diff --git a/bandbuttons.cpp b/bandbuttons.cpp new file mode 100644 index 0000000..6e87322 --- /dev/null +++ b/bandbuttons.cpp @@ -0,0 +1,338 @@ +#include "bandbuttons.h" +#include "ui_bandbuttons.h" + +bandbuttons::bandbuttons(QWidget *parent) : + QWidget(parent), + ui(new Ui::bandbuttons) +{ + ui->setupUi(this); + ui->bandStkLastUsedBtn->setVisible(false); + ui->bandStkVoiceBtn->setVisible(false); + ui->bandStkDataBtn->setVisible(false); + ui->bandStkCWBtn->setVisible(false); + this->setWindowTitle("Band Switcher"); +} + +bandbuttons::~bandbuttons() +{ + delete ui; +} + +int bandbuttons::getBSRNumber() +{ + return ui->bandStkPopdown->currentIndex()+1; +} + +void bandbuttons::acceptRigCaps(rigCapabilities rc) +{ + this->rigCaps = rc; + qDebug(logGui()) << "Accepting new rigcaps into band buttons."; + if(haveRigCaps) + qDebug(logGui()) << "Accepting additional rigcaps into band buttons."; + + qDebug(logGui()) << "Bands in this rigcaps: "; + for(size_t i=0; i < rigCaps.bands.size(); i++) + { + qDebug(logGui()) << "band[" << i << "]: " << (unsigned char)rigCaps.bands.at(i).band; + } + + for(size_t i=0; i < 20; i++) + { + qDebug(logGui()) << "bsr[" << i << "]: " << (unsigned char)rigCaps.bsr[i]; + } + + setUIToRig(); + haveRigCaps = true; +} + +void bandbuttons::setUIToRig() +{ + // Turn off each button first: + hideButton(ui->band23cmbtn); + hideButton(ui->band70cmbtn); + hideButton(ui->band2mbtn); + hideButton(ui->bandAirbtn); + hideButton(ui->bandWFMbtn); + hideButton(ui->band4mbtn); + hideButton(ui->band6mbtn); + + hideButton(ui->band10mbtn); + hideButton(ui->band12mbtn); + hideButton(ui->band15mbtn); + hideButton(ui->band17mbtn); + hideButton(ui->band20mbtn); + hideButton(ui->band30mbtn); + hideButton(ui->band40mbtn); + hideButton(ui->band60mbtn); + hideButton(ui->band80mbtn); + hideButton(ui->band160mbtn); + + hideButton(ui->band630mbtn); + hideButton(ui->band2200mbtn); + hideButton(ui->bandGenbtn); + + bandType bandSel; + for(unsigned int i=0; i < rigCaps.bands.size(); i++) + { + bandSel = rigCaps.bands.at(i); + switch(bandSel.band) + { + case(band23cm): + showButton(ui->band23cmbtn); + break; + case(band70cm): + showButton(ui->band70cmbtn); + break; + case(band2m): + showButton(ui->band2mbtn); + break; + case(bandAir): + showButton(ui->bandAirbtn); + break; + case(bandWFM): + showButton(ui->bandWFMbtn); + break; + case(band4m): + showButton(ui->band4mbtn); + break; + case(band6m): + showButton(ui->band6mbtn); + break; + + case(band10m): + showButton(ui->band10mbtn); + break; + case(band12m): + showButton(ui->band12mbtn); + break; + case(band15m): + showButton(ui->band15mbtn); + break; + case(band17m): + showButton(ui->band17mbtn); + break; + case(band20m): + showButton(ui->band20mbtn); + break; + case(band30m): + showButton(ui->band30mbtn); + break; + case(band40m): + showButton(ui->band40mbtn); + break; + case(band60m): + showButton(ui->band60mbtn); + break; + case(band80m): + showButton(ui->band80mbtn); + break; + case(band160m): + showButton(ui->band160mbtn); + break; + + case(band630m): + showButton(ui->band630mbtn); + break; + case(band2200m): + showButton(ui->band2200mbtn); + break; + case(bandGen): + showButton(ui->bandGenbtn); + break; + + default: + break; + } + } +} + +void bandbuttons::showButton(QPushButton *b) +{ + b->setVisible(true); +} + +void bandbuttons::hideButton(QPushButton *b) +{ + b->setHidden(true); +} + +void bandbuttons::receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn) +{ + // This function is not currently used, but perhaps it should be? + // Issue: wfmain is also waiting for a BSR and acts upon it. + if(waitingForBSR) + { + qDebug(logGui()) << "Received band stack register and was waiting for one."; + emit issueCmdF(cmdSetFreq, freqGo); + emit issueCmd(cmdSetMode, mode); + //emit issueCmd(cmdSetFilter, filter); // TODO + if(dataOn) + emit issueDelayedCommand(cmdSetDataModeOn); + else + emit issueDelayedCommand(cmdSetDataModeOff); + + waitingForBSR = false; + } else { + qWarning(logGui()) << "Received a BSR but did not expect one."; + } + (void)filter; +} + +void bandbuttons::bandStackBtnClick(availableBands band) +{ + if(haveRigCaps) + { + unsigned char bandRegister = rigCaps.bsr[band]; + if(bandRegister == 00) + { + qDebug(logGui()) << "requested to drop to band that does not have a BSR."; + // TODO: Jump to reasonable frequency for the selected band + jumpToBandWithoutBSR(band); + } else { + waitingForBSR = true; + // TODO: request the BSR 1, 2, or 3 + emit issueCmd(cmdGetBandStackReg, (unsigned char)band); + } + } else { + qWarning(logGui()) << "bandbuttons, Asked to go to a band but do not have rigCaps yet."; + } +} + +void bandbuttons::jumpToBandWithoutBSR(availableBands band) +{ + // Sometimes we do not have a BSR for these bands: + freqt f; + f.Hz = 0; + + switch(band) + { + case band2200m: + f.Hz = 136 * 1E3; + break; + case band630m: + f.Hz = 475 * 1E3; + break; + case band60m: + f.Hz = (5.3305) * 1E6; + break; + case band4m: + f.Hz = (70.200) * 1E6; + break; + case bandAir: + f.Hz = 121.5 * 1E6; + break; + case bandGen: + f.Hz = 10.0 * 1E6; + break; + case bandWFM: + f.Hz = (100.1) * 1E6; + break; + default: + qCritical(logGui()) << "Band " << (unsigned char) band << " not understood."; + break; + } + if(f.Hz != 0) + { + emit issueCmdF(cmdSetFreq, f); + } +} + +void bandbuttons::on_band2200mbtn_clicked() +{ + bandStackBtnClick(band2200m); +} + +void bandbuttons::on_band630mbtn_clicked() +{ + bandStackBtnClick(band630m); +} + +void bandbuttons::on_band160mbtn_clicked() +{ + bandStackBtnClick(band160m); +} + +void bandbuttons::on_band80mbtn_clicked() +{ + bandStackBtnClick(band80m); +} + +void bandbuttons::on_band60mbtn_clicked() +{ + bandStackBtnClick(band60m); +} + +void bandbuttons::on_band40mbtn_clicked() +{ + bandStackBtnClick(band40m); +} + +void bandbuttons::on_band30mbtn_clicked() +{ + bandStackBtnClick(band30m); +} + +void bandbuttons::on_band20mbtn_clicked() +{ + bandStackBtnClick(band20m); +} + +void bandbuttons::on_band17mbtn_clicked() +{ + bandStackBtnClick(band17m); +} + +void bandbuttons::on_band15mbtn_clicked() +{ + bandStackBtnClick(band15m); +} + +void bandbuttons::on_band12mbtn_clicked() +{ + bandStackBtnClick(band12m); +} + +void bandbuttons::on_band10mbtn_clicked() +{ + bandStackBtnClick(band10m); +} + +void bandbuttons::on_band6mbtn_clicked() +{ + bandStackBtnClick(band6m); +} + +void bandbuttons::on_band4mbtn_clicked() +{ + bandStackBtnClick(band4m); +} + +void bandbuttons::on_band2mbtn_clicked() +{ + bandStackBtnClick(band2m); +} + +void bandbuttons::on_band70cmbtn_clicked() +{ + bandStackBtnClick(band70cm); +} + +void bandbuttons::on_band23cmbtn_clicked() +{ + bandStackBtnClick(band23cm); +} + +void bandbuttons::on_bandWFMbtn_clicked() +{ + bandStackBtnClick(bandWFM); +} + +void bandbuttons::on_bandAirbtn_clicked() +{ + bandStackBtnClick(bandAir); +} + +void bandbuttons::on_bandGenbtn_clicked() +{ + bandStackBtnClick(bandGen); +} diff --git a/bandbuttons.h b/bandbuttons.h new file mode 100644 index 0000000..502a1f9 --- /dev/null +++ b/bandbuttons.h @@ -0,0 +1,94 @@ +#ifndef BANDBUTTONS_H +#define BANDBUTTONS_H + +#include +#include + +#include "logcategories.h" +#include "wfviewtypes.h" +#include "rigidentities.h" + +namespace Ui { +class bandbuttons; +} + +class bandbuttons : public QWidget +{ + Q_OBJECT + +public: + explicit bandbuttons(QWidget *parent = nullptr); + ~bandbuttons(); + + int getBSRNumber(); // returns the BSR combo box position + + + // flow: + // User presses button + // this sends request for BSR information and flags waitingForBSR=true + // When BSR data is received, and if we were waiting for it, + // then we select the frequency and mode and act upon it, + // by sending out a gotoFreqMode(freq, mode). + // Or we could grant access to the command queue and not have to do these + // custom functions. + + // The BSR can presumably show up without having been invited. + + // Most of the connections shall be to rigCommander and + // to the command queue in wfmain (soon to be broken out). + // One connection may also be made to update the UI when we change frequency and mode. + +signals: + // look at what cmdSetModeFilter does, can we depreciate it? + void issueCmdUniquePriority(cmds cmd, char c); // to go to a mode + void issueDelayedCommand(cmds cmd); // for data mode and filter + void issueCmdF(cmds cmd, freqt f); // go to frequency + void issueCmd(cmds, char); // to get BSR of a specific band + + // void getBandStackReg(char band, char regCode); // no, use the queue. + // void gotoFreqMode(); // TODO, arguments will contain BSR data + + +public slots: + // These should come from connections to rigCommander: + void acceptRigCaps(rigCapabilities rc); + void receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn); + +private slots: + void on_band2200mbtn_clicked(); + void on_band630mbtn_clicked(); + void on_band160mbtn_clicked(); + void on_band80mbtn_clicked(); + void on_band60mbtn_clicked(); + void on_band40mbtn_clicked(); + void on_band30mbtn_clicked(); + void on_band20mbtn_clicked(); + void on_band17mbtn_clicked(); + void on_band15mbtn_clicked(); + void on_band12mbtn_clicked(); + void on_band10mbtn_clicked(); + void on_band6mbtn_clicked(); + void on_band4mbtn_clicked(); + void on_band2mbtn_clicked(); + void on_band70cmbtn_clicked(); + void on_band23cmbtn_clicked(); + void on_bandWFMbtn_clicked(); + void on_bandAirbtn_clicked(); + void on_bandGenbtn_clicked(); + +private: + Ui::bandbuttons *ui; + void bandStackBtnClick(availableBands band); + void jumpToBandWithoutBSR(availableBands band); + void setUIToRig(); + void showButton(QPushButton *b); + void hideButton(QPushButton *b); + char bandStkRegCode; + + bool waitingForBSR = false; + rigCapabilities rigCaps; + bool haveRigCaps = false; + +}; + +#endif // BANDBUTTONS_H diff --git a/bandbuttons.ui b/bandbuttons.ui new file mode 100644 index 0000000..b03bb71 --- /dev/null +++ b/bandbuttons.ui @@ -0,0 +1,581 @@ + + + bandbuttons + + + + 0 + 0 + 737 + 512 + + + + Form + + + + + + Band + + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 2200m + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 630m + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 160m + + + L + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 80m + + + 8 + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 60m + + + S + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 40m + + + 4 + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 30m + + + 3 + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 20m + + + 2 + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 17m + + + 7 + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 15m + + + 5 + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 12m + + + T + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 10m + + + 1 + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 6m + + + 6 + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 4m + + + $ + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 2m + + + V + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 70cm + + + U + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + 23cm + + + + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + WFM + + + W + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + Air + + + A + + + + + + + + 0 + 0 + + + + + 16777215 + 128 + + + + Gen + + + G + + + + + + + + + + + + + 0 + 0 + + + + Segment + + + + + + &Last Used + + + + 16 + 16 + + + + true + + + + + + + Band Stack Selection: + + + + + + + + 1 - Latest Used + + + + + 2 - Older + + + + + 3 - Oldest Used + + + + + + + + Voice + + + + + + + Data + + + + + + + &CW + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + diff --git a/freqmemory.cpp b/freqmemory.cpp index f9d8f73..72884f3 100644 --- a/freqmemory.cpp +++ b/freqmemory.cpp @@ -21,7 +21,7 @@ void freqMemory::initializePresets() { presets[p].frequency = 14.1 + p/1000.0; presets[p].mode = modeUSB; - presets[p].isSet = true; + presets[p].isSet = false; } } @@ -61,6 +61,9 @@ void freqMemory::dumpMemory() { for(unsigned int p=0; p < numPresets; p++) { + if(presets[p].isSet) + { qInfo(logSystem()) << "Index: " << p << " freq: " << presets[p].frequency << " Mode: " << presets[p].mode << " isSet: " << presets[p].isSet; + } } } diff --git a/frequencyinputwidget.cpp b/frequencyinputwidget.cpp new file mode 100644 index 0000000..40ba22f --- /dev/null +++ b/frequencyinputwidget.cpp @@ -0,0 +1,241 @@ +#include "frequencyinputwidget.h" +#include "ui_frequencyinputwidget.h" + +frequencyinputwidget::frequencyinputwidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::frequencyinputwidget) +{ + ui->setupUi(this); + this->setWindowTitle("Frequency Input"); + ui->freqMhzLineEdit->setValidator( new QDoubleValidator(0, 100, 6, this)); +} + +frequencyinputwidget::~frequencyinputwidget() +{ + delete ui; +} + +void frequencyinputwidget::showEvent(QShowEvent *event) +{ + ui->freqMhzLineEdit->setFocus(); + QWidget::showEvent(event); +} + +void frequencyinputwidget::setAutomaticSidebandSwitching(bool autossb) +{ + this->automaticSidebandSwitching = autossb; +} + +void frequencyinputwidget::updateCurrentMode(mode_kind mode) +{ + currentMode = mode; +} + +void frequencyinputwidget::updateFilterSelection(int filter) +{ + currentFilter = filter; +} + +void frequencyinputwidget::on_f1btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("1")); +} + +void frequencyinputwidget::on_f2btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("2")); +} + +void frequencyinputwidget::on_f3btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("3")); +} + +void frequencyinputwidget::on_f4btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("4")); +} + +void frequencyinputwidget::on_f5btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("5")); +} + +void frequencyinputwidget::on_f6btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("6")); +} + +void frequencyinputwidget::on_f7btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("7")); +} + +void frequencyinputwidget::on_f8btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("8")); +} + +void frequencyinputwidget::on_f9btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("9")); +} + +void frequencyinputwidget::on_fDotbtn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append(".")); +} + +void frequencyinputwidget::on_f0btn_clicked() +{ + checkFreqSel(); + ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("0")); +} + +void frequencyinputwidget::on_fCEbtn_clicked() +{ + ui->freqMhzLineEdit->clear(); + freqTextSelected = false; +} + +void frequencyinputwidget::on_fStoBtn_clicked() +{ + // Memory Store + + // sequence: + // type frequency + // press Enter or Go + // change mode if desired + // type in index number 0 through 99 + // press STO + + bool ok; + int preset_number = ui->freqMhzLineEdit->text().toInt(&ok); + + if(ok && (preset_number >= 0) && (preset_number < 100)) + { + //emit setMemory(preset_number, freq, currentMode); + emit saveMemoryPreset(preset_number); + //mem.setPreset(preset_number, freq.MHzDouble, (mode_kind)ui->modeSelectCombo->currentData().toInt() ); + //showStatusBarText( QString("Storing frequency %1 to memory location %2").arg( freq.MHzDouble ).arg(preset_number) ); + } else { + //showStatusBarText(QString("Could not store preset to %1. Valid preset numbers are 0 to 99").arg(preset_number)); + } + ui->freqMhzLineEdit->clear(); +} + +void frequencyinputwidget::on_fRclBtn_clicked() +{ + // Memory Recall + bool ok; + int preset_number = ui->freqMhzLineEdit->text().toInt(&ok); + + if(ok && (preset_number >= 0) && (preset_number < 100)) + { + emit gotoMemoryPreset(preset_number); + // temp = mem.getPreset(preset_number); + // // TODO: change to int hz + // // TODO: store filter setting as well. + // freqString = QString("%1").arg(temp.frequency); + // ui->freqMhzLineEdit->setText( freqString ); + // ui->goFreqBtn->click(); + // setModeVal = temp.mode; + // setFilterVal = ui->modeFilterCombo->currentIndex()+1; // TODO, add to memory + // issueDelayedCommand(cmdSetModeFilter); +// issueDelayedCommand(cmdGetMode); + } else { + qInfo(logSystem()) << "Could not recall preset. Valid presets are 0 through 99."; + } + ui->freqMhzLineEdit->clear(); +} + +void frequencyinputwidget::on_fEnterBtn_clicked() +{ + on_goFreqBtn_clicked(); +} + +void frequencyinputwidget::on_fBackbtn_clicked() +{ + QString currentFreq = ui->freqMhzLineEdit->text(); + currentFreq.chop(1); + ui->freqMhzLineEdit->setText(currentFreq); +} + +void frequencyinputwidget::on_goFreqBtn_clicked() +{ + freqt f; + bool ok = false; + double freqDbl = 0; + int KHz = 0; + + if(ui->freqMhzLineEdit->text().contains(".")) + { + + freqDbl = ui->freqMhzLineEdit->text().toDouble(&ok); + if(ok) + { + f.Hz = freqDbl*1E6; + } + } else { + KHz = ui->freqMhzLineEdit->text().toInt(&ok); + if(ok) + { + f.Hz = KHz*1E3; + } + } + if(ok) + { + mode_info m; + issueCmdF(cmdSetFreq, f); + m.mk = sidebandChooser::getMode(f, currentMode); + m.reg = (unsigned char) m.mk; + + m.filter = currentFilter; + // TODO: usingDataMode + // TODO: auto sideband preference + if((m.mk != currentMode) && !usingDataMode && automaticSidebandSwitching) + { + emit issueCmdM(cmdSetMode, m); // mode info or mode kind..... + emit updateUIMode(m.mk); // mode kind or mode info? Check UI code + currentMode = m.mk; + } + + f.MHzDouble = (float)f.Hz / 1E6; + emit updateUIFrequency(f); + currentFrequency = f; + } else { + qWarning(logGui()) << "Could not understand frequency" << ui->freqMhzLineEdit->text(); + ui->freqMhzLineEdit->clear(); + } + + //ui->freqMhzLineEdit->clear(); + ui->freqMhzLineEdit->selectAll(); + freqTextSelected = true; + //ui->tabWidget->setCurrentIndex(0); +} + +void frequencyinputwidget::on_freqMhzLineEdit_returnPressed() +{ + on_goFreqBtn_clicked(); +} + +void frequencyinputwidget::checkFreqSel() +{ + if(freqTextSelected) + { + freqTextSelected = false; + ui->freqMhzLineEdit->clear(); + } +} + + diff --git a/frequencyinputwidget.h b/frequencyinputwidget.h new file mode 100644 index 0000000..336ed0e --- /dev/null +++ b/frequencyinputwidget.h @@ -0,0 +1,68 @@ +#ifndef FREQUENCYINPUTWIDGET_H +#define FREQUENCYINPUTWIDGET_H + +#include +#include + +#include "sidebandchooser.h" +#include "wfviewtypes.h" +#include "logcategories.h" + +namespace Ui { +class frequencyinputwidget; +} + +class frequencyinputwidget : public QWidget +{ + Q_OBJECT + +public: + explicit frequencyinputwidget(QWidget *parent = nullptr); + ~frequencyinputwidget(); + +signals: + void issueCmdF(cmds cmd, freqt f); + void issueCmdM(cmds cmd, mode_info m); + void updateUIMode(mode_kind mode); + void updateUIFrequency(freqt f); + void gotoMemoryPreset(int presetNumber); + void saveMemoryPreset(int presetNumber); + +public slots: + void updateCurrentMode(mode_kind mode); + void updateFilterSelection(int filter); + void setAutomaticSidebandSwitching(bool autossb); + +private slots: + void showEvent(QShowEvent *event); + void on_f1btn_clicked(); + void on_f2btn_clicked(); + void on_f3btn_clicked(); + void on_f4btn_clicked(); + void on_f5btn_clicked(); + void on_f6btn_clicked(); + void on_f7btn_clicked(); + void on_f8btn_clicked(); + void on_f9btn_clicked(); + void on_fDotbtn_clicked(); + void on_f0btn_clicked(); + void on_fCEbtn_clicked(); + void on_fStoBtn_clicked(); + void on_fRclBtn_clicked(); + void on_fEnterBtn_clicked(); + void on_fBackbtn_clicked(); + void on_goFreqBtn_clicked(); + void on_freqMhzLineEdit_returnPressed(); + +private: + Ui::frequencyinputwidget *ui; + bool freqTextSelected = false; + bool usingDataMode = false; + bool automaticSidebandSwitching = true; + mode_kind currentMode; + freqt currentFrequency; + int currentFilter = 1; + void checkFreqSel(); +}; + +#endif // FREQUENCYINPUTWIDGET_H diff --git a/frequencyinputwidget.ui b/frequencyinputwidget.ui new file mode 100644 index 0000000..a9b1404 --- /dev/null +++ b/frequencyinputwidget.ui @@ -0,0 +1,427 @@ + + + frequencyinputwidget + + + + 0 + 0 + 601 + 527 + + + + Form + + + + + + + + Frequency: + + + + + + + + DejaVu Sans Mono + 14 + 75 + true + + + + + + + + Go + + + Return + + + true + + + + + + + + + Entry + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 5 + + + 5 + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + <html><head/><body><p>To recall a preset memory:</p><p>1. Type in the preset number (0 through 99)</p><p>2. Press RCL (or use hotkey &quot;R&quot;)</p></body></html> + + + &RCL + + + R + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 6 + + + 6 + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 3 + + + 3 + + + false + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + &CE + + + C + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 4 + + + 4 + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + <html><head/><body><p>To store a preset:</p><p>1. Set the desired frequency and mode per normal methods</p><p>2. Type the index to to store to (0 through 99)</p><p>3. Press STO (or use hotkey &quot;S&quot;)</p></body></html> + + + &STO + + + S + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 9 + + + 9 + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + Back + + + Backspace + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + Enter + + + Enter + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + . + + + . + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 1 + + + 1 + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 2 + + + 2 + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 7 + + + 7 + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + 8 + + + 8 + + + + + + + + + + + diff --git a/prefs.h b/prefs.h index 9a04aaa..857fb7d 100644 --- a/prefs.h +++ b/prefs.h @@ -6,6 +6,74 @@ #include #include "wfviewtypes.h" +enum prefIfItem { + if_useFullScreen = 1 << 0, + if_useSystemTheme = 1 << 1, + if_drawPeaks = 1 << 2, + if_underlayMode = 1 << 3, + if_underlayBufferSize = 1 << 4, + if_wfAntiAlias = 1 << 5, + if_wfInterpolate = 1 << 6, + if_wftheme = 1 << 7, + if_plotFloor = 1 << 8, + if_plotCeiling = 1 << 9, + if_stylesheetPath = 1 << 10, + if_wflength = 1 << 11, + if_confirmExit = 1 << 12, + if_confirmPowerOff = 1 << 13, + if_meter2Type = 1 << 14, + if_clickDragTuningEnable = 1 << 15, + if_currentColorPresetNumber = 1 << 16, + if_all = 1 << 17 +}; + +enum prefRaItem { + + ra_radioCIVAddr = 1 << 0, + ra_CIVisRadioModel = 1 << 1, + ra_forceRTSasPTT = 1 << 2, + ra_polling_ms = 1 << 3, + ra_serialPortRadio = 1 << 4, + ra_serialPortBaud = 1 << 5, + ra_virtualSerialPort = 1 << 6, + ra_localAFgain = 1 << 7, + ra_audioSystem = 1 << 8, + ra_all = 1 << 9 +}; + +enum prefCtItem { + ct_enablePTT = 1 << 0, + ct_niceTS = 1 << 1, + ct_automaticSidebandSwitching = 1 << 2, + ct_enableUSBControllers = 1 << 3, + ct_usbSensitivity = 1 << 4, + ct_all = 1 << 5 +}; + +enum prefLanItem { + + l_enableLAN = 1 << 0, + l_enableRigCtlD = 1 << 1, + l_rigCtlPort = 1 << 2, + l_tcpPort = 1 << 3, + l_waterfallFormat = 1 << 4, + l_all = 1 << 5 +}; + +enum prefClusterItem { + cl_clusterUdpEnable = 1 << 0, + cl_clusterTcpEnable = 1 << 1, + cl_clusterUdpPort = 1 << 2, + cl_clusterTcpServerName = 1 << 3, + cl_clusterTcpUserName = 1 << 4, + cl_clusterTcpPassword = 1 << 5, + cl_clusterTcpPort = 1 << 6, + cl_clusterTimeout = 1 << 7, + cl_clusterSkimmerSpotsEnable = 1 << 8, + cl_all = 1 << 9 +}; + + struct preferences { // Program: @@ -32,6 +100,8 @@ struct preferences { bool confirmPowerOff; meter_t meter2Type; bool clickDragTuningEnable; + int currentColorPresetNumber = 0; + // Radio: unsigned char radioCIVAddr; @@ -54,7 +124,6 @@ struct preferences { bool enableLAN; bool enableRigCtlD; quint16 rigCtlPort; - int currentColorPresetNumber = 0; quint16 tcpPort; quint8 waterfallFormat; @@ -65,9 +134,9 @@ struct preferences { QString clusterTcpServerName; QString clusterTcpUserName; QString clusterTcpPassword; - int clusterTimeout; - bool clusterSkimmerSpotsEnable; - + int clusterTcpPort = 7300; + int clusterTimeout; // used? + bool clusterSkimmerSpotsEnable; // where is this used? }; #endif // PREFS_H diff --git a/repeatersetup.h b/repeatersetup.h index 88a089e..a3ca07e 100644 --- a/repeatersetup.h +++ b/repeatersetup.h @@ -74,41 +74,23 @@ private slots: void on_toneDTCS_clicked(); void on_splitPlusButton_clicked(); void on_splitMinusBtn_clicked(); - void on_splitTxFreqSetBtn_clicked(); - void on_selABtn_clicked(); - void on_selBBtn_clicked(); - void on_aEqBBtn_clicked(); - void on_swapABBtn_clicked(); - void on_selMainBtn_clicked(); - void on_selSubBtn_clicked(); - void on_mEqSBtn_clicked(); - void on_swapMSBtn_clicked(); - void on_setToneSubVFOBtn_clicked(); - void on_setRptrSubVFOBtn_clicked(); - void on_rptrOffsetSetBtn_clicked(); - void on_splitOffBtn_clicked(); - void on_splitEnableChk_clicked(); - void on_rptrOffsetEdit_returnPressed(); - void on_splitTransmitFreqEdit_returnPressed(); - void on_setSplitRptrToneChk_clicked(bool checked); - void on_quickSplitChk_clicked(bool checked); private: diff --git a/rigidentities.h b/rigidentities.h index 22b8582..7b2d414 100644 --- a/rigidentities.h +++ b/rigidentities.h @@ -176,6 +176,11 @@ struct bandStackType { //model_kind determineRadioModel(unsigned char rigID); +struct bsrRequest { + availableBands band; + int bsrPosition=1; +}; + struct rigCapabilities { quint8 model; quint8 civ; diff --git a/settingswidget.cpp b/settingswidget.cpp new file mode 100644 index 0000000..fc1ff58 --- /dev/null +++ b/settingswidget.cpp @@ -0,0 +1,1613 @@ +#include "settingswidget.h" +#include "ui_settingswidget.h" + +#define setchk(a,b) quietlyUpdateCheckbox(a,b) + +settingswidget::settingswidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::settingswidget) +{ + ui->setupUi(this); + createSettingsListItems(); + populateComboBoxes(); +} + +settingswidget::~settingswidget() +{ + delete ui; +} + +// Startup: +void settingswidget::createSettingsListItems() +{ + // Add items to the settings tab list widget + ui->settingsList->addItem("Radio Access"); // 0 + ui->settingsList->addItem("User Interface"); // 1 + ui->settingsList->addItem("Radio Settings"); // 2 + ui->settingsList->addItem("Radio Server"); // 3 + ui->settingsList->addItem("External Control"); // 4 + ui->settingsList->addItem("DX Cluster"); // 5 + ui->settingsList->addItem("Experimental"); // 6 + //ui->settingsList->addItem("Audio Processing"); // 7 + ui->settingsStack->setCurrentIndex(0); +} + +void settingswidget::populateComboBoxes() +{ + ui->baudRateCombo->blockSignals(true); + ui->baudRateCombo->insertItem(0, QString("115200"), 115200); + ui->baudRateCombo->insertItem(1, QString("57600"), 57600); + ui->baudRateCombo->insertItem(2, QString("38400"), 38400); + ui->baudRateCombo->insertItem(3, QString("28800"), 28800); + ui->baudRateCombo->insertItem(4, QString("19200"), 19200); + ui->baudRateCombo->insertItem(5, QString("9600"), 9600); + ui->baudRateCombo->insertItem(6, QString("4800"), 4800); + ui->baudRateCombo->insertItem(7, QString("2400"), 2400); + ui->baudRateCombo->insertItem(8, QString("1200"), 1200); + ui->baudRateCombo->insertItem(9, QString("300"), 300); + ui->baudRateCombo->blockSignals(false); + + ui->meter2selectionCombo->blockSignals(true); + ui->meter2selectionCombo->addItem("None", meterNone); + ui->meter2selectionCombo->addItem("SWR", meterSWR); + ui->meter2selectionCombo->addItem("ALC", meterALC); + ui->meter2selectionCombo->addItem("Compression", meterComp); + ui->meter2selectionCombo->addItem("Voltage", meterVoltage); + ui->meter2selectionCombo->addItem("Current", meterCurrent); + ui->meter2selectionCombo->addItem("Center", meterCenter); + ui->meter2selectionCombo->addItem("TxRxAudio", meterAudio); + ui->meter2selectionCombo->addItem("RxAudio", meterRxAudio); + ui->meter2selectionCombo->addItem("TxAudio", meterTxMod); + ui->meter2selectionCombo->show(); + ui->meter2selectionCombo->blockSignals(false); + + ui->secondaryMeterSelectionLabel->show(); + + ui->audioRXCodecCombo->blockSignals(true); + ui->audioRXCodecCombo->addItem("LPCM 1ch 16bit", 4); + ui->audioRXCodecCombo->addItem("LPCM 1ch 8bit", 2); + ui->audioRXCodecCombo->addItem("uLaw 1ch 8bit", 1); + ui->audioRXCodecCombo->addItem("LPCM 2ch 16bit", 16); + ui->audioRXCodecCombo->addItem("uLaw 2ch 8bit", 32); + ui->audioRXCodecCombo->addItem("PCM 2ch 8bit", 8); + ui->audioRXCodecCombo->addItem("Opus 1ch", 64); + ui->audioRXCodecCombo->addItem("Opus 2ch", 128); + ui->audioRXCodecCombo->blockSignals(false); + + ui->audioTXCodecCombo->blockSignals(true); + ui->audioTXCodecCombo->addItem("LPCM 1ch 16bit", 4); + ui->audioTXCodecCombo->addItem("LPCM 1ch 8bit", 2); + ui->audioTXCodecCombo->addItem("uLaw 1ch 8bit", 1); + ui->audioTXCodecCombo->addItem("Opus 1ch", 64); + ui->audioTXCodecCombo->blockSignals(false); + + ui->controlPortTxt->setValidator(new QIntValidator(this)); +} + +// Updating Preferences: +void settingswidget::acceptPreferencesPtr(preferences *pptr) +{ + if(pptr != NULL) + { + qDebug(logGui()) << "Accepting general preferences pointer into settings widget."; + prefs = pptr; + havePrefs = true; + } +} + +void settingswidget::acceptUdpPreferencesPtr(udpPreferences *upptr) +{ + if(upptr != NULL) + { + qDebug(logGui()) << "Accepting UDP preferences pointer into settings widget."; + udpPrefs = upptr; + haveUdpPrefs = true; + } +} + +void settingswidget::acceptServerConfig(SERVERCONFIG *sc) +{ + if(sc != NULL) + { + qDebug(logGui()) << "Accepting ServerConfig pointer into settings widget."; + serverConfig = sc; + haveServerConfig = true; + } +} + +void settingswidget::copyClusterList(QList c) +{ + this->clusters = c; + haveClusterList = true; + qDebug(logGui()) << "Updated settings widget clusters. Size of this->clusters: " << clusters.size(); + setUItoClustersList(); +} + +void settingswidget::insertClusterOutputText(QString text) +{ + ui->clusterOutputTextEdit->moveCursor(QTextCursor::End); + ui->clusterOutputTextEdit->insertPlainText(text); + ui->clusterOutputTextEdit->moveCursor(QTextCursor::End); +} + +void settingswidget::setUItoClustersList() +{ + if(haveClusterList) + { + int defaultCluster = 0; + int numClusters = clusters.size(); + if(numClusters > 0) + { + ui->clusterServerNameCombo->blockSignals(true); + for (int f = 0; f < clusters.size(); f++) + { + ui->clusterServerNameCombo->addItem(clusters[f].server); + if (clusters[f].isdefault) { + defaultCluster = f; + } + } + ui->clusterServerNameCombo->blockSignals(false); + if (clusters.size() > defaultCluster) + { + ui->clusterServerNameCombo->setCurrentIndex(defaultCluster); + ui->clusterTcpPortLineEdit->blockSignals(true); + ui->clusterUsernameLineEdit->blockSignals(true); + ui->clusterPasswordLineEdit->blockSignals(true); + ui->clusterTimeoutLineEdit->blockSignals(true); + ui->clusterTcpPortLineEdit->setText(QString::number(clusters[defaultCluster].port)); + ui->clusterUsernameLineEdit->setText(clusters[defaultCluster].userName); + ui->clusterPasswordLineEdit->setText(clusters[defaultCluster].password); + ui->clusterTimeoutLineEdit->setText(QString::number(clusters[defaultCluster].timeout)); + ui->clusterTcpPortLineEdit->blockSignals(false); + ui->clusterUsernameLineEdit->blockSignals(false); + ui->clusterPasswordLineEdit->blockSignals(false); + ui->clusterTimeoutLineEdit->blockSignals(false); + } + } else { + // No clusters in the list + ui->clusterTcpPortLineEdit->setEnabled(false); + ui->clusterUsernameLineEdit->setEnabled(false); + ui->clusterPasswordLineEdit->setEnabled(false); + ui->clusterTimeoutLineEdit->setEnabled(false); + } + } else { + qCritical(logGui()) << "Called to update UI of cluster info without cluister list."; + } +} + +void settingswidget::updateIfPrefs(int items) +{ + prefIfItem pif; + if(items & (int)if_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)if_all; i = i << 1) + { + if(items & i) + { + qDebug(logGui()) << "Updating If pref" << (int)i; + pif = (prefIfItem)i; + updateIfPref(pif); + } + } +} + +void settingswidget::updateRaPrefs(int items) +{ + prefRaItem pra; + if(items & (int)ra_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)ra_all; i = i << 1) + { + if(items & i) + { + qDebug(logGui()) << "Updating Ra pref" << (int)i; + pra = (prefRaItem)i; + updateRaPref(pra); + } + } +} + +void settingswidget::updateCtPrefs(int items) +{ + prefCtItem pct; + if(items & (int)ct_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)ct_all; i = i << 1) + { + if(items & i) + { + qDebug(logGui()) << "Updating Ct pref" << (int)i; + pct = (prefCtItem)i; + updateCtPref(pct); + } + } +} + +void settingswidget::updateServerConfigs(int items) +{ + serverItems si; + if(items & (int)s_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)s_all; i = i << 1) + { + if(items & i) + { + qDebug(logGui()) << "Updating ServerConfig" << (int)i; + si = (serverItems)i; + updateServerConfig(si); + } + } +} + +void settingswidget::updateLanPrefs(int items) +{ + prefLanItem plan; + if(items & (int)l_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)l_all; i = i << 1) + { + if(items & i) + { + qDebug(logGui()) << "Updating Lan pref" << (int)i; + plan = (prefLanItem)i; + updateLanPref(plan); + } + } +} + +void settingswidget::updateClusterPrefs(int items) +{ + prefClusterItem pcl; + if(items & (int)cl_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)cl_all; i = i << 1) + { + if(items & i) + { + qDebug(logGui()) << "Updating Cluster pref" << (int)i; + pcl = (prefClusterItem)i; + updateClusterPref(pcl); + } + } +} + +void settingswidget::updateIfPref(prefIfItem pif) +{ + if(prefs==NULL) + return; + + updatingUIFromPrefs = true; + switch(pif) + { + case if_useFullScreen: + quietlyUpdateCheckbox(ui->fullScreenChk, prefs->useFullScreen); + break; + case if_useSystemTheme: + quietlyUpdateCheckbox(ui->useSystemThemeChk, prefs->useSystemTheme); + break; + case if_drawPeaks: + // depreciated; + break; + case if_underlayMode: + updateUnderlayMode(); + break; + case if_underlayBufferSize: + quietlyUpdateSlider(ui->underlayBufferSlider, prefs->underlayBufferSize); + break; + case if_wfAntiAlias: + quietlyUpdateCheckbox(ui->wfAntiAliasChk, prefs->wfAntiAlias); + break; + case if_wfInterpolate: + quietlyUpdateCheckbox(ui->wfInterpolateChk, prefs->wfInterpolate); + break; + case if_wftheme: + // Not handled in settings. + break; + case if_plotFloor: + // Not handled in settings. + break; + case if_plotCeiling: + // Not handled in settings. + break; + case if_stylesheetPath: + // No UI element for this. + break; + case if_wflength: + // Not handled in settings. + break; + case if_confirmExit: + // No UI element for this. + break; + case if_confirmPowerOff: + // No UI element for this. + break; + case if_meter2Type: + { + ui->meter2selectionCombo->blockSignals(true); + int m = ui->meter2selectionCombo->findData(prefs->meter2Type); + ui->meter2selectionCombo->setCurrentIndex(m); + ui->meter2selectionCombo->blockSignals(false); + break; + } + case if_clickDragTuningEnable: + quietlyUpdateCheckbox(ui->clickDragTuningEnableChk, prefs->clickDragTuningEnable); + break; + case if_currentColorPresetNumber: + ui->colorPresetCombo->blockSignals(true); + ui->colorPresetCombo->setCurrentIndex(prefs->currentColorPresetNumber); + ui->colorPresetCombo->blockSignals(false); + // activate? or done when prefs load? Maybe some of each? + // TODO + break; + default: + qWarning(logGui()) << "Did not understand if pref update item " << (int)pif; + break; + } + updatingUIFromPrefs = false; +} + +void settingswidget::updateRaPref(prefRaItem pra) +{ + if(prefs==NULL) + return; + + updatingUIFromPrefs = true; + switch(pra) + { + case ra_radioCIVAddr: + // It may be possible to ignore this value at this time. + // TODO + if(prefs->radioCIVAddr == 0) + { + ui->rigCIVaddrHexLine->setText("auto"); + ui->rigCIVaddrHexLine->setEnabled(false); + } else { + ui->rigCIVaddrHexLine->setEnabled(true); + ui->rigCIVaddrHexLine->setText(QString("%1").arg(prefs->radioCIVAddr, 2, 16)); + } + break; + case ra_CIVisRadioModel: + quietlyUpdateCheckbox(ui->useCIVasRigIDChk, prefs->CIVisRadioModel); + break; + case ra_forceRTSasPTT: + quietlyUpdateCheckbox(ui->useRTSforPTTchk, prefs->forceRTSasPTT); + break; + case ra_polling_ms: + if(prefs->polling_ms == 0) + { + // Automatic + ui->pollingButtonGroup->blockSignals(true); + ui->autoPollBtn->setChecked(true); + ui->manualPollBtn->setChecked(false); + ui->pollingButtonGroup->blockSignals(false); + ui->pollTimeMsSpin->setEnabled(false); + } else { + // Manual + ui->pollingButtonGroup->blockSignals(true); + ui->autoPollBtn->setChecked(false); + ui->manualPollBtn->setChecked(true); + ui->pollingButtonGroup->blockSignals(false); + ui->pollTimeMsSpin->blockSignals(true); + ui->pollTimeMsSpin->setValue(prefs->polling_ms); + ui->pollTimeMsSpin->blockSignals(false); + ui->pollTimeMsSpin->setEnabled(true); + } + break; + case ra_serialPortRadio: + { + if(!haveSerialDevices) + { + qCritical(logGui()) << "Asked to show serial device without serial device list."; + break; + } + if(!prefs->serialPortRadio.isEmpty()) + { + int serialIndex = -1; + if(prefs->serialPortRadio.toLower() == "auto") + { + serialIndex = ui->serialDeviceListCombo->findText(QString("Auto")); + } else { + serialIndex = ui->serialDeviceListCombo->findText(prefs->serialPortRadio); + } + if (serialIndex != -1) { + ui->serialDeviceListCombo->setCurrentIndex(serialIndex); + } else { + qWarning(logGui()) << "Cannot find serial port" << prefs->serialPortRadio << "mentioned in preferences inside the serial combo box."; + } + } else { + qDebug(logGui()) << "Serial port in prefs is blank"; + } + break; + } + case ra_serialPortBaud: + ui->baudRateCombo->blockSignals(true); + ui->baudRateCombo->setCurrentIndex(ui->baudRateCombo->findData(prefs->serialPortBaud)); + ui->baudRateCombo->blockSignals(false); + break; + case ra_virtualSerialPort: + { + if(!haveVspDevices) + { + qCritical(logGui()) << "Asked to select VSP device without VSP device list."; + break; + } + int vspIndex = ui->vspCombo->findText(prefs->virtualSerialPort); + if (vspIndex != -1) { + ui->vspCombo->setCurrentIndex(vspIndex); + } else { + // TODO: Are we sure this is a good idea? + if(!prefs->virtualSerialPort.isEmpty()) + { + ui->vspCombo->addItem(prefs->virtualSerialPort); + ui->vspCombo->setCurrentIndex(ui->vspCombo->count() - 1); + } + } + break; + } + case ra_localAFgain: + // Not handled here. + break; + case ra_audioSystem: + ui->audioSystemCombo->blockSignals(true); + ui->audioSystemServerCombo->blockSignals(true); + ui->audioSystemCombo->setCurrentIndex(prefs->audioSystem); + ui->audioSystemServerCombo->setCurrentIndex(prefs->audioSystem); + ui->audioSystemServerCombo->blockSignals(false); + ui->audioSystemCombo->blockSignals(false); + break; + default: + qWarning(logGui()) << "Cannot update ra pref" << (int)pra; + } + updatingUIFromPrefs = false; +} + +void settingswidget::updateCtPref(prefCtItem pct) +{ + if(prefs==NULL) + return; + + updatingUIFromPrefs = true; + switch(pct) + { + case ct_enablePTT: + quietlyUpdateCheckbox(ui->pttEnableChk, prefs->enablePTT); + break; + case ct_niceTS: + quietlyUpdateCheckbox(ui->tuningFloorZerosChk, prefs->niceTS); + break; + case ct_automaticSidebandSwitching: + quietlyUpdateCheckbox(ui->autoSSBchk, prefs->automaticSidebandSwitching); + break; + case ct_enableUSBControllers: + quietlyUpdateCheckbox(ui->enableUsbChk, prefs->enableUSBControllers); + break; + case ct_usbSensitivity: + // No UI element for this. + break; + default: + qWarning(logGui()) << "No UI element matches setting" << (int)pct; + break; + } + updatingUIFromPrefs = false; +} + +void settingswidget::updateLanPref(prefLanItem plan) +{ + if(prefs==NULL) + return; + + updatingUIFromPrefs = true; + switch(plan) + { + case l_enableLAN: + quietlyUpdateRadiobutton(ui->lanEnableBtn, prefs->enableLAN); + break; + case l_enableRigCtlD: + quietlyUpdateCheckbox(ui->enableRigctldChk, prefs->enableRigCtlD); + break; + case l_rigCtlPort: + ui->rigctldPortTxt->setText(QString::number(prefs->rigCtlPort)); + break; + case l_tcpPort: + ui->tcpServerPortTxt->setText(QString::number(prefs->tcpPort)); + break; + case l_waterfallFormat: + ui->waterfallFormatCombo->blockSignals(true); + ui->waterfallFormatCombo->setCurrentIndex(prefs->waterfallFormat); + ui->waterfallFormatCombo->blockSignals(false); + break; + default: + qWarning(logGui()) << "Did not find matching preference for LAN ui update:" << (int)plan; + } + updatingUIFromPrefs = false; +} + +void settingswidget::updateClusterPref(prefClusterItem pcl) +{ + if(prefs==NULL) + return; + + updatingUIFromPrefs = true; + switch(pcl) + { + case cl_clusterUdpEnable: + quietlyUpdateCheckbox(ui->clusterUdpEnable, prefs->clusterUdpEnable); + break; + case cl_clusterTcpEnable: + quietlyUpdateCheckbox(ui->clusterTcpEnable, prefs->clusterTcpEnable); + break; + case cl_clusterUdpPort: + ui->clusterUdpPortLineEdit->blockSignals(true); + ui->clusterUdpPortLineEdit->setText(QString::number(prefs->clusterUdpPort)); + ui->clusterUdpPortLineEdit->blockSignals(false); + break; + case cl_clusterTcpServerName: + // Take this from the clusters list + break; + case cl_clusterTcpUserName: + // Take this from the clusters list + break; + case cl_clusterTcpPassword: + // Take this from the clusters list + break; + case cl_clusterTcpPort: + break; + case cl_clusterTimeout: + // Take this from the clusters list + break; + case cl_clusterSkimmerSpotsEnable: + quietlyUpdateCheckbox(ui->clusterSkimmerSpotsEnable, prefs->clusterSkimmerSpotsEnable); + break; + default: + qWarning(logGui()) << "Did not find matching UI element for cluster preference " << (int)pcl; + break; + } + updatingUIFromPrefs = false; +} + +void settingswidget::updateServerConfig(serverItems si) +{ + if(serverConfig == NULL) + { + qCritical(logGui()) << "serverConfig is NULL, cannot set preferences!"; + return; + } + updatingUIFromPrefs = true; + switch(si) + { + case s_enabled: + quietlyUpdateCheckbox(ui->serverEnableCheckbox, serverConfig->enabled); + break; + case s_lan: + // Not used here + break; + case s_controlPort: + quietlyUpdateLineEdit(ui->serverControlPortText, QString::number(serverConfig->civPort)); + break; + case s_civPort: + quietlyUpdateLineEdit(ui->serverCivPortText, QString::number(serverConfig->civPort)); + break; + case s_audioPort: + quietlyUpdateLineEdit(ui->serverAudioPortText, QString::number(serverConfig->audioPort)); + break; + case s_audioOutput: + break; + case s_audioInput: + break; + case s_resampleQuality: + // Not used here + break; + case s_baudRate: + // Not used here + break; + case s_users: + // This is fairly complex + populateServerUsers(); + break; + case s_rigs: + // Not used here + break; + default: + qWarning(logGui()) << "Did not find matching UI element for ServerConfig " << (int)si; + } + + updatingUIFromPrefs = false; +} + +void settingswidget::updateUdpPrefs(int items) +{ + udpPrefsItem upi; + if(items & (int)u_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)u_all; i = i << 1) + { + if(items & i) + { + qDebug(logGui()) << "Updating UDP preference " << i; + upi = (udpPrefsItem)i; + updateUdpPref(upi); + } + } +} + +void settingswidget::updateUdpPref(udpPrefsItem upi) +{ + updatingUIFromPrefs = true; + switch(upi) + { + case u_ipAddress: + ui->ipAddressTxt->blockSignals(true); + ui->ipAddressTxt->setEnabled(ui->lanEnableBtn->isChecked()); + ui->ipAddressTxt->setText(udpPrefs->ipAddress); + ui->ipAddressTxt->blockSignals(false); + break; + case u_controlLANPort: + ui->controlPortTxt->blockSignals(true); + ui->controlPortTxt->setEnabled(ui->lanEnableBtn->isChecked()); + ui->controlPortTxt->setText(QString("%1").arg(udpPrefs->controlLANPort)); + ui->controlPortTxt->blockSignals(false); + break; + case u_serialLANPort: + // Not used in the UI. + break; + case u_audioLANPort: + // Not used in the UI. + break; + case u_username: + ui->usernameTxt->blockSignals(true); + ui->usernameTxt->setEnabled(ui->lanEnableBtn->isChecked()); + ui->usernameTxt->setText(QString("%1").arg(udpPrefs->username)); + ui->usernameTxt->blockSignals(false); + break; + case u_password: + ui->passwordTxt->blockSignals(true); + ui->passwordTxt->setEnabled(ui->lanEnableBtn->isChecked()); + ui->passwordTxt->setText(QString("%1").arg(udpPrefs->password)); + ui->passwordTxt->blockSignals(false); + break; + case u_clientName: + // Not used in the UI. + break; + case u_waterfallFormat: + ui->waterfallFormatCombo->blockSignals(true); + ui->waterfallFormatCombo->setCurrentIndex(prefs->waterfallFormat); + ui->waterfallFormatCombo->blockSignals(false); + break; + case u_halfDuplex: + ui->audioDuplexCombo->blockSignals(true); + ui->audioDuplexCombo->setCurrentIndex((int)udpPrefs->halfDuplex); + ui->audioDuplexCombo->blockSignals(false); + break; + default: + qWarning(logGui()) << "Did not find matching UI element for UDP pref item " << (int)upi; + break; + } + updatingUIFromPrefs = false; +} + +void settingswidget::updateAllPrefs() +{ + // DEPRECIATED + // Maybe make this a public convenience function + + // Review all the preferences. This is intended to be called + // after new settings are loaded in. + // Not sure if we actually want to always assume we should load prefs. + updatingUIFromPrefs = true; + if(havePrefs) + { + updateIfPrefs((int)if_all); + updateRaPrefs((int)ra_all); + updateCtPrefs((int)ct_all); + updateClusterPrefs((int)cl_all); + updateLanPrefs((int)l_all); + } + if(haveUdpPrefs) + { + updateUdpPrefs((int)u_all); + } + + updatingUIFromPrefs = false; +} + +void settingswidget::updateAudioInputs(QStringList deviceList, int currentIndex, int chars) +{ + // see wfmain::setAudioDevicesUI() + if(haveAudioInputs) + qDebug(logGui()) << "Reloading audio input list"; + ui->audioInputCombo->blockSignals(true); + ui->audioInputCombo->clear(); + ui->audioInputCombo->addItems(deviceList); + ui->audioInputCombo->setCurrentIndex(-1); + ui->audioInputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(chars + 30)); + ui->audioInputCombo->blockSignals(false); + ui->audioInputCombo->setCurrentIndex(currentIndex); + haveAudioInputs = true; +} + +void settingswidget::updateAudioOutputs(QStringList deviceList, int currentIndex, int chars) +{ + if(haveAudioOutputs) + qDebug(logGui()) << "Reloading audio output list"; + ui->audioOutputCombo->blockSignals(true); + ui->audioOutputCombo->clear(); + ui->audioOutputCombo->addItems(deviceList); + ui->audioOutputCombo->setCurrentIndex(-1); + ui->audioOutputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(chars + 30)); + ui->audioOutputCombo->blockSignals(false); + ui->audioOutputCombo->setCurrentIndex(currentIndex); + haveAudioOutputs = true; +} + +void settingswidget::updateServerTXAudioOutputs(QStringList deviceList, int currentIndex, int chars) +{ + if(haveServerAudioOutputs) + qDebug(logGui()) << "Reloading ServerTXAudioOutputs"; + ui->serverTXAudioOutputCombo->blockSignals(true); + ui->serverTXAudioOutputCombo->clear(); + ui->serverTXAudioOutputCombo->addItems(deviceList); + ui->serverTXAudioOutputCombo->setCurrentIndex(-1); + ui->serverTXAudioOutputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(chars + 30)); + ui->serverTXAudioOutputCombo->setCurrentIndex(currentIndex); + ui->serverTXAudioOutputCombo->blockSignals(false); + haveServerAudioOutputs = true; +} + +void settingswidget::updateServerRXAudioInputs(QStringList deviceList, int currentIndex, int chars) +{ + if(haveServerAudioInputs) + qDebug(logGui()) << "Reloading ServerRXAudioInputs"; + ui->serverRXAudioInputCombo->blockSignals(true); + ui->serverRXAudioInputCombo->clear(); + ui->serverRXAudioInputCombo->addItems(deviceList); + ui->serverRXAudioInputCombo->setCurrentIndex(-1); + ui->serverRXAudioInputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(chars+30)); + ui->serverRXAudioInputCombo->setCurrentIndex(currentIndex); + ui->serverRXAudioInputCombo->blockSignals(false); + haveServerAudioInputs = true; +} + +void settingswidget::updateSerialPortList(QStringList deviceList, QVector data) +{ + if(deviceList.length() == data.length()) + { + ui->serialDeviceListCombo->blockSignals(true); + ui->serialDeviceListCombo->addItem("Auto", 0); + for(int i=0; i < deviceList.length(); i++) + { + ui->serialDeviceListCombo->addItem(deviceList.at(i), data.at(i)); + } +#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_UNIX) + ui->serialDeviceListCombo->addItem("Manual...", 256); +#endif + ui->serialDeviceListCombo->blockSignals(false); + haveSerialDevices = true; + } else { + qCritical(logGui()) << "Cannot populate serial device list. Data of unequal length."; + } +} + +void settingswidget::updateVSPList(QStringList deviceList, QVector data) +{ + // Do not supply "None" device, that is a UI thing and it is done here. + // Supply the complete filename + + // TODO: Should we clear the list first? + if(deviceList.length() == data.length()) + { + ui->vspCombo->blockSignals(true); + + for(int i=0; i < deviceList.length(); i++) + { + ui->vspCombo->addItem(deviceList.at(i), data.at(i)); + + if (QFile::exists(deviceList.at(i))) { + auto* model = qobject_cast(ui->vspCombo->model()); + auto* item = model->item(ui->vspCombo->count() - 1); + item->setEnabled(false); + } + } + + ui->serialDeviceListCombo->addItem("None", deviceList.size()); + + ui->vspCombo->blockSignals(false); + haveVspDevices = true; + } else { + qCritical(logGui()) << "Cannot populate serial device list. Data of unequal length."; + } +} + +void settingswidget::updateModSourceList(QStringList deviceNames, QVector data) +{ + ui->modInputCombo->blockSignals(true); + ui->modInputCombo->clear(); + for(int i=0; i < deviceNames.length(); i++) + { + ui->modInputCombo->addItem(deviceNames.at(i), data.at(i)); + } + ui->modInputCombo->blockSignals(false); +} + +void settingswidget::updateDataModSourceList(QStringList deviceNames, QVector data) +{ + ui->modInputDataCombo->blockSignals(true); + ui->modInputDataCombo->clear(); + for(int i=0; i < deviceNames.length(); i++) + { + ui->modInputDataCombo->addItem(deviceNames.at(i), data.at(i)); + } + ui->modInputDataCombo->blockSignals(false); +} + +void settingswidget::populateServerUsers() +{ + // Copy data from serverConfig.users into the server UI table + // We will assume the data are safe to use. + bool blank = false; + int row=0; + qDebug(logGui()) << "Adding server users. Size: " << serverConfig->users.size(); + + QList::iterator user = serverConfig->users.begin(); + while (user != serverConfig->users.end()) + { + serverAddUserLine(user->username, user->password, user->userType); + if((user->username == "") && !blank) + blank = true; + row++; + user++; + } + if (row==1 && blank) + { + // There are no defined users. The only user present is the blank one. + // The button is disabled, but it may be enabled + // when the user enters valid information for a potential new + // user account. + ui->serverAddUserBtn->setEnabled(false); + } +} + +void settingswidget::serverAddUserLine(const QString &user, const QString &pass, const int &type) +{ + // migration TODO: Review these signals/slots + + ui->serverUsersTable->blockSignals(true); + + ui->serverUsersTable->insertRow(ui->serverUsersTable->rowCount()); + + ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 0, new QTableWidgetItem()); + ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 1, new QTableWidgetItem()); + ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 2, new QTableWidgetItem()); + ui->serverUsersTable->setItem(ui->serverUsersTable->rowCount() - 1, 3, new QTableWidgetItem()); + + QLineEdit* username = new QLineEdit(); + username->setProperty("row", (int)ui->serverUsersTable->rowCount() - 1); + username->setProperty("col", (int)0); + username->setText(user); + connect(username, SIGNAL(editingFinished()), this, SLOT(onServerUserFieldChanged())); + ui->serverUsersTable->setCellWidget(ui->serverUsersTable->rowCount() - 1, 0, username); + + QLineEdit* password = new QLineEdit(); + password->setProperty("row", (int)ui->serverUsersTable->rowCount() - 1); + password->setProperty("col", (int)1); + password->setEchoMode(QLineEdit::PasswordEchoOnEdit); + password->setText(pass); + connect(password, SIGNAL(editingFinished()), this, SLOT(onServerUserFieldChanged())); + ui->serverUsersTable->setCellWidget(ui->serverUsersTable->rowCount() - 1, 1, password); + + QComboBox* comboBox = new QComboBox(); + comboBox->insertItems(0, { "Full User","Full with no TX","Monitor only" }); + comboBox->setProperty("row", (int)ui->serverUsersTable->rowCount() - 1); + comboBox->setProperty("col", (int)2); + comboBox->setCurrentIndex(type); + connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onServerUserFieldChanged())); + ui->serverUsersTable->setCellWidget(ui->serverUsersTable->rowCount() - 1, 2, comboBox); + + QPushButton* button = new QPushButton(); + button->setText("Delete"); + button->setProperty("row", (int)ui->serverUsersTable->rowCount() - 1); + button->setProperty("col", (int)3); + connect(button, SIGNAL(clicked()), this, SLOT(onServerUserFieldChanged())); + ui->serverUsersTable->setCellWidget(ui->serverUsersTable->rowCount() - 1, 3, button); + + ui->serverUsersTable->blockSignals(false); +} + +// Utility Functions: +void settingswidget::updateUnderlayMode() +{ + + quietlyUpdateRadiobutton(ui->underlayNone, false); + quietlyUpdateRadiobutton(ui->underlayPeakHold, false); + quietlyUpdateRadiobutton(ui->underlayPeakBuffer, false); + quietlyUpdateRadiobutton(ui->underlayAverageBuffer, false); + + switch(prefs->underlayMode) { + case underlayNone: + quietlyUpdateRadiobutton(ui->underlayNone, true); + ui->underlayBufferSlider->setDisabled(true); + break; + case underlayPeakHold: + quietlyUpdateRadiobutton(ui->underlayPeakHold, true); + ui->underlayBufferSlider->setDisabled(true); + break; + case underlayPeakBuffer: + quietlyUpdateRadiobutton(ui->underlayPeakBuffer, true); + ui->underlayBufferSlider->setEnabled(true); + break; + case underlayAverageBuffer: + quietlyUpdateRadiobutton(ui->underlayAverageBuffer, true); + ui->underlayBufferSlider->setEnabled(true); + break; + default: + qWarning() << "Do not understand underlay mode: " << (unsigned int) prefs->underlayMode; + } +} + +void settingswidget::quietlyUpdateSlider(QSlider *sl, int val) +{ + sl->blockSignals(true); + if( (val >= sl->minimum()) && (val <= sl->maximum()) ) + sl->setValue(val); + sl->blockSignals(false); +} + +void settingswidget::quietlyUpdateSpinbox(QSpinBox *sb, int val) +{ + sb->blockSignals(true); + if( (val >= sb->minimum()) && (val <= sb->maximum()) ) + sb->setValue(val); + sb->blockSignals(false); +} + +void settingswidget::quietlyUpdateCheckbox(QCheckBox *cb, bool isChecked) +{ + cb->blockSignals(true); + cb->setChecked(isChecked); + cb->blockSignals(false); +} + +void settingswidget::quietlyUpdateRadiobutton(QRadioButton *rb, bool isChecked) +{ + rb->blockSignals(true); + rb->setChecked(isChecked); + rb->blockSignals(false); +} + +void settingswidget::quietlyUpdateLineEdit(QLineEdit *le, const QString text) +{ + le->blockSignals(true); + le->setText(text); + le->blockSignals(false); +} + +// Resulting from User Interaction + +void settingswidget::on_debugBtn_clicked() +{ + qDebug(logGui()) << "Debug button pressed in settings widget."; +} + +void settingswidget::on_settingsList_currentRowChanged(int currentRow) +{ + ui->settingsStack->setCurrentIndex(currentRow); +} + +void settingswidget::onServerUserFieldChanged() +{ + if(!haveServerConfig) { + qCritical(logGui()) << "Do not have serverConfig, cannot edit users."; + return; + } + int row = sender()->property("row").toInt(); + int col = sender()->property("col").toInt(); + qDebug() << "Server User field col" << col << "row" << row << "changed"; + + // This is a new user line so add to serverUsersTable + if (serverConfig->users.length() <= row) + { + qInfo() << "Something bad has happened, serverConfig.users is shorter than table!"; + } + else + { + if (col == 0) + { + QLineEdit* username = (QLineEdit*)ui->serverUsersTable->cellWidget(row, 0); + if (username->text() != serverConfig->users[row].username) { + serverConfig->users[row].username = username->text(); + } + } + else if (col == 1) + { + QLineEdit* password = (QLineEdit*)ui->serverUsersTable->cellWidget(row, 1); + QByteArray pass; + passcode(password->text(), pass); + if (QString(pass) != serverConfig->users[row].password) { + serverConfig->users[row].password = pass; + } + } + else if (col == 2) + { + QComboBox* comboBox = (QComboBox*)ui->serverUsersTable->cellWidget(row, 2); + serverConfig->users[row].userType = comboBox->currentIndex(); + } + else if (col == 3) + { + serverConfig->users.removeAt(row); + ui->serverUsersTable->setRowCount(0); + foreach(SERVERUSER user, serverConfig->users) + { + serverAddUserLine(user.username, user.password, user.userType); + } + } + if (row == ui->serverUsersTable->rowCount() - 1) { + ui->serverAddUserBtn->setEnabled(true); + } + + } +} + +void settingswidget::on_lanEnableBtn_clicked(bool checked) +{ + // TODO: prefs.enableLAN = checked; + // TOTO? ui->connectBtn->setEnabled(true); // move to other side + ui->ipAddressTxt->setEnabled(checked); + ui->controlPortTxt->setEnabled(checked); + ui->usernameTxt->setEnabled(checked); + ui->passwordTxt->setEnabled(checked); + ui->audioRXCodecCombo->setEnabled(checked); + ui->audioTXCodecCombo->setEnabled(checked); + ui->audioSampleRateCombo->setEnabled(checked); + ui->rxLatencySlider->setEnabled(checked); + ui->txLatencySlider->setEnabled(checked); + ui->rxLatencyValue->setEnabled(checked); + ui->txLatencyValue->setEnabled(checked); + ui->audioOutputCombo->setEnabled(checked); + ui->audioInputCombo->setEnabled(checked); + ui->baudRateCombo->setEnabled(!checked); + ui->serialDeviceListCombo->setEnabled(!checked); + ui->serverRXAudioInputCombo->setEnabled(!checked); + ui->serverTXAudioOutputCombo->setEnabled(!checked); + ui->useRTSforPTTchk->setEnabled(!checked); + + prefs->enableLAN = checked; + emit changedLanPref(l_enableLAN); +} + +void settingswidget::on_serialEnableBtn_clicked(bool checked) +{ + prefs->enableLAN = !checked; + ui->serialDeviceListCombo->setEnabled(checked); + + ui->ipAddressTxt->setEnabled(!checked); + ui->controlPortTxt->setEnabled(!checked); + ui->usernameTxt->setEnabled(!checked); + ui->passwordTxt->setEnabled(!checked); + ui->audioRXCodecCombo->setEnabled(!checked); + ui->audioTXCodecCombo->setEnabled(!checked); + ui->audioSampleRateCombo->setEnabled(!checked); + ui->rxLatencySlider->setEnabled(!checked); + ui->txLatencySlider->setEnabled(!checked); + ui->rxLatencyValue->setEnabled(!checked); + ui->txLatencyValue->setEnabled(!checked); + ui->audioOutputCombo->setEnabled(!checked); + ui->audioInputCombo->setEnabled(!checked); + ui->baudRateCombo->setEnabled(checked); + ui->serialDeviceListCombo->setEnabled(checked); + ui->serverRXAudioInputCombo->setEnabled(checked); + ui->serverTXAudioOutputCombo->setEnabled(checked); + ui->useRTSforPTTchk->setEnabled(checked); + + emit changedLanPref(l_enableLAN); +} + +void settingswidget::on_autoSSBchk_clicked(bool checked) +{ + prefs->automaticSidebandSwitching = checked; + emit changedCtPref(ct_automaticSidebandSwitching); +} + +void settingswidget::on_useSystemThemeChk_clicked(bool checked) +{ + prefs->useSystemTheme = checked; + emit changedIfPrefs(if_useSystemTheme); +} + +void settingswidget::on_enableUsbChk_clicked(bool checked) +{ + prefs->enableUSBControllers = checked; + ui->usbControllerBtn->setEnabled(checked); + ui->usbButtonsResetBtn->setEnabled(checked); + ui->usbCommandsResetBtn->setEnabled(checked); + ui->usbResetLbl->setVisible(checked); + + emit changedCtPref(ct_enableUSBControllers); +} + +void settingswidget::on_usbControllerBtn_clicked() +{ + emit showUSBControllerSetup(); +} + +void settingswidget::on_autoPollBtn_clicked(bool checked) +{ + if(checked) + { + prefs->polling_ms = 0; + emit changedRaPref(ra_polling_ms); + ui->pollTimeMsSpin->setEnabled(false); + } +} + +void settingswidget::on_manualPollBtn_clicked(bool checked) +{ + if(checked) + { + ui->pollTimeMsSpin->setEnabled(true); + prefs->polling_ms = ui->pollTimeMsSpin->value(); + emit changedRaPref(ra_polling_ms); + } else { + // Do we need this... + // prefs.polling_ms = 0; + // emit changedRaPref(ra_polling_ms); + } +} + +void settingswidget::on_pollTimeMsSpin_valueChanged(int val) +{ + prefs->polling_ms = val; + emit changedRaPref(ra_polling_ms); +} + +void settingswidget::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; + qInfo(logGui()) << "Setting preferences to use manually-assigned serial port: " << manualPort; + ui->serialEnableBtn->setChecked(true); + emit changedRaPref(ra_serialPortRadio); + return; + } + } + if(arg1==QString("Auto")) + { + prefs->serialPortRadio = "auto"; + qInfo(logGui()) << "Setting preferences to automatically find rig serial port."; + ui->serialEnableBtn->setChecked(true); + emit changedRaPref(ra_serialPortRadio); + return; + } + + prefs->serialPortRadio = arg1; + qInfo(logGui()) << "Setting preferences to use manually-assigned serial port: " << arg1; + ui->serialEnableBtn->setChecked(true); + emit changedRaPref(ra_serialPortRadio); +} + +void settingswidget::on_baudRateCombo_activated(int index) +{ + bool ok = false; + quint32 baud = ui->baudRateCombo->currentData().toUInt(&ok); + if(ok) + { + prefs->serialPortBaud = baud; + qInfo(logGui()) << "Changed baud rate to" << baud << "bps. Press Save Settings to retain."; + emit changedRaPref(ra_serialPortBaud); + } + (void)index; +} + +void settingswidget::on_vspCombo_activated(int index) +{ + Q_UNUSED(index); + prefs->virtualSerialPort = ui->vspCombo->currentText(); + emit changedRaPref(ra_virtualSerialPort); +} + +void settingswidget::on_audioSystemCombo_currentIndexChanged(int value) +{ + prefs->audioSystem = static_cast(value); + ui->audioSystemServerCombo->blockSignals(true); + ui->audioSystemServerCombo->setCurrentIndex(value); + ui->audioSystemServerCombo->blockSignals(false); + emit changedRaPref(ra_audioSystem); +} + +void settingswidget::on_audioSystemServerCombo_currentIndexChanged(int value) +{ + prefs->audioSystem = static_cast(value); + ui->audioSystemCombo->blockSignals(true); + ui->audioSystemCombo->setCurrentIndex(value); + ui->audioSystemCombo->blockSignals(false); + emit changedRaPref(ra_audioSystem); +} + +void settingswidget::on_meter2selectionCombo_currentIndexChanged(int index) +{ + prefs->meter2Type = static_cast(ui->meter2selectionCombo->itemData(index).toInt()); + emit changedIfPref(if_meter2Type); +} + +void settingswidget::on_tuningFloorZerosChk_clicked(bool checked) +{ + prefs->niceTS = checked; + emit changedCtPref(ct_niceTS); +} + +void settingswidget::on_fullScreenChk_clicked(bool checked) +{ + prefs->useFullScreen = checked; + emit changedIfPref(if_useFullScreen); +} + +void settingswidget::on_wfAntiAliasChk_clicked(bool checked) +{ + prefs->wfAntiAlias = checked; + emit changedIfPref(if_wfAntiAlias); +} + +void settingswidget::on_wfInterpolateChk_clicked(bool checked) +{ + prefs->wfInterpolate = checked; + emit changedIfPref(if_wfInterpolate); +} + +void settingswidget::on_underlayNone_clicked(bool checked) +{ + if(checked) + { + prefs->underlayMode = underlayNone; + ui->underlayBufferSlider->setDisabled(true); + emit changedIfPref(if_underlayMode); + } +} + +void settingswidget::on_underlayPeakHold_clicked(bool checked) +{ + if(checked) + { + prefs->underlayMode = underlayPeakHold; + ui->underlayBufferSlider->setDisabled(true); + emit changedIfPref(if_underlayMode); + } +} + +void settingswidget::on_underlayPeakBuffer_clicked(bool checked) +{ + if(checked) + { + prefs->underlayMode = underlayPeakBuffer; + ui->underlayBufferSlider->setEnabled(true); + emit changedIfPref(if_underlayMode); + } +} + +void settingswidget::on_underlayAverageBuffer_clicked(bool checked) +{ + if(checked) + { + prefs->underlayMode = underlayAverageBuffer; + ui->underlayBufferSlider->setEnabled(true); + emit changedIfPref(if_underlayMode); + } +} + +void settingswidget::on_underlayBufferSlider_valueChanged(int value) +{ + prefs->underlayBufferSize = value; + emit changedIfPref(if_underlayBufferSize); +} + +void settingswidget::on_pttEnableChk_clicked(bool checked) +{ + prefs->enablePTT = checked; + emit changedCtPref(ct_enablePTT); +} + +void settingswidget::on_clickDragTuningEnableChk_clicked(bool checked) +{ + prefs->clickDragTuningEnable = checked; + emit changedIfPref(if_clickDragTuningEnable); +} + +void settingswidget::on_enableRigctldChk_clicked(bool checked) +{ + prefs->enableRigCtlD = checked; + emit changedLanPref(l_enableRigCtlD); +} + +void settingswidget::on_rigctldPortTxt_editingFinished() +{ + bool okconvert = false; + unsigned int port = ui->rigctldPortTxt->text().toUInt(&okconvert); + if (okconvert) + { + prefs->rigCtlPort = port; + emit changedLanPref(l_rigCtlPort); + } +} + +void settingswidget::on_tcpServerPortTxt_editingFinished() +{ + bool okconvert = false; + unsigned int port = ui->tcpServerPortTxt->text().toUInt(&okconvert); + if (okconvert) + { + prefs->tcpPort = port; + emit changedLanPref(l_tcpPort); + } +} + +void settingswidget::on_clusterServerNameCombo_currentIndexChanged(int index) +{ + if (index < 0) + return; + + if(!haveClusterList) + qWarning(logGui()) << "Do not have cluster list yet. Editing may not work."; + + QString text = ui->clusterServerNameCombo->currentText(); + + if (clusters.size() <= index) + { + qInfo(logGui) << "Adding Cluster server" << text; + clusterSettings c; + c.server = text; + clusters.append(c); + ui->clusterTcpPortLineEdit->setEnabled(true); + ui->clusterUsernameLineEdit->setEnabled(true); + ui->clusterPasswordLineEdit->setEnabled(true); + ui->clusterTimeoutLineEdit->setEnabled(true); + + } + else { + qInfo(logGui) << "Editing Cluster server" << text; + clusters[index].server = text; + } + ui->clusterUsernameLineEdit->blockSignals(true); + ui->clusterPasswordLineEdit->blockSignals(true); + ui->clusterTimeoutLineEdit->blockSignals(true); + ui->clusterTcpPortLineEdit->setText(QString::number(clusters[index].port)); + ui->clusterUsernameLineEdit->setText(clusters[index].userName); + ui->clusterPasswordLineEdit->setText(clusters[index].password); + ui->clusterTimeoutLineEdit->setText(QString::number(clusters[index].timeout)); + ui->clusterUsernameLineEdit->blockSignals(false); + ui->clusterPasswordLineEdit->blockSignals(false); + ui->clusterTimeoutLineEdit->blockSignals(false); + + + for (int i = 0; i < clusters.size(); i++) { + if (i == index) + clusters[i].isdefault = true; + else + clusters[i].isdefault = false; + } + + // For reference, here is what the code on the other side is basically doing: +// emit setClusterServerName(clusters[index].server); +// emit setClusterTcpPort(clusters[index].port); +// emit setClusterUserName(clusters[index].userName); +// emit setClusterPassword(clusters[index].password); +// emit setClusterTimeout(clusters[index].timeout); + + // We are using the not-arrayed data in preferences + // to communicate the current cluster information: + prefs->clusterTcpServerName = clusters[index].server; + prefs->clusterTcpPort = clusters[index].port; + prefs->clusterTcpUserName = clusters[index].userName; + prefs->clusterTcpPassword = clusters[index].password; + prefs->clusterTimeout = clusters[index].timeout; + prefs->clusterTcpEnable = ui->clusterTcpEnable->isChecked(); + + emit changedClusterPrefs(cl_clusterTcpServerName | + cl_clusterTcpPort | + cl_clusterTcpUserName | + cl_clusterTcpPassword | + cl_clusterTimeout | + cl_clusterTcpEnable); +} + +void settingswidget::on_clusterUdpEnable_clicked(bool checked) +{ + prefs->clusterUdpEnable = checked; + emit changedClusterPref(cl_clusterUdpEnable); +} + +void settingswidget::on_clusterTcpEnable_clicked(bool checked) +{ + prefs->clusterTcpEnable = checked; + emit changedClusterPref(cl_clusterTcpEnable); +} + +void settingswidget::on_clusterTcpSetNowBtn_clicked() +{ + // Maybe this will be easier than "hit enter" ? + int index = ui->clusterServerNameCombo->currentIndex(); + on_clusterServerNameCombo_currentIndexChanged(index); +} + +void settingswidget::on_clusterServerNameCombo_currentTextChanged(const QString &text) +{ + if (text.isEmpty()) { + int index = ui->clusterServerNameCombo->currentIndex(); + ui->clusterServerNameCombo->removeItem(index); + clusters.removeAt(index); + if (clusters.size() == 0) + { + ui->clusterTcpPortLineEdit->setEnabled(false); + ui->clusterUsernameLineEdit->setEnabled(false); + ui->clusterPasswordLineEdit->setEnabled(false); + ui->clusterTimeoutLineEdit->setEnabled(false); + } + } +} + +void settingswidget::on_clusterTcpPortLineEdit_editingFinished() +{ + int index = ui->clusterServerNameCombo->currentIndex(); + if (index < clusters.size()) + { + clusters[index].port = ui->clusterTcpPortLineEdit->displayText().toInt(); + //emit setClusterTcpPort(clusters[index].port); + prefs->clusterTcpPort = clusters[index].port; + emit changedClusterPref(cl_clusterTcpPort); + } +} + +void settingswidget::on_clusterUsernameLineEdit_editingFinished() +{ + int index = ui->clusterServerNameCombo->currentIndex(); + if (index < clusters.size()) + { + clusters[index].userName = ui->clusterUsernameLineEdit->text(); + //emit setClusterUserName(clusters[index].userName); + prefs->clusterTcpUserName = clusters[index].userName; + emit changedClusterPref(cl_clusterTcpUserName); + } +} + +void settingswidget::on_clusterPasswordLineEdit_editingFinished() +{ + int index = ui->clusterServerNameCombo->currentIndex(); + if (index < clusters.size()) + { + clusters[index].password = ui->clusterPasswordLineEdit->text(); + //emit setClusterPassword(clusters[index].password); + prefs->clusterTcpPassword = clusters[index].password; + emit changedClusterPref(cl_clusterTcpPassword); + } +} + +void settingswidget::on_clusterTimeoutLineEdit_editingFinished() +{ + int index = ui->clusterServerNameCombo->currentIndex(); + if (index < clusters.size()) + { + clusters[index].timeout = ui->clusterTimeoutLineEdit->displayText().toInt(); + //emit setClusterTimeout(clusters[index].timeout); + prefs->clusterTimeout = clusters[index].timeout; + emit changedClusterPref(cl_clusterTimeout); + } +} + +void settingswidget::on_clusterUdpPortLineEdit_editingFinished() +{ + bool ok = false; + int p = ui->clusterUdpPortLineEdit->text().toInt(&ok); + if(ok) + { + prefs->clusterUdpPort = p; + emit changedClusterPref(cl_clusterUdpPort); + } +} + +void settingswidget::on_clusterSkimmerSpotsEnable_clicked(bool checked) +{ + prefs->clusterSkimmerSpotsEnable = checked; + emit changedClusterPref(cl_clusterSkimmerSpotsEnable); +} + +void settingswidget::on_ipAddressTxt_textChanged(const QString &arg1) +{ + udpPrefs->ipAddress = arg1; + emit changedUdpPref(u_ipAddress); +} + +void settingswidget::on_usernameTxt_textChanged(const QString &arg1) +{ + udpPrefs->username = arg1; + emit changedUdpPref(u_username); +} + +void settingswidget::on_controlPortTxt_textChanged(const QString &arg1) +{ + bool ok = false; + int port = arg1.toUInt(&ok); + if(ok) + { + udpPrefs->controlLANPort = port; + emit changedUdpPref(u_controlLANPort); + } +} + +void settingswidget::on_passwordTxt_textChanged(const QString &arg1) +{ + udpPrefs->password = arg1; + emit changedUdpPref(u_password); +} + +void settingswidget::on_audioDuplexCombo_currentIndexChanged(int index) +{ + udpPrefs->halfDuplex = (bool)index; + emit changedUdpPref(u_halfDuplex); +} + +void settingswidget::on_audioOutputCombo_currentIndexChanged(int index) +{ + emit changedAudioOutputCombo(index); +} + +void settingswidget::on_audioInputCombo_currentIndexChanged(int index) +{ + emit changedAudioInputCombo(index); +} + +void settingswidget::on_serverRXAudioInputCombo_currentIndexChanged(int index) +{ + emit changedServerRXAudioInputCombo(index); +} + +void settingswidget::on_serverTXAudioOutputCombo_currentIndexChanged(int index) +{ + emit changedServerTXAudioOutputCombo(index); +} + +void settingswidget::on_serverEnableCheckbox_clicked(bool checked) +{ + serverConfig->enabled = checked; + emit changedServerConfig(s_enabled); +} + +void settingswidget::on_serverAddUserBtn_clicked() +{ + if(!haveServerConfig) + { + qCritical(logGui()) << "Cannot modify users without valid serverConfig."; + return; + } + serverAddUserLine("", "", 0); + SERVERUSER user; + user.username = ""; + user.password = ""; + user.userType = 0; + serverConfig->users.append(user); + + ui->serverAddUserBtn->setEnabled(false); +} diff --git a/settingswidget.h b/settingswidget.h new file mode 100644 index 0000000..e3369a4 --- /dev/null +++ b/settingswidget.h @@ -0,0 +1,191 @@ +#ifndef SETTINGSWIDGET_H +#define SETTINGSWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "logcategories.h" +#include "prefs.h" +#include "colorprefs.h" +#include "udpbase.h" // for udp preferences +#include "cluster.h" // for clusterSettings +#include "rigidentities.h" // for rigInputs +#include "udpserver.h" // for SERVERCONFIG + +namespace Ui { +class settingswidget; +} + +class settingswidget : public QWidget +{ + Q_OBJECT + +public: + explicit settingswidget(QWidget *parent = nullptr); + + ~settingswidget(); + +public slots: + void acceptPreferencesPtr(preferences *pptr); + void acceptUdpPreferencesPtr(udpPreferences *upptr); + void acceptServerConfig(SERVERCONFIG *serverConfig); + + void copyClusterList(QList c); + void insertClusterOutputText(QString text); + + void updateIfPrefs(int items); + void updateRaPrefs(int items); + void updateCtPrefs(int items); + void updateLanPrefs(int items); + void updateClusterPrefs(int items); + void updateServerConfigs(int items); + + void updateIfPref(prefIfItem pif); + void updateRaPref(prefRaItem pra); + void updateCtPref(prefCtItem pct); + void updateLanPref(prefLanItem plan); + void updateClusterPref(prefClusterItem pcl); + void updateServerConfig(serverItems si); + + void updateUdpPref(udpPrefsItem upi); + void updateUdpPrefs(int items); + + void updateAudioInputs(QStringList deviceList, int currentIndex, int chars); + void updateAudioOutputs(QStringList deviceList, int currentIndex, int chars); + void updateServerRXAudioInputs(QStringList deviceList, int currentIndex, int chars); + void updateServerTXAudioOutputs(QStringList deviceList, int currentIndex, int chars); + + void updateSerialPortList(QStringList deviceList, QVector data); + void updateVSPList(QStringList deviceList, QVector data); + + void updateModSourceList(QStringList deviceNames, QVector data); + void updateDataModSourceList(QStringList deviceNames, QVector data); + +signals: + void changedIfPrefs(int items); + void changedRaPrefs(int items); + void changedCtPrefs(int items); + void changedLanPrefs(int items); + void changedClusterPrefs(int items); + void changedUdpPrefs(int items); + void changedServerConfigs(int i); + + void changedAudioOutputCombo(int index); + void changedAudioInputCombo(int index); + void changedServerTXAudioOutputCombo(int index); + void changedServerRXAudioInputCombo(int index); + + void changedIfPref(prefIfItem i); + void changedRaPref(prefRaItem i); + void changedCtPref(prefCtItem i); + void changedLanPref(prefLanItem i); + void changedClusterPref(prefClusterItem i); + void changedUdpPref(udpPrefsItem i); + void changedServerConfig(serverItems i); + + void showUSBControllerSetup(); + +private slots: + void on_settingsList_currentRowChanged(int currentRow); + void onServerUserFieldChanged(); + void on_lanEnableBtn_clicked(bool checked); + void on_autoSSBchk_clicked(bool checked); + void on_useSystemThemeChk_clicked(bool checked); + void on_enableUsbChk_clicked(bool checked); + void on_usbControllerBtn_clicked(); + void on_autoPollBtn_clicked(bool checked); + void on_manualPollBtn_clicked(bool checked); + void on_pollTimeMsSpin_valueChanged(int arg1); + void on_serialDeviceListCombo_activated(const QString &arg1); + void on_baudRateCombo_activated(int index); + void on_vspCombo_activated(int index); + void on_audioSystemCombo_currentIndexChanged(int index); + void on_audioSystemServerCombo_currentIndexChanged(int index); + void on_meter2selectionCombo_currentIndexChanged(int index); + void on_tuningFloorZerosChk_clicked(bool checked); + void on_fullScreenChk_clicked(bool checked); + void on_wfAntiAliasChk_clicked(bool checked); + void on_wfInterpolateChk_clicked(bool checked); + void on_underlayNone_clicked(bool checked); + void on_underlayPeakHold_clicked(bool checked); + void on_underlayPeakBuffer_clicked(bool checked); + void on_underlayAverageBuffer_clicked(bool checked); + void on_underlayBufferSlider_valueChanged(int value); + void on_pttEnableChk_clicked(bool checked); + void on_clickDragTuningEnableChk_clicked(bool checked); + void on_serialEnableBtn_clicked(bool checked); + void on_enableRigctldChk_clicked(bool checked); + void on_rigctldPortTxt_editingFinished(); + void on_tcpServerPortTxt_editingFinished(); + void on_clusterServerNameCombo_currentIndexChanged(int index); + void on_clusterUdpEnable_clicked(bool checked); + void on_clusterTcpEnable_clicked(bool checked); + void on_clusterTcpSetNowBtn_clicked(); + void on_clusterServerNameCombo_currentTextChanged(const QString &arg1); + void on_clusterTcpPortLineEdit_editingFinished(); + void on_clusterUsernameLineEdit_editingFinished(); + void on_clusterPasswordLineEdit_editingFinished(); + void on_clusterTimeoutLineEdit_editingFinished(); + void on_clusterUdpPortLineEdit_editingFinished(); + void on_clusterSkimmerSpotsEnable_clicked(bool checked); + void on_debugBtn_clicked(); + void on_ipAddressTxt_textChanged(const QString &arg1); + void on_usernameTxt_textChanged(const QString &arg1); + void on_controlPortTxt_textChanged(const QString &arg1); + void on_passwordTxt_textChanged(const QString &arg1); + void on_audioDuplexCombo_currentIndexChanged(int index); + void on_audioOutputCombo_currentIndexChanged(int index); + void on_audioInputCombo_currentIndexChanged(int index); + void on_serverRXAudioInputCombo_currentIndexChanged(int index); + void on_serverTXAudioOutputCombo_currentIndexChanged(int index); + void on_serverEnableCheckbox_clicked(bool checked); + + void on_serverAddUserBtn_clicked(); + +private: + Ui::settingswidget *ui; + void createSettingsListItems(); + void populateComboBoxes(); + void updateAllPrefs(); + void updateUnderlayMode(); + void setUItoClustersList(); + + // Utility: + void quietlyUpdateSlider(QSlider* sl, int val); + void quietlyUpdateSpinbox(QSpinBox *sb, int val); + void quietlyUpdateCheckbox(QCheckBox *cb, bool isChecked); + void quietlyUpdateRadiobutton(QRadioButton *rb, bool isChecked); + void quietlyUpdateLineEdit(QLineEdit *le, const QString text); + + void populateServerUsers(); + void serverAddUserLine(const QString& user, const QString& pass, const int& type); + + preferences *prefs = NULL; + udpPreferences *udpPrefs = NULL; + SERVERCONFIG *serverConfig = NULL; + bool havePrefs = false; + bool haveUdpPrefs = false; + bool haveServerConfig = false; + bool haveSerialDevices = false; + bool haveVspDevices = false; + bool haveAudioInputs = false; + bool haveAudioOutputs = false; + bool haveServerAudioInputs = false; + bool haveServerAudioOutputs = false; + bool haveClusterList = false; + bool updatingUIFromPrefs = false; + + QList clusters; + +}; + +#endif // SETTINGSWIDGET_H diff --git a/settingswidget.ui b/settingswidget.ui new file mode 100644 index 0000000..03492e7 --- /dev/null +++ b/settingswidget.ui @@ -0,0 +1,3187 @@ + + + settingswidget + + + + 0 + 0 + 1118 + 561 + + + + Settings + + + + + + 0 + + + 0 + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + + + + + 3 + + + + + + + + + + 140 + 0 + + + + Radio Connection + + + + + + Serial (USB) + + + + + + + Network + + + + + + + + + + + 300 + 0 + + + + + 300 + 16777215 + + + + CI-V and Model + + + + + + <html><head/><body><p>If you are using an older (year 2010) radio, you may need to enable this option to manually specify the CI-V address. This option is also useful for radios that do not have CI-V Transceive enabled and thus will not answer our broadcast query for connected rigs on the CI-V bus.</p><p>If you have a modern radio with CI-V Transceive enabled, you should not need to check this box. </p><p>You will need to Save Settings and re-launch wfview for this to take effect. </p></body></html> + + + Manual Radio CI-V Address: + + + + + + + <html><head/><body><p>Only check for older radios!</p><p>This checkbox forces wfview to trust that the CI-V address is also the model number of the radio. This is only useful for older radios that do not reply to our Rig ID requests (0x19 0x00). Do not check this box unless you have an older radio. </p></body></html> + + + Use CI-V address as Model ID too + + + + + + + false + + + + 50 + 0 + + + + + 50 + 16777215 + + + + <html><head/><body><p>Enter the address in as hexadecimal, without any prefix, just as the radio presents the address in the menu. </p><p>Here are some common examples:</p> +<p>IC-706: 58 +<br/>IC-756: 50 +<br/>IC-756 Pro: 5C +<br/>IC-756 Pro II: 64 +<br/>IC-756 Pro III: 6E +<br/>IC-7000: 70 +<br/>IC-7100: 88 +<br/>IC-7200: 76 +<br/>IC-7300: 94 +</p><p>This setting is typically needed for older radios and for radios that do not have CI-V Transceive enabled. </p> +<p>After changing, press Save Settings and re-launch wfview.</p></body></html> + + + auto + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + Serial Connected Radios + + + + 3 + + + 5 + + + 3 + + + 5 + + + + + Serial Device: + + + + + + + + 180 + 0 + + + + + 180 + 16777215 + + + + + + + + Baud Rate + + + + + + + + 120 + 16777215 + + + + + + + + <html><head/><body><p>This feature is for older radios that respond best to an RTS serial port signal than a PTT command.</p><p><br/>For radios lacking PTT commands, this is automatic and transparent, but for radios which have a PTT command, you can check this box to override and force the PTT to be done using RTS. Do not check this box unless you really need this and have an appropriate adapter with RTS connected to the PTT line of the transceiver. </p></body></html> + + + Send RTS for PTT + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Network Connected Radios + + + + 6 + + + 3 + + + 5 + + + 3 + + + 5 + + + + + 0 + + + 0 + + + 0 + + + + + Hostname + + + + + + + + 256 + 0 + + + + + 256 + 16777215 + + + + + + + + Control Port + + + + + + + + 75 + 16777215 + + + + 50001 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Username + + + + + + + + 256 + 0 + + + + + 256 + 16777215 + + + + + + + + Password + + + + + + + + 180 + 0 + + + + + 180 + 16777215 + + + + QLineEdit::PasswordEchoOnEdit + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + RX Latency (ms) + + + + + + + + 0 + 0 + + + + 30 + + + 500 + + + Qt::Horizontal + + + + + + + 0 + + + + + + + TX Latency (ms) + + + + + + + 30 + + + 500 + + + Qt::Horizontal + + + + + + + 0 + + + + + + + RX Codec + + + + + + + Receive Audio Codec Selector + + + + + + + TX Codec + + + + + + + Transmit Audio Codec Selector + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Sample Rate + + + + + + + Audio Sample Rate Selector + + + + 48000 + + + + + 24000 + + + + + 16000 + + + + + 8000 + + + + + + + + Duplex + + + + + + + + Full Duplex + + + + + Half Duplex + + + + + + + + Audio System + + + + + + + + Qt Audio + + + + + PortAudio + + + + + RT Audio + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Audio Output + + + + + + + + 200 + 16777215 + + + + Audio Output Selector + + + + + + + Audio Input + + + + + + + + 200 + 16777215 + + + + Audio Input Selector + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + When tuning, set lower digits to zero + + + true + + + + + + + When using SSB, automatically switch to the standard sideband for a given band. + + + Auto SSB Switching + + + When using SSB, automatically switch to the standard sideband for a given band. + + + Auto SSB + + + + + + + Allow tuning via click and drag (experimental) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Enables interpolation between pixels. Note that this will increase CPU usage. + + + Interpolate Waterfall + + + true + + + + + + + Anti-Alias Waterfall + + + + + + + Use System Theme + + + + + + + Show full screen (F11) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Underlay Mode + + + + + + + No underlay graphics + + + None + + + true + + + + + + + Indefinite peak hold + + + Peak Hold + + + + + + + Peak value within the buffer + + + Peak + + + + + + + Average value within the buffer + + + Average + + + + + + + Underlay Buffer Size: + + + + + + + + 100 + 16777215 + + + + Size of buffer for spectrum data. Shorter values are more responsive. + + + 8 + + + 128 + + + 64 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Enable PTT Controls + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Secondary Meter Selection: + + + + + + + + + + wfview will automatically calculate command polling. Recommended. + + + AutoPolling + + + true + + + pollingButtonGroup + + + + + + + Manual (user-defined) command polling + + + Manual Polling Inteval: + + + pollingButtonGroup + + + + + + + Sets the polling interval, in ms. Automatic polling is recommended. Serial port and USB port radios should not poll quicker than about 75ms. + + + 1 + + + 250 + + + + + + + ms + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + 0 + + + + + Color scheme + + + + + + + Preset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + Select a color preset here. + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + + Saves the current preset to the settings file. + + + Save Preset + + + + + + + Revert the selected color preset to the default. + + + Revert + + + + + + + Rename the selected color preset. Max length is 10 characters. + + + Rename Preset + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 1 + + + + + 0 + 250 + + + + + 0 + 0 + + + + User-defined Color Editor + + + + 0 + + + 4 + + + 0 + + + 0 + + + + + QAbstractScrollArea::AdjustIgnored + + + true + + + + + 0 + 0 + 916 + 311 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + 6 + + + + + + 10 + 0 + + + + + + + + + 10 + 0 + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Meter Text + + + + + + + Grid + + + + + + + Text + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + + 10 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 10 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Meter Scale + + + + + + + + 90 + 16777215 + + + + Color text format is #AARRGGBB, where AA is the "alpha" channel, and value "00" is totally transparent, and "ff" is totally opaque. + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Waterfall Back + + + + + + + Axis + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Plot Background + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Spectrum Line + + + + + + + Spectrum Fill + + + + + + + Underlay Line + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + + 10 + 0 + + + + + + + + + 10 + 0 + + + + + + + + + 10 + 0 + + + + + + + + Underlay Fill + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Tuning Line + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Passband + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + PBT Indicator + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Meter Level + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Meter Average + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Meter Peak Level + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Meter High Scale + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Waterfall Grid + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Waterfall Axis + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Waterfall Text + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 10 + 0 + + + + + + + + Cluster Spots + + + + + + + + 0 + 0 + + + + + 90 + 16777215 + + + + + + + + + 10 + 0 + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + + + + + + Modulation Input: + + + + + + + Modulation Input + + + Transmit modulation source + + + QComboBox::AdjustToContents + + + + + + + Data Mod Input: + + + + + + + Data Modulation Input + + + Transmit Data-mode modulation input source + + + QComboBox::AdjustToContents + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Press here to set the clock of the radio. The command will be sent to the radio when the seconds go to zero. + + + Set Clock + + + + + + + Check this box to set the radio's clock to UTC. Otherwise, the clock will be set to the local timezone of this computer. + + + Use UTC + + + + + + + Satellite Ops + + + + + + + <html><head/><body><p>Click here to adjust the frequency reference on the IC-9700.</p></body></html> + + + Adjust Reference + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + Manual PTT Toggle + + + + + + + PTT On + + + Ctrl+S + + + + + + + PTT Off + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 279 + + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + Enable + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Server Setup + + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + Control Port + + + + + + + + 0 + 0 + + + + + 130 + 25 + + + + + 130 + 25 + + + + 99999 + + + 50001 + + + true + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + Civ Port + + + + + + + + 130 + 25 + + + + + 130 + 25 + + + + 99999 + + + 50002 + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + Audio Port + + + + + + + + 130 + 25 + + + + + 130 + 25 + + + + 99999 + + + 50003 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + RX Audio Input + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + + + + + TX Audio Output + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + + + + + Audio System + + + + + + + + Qt Audio + + + + + PortAudio + + + + + RT Audio + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 400 + 160 + + + + + 750 + 330 + + + + QFrame::StyledPanel + + + 1 + + + 0 + + + 4 + + + false + + + 100 + + + false + + + true + + + false + + + true + + + false + + + + Username + + + + + Password + + + + + Admin + + + + + Delete? + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Add User + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + 0 + + + 0 + + + + + Qt::LeftToRight + + + Enable RigCtld + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Port + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + + + + + Qt::Horizontal + + + + 422 + 20 + + + + + + + + + + + + Virtual Serial Port + + + + + + + + 250 + 0 + + + + + 250 + 16777215 + + + + <html><head/><body><p>Use this to define a virtual serial port. </p><p><br/></p><p>On Windows, the virtual serial port can be used to connect to a serial port loopback device, through which other programs can connect to the radio. </p><p><br/></p><p>On Linux and macOS, the port defined here is a pseudo-terminal device, which may be connected to directly by any program designed for a serial connection. </p></body></html> + + + Virtual Serial Port Selector + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + TCP Server Port + + + + + + + true + + + + 0 + 0 + + + + + + + + Enter port for TCP server, 0 = disabled (restart required if changed) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Waterfall Format + + + + + + + + Default + + + + + Single (network) + + + + + Multi (serial) + + + + + + + + Only change this if you are absolutely sure you need it (connecting to N1MM+ or similar) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Enable USB Controllers + + + + + + + + + + Setup USB Controller + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Reset Buttons + + + + + + + Reset Commands + + + + + + + Only reset buttons/commands if you have issues. + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + true + + + + + 0 + 10 + 831 + 21 + + + + + + + This page contains configuration for DX Cluster, either UDP style broadcast (from N1MM+/DXlog) or TCP connection to your favourite cluster + + + + + + + + + 10 + 50 + 201 + 181 + + + + UDP Broadcast Connection + + + + + 20 + 40 + 161 + 121 + + + + + + + UDP Port + + + + + + + 00000 + + + + + + + Enable + + + + + + + + + + 330 + 50 + 311 + 241 + + + + TCP Cluster Connection + + + + + 20 + 40 + 271 + 186 + + + + + + + Server Name + + + + + + + Username + + + + + + + + + + Password + + + + + + + QLineEdit::PasswordEchoOnEdit + + + + + + + Enable + + + + + + + true + + + true + + + + + + + Spot Timeout (minutes) + + + + + + + 0000 + + + + + + + + + + Server Port + + + + + + + 00000 + + + + + + + SetNow + + + + + + + + + + 10 + 320 + 811 + 141 + + + + QFrame::Raised + + + QAbstractScrollArea::AdjustIgnored + + + + + + 10 + 470 + 801 + 24 + + + + + + + Show Skimmer Spots + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + groupBox_9 + horizontalLayoutWidget + groupBox_10 + clusterOutputTextEdit + horizontalLayoutWidget_2 + + + + + + + + + This page contains experimental features. Use at your own risk. + + + + + + + + + + + <html><head/><body><p>This button runs debug functions, and is provided as a convenience for programmers. The functions executed are under:</p><p><span style=" color:#ffff55;">void</span><span style=" color:#55ff55;">wfmain</span><span style=" color:#aaaaaa;">::</span><span style=" font-weight:600;">on_debugBtn_clicked</span><span style=" color:#aaaaaa;">()</span></p><p>in wfmain.cpp.</p></body></html> + + + Debug + + + Ctrl+Alt+D + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 320 + + + + + + + + + true + + + + + + + + + + + QLedLabel + QWidget +
qledlabel.h
+ 1 +
+
+ + + + + +
diff --git a/udpbase.h b/udpbase.h index 24ce4be..de13019 100644 --- a/udpbase.h +++ b/udpbase.h @@ -24,6 +24,18 @@ #include "packettypes.h" +enum udpPrefsItem { + u_ipAddress = 1 << 0, + u_controlLANPort = 1 << 1, + u_serialLANPort = 1 << 2, + u_audioLANPort = 1 << 3, + u_username = 1 << 4, + u_password = 1 << 5, + u_clientName = 1 << 6, + u_waterfallFormat = 1 << 7, + u_halfDuplex = 1 << 8, + u_all = 1 << 9 +}; struct udpPreferences { diff --git a/udpserver.h b/udpserver.h index 3cbed99..fd9ce39 100644 --- a/udpserver.h +++ b/udpserver.h @@ -94,6 +94,21 @@ struct SERVERCONFIG { QList rigs; }; +enum serverItems { + s_enabled = 1 << 0, + s_lan = 1 << 1, + s_controlPort = 1 << 2, + s_civPort = 1 << 3, + s_audioPort = 1 << 4, + s_audioOutput = 1 << 5, + s_audioInput = 1 << 6, + s_resampleQuality = 1 << 7, + s_baudRate = 1 << 8, + s_users = 1 << 9, + s_rigs = 1 << 10, + s_all = 1 << 11 +}; + class udpServer : public QObject { diff --git a/wfmain.cpp b/wfmain.cpp index a47af95..1955567 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -52,6 +52,9 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode cw = new cwSender(); abtBox = new aboutbox(); selRad = new selectRadio(); + bandbtns = new bandbuttons(); + finputbtns = new frequencyinputwidget(); + setupui = new settingswidget(); qRegisterMetaType(); // Needs to be registered early. qRegisterMetaType(); @@ -160,6 +163,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode setupKeyShortcuts(); setupMainUI(); + connectSettingsWidget(); prepareSettingsWindow(); setSerialDevicesUI(); @@ -174,7 +178,9 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode loadSettings(); // Look for saved preferences - audioDev = new audioDevices(prefs.audioSystem, QFontMetrics(ui->audioInputCombo->font())); + // TODO: How to tell this thing how big the font is...? There isn't a UI anymore for this... + // Fake it for now assuming the button has the same font as a combo box + audioDev = new audioDevices(prefs.audioSystem, QFontMetrics(ui->connectBtn->font())); connect(audioDev, SIGNAL(updated()), this, SLOT(setAudioDevicesUI())); audioDev->enumerate(); //setAudioDevicesUI(); // no need to call this as it will be called by the updated() signal @@ -400,6 +406,7 @@ void wfmain::openRig() } +// Migrated void wfmain::createSettingsListItems() { // Add items to the settings tab list widget @@ -414,18 +421,12 @@ void wfmain::createSettingsListItems() ui->settingsStack->setCurrentIndex(0); } +// Migrated void wfmain::on_settingsList_currentRowChanged(int currentRow) { ui->settingsStack->setCurrentIndex(currentRow); } - -void wfmain::connectSettingsList() -{ - -} - - void wfmain::rigConnections() { @@ -590,6 +591,78 @@ void wfmain::rigConnections() connect(this, SIGNAL(setRptDuplexOffset(freqt)), rig, SLOT(setRptDuplexOffset(freqt))); connect(this, SIGNAL(getDuplexMode()), rig, SLOT(getDuplexMode())); + // Band buttons: + connect(rig, &rigCommander::haveRigID, + [=](const rigCapabilities &rigid) { + bandbtns->acceptRigCaps(rigid); + qDebug() << "Rig caps going to band buttons"; + }); + + if(haveRigCaps) + { + qDebug(logGui()) << "Already had rigCaps, sending to band buttons..."; + bandbtns->acceptRigCaps(rigCaps); + } + + connect(rig, SIGNAL(haveBandStackReg(freqt,char,char,bool)), bandbtns, SLOT(receiveBandStackReg(freqt,char,char,bool))); + connect(this->bandbtns, &bandbuttons::issueCmdF, + [=](const cmds cmd, freqt f) { + issueCmd(cmd, f); + }); + connect(bandbtns, &bandbuttons::issueCmdUniquePriority, + [=](const cmds cmd, char c) { + issueCmdUniquePriority(cmd, c); + }); + connect(bandbtns, &bandbuttons::issueCmd, + [=](cmds cmd, char c) { + issueCmd(cmd, c); + }); + connect(bandbtns, &bandbuttons::issueDelayedCommand, + [=](cmds cmd) { + issueDelayedCommand(cmd); + }); + + // Frequency Buttons: + connect(finputbtns, &frequencyinputwidget::issueCmdF, + [=](cmds cmd, freqt f) { + issueCmd(cmd, f); + }); + connect(finputbtns, &frequencyinputwidget::issueCmdM, + [=](cmds cmd, mode_info m) { + issueCmd(cmd, m); + }); + connect(finputbtns, &frequencyinputwidget::updateUIMode, + [=](mode_kind m) { + // set the mode combo box, quietly, to the mode indicated. + ui->modeSelectCombo->blockSignals(true); + ui->modeSelectCombo->setCurrentIndex(ui->modeSelectCombo->findData(m)); + ui->modeSelectCombo->blockSignals(false); + }); + connect(finputbtns, &frequencyinputwidget::updateUIFrequency, + [=](freqt f) { + // f has both parts populated + this->freq = f; + setUIFreq(); // requires f.MHzDouble + }); + connect(finputbtns, &frequencyinputwidget::gotoMemoryPreset, + [=](int presetNumber) { + gotoMemoryPreset(presetNumber); + }); + connect(finputbtns, &frequencyinputwidget::saveMemoryPreset, + [=](int presetNumber) { + saveMemoryPreset(presetNumber); + }); + + // Passband, CW Pitch, Tone, TSQL... + connect(this, SIGNAL(getPassband()), rig, SLOT(getPassband())); + connect(this, SIGNAL(setPassband(quint16)), rig, SLOT(setPassband(quint16))); + connect(this, SIGNAL(getCwPitch()), rig, SLOT(getCwPitch())); + connect(this, SIGNAL(getPskTone()), rig, SLOT(getPskTone())); + connect(this, SIGNAL(getRttyMark()), rig, SLOT(getRttyMark())); + connect(this, SIGNAL(getTone()), rig, SLOT(getTone())); + connect(this, SIGNAL(getTSQL()), rig, SLOT(getTSQL())); + connect(this, SIGNAL(getRptAccessMode()), rig, SLOT(getRptAccessMode())); + connect(this, SIGNAL(getModInput(bool)), rig, SLOT(getModInput(bool))); connect(rig, SIGNAL(haveModInput(inputTypes,bool)), this, SLOT(receiveModInput(inputTypes, bool))); connect(this, SIGNAL(setModInput(inputTypes, bool)), rig, SLOT(setModInput(inputTypes,bool))); @@ -1082,11 +1155,6 @@ void wfmain::setupMainUI() { createSettingsListItems(); - ui->bandStkLastUsedBtn->setVisible(false); - ui->bandStkVoiceBtn->setVisible(false); - ui->bandStkDataBtn->setVisible(false); - ui->bandStkCWBtn->setVisible(false); - ui->baudRateCombo->insertItem(0, QString("115200"), 115200); ui->baudRateCombo->insertItem(1, QString("57600"), 57600); ui->baudRateCombo->insertItem(2, QString("38400"), 38400); @@ -1121,23 +1189,23 @@ void wfmain::setupMainUI() ui->wfthemeCombo->addItem("Spectrum", QCPColorGradient::gpSpectrum); ui->wfthemeCombo->addItem("Candy", QCPColorGradient::gpCandy); - ui->meter2selectionCombo->addItem("None", meterNone); - ui->meter2selectionCombo->addItem("SWR", meterSWR); - ui->meter2selectionCombo->addItem("ALC", meterALC); - ui->meter2selectionCombo->addItem("Compression", meterComp); - ui->meter2selectionCombo->addItem("Voltage", meterVoltage); - ui->meter2selectionCombo->addItem("Current", meterCurrent); - ui->meter2selectionCombo->addItem("Center", meterCenter); - ui->meter2selectionCombo->addItem("TxRxAudio", meterAudio); - ui->meter2selectionCombo->addItem("RxAudio", meterRxAudio); - ui->meter2selectionCombo->addItem("TxAudio", meterTxMod); +// ui->meter2selectionCombo->addItem("None", meterNone); +// ui->meter2selectionCombo->addItem("SWR", meterSWR); +// ui->meter2selectionCombo->addItem("ALC", meterALC); +// ui->meter2selectionCombo->addItem("Compression", meterComp); +// ui->meter2selectionCombo->addItem("Voltage", meterVoltage); +// ui->meter2selectionCombo->addItem("Current", meterCurrent); +// ui->meter2selectionCombo->addItem("Center", meterCenter); +// ui->meter2selectionCombo->addItem("TxRxAudio", meterAudio); +// ui->meter2selectionCombo->addItem("RxAudio", meterRxAudio); +// ui->meter2selectionCombo->addItem("TxAudio", meterTxMod); ui->meter2Widget->hide(); - ui->meter2selectionCombo->show(); - ui->meter2selectionCombo->setCurrentIndex((int)prefs.meter2Type); +// ui->meter2selectionCombo->show(); +// ui->meter2selectionCombo->setCurrentIndex((int)prefs.meter2Type); - ui->secondaryMeterSelectionLabel->show(); +// ui->secondaryMeterSelectionLabel->show(); // Future ideas: @@ -1180,9 +1248,10 @@ void wfmain::setupMainUI() ui->monitorSlider->setTickInterval(100); ui->monitorSlider->setSingleStep(10); - ui->freqMhzLineEdit->setValidator( new QDoubleValidator(0, 100, 6, this)); + //ui->freqMhzLineEdit->setValidator( new QDoubleValidator(0, 100, 6, this)); ui->controlPortTxt->setValidator(new QIntValidator(this)); + // Keep this code when the rest is removed from this function: qDebug(logSystem()) << "Running with debugging options enabled."; #ifdef QT_DEBUG ui->debugBtn->setVisible(true); @@ -1270,6 +1339,52 @@ void wfmain::setupMainUI() queue->add(priorityImmediate,queueItem(funcPBTInner,QVariant::fromValue(passbandHz))); }); + connect(this->cw, &cwSender::sendCW, + [=](const QString &cwMessage) { issueCmd(cmdSendCW, cwMessage);}); + connect(this->cw, &cwSender::stopCW, + [=]() { issueDelayedCommand(cmdStopCW);}); + connect(this->cw, &cwSender::setBreakInMode, + [=](const unsigned char &bmode) { issueCmd(cmdSetBreakMode, bmode);}); + connect(this->cw, &cwSender::setKeySpeed, + [=](const unsigned char& wpm) { issueCmd(cmdSetKeySpeed, wpm); }); + connect(this->cw, &cwSender::setPitch, + [=](const unsigned char& pitch) { issueCmd(cmdSetCwPitch, pitch); }); + connect(this->cw, &cwSender::getCWSettings, + [=]() { issueDelayedCommand(cmdGetKeySpeed); + issueDelayedCommand(cmdGetBreakMode);}); + +void wfmain::connectSettingsWidget() +{ + connect(setupui, SIGNAL(changedClusterPref(prefClusterItem)), this, SLOT(extChangedClusterPref(prefClusterItem))); + connect(setupui, SIGNAL(changedClusterPrefs(int)), this, SLOT(extChangedClusterPrefs(int))); + + connect(setupui, SIGNAL(changedCtPref(prefCtItem)), this, SLOT(extChangedCtPref(prefCtItem))); + connect(setupui, SIGNAL(changedCtPrefs(int)), this, SLOT(extChangedCtPrefs(int))); + + connect(setupui, SIGNAL(changedIfPref(prefIfItem)), this, SLOT(extChangedIfPref(prefIfItem))); + connect(setupui, SIGNAL(changedIfPrefs(int)), this, SLOT(extChangedIfPrefs(int))); + + connect(setupui, SIGNAL(changedLanPref(prefLanItem)), this, SLOT(extChangedLanPref(prefLanItem))); + connect(setupui, SIGNAL(changedLanPrefs(int)), this, SLOT(extChangedLanPrefs(int))); + + connect(setupui, SIGNAL(changedRaPref(prefRaItem)), this, SLOT(extChangedRaPref(prefRaItem))); + connect(setupui, SIGNAL(changedRaPrefs(int)), this, SLOT(extChangedRaPrefs(int))); + + connect(setupui, SIGNAL(changedUdpPref(udpPrefsItem)), this, SLOT(extChangedUdpPref(udpPrefsItem))); + connect(setupui, SIGNAL(changedUdpPrefs(int)), this, SLOT(extChangedUdpPrefs(int))); + + connect(setupui, &settingswidget::showUSBControllerSetup, [=](){ + if(shut != Q_NULLPTR) + showAndRaiseWidget(shut); + }); + + connect(this, SIGNAL(haveClusterList(QList)), setupui, SLOT(copyClusterList(QList))); + + connect(setupui, SIGNAL(changedAudioInputCombo(int)), this, SLOT(changedAudioInput(int))); + connect(setupui, SIGNAL(changedAudioOutputCombo(int)), this, SLOT(changedAudioOutput(int))); + connect(setupui, SIGNAL(changedServerRXAudioInputCombo(int)), this, SLOT(changedServerRXAudioInput(int))); + connect(setupui, SIGNAL(changedServerTXAudioOutputCombo(int)), this, SLOT(changedServerTXAudioOutput(int))); + } void wfmain::prepareSettingsWindow() @@ -1288,6 +1403,7 @@ void wfmain::prepareSettingsWindow() // TODO: Capture an event when the window closes and handle accordingly. } +// NOT Migrated, EHL TODO, carefully remove this function void wfmain::updateSizes(int tabIndex) { @@ -1431,38 +1547,38 @@ void wfmain::setServerToPrefs() void wfmain::setUIToPrefs() { - ui->fullScreenChk->setChecked(prefs.useFullScreen); - on_fullScreenChk_clicked(prefs.useFullScreen); + //ui->fullScreenChk->setChecked(prefs.useFullScreen); + changeFullScreenMode(prefs.useFullScreen); - ui->useSystemThemeChk->setChecked(prefs.useSystemTheme); - on_useSystemThemeChk_clicked(prefs.useSystemTheme); + //ui->useSystemThemeChk->setChecked(prefs.useSystemTheme); + useSystemTheme(prefs.useSystemTheme); underlayMode = prefs.underlayMode; - switch(underlayMode) - { - case underlayNone: - ui->underlayNone->setChecked(true); - break; - case underlayPeakHold: - ui->underlayPeakHold->setChecked(true); - break; - case underlayPeakBuffer: - ui->underlayPeakBuffer->setChecked(true); - break; - case underlayAverageBuffer: - ui->underlayAverageBuffer->setChecked(true); - break; - default: - break; - } +// switch(underlayMode) +// { +// case underlayNone: +// ui->underlayNone->setChecked(true); +// break; +// case underlayPeakHold: +// ui->underlayPeakHold->setChecked(true); +// break; +// case underlayPeakBuffer: +// ui->underlayPeakBuffer->setChecked(true); +// break; +// case underlayAverageBuffer: +// ui->underlayAverageBuffer->setChecked(true); +// break; +// default: +// break; +// } - ui->underlayBufferSlider->setValue(prefs.underlayBufferSize); + //ui->underlayBufferSlider->setValue(prefs.underlayBufferSize); on_underlayBufferSlider_valueChanged(prefs.underlayBufferSize); - ui->wfAntiAliasChk->setChecked(prefs.wfAntiAlias); + //ui->wfAntiAliasChk->setChecked(prefs.wfAntiAlias); on_wfAntiAliasChk_clicked(prefs.wfAntiAlias); - ui->wfInterpolateChk->setChecked(prefs.wfInterpolate); + //ui->wfInterpolateChk->setChecked(prefs.wfInterpolate); on_wfInterpolateChk_clicked(prefs.wfInterpolate); ui->wfLengthSlider->setValue(prefs.wflength); @@ -1488,13 +1604,11 @@ void wfmain::setUIToPrefs() ui->wfthemeCombo->setCurrentIndex(ui->wfthemeCombo->findData(prefs.wftheme)); colorMap->setGradient(static_cast(prefs.wftheme)); - ui->tuningFloorZerosChk->blockSignals(true); - ui->tuningFloorZerosChk->setChecked(prefs.niceTS); - ui->tuningFloorZerosChk->blockSignals(false); +// ui->tuningFloorZerosChk->blockSignals(true); +// ui->tuningFloorZerosChk->setChecked(prefs.niceTS); +// ui->tuningFloorZerosChk->blockSignals(false); - ui->autoSSBchk->blockSignals(true); - ui->autoSSBchk->setChecked(prefs.automaticSidebandSwitching); - ui->autoSSBchk->blockSignals(false); + finputbtns->setAutomaticSidebandSwitching(prefs.automaticSidebandSwitching); ui->useCIVasRigIDChk->blockSignals(true); ui->useCIVasRigIDChk->setChecked(prefs.CIVisRadioModel); @@ -1503,6 +1617,9 @@ void wfmain::setUIToPrefs() void wfmain::setSerialDevicesUI() { + QStringList deviceList; + QVector deviceData; + ui->serialDeviceListCombo->blockSignals(true); ui->serialDeviceListCombo->addItem("Auto", 0); int i = 0; @@ -1510,9 +1627,13 @@ void wfmain::setSerialDevicesUI() { portList.append(serialPortInfo.portName()); #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) + deviceData.append(i); ui->serialDeviceListCombo->addItem(QString("/dev/") + serialPortInfo.portName(), i++); + deviceList.append(QString("/dev/") + serialPortInfo.portName()); #else ui->serialDeviceListCombo->addItem(serialPortInfo.portName(), i++); + deviceList.append(serialPortInfo.portName()); + //qInfo(logSystem()) << "Serial Port found: " << serialPortInfo.portName() << "Manufacturer:" << serialPortInfo.manufacturer() << "Product ID" << serialPortInfo.description() << "S/N" << serialPortInfo.serialNumber(); #endif } @@ -1521,14 +1642,23 @@ void wfmain::setSerialDevicesUI() #endif ui->serialDeviceListCombo->blockSignals(false); - ui->vspCombo->blockSignals(true); + setupui->updateSerialPortList(deviceList, deviceData); + + + // VSP: + QStringList vspList; + QVector vspData; + int vspCount=0; #ifdef Q_OS_WIN - ui->vspCombo->addItem(QString("None"), i++); + vspList.append(QString("None")); // i=0 when this is run + vspData.append(vspCount); foreach(const QSerialPortInfo & serialPortInfo, QSerialPortInfo::availablePorts()) { - ui->vspCombo->addItem(serialPortInfo.portName()); + vspList.append(serialPortInfo.portName()); + vspData.append(vspCount); + vspCount++; } #else // Provide reasonable names for the symbolic link to the pty device @@ -1538,20 +1668,17 @@ void wfmain::setSerialDevicesUI() QString vspName = QDir::homePath() + "/rig-pty"; #endif for (i = 1; i < 8; i++) { - ui->vspCombo->addItem(vspName + QString::number(i)); + vspList.append(vspName + QString::number(i)); + vspData.append(vspCount); + vspCount++; - if (QFile::exists(vspName + QString::number(i))) { - auto* model = qobject_cast(ui->vspCombo->model()); - auto* item = model->item(ui->vspCombo->count() - 1); - item->setEnabled(false); - } } - ui->vspCombo->addItem(vspName + QString::number(i)); - ui->vspCombo->addItem(QString("None"), i++); + vspList.append(vspName + QString::number(i)); + vspData.append(vspCount); + + setupui->updateVSPList(vspList, vspData); #endif - ui->vspCombo->setEditable(true); - ui->vspCombo->blockSignals(false); } @@ -1809,7 +1936,8 @@ void wfmain::setupUsbControllerDevice() void wfmain::pttToggle(bool status) { // is it enabled? - if (!ui->pttEnableChk->isChecked()) + + if (!prefs.enablePTT) { showStatusBarText("PTT is disabled, not sending command. Change under Settings tab."); return; @@ -2064,6 +2192,7 @@ void wfmain::setDefPrefs() void wfmain::loadSettings() { qInfo(logSystem()) << "Loading settings from " << settings->fileName(); + setupui->acceptServerConfig(&serverConfig); QString currentVersionString = QString(WFVIEW_VERSION); float currentVersionFloat = currentVersionString.toFloat(); @@ -2185,7 +2314,8 @@ void wfmain::loadSettings() } prefs.CIVisRadioModel = (bool)settings->value("CIVisRadioModel", defPrefs.CIVisRadioModel).toBool(); prefs.forceRTSasPTT = (bool)settings->value("ForceRTSasPTT", defPrefs.forceRTSasPTT).toBool(); - ui->useRTSforPTTchk->setChecked(prefs.forceRTSasPTT); + + //ui->useRTSforPTTchk->setChecked(prefs.forceRTSasPTT); prefs.serialPortRadio = settings->value("SerialPortRadio", defPrefs.serialPortRadio).toString(); int serialIndex = ui->serialDeviceListCombo->findText(prefs.serialPortRadio); @@ -2204,36 +2334,18 @@ void wfmain::loadSettings() } prefs.polling_ms = settings->value("polling_ms", defPrefs.polling_ms).toInt(); + // Migrated if(prefs.polling_ms == 0) { // Automatic - ui->pollingButtonGroup->blockSignals(true); - ui->autoPollBtn->setChecked(true); - ui->manualPollBtn->setChecked(false); - ui->pollingButtonGroup->blockSignals(false); - ui->pollTimeMsSpin->setEnabled(false); + } else { // Manual - ui->pollingButtonGroup->blockSignals(true); - ui->autoPollBtn->setChecked(false); - ui->manualPollBtn->setChecked(true); - ui->pollingButtonGroup->blockSignals(false); - ui->pollTimeMsSpin->blockSignals(true); - ui->pollTimeMsSpin->setValue(prefs.polling_ms); - ui->pollTimeMsSpin->blockSignals(false); - ui->pollTimeMsSpin->setEnabled(true); + } prefs.virtualSerialPort = settings->value("VirtualSerialPort", defPrefs.virtualSerialPort).toString(); - int vspIndex = ui->vspCombo->findText(prefs.virtualSerialPort); - if (vspIndex != -1) { - ui->vspCombo->setCurrentIndex(vspIndex); - } - else - { - ui->vspCombo->addItem(prefs.virtualSerialPort); - ui->vspCombo->setCurrentIndex(ui->vspCombo->count() - 1); - } + prefs.localAFgain = (unsigned char)settings->value("localAFgain", defPrefs.localAFgain).toUInt(); rxSetup.localAFgain = prefs.localAFgain; @@ -2253,7 +2365,6 @@ void wfmain::loadSettings() // Misc. user settings (enable PTT, draw peaks, etc) settings->beginGroup("Controls"); prefs.enablePTT = settings->value("EnablePTT", defPrefs.enablePTT).toBool(); - ui->pttEnableChk->setChecked(prefs.enablePTT); prefs.niceTS = settings->value("NiceTS", defPrefs.niceTS).toBool(); prefs.automaticSidebandSwitching = settings->value("automaticSidebandSwitching", defPrefs.automaticSidebandSwitching).toBool(); settings->endGroup(); @@ -2263,8 +2374,9 @@ void wfmain::loadSettings() prefs.enableLAN = settings->value("EnableLAN", defPrefs.enableLAN).toBool(); // If LAN is enabled, server gets its audio straight from the LAN - ui->serverRXAudioInputCombo->setEnabled(!prefs.enableLAN); - ui->serverTXAudioOutputCombo->setEnabled(!prefs.enableLAN); + // migrated, remove these + //ui->serverRXAudioInputCombo->setEnabled(!prefs.enableLAN); + //ui->serverTXAudioOutputCombo->setEnabled(!prefs.enableLAN); ui->audioSystemServerCombo->setEnabled(!prefs.enableLAN); // If LAN is not enabled, disable local audio input/output @@ -2278,11 +2390,9 @@ void wfmain::loadSettings() ui->connectBtn->setEnabled(true); prefs.enableRigCtlD = settings->value("EnableRigCtlD", defPrefs.enableRigCtlD).toBool(); - ui->enableRigctldChk->setChecked(prefs.enableRigCtlD); prefs.rigCtlPort = settings->value("RigCtlPort", defPrefs.rigCtlPort).toInt(); - ui->rigctldPortTxt->setText(QString("%1").arg(prefs.rigCtlPort)); // Call the function to start rigctld if enabled. - on_enableRigctldChk_clicked(prefs.enableRigCtlD); + enableRigCtl(prefs.enableRigCtlD); prefs.tcpPort = settings->value("TcpServerPort", defPrefs.tcpPort).toInt(); ui->tcpServerPortTxt->setText(QString("%1").arg(prefs.tcpPort)); @@ -2387,6 +2497,11 @@ void wfmain::loadSettings() serverConfig.civPort = settings->value("ServerCivPort", 50002).toInt(); serverConfig.audioPort = settings->value("ServerAudioPort", 50003).toInt(); + setupui->updateServerConfigs((int)(s_enabled | + s_controlPort | + s_civPort | + s_audioPort)); + serverConfig.users.clear(); int numUsers = settings->beginReadArray("Users"); @@ -2424,6 +2539,7 @@ void wfmain::loadSettings() ui->serverCivPortText->setText(QString::number(serverConfig.civPort)); ui->serverAudioPortText->setText(QString::number(serverConfig.audioPort)); + RIGCONFIG* rigTemp = new RIGCONFIG(); rigTemp->rxAudioSetup.isinput = true; rigTemp->txAudioSetup.isinput = false; @@ -2480,6 +2596,10 @@ void wfmain::loadSettings() ui->serverAddUserBtn->setEnabled(false); } + // At this point, the users list has exactly one empty user. + setupui->updateServerConfig(s_users); + + settings->endGroup(); // Memory channels @@ -2580,6 +2700,7 @@ void wfmain::loadSettings() } settings->endArray(); settings->endGroup(); + emit haveClusterList(clusters); // CW Memory Load: settings->beginGroup("Keyer"); @@ -2734,10 +2855,372 @@ void wfmain::loadSettings() #endif + + setupui->acceptPreferencesPtr(&prefs); + setupui->updateIfPrefs((int)if_all); + setupui->updateRaPrefs((int)ra_all); + setupui->updateCtPrefs((int)ct_all); + setupui->updateClusterPrefs((int)cl_all); + setupui->updateLanPrefs((int)l_all); + + setupui->acceptUdpPreferencesPtr(&udpPrefs); + setupui->updateUdpPrefs((int)u_all); + +} + +void wfmain::extChangedIfPrefs(int items) +{ + prefIfItem pif; + if(items & (int)if_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)if_all; i = i << 1) + { + if(items & i) + { + qDebug(logSystem()) << "Updating If pref in wfmain" << (int)i; + pif = (prefIfItem)i; + extChangedIfPref(pif); + } + } +} + +void wfmain::extChangedRaPrefs(int items) +{ + prefRaItem pra; + if(items & (int)ra_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)ra_all; i = i << 1) + { + if(items & i) + { + qDebug(logSystem()) << "Updating Ra pref in wfmain" << (int)i; + pra = (prefRaItem)i; + extChangedRaPref(pra); + } + } +} + +void wfmain::extChangedCtPrefs(int items) +{ + prefCtItem pct; + if(items & (int)ct_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)ct_all; i = i << 1) + { + if(items & i) + { + qDebug(logSystem()) << "Updating Ct pref in wfmain" << (int)i; + pct = (prefCtItem)i; + extChangedCtPref(pct); + } + } +} + +void wfmain::extChangedLanPrefs(int items) +{ + prefLanItem plan; + if(items & (int)l_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)l_all; i = i << 1) + { + if(items & i) + { + qDebug(logSystem()) << "Updating Lan pref in wfmain" << (int)i; + plan = (prefLanItem)i; + extChangedLanPref(plan); + } + } +} + +void wfmain::extChangedClusterPrefs(int items) +{ + prefClusterItem pcl; + if(items & (int)cl_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)cl_all; i = i << 1) + { + if(items & i) + { + qDebug(logSystem()) << "Updating Cluster pref in wfmain" << (int)i; + pcl = (prefClusterItem)i; + extChangedClusterPref(pcl); + } + } +} + +void wfmain::extChangedUdpPrefs(int items) +{ + udpPrefsItem upi; + if(items & (int)u_all) + { + items = 0xffffffff; + } + for(int i=1; i < (int)u_all; i = i << 1) + { + if(items & i) + { + qDebug(logSystem()) << "Updating UDP preference in wfmain:" << i; + upi = (udpPrefsItem)i; + extChangedUdpPref(upi); + } + } +} + +void wfmain::extChangedIfPref(prefIfItem i) +{ + switch(i) + { + case if_useFullScreen: + changeFullScreenMode(prefs.useFullScreen); + break; + case if_useSystemTheme: + useSystemTheme(prefs.useSystemTheme); + break; + case if_drawPeaks: + // depreciated; + break; + case if_underlayMode: + underlayMode = prefs.underlayMode; + on_clearPeakBtn_clicked(); + break; + case if_underlayBufferSize: + resizePlasmaBuffer(prefs.underlayBufferSize); + spectrumPlasmaSize = prefs.underlayBufferSize; + break; + case if_wfAntiAlias: + colorMap->setAntialiased(prefs.wfAntiAlias); + break; + case if_wfInterpolate: + colorMap->setInterpolate(prefs.wfInterpolate); + break; + case if_wftheme: + // Not in settings widget + colorMap->setGradient(static_cast(prefs.wftheme)); + break; + case if_plotFloor: + // Not in settings widget + wfFloor = prefs.plotFloor; + plotFloor = prefs.plotFloor; + plot->yAxis->setRange(QCPRange(plotFloor, plotCeiling)); + colorMap->setDataRange(QCPRange(wfFloor, wfCeiling)); + break; + case if_plotCeiling: + // Not in settings widget + wfCeiling = prefs.plotCeiling; + plotCeiling = prefs.plotCeiling; + plot->yAxis->setRange(QCPRange(plotFloor, plotCeiling)); + colorMap->setDataRange(QCPRange(wfFloor, wfCeiling)); + break; + case if_stylesheetPath: + // Not in settings widget + break; + case if_wflength: + // Not in settings widget + break; + case if_confirmExit: + // Not in settings widget + break; + case if_confirmPowerOff: + // Not in settings widget + break; + case if_meter2Type: + changeMeter2Type(prefs.meter2Type); + break; + case if_clickDragTuningEnable: + // There's nothing to do here since the code + // already uses the preference variable as state. + break; + case if_currentColorPresetNumber: + // TODO..... + break; + default: + qWarning(logSystem()) << "Did not understand if pref update in wfmain for item " << (int)i; + break; + } +} + +void wfmain::extChangedRaPref(prefRaItem i) +{ + // Radio Access Prefs + switch(i) + { + case ra_radioCIVAddr: + if(prefs.radioCIVAddr == 0) { + showStatusBarText("Setting radio CI-V address to: 'auto'. Make sure CI-V Transceive is enabled on the radio."); + } else { + showStatusBarText(QString("Setting radio CI-V address to: 0x%1. Press Save Settings to retain.").arg(prefs.radioCIVAddr, 2, 16)); + } + break; + case ra_CIVisRadioModel: + break; + case ra_forceRTSasPTT: + emit setRTSforPTT(prefs.forceRTSasPTT); + break; + case ra_polling_ms: + if(prefs.polling_ms == 0) + { + // Automatic + qInfo(logSystem()) << "User set radio polling interval to automatic."; + calculateTimingParameters(); + } else { + // Manual + changePollTiming(prefs.polling_ms); + } + break; + case ra_serialPortRadio: + { + break; + } + case ra_serialPortBaud: + prefs.serialPortBaud = prefs.serialPortBaud; + serverConfig.baudRate = prefs.serialPortBaud; + showStatusBarText(QString("Changed baud rate to %1 bps. Press Save Settings to retain.").arg(prefs.serialPortBaud)); + break; + case ra_virtualSerialPort: + break; + case ra_localAFgain: + // Not handled here. + break; + case ra_audioSystem: + audioDev->setAudioType(prefs.audioSystem); + audioDev->enumerate(); + break; + default: + qWarning(logSystem()) << "Cannot update wfmain ra pref" << (int)i; + } +} + +void wfmain::extChangedCtPref(prefCtItem i) +{ + switch(i) + { + case ct_enablePTT: + break; + case ct_niceTS: + break; + case ct_automaticSidebandSwitching: + finputbtns->setAutomaticSidebandSwitching(prefs.automaticSidebandSwitching); + break; + case ct_enableUSBControllers: + enableUsbControllers(prefs.enableUSBControllers); + break; + case ct_usbSensitivity: + // No UI element for this. + break; + default: + qWarning(logGui()) << "No UI element matches setting" << (int)i; + break; + } +} + +void wfmain::extChangedLanPref(prefLanItem i) +{ + switch(i) + { + case l_enableLAN: + ui->connectBtn->setEnabled(true); // always set, not sure why. + break; + case l_enableRigCtlD: + enableRigCtl(prefs.enableRigCtlD); + break; + case l_rigCtlPort: + // no action + break; + case l_tcpPort: + // no action + break; + case l_waterfallFormat: + // no action + break; + default: + qWarning(logSystem()) << "Did not find matching preference in wfmain for LAN ui update:" << (int)i; + } +} + +void wfmain::extChangedClusterPref(prefClusterItem i) +{ + switch(i) + { + case cl_clusterUdpEnable: + emit setClusterEnableUdp(prefs.clusterUdpEnable); + break; + case cl_clusterTcpEnable: + emit setClusterEnableTcp(prefs.clusterTcpEnable); + break; + case cl_clusterUdpPort: + emit setClusterUdpPort(prefs.clusterUdpPort); + break; + case cl_clusterTcpServerName: + emit setClusterServerName(prefs.clusterTcpServerName); + break; + case cl_clusterTcpUserName: + emit setClusterUserName(prefs.clusterTcpUserName); + break; + case cl_clusterTcpPassword: + emit setClusterPassword(prefs.clusterTcpPassword); + break; + case cl_clusterTcpPort: + emit setClusterTcpPort(prefs.clusterTcpPort); + break; + case cl_clusterTimeout: + // Used? + emit setClusterTimeout(prefs.clusterTimeout); + break; + case cl_clusterSkimmerSpotsEnable: + // Used? + emit setClusterSkimmerSpots(prefs.clusterSkimmerSpotsEnable); + break; + default: + qWarning(logSystem()) << "Did not find matching preference element in wfmain for cluster preference " << (int)i; + break; + } +} + +void wfmain::extChangedUdpPref(udpPrefsItem i) +{ + switch(i) + { + case u_ipAddress: + break; + case u_controlLANPort: + break; + case u_serialLANPort: + // Not used in the UI. + break; + case u_audioLANPort: + // Not used in the UI. + break; + case u_username: + break; + case u_password: + break; + case u_clientName: + // Not used in the UI. + break; + case u_waterfallFormat: + // Not used in the UI. + break; + case u_halfDuplex: + break; + default: + qWarning(logGui()) << "Did not find matching pref element in wfmain for UDP pref item " << (int)i; + break; + } } void wfmain::serverAddUserLine(const QString& user, const QString& pass, const int& type) { + // migrated ui->serverUsersTable->blockSignals(true); ui->serverUsersTable->insertRow(ui->serverUsersTable->rowCount()); @@ -2869,7 +3352,7 @@ void wfmain::on_serverAudioPortText_textChanged(QString text) serverConfig.audioPort = text.toInt(); } -void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) +void wfmain::changedServerRXAudioInput(int value) { if (!serverConfig.rigs.isEmpty() && value>=0) @@ -2886,7 +3369,7 @@ void wfmain::on_serverRXAudioInputCombo_currentIndexChanged(int value) } -void wfmain::on_serverTXAudioOutputCombo_currentIndexChanged(int value) +void wfmain::changedServerTXAudioOutput(int value) { if (!serverConfig.rigs.isEmpty() && value>=0) @@ -3354,11 +3837,13 @@ void wfmain::shortcutF11() { this->showNormal(); onFullscreen = false; + prefs.useFullScreen = false; } else { this->showFullScreen(); onFullscreen = true; + prefs.useFullScreen = true; } - ui->fullScreenChk->setChecked(onFullscreen); + setupui->updateIfPref(if_useFullScreen); } void wfmain::shortcutF1() @@ -3368,19 +3853,17 @@ void wfmain::shortcutF1() void wfmain::shortcutF2() { - ui->tabWidget->setCurrentIndex(1); + showAndRaiseWidget(bandbtns); } void wfmain::shortcutF3() { - ui->tabWidget->setCurrentIndex(2); - ui->freqMhzLineEdit->clear(); - ui->freqMhzLineEdit->setFocus(); + showAndRaiseWidget(finputbtns); } void wfmain::shortcutF4() { - ui->tabWidget->setCurrentIndex(3); + ui->tabWidget->setCurrentIndex(1); } // Mode switch keys: @@ -3457,9 +3940,7 @@ void wfmain::shortcutControlU() void wfmain::shortcutStar() { // Jump to frequency tab from Asterisk key on keypad - ui->tabWidget->setCurrentIndex(2); - ui->freqMhzLineEdit->clear(); - ui->freqMhzLineEdit->setFocus(); + showAndRaiseWidget(finputbtns); } void wfmain::shortcutSlash() @@ -3510,7 +3991,7 @@ void wfmain::on_tuningStepCombo_currentIndexChanged(int index) quint64 wfmain::roundFrequency(quint64 frequency, unsigned int tsHz) { quint64 rounded = 0; - if(ui->tuningFloorZerosChk->isChecked()) + if(prefs.niceTS) { rounded = ((frequency % tsHz) > tsHz/2) ? frequency + tsHz - frequency%tsHz : frequency - frequency%tsHz; return rounded; @@ -3530,7 +4011,7 @@ quint64 wfmain::roundFrequencyWithStep(quint64 frequency, int steps, unsigned in frequency = frequency - std::min((quint64)(abs(steps)*tsHz), frequency); } - if(ui->tuningFloorZerosChk->isChecked()) + if(prefs.niceTS) { rounded = ((frequency % tsHz) > tsHz/2) ? frequency + tsHz - frequency%tsHz : frequency - frequency%tsHz; return rounded; @@ -3852,7 +4333,7 @@ void wfmain::showStatusBarText(QString text) ui->statusBar->showMessage(text, 5000); } -void wfmain::on_useSystemThemeChk_clicked(bool checked) +void wfmain::useSystemTheme(bool checked) { setAppTheme(!checked); prefs.useSystemTheme = checked; @@ -4004,8 +4485,10 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) { // Note: We intentionally request rigID several times // because without rigID, we can't do anything with the waterfall. + bandbtns->acceptRigCaps(rigCaps); if(haveRigCaps) { + // Note: This line makes it difficult to accept a different radio connecting. return; } else { @@ -4141,7 +4624,12 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) } else { ui->modInputData3ComboText->setVisible(false); ui->modInputData3Combo->setVisible(false); + ui->modInputCombo->addItem("None", inputNone); + modSources.append("None"); + modData.append(inputNone); } + setupui->updateModSourceList(modSources, modData); + setupui->updateDataModSourceList(modSources, modData); ui->attSelCombo->clear(); if(rigCaps.commands.contains(funcAttenuator)) @@ -4198,7 +4686,7 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) } ui->scopeBWCombo->blockSignals(false); - setBandButtons(); + //setBandButtons(); ui->tuneEnableChk->setEnabled(rigCaps.commands.contains(funcTunerStatus)); ui->tuneNowBtn->setEnabled(rigCaps.commands.contains(funcTunerStatus)); @@ -4230,16 +4718,17 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) } // Set the second meter here as I suspect we need to be connected for it to work? - for (int i = 0; i < ui->meter2selectionCombo->count(); i++) - { - if (static_cast(ui->meter2selectionCombo->itemData(i).toInt()) == prefs.meter2Type) - { - // I thought that setCurrentIndex() would call the activated() function for the combobox - // but it doesn't, so call it manually. - ui->meter2selectionCombo->setCurrentIndex(i); - on_meter2selectionCombo_activated(i); - } - } + changeMeter2Type(prefs.meter2Type); +// for (int i = 0; i < ui->meter2selectionCombo->count(); i++) +// { +// if (static_cast(ui->meter2selectionCombo->itemData(i).toInt()) == prefs.meter2Type) +// { +// // I thought that setCurrentIndex() would call the activated() function for the combobox +// // but it doesn't, so call it manually. +// //ui->meter2selectionCombo->setCurrentIndex(i); +// changeMeter2Type(i); +// } +// } } updateSizes(ui->tabWidget->currentIndex()); } @@ -5118,10 +5607,20 @@ void wfmain::receiveMode(modeInfo mode) ui->modeFilterCombo->blockSignals(false); } - currentModeInfo = mode; - - rpt->handleUpdateCurrentMainMode(currentModeInfo); - cw->handleCurrentModeUpdate(currentModeInfo.mk); + currentModeIndex = mode; + finputbtns->updateCurrentMode(currentMode); + finputbtns->updateFilterSelection(filter); + currentModeInfo.mk = (mode_kind)mode; + currentMode = (mode_kind)mode; + currentModeInfo.filter = filter; + currentModeInfo.reg = mode; + rpt->handleUpdateCurrentMainMode(currentModeInfo); + cw->handleCurrentModeUpdate(currentMode); + if (!found) + { + qWarning(logSystem()) << __func__ << "Received mode " << mode << " but could not match to any index within the modeSelectCombo. "; + return; + } if (maxPassbandHz != 0) { @@ -5165,7 +5664,7 @@ void wfmain::on_clearPeakBtn_clicked() return; } -void wfmain::on_fullScreenChk_clicked(bool checked) +void wfmain::changeFullScreenMode(bool checked) { if(checked) { @@ -5178,139 +5677,7 @@ void wfmain::on_fullScreenChk_clicked(bool checked) prefs.useFullScreen = checked; } -void wfmain::on_goFreqBtn_clicked() -{ - freqt f; - bool ok = false; - double freqDbl = 0; - int KHz = 0; - - if(ui->freqMhzLineEdit->text().contains(".")) - { - - freqDbl = ui->freqMhzLineEdit->text().toDouble(&ok); - if(ok) - { - f.Hz = freqDbl*1E6; - } - } else { - KHz = ui->freqMhzLineEdit->text().toInt(&ok); - if(ok) - { - f.Hz = KHz*1E3; - } - } - if(ok) - { - queue->add(priorityImmediate,queueItem((rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqSet),QVariant::fromValue(f),false)); - - foreach (modeInfo mi, rigCaps.modes) - { - if (mi.reg == sidebandChooser::getMode(f, currentModeInfo.mk)) - { - modeInfo m = modeInfo(mi); - m.filter = ui->modeFilterCombo->currentData().toInt(); - m.data = usingDataMode; - m.VFO=selVFO_t::activeVFO; - if((m.mk != currentModeInfo.mk) && prefs.automaticSidebandSwitching) - { - queue->add(priorityImmediate,queueItem((rigCaps.commands.contains(funcSelectedMode)?funcSelectedMode:funcModeGet),QVariant::fromValue(m),false)); - } - break; - } - } - - f.MHzDouble = (float)f.Hz / 1E6; - freq = f; - setUIFreq(); - } - - ui->freqMhzLineEdit->selectAll(); - freqTextSelected = true; - ui->tabWidget->setCurrentIndex(0); -} - -void wfmain::checkFreqSel() -{ - if(freqTextSelected) - { - freqTextSelected = false; - ui->freqMhzLineEdit->clear(); - } -} - -void wfmain::on_f0btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("0")); -} -void wfmain::on_f1btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("1")); -} - -void wfmain::on_f2btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("2")); -} -void wfmain::on_f3btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("3")); -} -void wfmain::on_f4btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("4")); -} -void wfmain::on_f5btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("5")); -} -void wfmain::on_f6btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("6")); -} -void wfmain::on_f7btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("7")); -} -void wfmain::on_f8btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("8")); -} -void wfmain::on_f9btn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append("9")); -} -void wfmain::on_fDotbtn_clicked() -{ - checkFreqSel(); - ui->freqMhzLineEdit->setText(ui->freqMhzLineEdit->text().append(".")); -} - - -void wfmain::on_fBackbtn_clicked() -{ - QString currentFreq = ui->freqMhzLineEdit->text(); - currentFreq.chop(1); - ui->freqMhzLineEdit->setText(currentFreq); -} - -void wfmain::on_fCEbtn_clicked() -{ - ui->freqMhzLineEdit->clear(); - freqTextSelected = false; -} - -void wfmain::on_spectrumMode_tCombo_currentIndexChanged(int index) +void wfmain::on_spectrumModeCombo_currentIndexChanged(int index) { spectrumMode_t smode = static_cast(ui->spectrumMode_tCombo->itemData(index).toInt()); queue->add(priorityImmediate,queueItem(funcScopeMainMode,QVariant::fromValue(smode))); @@ -5337,14 +5704,6 @@ void wfmain::setUISpectrumControlsToMode(spectrumMode_t smode) } } -void wfmain::on_fEnterBtn_clicked() -{ - // TODO: do not jump to main tab on enter, only on return - // or something. - // Maybe this should be an option in settings-> - on_goFreqBtn_clicked(); -} - void wfmain::on_scopeBWCombo_currentIndexChanged(int index) { queue->add(priorityImmediate,queueItem(funcScopeMainSpan,ui->scopeBWCombo->itemData(index))); @@ -5481,7 +5840,7 @@ void wfmain::on_freqDial_valueChanged(int value) } } -void wfmain::receiveBandStackReg(freqt freqGo, char mode, char filter, bool dataOn) +void wfmain::handleBandStackReg(freqt freqGo, char mode, char filter, bool dataOn) { // read the band stack and apply by sending out commands @@ -5509,233 +5868,54 @@ void wfmain::receiveBandStackReg(freqt freqGo, char mode, char filter, bool data queue->add(priorityHighest,(rigCaps.commands.contains(funcSelectedMode)?funcSelectedFreq:funcModeGet)); } -void wfmain::bandStackBtnClick() -{ - bandStkRegCode = ui->bandStkPopdown->currentIndex() + 1; - waitingForBandStackRtn = true; // so that when the return is parsed we jump to this frequency/mode info - queue->add(priorityImmediate,queueItem(funcBandStackReg,QVariant::fromValue(bandStackType(bandStkBand, bandStkRegCode)),false)); -} - void wfmain::setBand(int band) { queue->add(priorityImmediate,queueItem(funcBandStackReg,QVariant::fromValue(band),false)); } -void wfmain::on_band23cmbtn_clicked() -{ - bandStkBand = rigCaps.bsr[band23cm]; // 23cm - bandStackBtnClick(); -} - -void wfmain::on_band70cmbtn_clicked() -{ - bandStkBand = rigCaps.bsr[band70cm]; // 70cm - bandStackBtnClick(); -} - -void wfmain::on_band2mbtn_clicked() -{ - bandStkBand = rigCaps.bsr[band2m]; // 2m - bandStackBtnClick(); -} - -void wfmain::on_bandAirbtn_clicked() -{ - bandStkBand = rigCaps.bsr[bandAir]; // VHF Aircraft - bandStackBtnClick(); -} - -void wfmain::on_bandWFMbtn_clicked() -{ - bandStkBand = rigCaps.bsr[bandWFM]; // Broadcast FM - bandStackBtnClick(); -} - -void wfmain::on_band4mbtn_clicked() -{ - // There isn't a BSR for this one: - freqt f; - f.VFO = activeVFO; - if ((currentModeInfo.mk == modeAM) || (currentModeInfo.mk == modeFM)) - { - f.Hz = (70.260) * 1E6; - } else { - f.Hz = (70.200) * 1E6; - } - queue->add(priorityImmediate,queueItem((rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqSet),QVariant::fromValue(f),false)); - - queue->add(priorityImmediate,(rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqGet)); - ui->tabWidget->setCurrentIndex(0); -} - -void wfmain::on_band6mbtn_clicked() -{ - bandStkBand = 0x10; // 6 meters - bandStackBtnClick(); -} - -void wfmain::on_band10mbtn_clicked() -{ - bandStkBand = 0x09; // 10 meters - bandStackBtnClick(); -} - -void wfmain::on_band12mbtn_clicked() -{ - bandStkBand = 0x08; // 12 meters - bandStackBtnClick(); -} - -void wfmain::on_band15mbtn_clicked() -{ - bandStkBand = 0x07; // 15 meters - bandStackBtnClick(); -} - -void wfmain::on_band17mbtn_clicked() -{ - bandStkBand = 0x06; // 17 meters - bandStackBtnClick(); -} - -void wfmain::on_band20mbtn_clicked() -{ - bandStkBand = 0x05; // 20 meters - bandStackBtnClick(); -} - -void wfmain::on_band30mbtn_clicked() -{ - bandStkBand = 0x04; // 30 meters - bandStackBtnClick(); -} - -void wfmain::on_band40mbtn_clicked() -{ - bandStkBand = 0x03; // 40 meters - bandStackBtnClick(); -} - -void wfmain::on_band60mbtn_clicked() -{ - // This one is tricky. There isn't a band stack register on the - // 7300 for 60 meters, so we just drop to the middle of the band: - // Channel 1: 5330.5 kHz - // Channel 2: 5346.5 kHz - // Channel 3: 5357.0 kHz - // Channel 4: 5371.5 kHz - // Channel 5: 5403.5 kHz - // Really not sure what the best strategy here is, don't want to - // clutter the UI with 60M channel buttons... - freqt f; - f.Hz = (5.3305) * 1E6; - queue->add(priorityImmediate,queueItem((rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqSet),QVariant::fromValue(f),false)); - - ui->tabWidget->setCurrentIndex(0); -} - -void wfmain::on_band80mbtn_clicked() -{ - bandStkBand = 0x02; // 80 meters - bandStackBtnClick(); -} - -void wfmain::on_band160mbtn_clicked() -{ - bandStkBand = 0x01; // 160 meters - bandStackBtnClick(); -} - -void wfmain::on_band630mbtn_clicked() -{ - freqt f; - f.Hz = 475 * 1E3; - //emit setFrequency(0,f); - queue->add(priorityImmediate,queueItem((rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqSet),QVariant::fromValue(f),false)); - queue->add(priorityImmediate,(rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqGet)); - - ui->tabWidget->setCurrentIndex(0); -} - -void wfmain::on_band2200mbtn_clicked() -{ - freqt f; - f.Hz = 136 * 1E3; - //emit setFrequency(0,f); - queue->add(priorityImmediate,queueItem((rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqSet),QVariant::fromValue(f),false)); - queue->add(priorityImmediate,(rigCaps.commands.contains(funcSelectedFreq)?funcSelectedFreq:funcFreqGet)); - - ui->tabWidget->setCurrentIndex(0); -} - -void wfmain::on_bandGenbtn_clicked() -{ - // "GENE" general coverage frequency outside the ham bands - // which does probably include any 60 meter frequencies used. - bandStkBand = rigCaps.bsr[bandGen]; // GEN - bandStackBtnClick(); -} - void wfmain::on_aboutBtn_clicked() { abtBox->show(); } -void wfmain::on_fStoBtn_clicked() +void wfmain::gotoMemoryPreset(int presetNumber) { - // sequence: - // type frequency - // press Enter or Go - // change mode if desired - // type in index number 0 through 99 - // press STO - - bool ok; - int preset_number = ui->freqMhzLineEdit->text().toInt(&ok); - - if(ok && (preset_number >= 0) && (preset_number < 100)) + preset_kind temp = mem.getPreset(presetNumber); + if(!temp.isSet) { - // TODO: keep an enum around with the current mode - mem.setPreset(preset_number, freq.MHzDouble, (rigMode_t)ui->modeSelectCombo->currentData().toInt() ); - showStatusBarText( QString("Storing frequency %1 to memory location %2").arg( freq.MHzDouble ).arg(preset_number) ); - } else { - showStatusBarText(QString("Could not store preset to %1. Valid preset numbers are 0 to 99").arg(preset_number)); + qWarning(logGui()) << "Recalled Preset #" << presetNumber << "is not set."; } + setFilterVal = ui->modeFilterCombo->currentIndex()+1; // TODO, add to memory + setModeVal = temp.mode; + freqt memFreq; + mode_info m; + m.mk = temp.mode; + m.filter = ui->modeFilterCombo->currentIndex()+1; + m.reg =(unsigned char) m.mk; // fallback, works only for some modes + memFreq.Hz = temp.frequency * 1E6; + issueCmd(cmdSetFreq, memFreq); + //issueDelayedCommand(cmdSetModeFilter); // goes to setModeVal + issueCmd(cmdSetMode, m); + memFreq.MHzDouble = memFreq.Hz / 1.0E6; + freq = memFreq; + qDebug(logGui()) << "Recalling preset number " << presetNumber << " as frequency " << temp.frequency << "MHz"; + + setUIFreq(); } -void wfmain::on_fRclBtn_clicked() +void wfmain::saveMemoryPreset(int presetNumber) { - // Sequence: - // type memory location 0 through 99 - // press RCL - - // Program recalls data stored in vector at position specified - // drop contents into text box, press go button - // add delayed command for mode and data mode - - preset_kind temp; - bool ok; - QString freqString; - int preset_number = ui->freqMhzLineEdit->text().toInt(&ok); - - if(ok && (preset_number >= 0) && (preset_number < 100)) + // int, double, mode_kind + double frequency; + if(this->freq.Hz == 0) { - temp = mem.getPreset(preset_number); - // TODO: change to int hz - // TODO: store filter setting as well. - freqString = QString("%1").arg(temp.frequency); - ui->freqMhzLineEdit->setText( freqString ); - ui->goFreqBtn->click(); - setModeVal = temp.mode; - setFilterVal = ui->modeFilterCombo->currentIndex()+1; // TODO, add to memory - - //issueDelayedCommand(cmdSetModeFilter); - //issueDelayedCommand(cmdGetMode); - queue->add(priorityMedium,(rigCaps.commands.contains(funcSelectedMode)?funcSelectedMode:funcModeGet),false); + frequency = freq.MHzDouble; } else { - qInfo(logSystem()) << "Could not recall preset. Valid presets are 0 through 99."; + frequency = freq.Hz / 1.0E6; } - + mode_kind mode = currentMode; + qDebug(logGui()) << "Saving preset number " << presetNumber << " to frequency " << frequency << " MHz"; + mem.setPreset(presetNumber, frequency, mode); } void wfmain::on_rfGainSlider_valueChanged(int value) @@ -5819,7 +5999,7 @@ void wfmain::on_pttOnBtn_clicked() { // is it enabled? - if(!ui->pttEnableChk->isChecked()) + if(!prefs.enablePTT) { showStatusBarText("PTT is disabled, not sending command. Change under Settings tab."); return; @@ -5892,13 +6072,9 @@ void wfmain::receiveATUStatus(unsigned char atustatus) } } -void wfmain::on_pttEnableChk_clicked(bool checked) -{ - prefs.enablePTT = checked; -} - void wfmain::on_serialEnableBtn_clicked(bool checked) { + // migrated, can be removed entirely prefs.enableLAN = !checked; ui->serialDeviceListCombo->setEnabled(checked); @@ -5914,17 +6090,18 @@ void wfmain::on_serialEnableBtn_clicked(bool checked) ui->txLatencySlider->setEnabled(!checked); ui->rxLatencyValue->setEnabled(!checked); ui->txLatencyValue->setEnabled(!checked); - ui->audioOutputCombo->setEnabled(!checked); - ui->audioInputCombo->setEnabled(!checked); + //ui->audioOutputCombo->setEnabled(!checked); + //ui->audioInputCombo->setEnabled(!checked); ui->baudRateCombo->setEnabled(checked); ui->serialDeviceListCombo->setEnabled(checked); - ui->serverRXAudioInputCombo->setEnabled(checked); - ui->serverTXAudioOutputCombo->setEnabled(checked); + //ui->serverRXAudioInputCombo->setEnabled(checked); + //ui->serverTXAudioOutputCombo->setEnabled(checked); } void wfmain::on_lanEnableBtn_clicked(bool checked) { + // Migrated, can be removed entirely prefs.enableLAN = checked; ui->connectBtn->setEnabled(true); ui->ipAddressTxt->setEnabled(checked); @@ -5938,12 +6115,12 @@ void wfmain::on_lanEnableBtn_clicked(bool checked) ui->txLatencySlider->setEnabled(checked); ui->rxLatencyValue->setEnabled(checked); ui->txLatencyValue->setEnabled(checked); - ui->audioOutputCombo->setEnabled(checked); - ui->audioInputCombo->setEnabled(checked); + //ui->audioOutputCombo->setEnabled(checked); + //ui->audioInputCombo->setEnabled(checked); ui->baudRateCombo->setEnabled(!checked); ui->serialDeviceListCombo->setEnabled(!checked); - ui->serverRXAudioInputCombo->setEnabled(!checked); - ui->serverTXAudioOutputCombo->setEnabled(!checked); + //ui->serverRXAudioInputCombo->setEnabled(!checked); + //ui->serverTXAudioOutputCombo->setEnabled(!checked); if(checked) { showStatusBarText("After filling in values, press Save Settings."); @@ -5952,31 +6129,37 @@ void wfmain::on_lanEnableBtn_clicked(bool checked) void wfmain::on_ipAddressTxt_textChanged(QString text) { + //migrated udpPrefs.ipAddress = text; } void wfmain::on_controlPortTxt_textChanged(QString text) { + // migrated udpPrefs.controlLANPort = text.toUInt(); } void wfmain::on_usernameTxt_textChanged(QString text) { + // migrated udpPrefs.username = text; } void wfmain::on_passwordTxt_textChanged(QString text) { + // migrated udpPrefs.password = text; } void wfmain::on_audioDuplexCombo_currentIndexChanged(int value) { + // migrated udpPrefs.halfDuplex = (bool)value; } -void wfmain::on_audioOutputCombo_currentIndexChanged(int value) +void wfmain::changedAudioInput(int value) { + // TODO: Change function name, send value from setupui to here. if (value>=0) { if (prefs.audioSystem == qtAudio) { @@ -5991,7 +6174,7 @@ void wfmain::on_audioOutputCombo_currentIndexChanged(int value) qDebug(logGui()) << "Changed audio output to:" << rxSetup.name; } -void wfmain::on_audioInputCombo_currentIndexChanged(int value) +void wfmain::changedAudioOutput(int value) { if (value >=0) { if (prefs.audioSystem == qtAudio) { @@ -6035,12 +6218,6 @@ void wfmain::on_txLatencySlider_valueChanged(int value) ui->txLatencyValue->setText(QString::number(value)); } -void wfmain::on_vspCombo_currentIndexChanged(int value) -{ - Q_UNUSED(value); - prefs.virtualSerialPort = ui->vspCombo->currentText(); -} - void wfmain::on_toFixedBtn_clicked() { int currentEdge = ui->scopeEdgeCombo->currentIndex(); @@ -6157,7 +6334,7 @@ void wfmain::on_transmitBtn_clicked() if(!amTransmitting) { // Currently receiving - if(!ui->pttEnableChk->isChecked()) + if(!prefs.enablePTT) { showStatusBarText("PTT is disabled, not sending command. Change under Settings tab."); return; @@ -6249,6 +6426,22 @@ void wfmain::setRadioTimeDateSend() waitingToSetTimeDate = false; } +void wfmain::showAndRaiseWidget(QWidget *w) +{ + if(!w) + return; + + if(w->isMinimized()) + { + w->raise(); + w->activateWindow(); + return; + } + w->show(); + w->raise(); + w->activateWindow(); +} + void wfmain::changeSliderQuietly(QSlider *slider, int value) { if (slider->value() != value) { @@ -6844,13 +7037,8 @@ void wfmain::calculateTimingParameters() queue->interval(msMinTiming * 4); } - qInfo(logSystem()) << "Delay command interval timing: " << delayedCommand->interval() << "ms"; - ui->pollTimeMsSpin->blockSignals(true); - ui->pollTimeMsSpin->setValue(delayedCommand->interval()); - ui->pollTimeMsSpin->blockSignals(false); - // Normal: delayedCmdIntervalLAN_ms = delayedCommand->interval(); delayedCmdIntervalSerial_ms = delayedCommand->interval(); @@ -6977,109 +7165,6 @@ void wfmain::hideButton(QPushButton *btn) btn->setHidden(true); } -void wfmain::setBandButtons() -{ - // Turn off each button first: - hideButton(ui->band23cmbtn); - hideButton(ui->band70cmbtn); - hideButton(ui->band2mbtn); - hideButton(ui->bandAirbtn); - hideButton(ui->bandWFMbtn); - hideButton(ui->band4mbtn); - hideButton(ui->band6mbtn); - - hideButton(ui->band10mbtn); - hideButton(ui->band12mbtn); - hideButton(ui->band15mbtn); - hideButton(ui->band17mbtn); - hideButton(ui->band20mbtn); - hideButton(ui->band30mbtn); - hideButton(ui->band40mbtn); - hideButton(ui->band60mbtn); - hideButton(ui->band80mbtn); - hideButton(ui->band160mbtn); - - hideButton(ui->band630mbtn); - hideButton(ui->band2200mbtn); - hideButton(ui->bandGenbtn); - - bandType bandSel; - - //for (auto band = rigCaps.bands.begin(); band != rigCaps.bands.end(); ++band) // no worky - for(unsigned int i=0; i < rigCaps.bands.size(); i++) - { - bandSel = rigCaps.bands.at(i); - switch(bandSel.band) - { - case(band23cm): - showButton(ui->band23cmbtn); - break; - case(band70cm): - showButton(ui->band70cmbtn); - break; - case(band2m): - showButton(ui->band2mbtn); - break; - case(bandAir): - showButton(ui->bandAirbtn); - break; - case(bandWFM): - showButton(ui->bandWFMbtn); - break; - case(band4m): - showButton(ui->band4mbtn); - break; - case(band6m): - showButton(ui->band6mbtn); - break; - - case(band10m): - showButton(ui->band10mbtn); - break; - case(band12m): - showButton(ui->band12mbtn); - break; - case(band15m): - showButton(ui->band15mbtn); - break; - case(band17m): - showButton(ui->band17mbtn); - break; - case(band20m): - showButton(ui->band20mbtn); - break; - case(band30m): - showButton(ui->band30mbtn); - break; - case(band40m): - showButton(ui->band40mbtn); - break; - case(band60m): - showButton(ui->band60mbtn); - break; - case(band80m): - showButton(ui->band80mbtn); - break; - case(band160m): - showButton(ui->band160mbtn); - break; - - case(band630m): - showButton(ui->band630mbtn); - break; - case(band2200m): - showButton(ui->band2200mbtn); - break; - case(bandGen): - showButton(ui->bandGenbtn); - break; - - default: - break; - } - } -} - void wfmain::on_rigCIVManualAddrChk_clicked(bool checked) { if(checked) @@ -7124,12 +7209,6 @@ void wfmain::on_baudRateCombo_activated(int index) (void)index; } -void wfmain::on_useRTSforPTTchk_clicked(bool checked) -{ - emit setRTSforPTT(checked); - prefs.forceRTSasPTT = checked; -} - void wfmain::on_wfLengthSlider_valueChanged(int value) { prefs.wflength = (unsigned int)(value); @@ -7190,7 +7269,7 @@ funcs wfmain::meter_tToMeterCommand(meter_t m) } -void wfmain::on_meter2selectionCombo_activated(int index) +void wfmain::changeMeter2Type(meterKind m) { meter_t newMeterType; meter_t oldMeterType; @@ -7217,13 +7296,11 @@ void wfmain::on_meter2selectionCombo_activated(int index) if((newMeterType!=meterRxAudio) && (newMeterType!=meterTxMod) && (newMeterType!=meterAudio)) queue->add(priorityHighest,queueItem(newCmd,true)); } - prefs.meter2Type = newMeterType; - - (void)index; } -void wfmain::on_enableRigctldChk_clicked(bool checked) +void wfmain::enableRigCtl(bool enabled) { + // migrated to this, keep if (rigCtl != Q_NULLPTR) { rigCtl->disconnect(); @@ -7231,7 +7308,7 @@ void wfmain::on_enableRigctldChk_clicked(bool checked) rigCtl = Q_NULLPTR; } - if (checked) { + if (enabled) { // Start rigctld rigCtl = new rigCtlD(this); rigCtl->startServer(prefs.rigCtlPort); @@ -7245,34 +7322,7 @@ void wfmain::on_enableRigctldChk_clicked(bool checked) emit requestRigState(); } } - prefs.enableRigCtlD = checked; -} - -void wfmain::on_rigctldPortTxt_editingFinished() -{ - - bool okconvert = false; - unsigned int port = ui->rigctldPortTxt->text().toUInt(&okconvert); - if (okconvert) - { - prefs.rigCtlPort = port; - } -} - -void wfmain::on_tcpServerPortTxt_editingFinished() -{ - - bool okconvert = false; - unsigned int port = ui->tcpServerPortTxt->text().toUInt(&okconvert); - if (okconvert) - { - prefs.tcpPort = port; - } -} - -void wfmain::on_waterfallFormatCombo_activated(int index) -{ - prefs.waterfallFormat = index; + //prefs.enableRigCtlD = checked; } void wfmain::on_moreControlsBtn_clicked() @@ -7323,37 +7373,46 @@ void wfmain::on_radioStatusBtn_clicked() void wfmain::setAudioDevicesUI() { + // ready for cleaning qInfo() << "Looking for inputs"; - ui->audioInputCombo->blockSignals(true); - ui->audioInputCombo->clear(); - ui->audioInputCombo->addItems(audioDev->getInputs()); - ui->audioInputCombo->setCurrentIndex(-1); - ui->audioInputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsIn() + 30)); - ui->audioInputCombo->blockSignals(false); - ui->audioInputCombo->setCurrentIndex(audioDev->findInput("Client", txSetup.name)); + // got these: +// ui->audioInputCombo->blockSignals(true); +// ui->audioInputCombo->clear(); +// ui->audioInputCombo->addItems(audioDev->getInputs()); +// ui->audioInputCombo->setCurrentIndex(-1); +// ui->audioInputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsIn() + 30)); +// ui->audioInputCombo->blockSignals(false); +// ui->audioInputCombo->setCurrentIndex(audioDev->findInput("Client", txSetup.name)); + + setupui->updateAudioInputs(audioDev->getInputs(), audioDev->findInput("Client", txSetup.name), audioDev->getNumCharsIn()); qInfo() << "Looking for outputs"; - ui->audioOutputCombo->blockSignals(true); - ui->audioOutputCombo->clear(); - ui->audioOutputCombo->addItems(audioDev->getOutputs()); - ui->audioOutputCombo->setCurrentIndex(-1); - ui->audioOutputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsOut() + 30)); - ui->audioOutputCombo->blockSignals(false); - ui->audioOutputCombo->setCurrentIndex(audioDev->findOutput("Client", rxSetup.name)); + // done: +// ui->audioOutputCombo->blockSignals(true); +// ui->audioOutputCombo->clear(); +// ui->audioOutputCombo->addItems(audioDev->getOutputs()); +// ui->audioOutputCombo->setCurrentIndex(-1); +// ui->audioOutputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsOut() + 30)); +// ui->audioOutputCombo->blockSignals(false); +// ui->audioOutputCombo->setCurrentIndex(audioDev->findOutput("Client", rxSetup.name)); - ui->serverTXAudioOutputCombo->blockSignals(true); - ui->serverTXAudioOutputCombo->clear(); - ui->serverTXAudioOutputCombo->addItems(audioDev->getOutputs()); - ui->serverTXAudioOutputCombo->setCurrentIndex(-1); - ui->serverTXAudioOutputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsOut() + 30)); - ui->serverTXAudioOutputCombo->blockSignals(false); + setupui->updateAudioOutputs(audioDev->getOutputs(), audioDev->findOutput("Client", rxSetup.name), audioDev->getNumCharsOut()); - ui->serverRXAudioInputCombo->blockSignals(true); - ui->serverRXAudioInputCombo->clear(); - ui->serverRXAudioInputCombo->addItems(audioDev->getInputs()); - ui->serverRXAudioInputCombo->setCurrentIndex(-1); - ui->serverRXAudioInputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsIn()+30)); - ui->serverRXAudioInputCombo->blockSignals(false); +// ui->serverTXAudioOutputCombo->blockSignals(true); +// ui->serverTXAudioOutputCombo->clear(); +// ui->serverTXAudioOutputCombo->addItems(audioDev->getOutputs()); +// ui->serverTXAudioOutputCombo->setCurrentIndex(-1); +// ui->serverTXAudioOutputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsOut() + 30)); +// ui->serverTXAudioOutputCombo->blockSignals(false); + int serverOutputIndex = -1; + +// ui->serverRXAudioInputCombo->blockSignals(true); +// ui->serverRXAudioInputCombo->clear(); +// ui->serverRXAudioInputCombo->addItems(audioDev->getInputs()); +// ui->serverRXAudioInputCombo->setCurrentIndex(-1); +// ui->serverRXAudioInputCombo->setStyleSheet(QString("QComboBox QAbstractItemView {min-width: %1px;}").arg(audioDev->getNumCharsIn()+30)); +// ui->serverRXAudioInputCombo->blockSignals(false); + int serverInputIndex = -1; rxSetup.type = prefs.audioSystem; txSetup.type = prefs.audioSystem; @@ -7363,16 +7422,22 @@ void wfmain::setAudioDevicesUI() serverConfig.rigs.first()->rxAudioSetup.type = prefs.audioSystem; serverConfig.rigs.first()->txAudioSetup.type = prefs.audioSystem; - ui->serverRXAudioInputCombo->setCurrentIndex(audioDev->findInput("Server", serverConfig.rigs.first()->rxAudioSetup.name)); - ui->serverTXAudioOutputCombo->setCurrentIndex(audioDev->findOutput("Server", serverConfig.rigs.first()->txAudioSetup.name)); + //ui->serverRXAudioInputCombo->setCurrentIndex(audioDev->findInput("Server", serverConfig.rigs.first()->rxAudioSetup.name)); + serverOutputIndex = audioDev->findOutput("Server", serverConfig.rigs.first()->txAudioSetup.name); + //ui->serverTXAudioOutputCombo->setCurrentIndex(audioDev->findOutput("Server", serverConfig.rigs.first()->txAudioSetup.name)); + serverInputIndex = audioDev->findOutput("Server", serverConfig.rigs.first()->txAudioSetup.name); } + setupui->updateServerRXAudioInputs(audioDev->getInputs(), serverInputIndex, audioDev->getNumCharsIn()); + setupui->updateServerTXAudioOutputs(audioDev->getOutputs(), serverOutputIndex, audioDev->getNumCharsOut()); + qDebug(logSystem()) << "Audio devices done."; } void wfmain::on_audioSystemCombo_currentIndexChanged(int value) { + // migrated prefs.audioSystem = static_cast(value); audioDev->setAudioType(prefs.audioSystem); audioDev->enumerate(); @@ -7383,6 +7448,7 @@ void wfmain::on_audioSystemCombo_currentIndexChanged(int value) void wfmain::on_audioSystemServerCombo_currentIndexChanged(int value) { + // migrated prefs.audioSystem = static_cast(value); audioDev->setAudioType(prefs.audioSystem); audioDev->enumerate(); @@ -7456,7 +7522,7 @@ void wfmain::clearPlasmaBuffer() void wfmain::on_underlayNone_toggled(bool checked) { - ui->underlayBufferSlider->setDisabled(checked); + //ui->underlayBufferSlider->setDisabled(checked); if(checked) { underlayMode = underlayNone; @@ -7467,7 +7533,7 @@ void wfmain::on_underlayNone_toggled(bool checked) void wfmain::on_underlayPeakHold_toggled(bool checked) { - ui->underlayBufferSlider->setDisabled(checked); + //ui->underlayBufferSlider->setDisabled(checked); if(checked) { underlayMode = underlayPeakHold; @@ -7478,7 +7544,7 @@ void wfmain::on_underlayPeakHold_toggled(bool checked) void wfmain::on_underlayPeakBuffer_toggled(bool checked) { - ui->underlayBufferSlider->setDisabled(!checked); + //ui->underlayBufferSlider->setDisabled(!checked); if(checked) { underlayMode = underlayPeakBuffer; @@ -7488,7 +7554,7 @@ void wfmain::on_underlayPeakBuffer_toggled(bool checked) void wfmain::on_underlayAverageBuffer_toggled(bool checked) { - ui->underlayBufferSlider->setDisabled(!checked); + //ui->underlayBufferSlider->setDisabled(!checked); if(checked) { underlayMode = underlayAverageBuffer; @@ -7508,6 +7574,12 @@ void wfmain::on_debugBtn_clicked() + //showAndRaiseWidget(setupui); + //setupui->updateIfPrefs((int)if_all); + //setupui->updateRaPrefs((int)ra_all); + //setupui->updateCtPrefs((int)ct_all); + //setupui->updateClusterPrefs((int)cl_all); + //setupui->updateUdpPrefs((int)u_all); } // ---------- color helper functions: ---------- // @@ -8357,6 +8429,7 @@ void wfmain::receiveClusterOutput(QString text) { ui->clusterOutputTextEdit->moveCursor(QTextCursor::End); ui->clusterOutputTextEdit->insertPlainText(text); ui->clusterOutputTextEdit->moveCursor(QTextCursor::End); + setupui->insertClusterOutputText(text); } void wfmain::on_clusterUdpEnable_clicked(bool enable) @@ -8471,7 +8544,6 @@ void wfmain::on_clusterPasswordLineEdit_editingFinished() clusters[index].password = ui->clusterPasswordLineEdit->text(); emit setClusterPassword(clusters[index].password); } - } void wfmain::on_clusterTimeoutLineEdit_editingFinished() @@ -8573,7 +8645,7 @@ void wfmain::receiveSpots(QList spots) void wfmain::on_clusterPopOutBtn_clicked() { - + // can be removed now if (settingsTabisAttached) { settingsTab = ui->tabWidget->currentWidget(); @@ -8601,16 +8673,18 @@ void wfmain::on_clusterPopOutBtn_clicked() void wfmain::on_clusterSkimmerSpotsEnable_clicked(bool enable) { + // migrated prefs.clusterSkimmerSpotsEnable = enable; emit setClusterSkimmerSpots(enable); } void wfmain::on_clickDragTuningEnableChk_clicked(bool checked) { + // migrated prefs.clickDragTuningEnable = checked; } -void wfmain::on_enableUsbChk_clicked(bool checked) +void wfmain::enableUsbControllers(bool enabled) { prefs.enableUSBControllers = checked; ui->usbControllerBtn->setEnabled(checked); @@ -8650,6 +8724,7 @@ void wfmain::on_usbControllerBtn_clicked() void wfmain::on_usbControllersResetBtn_clicked() { + // TODO int ret = QMessageBox::warning(this, tr("wfview"), tr("Are you sure you wish to reset the USB controllers?"), QMessageBox::Ok | QMessageBox::Cancel, @@ -8703,17 +8778,11 @@ void wfmain::changePollTiming(int timing_ms, bool setUI) qInfo(logSystem()) << "User changed radio polling interval to " << timing_ms << "ms."; showStatusBarText("User changed radio polling interval to " + QString("%1").arg(timing_ms) + "ms."); prefs.polling_ms = timing_ms; - if(setUI) - { - ui->pollTimeMsSpin->blockSignals(true); - ui->pollTimeMsSpin->setValue(timing_ms); - ui->pollTimeMsSpin->blockSignals(false); - } + (void)setUI; } void wfmain::connectionHandler(bool connect) { - if (!connect) { emit sendCloseComm(); ui->connectBtn->setText("Connect to Radio"); diff --git a/wfmain.h b/wfmain.h index 30f009e..91289e9 100644 --- a/wfmain.h +++ b/wfmain.h @@ -38,6 +38,9 @@ #include "satellitesetup.h" #include "transceiveradjustments.h" #include "cwsender.h" +#include "bandbuttons.h" +#include "frequencyinputwidget.h" +#include "settingswidget.h" #include "udpserver.h" #include "qledlabel.h" #include "rigctld.h" @@ -305,6 +308,22 @@ signals: void haveMemory(memoryType mem); private slots: + // Triggered from external preference changes: + void extChangedIfPrefs(int items); + void extChangedRaPrefs(int items); + void extChangedCtPrefs(int items); + void extChangedLanPrefs(int items); + void extChangedClusterPrefs(int items); + void extChangedUdpPrefs(int items); + + void extChangedIfPref(prefIfItem i); + void extChangedRaPref(prefRaItem i); + void extChangedCtPref(prefCtItem i); + void extChangedLanPref(prefLanItem i); + void extChangedClusterPref(prefClusterItem i); + void extChangedUdpPref(udpPrefsItem i); + + void receiveValue(cacheItem val); void setAudioDevicesUI(); void updateSizes(int tabIndex); @@ -355,8 +374,8 @@ private slots: void receivespectrumMode_t(spectrumMode_t spectMode); void receiveSpectrumSpan(freqt freqspan, bool isSub); void receivePTTstatus(bool pttOn); - void receiveDataModeStatus(unsigned char data, unsigned char filter); - void receiveBandStackReg(freqt f, char mode, char filter, bool dataOn); // freq, mode, (filter,) datamode + void receiveDataModeStatus(bool dataOn); + void handleBandStackReg(freqt f, char mode, char filter, bool dataOn); // freq, mode, (filter,) datamode void receiveRITStatus(bool ritEnabled); void receiveRITValue(int ritValHz); void receiveModInput(rigInput input, unsigned char data); @@ -435,84 +454,21 @@ private slots: void buttonControl(const COMMAND* cmd); - - // void on_getFreqBtn_clicked(); - - // void on_getModeBtn_clicked(); - - // void on_debugBtn_clicked(); - void on_clearPeakBtn_clicked(); - void on_fullScreenChk_clicked(bool checked); + void changeFullScreenMode(bool checked); - void on_goFreqBtn_clicked(); - - void on_f0btn_clicked(); - void on_f1btn_clicked(); - void on_f2btn_clicked(); - void on_f3btn_clicked(); - void on_f4btn_clicked(); - void on_f5btn_clicked(); - void on_f6btn_clicked(); - void on_f7btn_clicked(); - void on_f8btn_clicked(); - void on_f9btn_clicked(); - void on_fDotbtn_clicked(); - - - - void on_fBackbtn_clicked(); - - void on_fCEbtn_clicked(); - - void on_fEnterBtn_clicked(); void on_usbControllerBtn_clicked(); void on_usbControllersResetBtn_clicked(); - void on_enableUsbChk_clicked(bool checked); - void on_scopeBWCombo_currentIndexChanged(int index); - void on_scopeEdgeCombo_currentIndexChanged(int index); - void on_modeSelectCombo_activated(int index); - void on_freqDial_valueChanged(int value); - - void on_band6mbtn_clicked(); - - void on_band10mbtn_clicked(); - - void on_band12mbtn_clicked(); - - void on_band15mbtn_clicked(); - - void on_band17mbtn_clicked(); - - void on_band20mbtn_clicked(); - - void on_band30mbtn_clicked(); - - void on_band40mbtn_clicked(); - - void on_band60mbtn_clicked(); - - void on_band80mbtn_clicked(); - - void on_band160mbtn_clicked(); - - void on_bandGenbtn_clicked(); - void on_aboutBtn_clicked(); - void on_fStoBtn_clicked(); - - void on_fRclBtn_clicked(); - void on_rfGainSlider_valueChanged(int value); - void on_afGainSlider_valueChanged(int value); void on_monitorSlider_valueChanged(int value); @@ -520,75 +476,40 @@ private slots: void on_monitorCheck_clicked(bool checked); void on_tuneNowBtn_clicked(); - void on_tuneEnableChk_clicked(bool checked); - void on_exitBtn_clicked(); - void on_pttOnBtn_clicked(); - void on_pttOffBtn_clicked(); - void on_saveSettingsBtn_clicked(); - void on_debugBtn_clicked(); - - void on_pttEnableChk_clicked(bool checked); - void on_lanEnableBtn_clicked(bool checked); - void on_ipAddressTxt_textChanged(QString text); - void on_controlPortTxt_textChanged(QString text); - void on_usernameTxt_textChanged(QString text); - void on_passwordTxt_textChanged(QString text); - void on_audioDuplexCombo_currentIndexChanged(int value); - - void on_audioOutputCombo_currentIndexChanged(int value); - - void on_audioInputCombo_currentIndexChanged(int value); - + void changedAudioInput(int value); + void changedAudioOutput(int value); void on_toFixedBtn_clicked(); - void on_connectBtn_clicked(); - void on_rxLatencySlider_valueChanged(int value); - void on_txLatencySlider_valueChanged(int value); - void on_audioRXCodecCombo_currentIndexChanged(int value); - void on_audioTXCodecCombo_currentIndexChanged(int value); - void on_audioSampleRateCombo_currentIndexChanged(int value); - - void on_vspCombo_currentIndexChanged(int value); - - void on_scopeEnableWFBtn_stateChanged(int state); - + void on_scopeEnableWFBtn_clicked(bool checked); void on_sqlSlider_valueChanged(int value); - void on_modeFilterCombo_activated(int index); void on_datamodeCombo_activated(int index); void on_transmitBtn_clicked(); - void on_adjRefBtn_clicked(); - void on_satOpsBtn_clicked(); - void on_txPowerSlider_valueChanged(int value); - void on_micGainSlider_valueChanged(int value); - void on_scopeRefLevelSlider_valueChanged(int value); - - void on_useSystemThemeChk_clicked(bool checked); - + void useSystemTheme(bool checked); void on_modInputCombo_activated(int index); void on_modInputData1Combo_activated(int index); @@ -600,69 +521,26 @@ private slots: void on_spectrumMode_tCombo_currentIndexChanged(int index); void on_serialEnableBtn_clicked(bool checked); - void on_tuningStepCombo_currentIndexChanged(int index); - void on_serialDeviceListCombo_textActivated(const QString &arg1); - void on_rptSetupBtn_clicked(); - void on_attSelCombo_activated(int index); - void on_preampSelCombo_activated(int index); - void on_antennaSelCombo_activated(int index); - void on_rxAntennaCheck_clicked(bool value); - void on_wfthemeCombo_activated(int index); - void on_rigPowerOnBtn_clicked(); - void on_rigPowerOffBtn_clicked(); - void on_ritTuneDial_valueChanged(int value); - void on_ritEnableChk_clicked(bool checked); - - void on_band23cmbtn_clicked(); - - void on_band70cmbtn_clicked(); - - void on_band2mbtn_clicked(); - - void on_band4mbtn_clicked(); - - void on_band630mbtn_clicked(); - - void on_band2200mbtn_clicked(); - - void on_bandAirbtn_clicked(); - - void on_bandWFMbtn_clicked(); - void on_rigCIVManualAddrChk_clicked(bool checked); - void on_rigCIVaddrHexLine_editingFinished(); - void on_baudRateCombo_activated(int); - void on_wfLengthSlider_valueChanged(int value); - void on_wfAntiAliasChk_clicked(bool checked); - void on_wfInterpolateChk_clicked(bool checked); - - void on_meter2selectionCombo_activated(int index); - - void on_waterfallFormatCombo_activated(int index); - - void on_enableRigctldChk_clicked(bool checked); - - void on_rigctldPortTxt_editingFinished(); - - void on_tcpServerPortTxt_editingFinished(); - + void changeMeter2Type(meterKind m); + void enableRigCtl(bool enabled); void on_moreControlsBtn_clicked(); void on_memoriesBtn_clicked(); @@ -672,135 +550,73 @@ private slots: void receiveStateInfo(rigstate* state); void on_settingsList_currentRowChanged(int currentRow); - void on_setClockBtn_clicked(); - void on_serverEnableCheckbox_clicked(bool checked); void on_serverControlPortText_textChanged(QString text); void on_serverCivPortText_textChanged(QString text); void on_serverAudioPortText_textChanged(QString text); - void on_serverTXAudioOutputCombo_currentIndexChanged(int value); - void on_serverRXAudioInputCombo_currentIndexChanged(int value); + void changedServerTXAudioOutput(int value); + void changedServerRXAudioInput(int value); void onServerUserFieldChanged(); - void on_serverAddUserBtn_clicked(); - - void on_useRTSforPTTchk_clicked(bool checked); - void on_radioStatusBtn_clicked(); - void on_audioSystemCombo_currentIndexChanged(int value); - void on_topLevelSlider_valueChanged(int value); - void on_botLevelSlider_valueChanged(int value); - void on_underlayBufferSlider_valueChanged(int value); - void on_underlayNone_toggled(bool checked); - void on_underlayPeakHold_toggled(bool checked); - void on_underlayPeakBuffer_toggled(bool checked); - void on_underlayAverageBuffer_toggled(bool checked); void on_colorSetBtnGrid_clicked(); - void on_colorSetBtnPlotBackground_clicked(); - void on_colorSetBtnText_clicked(); - void on_colorSetBtnSpecLine_clicked(); - void on_colorSetBtnSpecFill_clicked(); - void on_colorEditPlotBackground_editingFinished(); - void on_colorPopOutBtn_clicked(); - void on_colorPresetCombo_currentIndexChanged(int index); - void on_colorEditSpecLine_editingFinished(); - void on_colorEditGrid_editingFinished(); - void on_colorEditText_editingFinished(); - void on_colorEditSpecFill_editingFinished(); - void on_colorSetBtnAxis_clicked(); - void on_colorEditAxis_editingFinished(); - void on_colorSetBtnUnderlayLine_clicked(); - void on_colorEditUnderlayLine_editingFinished(); - void on_colorSetBtnUnderlayFill_clicked(); - void on_colorEditUnderlayFill_editingFinished(); - void on_colorSetBtnwfBackground_clicked(); - void on_colorEditWfBackground_editingFinished(); - void on_colorSetBtnWfGrid_clicked(); - void on_colorEditWfGrid_editingFinished(); - void on_colorSetBtnWfAxis_clicked(); - void on_colorEditWfAxis_editingFinished(); - void on_colorSetBtnWfText_clicked(); - void on_colorEditWfText_editingFinished(); - void on_colorSetBtnTuningLine_clicked(); - void on_colorEditTuningLine_editingFinished(); - void on_colorSetBtnPassband_clicked(); - void on_colorEditPassband_editingFinished(); - void on_colorSetBtnPBT_clicked(); - void on_colorEditPBT_editingFinished(); - void on_colorSetBtnMeterLevel_clicked(); - void on_colorEditMeterLevel_editingFinished(); - void on_colorSetBtnMeterAvg_clicked(); - void on_colorEditMeterAvg_editingFinished(); - void on_colorSetBtnMeterScale_clicked(); - void on_colorEditMeterScale_editingFinished(); - void on_colorSetBtnMeterText_clicked(); - void on_colorEditMeterText_editingFinished(); - void on_colorSetBtnClusterSpots_clicked(); - void on_colorEditClusterSpots_editingFinished(); - void on_colorRenamePresetBtn_clicked(); - void on_colorRevertPresetBtn_clicked(); - void on_colorSetBtnMeterPeakLevel_clicked(); - void on_colorEditMeterPeakLevel_editingFinished(); - void on_colorSetBtnMeterPeakScale_clicked(); - void on_colorEditMeterPeakScale_editingFinished(); - void on_colorSavePresetBtn_clicked(); void on_showLogBtn_clicked(); @@ -826,16 +642,14 @@ private slots: void receiveClusterOutput(QString text); void receiveSpots(QList spots); - void on_autoPollBtn_clicked(bool checked); - - void on_manualPollBtn_clicked(bool checked); - - void on_pollTimeMsSpin_valueChanged(int arg1); - - void on_autoSSBchk_clicked(bool checked); - void on_cwButton_clicked(); + void on_showBandsBtn_clicked(); + + void on_showFreqBtn_clicked(); + + void on_showSettingsBtn_clicked(); + void on_rigCreatorBtn_clicked(); private: @@ -847,9 +661,9 @@ private: QSettings *settings=Q_NULLPTR; void loadSettings(); void saveSettings(); + void connectSettingsWidget(); void createSettingsListItems(); - void connectSettingsList(); void initLogging(); QTimer logCheckingTimer; @@ -870,7 +684,6 @@ private: void computePlasma(); void showHideSpectrum(bool show); void getInitialRigState(); - void setBandButtons(); void showButton(QPushButton *btn); void hideButton(QPushButton *btn); @@ -995,8 +808,7 @@ private: bool onFullscreen; bool freqTextSelected; - void checkFreqSel(); - void setUISpectrumControlsToMode(spectrumMode_t smode); + void setUISpectrumControlsToMode(spectrumMode smode); double oldLowerFreq; double oldUpperFreq; @@ -1025,6 +837,8 @@ private: datekind datesetpoint; freqMemory mem; + void gotoMemoryPreset(int presetNumber); + void saveMemoryPreset(int presetNumber); colorPrefsType colorPreset[numColorPresetsTotal]; @@ -1080,6 +894,7 @@ private: void changeTxBtn(); void changeSliderQuietly(QSlider *slider, int value); + void showAndRaiseWidget(QWidget *w); void statusFromSliderPercent(QString name, int percentValue); void statusFromSliderRaw(QString name, int rawValue); @@ -1130,6 +945,9 @@ private: selectRadio *selRad = Q_NULLPTR; loggingWindow *logWindow = Q_NULLPTR; rigCreator *creator = Q_NULLPTR; + bandbuttons* bandbtns; + frequencyinputwidget* finputbtns; + settingswidget* setupui; udpServer* udp = Q_NULLPTR; rigCtlD* rigCtl = Q_NULLPTR; diff --git a/wfmain.ui b/wfmain.ui index 60d08f9..c606c71 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -1653,985 +1653,6 @@ - - - Band - - - - - - Band - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 2200m - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 630m - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 160m - - - L - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 80m - - - 8 - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 60m - - - S - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 40m - - - 4 - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 30m - - - 3 - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 20m - - - 2 - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 17m - - - 7 - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 15m - - - 5 - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 12m - - - T - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 10m - - - 1 - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 6m - - - 6 - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 4m - - - $ - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 2m - - - V - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 70cm - - - U - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - 23cm - - - - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - WFM - - - W - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - Air - - - A - - - - - - - - 0 - 0 - - - - - 16777215 - 128 - - - - Gen - - - G - - - - - - - - - - - - - 0 - 0 - - - - Segment - - - - - - &Last Used - - - - 16 - 16 - - - - true - - - - - - - Band Stack Selection: - - - - - - - - 1 - Latest Used - - - - - 2 - Older - - - - - 3 - Oldest Used - - - - - - - - Voice - - - - - - - Data - - - - - - - &CW - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Frequency - - - - - - - - Frequency: - - - - - - - - DejaVu Sans Mono - 14 - true - - - - - - - - Go - - - Return - - - true - - - - - - - - - Entry - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 5 - - - 5 - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - <html><head/><body><p>To recall a preset memory:</p><p>1. Type in the preset number (0 through 99)</p><p>2. Press RCL (or use hotkey &quot;R&quot;)</p></body></html> - - - &RCL - - - R - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 6 - - - 6 - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 3 - - - 3 - - - false - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - &CE - - - C - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 4 - - - 4 - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - <html><head/><body><p>To store a preset:</p><p>1. Set the desired frequency and mode per normal methods</p><p>2. Type the index to to store to (0 through 99)</p><p>3. Press STO (or use hotkey &quot;S&quot;)</p></body></html> - - - &STO - - - S - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 9 - - - 9 - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - Back - - - Backspace - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - Enter - - - Enter - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - . - - - . - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 1 - - - 1 - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 2 - - - 2 - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 7 - - - 7 - - - - - - - - 0 - 0 - - - - - 30 - 30 - - - - 8 - - - 8 - - - - - - - - Settings @@ -2664,7 +1685,7 @@ - 2 + 3 @@ -2880,16 +1901,6 @@ Please use the "Radio Server" page to select server audio - - - - <html><head/><body><p>This feature is for older radios that respond best to an RTS serial port signal than a PTT command.</p><p><br/>For radios lacking PTT commands, this is automatic and transparent, but for radios which have a PTT command, you can check this box to override and force the PTT to be done using RTS. Do not check this box unless you really need this and have an appropriate adapter with RTS connected to the PTT line of the transceiver. </p></body></html> - - - Send RTS for PTT - - - @@ -3296,19 +2307,6 @@ Please use the "Radio Server" page to select server audio - - - - - 200 - 16777215 - - - - Audio Output Selector - - - @@ -3316,19 +2314,6 @@ Please use the "Radio Server" page to select server audio - - - - - 200 - 16777215 - - - - Audio Input Selector - - - @@ -3398,22 +2383,6 @@ Please use the "Radio Server" page to select server audio - - - - When using SSB, automatically switch to the standard sideband for a given band. - - - Auto SSB Switching - - - When using SSB, automatically switch to the standard sideband for a given band. - - - Auto SSB - - - @@ -3445,40 +2414,6 @@ Please use the "Radio Server" page to select server audio - - - - Enables interpolation between pixels. Note that this will increase CPU usage. - - - Interpolate Waterfall - - - true - - - - - - - Anti-Alias Waterfall - - - - - - - Use System Theme - - - - - - - Show full screen - - - @@ -3494,138 +2429,8 @@ Please use the "Radio Server" page to select server audio - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Underlay Mode - - - - - - - No underlay graphics - - - None - - - true - - - underlayButtonGroup - - - - - - - Indefinite peak hold - - - Peak Hold - - - underlayButtonGroup - - - - - - - Peak value within the buffer - - - Peak - - - underlayButtonGroup - - - - - - - Average value within the buffer - - - Average - - - underlayButtonGroup - - - - - - - Underlay Buffer Size: - - - - - - - - 100 - 16777215 - - - - Size of buffer for spectrum data. Shorter values are more responsive. - - - 8 - - - 128 - - - 64 - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Enable PTT Controls - - - @@ -3642,65 +2447,6 @@ Please use the "Radio Server" page to select server audio - - - - Secondary Meter Selection: - - - - - - - - - - wfview will automatically calculate command polling. Recommended. - - - AutoPolling - - - true - - - pollingButtonGroup - - - - - - - Manual (user-defined) command polling - - - Manual Polling Inteval: - - - pollingButtonGroup - - - - - - - Sets the polling interval, in ms. Automatic polling is recommended. Serial port and USB port radios should not poll quicker than about 75ms. - - - 1 - - - 250 - - - - - - - ms - - - @@ -3889,8 +2635,8 @@ Please use the "Radio Server" page to select server audio 0 0 - 579 - 254 + 453 + 235 @@ -5036,22 +3782,6 @@ Please use the "Radio Server" page to select server audio - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - @@ -5059,22 +3789,6 @@ Please use the "Radio Server" page to select server audio - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - @@ -5262,16 +3976,6 @@ Please use the "Radio Server" page to select server audio 0 - - - - Qt::LeftToRight - - - Enable RigCtld - - - @@ -5295,22 +3999,6 @@ Please use the "Radio Server" page to select server audio - - - - - 75 - 0 - - - - - 75 - 16777215 - - - - @@ -5335,28 +4023,6 @@ Please use the "Radio Server" page to select server audio - - - - - 250 - 0 - - - - - 250 - 16777215 - - - - <html><head/><body><p>Use this to define a virtual serial port. </p><p><br/></p><p>On Windows, the virtual serial port can be used to connect to a serial port loopback device, through which other programs can connect to the radio. </p><p><br/></p><p>On Linux and macOS, the port defined here is a pseudo-terminal device, which may be connected to directly by any program designed for a serial connection. </p></body></html> - - - Virtual Serial Port Selector - - - @@ -5468,13 +4134,6 @@ Please use the "Radio Server" page to select server audio - - - - Enable USB Controllers - - - @@ -5892,6 +4551,13 @@ Please use the "Radio Server" page to select server audio + + + + Settings + + + @@ -5913,6 +4579,20 @@ Please use the "Radio Server" page to select server audio + + + + Bands + + + + + + + Frequency + + + @@ -5968,14 +4648,20 @@ Please use the "Radio Server" page to select server audio 0 0 - 1063 - 22 + 1042 + 20 + + QLedLabel + QWidget +
qledlabel.h
+ 1 +
QCustomPlot 1 @@ -5986,18 +4672,10 @@ Please use the "Radio Server" page to select server audio
meter.h
1
- - QLedLabel - QWidget -
qledlabel.h
- 1 -
- - diff --git a/wfview.pro b/wfview.pro index 662dd09..d048f5e 100644 --- a/wfview.pro +++ b/wfview.pro @@ -230,11 +230,14 @@ win32:INCLUDEPATH += ../qcustomplot INCLUDEPATH += resampler SOURCES += main.cpp\ + bandbuttons.cpp \ cachingqueue.cpp \ cwsender.cpp \ + frequencyinputwidget.cpp \ cwsidetone.cpp \ debugwindow.cpp \ loggingwindow.cpp \ + settingswidget.cpp \ memories.cpp \ rigcreator.cpp \ tablewidget.cpp \ @@ -272,10 +275,12 @@ SOURCES += main.cpp\ audiodevices.cpp HEADERS += wfmain.h \ + bandbuttons.h \ cachingqueue.h \ colorprefs.h \ commhandler.h \ cwsender.h \ + frequencyinputwidget.h \ cwsidetone.h \ debugwindow.h \ loggingwindow.h \ @@ -286,6 +291,7 @@ HEADERS += wfmain.h \ freqmemory.h \ rigcreator.h \ rigidentities.h \ + settingswidget.h \ sidebandchooser.h \ tablewidget.h \ udpbase.h \ @@ -325,8 +331,10 @@ HEADERS += wfmain.h \ audiodevices.h FORMS += wfmain.ui \ + bandbuttons.ui \ calibrationwindow.ui \ cwsender.ui \ + frequencyinputwidget.ui \ debugwindow.ui \ loggingwindow.ui \ memories.ui \ @@ -334,6 +342,7 @@ FORMS += wfmain.ui \ satellitesetup.ui \ selectradio.ui \ repeatersetup.ui \ + settingswidget.ui \ transceiveradjustments.ui \ controllersetup.ui \ aboutbox.ui