kopia lustrzana https://gitlab.com/eliggett/wfview
Add function to handle connect/disconnect
rodzic
3e149ee742
commit
4a8de3c0c9
|
@ -320,7 +320,7 @@ void commHandler::openPort()
|
|||
qInfo(logSerial()) << "Could not open serial port " << portName << " , please restart.";
|
||||
isConnected = false;
|
||||
serialError = true;
|
||||
emit havePortError(errorType(portName, "Could not open port. Please restart."));
|
||||
emit havePortError(errorType(true, portName, "Could not open port. Please restart."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
46
wfmain.cpp
46
wfmain.cpp
|
@ -677,6 +677,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
|
|||
void wfmain::receivePortError(errorType err)
|
||||
{
|
||||
if (err.alert) {
|
||||
connectionHandler(false); // Force disconnect
|
||||
QMessageBox::critical(this, err.device, err.message, QMessageBox::Ok);
|
||||
}
|
||||
else
|
||||
|
@ -5273,26 +5274,14 @@ void wfmain::on_connectBtn_clicked()
|
|||
{
|
||||
this->rigStatus->setText(""); // Clear status
|
||||
|
||||
if (haveRigCaps) {
|
||||
emit sendCloseComm();
|
||||
ui->connectBtn->setText("Connect to Radio");
|
||||
ui->audioSystemCombo->setEnabled(true);
|
||||
ui->audioSystemServerCombo->setEnabled(true);
|
||||
haveRigCaps = false;
|
||||
rigName->setText("NONE");
|
||||
if (ui->connectBtn->text() == "Connect to Radio") {
|
||||
connectionHandler(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sendCloseComm(); // Just in case there is a failed connection open.
|
||||
if (ui->connectBtn->text() != "Cancel connection") {
|
||||
openRig();
|
||||
}
|
||||
else {
|
||||
ui->connectBtn->setText("Connect to Radio");
|
||||
ui->audioSystemCombo->setEnabled(true);
|
||||
ui->audioSystemServerCombo->setEnabled(true);
|
||||
}
|
||||
connectionHandler(false);
|
||||
}
|
||||
|
||||
ui->connectBtn->clearFocus();
|
||||
}
|
||||
|
||||
|
@ -7681,3 +7670,28 @@ void wfmain::changePollTiming(int timing_ms, bool setUI)
|
|||
ui->pollTimeMsSpin->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
void wfmain::connectionHandler(bool connect)
|
||||
{
|
||||
|
||||
if (!connect) {
|
||||
emit sendCloseComm();
|
||||
ui->connectBtn->setText("Connect to Radio");
|
||||
ui->audioSystemCombo->setEnabled(true);
|
||||
ui->audioSystemServerCombo->setEnabled(true);
|
||||
haveRigCaps = false;
|
||||
rigName->setText("NONE");
|
||||
}
|
||||
else
|
||||
{
|
||||
emit sendCloseComm(); // Just in case there is a failed connection open.
|
||||
if (ui->connectBtn->text() != "Cancel connection") {
|
||||
openRig();
|
||||
}
|
||||
else {
|
||||
ui->connectBtn->setText("Connect to Radio");
|
||||
ui->audioSystemCombo->setEnabled(true);
|
||||
ui->audioSystemServerCombo->setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
wfmain.h
2
wfmain.h
|
@ -985,6 +985,8 @@ private:
|
|||
void changeMode(mode_kind mode);
|
||||
void changeMode(mode_kind mode, bool dataOn);
|
||||
|
||||
void connectionHandler(bool connect);
|
||||
|
||||
cmds meterKindToMeterCommand(meterKind m);
|
||||
|
||||
int oldFreqDialVal;
|
||||
|
|
Ładowanie…
Reference in New Issue