aboutsummaryrefslogtreecommitdiff
path: root/qml/StateHandler.qml
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-07-20 21:02:54 +0200
committerAdrian Kummerlaender2015-07-20 21:02:54 +0200
commit84f2d6febc9344261dcb59c022f293f4f0de3d9a (patch)
tree82c571512b64bf8d615f6513597c4059ea0ab3d1 /qml/StateHandler.qml
parenteca10a1bd5b1f6186d280848bc102e0503c7b487 (diff)
downloadMetaTerm-84f2d6febc9344261dcb59c022f293f4f0de3d9a.tar
MetaTerm-84f2d6febc9344261dcb59c022f293f4f0de3d9a.tar.gz
MetaTerm-84f2d6febc9344261dcb59c022f293f4f0de3d9a.tar.bz2
MetaTerm-84f2d6febc9344261dcb59c022f293f4f0de3d9a.tar.lz
MetaTerm-84f2d6febc9344261dcb59c022f293f4f0de3d9a.tar.xz
MetaTerm-84f2d6febc9344261dcb59c022f293f4f0de3d9a.tar.zst
MetaTerm-84f2d6febc9344261dcb59c022f293f4f0de3d9a.zip
Moved UI mode implementation into separate `StateHandler`
`ApplicationWindow` doesn't offer QML State support but as this functionality lends itself quite well to the _Vim like_ UI mode paradigm it was moved into a `Item` based component.
Diffstat (limited to 'qml/StateHandler.qml')
-rw-r--r--qml/StateHandler.qml98
1 files changed, 98 insertions, 0 deletions
diff --git a/qml/StateHandler.qml b/qml/StateHandler.qml
new file mode 100644
index 0000000..4334a6b
--- /dev/null
+++ b/qml/StateHandler.qml
@@ -0,0 +1,98 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.2
+
+Item {
+ id: item
+
+ property Item terminalList : null
+
+ state: "INSERT"
+
+ function enterInsertMode() {
+ insertTerminalAction.trigger();
+ }
+
+ states: [
+ State {
+ name: "NORMAL"
+
+ PropertyChanges { target: escapeTerminalAction; enabled: false }
+ PropertyChanges { target: insertTerminalAction; enabled: true }
+ PropertyChanges { target: nextTerminalAction; enabled: true }
+ PropertyChanges { target: heightenTerminalAction; enabled: true }
+ PropertyChanges { target: shortenTerminalAction; enabled: true }
+ PropertyChanges { target: prevTerminalAction; enabled: true }
+ PropertyChanges { target: lastTerminalAction; enabled: true }
+ PropertyChanges { target: firstTerminalAction; enabled: true }
+ },
+ State {
+ name: "INSERT"
+
+ PropertyChanges { target: escapeTerminalAction; enabled: true }
+ PropertyChanges { target: insertTerminalAction; enabled: false }
+ PropertyChanges { target: nextTerminalAction; enabled: false }
+ PropertyChanges { target: heightenTerminalAction; enabled: false }
+ PropertyChanges { target: shortenTerminalAction; enabled: false }
+ PropertyChanges { target: prevTerminalAction; enabled: false }
+ PropertyChanges { target: lastTerminalAction; enabled: false }
+ PropertyChanges { target: firstTerminalAction; enabled: false }
+ }
+ ]
+
+ Action {
+ id: insertTerminalAction
+ shortcut: "i"
+ onTriggered: {
+ item.state = "INSERT";
+
+ terminalList.focusCurrent();
+ }
+ }
+
+ Action {
+ id: escapeTerminalAction
+ shortcut: "Shift+ESC"
+ onTriggered: {
+ item.state = "NORMAL";
+
+ terminalList.forceActiveFocus();
+ terminalList.unfocusCurrent();
+ }
+ }
+
+ Action {
+ id: nextTerminalAction
+ shortcut: "j"
+ onTriggered: terminalList.selectNext()
+ }
+
+ Action {
+ id: heightenTerminalAction
+ shortcut: "Shift+J"
+ onTriggered: terminalList.getCurrent().heighten()
+ }
+
+ Action {
+ id: shortenTerminalAction
+ shortcut: "Shift+K"
+ onTriggered: terminalList.getCurrent().shorten()
+ }
+
+ Action {
+ id: prevTerminalAction
+ shortcut: "k"
+ onTriggered: terminalList.selectPrev()
+ }
+
+ Action {
+ id: lastTerminalAction
+ shortcut: "Shift+G"
+ onTriggered: terminalList.selectItem(terminalList.children.length - 1)
+ }
+
+ Action {
+ id: firstTerminalAction
+ shortcut: "g"
+ onTriggered: terminalList.selectItem(0)
+ }
+}