Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / filebrowse / pages / CreateFolderDialog.qml
diff --git a/qml/filebrowse/pages/CreateFolderDialog.qml b/qml/filebrowse/pages/CreateFolderDialog.qml
new file mode 100644 (file)
index 0000000..d228fba
--- /dev/null
@@ -0,0 +1,64 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import "../components"
+
+Dialog {
+    property string path: ""
+
+    // return value
+    property string errorMessage: ""
+
+    id: dialog
+    allowedOrientations: Orientation.All
+    canAccept: folderName.text !== ""
+
+    onAccepted: errorMessage = engine.mkdir(path, folderName.text);
+
+    SilicaFlickable {
+        id: flickable
+        anchors.fill: parent
+        contentHeight: column.height
+        VerticalScrollDecorator { flickable: flickable }
+
+        Column {
+            id: column
+            anchors.left: parent.left
+            anchors.right: parent.right
+
+            DialogHeader {
+                id: dialogHeader
+                title: qsTr("Create Folder")
+                acceptText: qsTr("Create")
+            }
+
+            Label {
+                anchors.left: parent.left
+                anchors.right: parent.right
+                anchors.leftMargin: Theme.paddingLarge
+                anchors.rightMargin: Theme.paddingLarge
+                text: qsTr("Create a new folder under\n%1").arg(path)
+                color: Theme.secondaryColor
+                wrapMode: Text.Wrap
+            }
+
+            Spacer {
+                height: 20
+            }
+
+            TextField {
+                id: folderName
+                width: parent.width
+                placeholderText: qsTr("Folder name")
+                label: qsTr("Folder name")
+                focus: true
+
+                // return key on virtual keyboard accepts the dialog
+                EnterKey.enabled: folderName.text.length > 0
+                EnterKey.iconSource: "image://theme/icon-m-enter-accept"
+                EnterKey.onClicked: dialog.accept()
+            }
+        }
+    }
+}
+
+