diff options
Diffstat (limited to 'qml/main.qml')
-rw-r--r-- | qml/main.qml | 166 |
1 files changed, 90 insertions, 76 deletions
diff --git a/qml/main.qml b/qml/main.qml index 19d19fc..2b81fe2 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import QtQuick.Window 2.0 import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.1 import Qt.labs.settings 1.0 ApplicationWindow { @@ -12,7 +13,7 @@ ApplicationWindow { id: settings category: "window" - property color background : "#161616" + property color background : "#161616" } color: settings.background @@ -22,115 +23,128 @@ ApplicationWindow { terminalList.focusCurrent(); } - Flickable { - id: terminalListFlickable - + ColumnLayout { anchors.fill: parent - boundsBehavior: Flickable.StopAtBounds - contentHeight: terminalList.height - contentWidth: parent.width - pixelAligned: true - - Column { - id: terminalList + Flickable { + id: terminalListFlickable - property int activeItem : 0 - property int itemIndex : 0 + Layout.fillHeight: true + Layout.fillWidth: true - anchors { - left: parent.left - right: parent.right - } + boundsBehavior: Flickable.StopAtBounds + contentHeight: terminalList.height + contentWidth: parent.width + pixelAligned: true - spacing: 10 + Column { + id: terminalList - onHeightChanged: scrollTo(activeItem) + property int activeItem : 0 + property int itemIndex : 0 - function onItemExecuted(index) { - if ( index === (children.length - 1) ) { - createItem(); + anchors { + left: parent.left + right: parent.right } - } - function createItem() { - var terminalItem = Qt.createComponent("qrc:/TerminalItem.qml"); - var instantiateTerminal = function() { - var instance = terminalItem.createObject(terminalList, { - "index": itemIndex, - "width": terminalListFlickable.width - }); - instance.onExecuted.connect(onItemExecuted); + spacing: 10 - ++itemIndex; - } + onHeightChanged: scrollTo(activeItem) - if ( terminalItem.status === Component.Ready ) { - instantiateTerminal(); - } else { - terminalItem.statusChanged.connect(instantiateTerminal); + function onItemExecuted(index) { + if ( index === (children.length - 1) ) { + createItem(); + } } - } - function scrollTo(index) { - if ( terminalList.height >= terminalListFlickable.height ) { - var offset = children[index].y - + (children[index].height / 2) - - (terminalListFlickable.height / 2); + function createItem() { + var terminalItem = Qt.createComponent("qrc:/TerminalItem.qml"); + var instantiateTerminal = function() { + var instance = terminalItem.createObject(terminalList, { + "index": itemIndex, + "width": terminalListFlickable.width + }); + instance.onExecuted.connect(onItemExecuted); - var bound = terminalList.height - - terminalListFlickable.height; + ++itemIndex; + } - if ( offset < 0 ) { - terminalListFlickable.contentY = 0; - } else if ( offset >= bound ) { - terminalListFlickable.contentY = bound; + if ( terminalItem.status === Component.Ready ) { + instantiateTerminal(); } else { - terminalListFlickable.contentY = offset; + terminalItem.statusChanged.connect(instantiateTerminal); } } - } - function selectItem(index) { - children[activeItem].deselect(); - children[index ].select(); + function scrollTo(index) { + if ( terminalList.height >= terminalListFlickable.height ) { + var offset = children[index].y + + (children[index].height / 2) + - (terminalListFlickable.height / 2); + + var bound = terminalList.height + - terminalListFlickable.height; + + if ( offset < 0 ) { + terminalListFlickable.contentY = 0; + } else if ( offset >= bound ) { + terminalListFlickable.contentY = bound; + } else { + terminalListFlickable.contentY = offset; + } + } + } - activeItem = index; + function selectItem(index) { + children[activeItem].deselect(); + children[index ].select(); - scrollTo(index); - } + activeItem = index; - function selectNext() { - if ( activeItem < (children.length - 1) ) { - selectItem(activeItem + 1); - } else { - state.enterInsertMode(); + scrollTo(index); } - } - function selectPrev() { - if ( activeItem > 0 ) { - selectItem(activeItem - 1); + function selectNext() { + if ( activeItem < (children.length - 1) ) { + selectItem(activeItem + 1); + } else { + state.enterInsertMode(); + } } - } - function focusCurrent() { - children[activeItem].forceActiveFocus(); - } + function selectPrev() { + if ( activeItem > 0 ) { + selectItem(activeItem - 1); + } + } - function unfocusCurrent() { - children[activeItem].unfocus(); - } + function focusCurrent() { + children[activeItem].forceActiveFocus(); + } + + function unfocusCurrent() { + children[activeItem].unfocus(); + } - function getCurrent() { - return children[activeItem]; + function getCurrent() { + return children[activeItem]; + } } - } + } + + CommandInput { + id: command + + Layout.fillWidth: true + height: 20 + } } StateHandler { id: state terminalList: terminalList + commandInput: command } } |