aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-07-25 20:07:14 +0200
committerAdrian Kummerlaender2015-07-25 20:07:14 +0200
commit1ed6dfcd2eb9878b2ad25c42358d9a21839a1951 (patch)
treeaf61cd98c79b768c40a22fb74e4d174ffc999772
parent18538591a6226e79e5add5dfc084ab8701e1fd3b (diff)
downloadMetaTerm-1ed6dfcd2eb9878b2ad25c42358d9a21839a1951.tar
MetaTerm-1ed6dfcd2eb9878b2ad25c42358d9a21839a1951.tar.gz
MetaTerm-1ed6dfcd2eb9878b2ad25c42358d9a21839a1951.tar.bz2
MetaTerm-1ed6dfcd2eb9878b2ad25c42358d9a21839a1951.tar.lz
MetaTerm-1ed6dfcd2eb9878b2ad25c42358d9a21839a1951.tar.xz
MetaTerm-1ed6dfcd2eb9878b2ad25c42358d9a21839a1951.tar.zst
MetaTerm-1ed6dfcd2eb9878b2ad25c42358d9a21839a1951.zip
Reimplemented `delete` command as more of a `reset` command
Pressing `d` in normal mode causes the current embedded terminal to be destroyed and the containing terminal item to be reset into its initial state. This allows for much more flexible usage of _MetaTerm_. To prevent unnecessary terminal item instantiations the `onExecuted` signal was extended to provide a `index` argument containing the sender terminal's index.
-rw-r--r--qml/StateHandler.qml8
-rw-r--r--qml/TerminalItem.qml17
-rw-r--r--qml/main.qml14
3 files changed, 26 insertions, 13 deletions
diff --git a/qml/StateHandler.qml b/qml/StateHandler.qml
index aacb0fa..53ca3af 100644
--- a/qml/StateHandler.qml
+++ b/qml/StateHandler.qml
@@ -24,7 +24,7 @@ Item {
PropertyChanges { target: prevTerminalAction; enabled: true }
PropertyChanges { target: lastTerminalAction; enabled: true }
PropertyChanges { target: firstTerminalAction; enabled: true }
- PropertyChanges { target: deleteTerminalAction; enabled: true }
+ PropertyChanges { target: resetTerminalAction; enabled: true }
},
State {
name: "INSERT"
@@ -37,7 +37,7 @@ Item {
PropertyChanges { target: prevTerminalAction; enabled: false }
PropertyChanges { target: lastTerminalAction; enabled: false }
PropertyChanges { target: firstTerminalAction; enabled: false }
- PropertyChanges { target: deleteTerminalAction; enabled: false }
+ PropertyChanges { target: resetTerminalAction; enabled: false }
}
]
@@ -99,8 +99,8 @@ Item {
}
Action {
- id: deleteTerminalAction
+ id: resetTerminalAction
shortcut: "d"
- onTriggered: terminalList.deleteCurrent()
+ onTriggered: terminalList.getCurrent().reset()
}
}
diff --git a/qml/TerminalItem.qml b/qml/TerminalItem.qml
index 0650b1e..26793da 100644
--- a/qml/TerminalItem.qml
+++ b/qml/TerminalItem.qml
@@ -8,7 +8,7 @@ Item {
property int index : 0
property EmbeddedTerminal terminal : null
- signal executed
+ signal executed (int index)
anchors {
left: parent.left
@@ -63,6 +63,19 @@ Item {
}
}
+ function reset() {
+ if ( terminal !== null ) {
+ terminal.destroy();
+
+ terminal = null;
+ command.readOnly = false;
+ command.focus = true;
+
+ unfocus();
+ select();
+ }
+ }
+
FocusScope {
id: scope
@@ -146,7 +159,7 @@ Item {
focus = false;
elementList.createTerminal(text);
- item.executed();
+ item.executed(item.index);
highlighter.deselect();
}
}
diff --git a/qml/main.qml b/qml/main.qml
index f9e7162..836f97c 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -38,6 +38,12 @@ ApplicationWindow {
onHeightChanged: scrollTo(activeItem)
+ function onItemExecuted(index) {
+ if ( index === (children.length - 1) ) {
+ createItem();
+ }
+ }
+
function createItem() {
var terminalItem = Qt.createComponent("qrc:/TerminalItem.qml");
var instantiateTerminal = function() {
@@ -45,7 +51,7 @@ ApplicationWindow {
"index": itemIndex,
"width": terminalListFlickable.width
});
- instance.onExecuted.connect(createItem);
+ instance.onExecuted.connect(onItemExecuted);
++itemIndex;
}
@@ -110,12 +116,6 @@ ApplicationWindow {
function getCurrent() {
return children[activeItem];
}
-
- function deleteCurrent() {
- if ( children[activeItem].terminal != null ) {
- children[activeItem].destroy();
- }
- }
}
}