From afb72301684129cd6436f0f5ee2f6feff56ca40e Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 22 Feb 2017 13:49:07 +0100 Subject: [PATCH] feat(ui/views/App/Settings/SettingsUi): view in progress, add a `FileChooserButton` component --- linphone-desktop/assets/images/file.png | Bin 0 -> 596 bytes linphone-desktop/assets/languages/en.ts | 15 +++ linphone-desktop/assets/languages/fr.ts | 15 +++ linphone-desktop/resources.qrc | 3 + .../Common/Form/Buttons/FileChooserButton.qml | 93 ++++++++++++++++++ .../Common/Form/Fields/NumericField.qml | 8 +- .../modules/Common/Form/Fields/TextField.qml | 5 + .../Form/Buttons/FileChooserButtonStyle.qml | 22 +++++ .../ui/modules/Common/Styles/qmldir | 1 + linphone-desktop/ui/modules/Common/qmldir | 1 + linphone-desktop/ui/scripts/Utils/utils.js | 18 +++- .../ui/views/App/Settings/SettingsUi.qml | 42 ++++++++ 12 files changed, 214 insertions(+), 9 deletions(-) create mode 100644 linphone-desktop/assets/images/file.png create mode 100644 linphone-desktop/ui/modules/Common/Form/Buttons/FileChooserButton.qml create mode 100644 linphone-desktop/ui/modules/Common/Styles/Form/Buttons/FileChooserButtonStyle.qml diff --git a/linphone-desktop/assets/images/file.png b/linphone-desktop/assets/images/file.png new file mode 100644 index 0000000000000000000000000000000000000000..188c12c144a1fcf583243ff3e60bfce36131f401 GIT binary patch literal 596 zcmV-a0;~OrP)Ll1)g|Q5400@Be=`iYfN}0R=%RxhNv+gN%v_aw9E; z3JRi~5!9}2t9G>uY!yM9Xi*X5LZpZyEUHC>5kg-w>M)Kojx+yv?`<)oW{pC0;PBwS zch0@sqT|eJ$t)1ui{BdZ(M)Qibq`WXTJcxt@2bCGCW5zzk?yd`XHKS0N zoD-%C#>jZUM!r=mtqVIkN86@mHZ&Tq9^b-?DAW1e+<}qtz}-9dh~v2C$Rfh2Gd--_ z+DK9=;zf+f>;y>&mH5nvBg2<0-l!E1Pv!1~UMxVR2e zP!WoSDaM9BP%h2Pi>m?8a`n2+WDAPV<^%amhFop}%*}sit6s_sGX(=v#Z*yKGNWI~ z<^w)AW2Aq6p`mFNQ54}^l~IIqF=~Q}AW~UF2%thP^Mh Enable adaptive rate control + + SettingsUi + + pathsTitle + Paths + + + savedScreenshotsLabel + Saved screenshots folder + + + savedVideosLabel + Saved videos folder + + SettingsWindow diff --git a/linphone-desktop/assets/languages/fr.ts b/linphone-desktop/assets/languages/fr.ts index 2a56cb8e4..98b33137f 100644 --- a/linphone-desktop/assets/languages/fr.ts +++ b/linphone-desktop/assets/languages/fr.ts @@ -847,6 +847,21 @@ Url du serveur non configurée. Activer le contrôle de débit adaptif + + SettingsUi + + pathsTitle + Chemins + + + savedScreenshotsLabel + Dossier des captures d'écrans + + + savedVideosLabel + Dossier des captures vidéos + + SettingsWindow diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index caf6cd373..5e87b31dd 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -78,6 +78,7 @@ assets/images/edit_normal.svg assets/images/edit_pressed.svg assets/images/ended_call.svg + assets/images/file.png assets/images/file_sign.svg assets/images/filter.svg assets/images/fullscreen_hovered.svg @@ -177,6 +178,7 @@ ui/modules/Common/Form/ActionSwitch.qml ui/modules/Common/Form/Buttons/AbstractTextButton.qml ui/modules/Common/Form/Buttons/ExclusiveButtons.qml + ui/modules/Common/Form/Buttons/FileChooserButton.qml ui/modules/Common/Form/Buttons/SmallButton.qml ui/modules/Common/Form/Buttons/TextButtonA.qml ui/modules/Common/Form/Buttons/TextButtonB.qml @@ -224,6 +226,7 @@ ui/modules/Common/Styles/Form/ActionBarStyle.qml ui/modules/Common/Styles/Form/Buttons/AbstractTextButtonStyle.qml ui/modules/Common/Styles/Form/Buttons/ExclusiveButtonsStyle.qml + ui/modules/Common/Styles/Form/Buttons/FileChooserButtonStyle.qml ui/modules/Common/Styles/Form/Buttons/SmallButtonStyle.qml ui/modules/Common/Styles/Form/Buttons/TextButtonAStyle.qml ui/modules/Common/Styles/Form/Buttons/TextButtonBStyle.qml diff --git a/linphone-desktop/ui/modules/Common/Form/Buttons/FileChooserButton.qml b/linphone-desktop/ui/modules/Common/Form/Buttons/FileChooserButton.qml new file mode 100644 index 000000000..2c549e850 --- /dev/null +++ b/linphone-desktop/ui/modules/Common/Form/Buttons/FileChooserButton.qml @@ -0,0 +1,93 @@ +import QtQuick 2.7 +import QtQuick.Dialogs 1.2 + +import Common 1.0 +import Common.Styles 1.0 +import Utils 1.0 + +// ============================================================================= + +TextField { + id: textField + + // --------------------------------------------------------------------------- + + property alias selectExisting: fileDialog.selectExisting + property alias selectFolder: fileDialog.selectFolder + property alias title: fileDialog.title + + property string selectedFile: '' + + // --------------------------------------------------------------------------- + + signal accepted (var selectedFile) + signal rejected + + // --------------------------------------------------------------------------- + + text: { + var path = textField.selectedFile + return path.length ? Utils.basename(path) : '' + } + + tools: Item { + height: parent.height + width: FileChooserButtonStyle.tools.width + + Rectangle { + anchors { + fill: parent + margins: TextFieldStyle.background.border.width + } + + color: mouseArea.pressed + ? FileChooserButtonStyle.tools.button.color.pressed + : ( + mouseArea.containsMouse + ? FileChooserButtonStyle.tools.button.color.hovered + : FileChooserButtonStyle.tools.button.color.normal + ) + + Icon { + anchors.centerIn: parent + // TODO: Set icon file or folder. + iconSize: FileChooserButtonStyle.tools.button.iconSize + } + } + } + + // --------------------------------------------------------------------------- + + FileDialog { + id: fileDialog + + folder: { + if (!textField.selectedFile.length) { + return '' + } + + var folder = Utils.dirname(textField.selectedFile) + return !Utils.startsWith(folder, 'file:') + ? 'file:' + folder + : folder + } + + onAccepted: { + textField.selectedFile = fileUrl.toString().substring(7) + textField.accepted(textField.selectedFile) + } + + onRejected: textField.rejected() + } + + // --------------------------------------------------------------------------- + + MouseArea { + id: mouseArea + + anchors.fill: parent + hoverEnabled: true + + onClicked: fileDialog.open() + } +} diff --git a/linphone-desktop/ui/modules/Common/Form/Fields/NumericField.qml b/linphone-desktop/ui/modules/Common/Form/Fields/NumericField.qml index 7efce9c25..2060e44c3 100644 --- a/linphone-desktop/ui/modules/Common/Form/Fields/NumericField.qml +++ b/linphone-desktop/ui/modules/Common/Form/Fields/NumericField.qml @@ -35,13 +35,7 @@ TextField { text: minValue - tools: Rectangle { - border { - color: TextFieldStyle.background.border.color - width: TextFieldStyle.background.border.width - } - color: 'transparent' // Not a style. - + tools: Item { height: parent.height width: NumericFieldStyle.tools.width diff --git a/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml b/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml index 30c6ea61c..399a500b7 100644 --- a/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml +++ b/linphone-desktop/ui/modules/Common/Form/Fields/TextField.qml @@ -38,6 +38,11 @@ Controls.TextField { Rectangle { id: toolsContainer + border { + color: TextFieldStyle.background.border.color + width: TextFieldStyle.background.border.width + } + anchors.fill: parent color: background.color data: tools || [] diff --git a/linphone-desktop/ui/modules/Common/Styles/Form/Buttons/FileChooserButtonStyle.qml b/linphone-desktop/ui/modules/Common/Styles/Form/Buttons/FileChooserButtonStyle.qml new file mode 100644 index 000000000..b03adab02 --- /dev/null +++ b/linphone-desktop/ui/modules/Common/Styles/Form/Buttons/FileChooserButtonStyle.qml @@ -0,0 +1,22 @@ +pragma Singleton +import QtQuick 2.7 + +import Common 1.0 + +// ============================================================================= + +QtObject { + property QtObject tools: QtObject { + property int width: 30 + + property QtObject button: QtObject { + property int iconSize: 16 + + property QtObject color: QtObject { + property color hovered: Colors.c + property color normal: Colors.q + property color pressed: Colors.c + } + } + } +} diff --git a/linphone-desktop/ui/modules/Common/Styles/qmldir b/linphone-desktop/ui/modules/Common/Styles/qmldir index 1d2563f0d..052097cd8 100644 --- a/linphone-desktop/ui/modules/Common/Styles/qmldir +++ b/linphone-desktop/ui/modules/Common/Styles/qmldir @@ -10,6 +10,7 @@ singleton DialogStyle 1.0 Dialog/DialogStyle.qml singleton AbstractTextButtonStyle 1.0 Form/Buttons/AbstractTextButtonStyle.qml singleton ExclusiveButtonsStyle 1.0 Form/Buttons/ExclusiveButtonsStyle.qml +singleton FileChooserButtonStyle 1.0 Form/Buttons/FileChooserButtonStyle.qml singleton SmallButtonStyle 1.0 Form/Buttons/SmallButtonStyle.qml singleton TextButtonAStyle 1.0 Form/Buttons/TextButtonAStyle.qml singleton TextButtonBStyle 1.0 Form/Buttons/TextButtonBStyle.qml diff --git a/linphone-desktop/ui/modules/Common/qmldir b/linphone-desktop/ui/modules/Common/qmldir index 8e1f5aeba..130dba8a2 100644 --- a/linphone-desktop/ui/modules/Common/qmldir +++ b/linphone-desktop/ui/modules/Common/qmldir @@ -29,6 +29,7 @@ TransparentComboBox 1.0 Form/TransparentComboBox.qml TransparentTextInput 1.0 Form/TransparentTextInput.qml ExclusiveButtons 1.0 Form/Buttons/ExclusiveButtons.qml +FileChooserButton 1.0 Form/Buttons/FileChooserButton.qml TextButtonA 1.0 Form/Buttons/TextButtonA.qml TextButtonB 1.0 Form/Buttons/TextButtonB.qml diff --git a/linphone-desktop/ui/scripts/Utils/utils.js b/linphone-desktop/ui/scripts/Utils/utils.js index 4913b2e55..3289056be 100644 --- a/linphone-desktop/ui/scripts/Utils/utils.js +++ b/linphone-desktop/ui/scripts/Utils/utils.js @@ -262,13 +262,27 @@ function assert (condition, message) { // ----------------------------------------------------------------------------- function basename (str) { - return str.slice(str.lastIndexOf('/') + 1) + var str2 = str + var length = str2.length - 1 + + if (str2[length] === '/') { + str2 = str2.substring(0, length) + } + + return str2.slice(str2.lastIndexOf('/') + 1) } // ----------------------------------------------------------------------------- function dirname (str) { - return str.slice(0, str.lastIndexOf('/') + 1) + var str2 = str + var length = str2.length - 1 + + if (str2[length] === '/') { + str2 = str2.substring(0, length) + } + + return str2.slice(0, str2.lastIndexOf('/') + 1) } // ----------------------------------------------------------------------------- diff --git a/linphone-desktop/ui/views/App/Settings/SettingsUi.qml b/linphone-desktop/ui/views/App/Settings/SettingsUi.qml index f5c0de773..0d10e03a4 100644 --- a/linphone-desktop/ui/views/App/Settings/SettingsUi.qml +++ b/linphone-desktop/ui/views/App/Settings/SettingsUi.qml @@ -2,8 +2,50 @@ import QtQuick 2.7 import Common 1.0 +import App.Styles 1.0 + // ============================================================================= TabContainer { + Column { + spacing: SettingsWindowStyle.forms.spacing + width: parent.width + // ------------------------------------------------------------------------- + // Languages. + // ------------------------------------------------------------------------- + + // TODO + + // ------------------------------------------------------------------------- + // Paths. + // ------------------------------------------------------------------------- + + Form { + title: qsTr('pathsTitle') + width: parent.width + + FormLine { + FormGroup { + label: qsTr('savedScreenshotsLabel') + + FileChooserButton { + id: savedScreenshotsFolder + + selectFolder: true + } + } + + FormGroup { + label: qsTr('savedVideosLabel') + + FileChooserButton { + id: savedVideosFolder + + selectFolder: true + } + } + } + } + } }