Skip to content

Commit 802649e

Browse files
committed
qml: initial custom data directory support
1 parent baf09be commit 802649e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/qml/components/StorageLocations.qml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import QtQuick 2.15
66
import QtQuick.Controls 2.15
77
import QtQuick.Layouts 1.15
8+
import QtQuick.Dialogs 1.3
89
import "../controls"
910

1011
ColumnLayout {
@@ -21,9 +22,23 @@ ColumnLayout {
2122
checked: true
2223
}
2324
OptionButton {
25+
id: customDirOption
2426
Layout.fillWidth: true
2527
ButtonGroup.group: group
2628
text: qsTr("Custom")
2729
description: qsTr("Choose the directory and storage device.")
30+
customDir: fileDialog.folder
31+
onClicked: fileDialog.open()
2832
}
33+
34+
FileDialog {
35+
id: fileDialog
36+
title: qsTr("Please choose a directory")
37+
selectFolder: true
38+
folder: shortcuts.home
39+
onAccepted: {
40+
customDirOption.customDir = fileDilog.folder
41+
}
42+
}
43+
2944
}

src/qml/controls/OptionButton.qml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import QtQuick.Layouts 1.15
99
Button {
1010
property string description
1111
property bool recommended: false
12+
property string customDir: ""
1213
id: button
1314
padding: 15
1415
checkable: true
@@ -66,6 +67,27 @@ Button {
6667
}
6768
}
6869
}
70+
Loader {
71+
Layout.topMargin: 12
72+
Layout.fillWidth: true
73+
active: button.customDir.length > 0
74+
visible: active
75+
sourceComponent: Button {
76+
id: container
77+
background: Rectangle {
78+
color: Theme.color.neutral2
79+
radius: 5
80+
}
81+
font.family: "Inter"
82+
font.styleName: "Semi Bold"
83+
font.pixelSize: 13
84+
contentItem: Text {
85+
font: container.font
86+
color: Theme.color.neutral9
87+
text: button.customDir
88+
}
89+
}
90+
}
6991
}
7092
Item {
7193
height: parent.height

0 commit comments

Comments
 (0)