From 1453ed6f35a50e0e12838b59da085e8ac019c2ce Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Thu, 19 Feb 2015 12:26:36 +0000 Subject: [PATCH] Populate serial port lists with available actual devices git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4976 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 2 +- Configuration.cpp | 34 ++++++---------------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f7a854a8..d1026c908 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -805,7 +805,7 @@ set_target_properties (wsjtx PROPERTIES ) target_link_libraries (wsjtx wsjt_fort wsjt_cxx wsjt_qt ${hamlib_LIBRARIES} ${FFTW3_LIBRARIES}) -qt5_use_modules (wsjtx Widgets OpenGL Network Multimedia) +qt5_use_modules (wsjtx Widgets OpenGL Network Multimedia SerialPort) set (SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) if (WIN32) diff --git a/Configuration.cpp b/Configuration.cpp index 52227a3af..de7d2116a 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -154,6 +154,7 @@ #include #include #include +#include #include #include "qt_helpers.hpp" @@ -2375,38 +2376,15 @@ void Configuration::impl::enumerate_rigs () void Configuration::impl::fill_port_combo_box (QComboBox * cb) { auto current_text = cb->currentText (); - cb->clear (); - -#ifdef WIN32 - - for (int i {1}; i < 100; ++i) + Q_FOREACH (auto const& p, QSerialPortInfo::availablePorts ()) { - auto item = "COM" + QString::number (i); - cb->addItem (item); + if (!p.isBusy ()) + { + cb->addItem (p.portName ()); + } } cb->addItem("USB"); - -#else - - QStringList ports = { - "/dev/ttyS0" - , "/dev/ttyS1" - , "/dev/ttyS2" - , "/dev/ttyS3" - , "/dev/ttyS4" - , "/dev/ttyS5" - , "/dev/ttyS6" - , "/dev/ttyS7" - , "/dev/ttyUSB0" - , "/dev/ttyUSB1" - , "/dev/ttyUSB2" - , "/dev/ttyUSB3" - }; - cb->addItems (ports); - -#endif - cb->setEditText (current_text); }