Disable editable serial port combo on Windows

This commit is contained in:
Alex Spataru 2024-11-27 02:59:39 -05:00
parent 920977fa8f
commit 2d8de725b6
2 changed files with 9 additions and 3 deletions

View File

@ -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)
}
}

View File

@ -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)