Skip to content

Commit 2fbb27a

Browse files
committed
qml: UI only display datadir functionality
1 parent 61c180e commit 2fbb27a

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

src/qml/components/StorageLocations.qml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,52 @@ ColumnLayout {
1717
}
1818
spacing: 15
1919
OptionButton {
20+
id: defaultDirOption
2021
Layout.fillWidth: true
2122
ButtonGroup.group: group
2223
text: qsTr("Default")
2324
description: qsTr("Your application directory.")
25+
// customDir: optionsModel.getDefaultDataDirString // TODO: either delete or keep based on designer feedback
2426
recommended: true
2527
checked: true
28+
onClicked: {
29+
customDirOption.customDir = ""
30+
optionsModel.customDataDir = false
31+
}
2632
}
2733
OptionButton {
34+
id: customDirOption
2835
Layout.fillWidth: true
2936
ButtonGroup.group: group
3037
text: qsTr("Custom")
3138
description: qsTr("Choose the directory and storage device.")
39+
customDir: customDirOption.checked ? fileDialog.folder : ""
3240
onClicked: fileDialog.open()
41+
onCheckedChanged: {
42+
if (!customDirOption.checked) {
43+
customDirOption.customDir = ""
44+
}
45+
}
3346
}
3447
FileDialog {
3548
id: fileDialog
3649
selectFolder: true
37-
folder: optionsModel.getDefaultDataDirectory
50+
folder: shortcuts.home
3851
onAccepted: {
3952
optionsModel.setCustomDataDirString(fileDialog.fileUrls[0].toString())
4053
var customDataDir = fileDialog.fileUrl.toString();
4154
if (customDataDir !== "") {
4255
optionsModel.setCustomDataDirArgs(customDataDir);
56+
customDirOption.customDir = optionsModel.getCustomDataDirString();
4357
}
4458
}
4559
onRejected: {
4660
console.log("Custom datadir selection canceled")
61+
if (fileDialog.folder == shortcuts.home) {
62+
defaultDirOption.checked = true
63+
} else {
64+
customDirOption.customDir = optionsModel.getCustomDataDirString()
65+
}
4766
}
4867
}
4968
}

src/qml/components/StorageSettings.qml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,21 @@ ColumnLayout {
5858
loadedItem.forceActiveFocus()
5959
}
6060
}
61+
Separator { Layout.fillWidth: true }
62+
Setting {
63+
id: customDataDirSetting
64+
Layout.fillWidth: true
65+
header: qsTr("Data Directory")
66+
actionItem: ValueInput {
67+
parentState: "DISABLED"
68+
description: optionsModel.customDataDir ? optionsModel.getCustomDataDirString() : optionsModel.getDefaultDataDirString
69+
filled: true
70+
descriptionSize: 18
71+
textColor: Theme.color.neutral5
72+
validator: null
73+
maximumLength: 100
74+
width: 300
75+
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
76+
}
77+
}
6178
}

src/qml/controls/OptionButton.qml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Button {
1111
property string description
1212
property bool recommended: false
1313
property string image: ""
14+
property string customDir: ""
1415
padding: 15
1516
checkable: true
1617
implicitWidth: 450
@@ -80,6 +81,28 @@ Button {
8081
}
8182
}
8283
}
84+
Loader {
85+
Layout.topMargin: 12
86+
Layout.fillWidth: true
87+
active: button.customDir.length > 0
88+
visible: active
89+
sourceComponent: Button {
90+
id: container
91+
background: Rectangle {
92+
color: Theme.color.neutral2
93+
radius: 5
94+
}
95+
font.family: "Inter"
96+
font.styleName: "Semi Bold"
97+
font.pixelSize: 13
98+
contentItem: Text {
99+
font: container.font
100+
color: Theme.color.neutral9
101+
text: button.customDir
102+
wrapMode: Text.WordWrap
103+
}
104+
}
105+
}
83106
}
84107
Item {
85108
height: parent.height

0 commit comments

Comments
 (0)