mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-15 05:22:53 +08:00
parent
0fed6aff86
commit
11374a815b
@ -7,10 +7,13 @@
|
||||
<file>icons/bug.svg</file>
|
||||
<file>icons/chart.svg</file>
|
||||
<file>icons/code.svg</file>
|
||||
<file>icons/connect.svg</file>
|
||||
<file>icons/copy.svg</file>
|
||||
<file>icons/delete.svg</file>
|
||||
<file>icons/developer-board.svg</file>
|
||||
<file>icons/device-hub.svg</file>
|
||||
<file>icons/disconnect.svg</file>
|
||||
<file>icons/drag-drop.svg</file>
|
||||
<file>icons/equalizer.svg</file>
|
||||
<file>icons/error.svg</file>
|
||||
<file>icons/ethernet.svg</file>
|
||||
@ -46,10 +49,10 @@
|
||||
<file>instruments/AttitudeDial.svg</file>
|
||||
<file>instruments/AttitudePointer.svg</file>
|
||||
<file>instruments/Crosshair.svg</file>
|
||||
<file>messages/Welcome_DE.txt</file>
|
||||
<file>messages/Welcome_EN.txt</file>
|
||||
<file>messages/Welcome_ES.txt</file>
|
||||
<file>messages/Welcome_ZH.txt</file>
|
||||
<file>messages/Welcome_DE.txt</file>
|
||||
<file>qml/Widgets/AccelerometerDelegate.qml</file>
|
||||
<file>qml/Widgets/ArtificialHorizonDelegate.qml</file>
|
||||
<file>qml/Widgets/BarDelegate.qml</file>
|
||||
@ -69,14 +72,13 @@
|
||||
<file>qml/Windows/Toolbar.qml</file>
|
||||
<file>qml/Windows/Widgets.qml</file>
|
||||
<file>qml/main.qml</file>
|
||||
<file>translations/de.qm</file>
|
||||
<file>translations/de.ts</file>
|
||||
<file>translations/en.qm</file>
|
||||
<file>translations/en.ts</file>
|
||||
<file>translations/es.qm</file>
|
||||
<file>translations/es.ts</file>
|
||||
<file>translations/zh.qm</file>
|
||||
<file>translations/zh.ts</file>
|
||||
<file>icons/drag-drop.svg</file>
|
||||
<file>translations/de.qm</file>
|
||||
<file>translations/de.ts</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
1
assets/icons/connect.svg
Normal file
1
assets/icons/connect.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M16.01 7L16 3h-2v4h-4V3H8v4h-.01C7 6.99 6 7.99 6 8.99v5.49L9.5 18v3h5v-3l3.5-3.51v-5.5c0-1-1-2-1.99-1.99z"/></svg>
|
After Width: | Height: | Size: 243 B |
1
assets/icons/disconnect.svg
Normal file
1
assets/icons/disconnect.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M18 14.49V9c0-1-1.01-2.01-2-2V3h-2v4h-4V3H8v2.48l9.51 9.5.49-.49zm-1.76 1.77L7.2 7.2l-.01.01L3.98 4 2.71 5.25l3.36 3.36C6.04 8.74 6 8.87 6 9v5.48L9.5 18v3h5v-3l.48-.48L19.45 22l1.26-1.28-4.47-4.46z"/></svg>
|
After Width: | Height: | Size: 337 B |
@ -136,6 +136,12 @@ Window {
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
onClicked: CppExport.openLogFile()
|
||||
text: qsTr("Open log file") + CppTranslator.dummy
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Documentation") + CppTranslator.dummy
|
||||
|
@ -48,12 +48,11 @@ Control {
|
||||
property alias dmAuto: commAuto.checked
|
||||
property alias dmManual: commManual.checked
|
||||
property alias dmParity: parity.currentIndex
|
||||
property alias dmCsvExport: csvLogging.checked
|
||||
property alias dmStopBits: stopBits.currentIndex
|
||||
property alias dmDataBits: dataBits.currentIndex
|
||||
property alias dmOpenMode: openMode.currentIndex
|
||||
property alias dmBaudIndex: baudRate.currentIndex
|
||||
property alias dmCustomBrEnabled: customBr.checked
|
||||
property alias dmCustomBaudRate: customBaudRateValue.value
|
||||
property alias dmBaudValue: baudRate.currentIndex
|
||||
property alias dmFlowControl: flowControl.currentIndex
|
||||
property alias appLanguage: languageCombo.currentIndex
|
||||
property alias dmDisplayMode: displayMode.currentIndex
|
||||
@ -146,6 +145,34 @@ Control {
|
||||
qsTr("Select map file") + "...")
|
||||
}
|
||||
|
||||
//
|
||||
// CSV options
|
||||
//
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
CheckBox {
|
||||
id: csvLogging
|
||||
checked: true
|
||||
palette.highlight: "#2e895c"
|
||||
Layout.leftMargin: -app.spacing
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text: qsTr("CSV Export") + CppTranslator.dummy
|
||||
onCheckedChanged: CppExport.exportEnabled = checked
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
opacity: enabled ? 1 : 0.5
|
||||
enabled: commManual.checked
|
||||
onClicked: CppCsvPlayer.openFile()
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text: qsTr("CSV Player") + CppTranslator.dummy
|
||||
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Spacer
|
||||
//
|
||||
@ -166,36 +193,55 @@ Control {
|
||||
// COM port selector
|
||||
//
|
||||
Label {
|
||||
opacity: enabled ? 1 : 0.5
|
||||
enabled: !CppSerialManager.connected
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
text: qsTr("COM Port") + ":" + CppTranslator.dummy
|
||||
} ComboBox {
|
||||
id: portSelector
|
||||
Layout.fillWidth: true
|
||||
model: CppSerialManager.portList
|
||||
currentIndex: CppSerialManager.portIndex
|
||||
onCurrentIndexChanged: CppSerialManager.setPort(currentIndex)
|
||||
onCurrentIndexChanged: {
|
||||
if (currentIndex !== CppSerialManager.portIndex)
|
||||
CppSerialManager.portIndex = currentIndex
|
||||
}
|
||||
|
||||
opacity: enabled ? 1 : 0.5
|
||||
enabled: !CppSerialManager.connected
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
}
|
||||
|
||||
//
|
||||
// Baud rate selector
|
||||
//
|
||||
Label {
|
||||
text: qsTr("Baud Rate") + ":" + CppTranslator.dummy
|
||||
|
||||
enabled: !customBr.checked
|
||||
opacity: enabled ? 1 : 0.5
|
||||
enabled: !CppSerialManager.connected
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
|
||||
text: qsTr("Baud Rate") + ":" + CppTranslator.dummy
|
||||
} ComboBox {
|
||||
id: baudRate
|
||||
editable: true
|
||||
currentIndex: 3
|
||||
Layout.fillWidth: true
|
||||
enabled: !CppSerialManager.connected
|
||||
model: CppSerialManager.baudRateList
|
||||
currentIndex: CppSerialManager.baudRateIndex
|
||||
onCurrentIndexChanged: {
|
||||
if (CppSerialManager.baudRateIndex !== currentIndex && enabled)
|
||||
CppSerialManager.baudRateIndex = currentIndex
|
||||
|
||||
validator: IntValidator {
|
||||
bottom: 1
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
if (find(editText) === -1)
|
||||
CppSerialManager.appendBaudRate(editText)
|
||||
}
|
||||
|
||||
onCurrentTextChanged: {
|
||||
var value = currentText
|
||||
CppSerialManager.baudRate = value
|
||||
}
|
||||
|
||||
enabled: !customBr.checked
|
||||
opacity: enabled ? 1 : 0.5
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
}
|
||||
@ -207,6 +253,7 @@ Control {
|
||||
text: qsTr("Open mode") + ":" + CppTranslator.dummy
|
||||
} ComboBox {
|
||||
id: openMode
|
||||
currentIndex: 1
|
||||
Layout.fillWidth: true
|
||||
model: root.serialOpenModes
|
||||
onCurrentIndexChanged: {
|
||||
@ -233,32 +280,6 @@ Control {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Custom baud rate
|
||||
//
|
||||
CheckBox {
|
||||
id: customBr
|
||||
Layout.leftMargin: -app.spacing
|
||||
text: qsTr("Custom baud rate") + CppTranslator.dummy
|
||||
} SpinBox {
|
||||
id: customBaudRateValue
|
||||
|
||||
from: 1
|
||||
stepSize: 1
|
||||
to: 10000000
|
||||
value: 9600
|
||||
editable: true
|
||||
Layout.fillWidth: true
|
||||
enabled: customBr.checked
|
||||
opacity: enabled ? 1 : 0.5
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
|
||||
onValueChanged: {
|
||||
if (enabled)
|
||||
CppSerialManager.setBaudRate(value)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Spacer
|
||||
//
|
||||
|
@ -24,8 +24,6 @@ import QtQuick 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Controls 2.12
|
||||
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
Control {
|
||||
id: root
|
||||
|
||||
@ -52,13 +50,6 @@ Control {
|
||||
property alias consoleChecked: consoleBt.checked
|
||||
property alias widgetsChecked: widgetsBt.checked
|
||||
|
||||
//
|
||||
// Settings
|
||||
//
|
||||
Settings {
|
||||
property alias dataExport: csvLogging.checked
|
||||
}
|
||||
|
||||
//
|
||||
// Background gradient
|
||||
//
|
||||
@ -165,42 +156,6 @@ Control {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Switch {
|
||||
id: csvLogging
|
||||
checked: true
|
||||
palette.highlight: "#2e895c"
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text: qsTr("CSV Export") + CppTranslator.dummy
|
||||
onCheckedChanged: CppExport.exportEnabled = checked
|
||||
}
|
||||
|
||||
Button {
|
||||
flat: true
|
||||
icon.width: 24
|
||||
icon.height: 24
|
||||
Layout.fillHeight: true
|
||||
icon.color: palette.text
|
||||
icon.source: "qrc:/icons/bug.svg"
|
||||
onClicked: CppExport.openLogFile()
|
||||
text: qsTr("Log") + _btSpacer + CppTranslator.dummy
|
||||
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
}
|
||||
|
||||
Button {
|
||||
flat: true
|
||||
icon.width: 24
|
||||
icon.height: 24
|
||||
Layout.fillHeight: true
|
||||
icon.color: palette.text
|
||||
opacity: enabled ? 1 : 0.5
|
||||
onClicked: CppCsvPlayer.openFile()
|
||||
icon.source: "qrc:/icons/update.svg"
|
||||
text: qsTr("CSV Player") + _btSpacer + CppTranslator.dummy
|
||||
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
}
|
||||
|
||||
Button {
|
||||
flat: true
|
||||
icon.width: 24
|
||||
@ -215,5 +170,49 @@ Control {
|
||||
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: connectBt
|
||||
|
||||
//
|
||||
// Button properties
|
||||
//
|
||||
flat: true
|
||||
icon.width: 24
|
||||
icon.height: 24
|
||||
font.bold: true
|
||||
Layout.fillHeight: true
|
||||
icon.color: palette.buttonText
|
||||
|
||||
//
|
||||
// Device dependent properties
|
||||
//
|
||||
checked: CppSerialManager.connected
|
||||
palette.buttonText: checked ? "#d72d60" : "#2eed5c"
|
||||
text: (checked ? qsTr("Disconnect") : qsTr("Connect")) + _btSpacer
|
||||
icon.source: checked ? "qrc:/icons/disconnect.svg" : "qrc:/icons/connect.svg"
|
||||
|
||||
//
|
||||
// Only enable button if it can be clicked
|
||||
//
|
||||
opacity: enabled ? 1 : 0.5
|
||||
Behavior on opacity {NumberAnimation{}}
|
||||
enabled: CppSerialManager.serialConfigurationOk
|
||||
|
||||
//
|
||||
// Connect to the device through serial port
|
||||
//
|
||||
onClicked: {
|
||||
// Not connected, connect appropiate device
|
||||
if (!CppSerialManager.connected) {
|
||||
if (CppSerialManager.serialConfigurationOk)
|
||||
CppSerialManager.connectDevice()
|
||||
}
|
||||
|
||||
// We are already connected, remove device
|
||||
else
|
||||
CppSerialManager.disconnectDevice()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -237,9 +237,9 @@ ApplicationWindow {
|
||||
Layout.maximumHeight: 48
|
||||
dataChecked: data.visible
|
||||
aboutChecked: about.visible
|
||||
consoleChecked: terminal.visible
|
||||
widgetsChecked: widgets.visible
|
||||
setupChecked: setup.visible
|
||||
widgetsChecked: widgets.visible
|
||||
consoleChecked: terminal.visible
|
||||
onAboutClicked: about.visible ? about.hide() : about.show()
|
||||
onSetupClicked: setup.visible ? setup.hide() : setup.show()
|
||||
|
||||
@ -321,7 +321,7 @@ ApplicationWindow {
|
||||
|
||||
Setup {
|
||||
id: setup
|
||||
property int displayedWidth: 320
|
||||
property int displayedWidth: 340
|
||||
|
||||
function show() {
|
||||
opacity = 1
|
||||
|
Binary file not shown.
@ -39,6 +39,10 @@
|
||||
<source>Copyright © 2020-%1 %2, released under the MIT License.</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open log file</source>
|
||||
<translation>Logdatei öffnen</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AccelerometerDelegate</name>
|
||||
@ -451,6 +455,14 @@
|
||||
<source>Hexadecimal</source>
|
||||
<translation>Hexadezimal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Baud rate registered successfully</source>
|
||||
<translation>Baudrate erfolgreich registriert</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Rate "%1" has been added to baud rate list</source>
|
||||
<translation>Rate "%1" wurde zur Baudratenliste hinzugefügt</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
@ -520,7 +532,22 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>Custom baud rate</source>
|
||||
<translation>Andere Baudrate</translation>
|
||||
<translation type="vanished">Andere Baudrate</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Export</source>
|
||||
<translation>CSV-Export</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation>CSV Player</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Sidebar</name>
|
||||
<message>
|
||||
<source>Open CSV</source>
|
||||
<translation type="obsolete">CSV Öffnen</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -537,22 +564,10 @@
|
||||
<source>About</source>
|
||||
<translation>Über</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Export</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dashboard</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open CSV</source>
|
||||
<translation>CSV Öffnen</translation>
|
||||
@ -561,6 +576,14 @@
|
||||
<source>Setup</source>
|
||||
<translation>Einstellungen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Disconnect</source>
|
||||
<translation>Trennen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Connect</source>
|
||||
<translation>Verbinden</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Updater</name>
|
||||
|
Binary file not shown.
@ -39,6 +39,10 @@
|
||||
<source>Copyright © 2020-%1 %2, released under the MIT License.</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open log file</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AccelerometerDelegate</name>
|
||||
@ -439,6 +443,14 @@
|
||||
<source>Hexadecimal</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Baud rate registered successfully</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Rate "%1" has been added to baud rate list</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
@ -507,7 +519,11 @@
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Custom baud rate</source>
|
||||
<source>CSV Export</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
@ -525,22 +541,10 @@
|
||||
<source>About</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Export</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dashboard</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open CSV</source>
|
||||
<translation></translation>
|
||||
@ -549,6 +553,14 @@
|
||||
<source>Setup</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Disconnect</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Connect</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Updater</name>
|
||||
|
Binary file not shown.
@ -43,6 +43,10 @@
|
||||
<source>Copyright © 2020-%1 %2, released under the MIT License.</source>
|
||||
<translation>Copyright © 2020-%1 %2, distribuido bajo la licencia MIT.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open log file</source>
|
||||
<translation>Abrir archivo de log</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AccelerometerDelegate</name>
|
||||
@ -570,6 +574,14 @@
|
||||
<source>Hexadecimal</source>
|
||||
<translation>Hexadecimal</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Baud rate registered successfully</source>
|
||||
<translation>Nueva tasa de baudios registrada correctamente</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Rate "%1" has been added to baud rate list</source>
|
||||
<translation>Se ha añadido la velocidad "%1" a la lista de tasa de baudios</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
@ -639,7 +651,30 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>Custom baud rate</source>
|
||||
<translation>Otra tasa de baudios</translation>
|
||||
<translation type="vanished">Otra tasa de baudios</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Export</source>
|
||||
<translation>Exportación CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation>Reproductor CSV</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Sidebar</name>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation type="obsolete">Reproductor CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open CSV</source>
|
||||
<translation type="obsolete">Abrir CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log</source>
|
||||
<translation type="obsolete">Registro</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -666,7 +701,7 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Export</source>
|
||||
<translation>Exportación CSV</translation>
|
||||
<translation type="vanished">Exportación CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open past CSV</source>
|
||||
@ -682,11 +717,11 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation>Reproductor CSV</translation>
|
||||
<translation type="vanished">Reproductor CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log</source>
|
||||
<translation>Registro</translation>
|
||||
<translation type="vanished">Registro</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open CSV</source>
|
||||
@ -696,6 +731,14 @@
|
||||
<source>Setup</source>
|
||||
<translation>Configuración</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Disconnect</source>
|
||||
<translation>Desconectar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Connect</source>
|
||||
<translation>Conectar</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Updater</name>
|
||||
|
Binary file not shown.
@ -39,6 +39,10 @@
|
||||
<source>Close</source>
|
||||
<translation>关闭</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open log file</source>
|
||||
<translation>打开日志文件</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AccelerometerDelegate</name>
|
||||
@ -483,6 +487,14 @@
|
||||
<source>Hexadecimal</source>
|
||||
<translation>十六进制</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Baud rate registered successfully</source>
|
||||
<translation>波特率注册成功</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Rate "%1" has been added to baud rate list</source>
|
||||
<translation>速率"%1"已添加到波特率列表中</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
@ -552,7 +564,30 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>Custom baud rate</source>
|
||||
<translation>另一个波特率</translation>
|
||||
<translation type="vanished">另一个波特率</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Export</source>
|
||||
<translation>导出CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation>CSV 播放器</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Sidebar</name>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation type="obsolete">CSV 播放器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open CSV</source>
|
||||
<translation type="obsolete">打开CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log</source>
|
||||
<translation type="obsolete">日志</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -579,15 +614,15 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Export</source>
|
||||
<translation>导出CSV</translation>
|
||||
<translation type="vanished">导出CSV</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Log</source>
|
||||
<translation>日志</translation>
|
||||
<translation type="vanished">日志</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>CSV Player</source>
|
||||
<translation>CSV 播放器</translation>
|
||||
<translation type="vanished">CSV 播放器</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open CSV</source>
|
||||
@ -597,6 +632,14 @@
|
||||
<source>Setup</source>
|
||||
<translation>体系</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Disconnect</source>
|
||||
<translation>断开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Connect</source>
|
||||
<translation>连接</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Updater</name>
|
||||
|
@ -179,14 +179,18 @@ SerialManager::SerialManager()
|
||||
m_port = nullptr;
|
||||
m_receivedBytes = 0;
|
||||
|
||||
// Read settings
|
||||
readSettings();
|
||||
|
||||
// Init serial port configuration variables
|
||||
setDisplayMode(0);
|
||||
setBaudRate(9600);
|
||||
setWriteEnabled(true);
|
||||
disconnectDevice();
|
||||
setDataBits(dataBitsList().indexOf("8"));
|
||||
setStopBits(stopBitsList().indexOf("1"));
|
||||
setParity(parityList().indexOf(tr("None")));
|
||||
setBaudRateIndex(baudRateList().indexOf("9600"));
|
||||
setFlowControl(flowControlList().indexOf(tr("None")));
|
||||
disconnectDevice();
|
||||
|
||||
// Init start/finish sequence strings
|
||||
setStartSequence("/*");
|
||||
@ -369,6 +373,15 @@ QString SerialManager::finishSequence() const
|
||||
return m_finishSeq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns @c true if the user selects the appropiate controls & options to be able
|
||||
* to connect to a serial device
|
||||
*/
|
||||
bool SerialManager::serialConfigurationOk() const
|
||||
{
|
||||
return portIndex() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the current serial device selected by the program.
|
||||
*/
|
||||
@ -395,15 +408,6 @@ quint8 SerialManager::displayMode() const
|
||||
return m_displayMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correspoding index of the baud rate configuration in relation
|
||||
* to the @c QStringList returned by the @c baudRateList() function.
|
||||
*/
|
||||
quint8 SerialManager::baudRateIndex() const
|
||||
{
|
||||
return m_baudRateIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correspoding index of the data bits configuration in relation
|
||||
* to the @c QStringList returned by the @c dataBitsList() function.
|
||||
@ -465,16 +469,7 @@ QStringList SerialManager::parityList() const
|
||||
*/
|
||||
QStringList SerialManager::baudRateList() const
|
||||
{
|
||||
QStringList list;
|
||||
list.append("1200");
|
||||
list.append("2400");
|
||||
list.append("4800");
|
||||
list.append("9600");
|
||||
list.append("19200");
|
||||
list.append("38400");
|
||||
list.append("57600");
|
||||
list.append("115200");
|
||||
return list;
|
||||
return m_baudRateList;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -574,6 +569,67 @@ void SerialManager::configureTextDocument(QQuickTextDocument *doc)
|
||||
doc->textDocument()->setUndoRedoEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the current serial port and tries to open & configure a new serial
|
||||
* port connection with the device at the given port index returned by the @c portIndex()
|
||||
* function.
|
||||
*
|
||||
* @note If another device is connected through a serial port, then the
|
||||
* connection with that device will be canceled/closed before configuring the
|
||||
* new serial port connection.
|
||||
*/
|
||||
void SerialManager::connectDevice()
|
||||
{
|
||||
// Ignore the first item of the list (Select Port)
|
||||
auto ports = validPorts();
|
||||
auto portId = portIndex() - 1;
|
||||
if (portId >= 0 && portId < validPorts().count())
|
||||
{
|
||||
// Update port index variable & disconnect from current serial port
|
||||
disconnectDevice();
|
||||
|
||||
// Create new serial port handler
|
||||
m_port = new QSerialPort(ports.at(portId));
|
||||
|
||||
// Configure serial port
|
||||
port()->setParity(parity());
|
||||
port()->setBaudRate(baudRate());
|
||||
port()->setDataBits(dataBits());
|
||||
port()->setStopBits(stopBits());
|
||||
port()->setFlowControl(flowControl());
|
||||
|
||||
// Connect signals/slots
|
||||
// clang-format off
|
||||
connect(port(), SIGNAL(readyRead()),
|
||||
this, SLOT(onDataReceived()));
|
||||
connect(port(), SIGNAL(aboutToClose()),
|
||||
this, SLOT(disconnectDevice()));
|
||||
connect(port(), SIGNAL(errorOccurred(QSerialPort::SerialPortError)),
|
||||
this, SLOT(handleError(QSerialPort::SerialPortError)));
|
||||
// clang-format on
|
||||
|
||||
// Select open mode for serial port
|
||||
auto mode = QIODevice::ReadOnly;
|
||||
if (writeEnabled())
|
||||
mode = QIODevice::ReadWrite;
|
||||
|
||||
// Try to open the port
|
||||
if (port()->open(mode))
|
||||
{
|
||||
emit connectedChanged();
|
||||
LOG_INFO() << Q_FUNC_INFO << "Serial port opened successfully in " << mode;
|
||||
}
|
||||
|
||||
// Close serial port on error
|
||||
else
|
||||
disconnectDevice();
|
||||
|
||||
// Notify UI that the port status changed
|
||||
emit portChanged();
|
||||
LOG_INFO() << "Serial port selection set to" << portName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the contents of the temporary buffer. This function is called
|
||||
* automatically by the class when the temporary buffer size exceeds the
|
||||
@ -683,6 +739,10 @@ void SerialManager::setBaudRate(const qint32 rate)
|
||||
if (port())
|
||||
port()->setBaudRate(baudRate());
|
||||
|
||||
// Update baud rate index
|
||||
// if (baudRateList().contains(QString::number(rate)))
|
||||
// setBaudRateIndex(baudRateList().indexOf(QString::number(rate)));
|
||||
|
||||
// Update user interface
|
||||
emit baudRateChanged();
|
||||
|
||||
@ -690,82 +750,16 @@ void SerialManager::setBaudRate(const qint32 rate)
|
||||
LOG_INFO() << "Baud rate set to" << rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the current serial port and tries to open & configure a new serial
|
||||
* port connection with the device at the given @a port index.
|
||||
*
|
||||
* Upon serial port configuration the function emits the @c connectionChanged()
|
||||
* signal and the portChanged() signal.
|
||||
*
|
||||
* @note If the @a portIndex is the same as the current port index, then the
|
||||
* function shall not try to reconfigure or close the current serial port.
|
||||
*
|
||||
* @note If another device is connected through a serial port, then the
|
||||
* connection with that device will be canceled/closed before configuring the
|
||||
* new serial port connection.
|
||||
*/
|
||||
void SerialManager::setPort(const quint8 portIndex)
|
||||
void SerialManager::setPortIndex(const quint8 portIndex)
|
||||
{
|
||||
// Port index is equal to 0 -> disconnect current device
|
||||
if (portIndex == 0)
|
||||
{
|
||||
m_portIndex = 0;
|
||||
disconnectDevice();
|
||||
}
|
||||
|
||||
// Abort if portIndex is the same as the actual port index
|
||||
else if (portIndex == m_portIndex)
|
||||
return;
|
||||
|
||||
// Ignore the first item of the list (Select Port)
|
||||
auto ports = validPorts();
|
||||
auto portId = portIndex - 1;
|
||||
if (portId >= 0 && portId < validPorts().count())
|
||||
{
|
||||
// Update port index variable & disconnect from current serial port
|
||||
disconnectDevice();
|
||||
m_portIndex = portIndex;
|
||||
else
|
||||
m_portIndex = 0;
|
||||
|
||||
// Create new serial port handler
|
||||
m_port = new QSerialPort(ports.at(portId));
|
||||
|
||||
// Configure serial port
|
||||
port()->setParity(parity());
|
||||
port()->setBaudRate(baudRate());
|
||||
port()->setDataBits(dataBits());
|
||||
port()->setStopBits(stopBits());
|
||||
port()->setFlowControl(flowControl());
|
||||
|
||||
// Connect signals/slots
|
||||
// clang-format off
|
||||
connect(port(), SIGNAL(readyRead()),
|
||||
this, SLOT(onDataReceived()));
|
||||
connect(port(), SIGNAL(aboutToClose()),
|
||||
this, SLOT(disconnectDevice()));
|
||||
connect(port(), SIGNAL(errorOccurred(QSerialPort::SerialPortError)),
|
||||
this, SLOT(handleError(QSerialPort::SerialPortError)));
|
||||
// clang-format on
|
||||
|
||||
// Select open mode for serial port
|
||||
auto mode = QIODevice::ReadOnly;
|
||||
if (writeEnabled())
|
||||
mode = QIODevice::ReadWrite;
|
||||
|
||||
// Try to open the port in R/RW
|
||||
if (port()->open(mode))
|
||||
{
|
||||
emit connectedChanged();
|
||||
LOG_INFO() << Q_FUNC_INFO << "Serial port opened successfully in RW mode";
|
||||
}
|
||||
|
||||
// Close serial port on error
|
||||
else
|
||||
disconnectDevice();
|
||||
|
||||
// Notify UI that the port status changed
|
||||
emit portChanged();
|
||||
LOG_INFO() << "Serial port selection set to" << portName();
|
||||
}
|
||||
emit portIndexChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -788,7 +782,7 @@ void SerialManager::setWriteEnabled(const bool enabled)
|
||||
{
|
||||
auto index = portIndex();
|
||||
disconnectDevice();
|
||||
setPort(index);
|
||||
setPortIndex(index);
|
||||
}
|
||||
|
||||
emit writeEnabledChanged();
|
||||
@ -841,22 +835,19 @@ void SerialManager::setParity(const quint8 parityIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the baud rate of the serial port.
|
||||
*
|
||||
* @note This function is meant to be used with a combobox in the
|
||||
* QML interface
|
||||
* Registers the new baud rate to the list
|
||||
*/
|
||||
void SerialManager::setBaudRateIndex(const quint8 index)
|
||||
void SerialManager::appendBaudRate(const QString &baudRate)
|
||||
{
|
||||
if (index < baudRateList().count())
|
||||
if (!m_baudRateList.contains(baudRate))
|
||||
{
|
||||
m_baudRateIndex = index;
|
||||
setBaudRate(baudRateList().at(index).toInt());
|
||||
emit baudRateIndexChanged();
|
||||
}
|
||||
m_baudRateList.append(baudRate);
|
||||
writeSettings();
|
||||
emit baudRateListChanged();
|
||||
|
||||
else
|
||||
setBaudRateIndex(baudRateList().indexOf("9600"));
|
||||
NiceMessageBox(tr("Baud rate registered successfully"),
|
||||
tr("Rate \"%1\" has been added to baud rate list").arg(baudRate));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1236,6 +1227,68 @@ void SerialManager::readFrames()
|
||||
clearTempBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read saved settings (if any)
|
||||
*/
|
||||
void SerialManager::readSettings()
|
||||
{
|
||||
// Register standard baud rates
|
||||
QStringList stdBaudRates;
|
||||
stdBaudRates.append("1200");
|
||||
stdBaudRates.append("2400");
|
||||
stdBaudRates.append("4800");
|
||||
stdBaudRates.append("9600");
|
||||
stdBaudRates.append("19200");
|
||||
stdBaudRates.append("38400");
|
||||
stdBaudRates.append("57600");
|
||||
stdBaudRates.append("115200");
|
||||
|
||||
// Get value from settings
|
||||
m_baudRateList = m_settings.value("BaudRateList", stdBaudRates).toStringList();
|
||||
|
||||
// Sort baud rate list
|
||||
for (auto i = 0; i < m_baudRateList.count() - 1; ++i)
|
||||
{
|
||||
for (auto j = 0; j < m_baudRateList.count() - i - 1; ++j)
|
||||
{
|
||||
auto a = m_baudRateList.at(j).toInt();
|
||||
auto b = m_baudRateList.at(j + 1).toInt();
|
||||
if (a > b)
|
||||
m_baudRateList.swapItemsAt(j, j + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify UI
|
||||
emit baudRateListChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings between application runs
|
||||
*/
|
||||
void SerialManager::writeSettings()
|
||||
{
|
||||
// Sort baud rate list
|
||||
for (auto i = 0; i < m_baudRateList.count() - 1; ++i)
|
||||
{
|
||||
for (auto j = 0; j < m_baudRateList.count() - i - 1; ++j)
|
||||
{
|
||||
auto a = m_baudRateList.at(j).toInt();
|
||||
auto b = m_baudRateList.at(j + 1).toInt();
|
||||
if (a > b)
|
||||
{
|
||||
m_baudRateList.swapItemsAt(j, j + 1);
|
||||
emit baudRateListChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save list to memory
|
||||
m_settings.setValue("BaudRateList", baudRateList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with all the valid serial port objects
|
||||
*/
|
||||
QList<QSerialPortInfo> SerialManager::validPorts() const
|
||||
{
|
||||
// Search for available ports and add them to the lsit
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QSettings>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QtSerialPort>
|
||||
@ -76,8 +77,8 @@ class SerialManager : public QObject
|
||||
NOTIFY finishSequenceChanged)
|
||||
Q_PROPERTY(quint8 portIndex
|
||||
READ portIndex
|
||||
WRITE setPort
|
||||
NOTIFY portChanged)
|
||||
WRITE setPortIndex
|
||||
NOTIFY portIndexChanged)
|
||||
Q_PROPERTY(quint8 parityIndex
|
||||
READ parityIndex
|
||||
WRITE setParity
|
||||
@ -86,10 +87,6 @@ class SerialManager : public QObject
|
||||
READ displayMode
|
||||
WRITE setDisplayMode
|
||||
NOTIFY displayModeChanged)
|
||||
Q_PROPERTY(quint8 baudRateIndex
|
||||
READ baudRateIndex
|
||||
WRITE setBaudRateIndex
|
||||
NOTIFY baudRateIndexChanged)
|
||||
Q_PROPERTY(quint8 dataBitsIndex
|
||||
READ dataBitsIndex
|
||||
WRITE setDataBits
|
||||
@ -114,7 +111,7 @@ class SerialManager : public QObject
|
||||
CONSTANT)
|
||||
Q_PROPERTY(QStringList baudRateList
|
||||
READ baudRateList
|
||||
CONSTANT)
|
||||
NOTIFY baudRateListChanged)
|
||||
Q_PROPERTY(QStringList dataBitsList
|
||||
READ dataBitsList
|
||||
CONSTANT)
|
||||
@ -127,6 +124,9 @@ class SerialManager : public QObject
|
||||
Q_PROPERTY(QStringList consoleDisplayModes
|
||||
READ consoleDisplayModes
|
||||
CONSTANT)
|
||||
Q_PROPERTY(bool serialConfigurationOk
|
||||
READ serialConfigurationOk
|
||||
NOTIFY portIndexChanged)
|
||||
// clang-format on
|
||||
|
||||
signals:
|
||||
@ -137,8 +137,10 @@ signals:
|
||||
void dataBitsChanged();
|
||||
void stopBitsChanged();
|
||||
void connectedChanged();
|
||||
void portIndexChanged();
|
||||
void displayModeChanged();
|
||||
void flowControlChanged();
|
||||
void baudRateListChanged();
|
||||
void writeEnabledChanged();
|
||||
void textDocumentChanged();
|
||||
void baudRateIndexChanged();
|
||||
@ -168,11 +170,11 @@ public:
|
||||
QString receivedBytes() const;
|
||||
QString startSequence() const;
|
||||
QString finishSequence() const;
|
||||
bool serialConfigurationOk() const;
|
||||
|
||||
quint8 portIndex() const;
|
||||
quint8 parityIndex() const;
|
||||
quint8 displayMode() const;
|
||||
quint8 baudRateIndex() const;
|
||||
quint8 dataBitsIndex() const;
|
||||
quint8 stopBitsIndex() const;
|
||||
quint8 flowControlIndex() const;
|
||||
@ -194,15 +196,16 @@ public:
|
||||
Q_INVOKABLE void configureTextDocument(QQuickTextDocument *doc);
|
||||
|
||||
public slots:
|
||||
void connectDevice();
|
||||
void clearTempBuffer();
|
||||
void disconnectDevice();
|
||||
void sendData(const QString &data);
|
||||
void setBaudRate(const qint32 rate);
|
||||
void setPort(const quint8 portIndex);
|
||||
void setPortIndex(const quint8 portIndex);
|
||||
void setSendHexData(const bool &sendHex);
|
||||
void setWriteEnabled(const bool enabled);
|
||||
void setParity(const quint8 parityIndex);
|
||||
void setBaudRateIndex(const quint8 index);
|
||||
void appendBaudRate(const QString &baudRate);
|
||||
void setDataBits(const quint8 dataBitsIndex);
|
||||
void setStopBits(const quint8 stopBitsIndex);
|
||||
void setDisplayMode(const quint8 displayMode);
|
||||
@ -213,6 +216,8 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void readFrames();
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
void onDataReceived();
|
||||
void refreshSerialDevices();
|
||||
void handleError(QSerialPort::SerialPortError error);
|
||||
@ -227,6 +232,7 @@ private:
|
||||
QSerialPort *m_port;
|
||||
|
||||
qint32 m_baudRate;
|
||||
QSettings m_settings;
|
||||
QSerialPort::Parity m_parity;
|
||||
QSerialPort::DataBits m_dataBits;
|
||||
QSerialPort::StopBits m_stopBits;
|
||||
@ -235,7 +241,6 @@ private:
|
||||
quint8 m_portIndex;
|
||||
quint8 m_displayMode;
|
||||
quint8 m_parityIndex;
|
||||
quint8 m_baudRateIndex;
|
||||
quint8 m_dataBitsIndex;
|
||||
quint8 m_stopBitsIndex;
|
||||
quint64 m_receivedBytes;
|
||||
@ -249,6 +254,7 @@ private:
|
||||
QString m_finishSeq;
|
||||
QByteArray m_tempBuffer;
|
||||
QStringList m_portList;
|
||||
QStringList m_baudRateList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user