From 89ca089ab21249cbafb935ce4a71d9797d49580a Mon Sep 17 00:00:00 2001 From: jarolrod Date: Wed, 1 Feb 2023 04:05:09 -0500 Subject: [PATCH] qml: initial custom data directory support --- src/qml/components/StorageLocations.qml | 15 +++++++++++++++ src/qml/controls/OptionButton.qml | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/qml/components/StorageLocations.qml b/src/qml/components/StorageLocations.qml index 241477e775..2a3988cb2b 100644 --- a/src/qml/components/StorageLocations.qml +++ b/src/qml/components/StorageLocations.qml @@ -5,6 +5,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 +import QtQuick.Dialogs 1.3 import "../controls" ColumnLayout { @@ -21,9 +22,23 @@ ColumnLayout { checked: true } OptionButton { + id: customDirOption Layout.fillWidth: true ButtonGroup.group: group text: qsTr("Custom") description: qsTr("Choose the directory and storage device.") + customDir: fileDialog.folder + onClicked: fileDialog.open() } + + FileDialog { + id: fileDialog + title: qsTr("Please choose a directory") + selectFolder: true + folder: shortcuts.home + onAccepted: { + customDirOption.customDir = fileDilog.folder + } + } + } diff --git a/src/qml/controls/OptionButton.qml b/src/qml/controls/OptionButton.qml index ef459ce8be..1e16f1ade5 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 @@ -80,6 +81,27 @@ 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 + } + } + } } Item { height: parent.height