First implementation
This commit is contained in:
23
qml/Controls/ColoredLabel.qml
Normal file
23
qml/Controls/ColoredLabel.qml
Normal file
@@ -0,0 +1,23 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.Label {
|
||||
font.family: "Roboto"
|
||||
font.weight: Font.Normal
|
||||
font.pixelSize: Ui.scale(17)
|
||||
|
||||
topPadding: Ui.scale(6)
|
||||
bottomPadding: Ui.scale(6)
|
||||
leftPadding: Ui.scale(12)
|
||||
rightPadding: Ui.scale(12)
|
||||
|
||||
property color backgroundColor: Palette.backgroundColor
|
||||
|
||||
background: Rectangle {
|
||||
radius: Ui.scale(4)
|
||||
color: backgroundColor
|
||||
}
|
||||
}
|
||||
33
qml/Controls/Indicator.qml
Normal file
33
qml/Controls/Indicator.qml
Normal file
@@ -0,0 +1,33 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
|
||||
import Controls 1.0
|
||||
import Utils 1.0
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
columnSpacing: Ui.scale(8)
|
||||
rowSpacing: Ui.scale(4)
|
||||
|
||||
property string label
|
||||
property string indicator
|
||||
property alias value: valueField
|
||||
|
||||
SecondaryLabel {
|
||||
text: label
|
||||
topPadding: lineCount == 1 ? Ui.scale(12) : 0
|
||||
Layout.columnSpan: 2
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: valueField
|
||||
selectByMouse: true
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
IndicatorLabel {
|
||||
text: indicator
|
||||
Layout.preferredWidth: Ui.scale(18)
|
||||
}
|
||||
}
|
||||
12
qml/Controls/IndicatorLabel.qml
Normal file
12
qml/Controls/IndicatorLabel.qml
Normal file
@@ -0,0 +1,12 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.Label {
|
||||
id: control
|
||||
font.pixelSize: Ui.scale(21)
|
||||
font.family: "Roboto"
|
||||
font.weight: Font.DemiBold
|
||||
color: Palette.indicatorLabelColor
|
||||
}
|
||||
34
qml/Controls/PrimaryButton.qml
Normal file
34
qml/Controls/PrimaryButton.qml
Normal file
@@ -0,0 +1,34 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.Button {
|
||||
id: control
|
||||
|
||||
implicitHeight: Ui.scale(52)
|
||||
|
||||
font.pixelSize: Ui.scale(21)
|
||||
font.family: "Roboto"
|
||||
font.weight: Font.DemiBold
|
||||
|
||||
contentItem: Text {
|
||||
text: control.text
|
||||
font: control.font
|
||||
opacity: enabled ? 1.0 : 0.3
|
||||
color: Palette.primaryButtonTextColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
radius: Ui.scale(32)
|
||||
color: control.down ? Palette.primaryButtonPushedBackgroundColor : Palette.primaryButtonBackgroundColor
|
||||
border.width: Ui.scale(2)
|
||||
border.color: color
|
||||
|
||||
width: control.width
|
||||
height: control.height
|
||||
}
|
||||
}
|
||||
12
qml/Controls/PrimaryLabel.qml
Normal file
12
qml/Controls/PrimaryLabel.qml
Normal file
@@ -0,0 +1,12 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.Label {
|
||||
id: control
|
||||
font.pixelSize: Ui.scale(21)
|
||||
font.family: "Roboto"
|
||||
font.weight: Font.Bold
|
||||
color: Palette.primaryLabelColor
|
||||
}
|
||||
34
qml/Controls/SecondaryButton.qml
Normal file
34
qml/Controls/SecondaryButton.qml
Normal file
@@ -0,0 +1,34 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.Button {
|
||||
id: control
|
||||
|
||||
implicitHeight: Ui.scale(52)
|
||||
|
||||
font.pixelSize: Ui.scale(21)
|
||||
font.family: "Roboto"
|
||||
font.weight: Font.DemiBold
|
||||
|
||||
contentItem: Text {
|
||||
text: control.text
|
||||
font: control.font
|
||||
opacity: enabled ? 1.0 : 0.3
|
||||
color: Palette.secondaryButtonTextColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
radius: Ui.scale(32)
|
||||
color: control.down ? Palette.secondaryButtonPushedBackgroundColor : Palette.secondaryButtonBackgroundColor
|
||||
border.width: Ui.scale(2)
|
||||
border.color: Palette.secondaryButtonBorderColor
|
||||
|
||||
width: control.width
|
||||
height: control.height
|
||||
}
|
||||
}
|
||||
13
qml/Controls/SecondaryLabel.qml
Normal file
13
qml/Controls/SecondaryLabel.qml
Normal file
@@ -0,0 +1,13 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.Label {
|
||||
id: control
|
||||
font.pixelSize: Ui.scale(12)
|
||||
font.family: "Roboto"
|
||||
font.weight: Font.Normal
|
||||
color: Palette.secondaryLabelColor
|
||||
wrapMode : Text.Wrap
|
||||
}
|
||||
16
qml/Controls/Separator.qml
Normal file
16
qml/Controls/Separator.qml
Normal file
@@ -0,0 +1,16 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.ToolSeparator {
|
||||
padding: vertical ? Ui.scale(10) : Ui.scale(2)
|
||||
topPadding: vertical ? Ui.scale(2) : Ui.scale(10)
|
||||
bottomPadding: vertical ? Ui.scale(2) : Ui.scale(10)
|
||||
|
||||
contentItem: Rectangle {
|
||||
implicitWidth: parent.vertical ? Ui.scale(1) : Ui.scale(24)
|
||||
implicitHeight: parent.vertical ? Ui.scale(24) : Ui.scale(1)
|
||||
color: Palette.separatorColor
|
||||
}
|
||||
}
|
||||
34
qml/Controls/TextField.qml
Normal file
34
qml/Controls/TextField.qml
Normal file
@@ -0,0 +1,34 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
QuickControls.TextField {
|
||||
id: control
|
||||
|
||||
implicitHeight: Ui.scale(50)
|
||||
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
topPadding: Ui.scale(12)
|
||||
bottomPadding: Ui.scale(12)
|
||||
leftPadding: Ui.scale(24)
|
||||
rightPadding: Ui.scale(24)
|
||||
|
||||
font.family: "Roboto"
|
||||
font.pixelSize: Ui.scale(21)
|
||||
font.weight: Font.Bold
|
||||
|
||||
color: Palette.primaryLabelColor
|
||||
|
||||
background: Rectangle {
|
||||
radius: Ui.scale(5)
|
||||
color: Palette.textFieldBackgroundColor
|
||||
border.width: Ui.scale(1)
|
||||
border.color: control.acceptableInput ? Palette.borderColor : "red"
|
||||
|
||||
width: control.width
|
||||
height: control.height
|
||||
}
|
||||
}
|
||||
10
qml/Controls/qmldir
Normal file
10
qml/Controls/qmldir
Normal file
@@ -0,0 +1,10 @@
|
||||
module Controls
|
||||
ColoredLabel 1.0 ColoredLabel.qml
|
||||
Indicator 1.0 Indicator.qml
|
||||
IndicatorLabel 1.0 IndicatorLabel.qml
|
||||
PrimaryButton 1.0 PrimaryButton.qml
|
||||
PrimaryLabel 1.0 PrimaryLabel.qml
|
||||
SecondaryButton 1.0 SecondaryButton.qml
|
||||
SecondaryLabel 1.0 SecondaryLabel.qml
|
||||
Separator 1.0 Separator.qml
|
||||
TextField 1.0 TextField.qml
|
||||
27
qml/Utils/Palette.qml
Normal file
27
qml/Utils/Palette.qml
Normal file
@@ -0,0 +1,27 @@
|
||||
pragma Singleton
|
||||
|
||||
import QtQuick 2.12
|
||||
|
||||
QtObject {
|
||||
property color backgroundColor: "#F7F5F5"
|
||||
property color textFieldBackgroundColor: "#FFFFFF"
|
||||
|
||||
property color borderColor: "#C7C7C7"
|
||||
property color separatorColor: "#C7C7C7"
|
||||
|
||||
property color primaryLabelColor: "#232323"
|
||||
property color secondaryLabelColor: "#232323"
|
||||
property color indicatorLabelColor: "#A6A6A6"
|
||||
|
||||
property color primaryButtonBackgroundColor: "#003ACE"
|
||||
property color primaryButtonPushedBackgroundColor: "#0031AD"
|
||||
property color primaryButtonTextColor: "#FFFFFF"
|
||||
|
||||
property color secondaryButtonBackgroundColor: "#F7F5F5"
|
||||
property color secondaryButtonPushedBackgroundColor: "#E5ECFF"
|
||||
property color secondaryButtonBorderColor: "#003ACE"
|
||||
property color secondaryButtonTextColor: "#003ACE"
|
||||
|
||||
property color timeSectionBackgroundColor: "#F8F8F8"
|
||||
property color statusSectionBackgroundColor: "#FDD855"
|
||||
}
|
||||
18
qml/Utils/Ui.qml
Normal file
18
qml/Utils/Ui.qml
Normal file
@@ -0,0 +1,18 @@
|
||||
pragma Singleton
|
||||
|
||||
import QtQml 2.12
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Window 2.12
|
||||
|
||||
Item {
|
||||
property real currentWidth: 1024
|
||||
property real currentHeight: 768
|
||||
|
||||
property real referenceWidth: 1024
|
||||
property real referenceHeight: 768
|
||||
|
||||
function scale(size) {
|
||||
const value = Math.max(Math.round(size * Math.min(currentWidth / referenceWidth, currentHeight / referenceHeight)), 1)
|
||||
return value
|
||||
}
|
||||
}
|
||||
3
qml/Utils/qmldir
Normal file
3
qml/Utils/qmldir
Normal file
@@ -0,0 +1,3 @@
|
||||
module Utils
|
||||
singleton Palette 1.0 Palette.qml
|
||||
singleton Ui 1.0 Ui.qml
|
||||
249
qml/main.qml
Normal file
249
qml/main.qml
Normal file
@@ -0,0 +1,249 @@
|
||||
import QtQml 2.12
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Controls 2.12 as QuickControls
|
||||
|
||||
import Controls 1.0
|
||||
import Utils 1.0
|
||||
import Vku 1.0
|
||||
|
||||
QuickControls.ApplicationWindow {
|
||||
id: mainWindow
|
||||
width: 1024
|
||||
height: 768
|
||||
visible: true
|
||||
title: qsTr("Vku Monitor")
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: Ui.scale(32)
|
||||
anchors.bottomMargin: Ui.scale(32)
|
||||
anchors.leftMargin: Ui.scale(50)
|
||||
anchors.rightMargin: Ui.scale(50)
|
||||
|
||||
spacing: Ui.scale(12)
|
||||
|
||||
RowLayout {
|
||||
id: topLayout
|
||||
spacing: Ui.scale(40)
|
||||
Layout.fillWidth: true
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Ui.scale(12)
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: 100
|
||||
|
||||
PrimaryLabel {
|
||||
text: qsTr("Current state")
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
columnSpacing: Ui.scale(28)
|
||||
rowSpacing: Ui.scale(8)
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Input voltage")
|
||||
indicator: qsTr("V")
|
||||
value.text: CanController.inputVoltage
|
||||
value.readOnly: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Radiator temperature")
|
||||
indicator: qsTr("°С")
|
||||
value.text: CanController.radiatorTemperature
|
||||
value.readOnly: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Output voltage")
|
||||
indicator: qsTr("V")
|
||||
value.text: CanController.outputVoltage
|
||||
value.readOnly: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Emergency counter")
|
||||
indicator: ""
|
||||
value.text: CanController.emergencyCounter
|
||||
value.readOnly: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Output current")
|
||||
indicator: qsTr("A")
|
||||
value.text: CanController.outputCurrent
|
||||
value.readOnly: true
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
}
|
||||
|
||||
PrimaryButton {
|
||||
text: CanController.isVkuClosed ? qsTr("VKU opening") : qsTr("VKU closing")
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Ui.scale(12)
|
||||
onClicked: CanController.vkuClosure()
|
||||
}
|
||||
}
|
||||
|
||||
Separator {
|
||||
id: separator
|
||||
orientation: Qt.Vertical
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Ui.scale(12)
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: 100
|
||||
|
||||
PrimaryLabel {
|
||||
text: qsTr("Parameters control")
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
columnSpacing: Ui.scale(28)
|
||||
rowSpacing: Ui.scale(8)
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Maximum current")
|
||||
indicator: qsTr("A")
|
||||
value.text: CanController.maximumCurrent
|
||||
value.onEditingFinished: CanController.maximumCurrent = value.text
|
||||
value.validator: IntValidator { bottom: 0; top: 255 }
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Duration of delay after emergency")
|
||||
indicator: qsTr("s")
|
||||
value.text: CanController.emergencyDelay
|
||||
value.onEditingFinished: CanController.emergencyDelay = value.text
|
||||
value.validator: DoubleValidator { bottom: 2; top: 15; decimals: 1; notation: DoubleValidator.StandardNotation }
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Breaking delay")
|
||||
indicator: qsTr("ms")
|
||||
value.text: CanController.breakingDelay
|
||||
value.onEditingFinished: CanController.breakingDelay = value.text
|
||||
value.validator: IntValidator { bottom: 0; top: 255 }
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Number of retries after emergency breaking")
|
||||
indicator: ""
|
||||
value.text: CanController.retriesAfterEmergencyBreak
|
||||
value.onEditingFinished: CanController.retriesAfterEmergencyBreak = value.text
|
||||
value.validator: IntValidator { bottom: 1; top: 7 }
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
|
||||
Indicator {
|
||||
label: qsTr("Breaking current")
|
||||
indicator: qsTr("A")
|
||||
value.text: CanController.breakingCurrent
|
||||
value.onEditingFinished: CanController.breakingCurrent = value.text
|
||||
value.validator: IntValidator { bottom: 0; top: 255 }
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 100
|
||||
}
|
||||
}
|
||||
|
||||
SecondaryButton {
|
||||
text: qsTr("Emergency reset")
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Ui.scale(12)
|
||||
onClicked: CanController.emergencyReset()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrimaryLabel {
|
||||
text: qsTr("Status")
|
||||
visible: CanController.statuses.length > 0
|
||||
Layout.topMargin: Ui.scale(20)
|
||||
}
|
||||
|
||||
ListView {
|
||||
clip: true
|
||||
model: CanController.statuses
|
||||
|
||||
// ????
|
||||
implicitHeight: mainWindow.height
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
delegate: GridLayout {
|
||||
width: parent.width
|
||||
columns: 4
|
||||
|
||||
columnSpacing: Ui.scale(20)
|
||||
rowSpacing: Ui.scale(8)
|
||||
|
||||
Separator {
|
||||
bottomPadding: Ui.scale(8)
|
||||
orientation: Qt.Horizontal
|
||||
Layout.fillWidth: true
|
||||
Layout.columnSpan: 4
|
||||
}
|
||||
|
||||
ColoredLabel {
|
||||
text: modelData.time
|
||||
backgroundColor: Palette.timeSectionBackgroundColor
|
||||
}
|
||||
|
||||
PrimaryLabel {
|
||||
text: modelData.status
|
||||
}
|
||||
|
||||
ColoredLabel {
|
||||
text: modelData.description
|
||||
backgroundColor: Palette.statusSectionBackgroundColor
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Palette.backgroundColor
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Ui.currentWidth = Qt.binding(function(){ return width })
|
||||
Ui.currentHeight = Qt.binding(function(){ return height })
|
||||
}
|
||||
}
|
||||
18
qml/qml.qrc
Normal file
18
qml/qml.qrc
Normal file
@@ -0,0 +1,18 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>Controls/PrimaryLabel.qml</file>
|
||||
<file>Controls/SecondaryLabel.qml</file>
|
||||
<file>Controls/PrimaryButton.qml</file>
|
||||
<file>Controls/SecondaryButton.qml</file>
|
||||
<file>Controls/TextField.qml</file>
|
||||
<file>Controls/IndicatorLabel.qml</file>
|
||||
<file>Controls/Indicator.qml</file>
|
||||
<file>Controls/Separator.qml</file>
|
||||
<file>Utils/Palette.qml</file>
|
||||
<file>Utils/Ui.qml</file>
|
||||
<file>Controls/qmldir</file>
|
||||
<file>Utils/qmldir</file>
|
||||
<file>Controls/ColoredLabel.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
Reference in New Issue
Block a user