mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-20 02:00:55 +07:00
fix: double call filepicker
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user