Skip to content

Commit 7341bdf

Browse files
committed
qml: UI only display datadir functionality
1 parent debca7c commit 7341bdf

File tree

3 files changed

+65
-4
lines changed

3 files changed

+65
-4
lines changed

src/qml/components/StorageLocations.qml

Lines changed: 23 additions & 4 deletions
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.")
24-
recommended: true
25-
checked: true
25+
customDir: optionsModel.getDefaultDataDirString
26+
checked: optionsModel.dataDir === optionsModel.getDefaultDataDirString
27+
onClicked: {
28+
defaultDirOption.checked = true
29+
optionsModel.dataDir = optionsModel.getDefaultDataDirString
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.dataDir !== optionsModel.getDefaultDataDirString
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 !== "") {
42-
optionsModel.setCustomDataDirArgs(customDataDir);
50+
optionsModel.setCustomDataDirArgs(customDataDir)
51+
customDirOption.customDir = optionsModel.getCustomDataDirString()
52+
if (optionsModel.dataDir !== optionsModel.getDefaultDataDirString) {
53+
customDirOption.checked = true
54+
defaultDirOption.checked = false
55+
}
4356
}
4457
}
4558
onRejected: {
4659
console.log("Custom datadir selection canceled")
60+
if (optionsModel.isCustomDataDirSet) {
61+
customDirOption.checked = true
62+
defaultDirOption.checked = false
63+
} else {
64+
defaultDirOption.checked = true
65+
}
4766
}
4867
}
4968
}

src/qml/components/StorageSettings.qml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,17 @@ 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+
CoreText {
68+
Layout.fillWidth: true
69+
text: optionsModel.dataDir
70+
color: Theme.color.neutral7
71+
font.pixelSize: 15
72+
horizontalAlignment: Text.AlignLeft
73+
}
6174
}

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

0 commit comments

Comments
 (0)