diff --git a/colorprefs.h b/colorprefs.h index f736520..b0ef591 100644 --- a/colorprefs.h +++ b/colorprefs.h @@ -4,6 +4,8 @@ #include #include +#define numColorPresetsTotal (5) + struct colorPrefsType{ int presetNum = -1; QString *presetName = Q_NULLPTR; @@ -32,6 +34,7 @@ struct colorPrefsType{ QColor meterAverage; QColor meterPeakLevel; QColor meterPeakScale; + QColor meterScale; QColor meterLowerLine; QColor meterLowText; diff --git a/prefs.h b/prefs.h index 4fac4bb..a8dff5e 100644 --- a/prefs.h +++ b/prefs.h @@ -4,6 +4,7 @@ #include #include #include +#include "audioconverter.h" #include "rigidentities.h" #include "wfviewtypes.h" @@ -25,7 +26,8 @@ enum prefIfItem { if_meter2Type = 1 << 14, if_clickDragTuningEnable = 1 << 15, if_currentColorPresetNumber = 1 << 16, - if_all = 1 << 17 + if_rigCreatorEnable = 1 << 17, + if_all = 1 << 18 }; enum prefColItem { @@ -69,12 +71,13 @@ enum prefRaItem { 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 + ra_serialEnabled = 1 << 4, + ra_serialPortRadio = 1 << 5, + ra_serialPortBaud = 1 << 6, + ra_virtualSerialPort = 1 << 7, + ra_localAFgain = 1 << 8, + ra_audioSystem = 1 << 9, + ra_all = 1 << 10 }; enum prefCtItem { @@ -109,6 +112,26 @@ enum prefClusterItem { cl_all = 1 << 9 }; +enum udpPrefsItem { + u_enabled = 1 << 0, + u_ipAddress = 1 << 1, + u_controlLANPort = 1 << 2, + u_serialLANPort = 1 << 3, + u_audioLANPort = 1 << 4, + u_username = 1 << 5, + u_password = 1 << 6, + u_clientName = 1 << 7, + u_waterfallFormat = 1 << 8, + u_halfDuplex = 1 << 9, + u_sampleRate = 1 << 10, + u_rxCodec = 1 << 11, + u_txCodec = 1 << 12, + u_rxLatency = 1 << 13, + u_txLatency = 1 << 14, + u_audioInput = 1 << 15, + u_audioOutput = 1 << 16, + u_all = 1 << 17 +}; struct preferences { @@ -117,6 +140,7 @@ struct preferences { int majorVersion = 0; int minorVersion = 0; QString gitShort; + bool settingsChanged = false; // Interface: bool useFullScreen; @@ -137,7 +161,7 @@ struct preferences { meter_t meter2Type; bool clickDragTuningEnable; int currentColorPresetNumber = 0; - + bool rigCreatorEnable = false; // Radio: unsigned char radioCIVAddr; @@ -150,12 +174,6 @@ struct preferences { unsigned char localAFgain; audioType audioSystem; - // Radio settings: - inputTypes inputDataOff=inputNone; - inputTypes inputData1=inputNone; - inputTypes inputData2=inputNone; - inputTypes inputData3=inputNone; - // Controls: bool enablePTT; bool niceTS; @@ -173,12 +191,21 @@ struct preferences { bool clusterUdpEnable; bool clusterTcpEnable; int clusterUdpPort; - QString clusterTcpServerName; - QString clusterTcpUserName; - QString clusterTcpPassword; int clusterTcpPort = 7300; int clusterTimeout; // used? bool clusterSkimmerSpotsEnable; // where is this used? + QString clusterTcpServerName; + QString clusterTcpUserName; + QString clusterTcpPassword; + + // Temporary settings + inputTypes inputDataOff=inputNone; + inputTypes inputData1=inputNone; + inputTypes inputData2=inputNone; + inputTypes inputData3=inputNone; + + audioSetup rxSetup; + audioSetup txSetup; }; #endif // PREFS_H diff --git a/rigcreator.cpp b/rigcreator.cpp index f6ab0a3..0004fcb 100644 --- a/rigcreator.cpp +++ b/rigcreator.cpp @@ -337,8 +337,42 @@ void rigCreator::loadRigFile(QString file) settings->endGroup(); delete settings; + + // Connect signals to find out if changed. + connect(ui->antennas,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->attenuators,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->bands,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->commands,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->filters,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->inputs,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->modes,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->preamps,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->spans,SIGNAL(cellChanged(int,int)),SLOT(changed())); + connect(ui->hasCommand29,SIGNAL(stateChanged(int)),SLOT(changed())); + connect(ui->hasEthernet,SIGNAL(stateChanged(int)),SLOT(changed())); + connect(ui->hasFDComms,SIGNAL(stateChanged(int)),SLOT(changed())); + connect(ui->hasLAN,SIGNAL(stateChanged(int)),SLOT(changed())); + connect(ui->hasSpectrum,SIGNAL(stateChanged(int)),SLOT(changed())); + connect(ui->hasTransmit,SIGNAL(stateChanged(int)),SLOT(changed())); + connect(ui->hasWifi,SIGNAL(stateChanged(int)),SLOT(changed())); + connect(ui->civAddress,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->rigctldModel,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->model,SIGNAL(editingFinished()),SLOT(changed())); +// connect(ui->manufacturer,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->memGroups,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->memStart,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->memories,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->memoryFormat,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->satMemories,SIGNAL(editingFinished()),SLOT(changed())); + connect(ui->satelliteFormat,SIGNAL(editingFinished()),SLOT(changed())); + + settingsChanged = false; } +void rigCreator::changed() +{ + settingsChanged = true; +} void rigCreator::on_saveFile_clicked(bool clicked) { Q_UNUSED(clicked) @@ -527,6 +561,9 @@ void rigCreator::saveRigFile(QString file) settings->sync(); delete settings; + + settingsChanged = false; + } @@ -558,3 +595,19 @@ void rigCreator::on_hasCommand29_toggled(bool checked) { ui->commands->setColumnHidden(4,!checked); } + + +void rigCreator::closeEvent(QCloseEvent *event) +{ + + if (settingsChanged) + { + // Settings have changed since last save + qInfo() << "Settings have changed since last save"; + int reply = QMessageBox::question(this,"rig creator","Changes will be lost!",QMessageBox::Cancel |QMessageBox::Ok); + if (reply == QMessageBox::Cancel) + { + event->ignore(); + } + } +} diff --git a/rigcreator.h b/rigcreator.h index 4345472..12e0810 100644 --- a/rigcreator.h +++ b/rigcreator.h @@ -34,16 +34,19 @@ private slots: void loadRigFile(QString filename); void saveRigFile(QString filename); void commandRowAdded(int row); + void changed(); private: Ui::rigCreator *ui; + void closeEvent(QCloseEvent *event); QMenu* context; tableCombobox* commandsList; QStandardItemModel* commandsModel; QStandardItemModel* command36Model; QStandardItemModel* createModel(QStandardItemModel* model, QString strings[]); QString currentFile; + bool settingsChanged=false; }; diff --git a/rigcreator.ui b/rigcreator.ui index 78e461e..93c89cb 100644 --- a/rigcreator.ui +++ b/rigcreator.ui @@ -19,40 +19,12 @@ Rig Creator - - - - 900 - 10 - 81 - 41 - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - QDialogButtonBox::Ok - - - - - - 7 + 10 10 - 861 + 961 31 @@ -1074,10 +1046,10 @@ - 0 + 8 30 - 119 - 111 + 101 + 101 @@ -1197,38 +1169,5 @@ - - - buttonBox - accepted() - rigCreator - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - rigCreator - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/settingswidget.cpp b/settingswidget.cpp index d542b8d..6c59425 100644 --- a/settingswidget.cpp +++ b/settingswidget.cpp @@ -8,6 +8,7 @@ settingswidget::settingswidget(QWidget *parent) : ui(new Ui::settingswidget) { ui->setupUi(this); + createSettingsListItems(); populateComboBoxes(); } @@ -15,6 +16,14 @@ settingswidget::settingswidget(QWidget *parent) : settingswidget::~settingswidget() { delete ui; + + if (audioDev != Q_NULLPTR) { + delete audioDev; + } + + if (prefs->audioSystem == portAudio) { + Pa_Terminate(); + } } // Startup: @@ -87,6 +96,11 @@ void settingswidget::populateComboBoxes() ui->modInputData2Combo->setVisible(false); ui->modInputData3ComboText->setVisible(false); ui->modInputData3Combo->setVisible(false); + + // Set color preset combo to an invalid value to force the current preset to be loaded + ui->colorPresetCombo->blockSignals(true); + ui->colorPresetCombo->setCurrentIndex(-1); + ui->colorPresetCombo->blockSignals(false); } // Updating Preferences: @@ -108,6 +122,14 @@ void settingswidget::acceptUdpPreferencesPtr(udpPreferences *upptr) udpPrefs = upptr; haveUdpPrefs = true; } + // New we have prefs, we get audio information + + if (audioDev == Q_NULLPTR) { + audioDev = new audioDevices(prefs->audioSystem, QFontMetrics(ui->audioSystemCombo->font())); + connect(audioDev, SIGNAL(updated()), this, SLOT(setAudioDevicesUI())); + audioDev->enumerate(); + } + } void settingswidget::acceptServerConfig(SERVERCONFIG *sc) @@ -120,6 +142,16 @@ void settingswidget::acceptServerConfig(SERVERCONFIG *sc) } } + +void settingswidget::acceptColorPresetPtr(colorPrefsType *cp) +{ + if(cp != NULL) + { + qDebug(logGui()) << "Accepting color preset pointer into settings widget."; + colorPreset = cp; + } +} + void settingswidget::copyClusterList(QList c) { this->clusters = c; @@ -272,7 +304,7 @@ void settingswidget::updateCtPrefs(quint64 items) } void settingswidget::updateServerConfigs(quint64 items) -{ +{ serverItems si; if(items & (int)s_all) { @@ -290,7 +322,7 @@ void settingswidget::updateServerConfigs(quint64 items) } void settingswidget::updateLanPrefs(quint64 items) -{ +{ prefLanItem plan; if(items & (int)l_all) { @@ -387,12 +419,14 @@ void settingswidget::updateIfPref(prefIfItem pif) quietlyUpdateCheckbox(ui->clickDragTuningEnableChk, prefs->clickDragTuningEnable); break; case if_currentColorPresetNumber: - ui->colorPresetCombo->blockSignals(true); + //ui->colorPresetCombo->blockSignals(true); ui->colorPresetCombo->setCurrentIndex(prefs->currentColorPresetNumber); - ui->colorPresetCombo->blockSignals(false); + //ui->colorPresetCombo->blockSignals(false); // activate? or done when prefs load? Maybe some of each? // TODO break; + case if_rigCreatorEnable: + quietlyUpdateCheckbox(ui->rigCreatorChk, prefs->rigCreatorEnable); default: qWarning(logGui()) << "Did not understand if pref update item " << (int)pif; break; @@ -406,10 +440,141 @@ void settingswidget::updateColPref(prefColItem col) return; updatingUIFromPrefs = true; + int pos = ui->colorPresetCombo->currentIndex(); switch(col) { case col_grid: + { + QColor c = (colorPreset[pos].gridColor); + setColorElement(c,ui->colorSwatchGrid, ui->colorEditGrid); break; + } + case col_axis: + { + QColor c = (colorPreset[pos].axisColor); + setColorElement(c, ui->colorSwatchAxis, ui->colorEditAxis); + break; + } + case col_text: + { + QColor c = (colorPreset[pos].textColor); + setColorElement(c, ui->colorSwatchText, ui->colorEditText); + break; + } + case col_plotBackground: + { + QColor c = (colorPreset[pos].plotBackground); + setColorElement(c, ui->colorSwatchPlotBackground, ui->colorEditPlotBackground); + break; + } + case col_spectrumLine: + { + QColor c = (colorPreset[pos].spectrumLine); + setColorElement(c, ui->colorSwatchSpecLine, ui->colorEditSpecLine); + break; + } + case col_spectrumFill: + { + QColor c = (colorPreset[pos].spectrumFill); + setColorElement(c, ui->colorSwatchSpecFill, ui->colorEditSpecFill); + break; + } + case col_underlayLine: + { + QColor c = (colorPreset[pos].underlayLine); + setColorElement(c, ui->colorSwatchUnderlayLine, ui->colorEditUnderlayLine); + break; + } + case col_underlayFill: + { + QColor c = (colorPreset[pos].underlayFill); + setColorElement(c, ui->colorSwatchUnderlayFill, ui->colorEditUnderlayFill); + break; + } + case col_tuningLine: + { + QColor c = (colorPreset[pos].tuningLine); + setColorElement(c, ui->colorSwatchTuningLine, ui->colorEditTuningLine); + break; + } + case col_passband: + { + QColor c = (colorPreset[pos].passband); + setColorElement(c, ui->colorSwatchPassband, ui->colorEditPassband); + break; + } + case col_pbtIndicator: + { + QColor c = (colorPreset[pos].pbt); + setColorElement(c, ui->colorSwatchPBT, ui->colorEditPBT); + break; + } + case col_meterLevel: + { + QColor c = (colorPreset[pos].meterLevel); + setColorElement(c, ui->colorSwatchMeterLevel, ui->colorEditMeterLevel); + break; + } + case col_meterAverage: + { + QColor c = (colorPreset[pos].meterAverage); + setColorElement(c, ui->colorSwatchMeterAverage, ui->colorEditMeterAvg); + break; + } + case col_meterPeakLevel: + { + QColor c = (colorPreset[pos].meterPeakLevel); + setColorElement(c, ui->colorSwatchMeterPeakLevel, ui->colorEditMeterPeakLevel); + break; + } + case col_meterHighScale: + { + QColor c = (colorPreset[pos].meterPeakScale); + setColorElement(c, ui->colorSwatchMeterPeakScale, ui->colorEditMeterPeakScale); + break; + } + case col_meterScale: + { + QColor c = (colorPreset[pos].meterScale); + setColorElement(c, ui->colorSwatchMeterScale, ui->colorEditMeterScale); + break; + } + case col_meterText: + { + QColor c = (colorPreset[pos].meterLowText); + setColorElement(c, ui->colorSwatchMeterText, ui->colorEditMeterText); + break; + } + case col_waterfallBack: + { + QColor c = (colorPreset[pos].wfBackground); + setColorElement(c, ui->colorSwatchWfBackground, ui->colorEditWfBackground); + break; + } + case col_waterfallGrid: + { + QColor c = (colorPreset[pos].wfGrid); + setColorElement(c, ui->colorSwatchWfGrid, ui->colorEditWfGrid); + break; + } + case col_waterfallAxis: + { + QColor c = (colorPreset[pos].wfAxis); + setColorElement(c, ui->colorSwatchWfAxis, ui->colorEditWfAxis); + break; + } + case col_waterfallText: + { + QColor c = (colorPreset[pos].wfText); + setColorElement(c, ui->colorSwatchWfText, ui->colorEditWfText); + break; + } + case col_clusterSpots: + { + QColor c = (colorPreset[pos].clusterSpots); + setColorElement(c, ui->colorSwatchClusterSpots, ui->colorEditClusterSpots); + break; + } default: qWarning(logGui()) << "Did not understand color pref update item " << (int)col; break; @@ -437,6 +602,9 @@ void settingswidget::updateRaPref(prefRaItem pra) ui->rigCIVaddrHexLine->setText(QString("%1").arg(prefs->radioCIVAddr, 2, 16)); } break; + case ra_serialEnabled: + // Will be enabled/disabled by UDP connection prefs + break; case ra_CIVisRadioModel: quietlyUpdateCheckbox(ui->useCIVasRigIDChk, prefs->CIVisRadioModel); break; @@ -734,17 +902,15 @@ void settingswidget::updateUdpPref(udpPrefsItem upi) updatingUIFromPrefs = true; switch(upi) { + case u_enabled: + // Call function directly + on_lanEnableBtn_clicked(prefs->enableLAN); + break; case u_ipAddress: - ui->ipAddressTxt->blockSignals(true); - ui->ipAddressTxt->setEnabled(ui->lanEnableBtn->isChecked()); - ui->ipAddressTxt->setText(udpPrefs->ipAddress); - ui->ipAddressTxt->blockSignals(false); + quietlyUpdateLineEdit(ui->ipAddressTxt,udpPrefs->ipAddress); 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); + quietlyUpdateLineEdit(ui->controlPortTxt,QString::number(udpPrefs->controlLANPort)); break; case u_serialLANPort: // Not used in the UI. @@ -753,29 +919,40 @@ void settingswidget::updateUdpPref(udpPrefsItem upi) // 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); + quietlyUpdateLineEdit(ui->usernameTxt,udpPrefs->username); 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); + quietlyUpdateLineEdit(ui->passwordTxt,udpPrefs->password); 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); + quietlyUpdateCombobox(ui->waterfallFormatCombo,int(prefs->waterfallFormat)); break; case u_halfDuplex: - ui->audioDuplexCombo->blockSignals(true); - ui->audioDuplexCombo->setCurrentIndex((int)udpPrefs->halfDuplex); - ui->audioDuplexCombo->blockSignals(false); + quietlyUpdateCombobox(ui->audioDuplexCombo,int(udpPrefs->halfDuplex)); + break; + case u_sampleRate: + quietlyUpdateCombobox(ui->audioSampleRateCombo,QString::number(prefs->rxSetup.sampleRate)); + break; + case u_rxCodec: + quietlyUpdateCombobox(ui->audioRXCodecCombo,QVariant::fromValue(prefs->rxSetup.codec)); + break; + case u_txCodec: + quietlyUpdateCombobox(ui->audioTXCodecCombo,QVariant::fromValue(prefs->txSetup.codec)); + break; + case u_rxLatency: + ui->rxLatencySlider->setValue(prefs->rxSetup.latency); // We want the signal to fire on audio devices + break; + case u_txLatency: + ui->txLatencySlider->setValue(prefs->txSetup.latency); + break; + case u_audioInput: + ui->audioInputCombo->setCurrentIndex(audioDev->findInput("Client", prefs->txSetup.name)); + break; + case u_audioOutput: + ui->audioOutputCombo->setCurrentIndex(audioDev->findOutput("Client", prefs->rxSetup.name)); break; default: qWarning(logGui()) << "Did not find matching UI element for UDP pref item " << (int)upi; @@ -784,6 +961,61 @@ void settingswidget::updateUdpPref(udpPrefsItem upi) updatingUIFromPrefs = false; } + +void settingswidget::setAudioDevicesUI() +{ + 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); + + qInfo() << "Looking for outputs"; + // 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->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; + + prefs->rxSetup.type = prefs->audioSystem; + prefs->txSetup.type = prefs->audioSystem; + + if (!serverConfig->rigs.isEmpty()) + { + 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)); + 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); + } + + qDebug(logSystem()) << "Audio devices done."; +} + + void settingswidget::updateAllPrefs() { // DEPRECIATED @@ -811,59 +1043,18 @@ void settingswidget::updateAllPrefs() 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) @@ -1082,6 +1273,13 @@ void settingswidget::quietlyUpdateCombobox(QComboBox *cb, QVariant val) cb->blockSignals(false); } +void settingswidget::quietlyUpdateCombobox(QComboBox *cb, QString val) +{ + cb->blockSignals(true); + cb->setCurrentIndex(cb->findText(val)); + cb->blockSignals(false); +} + void settingswidget::quietlyUpdateSpinbox(QSpinBox *sb, int val) { sb->blockSignals(true); @@ -1181,6 +1379,9 @@ void settingswidget::on_lanEnableBtn_clicked(bool checked) { // TODO: prefs.enableLAN = checked; // TOTO? ui->connectBtn->setEnabled(true); // move to other side + ui->groupNetwork->setEnabled(checked); + ui->groupSerial->setEnabled(!checked); +/* ui->ipAddressTxt->setEnabled(checked); ui->controlPortTxt->setEnabled(checked); ui->usernameTxt->setEnabled(checked); @@ -1199,7 +1400,7 @@ void settingswidget::on_lanEnableBtn_clicked(bool checked) ui->serverRXAudioInputCombo->setEnabled(!checked); ui->serverTXAudioOutputCombo->setEnabled(!checked); ui->useRTSforPTTchk->setEnabled(!checked); - +*/ prefs->enableLAN = checked; emit changedLanPref(l_enableLAN); } @@ -1207,6 +1408,10 @@ void settingswidget::on_lanEnableBtn_clicked(bool checked) void settingswidget::on_serialEnableBtn_clicked(bool checked) { prefs->enableLAN = !checked; + ui->groupSerial->setEnabled(checked); + ui->groupNetwork->setEnabled(!checked); + +/* ui->serialDeviceListCombo->setEnabled(checked); ui->ipAddressTxt->setEnabled(!checked); @@ -1227,10 +1432,13 @@ void settingswidget::on_serialEnableBtn_clicked(bool 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; @@ -1348,15 +1556,19 @@ void settingswidget::on_vspCombo_activated(int index) void settingswidget::on_audioSystemCombo_currentIndexChanged(int value) { - prefs->audioSystem = static_cast(value); quietlyUpdateCombobox(ui->audioSystemServerCombo,value); + prefs->audioSystem = static_cast(value); + audioDev->setAudioType(prefs->audioSystem); + audioDev->enumerate(); emit changedRaPref(ra_audioSystem); } void settingswidget::on_audioSystemServerCombo_currentIndexChanged(int value) { - prefs->audioSystem = static_cast(value); quietlyUpdateCombobox(ui->audioSystemCombo,value); + prefs->audioSystem = static_cast(value); + audioDev->setAudioType(prefs->audioSystem); + audioDev->enumerate(); emit changedRaPref(ra_audioSystem); } @@ -1448,6 +1660,12 @@ void settingswidget::on_clickDragTuningEnableChk_clicked(bool checked) emit changedIfPref(if_clickDragTuningEnable); } +void settingswidget::on_rigCreatorChk_clicked(bool checked) +{ + prefs->rigCreatorEnable = checked; + emit changedIfPref(if_rigCreatorEnable); +} + void settingswidget::on_enableRigctldChk_clicked(bool checked) { prefs->enableRigCtlD = checked; @@ -1476,6 +1694,7 @@ void settingswidget::on_tcpServerPortTxt_editingFinished() } } +/* Beginning of cluster settings */ void settingswidget::on_clusterServerNameCombo_currentIndexChanged(int index) { if (index < 0) @@ -1638,6 +1857,10 @@ void settingswidget::on_clusterSkimmerSpotsEnable_clicked(bool checked) emit changedClusterPref(cl_clusterSkimmerSpotsEnable); } +/* End of cluster settings */ + + +/* Beginning of UDP connection settings */ void settingswidget::on_ipAddressTxt_textChanged(const QString &arg1) { udpPrefs->ipAddress = arg1; @@ -1673,16 +1896,78 @@ void settingswidget::on_audioDuplexCombo_currentIndexChanged(int index) emit changedUdpPref(u_halfDuplex); } +void settingswidget::on_audioSampleRateCombo_currentIndexChanged(int value) +{ + prefs->rxSetup.sampleRate= ui->audioSampleRateCombo->itemText(value).toInt(); + prefs->txSetup.sampleRate= ui->audioSampleRateCombo->itemText(value).toInt(); + emit changedUdpPref(u_sampleRate); +} + +void settingswidget::on_audioRXCodecCombo_currentIndexChanged(int value) +{ + prefs->rxSetup.codec = ui->audioRXCodecCombo->itemData(value).toInt(); + emit changedUdpPref(u_rxCodec); +} + +void settingswidget::on_audioTXCodecCombo_currentIndexChanged(int value) +{ + prefs->txSetup.codec = ui->audioTXCodecCombo->itemData(value).toInt(); + emit changedUdpPref(u_txCodec); +} + +void settingswidget::on_rxLatencySlider_valueChanged(int value) +{ + prefs->rxSetup.latency = value; + ui->rxLatencyValue->setText(QString::number(value)); + emit changedUdpPref(u_rxLatency); +} + +void settingswidget::on_txLatencySlider_valueChanged(int value) +{ + //txSetup.latency = value; + prefs->txSetup.latency = value; + ui->txLatencyValue->setText(QString::number(value)); + emit changedUdpPref(u_txLatency); +} + void settingswidget::on_audioOutputCombo_currentIndexChanged(int index) { - emit changedAudioOutputCombo(index); + if (index >= 0) { + if (prefs->audioSystem == qtAudio) { + prefs->rxSetup.port = audioDev->getOutputDeviceInfo(index); + } + else { + prefs->rxSetup.portInt = audioDev->getOutputDeviceInt(index); + } + + prefs->rxSetup.name = audioDev->getOutputName(index); + } + qDebug(logGui()) << "Changed audio output to:" << prefs->rxSetup.name; + + emit changedUdpPref(u_audioOutput); } void settingswidget::on_audioInputCombo_currentIndexChanged(int index) { - emit changedAudioInputCombo(index); + if (index >= 0) { + if (prefs->audioSystem == qtAudio) { + prefs->txSetup.port = audioDev->getInputDeviceInfo(index); + } + else { + prefs->txSetup.portInt = audioDev->getInputDeviceInt(index); + } + + prefs->txSetup.name = audioDev->getInputName(index); + } + qDebug(logGui()) << "Changed audio output to:" << prefs->rxSetup.name; + + emit changedUdpPref(u_audioInput); } +/* End of UDP connection settings */ + + +/* Beginning of UDP Server settings */ void settingswidget::on_serverRXAudioInputCombo_currentIndexChanged(int index) { emit changedServerRXAudioInputCombo(index); @@ -1716,7 +2001,10 @@ void settingswidget::on_serverAddUserBtn_clicked() ui->serverAddUserBtn->setEnabled(false); } +/* End of UDP Server settings */ + +/* Beginning of radio specific settings */ void settingswidget::on_modInputCombo_activated(int index) { emit changedModInput(0,ui->modInputCombo->currentData().value()); @@ -1738,3 +2026,637 @@ void settingswidget::on_modInputData3Combo_activated(int index) { emit changedModInput(3,ui->modInputData3Combo->currentData().value()); } + +/* End of radio specific settings */ + + +/* Color UI helper functions */ +void settingswidget::setColorElement(QColor color, + QLedLabel *led, + QLabel *label, + QLineEdit *lineText) +{ + if(led != Q_NULLPTR) + { + led->setColor(color, true); + } + if(label != Q_NULLPTR) + { + label->setText(color.name(QColor::HexArgb)); + } + if(lineText != Q_NULLPTR) + { + lineText->setText(color.name(QColor::HexArgb)); + } +} + +void settingswidget::setColorElement(QColor color, QLedLabel *led, QLabel *label) +{ + setColorElement(color, led, label, Q_NULLPTR); +} + +void settingswidget::setColorElement(QColor color, QLedLabel *led, QLineEdit *lineText) +{ + setColorElement(color, led, Q_NULLPTR, lineText); +} + +QColor settingswidget::getColorFromPicker(QColor initialColor) +{ + QColorDialog::ColorDialogOptions options; + options.setFlag(QColorDialog::ShowAlphaChannel, true); + options.setFlag(QColorDialog::DontUseNativeDialog, true); + QColor selColor = QColorDialog::getColor(initialColor, this, "Select Color", options); + int alphaVal = 0; + bool ok = false; + + if (selColor.isValid()) + { + if (selColor.alpha() == 0) + { + alphaVal = QInputDialog::getInt(this, tr("Specify Opacity"), + tr("You specified an opacity value of 0. \nDo you want to change it? (0=transparent, 255=opaque)"), 0, 0, 255, 1, + &ok); + if (!ok) + { + return selColor; + } + else { + selColor.setAlpha(alphaVal); + return selColor; + } + } + return selColor; + } + else + return initialColor; +} + +void settingswidget::getSetColor(QLedLabel *led, QLabel *label) +{ + QColor selColor = getColorFromPicker(led->getColor()); + setColorElement(selColor, led, label); +} + +void settingswidget::getSetColor(QLedLabel *led, QLineEdit *line) +{ + QColor selColor = getColorFromPicker(led->getColor()); + setColorElement(selColor, led, line); +} + +QString settingswidget::setColorFromString(QString colorstr, QLedLabel *led) +{ + if(led==Q_NULLPTR) + return "ERROR"; + + if(!colorstr.startsWith("#")) + { + colorstr.prepend("#"); + } + if(colorstr.length() != 9) + { + // TODO: Tell user about AA RR GG BB + return led->getColor().name(QColor::HexArgb); + } + led->setColor(colorstr, true); + return led->getColor().name(QColor::HexArgb); +} + +void settingswidget::setColorButtonOperations(QColor *colorStore, + QLineEdit *e, QLedLabel *d) +{ + // Call this function with a pointer into the colorPreset color you + // wish to edit. + + if(colorStore==Q_NULLPTR) + { + qInfo(logSystem()) << "ERROR, invalid pointer to color received."; + return; + } + getSetColor(d, e); + QColor t = d->getColor(); + colorStore->setNamedColor(t.name(QColor::HexArgb)); + //useCurrentColorPreset(); +} + +void settingswidget::setColorLineEditOperations(QColor *colorStore, + QLineEdit *e, QLedLabel *d) +{ + // Call this function with a pointer into the colorPreset color you + // wish to edit. + if(colorStore==Q_NULLPTR) + { + qInfo(logSystem()) << "ERROR, invalid pointer to color received."; + return; + } + + QString colorStrValidated = setColorFromString(e->text(), d); + e->setText(colorStrValidated); + colorStore->setNamedColor(colorStrValidated); + //useCurrentColorPreset(); +} + +void settingswidget::setEditAndLedFromColor(QColor c, QLineEdit *e, QLedLabel *d) +{ + bool blockSignals = true; + if(e != Q_NULLPTR) + { + e->blockSignals(blockSignals); + e->setText(c.name(QColor::HexArgb)); + e->blockSignals(false); + } + if(d != Q_NULLPTR) + { + d->setColor(c); + } +} + + + +void settingswidget::loadColorPresetToUIandPlots(int presetNumber) +{ + if(presetNumber >= numColorPresetsTotal) + { + qDebug(logSystem()) << "WARNING: asked for preset number [" << presetNumber << "], which is out of range."; + return; + } + + colorPrefsType p = colorPreset[presetNumber]; + //qInfo(logSystem()) << "color preset number [" << presetNumber << "] requested for UI load, which has internal index of [" << p.presetNum << "]"; + setEditAndLedFromColor(p.gridColor, ui->colorEditGrid, ui->colorSwatchGrid); + setEditAndLedFromColor(p.axisColor, ui->colorEditAxis, ui->colorSwatchAxis); + setEditAndLedFromColor(p.textColor, ui->colorEditText, ui->colorSwatchText); + setEditAndLedFromColor(p.spectrumLine, ui->colorEditSpecLine, ui->colorSwatchSpecLine); + setEditAndLedFromColor(p.spectrumFill, ui->colorEditSpecFill, ui->colorSwatchSpecFill); + setEditAndLedFromColor(p.underlayLine, ui->colorEditUnderlayLine, ui->colorSwatchUnderlayLine); + setEditAndLedFromColor(p.underlayFill, ui->colorEditUnderlayFill, ui->colorSwatchUnderlayFill); + setEditAndLedFromColor(p.plotBackground, ui->colorEditPlotBackground, ui->colorSwatchPlotBackground); + setEditAndLedFromColor(p.tuningLine, ui->colorEditTuningLine, ui->colorSwatchTuningLine); + setEditAndLedFromColor(p.passband, ui->colorEditPassband, ui->colorSwatchPassband); + setEditAndLedFromColor(p.pbt, ui->colorEditPBT, ui->colorSwatchPBT); + + setEditAndLedFromColor(p.meterLevel, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); + setEditAndLedFromColor(p.meterAverage, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); + setEditAndLedFromColor(p.meterPeakLevel, ui->colorEditMeterPeakLevel, ui->colorSwatchMeterPeakLevel); + setEditAndLedFromColor(p.meterPeakScale, ui->colorEditMeterPeakScale, ui->colorSwatchMeterPeakScale); + setEditAndLedFromColor(p.meterLowerLine, ui->colorEditMeterScale, ui->colorSwatchMeterScale); + setEditAndLedFromColor(p.meterLowText, ui->colorEditMeterText, ui->colorSwatchMeterText); + + setEditAndLedFromColor(p.wfBackground, ui->colorEditWfBackground, ui->colorSwatchWfBackground); + setEditAndLedFromColor(p.wfGrid, ui->colorEditWfGrid, ui->colorSwatchWfGrid); + setEditAndLedFromColor(p.wfAxis, ui->colorEditWfAxis, ui->colorSwatchWfAxis); + setEditAndLedFromColor(p.wfText, ui->colorEditWfText, ui->colorSwatchWfText); + + setEditAndLedFromColor(p.clusterSpots, ui->colorEditClusterSpots, ui->colorSwatchClusterSpots); + + //useColorPreset(&p); + prefs->currentColorPresetNumber = presetNumber; + emit changedIfPref(if_currentColorPresetNumber); +} + +void settingswidget::on_colorRenamePresetBtn_clicked() +{ + int p = ui->colorPresetCombo->currentIndex(); + QString newName; + QMessageBox msgBox; + + bool ok = false; + newName = QInputDialog::getText(this, tr("Rename Preset"), + tr("Preset Name (10 characters max):"), QLineEdit::Normal, + ui->colorPresetCombo->currentText(), &ok); + if(!ok) + return; + + if(ok && (newName.length() < 11) && !newName.isEmpty()) + { + colorPreset[p].presetName->clear(); + colorPreset[p].presetName->append(newName); + ui->colorPresetCombo->setItemText(p, *(colorPreset[p].presetName)); + } else { + if(newName.isEmpty() || (newName.length() > 10)) + { + msgBox.setText("Error, name must be at least one character and not exceed 10 characters."); + msgBox.exec(); + } + } +} + +void settingswidget::on_colorPresetCombo_currentIndexChanged(int index) +{ + prefs->currentColorPresetNumber = index; + loadColorPresetToUIandPlots(index); +} + +void settingswidget::on_colorRevertPresetBtn_clicked() +{ + int pn = ui->colorPresetCombo->currentIndex(); + //setDefaultColors(pn); + loadColorPresetToUIandPlots(pn); +} + +// ---------- end color helper functions ---------- // + + +// ---------- Color UI slots ----------// + + +void settingswidget::on_colorSavePresetBtn_clicked() +{ + int pn = ui->colorPresetCombo->currentIndex(); + + /* + settings->beginGroup("ColorPresets"); + settings->setValue("currentColorPresetNumber", prefs.currentColorPresetNumber); + settings->beginWriteArray("ColorPreset", numColorPresetsTotal); + + colorPrefsType *p; + p = &(colorPreset[pn]); + settings->setArrayIndex(pn); + settings->setValue("presetNum", p->presetNum); + settings->setValue("presetName", *(p->presetName)); + settings->setValue("gridColor", p->gridColor.name(QColor::HexArgb)); + settings->setValue("axisColor", p->axisColor.name(QColor::HexArgb)); + settings->setValue("textColor", p->textColor.name(QColor::HexArgb)); + settings->setValue("spectrumLine", p->spectrumLine.name(QColor::HexArgb)); + settings->setValue("spectrumFill", p->spectrumFill.name(QColor::HexArgb)); + settings->setValue("underlayLine", p->underlayLine.name(QColor::HexArgb)); + settings->setValue("underlayFill", p->underlayFill.name(QColor::HexArgb)); + settings->setValue("plotBackground", p->plotBackground.name(QColor::HexArgb)); + settings->setValue("tuningLine", p->tuningLine.name(QColor::HexArgb)); + settings->setValue("passband", p->passband.name(QColor::HexArgb)); + settings->setValue("pbt", p->pbt.name(QColor::HexArgb)); + settings->setValue("wfBackground", p->wfBackground.name(QColor::HexArgb)); + settings->setValue("wfGrid", p->wfGrid.name(QColor::HexArgb)); + settings->setValue("wfAxis", p->wfAxis.name(QColor::HexArgb)); + settings->setValue("wfText", p->wfText.name(QColor::HexArgb)); + settings->setValue("meterLevel", p->meterLevel.name(QColor::HexArgb)); + settings->setValue("meterAverage", p->meterAverage.name(QColor::HexArgb)); + settings->setValue("meterPeakScale", p->meterPeakScale.name(QColor::HexArgb)); + settings->setValue("meterPeakLevel", p->meterPeakLevel.name(QColor::HexArgb)); + settings->setValue("meterLowerLine", p->meterLowerLine.name(QColor::HexArgb)); + settings->setValue("meterLowText", p->meterLowText.name(QColor::HexArgb)); + settings->setValue("clusterSpots", p->clusterSpots.name(QColor::HexArgb)); + + settings->endArray(); + settings->endGroup(); + settings->sync(); +*/ +} + +// Grid: +void settingswidget::on_colorSetBtnGrid_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].gridColor); + setColorButtonOperations(c, ui->colorEditGrid, ui->colorSwatchGrid); + emit changedColPref(col_grid); +} +void settingswidget::on_colorEditGrid_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].gridColor); + setColorLineEditOperations(c, ui->colorEditGrid, ui->colorSwatchGrid); + emit changedColPref(col_grid); +} + +// Axis: +void settingswidget::on_colorSetBtnAxis_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].axisColor); + setColorButtonOperations(c, ui->colorEditAxis, ui->colorSwatchAxis); + emit changedColPref(col_axis); +} +void settingswidget::on_colorEditAxis_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].axisColor); + setColorLineEditOperations(c, ui->colorEditAxis, ui->colorSwatchAxis); + emit changedColPref(col_axis); +} + +// Text: +void settingswidget::on_colorSetBtnText_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].textColor); + setColorButtonOperations(c, ui->colorEditText, ui->colorSwatchText); + emit changedColPref(col_text); +} +void settingswidget::on_colorEditText_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].textColor); + setColorLineEditOperations(c, ui->colorEditText, ui->colorSwatchText); + emit changedColPref(col_text); +} + +// SpecLine: +void settingswidget::on_colorEditSpecLine_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].spectrumLine); + setColorLineEditOperations(c, ui->colorEditSpecLine, ui->colorSwatchSpecLine); + emit changedColPref(col_spectrumLine); +} +void settingswidget::on_colorSetBtnSpecLine_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].spectrumLine); + setColorButtonOperations(c, ui->colorEditSpecLine, ui->colorSwatchSpecLine); + emit changedColPref(col_spectrumLine); +} + +// SpecFill: +void settingswidget::on_colorSetBtnSpecFill_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].spectrumFill); + setColorButtonOperations(c, ui->colorEditSpecFill, ui->colorSwatchSpecFill); + emit changedColPref(col_spectrumFill); +} +void settingswidget::on_colorEditSpecFill_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].spectrumFill); + setColorLineEditOperations(c, ui->colorEditSpecFill, ui->colorSwatchSpecFill); + emit changedColPref(col_spectrumFill); +} + +// PlotBackground: +void settingswidget::on_colorEditPlotBackground_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].plotBackground); + setColorLineEditOperations(c, ui->colorEditPlotBackground, ui->colorSwatchPlotBackground); + emit changedColPref(col_plotBackground); +} +void settingswidget::on_colorSetBtnPlotBackground_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].plotBackground); + setColorButtonOperations(c, ui->colorEditPlotBackground, ui->colorSwatchPlotBackground); + emit changedColPref(col_plotBackground); +} + +// Underlay Line: +void settingswidget::on_colorSetBtnUnderlayLine_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].underlayLine); + setColorButtonOperations(c, ui->colorEditUnderlayLine, ui->colorSwatchUnderlayLine); + emit changedColPref(col_underlayLine); +} + +void settingswidget::on_colorEditUnderlayLine_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].underlayLine); + setColorLineEditOperations(c, ui->colorEditUnderlayLine, ui->colorSwatchUnderlayLine); + emit changedColPref(col_underlayLine); +} + +// Underlay Fill: +void settingswidget::on_colorSetBtnUnderlayFill_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].underlayFill); + setColorButtonOperations(c, ui->colorEditUnderlayFill, ui->colorSwatchUnderlayFill); + emit changedColPref(col_underlayFill); +} +void settingswidget::on_colorEditUnderlayFill_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].underlayFill); + setColorLineEditOperations(c, ui->colorEditUnderlayFill, ui->colorSwatchUnderlayFill); + emit changedColPref(col_underlayFill); +} + +// WF Background: +void settingswidget::on_colorSetBtnwfBackground_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].wfBackground); + setColorButtonOperations(c, ui->colorEditWfBackground, ui->colorSwatchWfBackground); + emit changedColPref(col_waterfallBack); +} +void settingswidget::on_colorEditWfBackground_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].wfBackground); + setColorLineEditOperations(c, ui->colorEditWfBackground, ui->colorSwatchWfBackground); + emit changedColPref(col_waterfallBack); +} + +// WF Grid: +void settingswidget::on_colorSetBtnWfGrid_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].wfGrid); + setColorButtonOperations(c, ui->colorEditWfGrid, ui->colorSwatchWfGrid); + emit changedColPref(col_waterfallGrid); +} +void settingswidget::on_colorEditWfGrid_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].wfGrid); + setColorLineEditOperations(c, ui->colorEditWfGrid, ui->colorSwatchWfGrid); + emit changedColPref(col_waterfallGrid); +} + +// WF Axis: +void settingswidget::on_colorSetBtnWfAxis_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].wfAxis); + setColorButtonOperations(c, ui->colorEditWfAxis, ui->colorSwatchWfAxis); + emit changedColPref(col_waterfallAxis); +} +void settingswidget::on_colorEditWfAxis_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].wfAxis); + setColorLineEditOperations(c, ui->colorEditWfAxis, ui->colorSwatchWfAxis); + emit changedColPref(col_waterfallAxis); +} + +// WF Text: +void settingswidget::on_colorSetBtnWfText_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].wfText); + setColorButtonOperations(c, ui->colorEditWfText, ui->colorSwatchWfText); + emit changedColPref(col_waterfallText); +} + +void settingswidget::on_colorEditWfText_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].wfText); + setColorLineEditOperations(c, ui->colorEditWfText, ui->colorSwatchWfText); + emit changedColPref(col_waterfallText); +} + +// Tuning Line: +void settingswidget::on_colorSetBtnTuningLine_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].tuningLine); + setColorButtonOperations(c, ui->colorEditTuningLine, ui->colorSwatchTuningLine); + emit changedColPref(col_tuningLine); +} +void settingswidget::on_colorEditTuningLine_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].tuningLine); + setColorLineEditOperations(c, ui->colorEditTuningLine, ui->colorSwatchTuningLine); + emit changedColPref(col_tuningLine); +} + +// Passband: +void settingswidget::on_colorSetBtnPassband_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].passband); + setColorButtonOperations(c, ui->colorEditPassband, ui->colorSwatchPassband); + emit changedColPref(col_passband); +} + +void settingswidget::on_colorEditPassband_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].passband); + setColorLineEditOperations(c, ui->colorEditPassband, ui->colorSwatchPassband); + emit changedColPref(col_passband); +} + +void settingswidget::on_colorSetBtnPBT_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].pbt); + setColorButtonOperations(c, ui->colorEditPBT, ui->colorSwatchPBT); + emit changedColPref(col_pbtIndicator); +} + +void settingswidget::on_colorEditPBT_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].pbt); + setColorLineEditOperations(c, ui->colorEditPBT, ui->colorSwatchPBT); + emit changedColPref(col_pbtIndicator); +} + +// Meter Level: +void settingswidget::on_colorSetBtnMeterLevel_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterLevel); + setColorButtonOperations(c, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); + emit changedColPref(col_meterLevel); +} +void settingswidget::on_colorEditMeterLevel_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterLevel); + setColorLineEditOperations(c, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); + emit changedColPref(col_meterLevel); +} + +// Meter Average: +void settingswidget::on_colorSetBtnMeterAvg_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterAverage); + setColorButtonOperations(c, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); + emit changedColPref(col_meterAverage); +} +void settingswidget::on_colorEditMeterAvg_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterAverage); + setColorLineEditOperations(c, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); + emit changedColPref(col_meterAverage); +} + +// Meter Peak Level: +void settingswidget::on_colorSetBtnMeterPeakLevel_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterPeakLevel); + setColorButtonOperations(c, ui->colorEditMeterPeakLevel, ui->colorSwatchMeterPeakLevel); + emit changedColPref(col_meterPeakLevel); +} +void settingswidget::on_colorEditMeterPeakLevel_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterPeakLevel); + setColorLineEditOperations(c, ui->colorEditMeterPeakLevel, ui->colorSwatchMeterPeakLevel); + emit changedColPref(col_meterPeakLevel); +} + +// Meter Peak Scale: +void settingswidget::on_colorSetBtnMeterPeakScale_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterPeakScale); + setColorButtonOperations(c, ui->colorEditMeterPeakScale, ui->colorSwatchMeterPeakScale); + emit changedColPref(col_meterHighScale); +} +void settingswidget::on_colorEditMeterPeakScale_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterPeakScale); + setColorLineEditOperations(c, ui->colorEditMeterPeakScale, ui->colorSwatchMeterPeakScale); + emit changedColPref(col_meterHighScale); +} + +// Meter Scale (line): +void settingswidget::on_colorSetBtnMeterScale_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterLowerLine); + setColorButtonOperations(c, ui->colorEditMeterScale, ui->colorSwatchMeterScale); + emit changedColPref(col_meterScale); +} +void settingswidget::on_colorEditMeterScale_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterLowerLine); + setColorLineEditOperations(c, ui->colorEditMeterScale, ui->colorSwatchMeterScale); + emit changedColPref(col_meterScale); +} + +// Meter Text: +void settingswidget::on_colorSetBtnMeterText_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterLowText); + setColorButtonOperations(c, ui->colorEditMeterText, ui->colorSwatchMeterText); + emit changedColPref(col_meterText); +} +void settingswidget::on_colorEditMeterText_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterLowText); + setColorLineEditOperations(c, ui->colorEditMeterText, ui->colorSwatchMeterText); + emit changedColPref(col_meterText); +} + +// Cluster Spots: +void settingswidget::on_colorSetBtnClusterSpots_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].clusterSpots); + setColorButtonOperations(c, ui->colorEditClusterSpots, ui->colorSwatchClusterSpots); + emit changedColPref(col_clusterSpots); +} +void settingswidget::on_colorEditClusterSpots_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor* c = &(colorPreset[pos].clusterSpots); + setColorLineEditOperations(c, ui->colorEditClusterSpots, ui->colorSwatchClusterSpots); + emit changedColPref(col_clusterSpots); +} + +// ---------- End color UI slots ----------// + + diff --git a/settingswidget.h b/settingswidget.h index d0ba060..a866e99 100644 --- a/settingswidget.h +++ b/settingswidget.h @@ -20,6 +20,8 @@ #include "cluster.h" // for clusterSettings #include "rigidentities.h" // for rigInputs #include "udpserver.h" // for SERVERCONFIG +#include "qledlabel.h" // For color swatches +#include "audiodevices.h" namespace Ui { class settingswidget; @@ -38,6 +40,7 @@ public slots: void acceptPreferencesPtr(preferences *pptr); void acceptUdpPreferencesPtr(udpPreferences *upptr); void acceptServerConfig(SERVERCONFIG *serverConfig); + void acceptColorPresetPtr(colorPrefsType *cp); void copyClusterList(QList c); void insertClusterOutputText(QString text); @@ -72,9 +75,11 @@ public slots: void updateVSPList(QStringList deviceList, QVector data); void updateModSourceList(uchar num, QVector data); + void setAudioDevicesUI(); signals: void changedIfPrefs(quint64 items); + void changedColPrefs(quint64 items); void changedRaPrefs(quint64 items); void changedRsPrefs(quint64 items); void changedCtPrefs(quint64 items); @@ -89,6 +94,7 @@ signals: void changedServerRXAudioInputCombo(int index); void changedIfPref(prefIfItem i); + void changedColPref(prefColItem i); void changedRaPref(prefRaItem i); void changedRsPref(prefRsItem i); void changedCtPref(prefCtItem i); @@ -98,7 +104,7 @@ signals: void changedServerConfig(serverItems i); void showUSBControllerSetup(); - void changedModInput(uchar num, inputTypes input); + void changedModInput(uchar num, inputTypes input); private slots: void on_settingsList_currentRowChanged(int currentRow); @@ -128,6 +134,7 @@ private slots: void on_underlayBufferSlider_valueChanged(int value); void on_pttEnableChk_clicked(bool checked); void on_clickDragTuningEnableChk_clicked(bool checked); + void on_rigCreatorChk_clicked(bool checked); void on_serialEnableBtn_clicked(bool checked); void on_enableRigctldChk_clicked(bool checked); void on_rigctldPortTxt_editingFinished(); @@ -155,6 +162,12 @@ private slots: void on_serverTXAudioOutputCombo_currentIndexChanged(int index); void on_serverEnableCheckbox_clicked(bool checked); + 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_serverAddUserBtn_clicked(); void on_modInputCombo_activated(int index); @@ -162,6 +175,56 @@ private slots: void on_modInputData2Combo_activated(int index); void on_modInputData3Combo_activated(int index); + // Color slots + void on_colorPresetCombo_currentIndexChanged(int index); + void on_colorSavePresetBtn_clicked(); + + void on_colorSetBtnPlotBackground_clicked(); + void on_colorEditPlotBackground_editingFinished(); + void on_colorSetBtnSpecLine_clicked(); + void on_colorEditSpecLine_editingFinished(); + void on_colorSetBtnGrid_clicked(); + void on_colorEditGrid_editingFinished(); + void on_colorSetBtnText_clicked(); + void on_colorEditText_editingFinished(); + void on_colorSetBtnSpecFill_clicked(); + 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(); private: Ui::settingswidget *ui; @@ -175,15 +238,30 @@ private: void quietlyUpdateSlider(QSlider* sl, int val); void quietlyUpdateCombobox(QComboBox *cb, int index); void quietlyUpdateCombobox(QComboBox *cb, QVariant val); + void quietlyUpdateCombobox(QComboBox *cb, QString 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); + // Colors (helper functions) + void setEditAndLedFromColor(QColor c, QLineEdit *e, QLedLabel *d); + void setColorButtonOperations(QColor *colorStore, QLineEdit *e, QLedLabel *d); + void setColorLineEditOperations(QColor *colorStore, QLineEdit *e, QLedLabel *d); + void loadColorPresetToUIandPlots(int presetNumber); + void setColorElement(QColor color, QLedLabel *led, QLabel *label); + void setColorElement(QColor color, QLedLabel *led, QLineEdit *lineText); + void setColorElement(QColor color, QLedLabel *led, QLabel *label, QLineEdit *lineText); + QColor getColorFromPicker(QColor initialColor); + void getSetColor(QLedLabel *led, QLabel *label); + void getSetColor(QLedLabel *led, QLineEdit *line); + QString setColorFromString(QString aarrggbb, QLedLabel *led); + void populateServerUsers(); void serverAddUserLine(const QString& user, const QString& pass, const int& type); preferences *prefs = NULL; + colorPrefsType *colorPreset; udpPreferences *udpPrefs = NULL; SERVERCONFIG *serverConfig = NULL; bool havePrefs = false; @@ -200,6 +278,8 @@ private: QList clusters; + audioDevices* audioDev = Q_NULLPTR; + }; #endif // SETTINGSWIDGET_H diff --git a/settingswidget.ui b/settingswidget.ui index f57dcee..4971df7 100644 --- a/settingswidget.ui +++ b/settingswidget.ui @@ -41,7 +41,7 @@ - 2 + 0 @@ -154,17 +154,38 @@ - - - Qt::Horizontal + + + + 0 + 0 + - - - 40 - 20 - + + Information - + + false + + + + + + + + Audio controls on this page are ONLY for network radios +Please use the "Radio Server" page to select server audio. +ONLY use Manual CI-V when Transceive mode is not supported + + + Qt::AlignCenter + + + + + + + @@ -174,7 +195,10 @@ 0 - + + + true + Serial Connected Radios @@ -271,7 +295,7 @@ 0 - + Network Connected Radios @@ -772,6 +796,16 @@ + + + + Rig creator allows changing of all rig features and adding new rig profiles + + + Enable Rig Creator Feature (use with care) + + + @@ -1211,8 +1245,8 @@ 0 0 - 925 - 332 + 453 + 235 diff --git a/udpbase.h b/udpbase.h index de13019..31f2fca 100644 --- a/udpbase.h +++ b/udpbase.h @@ -24,20 +24,6 @@ #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 { QString ipAddress; quint16 controlLANPort; diff --git a/wfmain.cpp b/wfmain.cpp index 1551787..c5acdf0 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -177,11 +177,6 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode loadSettings(); // Look for saved preferences - // 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 setTuningSteps(); // TODO: Combine into preferences @@ -293,13 +288,6 @@ wfmain::~wfmain() delete rigCtl; } - if (audioDev != Q_NULLPTR) { - delete audioDev; - } - - if (prefs.audioSystem == portAudio) { - Pa_Terminate(); - } delete rpt; delete ui; delete settings; @@ -321,6 +309,22 @@ wfmain::~wfmain() void wfmain::closeEvent(QCloseEvent *event) { + + if (prefs.settingsChanged) + { + // Settings have changed since last save + qInfo() << "Settings have changed since last save"; + int reply = QMessageBox::question(this,"wfview","Settings have changed since last save, exit anyway?",QMessageBox::Save | QMessageBox::No |QMessageBox::Yes); + if (reply == QMessageBox::Save) + { + saveSettings(); + } else if (reply == QMessageBox::No) + { + event->ignore(); + return; + } + } + // Are you sure? if (!prefs.confirmExit) { QApplication::exit(); @@ -374,9 +378,6 @@ void wfmain::openRig() // showRigSettings(); // rig setting dialog box for network/serial, CIV, hostname, port, baud rate, serial device, etc // TODO: How do we know if the setting was loaded? - ui->audioSystemServerCombo->setEnabled(false); - ui->audioSystemCombo->setEnabled(false); - ui->connectBtn->setText("Cancel connection"); // We are attempting to connect makeRig(); @@ -387,7 +388,7 @@ void wfmain::openRig() usingLAN = true; // We need to setup the tx/rx audio: udpPrefs.waterfallFormat = prefs.waterfallFormat; - emit sendCommSetup(rigList, prefs.radioCIVAddr, udpPrefs, rxSetup, txSetup, prefs.virtualSerialPort, prefs.tcpPort); + emit sendCommSetup(rigList, prefs.radioCIVAddr, udpPrefs, prefs.rxSetup, prefs.txSetup, prefs.virtualSerialPort, prefs.tcpPort); } else { ui->serialEnableBtn->setChecked(true); if( (prefs.serialPortRadio.toLower() == QString("auto"))) @@ -1240,9 +1241,6 @@ void wfmain::setupMainUI() ui->monitorSlider->setTickInterval(100); ui->monitorSlider->setSingleStep(10); - //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 @@ -1480,9 +1478,6 @@ void wfmain::setInitialTiming() delayedCmdStartupInterval_ms = 250; // interval for rigID polling delayedCommand = new QTimer(this); queue->interval(delayedCmdStartupInterval_ms); - delayedCommand->setInterval(delayedCmdStartupInterval_ms); // 250ms until we find rig civ and id, then 100ms. - delayedCommand->setSingleShot(false); - connect(delayedCommand, SIGNAL(timeout()), this, SLOT(sendRadioCommandLoop())); pttTimer = new QTimer(this); pttTimer->setInterval(180*1000); // 3 minute max transmit time in ms @@ -1601,7 +1596,8 @@ void wfmain::setUIToPrefs() } ui->colorPresetCombo->setCurrentIndex(prefs.currentColorPresetNumber); - loadColorPresetToUIandPlots(prefs.currentColorPresetNumber); + // TODO Load Initial color preset + //loadColorPresetToUIandPlots(prefs.currentColorPresetNumber); ui->wfthemeCombo->setCurrentIndex(ui->wfthemeCombo->findData(prefs.wftheme)); colorMap->setGradient(static_cast(prefs.wftheme)); @@ -2245,6 +2241,10 @@ void wfmain::loadSettings() prefs.meter2Type = static_cast(settings->value("Meter2Type", defPrefs.meter2Type).toInt()); prefs.clickDragTuningEnable = settings->value("ClickDragTuning", false).toBool(); ui->clickDragTuningEnableChk->setChecked(prefs.clickDragTuningEnable); + + prefs.rigCreatorEnable = settings->value("RigCreator",false).toBool(); + ui->rigCreatorBtn->setEnabled(prefs.rigCreatorEnable); + settings->endGroup(); // Load in the color presets. The default values are already loaded. @@ -2350,17 +2350,10 @@ void wfmain::loadSettings() prefs.localAFgain = (unsigned char)settings->value("localAFgain", defPrefs.localAFgain).toUInt(); - rxSetup.localAFgain = prefs.localAFgain; - txSetup.localAFgain = 255; + prefs.rxSetup.localAFgain = prefs.localAFgain; + prefs.txSetup.localAFgain = 255; prefs.audioSystem = static_cast(settings->value("AudioSystem", defPrefs.audioSystem).toInt()); - 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); - settings->endGroup(); @@ -2405,91 +2398,33 @@ void wfmain::loadSettings() ui->waterfallFormatCombo->blockSignals(false); udpPrefs.ipAddress = settings->value("IPAddress", udpDefPrefs.ipAddress).toString(); - ui->ipAddressTxt->setEnabled(ui->lanEnableBtn->isChecked()); - ui->ipAddressTxt->setText(udpPrefs.ipAddress); - udpPrefs.controlLANPort = settings->value("ControlLANPort", udpDefPrefs.controlLANPort).toInt(); - ui->controlPortTxt->setEnabled(ui->lanEnableBtn->isChecked()); - ui->controlPortTxt->setText(QString("%1").arg(udpPrefs.controlLANPort)); - udpPrefs.username = settings->value("Username", udpDefPrefs.username).toString(); - ui->usernameTxt->setEnabled(ui->lanEnableBtn->isChecked()); - ui->usernameTxt->setText(QString("%1").arg(udpPrefs.username)); - udpPrefs.password = settings->value("Password", udpDefPrefs.password).toString(); - ui->passwordTxt->setEnabled(ui->lanEnableBtn->isChecked()); - ui->passwordTxt->setText(QString("%1").arg(udpPrefs.password)); + prefs.rxSetup.isinput = false; + prefs.txSetup.isinput = true; + prefs.rxSetup.latency = settings->value("AudioRXLatency", "150").toInt(); + prefs.txSetup.latency = settings->value("AudioTXLatency", "150").toInt(); - rxSetup.isinput = false; - txSetup.isinput = true; + prefs.rxSetup.sampleRate=settings->value("AudioRXSampleRate", "48000").toInt(); + prefs.txSetup.sampleRate=prefs.rxSetup.sampleRate; - rxSetup.latency = settings->value("AudioRXLatency", "150").toInt(); - ui->rxLatencySlider->setEnabled(ui->lanEnableBtn->isChecked()); - ui->rxLatencySlider->setValue(rxSetup.latency); - ui->rxLatencySlider->setTracking(false); // Stop it sending value on every change. + prefs.rxSetup.codec = settings->value("AudioRXCodec", "4").toInt(); + prefs.txSetup.codec = settings->value("AudioTXCodec", "4").toInt(); + prefs.rxSetup.name = settings->value("AudioOutput", "Default Output Device").toString(); + qInfo(logGui()) << "Got Audio Output from Settings: " << prefs.rxSetup.name; - txSetup.latency = settings->value("AudioTXLatency", "150").toInt(); - ui->txLatencySlider->setEnabled(ui->lanEnableBtn->isChecked()); - ui->txLatencySlider->setValue(txSetup.latency); - ui->txLatencySlider->setTracking(false); // Stop it sending value on every change. + prefs.txSetup.name = settings->value("AudioInput", "Default Input Device").toString(); + qInfo(logGui()) << "Got Audio Input from Settings: " << prefs.txSetup.name; - ui->audioSampleRateCombo->blockSignals(true); - rxSetup.sampleRate=settings->value("AudioRXSampleRate", "48000").toInt(); - txSetup.sampleRate=rxSetup.sampleRate; - - ui->audioSampleRateCombo->setEnabled(ui->lanEnableBtn->isChecked()); - int audioSampleRateIndex = ui->audioSampleRateCombo->findText(QString::number(rxSetup.sampleRate)); - if (audioSampleRateIndex != -1) { - ui->audioSampleRateCombo->setCurrentIndex(audioSampleRateIndex); - } - ui->audioSampleRateCombo->blockSignals(false); - - // Add codec combobox items here so that we can add userdata! - 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(true); - rxSetup.codec = settings->value("AudioRXCodec", "4").toInt(); - ui->audioRXCodecCombo->setEnabled(ui->lanEnableBtn->isChecked()); - for (int f = 0; f < ui->audioRXCodecCombo->count(); f++) - if (ui->audioRXCodecCombo->itemData(f).toInt() == rxSetup.codec) - ui->audioRXCodecCombo->setCurrentIndex(f); - ui->audioRXCodecCombo->blockSignals(false); - - 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->audioRXCodecCombo->blockSignals(true); - txSetup.codec = settings->value("AudioTXCodec", "4").toInt(); - ui->audioTXCodecCombo->setEnabled(ui->lanEnableBtn->isChecked()); - for (int f = 0; f < ui->audioTXCodecCombo->count(); f++) - if (ui->audioTXCodecCombo->itemData(f).toInt() == txSetup.codec) - ui->audioTXCodecCombo->setCurrentIndex(f); - ui->audioRXCodecCombo->blockSignals(false); - - rxSetup.name = settings->value("AudioOutput", "Default Output Device").toString(); - qInfo(logGui()) << "Got Audio Output from Settings: " << rxSetup.name; - - txSetup.name = settings->value("AudioInput", "Default Input Device").toString(); - qInfo(logGui()) << "Got Audio Input from Settings: " << txSetup.name; - - - rxSetup.resampleQuality = settings->value("ResampleQuality", "4").toInt(); - txSetup.resampleQuality = rxSetup.resampleQuality; + prefs.rxSetup.resampleQuality = settings->value("ResampleQuality", "4").toInt(); + prefs.txSetup.resampleQuality = prefs.rxSetup.resampleQuality; udpPrefs.clientName = settings->value("ClientName", udpDefPrefs.clientName).toString(); udpPrefs.halfDuplex = settings->value("HalfDuplex", udpDefPrefs.halfDuplex).toBool(); - ui->audioDuplexCombo->setVisible(false); - ui->label_51->setVisible(false); + //ui->audioDuplexCombo->setVisible(false); + //ui->label_51->setVisible(false); settings->endGroup(); @@ -2859,9 +2794,11 @@ void wfmain::loadSettings() #endif setupui->acceptPreferencesPtr(&prefs); + setupui->acceptColorPresetPtr(colorPreset); setupui->updateIfPrefs((int)if_all); + setupui->updateColPrefs((int)col_all); setupui->updateRaPrefs((int)ra_all); - setupui->updateRsPrefs((int)ra_all); // Most of these come from the rig anyway + setupui->updateRsPrefs((int)rs_all); // Most of these come from the rig anyway setupui->updateCtPrefs((int)ct_all); setupui->updateClusterPrefs((int)cl_all); setupui->updateLanPrefs((int)l_all); @@ -2869,6 +2806,7 @@ void wfmain::loadSettings() setupui->acceptUdpPreferencesPtr(&udpPrefs); setupui->updateUdpPrefs((int)u_all); + prefs.settingsChanged = false; } void wfmain::extChangedIfPrefs(quint64 items) @@ -3017,6 +2955,7 @@ void wfmain::extChangedUdpPrefs(quint64 items) void wfmain::extChangedIfPref(prefIfItem i) { + prefs.settingsChanged = true; switch(i) { case if_useFullScreen: @@ -3079,9 +3018,16 @@ void wfmain::extChangedIfPref(prefIfItem i) // There's nothing to do here since the code // already uses the preference variable as state. break; + case if_rigCreatorEnable: + ui->rigCreatorBtn->setEnabled(prefs.rigCreatorEnable); + break; case if_currentColorPresetNumber: + { + colorPrefsType p = colorPreset[prefs.currentColorPresetNumber]; + useColorPreset(&p); // TODO..... break; + } default: qWarning(logSystem()) << "Did not understand if pref update in wfmain for item " << (int)i; break; @@ -3090,9 +3036,80 @@ void wfmain::extChangedIfPref(prefIfItem i) void wfmain::extChangedColPref(prefColItem i) { + prefs.settingsChanged = true; + colorPrefsType* cp = &colorPreset[prefs.currentColorPresetNumber]; + + // These are all updated by the widget itself switch(i) { case col_grid: + plot->xAxis->grid()->setPen(cp->gridColor); + plot->yAxis->grid()->setPen(cp->gridColor); + break; + case col_axis: + plot->xAxis->setBasePen(cp->axisColor); + plot->xAxis->setTickPen(cp->axisColor); + plot->yAxis->setBasePen(cp->axisColor); + plot->yAxis->setTickPen(cp->axisColor); + break; + case col_text: + plot->xAxis->setTickLabelColor(cp->textColor); + plot->yAxis->setTickLabelColor(cp->textColor); + break; + case col_plotBackground: + plot->setBackground(cp->plotBackground); + break; + case col_spectrumLine: + plot->graph(0)->setPen(QPen(cp->spectrumLine)); + break; + case col_spectrumFill: + plot->graph(0)->setBrush(QBrush(cp->spectrumFill)); + break; + case col_underlayLine: + plot->graph(1)->setPen(QPen(cp->underlayLine)); + break; + case col_underlayFill: + plot->graph(1)->setBrush(QBrush(cp->underlayFill)); + break; + case col_tuningLine: + freqIndicatorLine->setPen(QPen(cp->tuningLine)); + break; + case col_passband: + passbandIndicator->setPen(QPen(cp->passband)); + passbandIndicator->setBrush(QBrush(cp->passband)); + break; + case col_pbtIndicator: + pbtIndicator->setPen(QPen(cp->pbt)); + pbtIndicator->setBrush(QBrush(cp->pbt)); + break; + case col_meterLevel: + case col_meterAverage: + case col_meterPeakLevel: + case col_meterHighScale: + case col_meterScale: + case col_meterText: + ui->meterSPoWidget->setColors(cp->meterLevel, cp->meterPeakScale, cp->meterPeakLevel, cp->meterAverage, cp->meterLowerLine, cp->meterLowText); + ui->meter2Widget->setColors(cp->meterLevel, cp->meterPeakScale, cp->meterPeakLevel, cp->meterAverage, cp->meterLowerLine, cp->meterLowText); + break; + case col_waterfallBack: + wf->setBackground(cp->wfBackground); + break; + case col_waterfallGrid: + wf->xAxis->setLabelColor(cp->wfGrid); + wf->yAxis->setLabelColor(cp->wfGrid); + break; + case col_waterfallAxis: + wf->yAxis->setBasePen(cp->wfAxis); + wf->yAxis->setTickPen(cp->wfAxis); + wf->xAxis->setBasePen(cp->wfAxis); + wf->xAxis->setTickPen(cp->wfAxis); + break; + case col_waterfallText: + wf->xAxis->setTickLabelColor(cp->wfText); + wf->yAxis->setTickLabelColor(cp->wfText); + break; + case col_clusterSpots: + clusterColor = cp->clusterSpots; break; default: qWarning(logSystem()) << "Cannot update wfmain col pref" << (int)i; @@ -3101,6 +3118,7 @@ void wfmain::extChangedColPref(prefColItem i) void wfmain::extChangedRaPref(prefRaItem i) { + prefs.settingsChanged = true; // Radio Access Prefs switch(i) { @@ -3142,8 +3160,7 @@ void wfmain::extChangedRaPref(prefRaItem i) // Not handled here. break; case ra_audioSystem: - audioDev->setAudioType(prefs.audioSystem); - audioDev->enumerate(); + // Not handled here break; default: qWarning(logSystem()) << "Cannot update wfmain ra pref" << (int)i; @@ -3152,6 +3169,7 @@ void wfmain::extChangedRaPref(prefRaItem i) void wfmain::extChangedRsPref(prefRsItem i) { + prefs.settingsChanged = true; // Radio Settings prefs switch(i) { @@ -3173,6 +3191,7 @@ void wfmain::extChangedRsPref(prefRsItem i) void wfmain::extChangedCtPref(prefCtItem i) { + prefs.settingsChanged = true; switch(i) { case ct_enablePTT: @@ -3196,6 +3215,7 @@ void wfmain::extChangedCtPref(prefCtItem i) void wfmain::extChangedLanPref(prefLanItem i) { + prefs.settingsChanged = true; switch(i) { case l_enableLAN: @@ -3220,6 +3240,7 @@ void wfmain::extChangedLanPref(prefLanItem i) void wfmain::extChangedClusterPref(prefClusterItem i) { + prefs.settingsChanged = true; switch(i) { case cl_clusterUdpEnable: @@ -3259,6 +3280,7 @@ void wfmain::extChangedClusterPref(prefClusterItem i) void wfmain::extChangedUdpPref(udpPrefsItem i) { + prefs.settingsChanged = true; switch(i) { case u_ipAddress: @@ -3283,6 +3305,22 @@ void wfmain::extChangedUdpPref(udpPrefsItem i) break; case u_halfDuplex: break; + case u_sampleRate: + break; + case u_rxCodec: + break; + case u_txCodec: + break; + case u_rxLatency: + // Should be updated immediately + emit sendChangeLatency(prefs.rxSetup.latency); + break; + case u_txLatency: + break; + case u_audioInput: + break; + case u_audioOutput: + break; default: qWarning(logGui()) << "Did not find matching pref element in wfmain for UDP pref item " << (int)i; break; @@ -3423,40 +3461,6 @@ void wfmain::on_serverAudioPortText_textChanged(QString text) serverConfig.audioPort = text.toInt(); } -void wfmain::changedServerRXAudioInput(int value) -{ - - if (!serverConfig.rigs.isEmpty() && value>=0) - { - if (prefs.audioSystem == qtAudio) { - serverConfig.rigs.first()->rxAudioSetup.port = audioDev->getInputDeviceInfo(value); - } - else { - serverConfig.rigs.first()->rxAudioSetup.portInt = audioDev->getInputDeviceInt(value); - } - - serverConfig.rigs.first()->rxAudioSetup.name = audioDev->getInputName(value); - } - -} - -void wfmain::changedServerTXAudioOutput(int value) -{ - - if (!serverConfig.rigs.isEmpty() && value>=0) - { - if (prefs.audioSystem == qtAudio) { - serverConfig.rigs.first()->txAudioSetup.port = audioDev->getOutputDeviceInfo(value); - } - else { - serverConfig.rigs.first()->txAudioSetup.portInt = audioDev->getOutputDeviceInt(value); - } - - serverConfig.rigs.first()->txAudioSetup.name = audioDev->getOutputName(value); - } - - -} void wfmain::changedModInput(uchar val, inputTypes type) { @@ -3503,6 +3507,7 @@ void wfmain::saveSettings() qInfo(logSystem()) << "Saving settings to " << settings->fileName(); // Basic things to load: + prefs.settingsChanged = false; QString versionstr = QString(WFVIEW_VERSION); QString majorVersion = "-1"; @@ -3542,6 +3547,7 @@ void wfmain::saveSettings() settings->setValue("ConfirmPowerOff", prefs.confirmPowerOff); settings->setValue("Meter2Type", (int)prefs.meter2Type); settings->setValue("ClickDragTuning", prefs.clickDragTuningEnable); + settings->setValue("RigCreator",prefs.rigCreatorEnable); settings->endGroup(); @@ -3578,15 +3584,15 @@ void wfmain::saveSettings() settings->setValue("AudioLANPort", udpPrefs.audioLANPort); settings->setValue("Username", udpPrefs.username); settings->setValue("Password", udpPrefs.password); - settings->setValue("AudioRXLatency", rxSetup.latency); - settings->setValue("AudioTXLatency", txSetup.latency); - settings->setValue("AudioRXSampleRate", rxSetup.sampleRate); - settings->setValue("AudioRXCodec", rxSetup.codec); - settings->setValue("AudioTXSampleRate", txSetup.sampleRate); - settings->setValue("AudioTXCodec", txSetup.codec); - settings->setValue("AudioOutput", rxSetup.name); - settings->setValue("AudioInput", txSetup.name); - settings->setValue("ResampleQuality", rxSetup.resampleQuality); + settings->setValue("AudioRXLatency", prefs.rxSetup.latency); + settings->setValue("AudioTXLatency", prefs.txSetup.latency); + settings->setValue("AudioRXSampleRate", prefs.rxSetup.sampleRate); + settings->setValue("AudioRXCodec", prefs.rxSetup.codec); + settings->setValue("AudioTXSampleRate", prefs.txSetup.sampleRate); + settings->setValue("AudioTXCodec", prefs.txSetup.codec); + settings->setValue("AudioOutput", prefs.rxSetup.name); + settings->setValue("AudioInput", prefs.txSetup.name); + settings->setValue("ResampleQuality", prefs.rxSetup.resampleQuality); settings->setValue("ClientName", udpPrefs.clientName); settings->setValue("WaterfallFormat", prefs.waterfallFormat); settings->setValue("HalfDuplex", udpPrefs.halfDuplex); @@ -4767,8 +4773,8 @@ void wfmain::receiveRigID(rigCapabilities rigCaps) //ui->useRTSforPTTchk->setChecked(prefs.forceRTSasPTT); - ui->audioSystemCombo->setEnabled(false); - ui->audioSystemServerCombo->setEnabled(false); + // ui->audioSystemCombo->setEnabled(false); + //ui->audioSystemServerCombo->setEnabled(false); ui->connectBtn->setText("Disconnect from Radio"); // We must be connected now. @@ -5985,7 +5991,7 @@ void wfmain::on_afGainSlider_valueChanged(int value) { if(usingLAN) { - rxSetup.localAFgain = (unsigned char)(value); + prefs.rxSetup.localAFgain = (unsigned char)(value); prefs.localAFgain = (unsigned char)(value); emit setAfGain(value); emit sendLevel(cmdGetAfGain,value); @@ -6130,152 +6136,6 @@ void wfmain::receiveATUStatus(unsigned char atustatus) } } -void wfmain::on_serialEnableBtn_clicked(bool checked) -{ - // migrated, can be removed entirely - prefs.enableLAN = !checked; - ui->serialDeviceListCombo->setEnabled(checked); - - ui->connectBtn->setEnabled(true); - 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); - -} - -void wfmain::on_lanEnableBtn_clicked(bool checked) -{ - // Migrated, can be removed entirely - prefs.enableLAN = checked; - ui->connectBtn->setEnabled(true); - 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); - if(checked) - { - showStatusBarText("After filling in values, press Save Settings."); - } -} - -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::changedAudioInput(int value) -{ - // TODO: Change function name, send value from setupui to here. - - if (value>=0) { - if (prefs.audioSystem == qtAudio) { - rxSetup.port = audioDev->getOutputDeviceInfo(value); - } - else { - rxSetup.portInt = audioDev->getOutputDeviceInt(value); - } - - rxSetup.name = audioDev->getOutputName(value); - } - qDebug(logGui()) << "Changed audio output to:" << rxSetup.name; -} - -void wfmain::changedAudioOutput(int value) -{ - if (value >=0) { - if (prefs.audioSystem == qtAudio) { - txSetup.port = audioDev->getInputDeviceInfo(value); - } - else { - txSetup.portInt = audioDev->getInputDeviceInt(value); - } - - txSetup.name = audioDev->getInputName(value); - } - qDebug(logGui()) << "Changed audio input to:" << txSetup.name; -} - -void wfmain::on_audioSampleRateCombo_currentIndexChanged(int value) -{ - rxSetup.sampleRate= ui->audioSampleRateCombo->itemText(value).toInt(); - txSetup.sampleRate= ui->audioSampleRateCombo->itemText(value).toInt(); -} - -void wfmain::on_audioRXCodecCombo_currentIndexChanged(int value) -{ - rxSetup.codec = ui->audioRXCodecCombo->itemData(value).toInt(); -} - -void wfmain::on_audioTXCodecCombo_currentIndexChanged(int value) -{ - txSetup.codec = ui->audioTXCodecCombo->itemData(value).toInt(); -} - -void wfmain::on_rxLatencySlider_valueChanged(int value) -{ - rxSetup.latency = value; - ui->rxLatencyValue->setText(QString::number(value)); - emit sendChangeLatency(value); -} - -void wfmain::on_txLatencySlider_valueChanged(int value) -{ - txSetup.latency = value; - ui->txLatencyValue->setText(QString::number(value)); -} - void wfmain::on_toFixedBtn_clicked() { int currentEdge = ui->scopeEdgeCombo->currentIndex(); @@ -7342,89 +7202,9 @@ void wfmain::on_radioStatusBtn_clicked() void wfmain::setAudioDevicesUI() { - // ready for cleaning - qInfo() << "Looking for inputs"; - // 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"; - // 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)); - - setupui->updateAudioOutputs(audioDev->getOutputs(), audioDev->findOutput("Client", rxSetup.name), audioDev->getNumCharsOut()); - -// 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; - - if (!serverConfig.rigs.isEmpty()) - { - 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)); - 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(); - ui->audioSystemServerCombo->blockSignals(true); - ui->audioSystemServerCombo->setCurrentIndex(value); - ui->audioSystemServerCombo->blockSignals(false); -} - -void wfmain::on_audioSystemServerCombo_currentIndexChanged(int value) -{ - // migrated - prefs.audioSystem = static_cast(value); - audioDev->setAudioType(prefs.audioSystem); - audioDev->enumerate(); - ui->audioSystemCombo->blockSignals(true); - ui->audioSystemCombo->setCurrentIndex(value); - ui->audioSystemCombo->blockSignals(false); -} void wfmain::on_topLevelSlider_valueChanged(int value) { @@ -7553,95 +7333,6 @@ void wfmain::on_debugBtn_clicked() // ---------- color helper functions: ---------- // -void wfmain::setColorElement(QColor color, - QLedLabel *led, - QLabel *label, - QLineEdit *lineText) -{ - if(led != Q_NULLPTR) - { - led->setColor(color, true); - } - if(label != Q_NULLPTR) - { - label->setText(color.name(QColor::HexArgb)); - } - if(lineText != Q_NULLPTR) - { - lineText->setText(color.name(QColor::HexArgb)); - } -} - -void wfmain::setColorElement(QColor color, QLedLabel *led, QLabel *label) -{ - setColorElement(color, led, label, Q_NULLPTR); -} - -void wfmain::setColorElement(QColor color, QLedLabel *led, QLineEdit *lineText) -{ - setColorElement(color, led, Q_NULLPTR, lineText); -} - -QColor wfmain::getColorFromPicker(QColor initialColor) -{ - QColorDialog::ColorDialogOptions options; - options.setFlag(QColorDialog::ShowAlphaChannel, true); - options.setFlag(QColorDialog::DontUseNativeDialog, true); - QColor selColor = QColorDialog::getColor(initialColor, this, "Select Color", options); - int alphaVal = 0; - bool ok = false; - - if (selColor.isValid()) - { - if (selColor.alpha() == 0) - { - alphaVal = QInputDialog::getInt(this, tr("Specify Opacity"), - tr("You specified an opacity value of 0. \nDo you want to change it? (0=transparent, 255=opaque)"), 0, 0, 255, 1, - &ok); - if (!ok) - { - return selColor; - } - else { - selColor.setAlpha(alphaVal); - return selColor; - } - } - return selColor; - } - else - return initialColor; -} - -void wfmain::getSetColor(QLedLabel *led, QLabel *label) -{ - QColor selColor = getColorFromPicker(led->getColor()); - setColorElement(selColor, led, label); -} - -void wfmain::getSetColor(QLedLabel *led, QLineEdit *line) -{ - QColor selColor = getColorFromPicker(led->getColor()); - setColorElement(selColor, led, line); -} - -QString wfmain::setColorFromString(QString colorstr, QLedLabel *led) -{ - if(led==Q_NULLPTR) - return "ERROR"; - - if(!colorstr.startsWith("#")) - { - colorstr.prepend("#"); - } - if(colorstr.length() != 9) - { - // TODO: Tell user about AA RR GG BB - return led->getColor().name(QColor::HexArgb); - } - led->setColor(colorstr, true); - return led->getColor().name(QColor::HexArgb); -} void wfmain::useCurrentColorPreset() { @@ -7710,67 +7401,6 @@ void wfmain::useColorPreset(colorPrefsType *cp) clusterColor = cp->clusterSpots; } -void wfmain::setColorButtonOperations(QColor *colorStore, - QLineEdit *e, QLedLabel *d) -{ - // Call this function with a pointer into the colorPreset color you - // wish to edit. - - if(colorStore==Q_NULLPTR) - { - qInfo(logSystem()) << "ERROR, invalid pointer to color received."; - return; - } - getSetColor(d, e); - QColor t = d->getColor(); - colorStore->setNamedColor(t.name(QColor::HexArgb)); - useCurrentColorPreset(); -} - -void wfmain::setColorLineEditOperations(QColor *colorStore, - QLineEdit *e, QLedLabel *d) -{ - // Call this function with a pointer into the colorPreset color you - // wish to edit. - if(colorStore==Q_NULLPTR) - { - qInfo(logSystem()) << "ERROR, invalid pointer to color received."; - return; - } - - QString colorStrValidated = setColorFromString(e->text(), d); - e->setText(colorStrValidated); - colorStore->setNamedColor(colorStrValidated); - useCurrentColorPreset(); -} - -void wfmain::on_colorPopOutBtn_clicked() -{ - - if (settingsTabisAttached) - { - settingsTab = ui->tabWidget->currentWidget(); - ui->tabWidget->removeTab(ui->tabWidget->indexOf(settingsTab)); - settingsWidgetTab->addTab(settingsTab, "Settings"); - settingsWidgetWindow->show(); - ui->colorPopOutBtn->setText("Re-attach"); - ui->clusterPopOutBtn->setText("Re-attach"); - ui->tabWidget->setCurrentIndex(0); - settingsTabisAttached = false; - } - else { - settingsTab = settingsWidgetTab->currentWidget(); - - settingsWidgetTab->removeTab(settingsWidgetTab->indexOf(settingsTab)); - ui->tabWidget->addTab(settingsTab, "Settings"); - settingsWidgetWindow->close(); - - ui->colorPopOutBtn->setText("Pop-Out"); - ui->clusterPopOutBtn->setText("Pop-Out"); - ui->tabWidget->setCurrentIndex(3); - settingsTabisAttached = true; - } -} void wfmain::setDefaultColorPresets() { @@ -7782,458 +7412,7 @@ void wfmain::setDefaultColorPresets() } } -void wfmain::setEditAndLedFromColor(QColor c, QLineEdit *e, QLedLabel *d) -{ - bool blockSignals = true; - if(e != Q_NULLPTR) - { - e->blockSignals(blockSignals); - e->setText(c.name(QColor::HexArgb)); - e->blockSignals(false); - } - if(d != Q_NULLPTR) - { - d->setColor(c); - } -} -void wfmain::loadColorPresetToUIandPlots(int presetNumber) -{ - if(presetNumber >= numColorPresetsTotal) - { - qDebug(logSystem()) << "WARNING: asked for preset number [" << presetNumber << "], which is out of range."; - return; - } - - colorPrefsType p = colorPreset[presetNumber]; - //qInfo(logSystem()) << "color preset number [" << presetNumber << "] requested for UI load, which has internal index of [" << p.presetNum << "]"; - setEditAndLedFromColor(p.gridColor, ui->colorEditGrid, ui->colorSwatchGrid); - setEditAndLedFromColor(p.axisColor, ui->colorEditAxis, ui->colorSwatchAxis); - setEditAndLedFromColor(p.textColor, ui->colorEditText, ui->colorSwatchText); - setEditAndLedFromColor(p.spectrumLine, ui->colorEditSpecLine, ui->colorSwatchSpecLine); - setEditAndLedFromColor(p.spectrumFill, ui->colorEditSpecFill, ui->colorSwatchSpecFill); - setEditAndLedFromColor(p.underlayLine, ui->colorEditUnderlayLine, ui->colorSwatchUnderlayLine); - setEditAndLedFromColor(p.underlayFill, ui->colorEditUnderlayFill, ui->colorSwatchUnderlayFill); - setEditAndLedFromColor(p.plotBackground, ui->colorEditPlotBackground, ui->colorSwatchPlotBackground); - setEditAndLedFromColor(p.tuningLine, ui->colorEditTuningLine, ui->colorSwatchTuningLine); - setEditAndLedFromColor(p.passband, ui->colorEditPassband, ui->colorSwatchPassband); - setEditAndLedFromColor(p.pbt, ui->colorEditPBT, ui->colorSwatchPBT); - - setEditAndLedFromColor(p.meterLevel, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); - setEditAndLedFromColor(p.meterAverage, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); - setEditAndLedFromColor(p.meterPeakLevel, ui->colorEditMeterPeakLevel, ui->colorSwatchMeterPeakLevel); - setEditAndLedFromColor(p.meterPeakScale, ui->colorEditMeterPeakScale, ui->colorSwatchMeterPeakScale); - setEditAndLedFromColor(p.meterLowerLine, ui->colorEditMeterScale, ui->colorSwatchMeterScale); - setEditAndLedFromColor(p.meterLowText, ui->colorEditMeterText, ui->colorSwatchMeterText); - - setEditAndLedFromColor(p.wfBackground, ui->colorEditWfBackground, ui->colorSwatchWfBackground); - setEditAndLedFromColor(p.wfGrid, ui->colorEditWfGrid, ui->colorSwatchWfGrid); - setEditAndLedFromColor(p.wfAxis, ui->colorEditWfAxis, ui->colorSwatchWfAxis); - setEditAndLedFromColor(p.wfText, ui->colorEditWfText, ui->colorSwatchWfText); - - setEditAndLedFromColor(p.clusterSpots, ui->colorEditClusterSpots, ui->colorSwatchClusterSpots); - - useColorPreset(&p); -} - -void wfmain::on_colorRenamePresetBtn_clicked() -{ - int p = ui->colorPresetCombo->currentIndex(); - QString newName; - QMessageBox msgBox; - - bool ok = false; - newName = QInputDialog::getText(this, tr("Rename Preset"), - tr("Preset Name (10 characters max):"), QLineEdit::Normal, - ui->colorPresetCombo->currentText(), &ok); - if(!ok) - return; - - if(ok && (newName.length() < 11) && !newName.isEmpty()) - { - colorPreset[p].presetName->clear(); - colorPreset[p].presetName->append(newName); - ui->colorPresetCombo->setItemText(p, *(colorPreset[p].presetName)); - } else { - if(newName.isEmpty() || (newName.length() > 10)) - { - msgBox.setText("Error, name must be at least one character and not exceed 10 characters."); - msgBox.exec(); - } - } -} - -void wfmain::on_colorPresetCombo_currentIndexChanged(int index) -{ - prefs.currentColorPresetNumber = index; - loadColorPresetToUIandPlots(index); -} - -void wfmain::on_colorRevertPresetBtn_clicked() -{ - int pn = ui->colorPresetCombo->currentIndex(); - setDefaultColors(pn); - loadColorPresetToUIandPlots(pn); -} - -// ---------- end color helper functions ---------- // - -// ---------- Color UI slots ----------// - -// Grid: -void wfmain::on_colorSetBtnGrid_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].gridColor); - setColorButtonOperations(c, ui->colorEditGrid, ui->colorSwatchGrid); -} -void wfmain::on_colorEditGrid_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].gridColor); - setColorLineEditOperations(c, ui->colorEditGrid, ui->colorSwatchGrid); -} - -// Axis: -void wfmain::on_colorSetBtnAxis_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].axisColor); - setColorButtonOperations(c, ui->colorEditAxis, ui->colorSwatchAxis); -} -void wfmain::on_colorEditAxis_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].axisColor); - setColorLineEditOperations(c, ui->colorEditAxis, ui->colorSwatchAxis); -} - -// Text: -void wfmain::on_colorSetBtnText_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].textColor); - setColorButtonOperations(c, ui->colorEditText, ui->colorSwatchText); -} -void wfmain::on_colorEditText_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].textColor); - setColorLineEditOperations(c, ui->colorEditText, ui->colorSwatchText); -} - -// SpecLine: -void wfmain::on_colorEditSpecLine_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].spectrumLine); - setColorLineEditOperations(c, ui->colorEditSpecLine, ui->colorSwatchSpecLine); -} -void wfmain::on_colorSetBtnSpecLine_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].spectrumLine); - setColorButtonOperations(c, ui->colorEditSpecLine, ui->colorSwatchSpecLine); -} - -// SpecFill: -void wfmain::on_colorSetBtnSpecFill_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].spectrumFill); - setColorButtonOperations(c, ui->colorEditSpecFill, ui->colorSwatchSpecFill); -} -void wfmain::on_colorEditSpecFill_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].spectrumFill); - setColorLineEditOperations(c, ui->colorEditSpecFill, ui->colorSwatchSpecFill); -} - -// PlotBackground: -void wfmain::on_colorEditPlotBackground_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].plotBackground); - setColorLineEditOperations(c, ui->colorEditPlotBackground, ui->colorSwatchPlotBackground); -} -void wfmain::on_colorSetBtnPlotBackground_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].plotBackground); - setColorButtonOperations(c, ui->colorEditPlotBackground, ui->colorSwatchPlotBackground); -} - -// Underlay Line: -void wfmain::on_colorSetBtnUnderlayLine_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].underlayLine); - setColorButtonOperations(c, ui->colorEditUnderlayLine, ui->colorSwatchUnderlayLine); -} - -void wfmain::on_colorEditUnderlayLine_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].underlayLine); - setColorLineEditOperations(c, ui->colorEditUnderlayLine, ui->colorSwatchUnderlayLine); -} - -// Underlay Fill: -void wfmain::on_colorSetBtnUnderlayFill_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].underlayFill); - setColorButtonOperations(c, ui->colorEditUnderlayFill, ui->colorSwatchUnderlayFill); -} -void wfmain::on_colorEditUnderlayFill_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].underlayFill); - setColorLineEditOperations(c, ui->colorEditUnderlayFill, ui->colorSwatchUnderlayFill); -} - -// WF Background: -void wfmain::on_colorSetBtnwfBackground_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].wfBackground); - setColorButtonOperations(c, ui->colorEditWfBackground, ui->colorSwatchWfBackground); -} -void wfmain::on_colorEditWfBackground_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].wfBackground); - setColorLineEditOperations(c, ui->colorEditWfBackground, ui->colorSwatchWfBackground); -} - -// WF Grid: -void wfmain::on_colorSetBtnWfGrid_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].wfGrid); - setColorButtonOperations(c, ui->colorEditWfGrid, ui->colorSwatchWfGrid); -} -void wfmain::on_colorEditWfGrid_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].wfGrid); - setColorLineEditOperations(c, ui->colorEditWfGrid, ui->colorSwatchWfGrid); -} - -// WF Axis: -void wfmain::on_colorSetBtnWfAxis_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].wfAxis); - setColorButtonOperations(c, ui->colorEditWfAxis, ui->colorSwatchWfAxis); -} -void wfmain::on_colorEditWfAxis_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].wfAxis); - setColorLineEditOperations(c, ui->colorEditWfAxis, ui->colorSwatchWfAxis); -} - -// WF Text: -void wfmain::on_colorSetBtnWfText_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].wfText); - setColorButtonOperations(c, ui->colorEditWfText, ui->colorSwatchWfText); -} - -void wfmain::on_colorEditWfText_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].wfText); - setColorLineEditOperations(c, ui->colorEditWfText, ui->colorSwatchWfText); -} - -// Tuning Line: -void wfmain::on_colorSetBtnTuningLine_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].tuningLine); - setColorButtonOperations(c, ui->colorEditTuningLine, ui->colorSwatchTuningLine); -} -void wfmain::on_colorEditTuningLine_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].tuningLine); - setColorLineEditOperations(c, ui->colorEditTuningLine, ui->colorSwatchTuningLine); -} - -// Passband: -void wfmain::on_colorSetBtnPassband_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].passband); - setColorButtonOperations(c, ui->colorEditPassband, ui->colorSwatchPassband); -} - -void wfmain::on_colorEditPassband_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].passband); - setColorLineEditOperations(c, ui->colorEditPassband, ui->colorSwatchPassband); -} - -void wfmain::on_colorSetBtnPBT_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].pbt); - setColorButtonOperations(c, ui->colorEditPBT, ui->colorSwatchPBT); -} - -void wfmain::on_colorEditPBT_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].pbt); - setColorLineEditOperations(c, ui->colorEditPBT, ui->colorSwatchPBT); -} - -// Meter Level: -void wfmain::on_colorSetBtnMeterLevel_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterLevel); - setColorButtonOperations(c, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); -} -void wfmain::on_colorEditMeterLevel_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterLevel); - setColorLineEditOperations(c, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); -} - -// Meter Average: -void wfmain::on_colorSetBtnMeterAvg_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterAverage); - setColorButtonOperations(c, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); -} -void wfmain::on_colorEditMeterAvg_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterAverage); - setColorLineEditOperations(c, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); -} - -// Meter Peak Level: -void wfmain::on_colorSetBtnMeterPeakLevel_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterPeakLevel); - setColorButtonOperations(c, ui->colorEditMeterPeakLevel, ui->colorSwatchMeterPeakLevel); -} -void wfmain::on_colorEditMeterPeakLevel_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterPeakLevel); - setColorLineEditOperations(c, ui->colorEditMeterPeakLevel, ui->colorSwatchMeterPeakLevel); -} - -// Meter Peak Scale: -void wfmain::on_colorSetBtnMeterPeakScale_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterPeakScale); - setColorButtonOperations(c, ui->colorEditMeterPeakScale, ui->colorSwatchMeterPeakScale); -} -void wfmain::on_colorEditMeterPeakScale_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterPeakScale); - setColorLineEditOperations(c, ui->colorEditMeterPeakScale, ui->colorSwatchMeterPeakScale); -} - -// Meter Scale (line): -void wfmain::on_colorSetBtnMeterScale_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterLowerLine); - setColorButtonOperations(c, ui->colorEditMeterScale, ui->colorSwatchMeterScale); -} -void wfmain::on_colorEditMeterScale_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterLowerLine); - setColorLineEditOperations(c, ui->colorEditMeterScale, ui->colorSwatchMeterScale); -} - -// Meter Text: -void wfmain::on_colorSetBtnMeterText_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterLowText); - setColorButtonOperations(c, ui->colorEditMeterText, ui->colorSwatchMeterText); -} -void wfmain::on_colorEditMeterText_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterLowText); - setColorLineEditOperations(c, ui->colorEditMeterText, ui->colorSwatchMeterText); -} - -// Cluster Spots: -void wfmain::on_colorSetBtnClusterSpots_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].clusterSpots); - setColorButtonOperations(c, ui->colorEditClusterSpots, ui->colorSwatchClusterSpots); -} -void wfmain::on_colorEditClusterSpots_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QColor* c = &(colorPreset[pos].clusterSpots); - setColorLineEditOperations(c, ui->colorEditClusterSpots, ui->colorSwatchClusterSpots); -} - -// ---------- End color UI slots ----------// - -void wfmain::on_colorSavePresetBtn_clicked() -{ - int pn = ui->colorPresetCombo->currentIndex(); - - settings->beginGroup("ColorPresets"); - settings->setValue("currentColorPresetNumber", prefs.currentColorPresetNumber); - settings->beginWriteArray("ColorPreset", numColorPresetsTotal); - - colorPrefsType *p; - p = &(colorPreset[pn]); - - settings->setArrayIndex(pn); - settings->setValue("presetNum", p->presetNum); - settings->setValue("presetName", *(p->presetName)); - settings->setValue("gridColor", p->gridColor.name(QColor::HexArgb)); - settings->setValue("axisColor", p->axisColor.name(QColor::HexArgb)); - settings->setValue("textColor", p->textColor.name(QColor::HexArgb)); - settings->setValue("spectrumLine", p->spectrumLine.name(QColor::HexArgb)); - settings->setValue("spectrumFill", p->spectrumFill.name(QColor::HexArgb)); - settings->setValue("underlayLine", p->underlayLine.name(QColor::HexArgb)); - settings->setValue("underlayFill", p->underlayFill.name(QColor::HexArgb)); - settings->setValue("plotBackground", p->plotBackground.name(QColor::HexArgb)); - settings->setValue("tuningLine", p->tuningLine.name(QColor::HexArgb)); - settings->setValue("passband", p->passband.name(QColor::HexArgb)); - settings->setValue("pbt", p->pbt.name(QColor::HexArgb)); - settings->setValue("wfBackground", p->wfBackground.name(QColor::HexArgb)); - settings->setValue("wfGrid", p->wfGrid.name(QColor::HexArgb)); - settings->setValue("wfAxis", p->wfAxis.name(QColor::HexArgb)); - settings->setValue("wfText", p->wfText.name(QColor::HexArgb)); - settings->setValue("meterLevel", p->meterLevel.name(QColor::HexArgb)); - settings->setValue("meterAverage", p->meterAverage.name(QColor::HexArgb)); - settings->setValue("meterPeakScale", p->meterPeakScale.name(QColor::HexArgb)); - settings->setValue("meterPeakLevel", p->meterPeakLevel.name(QColor::HexArgb)); - settings->setValue("meterLowerLine", p->meterLowerLine.name(QColor::HexArgb)); - settings->setValue("meterLowText", p->meterLowText.name(QColor::HexArgb)); - settings->setValue("clusterSpots", p->clusterSpots.name(QColor::HexArgb)); - - settings->endArray(); - settings->endGroup(); - settings->sync(); -} void wfmain::on_showLogBtn_clicked() { @@ -8753,25 +7932,14 @@ void wfmain::changePollTiming(int timing_ms, bool setUI) void wfmain::connectionHandler(bool connect) { - if (!connect) { - emit sendCloseComm(); + emit sendCloseComm(); + haveRigCaps = false; + rigName->setText("NONE"); + + if (connect && ui->connectBtn->text() != "Cancel connection") { + openRig(); + } else { ui->connectBtn->setText("Connect to Radio"); - ui->audioSystemCombo->setEnabled(true); - ui->audioSystemServerCombo->setEnabled(true); - haveRigCaps = false; - rigName->setText("NONE"); - } - else - { - emit sendCloseComm(); // Just in case there is a failed connection open. - if (ui->connectBtn->text() != "Cancel connection") { - openRig(); - } - else { - ui->connectBtn->setText("Connect to Radio"); - ui->audioSystemCombo->setEnabled(true); - ui->audioSystemServerCombo->setEnabled(true); - } } // Whatever happened, make sure we delete the memories window. @@ -8779,16 +7947,11 @@ void wfmain::connectionHandler(bool connect) delete memWindow; memWindow = Q_NULLPTR; } + // Also clear the queue queue->clear(); } -/* -void wfmain::on_autoSSBchk_clicked(bool checked) -{ - prefs.automaticSidebandSwitching = checked; -} -*/ void wfmain::on_cwButton_clicked() { @@ -8885,100 +8048,8 @@ void wfmain::on_rigCreatorBtn_clicked() rigCreator* create = new rigCreator(); create->setAttribute(Qt::WA_DeleteOnClose); create->show(); - - /* - if(creator == Q_NULLPTR) - { - creator = new rigCreator(); - } else { - if (creator->isVisible()) - { - creator->raise(); - } - else - { - delete creator; - creator = new rigCreator(); - } - } - creator->show(); -*/ } -#ifdef USB_HOTPLUG - -#ifdef Q_OS_WINDOWS -bool wfmain::nativeEvent(const QByteArray& eventType, void* message, qintptr* result) -{ - Q_UNUSED(eventType); - Q_UNUSED(result); - - if (QDateTime::currentMSecsSinceEpoch() > lastUsbNotify + 10) - { - static bool created = false; - - MSG * msg = static_cast< MSG * > (message); - switch (msg->message) - { - case WM_PAINT: - { - if (!created) { - GUID InterfaceClassGuid = {0x745a17a0, 0x74d3, 0x11d0,{ 0xb6, 0xfe, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda}}; - DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; - ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) ); - NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); - NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; - NotificationFilter.dbcc_classguid = InterfaceClassGuid; - HWND hw = (HWND) this->effectiveWinId(); //Main window handle - RegisterDeviceNotification(hw,&NotificationFilter, DEVICE_NOTIFY_ALL_INTERFACE_CLASSES ); - created = true; - } - break; - } - case WM_DEVICECHANGE: - { - switch (msg->wParam) { - case DBT_DEVICEARRIVAL: - case DBT_DEVICEREMOVECOMPLETE: - emit usbHotplug(); - lastUsbNotify = QDateTime::currentMSecsSinceEpoch(); - break; - case DBT_DEVNODES_CHANGED: - break; - default: - break; - } - - return true; - break; - } - default: - break; - } - } - return false; // Process native events as normal -} - -#elif defined(Q_OS_LINUX) - -void wfmain::uDevEvent() -{ - udev_device *dev = udev_monitor_receive_device(uDevMonitor); - if (dev) - { - const char* action = udev_device_get_action(dev); - if (action && strcmp(action, "add") == 0 && QDateTime::currentMSecsSinceEpoch() > lastUsbNotify + 10) - { - emit usbHotplug(); - lastUsbNotify = QDateTime::currentMSecsSinceEpoch(); - } - udev_device_unref(dev); - } -} -#endif -#endif - - void wfmain::receiveValue(cacheItem val){ @@ -9378,3 +8449,78 @@ void wfmain::on_showSettingsBtn_clicked() showAndRaiseWidget(setupui); } + +/* USB Hotplug support added at the end of the file for convenience */ +#ifdef USB_HOTPLUG + +#ifdef Q_OS_WINDOWS +bool wfmain::nativeEvent(const QByteArray& eventType, void* message, qintptr* result) +{ + Q_UNUSED(eventType); + Q_UNUSED(result); + + if (QDateTime::currentMSecsSinceEpoch() > lastUsbNotify + 10) + { + static bool created = false; + + MSG * msg = static_cast< MSG * > (message); + switch (msg->message) + { + case WM_PAINT: + { + if (!created) { + GUID InterfaceClassGuid = {0x745a17a0, 0x74d3, 0x11d0,{ 0xb6, 0xfe, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda}}; + DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; + ZeroMemory( &NotificationFilter, sizeof(NotificationFilter) ); + NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); + NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + NotificationFilter.dbcc_classguid = InterfaceClassGuid; + HWND hw = (HWND) this->effectiveWinId(); //Main window handle + RegisterDeviceNotification(hw,&NotificationFilter, DEVICE_NOTIFY_ALL_INTERFACE_CLASSES ); + created = true; + } + break; + } + case WM_DEVICECHANGE: + { + switch (msg->wParam) { + case DBT_DEVICEARRIVAL: + case DBT_DEVICEREMOVECOMPLETE: + emit usbHotplug(); + lastUsbNotify = QDateTime::currentMSecsSinceEpoch(); + break; + case DBT_DEVNODES_CHANGED: + break; + default: + break; + } + + return true; + break; + } + default: + break; + } + } + return false; // Process native events as normal +} + +#elif defined(Q_OS_LINUX) + +void wfmain::uDevEvent() +{ + udev_device *dev = udev_monitor_receive_device(uDevMonitor); + if (dev) + { + const char* action = udev_device_get_action(dev); + if (action && strcmp(action, "add") == 0 && QDateTime::currentMSecsSinceEpoch() > lastUsbNotify + 10) + { + emit usbHotplug(); + lastUsbNotify = QDateTime::currentMSecsSinceEpoch(); + } + udev_device_unref(dev); + } +} +#endif +#endif + diff --git a/wfmain.h b/wfmain.h index 7a141df..735b6da 100644 --- a/wfmain.h +++ b/wfmain.h @@ -81,8 +81,6 @@ #endif #endif -#define numColorPresetsTotal (5) - namespace Ui { class wfmain; } @@ -484,23 +482,14 @@ private slots: void on_pttOffBtn_clicked(); void on_saveSettingsBtn_clicked(); void on_debugBtn_clicked(); - 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 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_scopeEnableWFBtn_stateChanged(int state); void on_sqlSlider_valueChanged(int value); + void on_modeFilterCombo_activated(int index); void on_datamodeCombo_activated(int index); @@ -517,7 +506,6 @@ private slots: void on_spectrumModeCombo_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(); @@ -551,14 +539,12 @@ private slots: void on_serverCivPortText_textChanged(QString text); void on_serverAudioPortText_textChanged(QString text); - void changedServerTXAudioOutput(int value); - void changedServerRXAudioInput(int value); void onServerUserFieldChanged(); void changedModInput(uchar val, inputTypes type); void on_serverAddUserBtn_clicked(); 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); @@ -567,60 +553,8 @@ private slots: 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(); - void on_audioSystemServerCombo_currentIndexChanged(int index); - void on_customEdgeBtn_clicked(); void on_clusterUdpEnable_clicked(bool enable); @@ -844,29 +778,14 @@ private: udpPreferences udpPrefs; udpPreferences udpDefPrefs; - // Configuration for audio output and input. - audioSetup rxSetup; - audioSetup txSetup; - void setDefaultColors(int presetNumber); // populate with default values + void setDefaultColorPresets(); + void useColorPreset(colorPrefsType *cp); void useColors(); // set the plot up void setDefPrefs(); // populate default values to default prefs void setTuningSteps(); - void setColorElement(QColor color, QLedLabel *led, QLabel *label); - void setColorElement(QColor color, QLedLabel *led, QLineEdit *lineText); - void setColorElement(QColor color, QLedLabel *led, QLabel *label, QLineEdit *lineText); - QColor getColorFromPicker(QColor initialColor); - void getSetColor(QLedLabel *led, QLabel *label); - void getSetColor(QLedLabel *led, QLineEdit *line); - QString setColorFromString(QString aarrggbb, QLedLabel *led); - void setDefaultColorPresets(); - void loadColorPresetToUIandPlots(int presetNumber); - void useColorPreset(colorPrefsType *cp); void useCurrentColorPreset(); - void setEditAndLedFromColor(QColor c, QLineEdit *e, QLedLabel *d); - void setColorButtonOperations(QColor *colorStore, QLineEdit *e, QLedLabel *d); - void setColorLineEditOperations(QColor *colorStore, QLineEdit *e, QLedLabel *d); void calculateTimingParameters(); void initPeriodicCommands(); diff --git a/wfmain.ui b/wfmain.ui index 027748e..c3c17d5 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -1685,7 +1685,7 @@ - 1 + 0 @@ -1930,408 +1930,6 @@ Please use the "Radio Server" page to select server audio 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 - - - - - - - Audio Input - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - @@ -2579,782 +2177,6 @@ Please use the "Radio Server" page to select server audio - - - - - 0 - 1 - - - - - 0 - 250 - - - - - 0 - 0 - - - - User-defined Color Editor - - - - 0 - - - 4 - - - 0 - - - 0 - - - - - QAbstractScrollArea::AdjustIgnored - - - true - - - - - 0 - 0 - 852 - 259 - - - - - - - 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 - - - - - - - - - - - - - @@ -4596,12 +3418,6 @@ Please use the "Radio Server" page to select server audio - - QLedLabel - QWidget -
qledlabel.h
- 1 -
QCustomPlot 1