X-Git-Url: https://www.flypig.org.uk/git/?p=openvpnui.git;a=blobdiff_plain;f=qml%2Ffilebrowse%2Fpages%2FConsolePage.qml;fp=qml%2Ffilebrowse%2Fpages%2FConsolePage.qml;h=96f487486b63fab98f346d6de85b567a4fff9257;hp=0000000000000000000000000000000000000000;hb=e24363e314aca32e7bee952f02f517a04a8dc5f2;hpb=ee3968ffa08d4e0fcbad87765efa3aeb32ff0554 diff --git a/qml/filebrowse/pages/ConsolePage.qml b/qml/filebrowse/pages/ConsolePage.qml new file mode 100644 index 0000000..96f4874 --- /dev/null +++ b/qml/filebrowse/pages/ConsolePage.qml @@ -0,0 +1,102 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import harbour.file.browser.FileInfo 1.0 +import "../components" + +Page { + id: page + allowedOrientations: Orientation.All + property string title: "" + property string command: "" + property variant arguments // this must be set to a string list, e.g. [ "arg1", "arg2" ] + property string initialText: qsTr("Installing...") + property string successText: qsTr("Successful") + property string infoText: "" + property color consoleColor: Theme.secondaryColor + + // execute command when page activates + onStatusChanged: { + if (status === PageStatus.Activating) { + fileInfo.executeCommand(page.command, page.arguments); + } + } + + FileInfo { + id: fileInfo + + // called when command exits + onProcessExited: { + busyIndicator.running = false; + if (exitCode == 0) { + statusLabel.text = page.successText; + infoLabel.text = page.infoText; + } else { + statusLabel.text = qsTr("Failed! Error code: %1").arg(exitCode); + } + } + } + + SilicaFlickable { + id: flickable + anchors.fill: parent + contentHeight: column.height + VerticalScrollDecorator { flickable: flickable } + + Column { + id: column + width: parent.width + + PageHeader { title: page.title } + + BusyIndicator { + id: busyIndicator + anchors.horizontalCenter: parent.horizontalCenter + running: true + size: BusyIndicatorSize.Small + } + Label { + id: statusLabel + anchors.horizontalCenter: parent.horizontalCenter + text: page.initialText + color: Theme.highlightColor + } + Label { + id: infoLabel + visible: text !== "" + text: "" + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: Theme.paddingLarge + anchors.rightMargin: Theme.paddingLarge + wrapMode: Text.Wrap + font.pixelSize: Theme.fontSizeTiny + horizontalAlignment: Text.AlignHCenter + color: Theme.secondaryColor + } + + Spacer { height: 40 } + + // command line text + Label { + width: parent.width + text: "$ "+page.command+" "+page.arguments.join(" ") + wrapMode: Text.WrapAnywhere + font.pixelSize: Theme.fontSizeTiny + font.family: "Monospace" + color: Theme.secondaryColor + } + + // command output + Label { + width: parent.width + text: fileInfo.processOutput + wrapMode: Text.WrapAnywhere + font.pixelSize: Theme.fontSizeTiny + font.family: "Monospace" + color: page.consoleColor + } + } + } +} + +