Skip to content

Commit 2a301e1

Browse files
committed
qml: UI only display datadir functionality
1 parent 489b60b commit 2a301e1

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

src/qml/components/StorageLocations.qml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,45 @@ 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.")
24-
recommended: true
25+
customDir: optionsModel.getDefaultDataDirString
2526
checked: true
27+
onClicked: {
28+
optionsModel.customDataDir = false
29+
}
2630
}
2731
OptionButton {
32+
id: customDirOption
2833
Layout.fillWidth: true
2934
ButtonGroup.group: group
3035
text: qsTr("Custom")
3136
description: qsTr("Choose the directory and storage device.")
37+
customDir: customDirOption.checked ? fileDialog.folder : ""
3238
onClicked: fileDialog.open()
3339
}
3440
FileDialog {
3541
id: fileDialog
3642
selectFolder: true
37-
folder: optionsModel.getDefaultDataDirectory
43+
folder: shortcuts.home
3844
onAccepted: {
3945
optionsModel.setCustomDataDirString(fileDialog.fileUrls[0].toString())
4046
var customDataDir = fileDialog.fileUrl.toString();
4147
if (customDataDir !== "") {
4248
optionsModel.setCustomDataDirArgs(customDataDir);
49+
customDirOption.customDir = optionsModel.getCustomDataDirString();
4350
}
4451
}
4552
onRejected: {
4653
console.log("Custom datadir selection canceled")
54+
if (fileDialog.folder == shortcuts.home) {
55+
defaultDirOption.checked = true
56+
} else {
57+
customDirOption.customDir = optionsModel.getCustomDataDirString()
58+
}
4759
}
4860
}
4961
}

src/qml/components/StorageSettings.qml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,22 @@ 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+
}
67+
ValueInput {
68+
Layout.fillWidth: true
69+
parentState: "DISABLED"
70+
description: optionsModel.customDataDir ? optionsModel.getCustomDataDirString() : optionsModel.getDefaultDataDirString
71+
filled: true
72+
descriptionSize: 15
73+
textColor: Theme.color.neutral5
74+
validator: null
75+
maximumLength: 100
76+
horizontalAlignment: Text.AlignLeft
77+
wrapMode: Text.WordWrap
78+
}
6179
}

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)