Implemented a screen displaying the history of operations with the board. Added dialogs for displaying messages and statuses

This commit is contained in:
Yury Shuvakin
2022-08-26 07:34:04 +03:00
parent 79518df613
commit 6ae4386b37
18 changed files with 535 additions and 61 deletions

View File

@@ -0,0 +1,86 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Controls 1.0 as Controls
import Cubo 1.0
import Utils 1.0
Dialog {
id: root
title: qsTr("Connection screen")
width: 400
height: 320
modal: true
closePolicy: Popup.CloseOnEscape
header: Controls.DialogHeader {
dialog: root
}
contentItem: Rectangle {
color: Palette.screenBackgroundColor
ColumnLayout {
anchors.fill: parent
anchors.leftMargin: 45
anchors.rightMargin: 45
spacing: 20
Item {
Layout.fillHeight: true
}
Label {
text: qsTr("Select serial port")
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
}
Controls.ComboBox {
id: serialBox
model: BmsInterface.serialPortNames()
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
}
Controls.Button {
id: connectButton
text: qsTr("Connect")
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
onClicked: {
if (BmsInterface.isPortConnected()) {
BmsInterface.disconnectPort()
} else {
var currentPort = BmsInterface.serialPortNames()[serialBox.currentIndex]
if (BmsInterface.connectSerial(currentPort)) {
root.close()
}
}
}
}
Item {
Layout.fillHeight: true
}
}
}
background: Controls.DialogBackground {}
onVisibleChanged: {
x = Qt.binding(function() { return (parent.width - width) / 2})
y = Qt.binding(function() { return (parent.height - height) / 2})
serialBox.model = BmsInterface.serialPortNames()
}
Connections {
target: BmsInterface
onPortConnectedChanged: {
connectButton.text = BmsInterface.isPortConnected() ? qsTr("Disconnect") : qsTr("Connect")
serialBox.enabled = !BmsInterface.isPortConnected()
}
}
}

View File

@@ -1,49 +0,0 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.12
import Controls 1.0 as Controls
import Cubo 1.0
import Utils 1.0
Dialog {
id: root
title: qsTr("Connection Screen")
width: 300
height: 300
standardButtons: Dialog.NoButton
contentItem: Rectangle {
color: Palette.screenBackgroundColor
ColumnLayout {
anchors.fill: parent
anchors.margins: 45
Label {
text: qsTr("Select serial port")
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
}
Controls.ComboBox {
id: serialBox
model: BmsInterface.serialPortNames()
Layout.fillWidth: true
Layout.alignment: Qt.AlignCenter
}
Controls.Button {
text: qsTr("Connect")
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
onClicked: {
var currentPort = BmsInterface.serialPortNames()[serialBox.currentIndex]
if (BmsInterface.connectSerial(currentPort))
root.close()
}
}
}
}
}

View File

@@ -0,0 +1,35 @@
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
Controls.Frame {
ScrollView {
anchors.fill: parent
Controls.TextArea {
id: outputArea
}
}
Layout.fillWidth: true
Layout.fillHeight: true
}
Controls.Button {
text: qsTr("Clear")
Layout.preferredWidth: 120
onClicked: outputArea.clear()
}
Connections {
target: BmsInterface
onStatusMessage: {
outputArea.append(msg)
}
}
}

View File

@@ -0,0 +1,65 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Controls 1.0 as Controls
import Utils 1.0
Dialog {
id: root
width: 500
height: 350
modal: true
closePolicy: Popup.CloseOnEscape
bottomPadding: 0
property string description: ""
property bool good: true
header: Controls.DialogHeader {
dialog: root
}
contentItem: ColumnLayout {
spacing: 20
RowLayout {
spacing: 20
Image {
source: good ? "qrc:/Icons/info.svg" : "qrc:/Icons/warning.svg"
sourceSize.width: 52
sourceSize.height: 48
}
Controls.SubtitleLabel {
text: root.description
maximumLineCount: 10
wrapMode: Text.Wrap
Layout.fillWidth: true
}
Layout.fillWidth: true
Layout.fillHeight: true
}
RowLayout {
Controls.Button {
text: qsTr("Ok")
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: 100
onClicked: root.close()
}
Layout.alignment: Qt.AlignCenter
Layout.fillWidth: true
}
}
background: Controls.DialogBackground {}
onVisibleChanged: {
x = Qt.binding(function() { return (parent.width - width) / 2})
y = Qt.binding(function() { return (parent.height - height) / 2})
}
}

View File

@@ -0,0 +1,48 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import Controls 1.0 as Controls
import Utils 1.0
Popup {
id: root
x: (parent.width - width) / 2
y: parent.height - height - 20
closePolicy: Popup.NoAutoClose
property string text: ""
property bool good: true
Controls.SubtitleLabel {
id: label
text: root.text
maximumLineCount: 10
wrapMode: Text.Wrap
color: Palette.alternativeTextColor
}
background: Rectangle {
radius: 6
color: good ? Palette.alternativeBackgroundColor : Palette.invalidColor
border.width: 1
border.color: Palette.borderColor
}
enter: Transition {
NumberAnimation {
property: "opacity"
from: 0.0
to: 1.0
duration: 300
}
}
exit: Transition {
NumberAnimation {
property: "opacity"
from: 1.0
to: 0.0
duration: 2500
}
}
}

View File

@@ -1,7 +1,10 @@
module Screens
ConnectionScreen 1.0 ConnectionScreen.qml
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
DebugInformationScreen 1.0 DebugInformationScreen.qml
ConnectionDialog 1.0 ConnectionDialog.qml
MessageDialog 1.0 MessageDialog.qml
StatusPopup 1.0 StatusPopup.qml