diff --git a/src/qml/components/StorageLocations.qml b/src/qml/components/StorageLocations.qml index b5fac4aa4d..acaa69b40a 100644 --- a/src/qml/components/StorageLocations.qml +++ b/src/qml/components/StorageLocations.qml @@ -17,33 +17,52 @@ ColumnLayout { } spacing: 15 OptionButton { + id: defaultDirOption Layout.fillWidth: true ButtonGroup.group: group text: qsTr("Default") description: qsTr("Your application directory.") - recommended: true - checked: true + customDir: optionsModel.getDefaultDataDirString + checked: optionsModel.dataDir === optionsModel.getDefaultDataDirString + onClicked: { + defaultDirOption.checked = true + optionsModel.dataDir = optionsModel.getDefaultDataDirString + } } OptionButton { + id: customDirOption Layout.fillWidth: true ButtonGroup.group: group text: qsTr("Custom") description: qsTr("Choose the directory and storage device.") + customDir: customDirOption.checked ? fileDialog.folder : "" + checked: optionsModel.dataDir !== optionsModel.getDefaultDataDirString onClicked: fileDialog.open() } FileDialog { id: fileDialog selectFolder: true - folder: optionsModel.getDefaultDataDirectory + folder: shortcuts.home onAccepted: { optionsModel.setCustomDataDirString(fileDialog.fileUrls[0].toString()) var customDataDir = fileDialog.fileUrl.toString(); if (customDataDir !== "") { - optionsModel.setCustomDataDirArgs(customDataDir); + optionsModel.setCustomDataDirArgs(customDataDir) + customDirOption.customDir = optionsModel.getCustomDataDirString() + if (optionsModel.dataDir !== optionsModel.getDefaultDataDirString) { + customDirOption.checked = true + defaultDirOption.checked = false + } } } onRejected: { console.log("Custom datadir selection canceled") + if (optionsModel.dataDir !== optionsModel.getDefaultDataDirString) { + customDirOption.checked = true + defaultDirOption.checked = false + } else { + defaultDirOption.checked = true + } } } } diff --git a/src/qml/components/StorageSettings.qml b/src/qml/components/StorageSettings.qml index 2a2951bfac..5916536934 100644 --- a/src/qml/components/StorageSettings.qml +++ b/src/qml/components/StorageSettings.qml @@ -58,4 +58,17 @@ ColumnLayout { loadedItem.forceActiveFocus() } } + Separator { Layout.fillWidth: true } + Setting { + id: customDataDirSetting + Layout.fillWidth: true + header: qsTr("Data Directory") + } + CoreText { + Layout.fillWidth: true + text: optionsModel.dataDir + color: Theme.color.neutral7 + font.pixelSize: 15 + horizontalAlignment: Text.AlignLeft + } } diff --git a/src/qml/controls/OptionButton.qml b/src/qml/controls/OptionButton.qml index ef459ce8be..2244c58465 100644 --- a/src/qml/controls/OptionButton.qml +++ b/src/qml/controls/OptionButton.qml @@ -11,6 +11,7 @@ Button { property string description property bool recommended: false property string image: "" + property string customDir: "" padding: 15 checkable: true implicitWidth: 450 @@ -24,6 +25,12 @@ Button { borderRadius: 14 } } + + MouseArea { + anchors.fill: parent + onClicked: button.clicked() + } + contentItem: RowLayout { spacing: 3 Loader { @@ -80,6 +87,28 @@ Button { } } } + Loader { + Layout.topMargin: 12 + Layout.fillWidth: true + active: button.customDir.length > 0 + visible: active + sourceComponent: Button { + id: container + background: Rectangle { + color: Theme.color.neutral2 + radius: 5 + } + font.family: "Inter" + font.styleName: "Semi Bold" + font.pixelSize: 13 + contentItem: Text { + font: container.font + color: Theme.color.neutral9 + text: button.customDir + wrapMode: Text.WordWrap + } + } + } } Item { height: parent.height