Skip to content

Commit 36467ea

Browse files
committed
qml: UI only display datadir functionality
1 parent a31878b commit 36467ea

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

src/qml/components/StorageLocations.qml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,47 @@ 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()
3341
}
3442
FileDialog {
3543
id: fileDialog
3644
selectFolder: true
37-
folder: optionsModel.getDefaultDataDirectory
45+
folder: shortcuts.home
3846
onAccepted: {
3947
optionsModel.setCustomDataDirString(fileDialog.fileUrls[0].toString())
4048
var customDataDir = fileDialog.fileUrl.toString();
4149
if (customDataDir !== "") {
4250
optionsModel.setCustomDataDirArgs(customDataDir);
51+
customDirOption.customDir = optionsModel.getCustomDataDirString();
4352
}
4453
}
4554
onRejected: {
4655
console.log("Custom datadir selection canceled")
56+
if (fileDialog.folder == shortcuts.home) {
57+
defaultDirOption.checked = true
58+
} else {
59+
customDirOption.customDir = optionsModel.getCustomDataDirString()
60+
}
4761
}
4862
}
4963
}

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)