From 18538591a6226e79e5add5dfc084ab8701e1fd3b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 24 Jul 2015 22:54:12 +0200 Subject: Implemented basic delete command in normal mode --- qml/StateHandler.qml | 8 ++++++++ qml/main.qml | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'qml') diff --git a/qml/StateHandler.qml b/qml/StateHandler.qml index 4334a6b..aacb0fa 100644 --- a/qml/StateHandler.qml +++ b/qml/StateHandler.qml @@ -24,6 +24,7 @@ Item { PropertyChanges { target: prevTerminalAction; enabled: true } PropertyChanges { target: lastTerminalAction; enabled: true } PropertyChanges { target: firstTerminalAction; enabled: true } + PropertyChanges { target: deleteTerminalAction; enabled: true } }, State { name: "INSERT" @@ -36,6 +37,7 @@ Item { PropertyChanges { target: prevTerminalAction; enabled: false } PropertyChanges { target: lastTerminalAction; enabled: false } PropertyChanges { target: firstTerminalAction; enabled: false } + PropertyChanges { target: deleteTerminalAction; enabled: false } } ] @@ -95,4 +97,10 @@ Item { shortcut: "g" onTriggered: terminalList.selectItem(0) } + + Action { + id: deleteTerminalAction + shortcut: "d" + onTriggered: terminalList.deleteCurrent() + } } diff --git a/qml/main.qml b/qml/main.qml index 11337f3..f9e7162 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -8,7 +8,10 @@ ApplicationWindow { visible: true color: "#161616" - Component.onCompleted: terminalList.focusCurrent() + Component.onCompleted: { + terminalList.createItem(); + terminalList.focusCurrent(); + } Flickable { id: terminalListFlickable @@ -24,6 +27,7 @@ ApplicationWindow { id: terminalList property int activeItem : 0 + property int itemIndex : 0 anchors { left: parent.left @@ -38,10 +42,12 @@ ApplicationWindow { var terminalItem = Qt.createComponent("qrc:/TerminalItem.qml"); var instantiateTerminal = function() { var instance = terminalItem.createObject(terminalList, { - "index": terminalList.children.length, + "index": itemIndex, "width": terminalListFlickable.width }); instance.onExecuted.connect(createItem); + + ++itemIndex; } if ( terminalItem.status === Component.Ready ) { @@ -105,9 +111,10 @@ ApplicationWindow { return children[activeItem]; } - TerminalItem { - width: terminalListFlickable.width - onExecuted: terminalList.createItem() + function deleteCurrent() { + if ( children[activeItem].terminal != null ) { + children[activeItem].destroy(); + } } } } -- cgit v1.2.3