Fix problems with browse of folder in settings dialog.

This commit is contained in:
Adam Treat 2023-07-09 13:05:06 -04:00
parent 58d6f40f50
commit d9f0245c1b
4 changed files with 23 additions and 19 deletions

View File

@ -53,14 +53,6 @@ MySettingsTab {
MySettings.userDefaultModel = comboBox.currentText
}
}
FolderDialog {
id: modelPathDialog
title: "Please choose a directory"
currentFolder: "file://" + MySettings.modelPath
onAccepted: {
MySettings.modelPath = selectedFolder
}
}
Label {
id: modelPathLabel
text: qsTr("Download path:")
@ -93,7 +85,11 @@ MySettingsTab {
Layout.column: 2
text: qsTr("Browse")
Accessible.description: qsTr("Opens a folder picker dialog to choose where to save model files")
onClicked: modelPathDialog.open()
onClicked: {
openFolderDialog("file://" + MySettings.modelPath, function(selectedFolder) {
MySettings.modelPath = selectedFolder
})
}
}
Label {
id: nThreadsLabel

View File

@ -21,15 +21,6 @@ MySettingsTab {
property alias collection: collection.text
property alias folder_path: folderEdit.text
FolderDialog {
id: folderDialog
title: "Please choose a directory"
currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation)
onAccepted: {
root.folder_path = selectedFolder
}
}
Item {
Layout.fillWidth: true
height: row.height
@ -79,7 +70,9 @@ MySettingsTab {
id: browseButton
text: qsTr("Browse")
onClicked: {
folderDialog.open();
openFolderDialog(StandardPaths.writableLocation(StandardPaths.HomeLocation), function(selectedFolder) {
root.folder_path = selectedFolder
})
}
}

View File

@ -3,6 +3,8 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Layouts
import QtQuick.Dialogs
import Qt.labs.folderlistmodel
import mysettings
Item {
@ -91,6 +93,17 @@ Item {
border.color: theme.tabBorder
}
FolderDialog {
id: folderDialog
title: qsTr("Please choose a directory")
}
function openFolderDialog(currentFolder, onAccepted) {
folderDialog.currentFolder = currentFolder;
folderDialog.accepted.connect(function() { onAccepted(folderDialog.currentFolder); });
folderDialog.open();
}
StackLayout {
id: stackLayout
anchors.top: tabTitlesModel.count > 1 ? dividerTabBar.bottom : titleLabel.bottom
@ -106,6 +119,7 @@ Item {
sourceComponent: model.modelData
onLoaded: {
settingsStack.tabTitlesModel.append({ "title": loader.item.title });
item.openFolderDialog = settingsStack.openFolderDialog;
}
}
}

View File

@ -9,6 +9,7 @@ Item {
property string title: ""
property Item contentItem: null
property Item advancedSettings: null
property var openFolderDialog
signal restoreDefaultsClicked
onContentItemChanged: function() {