Skip to content

Commit 0c46cae

Browse files
committed
qml: UI only display datadir functionality
1 parent 489b60b commit 0c46cae

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

src/qml/components/StorageLocations.qml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,49 @@ 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-
checked: true
25+
customDir: optionsModel.getDefaultDataDirString
26+
checked: !optionsModel.customDataDir
27+
onClicked: {
28+
optionsModel.customDataDir = false
29+
defaultDirOption.checked = true
30+
}
2631
}
2732
OptionButton {
33+
id: customDirOption
2834
Layout.fillWidth: true
2935
ButtonGroup.group: group
3036
text: qsTr("Custom")
3137
description: qsTr("Choose the directory and storage device.")
38+
customDir: customDirOption.checked ? fileDialog.folder : ""
39+
checked: optionsModel.customDataDir
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+
defaultDirOption.checked = true
57+
optionsModel.customDataDir = false
58+
if (fileDialog.folder == shortcuts.home) {
59+
defaultDirOption.checked = true
60+
} else {
61+
customDirOption.customDir = optionsModel.getCustomDataDirString()
62+
}
4763
}
4864
}
4965
}

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+
}
67+
ValueInput {
68+
Layout.fillWidth: true
69+
parentState: "DIRECTORY"
70+
description: optionsModel.customDataDir ? optionsModel.getCustomDataDirString() : optionsModel.getDefaultDataDirString
71+
filled: true
72+
descriptionSize: 15
73+
validator: null
74+
maximumLength: 100
75+
horizontalAlignment: Text.AlignLeft
76+
wrapMode: Text.WordWrap
77+
}
6178
}

src/qml/controls/OptionButton.qml

Lines changed: 29 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
@@ -24,6 +25,12 @@ Button {
2425
borderRadius: 14
2526
}
2627
}
28+
29+
MouseArea {
30+
anchors.fill: parent
31+
onClicked: button.clicked()
32+
}
33+
2734
contentItem: RowLayout {
2835
spacing: 3
2936
Loader {
@@ -80,6 +87,28 @@ Button {
8087
}
8188
}
8289
}
90+
Loader {
91+
Layout.topMargin: 12
92+
Layout.fillWidth: true
93+
active: button.customDir.length > 0
94+
visible: active
95+
sourceComponent: Button {
96+
id: container
97+
background: Rectangle {
98+
color: Theme.color.neutral2
99+
radius: 5
100+
}
101+
font.family: "Inter"
102+
font.styleName: "Semi Bold"
103+
font.pixelSize: 13
104+
contentItem: Text {
105+
font: container.font
106+
color: Theme.color.neutral9
107+
text: button.customDir
108+
wrapMode: Text.WordWrap
109+
}
110+
}
111+
}
83112
}
84113
Item {
85114
height: parent.height

src/qml/controls/ValueInput.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ TextInput {
3636
enabled: false
3737
textColor: Theme.color.neutral4
3838
}
39+
},
40+
State {
41+
name: "DIRECTORY"
42+
PropertyChanges {
43+
target: root
44+
enabled: false
45+
textColor: Theme.color.neutral7
46+
}
3947
}
4048
]
4149

0 commit comments

Comments
 (0)