From ab1d14d90e69e35f45eefa8e7236d566fea81c41 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 19 Jul 2015 12:00:14 +0200 Subject: Maximized terminal width Terminal width is now automatically adjusted to use all available space. Commands to control horizontal terminal height were removed correspondingly. --- qml/EmbeddedTerminal.qml | 23 ++++++++++++++++------- qml/TerminalItem.qml | 33 +++++++++++++++++++-------------- qml/main.qml | 25 ++++++------------------- 3 files changed, 41 insertions(+), 40 deletions(-) (limited to 'qml') diff --git a/qml/EmbeddedTerminal.qml b/qml/EmbeddedTerminal.qml index 146df7f..0a878b7 100644 --- a/qml/EmbeddedTerminal.qml +++ b/qml/EmbeddedTerminal.qml @@ -1,28 +1,35 @@ import QtQuick 2.0 import QMLTermWidget 1.0 +import QtQuick.Layouts 1.1 Item { id: item property string program property string workingDirectory - property int columns property int lines - width: container.width - height: container.height + height: terminal.height + width: parent.width function select() { highlighter.select() } function deselect() { highlighter.deselect() } - Row { + RowLayout { id: container + anchors { + left: parent.left + right: parent.right + } + + spacing: 0 + Rectangle { id: highlighter width: 10 - height: terminal.height + Layout.fillHeight: true color: "#909636" @@ -40,9 +47,11 @@ Item { } Rectangle { - width: terminal.width height: terminal.height + Layout.fillWidth: true + Layout.preferredHeight: terminal.height + color: "#ffffff" QMLTermWidget { @@ -51,7 +60,7 @@ Item { font.family: "Monospace" font.pointSize: 8 - width: fontMetrics.width * item.columns + width: parent.width height: fontMetrics.height * item.lines session: QMLTermSession { diff --git a/qml/TerminalItem.qml b/qml/TerminalItem.qml index acc2f8e..f3527b8 100644 --- a/qml/TerminalItem.qml +++ b/qml/TerminalItem.qml @@ -10,6 +10,11 @@ Item { signal executed + anchors { + left: parent.left + right: parent.right + } + height: elementList.height function select() { @@ -44,18 +49,6 @@ Item { } } - function widen() { - if ( terminal !== null ) { - terminal.columns += 1; - } - } - - function narrow() { - if ( terminal !== null ) { - terminal.columns -= 1; - } - } - function heighten() { if ( terminal !== null ) { terminal.lines += 1; @@ -71,14 +64,23 @@ Item { FocusScope { id: scope + anchors { + left: parent.left + right: parent.right + } + Column { id: elementList + anchors { + left: parent.left + right: parent.right + } + function createTerminal(program) { var terminalComponent = Qt.createComponent("qrc:/EmbeddedTerminal.qml"); var instantiateTerminal = function() { item.terminal = terminalComponent.createObject(elementList, { - "columns" : 90, "lines" : 20, "program" : program, "workingDirectory" : "$HOME", @@ -94,7 +96,10 @@ Item { } RowLayout { - width: item.width + anchors { + left: parent.left + right: parent.right + } Rectangle { id: highlighter diff --git a/qml/main.qml b/qml/main.qml index a2355e9..ef17a99 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -18,7 +18,7 @@ ApplicationWindow { boundsBehavior: Flickable.StopAtBounds contentHeight: terminalList.height - contentWidth: terminalList.width + contentWidth: parent.width pixelAligned: true Column { @@ -26,6 +26,11 @@ ApplicationWindow { property int activeItem : 0 + anchors { + left: parent.left + right: parent.right + } + spacing: 10 onHeightChanged: scrollTo(activeItem) @@ -118,8 +123,6 @@ ApplicationWindow { nextTerminalAction.enabled = false; heightenTerminalAction.enabled = false; shortenTerminalAction.enabled = false; - widenTerminalAction.enabled = false; - narrowTerminalAction.enabled = false; prevTerminalAction.enabled = false; lastTerminalAction.enabled = false; firstTerminalAction.enabled = false; @@ -137,8 +140,6 @@ ApplicationWindow { nextTerminalAction.enabled = true; heightenTerminalAction.enabled = true; shortenTerminalAction.enabled = true; - widenTerminalAction.enabled = true; - narrowTerminalAction.enabled = true; prevTerminalAction.enabled = true; lastTerminalAction.enabled = true; firstTerminalAction.enabled = true; @@ -169,20 +170,6 @@ ApplicationWindow { onTriggered: terminalList.getCurrent().shorten() } - Action { - id: widenTerminalAction - shortcut: "Shift+L" - enabled: false - onTriggered: terminalList.getCurrent().widen() - } - - Action { - id: narrowTerminalAction - shortcut: "Shift+H" - enabled: false - onTriggered: terminalList.getCurrent().narrow() - } - Action { id: prevTerminalAction shortcut: "k" -- cgit v1.2.3