From 610cc9d77f89ab106fdbfbc006934c9d192a55a8 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 11 Aug 2015 21:28:46 +0200 Subject: Add command output log to UI `output` text item reference is passed to all command implementations. --- qml/CommandInput.qml | 91 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 22 deletions(-) (limited to 'qml/CommandInput.qml') diff --git a/qml/CommandInput.qml b/qml/CommandInput.qml index ae48a7a..6add27a 100644 --- a/qml/CommandInput.qml +++ b/qml/CommandInput.qml @@ -11,6 +11,8 @@ Item { visible: false + Layout.preferredHeight: container.height + Settings { id: settings category: "command" @@ -21,6 +23,8 @@ Item { property color fontColor : "white" } + onVisibleChanged: container.reset() + function focus(prefix) { visible = true; command.text = prefix; @@ -32,40 +36,83 @@ Item { } Rectangle { - anchors.fill: parent + anchors { + top: parent.top + left: parent.left + right: parent.right + } + + height: container.height + color: settings.background - TextInput { - id: command + ColumnLayout { + id: container - font { - family: settings.fontFamily - pointSize: settings.fontSize + function reset() { + command.text = ''; + output.text = ''; } - color: settings.fontColor - selectionColor: settings.fontColor - selectedTextColor: settings.background - selectByMouse: true + TextInput { + id: command - function reset() { text = '' } + Layout.fillWidth: true - onAccepted: { - const prefix = String(text).charAt(0); - const cmd = String(text).substring(1, String(text).length); + font { + family: settings.fontFamily + pointSize: settings.fontSize + } - switch ( prefix ) { - case ':': { - Commands.execute(cmd); - reset(); - break; + color: settings.fontColor + selectionColor: settings.fontColor + selectedTextColor: settings.background + selectByMouse: true + + onAccepted: { + const prefix = String(text).charAt(0); + const cmd = String(text).substring(1, String(text).length); + + switch ( prefix ) { + case ':': { + Commands.execute(output, cmd); + break; + } + default: { + output.log('"' + prefix + '"' + " is not a command prefix."); + } } - default: { - console.log('"' + prefix + '"' + " is not a command prefix."); + + if ( output.text === '' ) { + item.executed(); } } + } + + Text { + id: output - item.executed(); + Layout.fillWidth: true + Layout.preferredHeight: 0 + + font { + family: settings.fontFamily + pointSize: settings.fontSize + } + + color: settings.fontColor + + function log(msg) { + text = msg; + } + + onTextChanged: { + if ( text === '' ) { + Layout.preferredHeight = 0; + } else { + Layout.preferredHeight = contentHeight; + } + } } } } -- cgit v1.2.3