X-Git-Url: https://www.flypig.org.uk/git/?p=openvpnui.git;a=blobdiff_plain;f=qml%2Ffilebrowse%2Fpages%2FRenameDialog.qml;fp=qml%2Ffilebrowse%2Fpages%2FRenameDialog.qml;h=2e0d11b2ef88f5e2adaa7ea026dd391240a7dc3e;hp=0000000000000000000000000000000000000000;hb=e24363e314aca32e7bee952f02f517a04a8dc5f2;hpb=ee3968ffa08d4e0fcbad87765efa3aeb32ff0554 diff --git a/qml/filebrowse/pages/RenameDialog.qml b/qml/filebrowse/pages/RenameDialog.qml new file mode 100644 index 0000000..2e0d11b --- /dev/null +++ b/qml/filebrowse/pages/RenameDialog.qml @@ -0,0 +1,74 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "functions.js" as Functions +import "../components" + +Dialog { + property string path: "" + + // return values + property string errorMessage: "" + property string newPath: "" + + id: dialog + allowedOrientations: Orientation.All + canAccept: newName.text !== "" + + onAccepted: { + var res = engine.rename(path, newName.text); + newPath = res[0] + errorMessage = res[1] + } + + Component.onCompleted: { + newName.text = Functions.lastPartOfPath(path) + } + + 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("Rename") + acceptText: qsTr("Rename") + } + + Label { + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: Theme.paddingLarge + anchors.rightMargin: Theme.paddingLarge + text: qsTr("Give a new name for\n%1").arg(path) + color: Theme.secondaryColor + wrapMode: Text.Wrap + } + + Spacer { + height: 20 + } + + TextField { + id: newName + width: parent.width + placeholderText: qsTr("New name") + label: qsTr("New name") + focus: true + + // return key on virtual keyboard accepts the dialog + EnterKey.enabled: newName.text.length > 0 + EnterKey.iconSource: "image://theme/icon-m-enter-accept" + EnterKey.onClicked: dialog.accept() + } + } + } +} + +