diff options
author | Adrian Kummerlaender | 2015-07-06 20:26:14 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2015-07-06 20:26:14 +0200 |
commit | cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74 (patch) | |
tree | ace3a2328e3e755a85cfea400d4705a5b42e34a4 /qml/TerminalItem.qml | |
parent | ef1a71f77d318ef75e04467bab17a650c0b4d868 (diff) | |
download | MetaTerm-cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74.tar MetaTerm-cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74.tar.gz MetaTerm-cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74.tar.bz2 MetaTerm-cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74.tar.lz MetaTerm-cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74.tar.xz MetaTerm-cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74.tar.zst MetaTerm-cdec039fe30ec2bcb75a9a1596b32fa6eeed6b74.zip |
Added `terminal` property to TerminalItem
Makes it easier to access the `QMLTermWidget` instance from both outside and inside `TerminalItem`
Diffstat (limited to 'qml/TerminalItem.qml')
-rw-r--r-- | qml/TerminalItem.qml | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/qml/TerminalItem.qml b/qml/TerminalItem.qml index 51ef98c..13a19dd 100644 --- a/qml/TerminalItem.qml +++ b/qml/TerminalItem.qml @@ -3,34 +3,35 @@ import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 Item { - id: terminalItem + id: item - property int index : 0 + property int index : 0 + property EmbeddedTerminal terminal : null signal executed height: elementList.height function select() { - if ( command.readOnly ) { - elementList.children[1].select(); - } else { + if ( terminal == null ) { highlighter.select(); + } else { + terminal.select(); } } function deselect() { - if ( command.readOnly ) { - elementList.children[1].deselect(); - } else { + if ( terminal == null ) { highlighter.deselect(); + } else { + terminal.deselect(); } } function forceActiveFocus() { - if ( command.readOnly ) { - scope.forceActiveFocus(); - } else { + scope.forceActiveFocus(); + + if ( terminal == null ) { scope.forceActiveFocus(); highlighter.select(); highlighter.focus(); @@ -38,7 +39,7 @@ Item { } function unfocus() { - if ( !command.readOnly ) { + if ( terminal == null ) { highlighter.unfocus(); } } @@ -50,26 +51,26 @@ Item { id: elementList function createTerminal(program) { - var terminal = Qt.createComponent("qrc:/EmbeddedTerminal.qml"); + var terminalComponent = Qt.createComponent("qrc:/EmbeddedTerminal.qml"); var instantiateTerminal = function() { - terminal.createObject(elementList, { - "columns": 90, - "lines": 20, - "program": program, - "workingDirectory": "$HOME", - "focus": true + item.terminal = terminalComponent.createObject(elementList, { + "columns" : 90, + "lines" : 20, + "program" : program, + "workingDirectory" : "$HOME", + "focus" : true }); } - if ( terminal.status === Component.Ready ) { + if ( terminalComponent.status === Component.Ready ) { instantiateTerminal(); } else { - terminal.statusChanged.connect(instantiateTerminal); + terminalComponent.statusChanged.connect(instantiateTerminal); } } RowLayout { - width: terminalItem.width + width: item.width Rectangle { id: highlighter @@ -109,18 +110,19 @@ Item { Layout.fillWidth: true onAccepted: { - if ( !readOnly ) { + if ( item.terminal == null ) { readOnly = true; focus = false; + elementList.createTerminal(text); - terminalItem.executed(); + item.executed(); highlighter.deselect(); } } } Text { - text: terminalItem.index + text: item.index font { family: "Monospace" pointSize: 12 |