aboutsummaryrefslogtreecommitdiff
path: root/qml/CommandInput.qml
diff options
context:
space:
mode:
Diffstat (limited to 'qml/CommandInput.qml')
-rw-r--r--qml/CommandInput.qml63
1 files changed, 63 insertions, 0 deletions
diff --git a/qml/CommandInput.qml b/qml/CommandInput.qml
new file mode 100644
index 0000000..835ccae
--- /dev/null
+++ b/qml/CommandInput.qml
@@ -0,0 +1,63 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.1
+import Qt.labs.settings 1.0
+
+Item {
+ id: item
+
+ visible: false
+
+ Settings {
+ id: settings
+ category: "command"
+
+ property color background : "black"
+ property int fontSize : 12
+ property string fontFamily : "Monospace"
+ property color fontColor : "white"
+ }
+
+ function focus() {
+ visible = true;
+ command.forceActiveFocus();
+ }
+
+ function unfocus() {
+ visible = false;
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ color: settings.background
+
+ TextInput {
+ id: command
+
+ font {
+ family: settings.fontFamily
+ pointSize: settings.fontSize
+ }
+
+ color: settings.fontColor
+ selectionColor: settings.fontColor
+ selectedTextColor: settings.background
+ text: ":"
+
+ selectByMouse: true
+
+ onAccepted: {
+ const prefix = String(text).charAt(0);
+ const cmd = String(text).substring(1, String(text).length);
+
+ switch ( prefix ) {
+ case ':': {
+ eval(cmd);
+ text = ':';
+ break;
+ }
+ default: { }
+ }
+ }
+ }
+ }
+}