From 359c878cbfe97dafad328c748ae744b38a7dbd5b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 7 Aug 2015 14:42:32 +0200 Subject: Implemented basic command mode Exposes access to the application via JavaScript to the user. This will enable easy configuration changes as well as make more complex commands possible. All JavaScript entered in command mode is evaluated at the application root. --- qml/StateHandler.qml | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'qml/StateHandler.qml') diff --git a/qml/StateHandler.qml b/qml/StateHandler.qml index 4d226c9..8c78e2f 100644 --- a/qml/StateHandler.qml +++ b/qml/StateHandler.qml @@ -5,7 +5,8 @@ import Qt.labs.settings 1.0 Item { id: item - property Item terminalList : null + property Item terminalList : null + property CommandInput commandInput : null Settings { id: settings @@ -13,6 +14,7 @@ Item { property string insertMode : "i" property string normalMode : "Shift+ESC" + property string commandMode : ":" property string nextItem : "j" property string prevItem : "k" property string firstItem : "g" @@ -32,8 +34,9 @@ Item { State { name: "NORMAL" - PropertyChanges { target: escapeInsertAction; enabled: false } + PropertyChanges { target: enterNormalAction; enabled: false } PropertyChanges { target: enterInsertAction; enabled: true } + PropertyChanges { target: enterCommandAction; enabled: true } PropertyChanges { target: nextTerminalAction; enabled: true } PropertyChanges { target: heightenTerminalAction; enabled: true } PropertyChanges { target: shortenTerminalAction; enabled: true } @@ -45,8 +48,23 @@ Item { State { name: "INSERT" - PropertyChanges { target: escapeInsertAction; enabled: true } + PropertyChanges { target: enterNormalAction; enabled: true } PropertyChanges { target: enterInsertAction; enabled: false } + PropertyChanges { target: enterCommandAction; 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 } + PropertyChanges { target: resetTerminalAction; enabled: false } + }, + State { + name: "COMMAND" + + PropertyChanges { target: enterNormalAction; enabled: true } + PropertyChanges { target: enterInsertAction; enabled: false } + PropertyChanges { target: enterCommandAction; enabled: false } PropertyChanges { target: nextTerminalAction; enabled: false } PropertyChanges { target: heightenTerminalAction; enabled: false } PropertyChanges { target: shortenTerminalAction; enabled: false } @@ -57,6 +75,18 @@ Item { } ] + Action { + id: enterNormalAction + shortcut: settings.normalMode + onTriggered: { + item.state = "NORMAL"; + + terminalList.forceActiveFocus(); + terminalList.unfocusCurrent(); + commandInput.unfocus(); + } + } + Action { id: enterInsertAction shortcut: settings.insertMode @@ -68,13 +98,12 @@ Item { } Action { - id: escapeInsertAction - shortcut: settings.normalMode + id: enterCommandAction + shortcut: settings.commandMode onTriggered: { - item.state = "NORMAL"; + item.state = "COMMAND"; - terminalList.forceActiveFocus(); - terminalList.unfocusCurrent(); + commandInput.focus(); } } -- cgit v1.2.3