aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qml/StateHandler.qml8
-rw-r--r--qml/main.qml17
2 files changed, 20 insertions, 5 deletions
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();
+ }
}
}
}