reworking of getting the path to the file when saving/opening files
This commit is contained in:
parent
e1fa24c251
commit
b5dd48ad7b
21 changed files with 167 additions and 243 deletions
|
@ -84,31 +84,22 @@ PageType {
|
|||
text: qsTr("Make a backup")
|
||||
|
||||
onClicked: {
|
||||
var fileName = ""
|
||||
if (GC.isMobile()) {
|
||||
backupAppConfig("AmneziaVPN.backup")
|
||||
fileName = "AmneziaVPN.backup"
|
||||
} else {
|
||||
saveFileDialog.open()
|
||||
fileName = SystemController.getFileName(qsTr("Save backup file"),
|
||||
qsTr("Backup files (*.backup)"),
|
||||
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN",
|
||||
true,
|
||||
".backup")
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: saveFileDialog
|
||||
acceptLabel: qsTr("Save backup file")
|
||||
nameFilters: [ "Backup files (*.backup)" ]
|
||||
fileMode: FileDialog.SaveFile
|
||||
|
||||
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN"
|
||||
defaultSuffix: ".backup"
|
||||
onAccepted: {
|
||||
makeBackupButton.backupAppConfig(saveFileDialog.currentFile.toString())
|
||||
if (fileName !== "") {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.backupAppConfig(fileName)
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
|
||||
function backupAppConfig(fileName) {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.backupAppConfig(fileName)
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
|
@ -125,8 +116,13 @@ PageType {
|
|||
text: qsTr("Restore from backup")
|
||||
|
||||
onClicked: {
|
||||
PageController.setupFileDialogForBackup()
|
||||
SystemController.getFileName()
|
||||
var fileName = SystemController.getFileName(qsTr("Open backup file"),
|
||||
qsTr("Backup files (*.backup)"))
|
||||
if (fileName !== "") {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.restoreAppConfig(fileName)
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,23 +101,20 @@ PageType {
|
|||
image: "qrc:/images/controls/save.svg"
|
||||
|
||||
onClicked: {
|
||||
var fileName = ""
|
||||
if (GC.isMobile()) {
|
||||
SettingsController.exportLogsFile("AmneziaVPN.log")
|
||||
fileName = "AmneziaVPN.log"
|
||||
} else {
|
||||
fileDialog.open()
|
||||
fileName = SystemController.getFileName(qsTr("Save logs"),
|
||||
qsTr("Logs files (*.log)"),
|
||||
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN",
|
||||
true,
|
||||
".log")
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
acceptLabel: qsTr("Save logs")
|
||||
nameFilters: [ "Logs files (*.log)" ]
|
||||
fileMode: FileDialog.SaveFile
|
||||
|
||||
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN"
|
||||
defaultSuffix: ".log"
|
||||
onAccepted: {
|
||||
SettingsController.exportLogsFile(fileDialog.currentFile.toString())
|
||||
if (fileName !== "") {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.exportLogsFile(fileName)
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,25 +300,19 @@ PageType {
|
|||
text: qsTr("Save site list")
|
||||
|
||||
clickedFunction: function() {
|
||||
var fileName = ""
|
||||
if (GC.isMobile()) {
|
||||
SitesController.exportSites("amezia_tunnel.json")
|
||||
fileName = "amnezia_sites.json"
|
||||
} else {
|
||||
saveFileDialog.open()
|
||||
fileName = SystemController.getFileName(qsTr("Save sites"),
|
||||
qsTr("Sites files (*.json)"),
|
||||
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/amnezia_sites",
|
||||
true,
|
||||
".json")
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: saveFileDialog
|
||||
objectName: saveFileDialog
|
||||
acceptLabel: qsTr("Save sites")
|
||||
nameFilters: [ "Sites files (*.json)" ]
|
||||
fileMode: FileDialog.SaveFile
|
||||
|
||||
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/sites"
|
||||
defaultSuffix: ".json"
|
||||
onAccepted: {
|
||||
if (fileName !== "") {
|
||||
PageController.showBusyIndicator(true)
|
||||
SitesController.exportSites(saveFileDialog.currentFile.toString())
|
||||
SitesController.exportSites(fileName)
|
||||
moreActionsDrawer.close()
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
|
@ -377,8 +371,11 @@ PageType {
|
|||
text: qsTr("Replace site list")
|
||||
|
||||
clickedFunction: function() {
|
||||
PageController.setupFileDialogForSites(true)
|
||||
SystemController.getFileName()
|
||||
var fileName = SystemController.getFileName(qsTr("Open sites file"),
|
||||
qsTr("Sites files (*.json)"))
|
||||
if (fileName !== "") {
|
||||
importSitesDrawerContent.importSites(fileName, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,13 +386,22 @@ PageType {
|
|||
text: qsTr("Add imported sites to existing ones")
|
||||
|
||||
clickedFunction: function() {
|
||||
PageController.setupFileDialogForSites(false)
|
||||
SystemController.getFileName()
|
||||
importSitesDrawer.close()
|
||||
moreActionsDrawer.close()
|
||||
var fileName = SystemController.getFileName(qsTr("Open sites file"),
|
||||
qsTr("Sites files (*.json)"))
|
||||
if (fileName !== "") {
|
||||
importSitesDrawerContent.importSites(fileName, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function importSites(fileName, replaceExistingSites) {
|
||||
PageController.showBusyIndicator(true)
|
||||
SitesController.importSites(fileName, replaceExistingSites)
|
||||
PageController.showBusyIndicator(false)
|
||||
importSitesDrawer.close()
|
||||
moreActionsDrawer.close()
|
||||
}
|
||||
|
||||
DividerType {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,19 @@ It's okay as long as it's from someone you trust.")
|
|||
leftImageSource: "qrc:/images/controls/folder-open.svg"
|
||||
|
||||
clickedFunction: function() {
|
||||
PageController.setupFileDialogForConfig()
|
||||
SystemController.getFileName()
|
||||
var nameFilter = !ServersModel.getServersCount() ? "Config or backup files (*.vpn *.ovpn *.conf *.backup)" :
|
||||
"Config files (*.vpn *.ovpn *.conf)"
|
||||
var fileName = SystemController.getFileName(qsTr("Open config file"), nameFilter)
|
||||
if (fileName !== "") {
|
||||
if (fileName.indexOf(".backup") !== -1 && !ServersModel.getServersCount()) {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.restoreAppConfig(fileName)
|
||||
PageController.showBusyIndicator(false)
|
||||
} else {
|
||||
ImportController.extractConfigFromFile(fileName)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue