aboutsummaryrefslogtreecommitdiff
path: root/qml
diff options
context:
space:
mode:
Diffstat (limited to 'qml')
-rw-r--r--qml/EmbeddedTerminal.qml21
-rw-r--r--qml/TerminalItem.qml52
-rw-r--r--qml/main.qml4
3 files changed, 40 insertions, 37 deletions
diff --git a/qml/EmbeddedTerminal.qml b/qml/EmbeddedTerminal.qml
index 6d94230..146df7f 100644
--- a/qml/EmbeddedTerminal.qml
+++ b/qml/EmbeddedTerminal.qml
@@ -1,16 +1,15 @@
import QtQuick 2.0
import QMLTermWidget 1.0
-import QtQuick.Controls 1.2
Item {
- id: embeddedTerminal
+ id: item
property string program
property string workingDirectory
- property int columns
- property int lines
+ property int columns
+ property int lines
- width: container.width
+ width: container.width
height: container.height
function select() { highlighter.select() }
@@ -52,18 +51,18 @@ Item {
font.family: "Monospace"
font.pointSize: 8
- width: fontMetrics.width * embeddedTerminal.columns
- height: fontMetrics.height * embeddedTerminal.lines
+ width: fontMetrics.width * item.columns
+ height: fontMetrics.height * item.lines
session: QMLTermSession {
- initialWorkingDirectory: embeddedTerminal.workingDirectory
+ initialWorkingDirectory: item.workingDirectory
shellProgram: {
- return (embeddedTerminal.program).split(" ")[0];
+ return (item.program).split(" ")[0];
}
shellProgramArgs: {
- var elements = (embeddedTerminal.program).split(" ");
+ var elements = (item.program).split(" ");
elements.shift();
return elements;
@@ -80,7 +79,7 @@ Item {
}
Component.onCompleted: {
- terminal.forceActiveFocus();
+ forceActiveFocus();
session.startShellProgram();
}
}
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
diff --git a/qml/main.qml b/qml/main.qml
index 48be124..70110db 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -13,6 +13,7 @@ ApplicationWindow {
Flickable {
id: terminalListFlickable
+
anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds
@@ -22,10 +23,11 @@ ApplicationWindow {
Column {
id: terminalList
- spacing: 10
property int activeItem : 0
+ spacing: 10
+
onHeightChanged: scrollTo(activeItem)
function createItem() {