From 79518df6137ae9531e1e4a724def5dfc55eabfc5 Mon Sep 17 00:00:00 2001 From: Yury Shuvakin Date: Thu, 25 Aug 2022 09:19:00 +0300 Subject: [PATCH] Implemented terminal screen --- qml/Controls/TextArea.qml | 11 ++++++ qml/Controls/qmldir | 1 + qml/MainWindow.qml | 9 +++++ qml/Screens/BmsServiceScreen.qml | 63 ++++++++++++++++++++++++++++++++ qml/Screens/qmldir | 1 + qml/qml_items.qrc | 2 + 6 files changed, 87 insertions(+) create mode 100644 qml/Controls/TextArea.qml create mode 100644 qml/Screens/BmsServiceScreen.qml diff --git a/qml/Controls/TextArea.qml b/qml/Controls/TextArea.qml new file mode 100644 index 0000000..7597929 --- /dev/null +++ b/qml/Controls/TextArea.qml @@ -0,0 +1,11 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +import Utils 1.0 + +TextArea { + color: Palette.textColor + selectByMouse: true + selectionColor: Palette.alternativeBackgroundColor + font.pixelSize: 16 +} diff --git a/qml/Controls/qmldir b/qml/Controls/qmldir index 9872152..0ebc71e 100644 --- a/qml/Controls/qmldir +++ b/qml/Controls/qmldir @@ -19,3 +19,4 @@ LinkLabel 1.0 LinkLabel.qml TabButton 1.0 TabButton.qml TabBar 1.0 TabBar.qml ChartView 1.0 ChartView.qml +TextArea 1.0 TextArea.qml diff --git a/qml/MainWindow.qml b/qml/MainWindow.qml index 0c99012..bed6f63 100644 --- a/qml/MainWindow.qml +++ b/qml/MainWindow.qml @@ -174,6 +174,9 @@ ApplicationWindow { qsTr("Cell monitor"), qsTr("BMS settings"), qsTr("Visualization"), + qsTr("History"), + qsTr("Terminal"), + qsTr("Exit"), ] Label { @@ -211,6 +214,12 @@ ApplicationWindow { Screens.VisualizationScreen { } + + Screens.BmsSettingsScreen { + } + + Screens.BmsServiceScreen { + } } } } diff --git a/qml/Screens/BmsServiceScreen.qml b/qml/Screens/BmsServiceScreen.qml new file mode 100644 index 0000000..71351b2 --- /dev/null +++ b/qml/Screens/BmsServiceScreen.qml @@ -0,0 +1,63 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +import Controls 1.0 as Controls +import Cubo 1.0 + +ColumnLayout { + spacing: 20 + + Keys.onReturnPressed: sendButton.clicked() + Keys.onEnterPressed: sendButton.clicked() + + Controls.Frame { + ScrollView { + anchors.fill: parent + Controls.TextArea { + id: outputArea + } + } + Layout.fillWidth: true + Layout.fillHeight: true + } + + RowLayout { + spacing: 20 + + Controls.Button { + text: qsTr("Clear") + Layout.preferredWidth: 120 + onClicked: outputArea.clear() + } + + Controls.TextField { + id: commandField + implicitHeight: 52 + Layout.fillWidth: true + } + + Controls.Button { + id: sendButton + text: qsTr("Send") + Layout.preferredWidth: 120 + onClicked: { + BmsInterface.commands().sendTerminalCmd(commandField.text) + commandField.clear() + } + } + + Controls.Button { + text: qsTr("Help") + Layout.preferredWidth: 120 + onClicked: BmsInterface.commands().sendTerminalCmd("help") + } + + Layout.fillWidth: true + } + + Connections { + target: BmsInterface.commands() + onPrintReceived: outputArea.append(str) + } +} diff --git a/qml/Screens/qmldir b/qml/Screens/qmldir index 05ce25a..fbd6b1f 100644 --- a/qml/Screens/qmldir +++ b/qml/Screens/qmldir @@ -4,3 +4,4 @@ AkbMonitorScreen 1.0 AkbMonitorScreen.qml CellMonitorScreen 1.0 CellMonitorScreen.qml BmsSettingsScreen 1.0 BmsSettingsScreen.qml VisualizationScreen 1.0 VisualizationScreen.qml +BmsServiceScreen 1.0 BmsServiceScreen.qml diff --git a/qml/qml_items.qrc b/qml/qml_items.qrc index 95f6b0d..4803137 100644 --- a/qml/qml_items.qrc +++ b/qml/qml_items.qrc @@ -30,5 +30,7 @@ Controls/TabButton.qml Controls/TabBar.qml Controls/ChartView.qml + Screens/BmsServiceScreen.qml + Controls/TextArea.qml