From 2d8de725b63d67c33cc193991a36cb06ee355f6f Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Wed, 27 Nov 2024 02:59:39 -0500 Subject: [PATCH] Disable editable serial port combo on Windows --- app/qml/MainWindow/Panes/SetupPanes/Devices/Serial.qml | 6 +++--- app/src/IO/Drivers/Serial.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/qml/MainWindow/Panes/SetupPanes/Devices/Serial.qml b/app/qml/MainWindow/Panes/SetupPanes/Devices/Serial.qml index 75791c2f..2aaae30c 100644 --- a/app/qml/MainWindow/Panes/SetupPanes/Devices/Serial.qml +++ b/app/qml/MainWindow/Panes/SetupPanes/Devices/Serial.qml @@ -77,12 +77,12 @@ Item { enabled: !Cpp_IO_Manager.connected } ComboBox { id: _portCombo - editable: true Layout.fillWidth: true opacity: enabled ? 1 : 0.5 model: Cpp_IO_Serial.portList enabled: !Cpp_IO_Manager.connected currentIndex: Cpp_IO_Serial.portIndex + editable: Qt.platform.os !== "windows" onCurrentIndexChanged: { if (enabled) { if (currentIndex !== Cpp_IO_Serial.portIndex) @@ -91,8 +91,8 @@ Item { } onAccepted: { - if (find(editText) === -1) - Cpp_IO_Serial.registerDevice(editText) + if (_portCombo.editable && _portCombo.find(_portCombo.editText) === -1) + Cpp_IO_Serial.registerDevice(_portCombo.editText) } } diff --git a/app/src/IO/Drivers/Serial.cpp b/app/src/IO/Drivers/Serial.cpp index 3dd35b54..4c9ba0e3 100644 --- a/app/src/IO/Drivers/Serial.cpp +++ b/app/src/IO/Drivers/Serial.cpp @@ -724,7 +724,13 @@ void IO::Drivers::Serial::refreshSerialDevices() // Search for available ports and add them to the lsit auto validPortList = validPorts(); Q_FOREACH (QSerialPortInfo info, validPortList) + { +#ifdef Q_OS_WIN + ports.append(info.portName()); +#else ports.append(info.systemLocation()); +#endif + } // Update list only if necessary if (portList() != ports)