filedialog for qml moved to main.qml
This commit is contained in:
parent
4ab006f065
commit
c166327835
11 changed files with 213 additions and 52 deletions
|
|
@ -125,18 +125,8 @@ PageType {
|
|||
text: qsTr("Restore from backup")
|
||||
|
||||
onClicked: {
|
||||
openFileDialog.open()
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: openFileDialog
|
||||
acceptLabel: qsTr("Open backup file")
|
||||
nameFilters: [ "Backup files (*.backup)" ]
|
||||
onAccepted: {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.restoreAppConfig(openFileDialog.selectedFile.toString())
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
PageController.setupFileDialogForBackup()
|
||||
SystemController.getFileName()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ PageType {
|
|||
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN"
|
||||
defaultSuffix: ".log"
|
||||
onAccepted: {
|
||||
ExportController.saveFile(fileDialog.currentFile.toString())
|
||||
SettingsController.exportLogsFile(fileDialog.currentFile.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@ PageType {
|
|||
allExceptSites
|
||||
]
|
||||
|
||||
property bool replaceExistingSites
|
||||
|
||||
QtObject {
|
||||
id: onlyForwardSites
|
||||
property string name: qsTr("Only the addresses in the list must be opened via VPN")
|
||||
|
|
@ -303,7 +301,7 @@ PageType {
|
|||
|
||||
clickedFunction: function() {
|
||||
if (Qt.platform.os === "ios") {
|
||||
ExportController.saveFile("amezia_tunnel.json")
|
||||
SitesController.exportSites("amezia_tunnel.json")
|
||||
} else {
|
||||
saveFileDialog.open()
|
||||
}
|
||||
|
|
@ -311,6 +309,7 @@ PageType {
|
|||
|
||||
FileDialog {
|
||||
id: saveFileDialog
|
||||
objectName: saveFileDialog
|
||||
acceptLabel: qsTr("Save sites")
|
||||
nameFilters: [ "Sites files (*.json)" ]
|
||||
fileMode: FileDialog.SaveFile
|
||||
|
|
@ -378,8 +377,8 @@ PageType {
|
|||
text: qsTr("Replace site list")
|
||||
|
||||
clickedFunction: function() {
|
||||
root.replaceExistingSites = true
|
||||
openFileDialog.open()
|
||||
PageController.setupFileDialogForSites(true)
|
||||
SystemController.getFileName()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -390,25 +389,14 @@ PageType {
|
|||
text: qsTr("Add imported sites to existing ones")
|
||||
|
||||
clickedFunction: function() {
|
||||
root.replaceExistingSites = false
|
||||
openFileDialog.open()
|
||||
PageController.setupFileDialogForSites(false)
|
||||
SystemController.getFileName()
|
||||
importSitesDrawer.close()
|
||||
moreActionsDrawer.close()
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {}
|
||||
|
||||
FileDialog {
|
||||
id: openFileDialog
|
||||
acceptLabel: qsTr("Open sites file")
|
||||
nameFilters: [ "Sites files (*.json)" ]
|
||||
onAccepted: {
|
||||
PageController.showBusyIndicator(true)
|
||||
SitesController.importSites(openFileDialog.selectedFile.toString(), replaceExistingSites)
|
||||
importSitesDrawer.close()
|
||||
moreActionsDrawer.close()
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,28 +65,13 @@ It's okay as long as it's from someone you trust.")
|
|||
Layout.fillWidth: true
|
||||
Layout.topMargin: 16
|
||||
|
||||
text: qsTr("File with connection settings or backup")
|
||||
text: !ServersModel.getServersCount() ? qsTr("File with connection settings or backup") : qsTr("File with connection settings")
|
||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||
leftImageSource: "qrc:/images/controls/folder-open.svg"
|
||||
|
||||
clickedFunction: function() {
|
||||
fileDialog.open()
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
acceptLabel: qsTr("Open config file")
|
||||
nameFilters: [ "Config or backup files (*.vpn *.ovpn *.conf *.backup)" ]
|
||||
onAccepted: {
|
||||
if (fileDialog.selectedFile.toString().indexOf(".backup") != -1) {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.restoreAppConfig(fileDialog.selectedFile.toString())
|
||||
PageController.showBusyIndicator(false)
|
||||
} else {
|
||||
ImportController.extractConfigFromFile(fileDialog.selectedFile.toString())
|
||||
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
|
||||
}
|
||||
}
|
||||
PageController.setupFileDialogForConfig()
|
||||
SystemController.getFileName()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import QtQuick
|
|||
import QtQuick.Window
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Dialogs
|
||||
|
||||
import PageEnum 1.0
|
||||
|
||||
|
|
@ -10,6 +11,7 @@ import "Controls2"
|
|||
|
||||
Window {
|
||||
id: root
|
||||
objectName: "mainWindow"
|
||||
visible: true
|
||||
width: GC.screenWidth
|
||||
height: GC.screenHeight
|
||||
|
|
@ -79,6 +81,42 @@ Window {
|
|||
function onShowPassphraseRequestDrawer() {
|
||||
privateKeyPassphraseDrawer.open()
|
||||
}
|
||||
|
||||
function onSetupFileDialogForConfig() {
|
||||
mainFileDialog.acceptLabel = qsTr("Open config file")
|
||||
mainFileDialog.nameFilters = !ServersModel.getServersCount() ? [ "Config or backup files (*.vpn *.ovpn *.conf *.backup)" ] :
|
||||
[ "Config files (*.vpn *.ovpn *.conf)" ]
|
||||
mainFileDialog.acceptFunction = function() {
|
||||
if (mainFileDialog.selectedFile.toString().indexOf(".backup") !== -1 && !ServersModel.getServersCount()) {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.restoreAppConfig(mainFileDialog.selectedFile.toString())
|
||||
PageController.showBusyIndicator(false)
|
||||
} else {
|
||||
ImportController.extractConfigFromFile(mainFileDialog.selectedFile)
|
||||
PageController.goToPage(PageEnum.PageSetupWizardViewConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSetupFileDialogForSites(replaceExistingSites) {
|
||||
mainFileDialog.acceptLabel = qsTr("Open sites file")
|
||||
mainFileDialog.nameFilters = [ "Sites files (*.json)" ]
|
||||
mainFileDialog.acceptFunction = function() {
|
||||
PageController.showBusyIndicator(true)
|
||||
SitesController.importSites(mainFileDialog.selectedFile.toString(), replaceExistingSites)
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
|
||||
function onSetupFileDialogForBackup() {
|
||||
mainFileDialog.acceptLabel = qsTr("Open backup file")
|
||||
mainFileDialog.nameFilters = [ "Backup files (*.backup)" ]
|
||||
mainFileDialog.acceptFunction = function() {
|
||||
PageController.showBusyIndicator(true)
|
||||
SettingsController.restoreAppConfig(mainFileDialog.selectedFile.toString())
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
|
@ -192,4 +230,14 @@ Window {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: mainFileDialog
|
||||
|
||||
property var acceptFunction
|
||||
|
||||
objectName: "mainFileDialog"
|
||||
|
||||
onAccepted: acceptFunction()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue