From 545977a4b725b009459d262cb9acaa1ccf8355b2 Mon Sep 17 00:00:00 2001 From: Yury Shuvakin Date: Sun, 28 Aug 2022 16:32:07 +0300 Subject: [PATCH] Added scrollbars for lists and text fields. Added saving to the path settings for configuration files and the current language. Various UI improvements --- configparams.h | 2 +- qml/Controls/MenuItemDelegate.qml | 5 +- qml/Controls/ScrollBar.qml | 40 ++-- qml/Controls/ScrollIndicator.qml | 40 ++++ qml/Controls/qmldir | 1 + qml/MainWindow.qml | 9 +- qml/Screens/AkbMonitorScreen.qml | 7 + qml/Screens/BmsServiceScreen.qml | 17 +- qml/Screens/BmsSettingsScreen.qml | 33 +++- qml/Screens/CellMonitorScreen.qml | 10 + qml/Screens/DebugInformationScreen.qml | 36 +++- qml/Screens/VisualizationScreen.qml | 3 + qml/qml_items.qrc | 1 + translations/cubo_en.ts | 262 +++++++++++++------------ translations/cubo_it.ts | 262 +++++++++++++------------ translations/cubo_ru.qm | Bin 17941 -> 18167 bytes translations/cubo_ru.ts | 262 +++++++++++++------------ translator.cpp | 32 ++- 18 files changed, 607 insertions(+), 415 deletions(-) create mode 100644 qml/Controls/ScrollIndicator.qml diff --git a/configparams.h b/configparams.h index 417d0b6..47f0eb4 100644 --- a/configparams.h +++ b/configparams.h @@ -100,7 +100,7 @@ public: bool setXML(QXmlStreamReader &stream, QString configName); Q_INVOKABLE bool saveXml(QString fileName, QString configName); Q_INVOKABLE bool loadXml(QString fileName, QString configName); - QString xmlStatus(); + Q_INVOKABLE QString xmlStatus(); void getParamsXML(QXmlStreamWriter &stream); bool setParamsXML(QXmlStreamReader &stream); diff --git a/qml/Controls/MenuItemDelegate.qml b/qml/Controls/MenuItemDelegate.qml index 71e41a3..26803ee 100644 --- a/qml/Controls/MenuItemDelegate.qml +++ b/qml/Controls/MenuItemDelegate.qml @@ -53,7 +53,8 @@ ItemDelegate { } background: Rectangle { - color: control.pressed ? Palette.pressedButtonColor : - control.hovered ? Palette.hoveredButtonColor : Palette.buttonColor + color: control.pressed || control.highlighted ? + Palette.pressedButtonColor : control.hovered ? + Palette.hoveredButtonColor : Palette.buttonColor } } diff --git a/qml/Controls/ScrollBar.qml b/qml/Controls/ScrollBar.qml index a8fd1f4..932cdca 100644 --- a/qml/Controls/ScrollBar.qml +++ b/qml/Controls/ScrollBar.qml @@ -5,22 +5,36 @@ import Utils 1.0 ScrollBar { id: control - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 2 + visible: control.policy !== ScrollBar.AlwaysOff + minimumSize: orientation == Qt.Horizontal ? height / width : width / height contentItem: Rectangle { - implicitWidth: 12 - implicitHeight: 100 - radius: width / 2 - color: Palette.alternativeBackgroundColor - // Hide the ScrollBar when it's not needed. - opacity: control.policy === ScrollBar.AlwaysOn || (control.active && control.size < 1.0) ? 0.75 : 0 + implicitWidth: control.interactive ? 6 : 2 + implicitHeight: control.interactive ? 6 : 2 - // Animate the changes in opacity (default duration is 250 ms). - Behavior on opacity { - NumberAnimation {} + radius: width / 2 + color: control.pressed ? Palette.alternativeBackgroundColor : Qt.lighter(Palette.alternativeBackgroundColor, 1.1) + opacity: 0.0 + + states: State { + name: "active" + when: control.policy === ScrollBar.AlwaysOn || (control.active && control.size < 1.0) + PropertyChanges { target: control.contentItem; opacity: 0.75 } + } + + transitions: Transition { + from: "active" + SequentialAnimation { + PauseAnimation { duration: 450 } + NumberAnimation { target: control.contentItem; duration: 200; property: "opacity"; to: 0.0 } + } } } } diff --git a/qml/Controls/ScrollIndicator.qml b/qml/Controls/ScrollIndicator.qml new file mode 100644 index 0000000..beb4b4f --- /dev/null +++ b/qml/Controls/ScrollIndicator.qml @@ -0,0 +1,40 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +import Utils 1.0 + +ScrollIndicator { + id: control + + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) + + padding: 2 + + contentItem: Rectangle { + implicitWidth: 2 + implicitHeight: 2 + + color: Palette.alternativeBackgroundColor + visible: control.size < 1.0 + opacity: 0.0 + + states: State { + name: "active" + when: control.active + PropertyChanges { target: control.contentItem; opacity: 0.75 } + } + + transitions: [ + Transition { + from: "active" + SequentialAnimation { + PauseAnimation { duration: 450 } + NumberAnimation { target: control.contentItem; duration: 200; property: "opacity"; to: 0.0 } + } + } + ] + } +} diff --git a/qml/Controls/qmldir b/qml/Controls/qmldir index 866e050..d97719b 100644 --- a/qml/Controls/qmldir +++ b/qml/Controls/qmldir @@ -22,3 +22,4 @@ DialogHeader 1.0 DialogHeader.qml DialogBackground 1.0 DialogBackground.qml BusyIndicator 1.0 BusyIndicator.qml MenuItemDelegate 1.0 MenuItemDelegate.qml +ScrollIndicator 1.0 ScrollIndicator.qml diff --git a/qml/MainWindow.qml b/qml/MainWindow.qml index a1e89ae..0bef1c2 100644 --- a/qml/MainWindow.qml +++ b/qml/MainWindow.qml @@ -71,6 +71,8 @@ ApplicationWindow { ListView { id: menuView + clip: true + boundsBehavior: Flickable.StopAtBounds property var menuModel: [ {"text": qsTr("AKB monitor"), "icon": "qrc:/Icons/akb-monitor.svg"}, @@ -87,6 +89,7 @@ ApplicationWindow { width: ListView.view.width text: menuView.menuModel[modelData].text icon.source: menuView.menuModel[modelData].icon + highlighted: ListView.isCurrentItem minimized: pane.minimized onClicked: menuView.currentIndex = index } @@ -291,7 +294,7 @@ ApplicationWindow { } Layout.preferredWidth: languagesLayout.implicitWidth - Layout.fillHeight: true + Layout.preferredHeight: languagesLayout.implicitHeight } } @@ -331,6 +334,7 @@ ApplicationWindow { } Screens.DebugInformationScreen { + id: debugScreen } Screens.BmsServiceScreen { @@ -351,6 +355,8 @@ ApplicationWindow { serialLabel.text = "-" firmwareLabel.text = "-" } + + debugScreen.printMessage(BmsInterface.getConnectedPortName(), true) } onMessageDialog: { @@ -494,5 +500,6 @@ ApplicationWindow { Component.onCompleted: { connectionDialog.open() + Qt.callLater(debugScreen.printMessage, qsTr("Tool started"), true) } } diff --git a/qml/Screens/AkbMonitorScreen.qml b/qml/Screens/AkbMonitorScreen.qml index 93c4c1f..099f275 100644 --- a/qml/Screens/AkbMonitorScreen.qml +++ b/qml/Screens/AkbMonitorScreen.qml @@ -332,9 +332,16 @@ Item { onVisibleChanged: getValues() + Timer { + id: refreshValuesTimer + interval: 5000 + onTriggered: getValues() + } + function getValues() { if (BmsInterface.isPortConnected() && visible) { BmsInterface.commands().getValues() + refreshValuesTimer.start() } } } diff --git a/qml/Screens/BmsServiceScreen.qml b/qml/Screens/BmsServiceScreen.qml index 71351b2..11da120 100644 --- a/qml/Screens/BmsServiceScreen.qml +++ b/qml/Screens/BmsServiceScreen.qml @@ -12,12 +12,20 @@ ColumnLayout { Keys.onEnterPressed: sendButton.clicked() Controls.Frame { - ScrollView { + Flickable { + id: outputFlickable + clip: true anchors.fill: parent - Controls.TextArea { + boundsBehavior: Flickable.StopAtBounds + + TextArea.flickable: Controls.TextArea { id: outputArea } + + ScrollBar.horizontal: Controls.ScrollBar {} + ScrollBar.vertical: Controls.ScrollBar {} } + Layout.fillWidth: true Layout.fillHeight: true } @@ -58,6 +66,9 @@ ColumnLayout { Connections { target: BmsInterface.commands() - onPrintReceived: outputArea.append(str) + onPrintReceived: { + outputArea.append(str) + outputArea.cursorPosition = outputArea.length + } } } diff --git a/qml/Screens/BmsSettingsScreen.qml b/qml/Screens/BmsSettingsScreen.qml index eeee39f..729124f 100644 --- a/qml/Screens/BmsSettingsScreen.qml +++ b/qml/Screens/BmsSettingsScreen.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import QtQuick.Dialogs 1.2 +import Qt.labs.settings 1.1 import Controls 1.0 as Controls import Cubo 1.0 @@ -20,6 +21,7 @@ RowLayout { id: settingsFlickable clip: true contentHeight: configLayout.height + boundsBehavior: Flickable.StopAtBounds ColumnLayout { id: configLayout @@ -587,9 +589,17 @@ RowLayout { folder: shortcuts.documents nameFilters: [ qsTr("Configuration files (*.xml)"), qsTr("All files (*)") ] onAccepted: { - BmsInterface.bmsConfig().loadXml(loadFileDialog.fileUrl.toString().replace(/^(file:\/{3})/, ""), "bmsConfiguration") + let result = BmsInterface.bmsConfig().loadXml(loadFileDialog.fileUrl.toString().replace(/^(file:\/{3})/, ""), "bmsConfiguration") + if (!result) { + BmsInterface.emitStatusMessage(BmsInterface.bmsConfig().xmlStatus(), false) + } } } + + Settings { + category: "loadConfiguration" + property alias folder: loadFileDialog.folder + } } Controls.OutlineButton { @@ -604,15 +614,23 @@ RowLayout { folder: shortcuts.documents nameFilters: [ qsTr("Configuration files (*.xml)"), qsTr("All files (*)") ] onAccepted: { - BmsInterface.bmsConfig().saveXml(saveFileDialog.fileUrl.toString().replace(/^(file:\/{3})/, ""), "bmsConfiguration") + let result = BmsInterface.bmsConfig().saveXml(saveFileDialog.fileUrl.toString().replace(/^(file:\/{3})/, ""), "bmsConfiguration") + if (!result) { + BmsInterface.emitStatusMessage(BmsInterface.bmsConfig().xmlStatus(), false) + } else { + BmsInterface.emitStatusMessage(qsTr("BMS configuration saved to file"), true) + } } } + + Settings { + category: "saveConfiguration" + property alias folder: saveFileDialog.folder + } } } - ScrollBar.vertical: Controls.ScrollBar { -// policy: ScrollBar.AlwaysOn - } + ScrollBar.vertical: Controls.ScrollBar {} Layout.fillWidth: true Layout.fillHeight: true @@ -658,7 +676,10 @@ RowLayout { Controls.LinkLabel { text: qsTr("Current sensor value \"0\"") - onClicked: settingsFlickable.contentY = zeroSensorSettingsFrame.mapToItem(settingsFlickable.contentItem, 0, 0).y + onClicked: { + settingsFlickable.contentY = zeroSensorSettingsFrame.mapToItem(settingsFlickable.contentItem, 0, 0).y + settingsFlickable.returnToBounds() + } } Item { diff --git a/qml/Screens/CellMonitorScreen.qml b/qml/Screens/CellMonitorScreen.qml index 88195e8..48ce212 100644 --- a/qml/Screens/CellMonitorScreen.qml +++ b/qml/Screens/CellMonitorScreen.qml @@ -1,4 +1,5 @@ import QtQuick 2.12 +import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import QtGraphicalEffects 1.0 @@ -123,6 +124,7 @@ Item { header: cellListHeader delegate: cellListDelegate + ScrollBar.vertical: Controls.ScrollBar {} } Layout.fillWidth: true @@ -145,6 +147,7 @@ Item { header: cellListHeader delegate: cellListDelegate + ScrollBar.vertical: Controls.ScrollBar {} } Layout.fillWidth: true @@ -182,9 +185,16 @@ Item { onVisibleChanged: getValues() + Timer { + id: refreshValuesTimer + interval: 5000 + onTriggered: getValues() + } + function getValues() { if (BmsInterface.isPortConnected() && visible) { BmsInterface.commands().getCells() + refreshValuesTimer.start() } } } diff --git a/qml/Screens/DebugInformationScreen.qml b/qml/Screens/DebugInformationScreen.qml index 6c73a46..c59e51f 100644 --- a/qml/Screens/DebugInformationScreen.qml +++ b/qml/Screens/DebugInformationScreen.qml @@ -4,17 +4,27 @@ import QtQuick.Layouts 1.12 import Controls 1.0 as Controls import Cubo 1.0 +import Utils 1.0 ColumnLayout { spacing: 20 Controls.Frame { - ScrollView { + Flickable { + id: outputFlickable + clip: true anchors.fill: parent - Controls.TextArea { + boundsBehavior: Flickable.StopAtBounds + + TextArea.flickable: Controls.TextArea { id: outputArea + textFormat: Text.RichText } + + ScrollBar.horizontal: Controls.ScrollBar { } + ScrollBar.vertical: Controls.ScrollBar { } } + Layout.fillWidth: true Layout.fillHeight: true } @@ -27,9 +37,27 @@ ColumnLayout { Connections { target: BmsInterface + onStatusMessage: printMessage(msg, isGood) + } - onStatusMessage: { - outputArea.append(msg) + function printMessage(msg, isGood) { + var message = "" + + if (!isGood) { + message += "" } + + message += new Date().toLocaleString(Qt.locale("en-US"), "dd.MM.yyyy hh:mm:ss") + ": " + msg + + if (!isGood) { + message += "" + } + + message += "
" + + outputArea.insert(outputArea.length, message) + outputArea.cursorPosition = outputArea.length + + outputFlickable.contentX = 0 } } diff --git a/qml/Screens/VisualizationScreen.qml b/qml/Screens/VisualizationScreen.qml index 84b104f..ed10123 100644 --- a/qml/Screens/VisualizationScreen.qml +++ b/qml/Screens/VisualizationScreen.qml @@ -1,4 +1,5 @@ import QtQuick 2.12 +import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 import QtCharts 2.3 @@ -169,6 +170,8 @@ ColumnLayout { model: seriesCount delegate: legendDelegate visible: !horizontalLegend + boundsBehavior: Flickable.StopAtBounds + ScrollBar.vertical: Controls.ScrollBar {} property Controls.ChartView chartItem: chart diff --git a/qml/qml_items.qrc b/qml/qml_items.qrc index ed200fa..f204e44 100644 --- a/qml/qml_items.qrc +++ b/qml/qml_items.qrc @@ -38,5 +38,6 @@ Utils/MathHelper.qml Controls/BusyIndicator.qml Controls/MenuItemDelegate.qml + Controls/ScrollIndicator.qml diff --git a/translations/cubo_en.ts b/translations/cubo_en.ts index fd3ca5b..1f2dd6a 100644 --- a/translations/cubo_en.ts +++ b/translations/cubo_en.ts @@ -209,17 +209,17 @@ BmsServiceScreen - + Clear - + Send - + Help @@ -227,226 +227,231 @@ BmsSettingsScreen - - + + Serial number - - + + Configuration - + Number of boards - + Number of cells - - + + SOC - + Number of cells connected in parallel - + Battery capacity - - + + Limits - + Maximum charge current, A - + Maximum load current, A - + Maximum temperature, °C - - + + Cell configuration - + Lower disable threshold, V - + Upper disable threshold, V - + Lower enable threshold (should be higher than disable), V - + Upper enable threshold (should be higher than disable), V - - + + Balancing configuration - + Balancing start voltage, V - + Cell voltage delta to start balancing, V - + Cell balancing interval, ms - - + + Output settings - + # 1 - + Use for storage management - + # 2 - + # 3 - + # 4 - + + BMS configuration saved to file + + + + Read default settings - + The settings are written to non-volatile memory. Wait, please. - + Normally closed - + Change in value during SOC - - + + Closes at t<, °C - - + + Opens at t>, °C - - + + Current sensor value "0" - + Calibrate "0" - + Load settings from file - - + + Select configuration file - - + + Configuration files (*.xml) - - + + All files (*) - + Save settings to file - + Read current settings from BMS - + Write to non-volatile memory of BMS - + Write current values to BMS @@ -454,22 +459,22 @@ Wait, please. CellMonitorScreen - + # - + Voltage - + Balancing - + V @@ -540,7 +545,7 @@ Wait, please. DebugInformationScreen - + Clear @@ -558,74 +563,79 @@ Wait, please. - - + + AKB monitor - - + + Cell monitor - + Configuration - - + + Visualization - + History - + BMS service - + Connection - + BMS settings - + Information output - + Terminal - - + + Disconnected - + Serial number - + Connected + + + Tool started + + MessageDialog @@ -677,140 +687,140 @@ Wait, please. VisualizationScreen - + Voltage - + Current - + Battery temperature - + BMS temperature - + Cell voltage - + Cell list - - - - - - + + + + + + Time, s - - - + + + Voltage, V - + Current, A - - + + Temperature, °C - + Pause data collection - + Resume data collection - + Clear data - + Reset zoom - - + + Cell # - - + + Voltage indicator - - + + Current indicator - - - - + + + + Maximum temperature - - - - + + + + Average temperature - - - - + + + + Minimum temperature - - + + Maximum voltage - - + + Average voltage - - + + Minimum voltage diff --git a/translations/cubo_it.ts b/translations/cubo_it.ts index e384e53..8a147be 100644 --- a/translations/cubo_it.ts +++ b/translations/cubo_it.ts @@ -209,17 +209,17 @@ BmsServiceScreen - + Clear - + Send - + Help @@ -227,226 +227,231 @@ BmsSettingsScreen - - + + Serial number - - + + Configuration - + Number of boards - + Number of cells - - + + SOC - + Number of cells connected in parallel - + Battery capacity - - + + Limits - + Maximum charge current, A - + Maximum load current, A - + Maximum temperature, °C - - + + Cell configuration - + Lower disable threshold, V - + Upper disable threshold, V - + Lower enable threshold (should be higher than disable), V - + Upper enable threshold (should be higher than disable), V - - + + Balancing configuration - + Balancing start voltage, V - + Cell voltage delta to start balancing, V - + Cell balancing interval, ms - - + + Output settings - + # 1 - + Use for storage management - + # 2 - + # 3 - + # 4 - + + BMS configuration saved to file + + + + Read default settings - + The settings are written to non-volatile memory. Wait, please. - + Normally closed - + Change in value during SOC - - + + Closes at t<, °C - - + + Opens at t>, °C - - + + Current sensor value "0" - + Calibrate "0" - + Load settings from file - - + + Select configuration file - - + + Configuration files (*.xml) - - + + All files (*) - + Save settings to file - + Read current settings from BMS - + Write to non-volatile memory of BMS - + Write current values to BMS @@ -454,22 +459,22 @@ Wait, please. CellMonitorScreen - + # - + Voltage - + Balancing - + V @@ -540,7 +545,7 @@ Wait, please. DebugInformationScreen - + Clear @@ -558,74 +563,79 @@ Wait, please. - - + + AKB monitor - - + + Cell monitor - + Configuration - - + + Visualization - + History - + BMS service - + Connection - + BMS settings - + Information output - + Terminal - - + + Disconnected - + Serial number - + Connected + + + Tool started + + MessageDialog @@ -677,140 +687,140 @@ Wait, please. VisualizationScreen - + Voltage - + Current - + Battery temperature - + BMS temperature - + Cell voltage - + Cell list - - - - - - + + + + + + Time, s - - - + + + Voltage, V - + Current, A - - + + Temperature, °C - + Pause data collection - + Resume data collection - + Clear data - + Reset zoom - - + + Cell # - - + + Voltage indicator - - + + Current indicator - - - - + + + + Maximum temperature - - - - + + + + Average temperature - - - - + + + + Minimum temperature - - + + Maximum voltage - - + + Average voltage - - + + Minimum voltage diff --git a/translations/cubo_ru.qm b/translations/cubo_ru.qm index 04eeb25aa5409fe927e709787023550171a041ef..97fe8bb9080ffe8f5408de3e321af1f2d641e567 100644 GIT binary patch delta 1231 zcmX|=dr(wm7{;G-_S@y`;Ve5`0_5fbEg+X=xyt>rTm}V#3DBCfhS-IeQ7D&1iD(UC z5J#+7a72m95Y4eah!SROHbo??v5Un_PD~iGn!=PwGvv@@FYQc!eDlovo$tKg^ZwrV z>p#M+^>A-{r5*wh3dFRM?jT(P*buOFigc0G0m##VSUc%+K(aTf1xQi6QyONCCl7SZir3z(PR{+^VwD@%ZPqv}$H93&^2z}r3 zbYqEAx9oIkl7Q(11rSon`Aqha3kMf6^cS65;k0uLh(h25Hxu_cSz6^5Ix2z0ac(ii z1f;ET>-rxl7I?4o&jSHwTOb#1Jw7hT%LG3^Pys}nc*n0{ zK+qljZi^AfD3oPAref2M$#%!A0%3<`FT5vP6{;CJQ4x2UXyaCvKV5a9VpKJqD*8?h+AW$C1g_RD|! zjLO|IqR4Q6hBzlG=E|R-|K=4A-6?n?)2LXk{s++Pb!z-=TNS_Adfa7tmePkUyR2=r zBkP(F)E*2dUJ?wVJK32RI*N*DKp^zD7LZH|mnXlcwp|ov#>_zcv%*a+)fYdc^jmMD zHfJl7bfYv^{mS}T;^Ug8JbK?j-~E+y?~_gcW#xSLY0CSSa`lU=#3lV{QROiRXjeqv z-8aZ@j2Lt9PXd}HR<9=ldWUH8^a4~7qN$iT>5Ij>5=xLAFIx25sGJFLe>2621>%9T zwLtEg*!EE&@$?fvK1rP1n#F5J=zs2Sr)I{AONB}@@}8^g^-x%m>+M>W@dgc~;My~F z7tl?*I>tXFfJ08z4!S;UqgW$J?pMD7d@3X_p5h>-w6n`W19?KKIdPpD#iUoJMgaa3 zsd@W`>ZDgAiMPH-YQ11562D7*+#HZpE?xS82)o2d(-^hglX+NmUaFcio#eerWj;i2 zC-=Cj^MQ$aYf*KV`_NnBRHHsLOu8!7R~r^%bKH2}UntcLx5~=|SzF{bcK-@lxTF>@ z+$0tqYVU+;AaYn8G&M!%y40p!6*T0FYRf3ilr*hw=}Q9A&!~I%*r9=Mm-=*RExnZm z^~FDo#9~E#r=kH+e^3t?^2U1E1Ai9-b7ui8*ya|qDZdOFmdmnO0n1@}mdTQ6>1i*X zRzB^dvUFi%XcV+I8%irQHH{6m^>vng)lKz{4H|QGv&m@tE;@9qUE{SWQNu!+fu*o? nT897fY^5C8ERSt-X8u2yRN2_LM`LcP-e=29@fkaoYL)&4{|P-c delta 1068 zcmXAoe@xVM7{}k=A9vh+?|XMcP7Z+sf$kvr;T;?pa3L0%1*RKVZgQByWjb>;L}5h7 z51FxvD}MZeF-l7_XMeCOt)&=0ytEA~i!C?uSDcnIGH_DEW$$@^z4v^-&*$?z@7MEu z<~xPn1HyZj{CWT>K*oLQ%RpugAP)d}v(zbIMHHYZ1eUL$ZUS;ksCE4Aet)gQpL!1R zv=fM}g{Gf>Vvl2)qZV+S!HemwjPt|lvY@PQE1)-GUC}5Y&7vW;jfEee>1_@0bSip& z5LvM-tZ6@n)!l+%juuE77px;a?4n9Y9{7iOe+%}>n@ESvC0uZwVM}wu&9(}_?G&b- z@&N^QVZr$ekkcYsPF4YN)7>^9)h~(re*KOnZQ_ZcJ|O-#ar}*?K*U$#wZ3v7{i+zc z;Q$ggi?Ay>^KRv|;w#xlk zDJ+~P4=E-fdr}_CVE)Q|8fS5U9HKR)*J&&JBTZvQ0uc4D=GYgso95MAuWM(ay_!G1 zq}?YIwVue0p%^EHUbiIwwQATvbBR}!`pSlZyTEKN#cg0SB*;ak*!fuXv zr9L-nkmEJ!w@;9dp+JA|PKbFu`fD9WY45Cl?%a7!saY{D>L(Zb4kgBW8CZHu$!xw) zkUNzv3vPm}QhZSsz?i1^O37#Wn6j;m7Zkm!)Hz>ZzDwD=hjGr3Qh)q4V3l2I`fN3@ ztXui~1M)HLQ7#_fdEsGLJznMRYCYHCLxc1VITx20)_Gd+EK*twonyCwtU^QR^v47@ z5LWwQ!)z1d#CA3E{3XCzu3ALKwpR6({UI*mA+`F@I0uy7eO9viwQA$3A^M$BdxS}D z<3;t`pUE-8r3OJB`Z@K+19C>SvHH_??qO$Gi`$H~@AA162aWCbeB7@YW5;?cpO0W1 zv~qtkFB!jo+}+nEG3F}qz*I3T0Z$B@0(VAPea5Vux&l0(^Uxff6QqBe*;iT4SM4>| z4RU|fpt+$Zm%t~?T|3!e%zpFHwd57Q$^6YMlP diff --git a/translations/cubo_ru.ts b/translations/cubo_ru.ts index e830087..99d6f33 100644 --- a/translations/cubo_ru.ts +++ b/translations/cubo_ru.ts @@ -209,17 +209,17 @@ BmsServiceScreen - + Clear Очистить - + Send Отправить - + Help Помощь @@ -227,212 +227,217 @@ BmsSettingsScreen - - + + Serial number Серийный номер - - + + Configuration Конфигурация - + Number of boards Количество плат - + Number of cells Количество ячеек - - + + SOC SOC - + Number of cells connected in parallel Количество параллельно включенных ячеек - + Battery capacity Ёмкость батареи - - + + Limits Ограничения - + Maximum charge current, A Максимальный ток заряда, A - + Maximum load current, A Максимальный ток нагрузки, A - + Maximum temperature, °C Максимальная температура, C - - + + Cell configuration Конфигурация ячеек - + Lower disable threshold, V Нижний порог отключения, В - + Upper disable threshold, V Верхний порог отключения, В - + Lower enable threshold (should be higher than disable), V Нижний порог включения (должен быть выше отключения), В - + Upper enable threshold (should be higher than disable), V Верхний порог включения (должен быть выше отключения), В - - + + Balancing configuration Конфигурация балансировки - + Balancing start voltage, V Напряжение старта балансировки, В - + Cell voltage delta to start balancing, V Дельта напряжения ячеек для старта балансировки, В - + Cell balancing interval, ms Интервал балансировки ячейки, мс - - + + Output settings Настройка выходов - + # 1 № 1 - + Use for storage management Использовать для управления ЗУ - + # 2 № 2 - + # 3 № 3 - + # 4 № 4 - + + BMS configuration saved to file + БМС конфигурация сохранена в файл + + + Read default settings Загрузить настройки по-умолчанию - + The settings are written to non-volatile memory. Wait, please. Выполняется запись настроек в энергонезависимую память. Пожалуйста подождите. - + Normally closed Нормально замкнут - + Change in value during SOC Изменение значения при SOC - - + + Closes at t<, °C Замыкается при t<, °C - - + + Opens at t>, °C Размыкается при t>, °C - - + + Current sensor value "0" Значение датчика тока «0» - + Calibrate "0" Калибровать «0» - + Load settings from file Загрузить настройки из файла - - + + Select configuration file Выберите файл конфигурации - - + + Configuration files (*.xml) Файлы конфигурации (*.xml) - - + + All files (*) Все файлы (*) - + Save settings to file Сохранить настройки в файл @@ -441,17 +446,17 @@ Wait, please. Загрузить настройки из файла - + Read current settings from BMS Загрузить текущие настройки из BMS - + Write to non-volatile memory of BMS Записать в энергонезависимую память BMS - + Write current values to BMS Записать текущие значения в BMS @@ -459,22 +464,22 @@ Wait, please. CellMonitorScreen - + # - + Voltage Напряжение - + Balancing Балансировка - + V V @@ -545,7 +550,7 @@ Wait, please. DebugInformationScreen - + Clear Очистить @@ -563,75 +568,80 @@ Wait, please. Скрыть меню - - + + AKB monitor Монитор АКБ - - + + Cell monitor Монитор ячеек - + Configuration Конфигурация - - + + Visualization Визуализация - + History История - + BMS service Сервис BMS - + Connection Подключение - + BMS settings Настройка BMS - + Information output Вывод информации - + Terminal Терминал + + + Tool started + Утилита запущена + Exit Выход - - + + Disconnected Отключено - + Serial number Серийный номер - + Connected Подключено @@ -686,140 +696,140 @@ Wait, please. VisualizationScreen - + Voltage Напряжение - + Current Ток - + Battery temperature Температура батареи - + BMS temperature Температура BMS - + Cell voltage Вольтаж ячейки - + Cell list Список ячеек - - - - - - + + + + + + Time, s Время, c - - - + + + Voltage, V Напряжение, В - + Current, A Ток, А - - + + Temperature, °C Температура, °C - + Pause data collection Приостановить сбор данных - + Resume data collection Продолжить сбор данных - + Clear data Очистить данные - + Reset zoom Сбросить масштаб - - + + Cell # Ячейка № - - + + Voltage indicator Показатель вольтажа - - + + Current indicator Показатель тока - - - - + + + + Maximum temperature Максимальная температура - - - - + + + + Average temperature Средняя температура - - - - + + + + Minimum temperature Минимальная температура - - + + Maximum voltage Максимальное напряжение - - + + Average voltage Среднее напряжение - - + + Minimum voltage Минимальное напряжение diff --git a/translator.cpp b/translator.cpp index 54aec58..0e9620a 100644 --- a/translator.cpp +++ b/translator.cpp @@ -5,6 +5,13 @@ #include #include #include +#include + + +namespace +{ + const QString settingsKey = "translator/currentLanguage"; +} Translator::Translator(QQmlEngine *engine, QObject *parent) : QObject(parent), @@ -34,17 +41,26 @@ Translator::Translator(QQmlEngine *engine, QObject *parent) : QCoreApplication::installTranslator(mCurrentTranslator); - if (QLocale::system().language() == QLocale::Russian) + QSettings settings; + + if (!settings.contains(::settingsKey)) { - setCurrentLanguage(Language::Russian); - } - else if (QLocale::system().language() == QLocale::Italian) - { - setCurrentLanguage(Language::Italian); + if (QLocale::system().language() == QLocale::Russian) + { + setCurrentLanguage(Language::Russian); + } + else if (QLocale::system().language() == QLocale::Italian) + { + setCurrentLanguage(Language::Italian); + } + else + { + setCurrentLanguage(Language::English); + } } else { - setCurrentLanguage(Language::English); + setCurrentLanguage(static_cast(settings.value(::settingsKey).toInt())); } } @@ -74,6 +90,8 @@ void Translator::setCurrentLanguage(Language language) emit currentLanguageChanged(); emit currentLanguageNameChanged(); emit currentLanguageIconChanged(); + + QSettings().setValue(::settingsKey, static_cast(mCurrentLanguage)); } QString Translator::currentLanguageName() const