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
This commit is contained in:
Bill Somerville 2015-02-19 12:26:36 +00:00
parent 0df477c717
commit 1453ed6f35
2 changed files with 7 additions and 29 deletions

View File

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

View File

@ -154,6 +154,7 @@
#include <QFont>
#include <QFontDialog>
#include <QColorDialog>
#include <QSerialPortInfo>
#include <QDebug>
#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);
}