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 {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property bool isRestoringBackup: false
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: SettingsController
|
target: SettingsController
|
||||||
|
|
||||||
@@ -138,9 +140,14 @@ PageType {
|
|||||||
textColor: AmneziaStyle.color.paleGray
|
textColor: AmneziaStyle.color.paleGray
|
||||||
borderWidth: 1
|
borderWidth: 1
|
||||||
|
|
||||||
|
enabled: !root.isRestoringBackup
|
||||||
|
|
||||||
text: qsTr("Restore from backup")
|
text: qsTr("Restore from backup")
|
||||||
|
|
||||||
clickedFunc: function() {
|
clickedFunc: function() {
|
||||||
|
if (root.isRestoringBackup) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var filePath = SystemController.getFileName(qsTr("Open backup file"),
|
var filePath = SystemController.getFileName(qsTr("Open backup file"),
|
||||||
qsTr("Backup files (*.backup)"))
|
qsTr("Backup files (*.backup)"))
|
||||||
if (filePath !== "") {
|
if (filePath !== "") {
|
||||||
@@ -152,6 +159,10 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function restoreBackup(filePath) {
|
function restoreBackup(filePath) {
|
||||||
|
if (root.isRestoringBackup) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var headerText = qsTr("Import settings from a backup file?")
|
var headerText = qsTr("Import settings from a backup file?")
|
||||||
var descriptionText = qsTr("All current settings will be reset");
|
var descriptionText = qsTr("All current settings will be reset");
|
||||||
var yesButtonText = qsTr("Continue")
|
var yesButtonText = qsTr("Continue")
|
||||||
@@ -161,9 +172,13 @@ PageType {
|
|||||||
if (ConnectionController.isConnected) {
|
if (ConnectionController.isConnected) {
|
||||||
PageController.showNotificationMessage(qsTr("Cannot restore backup settings during active connection"))
|
PageController.showNotificationMessage(qsTr("Cannot restore backup settings during active connection"))
|
||||||
} else {
|
} else {
|
||||||
|
root.isRestoringBackup = true
|
||||||
PageController.showBusyIndicator(true)
|
PageController.showBusyIndicator(true)
|
||||||
SettingsController.restoreAppConfig(filePath)
|
Qt.callLater(function() {
|
||||||
PageController.showBusyIndicator(false)
|
SettingsController.restoreAppConfig(filePath)
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
|
root.isRestoringBackup = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var noButtonFunction = function() {
|
var noButtonFunction = function() {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import "../Config"
|
|||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property bool isRestoringBackup: false
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: ImportController
|
target: ImportController
|
||||||
|
|
||||||
@@ -228,6 +230,8 @@ PageType {
|
|||||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||||
leftImageSource: imageSource
|
leftImageSource: imageSource
|
||||||
|
|
||||||
|
enabled: !root.isRestoringBackup
|
||||||
|
|
||||||
onClicked: { handler() }
|
onClicked: { handler() }
|
||||||
|
|
||||||
Keys.onEnterPressed: this.clicked()
|
Keys.onEnterPressed: this.clicked()
|
||||||
@@ -314,12 +318,19 @@ PageType {
|
|||||||
property string imageSource: "qrc:/images/controls/archive-restore.svg"
|
property string imageSource: "qrc:/images/controls/archive-restore.svg"
|
||||||
property bool isVisible: PageController.isStartPageVisible()
|
property bool isVisible: PageController.isStartPageVisible()
|
||||||
property var handler: function() {
|
property var handler: function() {
|
||||||
|
if (root.isRestoringBackup) {
|
||||||
|
return
|
||||||
|
}
|
||||||
var filePath = SystemController.getFileName(qsTr("Open backup file"),
|
var filePath = SystemController.getFileName(qsTr("Open backup file"),
|
||||||
qsTr("Backup files (*.backup)"))
|
qsTr("Backup files (*.backup)"))
|
||||||
if (filePath !== "") {
|
if (filePath !== "") {
|
||||||
|
root.isRestoringBackup = true
|
||||||
PageController.showBusyIndicator(true)
|
PageController.showBusyIndicator(true)
|
||||||
SettingsController.restoreAppConfig(filePath)
|
Qt.callLater(function() {
|
||||||
PageController.showBusyIndicator(false)
|
SettingsController.restoreAppConfig(filePath)
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
|
root.isRestoringBackup = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user