From e88b7284bf6ddb21a19f9a7410a3620401e1d1db Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 1 Jul 2015 20:36:07 +0200 Subject: Control UI mode by enabling and disabling actions --- MetaTerm.qml | 64 +++++++++++++++--------------------------------------------- 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/MetaTerm.qml b/MetaTerm.qml index 913f514..7618594 100644 --- a/MetaTerm.qml +++ b/MetaTerm.qml @@ -9,12 +9,9 @@ Rectangle { color: "#161616" - property string uiMode : "insert" - Flickable { id: terminalListFlickable boundsBehavior: Flickable.StopAtBounds - width: 600 anchors.fill: parent Column { @@ -74,19 +71,14 @@ Rectangle { Action { id: insertTerminalAction shortcut: "i" + enabled: false onTriggered: { - switch ( uiMode ) { - case "normal": { - uiMode = "insert"; - terminalList.focusItem(); - break; - } - default: { - break; - } - } + escapeTerminalAction.enabled = true; + insertTerminalAction.enabled = false; + nextTerminalAction.enabled = false; + prevTerminalAction.enabled = false; - console.log(uiMode); + terminalList.focusItem(); } } @@ -94,52 +86,28 @@ Rectangle { id: escapeTerminalAction shortcut: "Shift+ESC" onTriggered: { - switch ( uiMode ) { - case "insert": { - uiMode = "normal"; - root.forceActiveFocus(); - terminalList.unfocusItem(); - break; - } - default: { - break; - } - } + escapeTerminalAction.enabled = false; + insertTerminalAction.enabled = true; + nextTerminalAction.enabled = true; + prevTerminalAction.enabled = true; - console.log(uiMode); + root.forceActiveFocus(); + terminalList.unfocusItem(); } } Action { id: nextTerminalAction shortcut: "j" - onTriggered: { - switch ( uiMode ) { - case "normal": { - terminalList.nextItem(); - break; - } - default: { - break; - } - } - } + enabled: false + onTriggered: terminalList.nextItem() } Action { id: prevTerminalAction shortcut: "k" - onTriggered: { - switch ( uiMode ) { - case "normal": { - terminalList.prevItem(); - break; - } - default: { - break; - } - } - } + enabled: false + onTriggered: terminalList.prevItem() } ScrollBar { -- cgit v1.2.3