Added serial port drop-down population code. Untested.

merge-requests/2/head
Elliott Liggett 2021-03-06 23:35:46 -08:00
rodzic 5a611f5c94
commit ce6cc451b9
3 zmienionych plików z 56 dodań i 12 usunięć

Wyświetl plik

@ -312,6 +312,18 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
periodicPollingTimer->setSingleShot(false);
connect(periodicPollingTimer, SIGNAL(timeout()), this, SLOT(runPeriodicCommands()));
ui->serialDeviceListCombo->blockSignals(true);
ui->serialDeviceListCombo->addItem("Auto", 0);
int i=0;
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
{
portList.append(serialPortInfo.portName());
ui->serialDeviceListCombo->addItem(serialPortInfo.portName(), i++);
}
ui->serialDeviceListCombo->addItem("Manual...", 256);
ui->serialDeviceListCombo->blockSignals(false);
openRig();
qRegisterMetaType<rigCapabilities>();
@ -479,14 +491,6 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
freqLock = false;
// Not needed since we automate this now.
/*
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts())
{
portList.append(serialPortInfo.portName());
// ui->commPortDrop->addItem(serialPortInfo.portName());
}
*/
#ifdef QT_DEBUG
@ -3464,6 +3468,41 @@ void wfmain::on_tuneLockChk_clicked(bool checked)
freqLock = checked;
}
void wfmain::on_serialDeviceListCombo_activated(const QString &arg1)
{
QString manualPort;
bool ok;
if(arg1==QString("Manual..."))
{
manualPort = QInputDialog::getText(this, tr("Manual port assignment"),
tr("Enter serial port assignment:"),
QLineEdit::Normal,
tr("/dev/device"), &ok);
if(manualPort.isEmpty() || !ok)
{
ui->serialDeviceListCombo->blockSignals(true);
ui->serialDeviceListCombo->setCurrentIndex(0);
ui->serialDeviceListCombo->blockSignals(false);
return;
} else {
prefs.serialPortRadio = manualPort;
showStatusBarText("Setting preferences to use manually-assigned serial port: " + manualPort);
ui->serialEnableBtn->setChecked(true);
return;
}
}
if(arg1==QString("Auto"))
{
prefs.serialPortRadio = "Auto";
showStatusBarText("Setting preferences to automatically find rig serial port.");
ui->serialEnableBtn->setChecked(true);
return;
}
prefs.serialPortRadio = arg1;
showStatusBarText("Setting preferences to use manually-assigned serial port: " + arg1);
ui->serialEnableBtn->setChecked(true);
}
// --- DEBUG FUNCTION ---
void wfmain::on_debugBtn_clicked()
@ -3483,4 +3522,3 @@ void wfmain::on_debugBtn_clicked()
emit getScopeMode();
}

Wyświetl plik

@ -377,6 +377,8 @@ private slots:
void on_tuningStepCombo_currentIndexChanged(int index);
void on_serialDeviceListCombo_activated(const QString &arg1);
private:
Ui::wfmain *ui;
QSettings settings;

Wyświetl plik

@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="mainTab">
<attribute name="title">
@ -1643,7 +1643,11 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="serialDeviceListCombo"/>
<widget class="QComboBox" name="serialDeviceListCombo">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a serial port here. &lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;Once selected, check &amp;quot;Enable USB(serial), press &amp;quot;Save Settings&amp;quot;, exit, and re-start wfview. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="tuneSpacer">
@ -2000,7 +2004,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="radioConnectionSerialNetworkGrp"/>
<buttongroup name="duplexBtnGrp"/>
<buttongroup name="radioConnectionSerialNetworkGrp"/>
</buttongroups>
</ui>