Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / pages / ConfigurePage.qml
index 1692d1e..1615c97 100644 (file)
 
 import QtQuick 2.0
 import Sailfish.Silica 1.0
+import "../components"
+import "../filebrowse/pages/functions.js" as Functions
 
 Dialog {
     id: configurePage
     canAccept: true
     acceptDestinationAction: PageStackAction.Pop
+    property int _fileDialogue: 0
 
     Connections {
         target:VpnControl
     }
 
+    // connect signals from engine to panels
+    Connections {
+        target: engine
+        onSelectedFilenameChanged: {
+            switch (_fileDialogue) {
+                case 1:
+                    caCertFilename.value = engine.selectedFilename
+                    break;
+                case 2:
+                    clientCertFilename.value = engine.selectedFilename
+                    break;
+                case 3:
+                    clientKeyFilename.value = engine.selectedFilename
+                    break;
+                case 4:
+                    tlsKeyFilename.value = engine.selectedFilename
+                    break;
+            }
+            _fileDialogue = 0;
+        }
+    }
+
+
     SilicaFlickable {
         // ComboBox requires a flickable ancestor
         width: parent.width
@@ -95,10 +121,6 @@ Dialog {
                 id: configureTLS
                 text: "Use TLS authentication"
                 checked: VpnControl.useTLS
-                onCheckedChanged: {
-                    configureTLSdirection.enabled = checked
-                    configureTLSinfo.visible = checked
-                }
                 automaticCheck: true
             }
             // set currentIndex to change the selected value
@@ -107,7 +129,7 @@ Dialog {
                 width: parent.width
                 label: "TLS direction"
                 currentIndex: VpnControl.tlsDirection;
-                enabled: false
+                enabled: configureTLS.checked
 
                 menu: ContextMenu {
                     MenuItem { text: "0" }
@@ -115,46 +137,50 @@ Dialog {
                 }
             }
 
-            Button {
-                id: connect
-                text: "Select key"
-                enabled: true
-                onClicked: VpnControl.vpnConnect()
+            ValueButtonAlignRight {
+                id: caCertFilename
+                label: "CA cert"
+                value: "Select"
+                width: parent.width
+                onClicked: {
+                    _fileDialogue = 1
+                    Functions.goToInitial(Functions.folderFromFile(value), "crt")
+                }
             }
 
-            Label {
-                text: "Place key files on SD card:"
-                color: Theme.secondaryColor
-                font.pixelSize: Theme.fontSizeSmall
-                x: Theme.paddingLarge
-            }
-            Label {
-                text: "\tca.crt"
-                color: Theme.secondaryColor
-                font.pixelSize: Theme.fontSizeSmall
-                x: Theme.paddingLarge
-            }
-            Label {
-                text: "\tclient.crt"
-                color: Theme.secondaryColor
-                font.pixelSize: Theme.fontSizeSmall
-                x: Theme.paddingLarge
-            }
-            Label {
-                text: "\tclient.key"
-                color: Theme.secondaryColor
-                font.pixelSize: Theme.fontSizeSmall
-                x: Theme.paddingLarge
+            ValueButtonAlignRight {
+                id: clientCertFilename
+                value: "Select"
+                label: "Client cert"
+                width: parent.width
+                onClicked: {
+                    _fileDialogue = 2;
+                    Functions.goToInitial(Functions.folderFromFile(value), "crt")
+                }
             }
-            Label {
-                id: configureTLSinfo
-                visible: false
-                text: "\tta.key"
-                color: Theme.secondaryColor
-                font.pixelSize: Theme.fontSizeSmall
-                x: Theme.paddingLarge
+
+            ValueButtonAlignRight {
+                id: clientKeyFilename
+                value: "Select"
+                label: "Client key"
+                width: parent.width
+                onClicked: {
+                    _fileDialogue = 3;
+                    Functions.goToInitial(Functions.folderFromFile(value), "key")
+                }
             }
 
+            ValueButtonAlignRight {
+                id: tlsKeyFilename
+                value: "Select"
+                label: "TLS key"
+                width: parent.width
+                enabled: configureTLS.checked
+                onClicked: {
+                    _fileDialogue = 4;
+                    Functions.goToInitial(Functions.folderFromFile(value), "key")
+                }
+            }
         }
     }