fix: double call filepicker

This commit is contained in:
NickVs2015
2026-06-17 11:35:37 +03:00
parent 8ce5237a5f
commit ebffda68c2
2 changed files with 30 additions and 4 deletions
@@ -17,6 +17,8 @@ import "../Controls2/TextTypes"
PageType {
id: root
property bool isRestoringBackup: false
Connections {
target: SettingsController
@@ -138,9 +140,14 @@ PageType {
textColor: AmneziaStyle.color.paleGray
borderWidth: 1
enabled: !root.isRestoringBackup
text: qsTr("Restore from backup")
clickedFunc: function() {
if (root.isRestoringBackup) {
return
}
var filePath = SystemController.getFileName(qsTr("Open backup file"),
qsTr("Backup files (*.backup)"))
if (filePath !== "") {
@@ -152,6 +159,10 @@ PageType {
}
function restoreBackup(filePath) {
if (root.isRestoringBackup) {
return
}
var headerText = qsTr("Import settings from a backup file?")
var descriptionText = qsTr("All current settings will be reset");
var yesButtonText = qsTr("Continue")
@@ -161,9 +172,13 @@ PageType {
if (ConnectionController.isConnected) {
PageController.showNotificationMessage(qsTr("Cannot restore backup settings during active connection"))
} else {
root.isRestoringBackup = true
PageController.showBusyIndicator(true)
Qt.callLater(function() {
SettingsController.restoreAppConfig(filePath)
PageController.showBusyIndicator(false)
root.isRestoringBackup = false
})
}
}
var noButtonFunction = function() {
@@ -16,6 +16,8 @@ import "../Config"
PageType {
id: root
property bool isRestoringBackup: false
Connections {
target: ImportController
@@ -228,6 +230,8 @@ PageType {
rightImageSource: "qrc:/images/controls/chevron-right.svg"
leftImageSource: imageSource
enabled: !root.isRestoringBackup
onClicked: { handler() }
Keys.onEnterPressed: this.clicked()
@@ -314,12 +318,19 @@ PageType {
property string imageSource: "qrc:/images/controls/archive-restore.svg"
property bool isVisible: PageController.isStartPageVisible()
property var handler: function() {
if (root.isRestoringBackup) {
return
}
var filePath = SystemController.getFileName(qsTr("Open backup file"),
qsTr("Backup files (*.backup)"))
if (filePath !== "") {
root.isRestoringBackup = true
PageController.showBusyIndicator(true)
Qt.callLater(function() {
SettingsController.restoreAppConfig(filePath)
PageController.showBusyIndicator(false)
root.isRestoringBackup = false
})
}
}
}