A system of translations into different languages has been implemented. Added translations into Russian. Various UI fixes for valid internationalization
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import Controls 1.0 as Controls
|
||||
import Screens 1.0 as Screens
|
||||
@@ -10,7 +9,7 @@ import Utils 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
title: qsTr("Cubo Verde BMS Tool")
|
||||
title: qsTr("Cubo Verde BMS tool")
|
||||
width: 1366
|
||||
height: 768
|
||||
visible: true
|
||||
@@ -45,38 +44,11 @@ ApplicationWindow {
|
||||
Layout.preferredHeight: pane.minimized ? 85 : 40
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
leftPadding: pane.minimized ? 0 : 40
|
||||
|
||||
contentItem: RowLayout {
|
||||
height: 50
|
||||
spacing: 25
|
||||
|
||||
Item {
|
||||
visible: pane.minimized
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Image {
|
||||
source: "qrc:/Icons/hide-menu.svg"
|
||||
mirror: pane.minimized
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Hide menu")
|
||||
color: Palette.alternativeTextColor
|
||||
visible: !pane.minimized
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: "transparent"
|
||||
}
|
||||
Controls.MenuItemDelegate {
|
||||
text: qsTr("Hide menu")
|
||||
font.weight: Font.Normal
|
||||
icon.source: "qrc:/Icons/hide-menu.svg"
|
||||
minimized: pane.minimized
|
||||
|
||||
onClicked: if (pane.implicitWidth === 300) {
|
||||
animation.from = 300
|
||||
@@ -90,7 +62,6 @@ ApplicationWindow {
|
||||
pane.minimized = false
|
||||
}
|
||||
|
||||
Layout.preferredHeight: 52
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
@@ -100,101 +71,36 @@ ApplicationWindow {
|
||||
|
||||
ListView {
|
||||
id: menuView
|
||||
model: [
|
||||
|
||||
property var menuModel: [
|
||||
{"text": qsTr("AKB monitor"), "icon": "qrc:/Icons/akb-monitor.svg"},
|
||||
{"text": qsTr("Cell monitor"), "icon": "qrc:/Icons/cell-monitor.svg"},
|
||||
{"text": qsTr("Configuration"), "icon": "qrc:/Icons/bms-configuration.svg"},
|
||||
{"text": qsTr("Visualization"), "icon": "qrc:/Icons/visualization.svg"},
|
||||
{"text": qsTr("History"), "icon": "qrc:/Icons/history.svg"},
|
||||
{"text": qsTr("BMS service"), "icon": "qrc:/Icons/bms-service.svg"},
|
||||
// {"text": qsTr("Exit"), "icon": "qrc:/Icons/exit.svg"},
|
||||
{"text": qsTr("BMS service"), "icon": "qrc:/Icons/bms-service.svg"}
|
||||
]
|
||||
|
||||
delegate: ItemDelegate {
|
||||
id: menuDelegate
|
||||
model: menuModel.length
|
||||
|
||||
delegate: Controls.MenuItemDelegate {
|
||||
width: ListView.view.width
|
||||
height: 52
|
||||
leftPadding: pane.minimized ? 0 : 40
|
||||
highlighted: ListView.isCurrentItem
|
||||
text: menuView.menuModel[modelData].text
|
||||
icon.source: menuView.menuModel[modelData].icon
|
||||
minimized: pane.minimized
|
||||
onClicked: menuView.currentIndex = index
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: pane.minimized ? 0 : 25
|
||||
height: 50
|
||||
|
||||
Item {
|
||||
visible: pane.minimized
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Image {
|
||||
source: modelData.icon
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
}
|
||||
|
||||
Label {
|
||||
text: modelData.text
|
||||
font.weight: Font.Bold
|
||||
color: Palette.alternativeTextColor
|
||||
visible: !pane.minimized
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: menuDelegate.highlighted ? Palette.pressedButtonColor : Palette.buttonColor
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
ItemDelegate {
|
||||
leftPadding: pane.minimized ? 0 : 40
|
||||
Controls.MenuItemDelegate {
|
||||
text: qsTr("Connection")
|
||||
icon.source: "qrc:/Icons/connection.svg"
|
||||
icon.color: "#FFFFFF"
|
||||
minimized: pane.minimized
|
||||
onClicked: connectionDialog.open()
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: pane.minimized ? 0 : 25
|
||||
height: 50
|
||||
|
||||
Item {
|
||||
visible: pane.minimized
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Image {
|
||||
source: "qrc:/Icons/connection.svg"
|
||||
sourceSize.width: 24
|
||||
sourceSize.height: 24
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
|
||||
ColorOverlay {
|
||||
anchors.fill: parent
|
||||
source: parent
|
||||
color: "#FFFFFF"
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Connection")
|
||||
font.weight: Font.Bold
|
||||
color: Palette.alternativeTextColor
|
||||
visible: !pane.minimized
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: parent.down ? Palette.pressedButtonColor : Palette.buttonColor
|
||||
}
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
@@ -216,6 +122,8 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
|
||||
RowLayout {
|
||||
id: topBar
|
||||
|
||||
@@ -226,13 +134,13 @@ ApplicationWindow {
|
||||
qsTr("Visualization"),
|
||||
qsTr("Information output"),
|
||||
qsTr("Terminal"),
|
||||
qsTr("Exit"),
|
||||
]
|
||||
|
||||
Label {
|
||||
text: topBar.labels[stack.currentIndex]
|
||||
font.pixelSize: 38
|
||||
font.weight: Font.Bold
|
||||
color: Palette.textColor
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -240,8 +148,14 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 20
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 5
|
||||
|
||||
RowLayout {
|
||||
spacing: 7
|
||||
|
||||
Controls.ContentLabel {
|
||||
id: connectionStatusLabel
|
||||
text: qsTr("Disconnected")
|
||||
@@ -264,6 +178,8 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 5
|
||||
|
||||
Controls.ContentLabel {
|
||||
text: qsTr("Serial number") + ":"
|
||||
Layout.alignment: Qt.AlignRight
|
||||
@@ -277,11 +193,111 @@ ApplicationWindow {
|
||||
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
|
||||
Layout.topMargin: 15
|
||||
Layout.bottomMargin: 15
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
Controls.LineSeparator {
|
||||
horizontal: false
|
||||
Layout.fillHeight: true
|
||||
Layout.topMargin: 15
|
||||
Layout.bottomMargin: 15
|
||||
}
|
||||
|
||||
Item {
|
||||
RowLayout {
|
||||
id: languagesLayout
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Controls.ContentLabel {
|
||||
text: Translator.currentLanguageName
|
||||
}
|
||||
|
||||
Image {
|
||||
source: Translator.currentLanguageIcon
|
||||
sourceSize.width: 30
|
||||
sourceSize.height: 26
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: languagesPopup.open()
|
||||
}
|
||||
|
||||
Popup {
|
||||
id: languagesPopup
|
||||
width: 90
|
||||
contentHeight: languagesList.contentHeight
|
||||
padding: 1
|
||||
x: -(width - languagesLayout.width) / 2
|
||||
y: languagesLayout.height + 2
|
||||
|
||||
background: Rectangle {
|
||||
color: Palette.backgroundColor
|
||||
radius: 6
|
||||
border.width: 1
|
||||
border.color: Palette.borderColor
|
||||
}
|
||||
|
||||
contentItem: ListView {
|
||||
id: languagesList
|
||||
model: [Translator.Russian, Translator.English, Translator.Italian]
|
||||
width: languagesPopup.width
|
||||
height: 120
|
||||
clip: true
|
||||
spacing: 0
|
||||
|
||||
delegate: Rectangle {
|
||||
width: ListView.view.width
|
||||
height: 40
|
||||
color: Palette.backgroundColor
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Controls.ContentLabel {
|
||||
text: Translator.languageName(modelData)
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 10
|
||||
}
|
||||
|
||||
Image {
|
||||
source: Translator.languageIcon(modelData)
|
||||
sourceSize.width: 30
|
||||
sourceSize.height: 26
|
||||
Layout.rightMargin: 10
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onPressed: parent.color = Palette.selectedBackgroundColor
|
||||
onReleased: parent.color = Palette.backgroundColor
|
||||
onEntered: parent.color = Palette.hoveredBackgroundColor
|
||||
onExited: parent.color = Palette.backgroundColor
|
||||
onClicked: {
|
||||
languagesPopup.close()
|
||||
Translator.currentLanguage = modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Layout.preferredWidth: languagesLayout.implicitWidth
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
|
||||
Layout.leftMargin: 45
|
||||
Layout.rightMargin: 45
|
||||
Layout.maximumHeight: 90
|
||||
}
|
||||
|
||||
StackLayout {
|
||||
@@ -301,6 +317,14 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
Screens.BmsSettingsScreen {
|
||||
onNeedWait: {
|
||||
if (active) {
|
||||
busyPopup.text = text
|
||||
busyPopup.open()
|
||||
} else {
|
||||
busyPopup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Screens.VisualizationScreen {
|
||||
@@ -319,7 +343,7 @@ ApplicationWindow {
|
||||
target: BmsInterface
|
||||
|
||||
onPortConnectedChanged: {
|
||||
connectionStatusLabel.text = BmsInterface.isPortConnected() ? qsTr("Connected") : qsTr("Disconnected")
|
||||
connectionStatusLabel.text = Qt.binding(function(){ return BmsInterface.isPortConnected() ? qsTr("Connected") : qsTr("Disconnected") })
|
||||
connectionStatusIndicator.enabled = BmsInterface.isPortConnected()
|
||||
if (BmsInterface.isPortConnected()) {
|
||||
BmsInterface.commands().getBMSconf()
|
||||
@@ -351,7 +375,6 @@ ApplicationWindow {
|
||||
statusPopup.text = msg
|
||||
statusPopup.good = isGood
|
||||
statusPopup.open()
|
||||
hideStatusTimer.start()
|
||||
} else {
|
||||
if (statusPopup.text !== msg) {
|
||||
statusPopup.queue.push({"text": msg, "good": isGood})
|
||||
@@ -395,7 +418,7 @@ ApplicationWindow {
|
||||
Screens.StatusPopup {
|
||||
id: statusPopup
|
||||
|
||||
property var filteredStatuses: []//[qsTr("BMS configuration updated")]
|
||||
property var filteredStatuses: []
|
||||
property var queue: []
|
||||
|
||||
onClosed: {
|
||||
@@ -404,9 +427,13 @@ ApplicationWindow {
|
||||
statusPopup.text = message.text
|
||||
statusPopup.good = message.good
|
||||
statusPopup.open()
|
||||
hideStatusTimer.start()
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: {
|
||||
hideStatusTimer.start()
|
||||
busyPopup.close()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
@@ -415,13 +442,57 @@ ApplicationWindow {
|
||||
onTriggered: statusPopup.close()
|
||||
}
|
||||
|
||||
Popup {
|
||||
id: busyPopup
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height) / 2
|
||||
modal: true
|
||||
closePolicy: Popup.NoAutoClose
|
||||
|
||||
property string text: ""
|
||||
|
||||
background: Rectangle {
|
||||
color: "transparent"
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Controls.BusyIndicator {
|
||||
running: true
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
}
|
||||
|
||||
Controls.SubtitleLabel {
|
||||
text: busyPopup.text
|
||||
color: Palette.alternativeTextColor
|
||||
maximumLineCount: 3
|
||||
wrapMode: Text.Wrap
|
||||
font.pixelSize: 20
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
||||
background: Rectangle {
|
||||
color: Palette.textColor
|
||||
opacity: 0.3
|
||||
radius: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: hideBusyTimer.start()
|
||||
onClosed: hideBusyTimer.stop()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: hideBusyTimer
|
||||
interval: 30000
|
||||
onTriggered: busyPopup.close()
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: Palette.screenBackgroundColor
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// BmsInterface.bmsConfig().loadParamsXml("://res/config.xml")
|
||||
// BmsInterface.infoConfig().loadParamsXml("://res/info.xml")
|
||||
connectionDialog.open()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user