Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / qml / filebrowse / pages / CreateFolderDialog.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import "../components"
4
5 Dialog {
6     property string path: ""
7
8     // return value
9     property string errorMessage: ""
10
11     id: dialog
12     allowedOrientations: Orientation.All
13     canAccept: folderName.text !== ""
14
15     onAccepted: errorMessage = engine.mkdir(path, folderName.text);
16
17     SilicaFlickable {
18         id: flickable
19         anchors.fill: parent
20         contentHeight: column.height
21         VerticalScrollDecorator { flickable: flickable }
22
23         Column {
24             id: column
25             anchors.left: parent.left
26             anchors.right: parent.right
27
28             DialogHeader {
29                 id: dialogHeader
30                 title: qsTr("Create Folder")
31                 acceptText: qsTr("Create")
32             }
33
34             Label {
35                 anchors.left: parent.left
36                 anchors.right: parent.right
37                 anchors.leftMargin: Theme.paddingLarge
38                 anchors.rightMargin: Theme.paddingLarge
39                 text: qsTr("Create a new folder under\n%1").arg(path)
40                 color: Theme.secondaryColor
41                 wrapMode: Text.Wrap
42             }
43
44             Spacer {
45                 height: 20
46             }
47
48             TextField {
49                 id: folderName
50                 width: parent.width
51                 placeholderText: qsTr("Folder name")
52                 label: qsTr("Folder name")
53                 focus: true
54
55                 // return key on virtual keyboard accepts the dialog
56                 EnterKey.enabled: folderName.text.length > 0
57                 EnterKey.iconSource: "image://theme/icon-m-enter-accept"
58                 EnterKey.onClicked: dialog.accept()
59             }
60         }
61     }
62 }
63
64