From 7093ac104a6781798893887227b5465a3b23796e Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 10:24:07 -0700 Subject: [PATCH 01/37] Removed unused variables, corrected spelling. --- wfmain.cpp | 7 ------- wfmain.h | 2 -- wfmain.ui | 4 ++-- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index c55d6cc..2877d76 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1048,7 +1048,6 @@ void wfmain::setUIToPrefs() ui->drawPeakChk->setChecked(prefs.drawPeaks); on_drawPeakChk_clicked(prefs.drawPeaks); - drawPeaks = prefs.drawPeaks; underlayMode = prefs.underlayMode; switch(underlayMode) @@ -3591,9 +3590,6 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e //spectrumPlasma.resize(spectrumPlasmaSize); plasmaMutex.unlock(); - // HACK DO NOT CHECK IN: - drawPeaks = false; - drawPlasma = true; if(!spectrumDrawLock) { @@ -3678,7 +3674,6 @@ void wfmain::computePlasma() } } plasmaMutex.unlock(); - } void wfmain::receiveSpectrumMode(spectrumMode spectMode) @@ -3882,10 +3877,8 @@ void wfmain::on_drawPeakChk_clicked(bool checked) if(checked) { on_clearPeakBtn_clicked(); // clear - drawPeaks = true; } else { - drawPeaks = false; #if QCUSTOMPLOT_VERSION >= 0x020000 plot->graph(1)->data()->clear(); diff --git a/wfmain.h b/wfmain.h index 55fc8d2..6ec4a6d 100644 --- a/wfmain.h +++ b/wfmain.h @@ -672,7 +672,6 @@ private: QVector spectrumPlasma; unsigned int spectrumPlasmaSize = 64; underlay_t underlayMode = underlayNone; - bool drawPlasma = true; QMutex plasmaMutex; void resizePlasmaBuffer(int newSize); @@ -687,7 +686,6 @@ private: unsigned int wfLengthMax; bool onFullscreen; - bool drawPeaks; bool freqTextSelected; void checkFreqSel(); diff --git a/wfmain.ui b/wfmain.ui index 2e0d107..a935e8c 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -18,7 +18,7 @@ - 3 + 0 @@ -2974,7 +2974,7 @@ - Uneerlay Buffer Size: + Underlay Buffer Size: From c59050e632c9172f361707c49cdecd60c3a29dcc Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 10:54:54 -0700 Subject: [PATCH 02/37] Removed issue with plasma buffer resizing with the waterfall. --- wfmain.cpp | 35 +++++++++++++++++++++++------------ wfmain.h | 2 ++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 2877d76..943cfaf 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1079,7 +1079,7 @@ void wfmain::setUIToPrefs() ui->wfLengthSlider->setValue(prefs.wflength); prepareWf(prefs.wflength); - + preparePlasma(); ui->topLevelSlider->setValue(prefs.plotCeiling); ui->botLevelSlider->setValue(prefs.plotFloor); @@ -2079,17 +2079,6 @@ void wfmain::prepareWf(unsigned int wfLength) QByteArray empty((int)spectWidth, '\x01'); spectrumPeaks = QByteArray( (int)spectWidth, '\x01' ); - if(spectrumPlasmaSize == 0) - spectrumPlasmaSize = 128; - - //spectrumPlasma.resize(spectrumPlasmaSize); - for(unsigned int p=0; p < spectrumPlasmaSize; p++) - { - spectrumPlasma.append(empty); - } - - //wfimage.resize(wfLengthMax); - if((unsigned int)wfimage.size() < wfLengthMax) { unsigned int i=0; @@ -3646,6 +3635,28 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e } } +void wfmain::preparePlasma() +{ + if(plasmaPrepared) + return; + QByteArray empty((int)spectWidth, '\x01'); + + if(spectrumPlasmaSize == 0) + spectrumPlasmaSize = 128; + + plasmaMutex.lock(); + spectrumPlasma.clear(); + + for(unsigned int p=0; p < spectrumPlasmaSize; p++) + { + spectrumPlasma.append(empty); + } + + spectrumPlasma.squeeze(); + plasmaMutex.unlock(); + plasmaPrepared = true; +} + void wfmain::computePlasma() { plasmaMutex.lock(); diff --git a/wfmain.h b/wfmain.h index 6ec4a6d..5c7988f 100644 --- a/wfmain.h +++ b/wfmain.h @@ -573,6 +573,8 @@ private: void setPlotTheme(QCustomPlot *plot, bool isDark); void prepareWf(); void prepareWf(unsigned int wfLength); + void preparePlasma(); + bool plasmaPrepared = false; void computePlasma(); void showHideSpectrum(bool show); void getInitialRigState(); From a7587963b07eccb1e5129bbe13ad15b3a7414ee9 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 11:07:29 -0700 Subject: [PATCH 03/37] Fixed issue where the waterfall colors re-scaled to min-max versus user preference upon wf length change. --- wfmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index 943cfaf..805e7d0 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2098,7 +2098,7 @@ void wfmain::prepareWf(unsigned int wfLength) colorMap->data()->setValueRange(QCPRange(0, wfLength-1)); colorMap->data()->setKeyRange(QCPRange(0, spectWidth-1)); - colorMap->setDataRange(QCPRange(0, rigCaps.spectAmpMax)); + colorMap->setDataRange(QCPRange(prefs.plotFloor, prefs.plotCeiling)); colorMap->setGradient(static_cast(ui->wfthemeCombo->currentData().toInt())); if(colorMapData == Q_NULLPTR) From ebb2c59a45e023ee7ec2fae1852297c4863b090f Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 11:11:57 -0700 Subject: [PATCH 04/37] Added "pre-sorted" flag to plasma average mode plotting. --- wfmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index 805e7d0..8eb7196 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -3597,7 +3597,7 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e plot->graph(1)->setData(x,y2, true); // peaks } else if (underlayMode != underlayNone) { computePlasma(); - plot->graph(1)->setData(x,spectrumPlasmaLine); + plot->graph(1)->setData(x,spectrumPlasmaLine, true); } else { plot->graph(1)->setData(x,y2, true); // peaks, but probably cleared out } From 1d14d9520e296b252f77fa91930dd6137113981c Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 11:52:41 -0700 Subject: [PATCH 05/37] Fixed issue where spectrum greater than 128 was negative. --- wfmain.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 8eb7196..074f4c0 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -3555,6 +3555,7 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e QVector x(spectWidth), y(spectWidth), y2(spectWidth); + // TODO: Keep x around unless the frequency range changes. Should save a little time. for(int i=0; i < spectWidth; i++) { x[i] = (i * (endFreq-startFreq)/spectWidth) + startFreq; @@ -3669,7 +3670,7 @@ void wfmain::computePlasma() { for(int pos=0; pos < specPlasmaSize; pos++) { - spectrumPlasmaLine[col] += spectrumPlasma[pos][col]; + spectrumPlasmaLine[col] += (unsigned char)spectrumPlasma[pos][col]; } spectrumPlasmaLine[col] = spectrumPlasmaLine[col] / specPlasmaSize; } @@ -3679,8 +3680,8 @@ void wfmain::computePlasma() { for(int pos=0; pos < specPlasmaSize; pos++) { - if((double)(spectrumPlasma[pos][col]) > spectrumPlasmaLine[col]) - spectrumPlasmaLine[col] = spectrumPlasma[pos][col]; + if((double)((unsigned char)spectrumPlasma[pos][col]) > spectrumPlasmaLine[col]) + spectrumPlasmaLine[col] = (unsigned char)spectrumPlasma[pos][col]; } } } From a947ba6b189f663fbe506e5aea577165bb2b643a Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 16:40:10 -0700 Subject: [PATCH 06/37] Added support for qcp 1.3 --- wfmain.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wfmain.cpp b/wfmain.cpp index 074f4c0..475bd6d 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -3593,6 +3593,8 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e freqIndicatorLine->start->setCoords(freq.MHzDouble,0); freqIndicatorLine->end->setCoords(freq.MHzDouble,rigCaps.spectAmpMax); } + +#if QCUSTOMPLOT_VERSION >= 0x020000 if(underlayMode == underlayPeakHold) { plot->graph(1)->setData(x,y2, true); // peaks @@ -3602,6 +3604,17 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e } else { plot->graph(1)->setData(x,y2, true); // peaks, but probably cleared out } +#else + if(underlayMode == underlayPeakHold) + { + plot->graph(1)->setData(x,y2); // peaks + } else if (underlayMode != underlayNone) { + computePlasma(); + plot->graph(1)->setData(x,spectrumPlasmaLine); + } else { + plot->graph(1)->setData(x,y2); // peaks, but probably cleared out + } +#endif if(updateRange) plot->yAxis->setRange(prefs.plotFloor, prefs.plotCeiling); From d8dc9daa1501841afec6002bd204deacf39330ac Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 16:45:58 -0700 Subject: [PATCH 07/37] One more thing for qcp 1.3 --- wfmain.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index 475bd6d..d29e68f 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -3587,6 +3587,8 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e updateRange = true; //ui->qcp->addGraph(); +#if QCUSTOMPLOT_VERSION >= 0x020000 + plot->graph(0)->setData(x,y, true); if((freq.MHzDouble < endFreq) && (freq.MHzDouble > startFreq)) { @@ -3594,7 +3596,6 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e freqIndicatorLine->end->setCoords(freq.MHzDouble,rigCaps.spectAmpMax); } -#if QCUSTOMPLOT_VERSION >= 0x020000 if(underlayMode == underlayPeakHold) { plot->graph(1)->setData(x,y2, true); // peaks @@ -3605,6 +3606,13 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e plot->graph(1)->setData(x,y2, true); // peaks, but probably cleared out } #else + plot->graph(0)->setData(x,y); + if((freq.MHzDouble < endFreq) && (freq.MHzDouble > startFreq)) + { + freqIndicatorLine->start->setCoords(freq.MHzDouble,0); + freqIndicatorLine->end->setCoords(freq.MHzDouble,rigCaps.spectAmpMax); + } + if(underlayMode == underlayPeakHold) { plot->graph(1)->setData(x,y2); // peaks From 088d34af8be7d6759e75627ae2f765629c7ab203 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 20:54:50 -0700 Subject: [PATCH 08/37] Removed checkbox from prior peak hold mode. --- wfmain.cpp | 21 --------------------- wfmain.h | 2 -- wfmain.ui | 15 ++++----------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index d29e68f..e381bba 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1046,9 +1046,6 @@ void wfmain::setUIToPrefs() ui->useSystemThemeChk->setChecked(prefs.useSystemTheme); on_useSystemThemeChk_clicked(prefs.useSystemTheme); - ui->drawPeakChk->setChecked(prefs.drawPeaks); - on_drawPeakChk_clicked(prefs.drawPeaks); - underlayMode = prefs.underlayMode; switch(underlayMode) { @@ -3905,24 +3902,6 @@ void wfmain::on_clearPeakBtn_clicked() return; } -void wfmain::on_drawPeakChk_clicked(bool checked) -{ - if(checked) - { - on_clearPeakBtn_clicked(); // clear - - } else { - -#if QCUSTOMPLOT_VERSION >= 0x020000 - plot->graph(1)->data()->clear(); -#else - plot->graph(1)->clearData(); -#endif - - } - prefs.drawPeaks = checked; -} - void wfmain::on_fullScreenChk_clicked(bool checked) { if(checked) diff --git a/wfmain.h b/wfmain.h index 5c7988f..664dc8a 100644 --- a/wfmain.h +++ b/wfmain.h @@ -297,8 +297,6 @@ private slots: void on_clearPeakBtn_clicked(); - void on_drawPeakChk_clicked(bool checked); - void on_fullScreenChk_clicked(bool checked); void on_goFreqBtn_clicked(); diff --git a/wfmain.ui b/wfmain.ui index a935e8c..6b92776 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -6,7 +6,7 @@ 0 0 - 1002 + 1032 569 @@ -18,7 +18,7 @@ - 0 + 3 @@ -2820,13 +2820,6 @@ - - - - Draw Peaks - - - @@ -4006,7 +3999,7 @@ 0 0 - 1002 + 1032 21 @@ -4028,7 +4021,7 @@ - + From ab65f8e38dc7dd053601c4ae682c34ad27d30e42 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Thu, 18 Aug 2022 20:56:24 -0700 Subject: [PATCH 09/37] Finally remembered to remove annoying commented-out code. --- wfmain.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index e381bba..01fe55b 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -3583,7 +3583,6 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e if((plotFloor != oldPlotFloor) || (plotCeiling != oldPlotCeiling)) updateRange = true; - //ui->qcp->addGraph(); #if QCUSTOMPLOT_VERSION >= 0x020000 plot->graph(0)->setData(x,y, true); From 1423e7c3007192649b6ae81eeb505b678b6d1991 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 19 Aug 2022 09:41:13 -0700 Subject: [PATCH 10/37] Added color picker functions and demonstration UI elements --- qledlabel.cpp | 50 +++++++++++++++++- qledlabel.h | 6 +++ wfmain.cpp | 55 +++++++++++++++++++ wfmain.h | 10 ++++ wfmain.ui | 143 +++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 261 insertions(+), 3 deletions(-) diff --git a/qledlabel.cpp b/qledlabel.cpp index 640b1c4..5370b5e 100644 --- a/qledlabel.cpp +++ b/qledlabel.cpp @@ -38,4 +38,52 @@ void QLedLabel::setState(State state) void QLedLabel::setState(bool state) { setState(state ? StateOk : StateError); -} \ No newline at end of file +} + +void QLedLabel::setColor(QColor customColor, bool applyGradient=true) +{ + QColor top,middle,bottom; + this->baseColor = customColor; + + if(applyGradient) + { + top = customColor.lighter(200); + middle = customColor; + bottom = customColor.darker(200); + } else { + top = customColor; + middle = customColor; + bottom = customColor; + } + + // Stop 0 is the upper corner color, white-ish + // Stop 0.4 is the middle color + // Stop 1 is the bottom-right corner, darker. + + QString colorSS = QString("color: white;\ + border-radius: %1;background-color: \ + qlineargradient(spread:pad, x1:0.04, \ + y1:0.0565909, x2:0.799, y2:0.795, \ + stop:0 \ + rgba(%2, %3, %4, %5), \ + stop:0.41206 \ + rgba(%6, %7, %8, %9), \ + stop:1 \ + rgba(%10, %11, %12, %13));").arg(SIZE / 3) + .arg(top.red()).arg(top.green()).arg(top.blue()).arg(top.alpha()) + .arg(middle.red()).arg(middle.green()).arg(middle.blue()).arg(middle.alpha()) + .arg(bottom.red()).arg(bottom.green()).arg(bottom.blue()).arg(bottom.alpha()); + + setStyleSheet(colorSS); +} + +void QLedLabel::setColor(QString colorString, bool applyGradient=true) +{ + QColor c = QColor(colorString); + setColor(c, applyGradient); +} + +QColor QLedLabel::getColor() +{ + return baseColor; +} diff --git a/qledlabel.h b/qledlabel.h index b5dc706..824fbac 100644 --- a/qledlabel.h +++ b/qledlabel.h @@ -22,6 +22,12 @@ signals: public slots: void setState(State state); void setState(bool state); + void setColor(QColor customColor, bool applyGradient); + void setColor(QString colorString, bool applyGradient); + QColor getColor(); + +private: + QColor baseColor; }; #endif // QLEDLABEL_H diff --git a/wfmain.cpp b/wfmain.cpp index 01fe55b..4e07fd3 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6219,3 +6219,58 @@ void wfmain::on_debugBtn_clicked() // adjustSize(); } + +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::getColor(QColor initialColor) +{ + QColorDialog::ColorDialogOptions options; + options.setFlag(QColorDialog::ShowAlphaChannel, true); + options.setFlag(QColorDialog::DontUseNativeDialog, true); + QColor selColor = QColorDialog::getColor(initialColor, this, "Select Color", options); + return selColor; +} + +void wfmain::getSetColor(QLedLabel *led, QLabel *label) +{ + QColor selColor = getColor(led->getColor()); + setColorElement(selColor, led, label); +} + +void wfmain::getSetColor(QLedLabel *led, QLineEdit *line) +{ + QColor selColor = getColor(led->getColor()); + setColorElement(selColor, led, line); +} + +void wfmain::on_colorSetBtnGrid_clicked() +{ + getSetColor(ui->colorSwatchGrid, ui->colorLabelGrid); +} diff --git a/wfmain.h b/wfmain.h index 664dc8a..ba21879 100644 --- a/wfmain.h +++ b/wfmain.h @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include "logcategories.h" #include "commhandler.h" @@ -553,6 +555,8 @@ private slots: void on_underlayAverageBuffer_toggled(bool checked); + void on_colorSetBtnGrid_clicked(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -833,6 +837,12 @@ private: 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 getColor(QColor initialColor); + void getSetColor(QLedLabel *led, QLabel *label); + void getSetColor(QLedLabel *led, QLineEdit *line); quint64 roundFrequency(quint64 frequency, unsigned int tsHz); quint64 roundFrequencyWithStep(quint64 oldFreq, int steps,\ diff --git a/wfmain.ui b/wfmain.ui index 6b92776..682777e 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3081,6 +3081,139 @@ + + + + + 0 + 0 + + + + User-defined colors + + + + + + true + + + + + 0 + 0 + 767 + 192 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Grid... + + + + + + + PushButton + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + GRID + + + + + + + PushButton + + + + + + + TextLabel + + + + + + + + 15 + 15 + + + + + 15 + 15 + + + + + + + + + + + @@ -3089,7 +3222,7 @@ 20 - 40 + 20 @@ -4017,11 +4150,17 @@
meter.h
1 + + QLedLabel + QWidget +
qledlabel.h
+ 1 +
- + From 4b0ce8537e242b6dcd37be151d91c3e21cadea31 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 19 Aug 2022 10:32:06 -0700 Subject: [PATCH 11/37] Added line input to color functions --- qledlabel.cpp | 3 ++- wfmain.cpp | 30 ++++++++++++++++++++++++++++++ wfmain.h | 5 +++++ wfmain.ui | 35 ++++++++++++++++++++++------------- 4 files changed, 59 insertions(+), 14 deletions(-) diff --git a/qledlabel.cpp b/qledlabel.cpp index 5370b5e..c146071 100644 --- a/qledlabel.cpp +++ b/qledlabel.cpp @@ -12,6 +12,7 @@ QLedLabel::QLedLabel(QWidget* parent) : { //Set to ok by default setState(StateOkBlue); + baseColor = QColor(0, 115, 255, 255); setFixedSize(SIZE, SIZE); } @@ -69,7 +70,7 @@ void QLedLabel::setColor(QColor customColor, bool applyGradient=true) stop:0.41206 \ rgba(%6, %7, %8, %9), \ stop:1 \ - rgba(%10, %11, %12, %13));").arg(SIZE / 3) + rgba(%10, %11, %12, %13));").arg(SIZE / 2) .arg(top.red()).arg(top.green()).arg(top.blue()).arg(top.alpha()) .arg(middle.red()).arg(middle.green()).arg(middle.blue()).arg(middle.alpha()) .arg(bottom.red()).arg(bottom.green()).arg(bottom.blue()).arg(bottom.alpha()); diff --git a/wfmain.cpp b/wfmain.cpp index 4e07fd3..5e66c31 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6270,7 +6270,37 @@ void wfmain::getSetColor(QLedLabel *led, QLineEdit *line) 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::on_colorSetBtnGrid_clicked() { getSetColor(ui->colorSwatchGrid, ui->colorLabelGrid); } + +void wfmain::on_colorSetBtnPlotBackground_clicked() +{ + getSetColor(ui->colorSwatchPlotBackground, ui->colorLinePlotBackground); +} + +void wfmain::on_colorLinePlotBackground_editingFinished() +{ + QString c = ui->colorLinePlotBackground->text(); + c = setColorFromString(c, ui->colorSwatchPlotBackground); + ui->colorLinePlotBackground->setText(c); +} diff --git a/wfmain.h b/wfmain.h index ba21879..bc99071 100644 --- a/wfmain.h +++ b/wfmain.h @@ -557,6 +557,10 @@ private slots: void on_colorSetBtnGrid_clicked(); + void on_colorSetBtnPlotBackground_clicked(); + + void on_colorLinePlotBackground_editingFinished(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -843,6 +847,7 @@ private: QColor getColor(QColor initialColor); void getSetColor(QLedLabel *led, QLabel *label); void getSetColor(QLedLabel *led, QLineEdit *line); + QString setColorFromString(QString aarrggbb, QLedLabel *led); quint64 roundFrequency(quint64 frequency, unsigned int tsHz); quint64 roundFrequencyWithStep(quint64 oldFreq, int steps,\ diff --git a/wfmain.ui b/wfmain.ui index 682777e..020ba1e 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3135,13 +3135,6 @@
- - - - TextLabel - - - @@ -3164,9 +3157,9 @@ - + - PushButton + Plot Background... @@ -3195,18 +3188,34 @@ - 15 - 15 + 0 + 0 - 15 - 15 + 65535 + 65535
+ + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + From b77715e0d8440b59dc640b7e1024e4db6e772432 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 00:17:44 -0700 Subject: [PATCH 12/37] Color preferences. We can now set a single color and also detach the settings tab. --- colorprefs.h | 30 +++++ qledlabel.cpp | 6 + qledlabel.h | 3 +- wfmain.cpp | 83 +++++++++++- wfmain.h | 14 ++ wfmain.ui | 365 ++++++++++++++++++++++++++++++++++++++++++-------- wfview.pro | 1 + 7 files changed, 437 insertions(+), 65 deletions(-) create mode 100644 colorprefs.h diff --git a/colorprefs.h b/colorprefs.h new file mode 100644 index 0000000..cbdcf61 --- /dev/null +++ b/colorprefs.h @@ -0,0 +1,30 @@ +#ifndef COLORPREFS_H +#define COLORPREFS_H + +#include +#include + +struct colorPrefsType{ + int presetNum = -1; + QString presetName = QString("uninitialized"); + + QColor gridColor; + QColor textColor; + QColor spectrumLine; + QColor spectrumFill; + QColor underlayLine; + QColor underlayFill; + QColor plotBackground; + QColor tuningLine; + + QColor meterLevel; + QColor meterAverage; + QColor meterPeak; + + QColor wfBackground; + QColor wfGrid; + QColor wfText; +}; + + +#endif // COLORPREFS_H diff --git a/qledlabel.cpp b/qledlabel.cpp index c146071..9829fdf 100644 --- a/qledlabel.cpp +++ b/qledlabel.cpp @@ -6,6 +6,7 @@ static const QString greenSS = QString("color: white;border-radius: %1;backgroun static const QString redSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.145, y1:0.16, x2:0.92, y2:0.988636, stop:0 rgba(255, 12, 12, 255), stop:0.869347 rgba(103, 0, 0, 255));").arg(SIZE / 2); static const QString orangeSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.232, y1:0.272, x2:0.98, y2:0.959773, stop:0 rgba(255, 113, 4, 255), stop:1 rgba(91, 41, 7, 255))").arg(SIZE / 2); static const QString blueSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.04, y1:0.0565909, x2:0.799, y2:0.795, stop:0 rgba(203, 220, 255, 255), stop:0.41206 rgba(0, 115, 255, 255), stop:1 rgba(0, 49, 109, 255));").arg(SIZE / 2); +static const QString blankSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.04, y1:0.0565909, x2:0.799, y2:0.795, stop:0 rgba(203, 220, 255, 0), stop:0.41206 rgba(0, 115, 255, 0), stop:1 rgba(0, 49, 109, 0));").arg(SIZE / 2); QLedLabel::QLedLabel(QWidget* parent) : QLabel(parent) @@ -30,6 +31,11 @@ void QLedLabel::setState(State state) setStyleSheet(redSS); break; case StateOkBlue: + setStyleSheet(blueSS); + break; + case StateBlank: + setStyleSheet(blankSS); + break; default: setStyleSheet(blueSS); break; diff --git a/qledlabel.h b/qledlabel.h index 824fbac..3cb2c66 100644 --- a/qledlabel.h +++ b/qledlabel.h @@ -13,7 +13,8 @@ public: StateOk, StateOkBlue, StateWarning, - StateError + StateError, + StateBlank }; diff --git a/wfmain.cpp b/wfmain.cpp index 5e66c31..69c9967 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6290,17 +6290,90 @@ QString wfmain::setColorFromString(QString colorstr, QLedLabel *led) void wfmain::on_colorSetBtnGrid_clicked() { - getSetColor(ui->colorSwatchGrid, ui->colorLabelGrid); + getSetColor(ui->colorSwatchGrid, ui->colorEditGrid); } void wfmain::on_colorSetBtnPlotBackground_clicked() { - getSetColor(ui->colorSwatchPlotBackground, ui->colorLinePlotBackground); + getSetColor(ui->colorSwatchPlotBackground, ui->colorEditPlotBackground); } void wfmain::on_colorLinePlotBackground_editingFinished() { - QString c = ui->colorLinePlotBackground->text(); - c = setColorFromString(c, ui->colorSwatchPlotBackground); - ui->colorLinePlotBackground->setText(c); + +} + +void wfmain::useColorPreset(colorPrefsType *cp) +{ + // Apply the given preset to the UI elements + // prototyped from setPlotTheme() + if(cp == Q_NULLPTR) + return; + + plot->setBackground(cp->plotBackground); + + plot->xAxis->grid()->setPen(cp->gridColor); + plot->yAxis->grid()->setPen(cp->gridColor); + + plot->legend->setTextColor(cp->textColor); + plot->legend->setBorderPen(cp->gridColor); + plot->legend->setBrush(cp->gridColor); + + plot->xAxis->setTickLabelColor(cp->gridColor); + plot->xAxis->setLabelColor(cp->textColor); + plot->yAxis->setTickLabelColor(cp->gridColor); + plot->yAxis->setLabelColor(cp->textColor); + + plot->xAxis->setBasePen(cp->textColor); + plot->xAxis->setTickPen(cp->textColor); + plot->yAxis->setBasePen(cp->textColor); + plot->yAxis->setTickPen(cp->textColor); + + freqIndicatorLine->setPen(QPen(cp->tuningLine)); + + plot->graph(0)->setPen(QPen(cp->spectrumLine)); + plot->graph(0)->setBrush(QBrush(cp->spectrumFill)); + + plot->graph(1)->setPen(QPen(cp->underlayLine)); + plot->graph(1)->setBrush(QBrush(cp->underlayFill)); + +} + + +void wfmain::on_colorSetBtnText_clicked() +{ + +} + +void wfmain::on_colorSetBtnSpecLine_clicked() +{ + +} + +void wfmain::on_colorSetBtnSpecFill_clicked() +{ + +} + +void wfmain::on_colorEditPlotBackground_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QString c = ui->colorEditPlotBackground->text(); + c = setColorFromString(c, ui->colorSwatchPlotBackground); + ui->colorEditPlotBackground->setText(c); + colorPreset[pos].plotBackground = c; + useColorPreset(&colorPreset[pos]); +} + +void wfmain::on_colorPopOutBtn_clicked() +{ + QWidget *settingsPop = new QWidget; + QWidget *settingsTab = ui->tabWidget->currentWidget(); + ui->tabWidget->removeTab(ui->tabWidget->indexOf(settingsTab)); + QGridLayout *g = new QGridLayout; + QTabWidget *t = new QTabWidget; + settingsPop->setLayout(g); + g->addWidget(t); + t->addTab(settingsTab, "Settings"); + settingsPop->show(); } diff --git a/wfmain.h b/wfmain.h index bc99071..006d79f 100644 --- a/wfmain.h +++ b/wfmain.h @@ -37,6 +37,7 @@ #include "rigctld.h" #include "aboutbox.h" #include "selectradio.h" +#include "colorprefs.h" #include #include @@ -561,6 +562,16 @@ private slots: void on_colorLinePlotBackground_editingFinished(); + void on_colorSetBtnText_clicked(); + + void on_colorSetBtnSpecLine_clicked(); + + void on_colorSetBtnSpecFill_clicked(); + + void on_colorEditPlotBackground_editingFinished(); + + void on_colorPopOutBtn_clicked(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -791,6 +802,8 @@ private: } colorScheme; + colorPrefsType colorPreset[5]; + struct preferences { bool useFullScreen; bool useDarkMode; @@ -839,6 +852,7 @@ private: void setDefaultColors(); // populate with default values void useColors(); // set the plot up + void useColorPreset(colorPrefsType *cp); void setDefPrefs(); // populate default values to default prefs void setTuningSteps(); void setColorElement(QColor color, QLedLabel *led, QLabel *label); diff --git a/wfmain.ui b/wfmain.ui index 020ba1e..f90f61e 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3090,7 +3090,7 @@ - User-defined colors + User-defined Color Editor @@ -3104,87 +3104,186 @@ 0 0 767 - 192 + 372 - - - - Qt::Horizontal - - - - 40 - 20 - - - + + - - - - Grid... - - - - - - - PushButton - - + + - + + + + 90 + 16777215 + + - TextLabel + #AARRGGBB - - + + + + + 90 + 16777215 + + - PushButton + #AARRGGBB - - + + + + + + + + - PushButton + Overlay Line + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Rename Preset + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Meter Average + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Spectrum Fill - + - Plot Background... + Preset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 90 + 16777215 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + + + + + + + + + 90 + 16777215 + + - GRID + #AARRGGBB - - - - PushButton - - - - - - - TextLabel - - - - + @@ -3200,8 +3299,15 @@ - - + + + + Spectrum Line + + + + + 90 @@ -3213,8 +3319,149 @@ - - + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Plot Background + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Text + + + + + + + Meter Level + + + + + + + + + + Grid + + + + + + + Make Current + + + + + + + Save Preset + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Meter Peak + + + + + + + Pop-Out + + + + + + + Overlay Fill + + + + + + + Tuning Line + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + diff --git a/wfview.pro b/wfview.pro index c9cd8aa..f3118dd 100644 --- a/wfview.pro +++ b/wfview.pro @@ -176,6 +176,7 @@ SOURCES += main.cpp\ aboutbox.cpp HEADERS += wfmain.h \ + colorprefs.h \ commhandler.h \ rigcommander.h \ freqmemory.h \ From ac8a98049e936bba064713f4c315952647803676 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 00:33:59 -0700 Subject: [PATCH 13/37] More connections from picker to UI. --- wfmain.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 69c9967..6604836 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6288,11 +6288,6 @@ QString wfmain::setColorFromString(QString colorstr, QLedLabel *led) return led->getColor().name(QColor::HexArgb); } -void wfmain::on_colorSetBtnGrid_clicked() -{ - getSetColor(ui->colorSwatchGrid, ui->colorEditGrid); -} - void wfmain::on_colorSetBtnPlotBackground_clicked() { getSetColor(ui->colorSwatchPlotBackground, ui->colorEditPlotBackground); @@ -6355,6 +6350,15 @@ void wfmain::on_colorSetBtnSpecFill_clicked() } +void wfmain::on_colorSetBtnGrid_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + getSetColor(ui->colorSwatchGrid, ui->colorEditGrid); + QColor c = ui->colorSwatchPlotBackground->getColor(); + colorPreset[pos].gridColor = c; + useColorPreset(&colorPreset[pos]); +} + void wfmain::on_colorEditPlotBackground_editingFinished() { int pos = ui->colorPresetCombo->currentIndex(); @@ -6376,4 +6380,5 @@ void wfmain::on_colorPopOutBtn_clicked() g->addWidget(t); t->addTab(settingsTab, "Settings"); settingsPop->show(); + //connect(settingsPop, SIGNAL(destroyed(QObject*)), this, foo()); } From 2a509a61774305206c78b2bcb73ed0a0fb568465 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 16:47:17 -0700 Subject: [PATCH 14/37] Color editing for a few parameters is working. Lots of new helper functions introduced to make coding simpler. --- colorprefs.h | 3 + meter.cpp | 11 ++ meter.h | 3 + qledlabel.cpp | 10 ++ qledlabel.h | 2 + wfmain.cpp | 246 ++++++++++++++++++++++---- wfmain.h | 23 ++- wfmain.ui | 475 +++++++++++++++++++++++++++++++------------------- 8 files changed, 555 insertions(+), 218 deletions(-) diff --git a/colorprefs.h b/colorprefs.h index cbdcf61..aa2a4bf 100644 --- a/colorprefs.h +++ b/colorprefs.h @@ -20,6 +20,9 @@ struct colorPrefsType{ QColor meterLevel; QColor meterAverage; QColor meterPeak; + QColor meterLowerLine; + QColor meterLowText; + QColor wfBackground; QColor wfGrid; diff --git a/meter.cpp b/meter.cpp index bc606ef..611c2e7 100644 --- a/meter.cpp +++ b/meter.cpp @@ -48,6 +48,17 @@ meter::meter(QWidget *parent) : QWidget(parent) } +void meter::setColors(QColor current, QColor peak, + QColor average, QColor lowLine, + QColor lowText) +{ + currentColor = current; + peakColor = peak; + averageColor = average; + lowLineColor = lowLine; + lowTextColor = lowText; +} + void meter::clearMeterOnPTTtoggle() { // When a meter changes type, such as the fixed S -- TxPo meter, diff --git a/meter.h b/meter.h index d94657c..fc29168 100644 --- a/meter.h +++ b/meter.h @@ -30,6 +30,9 @@ public slots: void setMeterShortString(QString); QString getMeterShortString(); meterKind getMeterType(); + void setColors(QColor current, QColor peak, + QColor average, QColor lowLine, + QColor lowText); private: diff --git a/qledlabel.cpp b/qledlabel.cpp index 9829fdf..d85ca8a 100644 --- a/qledlabel.cpp +++ b/qledlabel.cpp @@ -90,6 +90,16 @@ void QLedLabel::setColor(QString colorString, bool applyGradient=true) setColor(c, applyGradient); } +void QLedLabel::setColor(QColor c) +{ + this->setColor(c, true); +} + +void QLedLabel::setColor(QString s) +{ + this->setColor(s, true); +} + QColor QLedLabel::getColor() { return baseColor; diff --git a/qledlabel.h b/qledlabel.h index 3cb2c66..d4117c9 100644 --- a/qledlabel.h +++ b/qledlabel.h @@ -25,6 +25,8 @@ public slots: void setState(bool state); void setColor(QColor customColor, bool applyGradient); void setColor(QString colorString, bool applyGradient); + void setColor(QColor c); + void setColor(QString s); QColor getColor(); private: diff --git a/wfmain.cpp b/wfmain.cpp index 6604836..a70fa1e 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -71,6 +71,9 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s qDebug(logSystem()) << "Running setUIToPrefs()"; setUIToPrefs(); + setDefaultColorPresets(); + loadColorPresetToUIandPlots(0); + qDebug(logSystem()) << "Running setInititalTiming()"; setInitialTiming(); @@ -6249,7 +6252,7 @@ void wfmain::setColorElement(QColor color, QLedLabel *led, QLineEdit *lineText) setColorElement(color, led, Q_NULLPTR, lineText); } -QColor wfmain::getColor(QColor initialColor) +QColor wfmain::getColorFromPicker(QColor initialColor) { QColorDialog::ColorDialogOptions options; options.setFlag(QColorDialog::ShowAlphaChannel, true); @@ -6260,13 +6263,13 @@ QColor wfmain::getColor(QColor initialColor) void wfmain::getSetColor(QLedLabel *led, QLabel *label) { - QColor selColor = getColor(led->getColor()); + QColor selColor = getColorFromPicker(led->getColor()); setColorElement(selColor, led, label); } void wfmain::getSetColor(QLedLabel *led, QLineEdit *line) { - QColor selColor = getColor(led->getColor()); + QColor selColor = getColorFromPicker(led->getColor()); setColorElement(selColor, led, line); } @@ -6288,16 +6291,17 @@ QString wfmain::setColorFromString(QString colorstr, QLedLabel *led) return led->getColor().name(QColor::HexArgb); } -void wfmain::on_colorSetBtnPlotBackground_clicked() -{ - getSetColor(ui->colorSwatchPlotBackground, ui->colorEditPlotBackground); -} - void wfmain::on_colorLinePlotBackground_editingFinished() { } +void wfmain::useCurrentColorPreset() +{ + int pos = ui->colorPresetCombo->currentIndex(); + useColorPreset(&colorPreset[pos]); +} + void wfmain::useColorPreset(colorPrefsType *cp) { // Apply the given preset to the UI elements @@ -6305,6 +6309,8 @@ void wfmain::useColorPreset(colorPrefsType *cp) if(cp == Q_NULLPTR) return; + qInfo(logSystem()) << "Setting plots to color preset " << cp->presetNum; + plot->setBackground(cp->plotBackground); plot->xAxis->grid()->setPen(cp->gridColor); @@ -6334,39 +6340,39 @@ void wfmain::useColorPreset(colorPrefsType *cp) } - -void wfmain::on_colorSetBtnText_clicked() +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()); + //colorStore->setBlue(100); + useCurrentColorPreset(); } -void wfmain::on_colorSetBtnSpecLine_clicked() +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; + } -} - -void wfmain::on_colorSetBtnSpecFill_clicked() -{ - -} - -void wfmain::on_colorSetBtnGrid_clicked() -{ - int pos = ui->colorPresetCombo->currentIndex(); - getSetColor(ui->colorSwatchGrid, ui->colorEditGrid); - QColor c = ui->colorSwatchPlotBackground->getColor(); - colorPreset[pos].gridColor = c; - useColorPreset(&colorPreset[pos]); -} - -void wfmain::on_colorEditPlotBackground_editingFinished() -{ - int pos = ui->colorPresetCombo->currentIndex(); - QString c = ui->colorEditPlotBackground->text(); - c = setColorFromString(c, ui->colorSwatchPlotBackground); - ui->colorEditPlotBackground->setText(c); - colorPreset[pos].plotBackground = c; - useColorPreset(&colorPreset[pos]); + QString colorStrValidated = setColorFromString(e->text(), d); + e->setText(colorStrValidated); + colorStore->setNamedColor(colorStrValidated); + useCurrentColorPreset(); } void wfmain::on_colorPopOutBtn_clicked() @@ -6382,3 +6388,173 @@ void wfmain::on_colorPopOutBtn_clicked() settingsPop->show(); //connect(settingsPop, SIGNAL(destroyed(QObject*)), this, foo()); } + +// Color Helper Functions: +void wfmain::setDefaultColorPresets() +{ + // Default wfview colors in each preset + // gets overridden after preferences are loaded + for(int pn=0; pn < numColorPresetsTotal; pn++) + { + qInfo(logSystem()) << "Setting default color preset " << pn; + colorPrefsType *p = &colorPreset[pn]; + + p->presetNum = pn; + //p->presetName = new QString("%1").arg(pn); + + // Colors are "#AARRGGBB" (AA=0xff is opaque) + // or as (r, g, b, a) + // Since the UI shows ##AARRGGBB, we should use + // that format in the code when convenient. + + p->gridColor = QColor(0,0,0,255); + p->textColor = QColor(Qt::white); + p->spectrumLine = QColor(Qt::yellow); + p->spectrumFill = QColor("transparent"); + p->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); + p->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); + p->plotBackground = QColor(Qt::black); + p->tuningLine = QColor(Qt::blue); + + p->meterLevel = QColor("#148CD2").darker(); + p->meterAverage = QColor("#3FB7CD"); + p->meterPeak = QColor("#3CA0DB").lighter(); + p->meterLowerLine = QColor("#eff0f1"); + p->meterLowText = QColor("#eff0f1"); + + p->wfBackground = QColor(Qt::black); + p->wfGrid = QColor(Qt::white); + p->wfText = QColor(Qt::white); + + qInfo(logSystem()) << "default color preset [" << pn << "] set to pn.presetNum index [" << p->presetNum << "]"; + } +} + +void wfmain::setEditAndLedFromColor(QColor c, QLineEdit *e, QLedLabel *d) +{ + bool blockSignals = true; + if(e != Q_NULLPTR) + { + e->blockSignals(blockSignals); + e->setText(c.name()); + 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.spectrumLine, ui->colorEditSpecLine, ui->colorSwatchSpecLine); + setEditAndLedFromColor(p.spectrumFill, ui->colorEditSpecFill, ui->colorSwatchSpecFill); + setEditAndLedFromColor(p.underlayLine, ui->colorEditOverlayLine, ui->colorSwatchOverlayLine); + setEditAndLedFromColor(p.underlayFill, ui->colorEditOverlayFill, ui->colorSwatchOverlayFill); + setEditAndLedFromColor(p.plotBackground, ui->colorEditPlotBackground, ui->colorSwatchPlotBackground); + setEditAndLedFromColor(p.tuningLine, ui->colorEditTuningLine, ui->colorSwatchTuningLine); + + setEditAndLedFromColor(p.meterLevel, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); + setEditAndLedFromColor(p.meterAverage, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); + setEditAndLedFromColor(p.meterPeak, ui->colorEditMeterPeak, ui->colorSwatchMeterPeak); + 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.wfText, ui->colorEditWfText, ui->colorSwatchWfText); + + useColorPreset(&p); +} + + +void wfmain::on_colorPresetCombo_currentIndexChanged(int index) +{ + qInfo(logSystem()) << "color preset combo box set to index: " << index; + loadColorPresetToUIandPlots(index); +} + +// Color buttons and lineEdit action functions: + +// 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); +} + +// 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); +} + + + diff --git a/wfmain.h b/wfmain.h index 006d79f..ea109be 100644 --- a/wfmain.h +++ b/wfmain.h @@ -52,6 +52,7 @@ #include "rtaudio/RtAudio.h" #endif +#define numColorPresetsTotal (5) namespace Ui { class wfmain; @@ -572,6 +573,16 @@ private slots: 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(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -802,7 +813,7 @@ private: } colorScheme; - colorPrefsType colorPreset[5]; + colorPrefsType colorPreset[numColorPresetsTotal]; struct preferences { bool useFullScreen; @@ -852,16 +863,22 @@ private: void setDefaultColors(); // populate with default values void useColors(); // set the plot up - void useColorPreset(colorPrefsType *cp); 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 getColor(QColor initialColor); + 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); quint64 roundFrequency(quint64 frequency, unsigned int tsHz); quint64 roundFrequencyWithStep(quint64 oldFreq, int steps,\ diff --git a/wfmain.ui b/wfmain.ui index f90f61e..4b441f7 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3104,102 +3104,37 @@ 0 0 767 - 372 + 522 - - - - - - - - - - - 90 - 16777215 - - + + - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - - - - Overlay Line - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Rename Preset - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Meter Average + Meter Scale - + - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + @@ -3212,6 +3147,22 @@ + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + @@ -3219,16 +3170,145 @@ - - + + + + + + + + - Preset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Waterfall Back + + + + Meter Text + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Save Preset + + + + + + + Rename Preset + + + + + + + Text + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Pop-Out + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Make Current + + + + + + + Meter Peak + + + + + + + + + + Meter Level + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + @@ -3264,25 +3344,6 @@ - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - @@ -3293,8 +3354,8 @@ - 65535 - 65535 + 16777215 + 16777215 @@ -3306,8 +3367,8 @@ - - + + 90 @@ -3319,8 +3380,8 @@ - - + + 90 @@ -3332,42 +3393,58 @@ - - + + + + + - Plot Background + Meter Average - - - - Qt::Horizontal + + + + Underlay Fill - + + + + + - 40 - 20 + 90 + 16777215 - - - - - Text + #AARRGGBB - - + + + + + + + + 90 + 16777215 + + - Meter Level + #AARRGGBB - - + + + + Underlay Line + + @@ -3376,25 +3453,8 @@ - - - - Make Current - - - - - - - Save Preset - - - - - - - - + + 90 @@ -3419,36 +3479,25 @@ - - + + - Meter Peak + Preset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - Pop-Out - - - - - - - Overlay Fill - - - - - - - Tuning Line + Plot Background - + 90 @@ -3460,8 +3509,74 @@ - - + + + + Tuning Line + + + + + + + Waterfall Grid + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + Waterfall Text + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + From ecb9b8fbb4c166900a634c1f8616019c134e10b3 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 17:52:52 -0700 Subject: [PATCH 15/37] Now all colors can be edited. --- colorprefs.h | 2 + wfmain.cpp | 217 +++++++++++++++- wfmain.h | 52 ++++ wfmain.ui | 710 +++++++++++++++++++++++++++------------------------ 4 files changed, 639 insertions(+), 342 deletions(-) diff --git a/colorprefs.h b/colorprefs.h index aa2a4bf..fd9c005 100644 --- a/colorprefs.h +++ b/colorprefs.h @@ -9,6 +9,7 @@ struct colorPrefsType{ QString presetName = QString("uninitialized"); QColor gridColor; + QColor axisColor; QColor textColor; QColor spectrumLine; QColor spectrumFill; @@ -26,6 +27,7 @@ struct colorPrefsType{ QColor wfBackground; QColor wfGrid; + QColor wfAxis; QColor wfText; }; diff --git a/wfmain.cpp b/wfmain.cpp index a70fa1e..ad34847 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6320,15 +6320,15 @@ void wfmain::useColorPreset(colorPrefsType *cp) plot->legend->setBorderPen(cp->gridColor); plot->legend->setBrush(cp->gridColor); - plot->xAxis->setTickLabelColor(cp->gridColor); - plot->xAxis->setLabelColor(cp->textColor); - plot->yAxis->setTickLabelColor(cp->gridColor); - plot->yAxis->setLabelColor(cp->textColor); + plot->xAxis->setTickLabelColor(cp->textColor); + plot->xAxis->setLabelColor(cp->gridColor); + plot->yAxis->setTickLabelColor(cp->textColor); + plot->yAxis->setLabelColor(cp->gridColor); - plot->xAxis->setBasePen(cp->textColor); - plot->xAxis->setTickPen(cp->textColor); - plot->yAxis->setBasePen(cp->textColor); - plot->yAxis->setTickPen(cp->textColor); + plot->xAxis->setBasePen(cp->axisColor); + plot->xAxis->setTickPen(cp->axisColor); + plot->yAxis->setBasePen(cp->axisColor); + plot->yAxis->setTickPen(cp->axisColor); freqIndicatorLine->setPen(QPen(cp->tuningLine)); @@ -6338,6 +6338,21 @@ void wfmain::useColorPreset(colorPrefsType *cp) plot->graph(1)->setPen(QPen(cp->underlayLine)); plot->graph(1)->setBrush(QBrush(cp->underlayFill)); + wf->yAxis->setBasePen(cp->wfAxis); + wf->yAxis->setTickPen(cp->wfAxis); + wf->xAxis->setBasePen(cp->wfAxis); + wf->xAxis->setTickPen(cp->wfAxis); + + wf->xAxis->setLabelColor(cp->wfGrid); + wf->yAxis->setLabelColor(cp->wfGrid); + + wf->xAxis->setTickLabelColor(cp->wfText); + wf->yAxis->setTickLabelColor(cp->wfText); + + wf->setBackground(cp->wfBackground); + + ui->meterSPoWidget->setColors(cp->meterLevel, cp->meterPeak, cp->meterAverage, cp->meterLowerLine, cp->meterLowText); + ui->meter2Widget->setColors(cp->meterLevel, cp->meterPeak, cp->meterAverage, cp->meterLowerLine, cp->meterLowText); } void wfmain::setColorButtonOperations(QColor *colorStore, @@ -6408,6 +6423,7 @@ void wfmain::setDefaultColorPresets() // that format in the code when convenient. p->gridColor = QColor(0,0,0,255); + p->axisColor = QColor(Qt::white); p->textColor = QColor(Qt::white); p->spectrumLine = QColor(Qt::yellow); p->spectrumFill = QColor("transparent"); @@ -6423,6 +6439,7 @@ void wfmain::setDefaultColorPresets() p->meterLowText = QColor("#eff0f1"); p->wfBackground = QColor(Qt::black); + p->wfAxis = QColor(Qt::white); p->wfGrid = QColor(Qt::white); p->wfText = QColor(Qt::white); @@ -6459,8 +6476,8 @@ void wfmain::loadColorPresetToUIandPlots(int presetNumber) setEditAndLedFromColor(p.spectrumLine, ui->colorEditSpecLine, ui->colorSwatchSpecLine); setEditAndLedFromColor(p.spectrumFill, ui->colorEditSpecFill, ui->colorSwatchSpecFill); - setEditAndLedFromColor(p.underlayLine, ui->colorEditOverlayLine, ui->colorSwatchOverlayLine); - setEditAndLedFromColor(p.underlayFill, ui->colorEditOverlayFill, ui->colorSwatchOverlayFill); + 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); @@ -6500,6 +6517,20 @@ void wfmain::on_colorEditGrid_editingFinished() 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() { @@ -6556,5 +6587,171 @@ void wfmain::on_colorSetBtnPlotBackground_clicked() 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); +} + +// 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: +void wfmain::on_colorSetBtnMeterPeak_clicked() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterPeak); + setColorButtonOperations(c, ui->colorEditMeterPeak, ui->colorSwatchMeterPeak); +} +void wfmain::on_colorEditMeterPeak_editingFinished() +{ + int pos = ui->colorPresetCombo->currentIndex(); + QColor *c = &(colorPreset[pos].meterPeak); + setColorLineEditOperations(c, ui->colorEditMeterPeak, ui->colorSwatchMeterPeak); +} + +// 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); +} diff --git a/wfmain.h b/wfmain.h index ea109be..35a147d 100644 --- a/wfmain.h +++ b/wfmain.h @@ -583,6 +583,58 @@ private slots: 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_colorSetBtnMeterLevel_clicked(); + + void on_colorEditMeterLevel_editingFinished(); + + void on_colorSetBtnMeterAvg_clicked(); + + void on_colorEditMeterAvg_editingFinished(); + + void on_colorSetBtnMeterPeak_clicked(); + + void on_colorEditMeterPeak_editingFinished(); + + void on_colorSetBtnMeterScale_clicked(); + + void on_colorEditMeterScale_editingFinished(); + + void on_colorSetBtnMeterText_clicked(); + + void on_colorEditMeterText_editingFinished(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); diff --git a/wfmain.ui b/wfmain.ui index 4b441f7..86e1e77 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3102,21 +3102,197 @@ 0 - 0 + -100 767 - 522 + 582 - - + + - Meter Scale + Make Current - - + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Plot Background + + + + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Axis + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Text + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + @@ -3131,11 +3307,8 @@ - - - - - + + 90 @@ -3147,168 +3320,23 @@ - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Spectrum Fill - - - - + - - - - - + + - Waterfall Back + Underlay Line - - + + - Meter Text + Waterfall Grid - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Save Preset - - - - - - - Rename Preset - - - - - - - Text - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Pop-Out - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Make Current - - - - - - - Meter Peak - - - - - - - - - - Meter Level - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - @@ -3344,6 +3372,69 @@ + + + + Tuning Line + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + Underlay Fill + + + + + + + Pop-Out + + + + + + + Save Preset + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + @@ -3360,91 +3451,11 @@ - - - - Spectrum Line - - + + - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - Meter Average - - - - - - - Underlay Fill - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Underlay Line - - + + @@ -3453,76 +3464,6 @@ - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Preset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Plot Background - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Tuning Line - - - - - - - Waterfall Grid - - - @@ -3536,11 +3477,8 @@ - - - - - + + 90 @@ -3552,17 +3490,14 @@ - - - - - + + - Waterfall Text + Meter Peak - + @@ -3575,8 +3510,119 @@ - - + + + + + + + Meter Scale + + + + + + + Spectrum Fill + + + + + + + + + + Rename Preset + + + + + + + Waterfall Back + + + + + + + + + + + + + Preset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Spectrum Line + + + + + + + Meter Average + + + + + + + + + + Meter Level + + + + + + + Meter Text + + + + + + + + + + Waterfall Text + + + + + + + Waterfall Axis + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + From 93b1af6eb60637c69d93b03aa31c28411a847152 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 18:05:20 -0700 Subject: [PATCH 16/37] Removed unused function --- wfmain.cpp | 7 +------ wfmain.h | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index ad34847..d5ffdc1 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6223,6 +6223,7 @@ void wfmain::on_debugBtn_clicked() } +// Color Helper Functions: void wfmain::setColorElement(QColor color, QLedLabel *led, QLabel *label, @@ -6291,11 +6292,6 @@ QString wfmain::setColorFromString(QString colorstr, QLedLabel *led) return led->getColor().name(QColor::HexArgb); } -void wfmain::on_colorLinePlotBackground_editingFinished() -{ - -} - void wfmain::useCurrentColorPreset() { int pos = ui->colorPresetCombo->currentIndex(); @@ -6404,7 +6400,6 @@ void wfmain::on_colorPopOutBtn_clicked() //connect(settingsPop, SIGNAL(destroyed(QObject*)), this, foo()); } -// Color Helper Functions: void wfmain::setDefaultColorPresets() { // Default wfview colors in each preset diff --git a/wfmain.h b/wfmain.h index 35a147d..a67296d 100644 --- a/wfmain.h +++ b/wfmain.h @@ -561,8 +561,6 @@ private slots: void on_colorSetBtnPlotBackground_clicked(); - void on_colorLinePlotBackground_editingFinished(); - void on_colorSetBtnText_clicked(); void on_colorSetBtnSpecLine_clicked(); From a84fb6d09131abaf8ea3d93b53d3393d1f995efd Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 21:19:08 -0700 Subject: [PATCH 17/37] Cleaner tab add/remove code for the settings tab. --- wfmain.cpp | 49 +++++++++++++++++++++++++++++++++++++------------ wfmain.h | 10 +++++++++- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index d5ffdc1..730dab4 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -53,6 +53,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s setupKeyShortcuts(); setupMainUI(); + prepareSettingsWindow(); setSerialDevicesUI(); @@ -880,8 +881,18 @@ void wfmain::setupMainUI() [=](const unsigned char &newValue) { issueCmdUniquePriority(cmdSetTPBFOuter, newValue);} ); +} +void wfmain::prepareSettingsWindow() +{ + settingsTabisAttached = true; + // settingsTab; + settingsWidgetWindow = new QWidget; + settingsWidgetLayout = new QGridLayout; + settingsWidgetTab = new QTabWidget; + settingsWidgetWindow->setLayout(settingsWidgetLayout); + settingsWidgetLayout->addWidget(settingsWidgetTab); } void wfmain::updateSizes(int tabIndex) @@ -6223,7 +6234,8 @@ void wfmain::on_debugBtn_clicked() } -// Color Helper Functions: +// ---------- color helper functions: ---------- // + void wfmain::setColorElement(QColor color, QLedLabel *led, QLabel *label, @@ -6388,16 +6400,25 @@ void wfmain::setColorLineEditOperations(QColor *colorStore, void wfmain::on_colorPopOutBtn_clicked() { - QWidget *settingsPop = new QWidget; - QWidget *settingsTab = ui->tabWidget->currentWidget(); - ui->tabWidget->removeTab(ui->tabWidget->indexOf(settingsTab)); - QGridLayout *g = new QGridLayout; - QTabWidget *t = new QTabWidget; - settingsPop->setLayout(g); - g->addWidget(t); - t->addTab(settingsTab, "Settings"); - settingsPop->show(); - //connect(settingsPop, SIGNAL(destroyed(QObject*)), this, foo()); + + if(settingsTabisAttached) + { + settingsTab = ui->tabWidget->currentWidget(); + ui->tabWidget->removeTab(ui->tabWidget->indexOf(settingsTab)); + settingsWidgetTab->addTab(settingsTab, "Settings"); + settingsWidgetWindow->show(); + ui->colorPopOutBtn->setText("Re-attach"); + settingsTabisAttached = false; + } else { + settingsTab = settingsWidgetTab->currentWidget(); + + settingsWidgetTab->removeTab(settingsWidgetTab->indexOf(settingsTab)); + ui->tabWidget->addTab(settingsTab, "Settings"); + settingsWidgetWindow->close(); + + ui->colorPopOutBtn->setText("Pop-Out"); + settingsTabisAttached = true; + } } void wfmain::setDefaultColorPresets() @@ -6496,7 +6517,9 @@ void wfmain::on_colorPresetCombo_currentIndexChanged(int index) loadColorPresetToUIandPlots(index); } -// Color buttons and lineEdit action functions: +// ---------- end color helper functions ---------- // + +// ---------- Color UI slots ----------// // Grid: void wfmain::on_colorSetBtnGrid_clicked() @@ -6750,3 +6773,5 @@ void wfmain::on_colorEditMeterText_editingFinished() QColor *c = &(colorPreset[pos].meterLowText); setColorLineEditOperations(c, ui->colorEditMeterText, ui->colorSwatchMeterText); } + +// ---------- End color UI slots ----------// diff --git a/wfmain.h b/wfmain.h index a67296d..fd8b9ed 100644 --- a/wfmain.h +++ b/wfmain.h @@ -428,7 +428,6 @@ private slots: void on_dataModeBtn_toggled(bool checked); - void on_transmitBtn_clicked(); void on_adjRefBtn_clicked(); @@ -930,6 +929,15 @@ private: void setColorButtonOperations(QColor *colorStore, QLineEdit *e, QLedLabel *d); void setColorLineEditOperations(QColor *colorStore, QLineEdit *e, QLedLabel *d); + void detachSettingsTab(); + void reattachSettingsTab(); + void prepareSettingsWindow(); + QWidget *settingsWidgetWindow; + QWidget *settingsTab; + QGridLayout *settingsWidgetLayout; + QTabWidget *settingsWidgetTab; + bool settingsTabisAttached = true; + quint64 roundFrequency(quint64 frequency, unsigned int tsHz); quint64 roundFrequencyWithStep(quint64 oldFreq, int steps,\ unsigned int tsHz); From 16237a47f54afcb089a6fdc321e08ed6820ecade Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 21:32:49 -0700 Subject: [PATCH 18/37] Slightly better closing for settings --- wfmain.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index 730dab4..4c9f24c 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -886,13 +886,17 @@ void wfmain::setupMainUI() void wfmain::prepareSettingsWindow() { settingsTabisAttached = true; - // settingsTab; + settingsWidgetWindow = new QWidget; settingsWidgetLayout = new QGridLayout; settingsWidgetTab = new QTabWidget; settingsWidgetWindow->setLayout(settingsWidgetLayout); settingsWidgetLayout->addWidget(settingsWidgetTab); + settingsWidgetWindow->setWindowFlag(Qt::WindowCloseButtonHint, false); + //settingsWidgetWindow->setWindowFlag(Qt::WindowMinimizeButtonHint, false); + //settingsWidgetWindow->setWindowFlag(Qt::WindowMaximizeButtonHint, false); + // TODO: Capture an event when the window closes and handle accordingly. } void wfmain::updateSizes(int tabIndex) @@ -6408,6 +6412,7 @@ void wfmain::on_colorPopOutBtn_clicked() settingsWidgetTab->addTab(settingsTab, "Settings"); settingsWidgetWindow->show(); ui->colorPopOutBtn->setText("Re-attach"); + ui->tabWidget->setCurrentIndex(0); settingsTabisAttached = false; } else { settingsTab = settingsWidgetTab->currentWidget(); @@ -6417,6 +6422,7 @@ void wfmain::on_colorPopOutBtn_clicked() settingsWidgetWindow->close(); ui->colorPopOutBtn->setText("Pop-Out"); + ui->tabWidget->setCurrentIndex(3); settingsTabisAttached = true; } } From 1388c756c43d954f047afd14ea9068cea9808c7f Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 21:51:50 -0700 Subject: [PATCH 19/37] Fixed alpha channel issue --- wfmain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 4c9f24c..62c068f 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6380,7 +6380,7 @@ void wfmain::setColorButtonOperations(QColor *colorStore, } getSetColor(d, e); QColor t = d->getColor(); - colorStore->setNamedColor(t.name()); + colorStore->setNamedColor(t.name(QColor::HexArgb)); //colorStore->setBlue(100); useCurrentColorPreset(); } @@ -6475,7 +6475,7 @@ void wfmain::setEditAndLedFromColor(QColor c, QLineEdit *e, QLedLabel *d) if(e != Q_NULLPTR) { e->blockSignals(blockSignals); - e->setText(c.name()); + e->setText(c.name(QColor::HexArgb)); e->blockSignals(false); } if(d != Q_NULLPTR) From d11ae30b1ac11c664a4655025ba2e518395a3b92 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 23:50:02 -0700 Subject: [PATCH 20/37] Fixed bug relate to pressing cancel in the color picker. --- meter.cpp | 2 +- wfmain.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/meter.cpp b/meter.cpp index 611c2e7..478f90a 100644 --- a/meter.cpp +++ b/meter.cpp @@ -236,7 +236,7 @@ void meter::paintEvent(QPaintEvent *) void meter::drawLabel(QPainter *qp) { - qp->setPen(lowLineColor); + qp->setPen(lowTextColor); qp->drawText(0,scaleTextYstart, label ); } diff --git a/wfmain.cpp b/wfmain.cpp index 62c068f..ee1d68d 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6275,7 +6275,10 @@ QColor wfmain::getColorFromPicker(QColor initialColor) options.setFlag(QColorDialog::ShowAlphaChannel, true); options.setFlag(QColorDialog::DontUseNativeDialog, true); QColor selColor = QColorDialog::getColor(initialColor, this, "Select Color", options); - return selColor; + if(selColor.isValid()) + return selColor; + else + return initialColor; } void wfmain::getSetColor(QLedLabel *led, QLabel *label) From 952585261c123134a290295b3456ff45d37d6e35 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 23:54:37 -0700 Subject: [PATCH 21/37] Forgot text color from default load-in --- wfmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index ee1d68d..b227b1f 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6498,7 +6498,7 @@ void wfmain::loadColorPresetToUIandPlots(int presetNumber) 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.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); From 92904f8ae585b4447065e5acbe98b83e937d894e Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Sun, 21 Aug 2022 23:59:48 -0700 Subject: [PATCH 22/37] Forgot the axis color from default. --- wfmain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wfmain.cpp b/wfmain.cpp index b227b1f..c541204 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6498,6 +6498,7 @@ void wfmain::loadColorPresetToUIandPlots(int presetNumber) 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); @@ -6514,6 +6515,7 @@ void wfmain::loadColorPresetToUIandPlots(int presetNumber) 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); useColorPreset(&p); From 7e4d3f76d5ef3bbfac1c23c0d4a93244d82ba4ab Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 09:04:19 -0700 Subject: [PATCH 23/37] Fixed stretched grid color swatch. This has to be a qt uic bug. --- wfmain.ui | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index 86e1e77..d643fd5 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3436,20 +3436,7 @@ - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - + From 59d2d735e6e55174090ef90c9fa5febc7a5c61e0 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 09:44:00 -0700 Subject: [PATCH 24/37] Added preset names --- colorprefs.h | 16 +- wfmain.cpp | 39 +++- wfmain.h | 2 + wfmain.ui | 612 +++++++++++++++++++++++++-------------------------- 4 files changed, 353 insertions(+), 316 deletions(-) diff --git a/colorprefs.h b/colorprefs.h index fd9c005..5678f64 100644 --- a/colorprefs.h +++ b/colorprefs.h @@ -6,8 +6,9 @@ struct colorPrefsType{ int presetNum = -1; - QString presetName = QString("uninitialized"); + QString *presetName = Q_NULLPTR; + // Spectrum line plot: QColor gridColor; QColor axisColor; QColor textColor; @@ -18,17 +19,18 @@ struct colorPrefsType{ QColor plotBackground; QColor tuningLine; + // Waterfall: + QColor wfBackground; + QColor wfGrid; + QColor wfAxis; + QColor wfText; + + // Meters: QColor meterLevel; QColor meterAverage; QColor meterPeak; QColor meterLowerLine; QColor meterLowText; - - - QColor wfBackground; - QColor wfGrid; - QColor wfAxis; - QColor wfText; }; diff --git a/wfmain.cpp b/wfmain.cpp index c541204..b28c917 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6324,7 +6324,7 @@ void wfmain::useColorPreset(colorPrefsType *cp) if(cp == Q_NULLPTR) return; - qInfo(logSystem()) << "Setting plots to color preset " << cp->presetNum; + qInfo(logSystem()) << "Setting plots to color preset number " << cp->presetNum << ", with name " << *(cp->presetName); plot->setBackground(cp->plotBackground); @@ -6440,7 +6440,10 @@ void wfmain::setDefaultColorPresets() colorPrefsType *p = &colorPreset[pn]; p->presetNum = pn; - //p->presetName = new QString("%1").arg(pn); + if(p->presetName == Q_NULLPTR) + { + p->presetName = new QString( QString("Preset %1").arg(pn) ); + } // Colors are "#AARRGGBB" (AA=0xff is opaque) // or as (r, g, b, a) @@ -6468,7 +6471,8 @@ void wfmain::setDefaultColorPresets() p->wfGrid = QColor(Qt::white); p->wfText = QColor(Qt::white); - qInfo(logSystem()) << "default color preset [" << pn << "] set to pn.presetNum index [" << p->presetNum << "]"; + qInfo(logSystem()) << "default color preset [" << pn << "] set to pn.presetNum index [" << p->presetNum << "]" << ", with name " << *(p->presetName); + ui->colorPresetCombo->setItemText(pn, *(p->presetName)); } } @@ -6786,3 +6790,32 @@ void wfmain::on_colorEditMeterText_editingFinished() } // ---------- End color UI slots ----------// + +void wfmain::on_colorRenamePresetBtn_clicked() +{ + int p = ui->colorPresetCombo->currentIndex(); + QString newName; + QMessageBox msgBox; + + bool ok = false; + newName = QInputDialog::getText(this, tr("QInputDialog::getText()"), + tr("Preset Name (32 characters max):"), QLineEdit::Normal, + ui->colorPresetCombo->currentText(), &ok); + if(!ok) + return; + + if(ok && (newName.length() < 33) && !newName.isEmpty()) + { + colorPreset[p].presetName->clear(); + colorPreset[p].presetName->append(newName); + ui->colorPresetCombo->setItemText(p, *(colorPreset[p].presetName)); + qInfo(logSystem()) << "Setting color preset number " << p << " to have text " << newName << ", as read in preset data: " << *(colorPreset[p].presetName) << ", and as read from combo box: " << ui->colorPresetCombo->currentText(); + } else { + if(newName.isEmpty() || (newName.length() > 32)) + { + msgBox.setText("Error, name must be at least one character and not exceed 32 characters."); + msgBox.exec(); + } + } + +} diff --git a/wfmain.h b/wfmain.h index fd8b9ed..25e93f3 100644 --- a/wfmain.h +++ b/wfmain.h @@ -632,6 +632,8 @@ private slots: void on_colorEditMeterText_editingFinished(); + void on_colorRenamePresetBtn_clicked(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); diff --git a/wfmain.ui b/wfmain.ui index d643fd5..c060ab7 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3102,24 +3102,14 @@ 0 - -100 + 0 767 582 - - - - Make Current - - - - - - - - + + 90 @@ -3131,42 +3121,27 @@ - - - - - 90 - 16777215 - - + + + + + - #AARRGGBB + Waterfall Back - - - - - 90 - 16777215 - - + + - #AARRGGBB + Meter Scale - - - - - 90 - 16777215 - - + + - #AARRGGBB + Meter Peak @@ -3183,61 +3158,6 @@ - - - - Plot Background - - - - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - @@ -3251,25 +3171,11 @@ - - - - Axis - - + + - - - - - 90 - 16777215 - - - - #AARRGGBB - - + + @@ -3278,8 +3184,58 @@ - - + + + + + + + Grid + + + + + + + + + + + + + Meter Text + + + + + + + Spectrum Fill + + + + + + + + + + Meter Level + + + + + + + + + + Rename Preset + + + + + 90 @@ -3291,21 +3247,83 @@ - - - - - - - Qt::Horizontal + + + + Waterfall Text - + + + + + + Waterfall Grid + + + + + + + + + + + + - 40 - 20 + 90 + 16777215 - + + #AARRGGBB + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + @@ -3320,20 +3338,10 @@ - - - - - + + - Underlay Line - - - - - - - Waterfall Grid + Axis @@ -3372,6 +3380,16 @@ + + + + Spectrum Line + + + + + + @@ -3379,48 +3397,11 @@ - - - - - 90 - 16777215 - - - - #AARRGGBB - - + + - - - - - - - Underlay Fill - - - - - - - Pop-Out - - - - - - - Save Preset - - - - - - - - + + 90 @@ -3435,22 +3416,75 @@ - - - - - - - - - - - + + - Grid + Pop-Out + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Waterfall Axis + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Underlay Fill + + + + + + @@ -3464,8 +3498,15 @@ - - + + + + Plot Background + + + + + 90 @@ -3477,13 +3518,79 @@ - - + + - Meter Peak + Meter Average + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Save Preset + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Preset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Underlay Line + + + + + + @@ -3497,120 +3604,13 @@ - - - - - - - Meter Scale - - - - - - - Spectrum Fill - - - - - - - + - Rename Preset + Revert - - - - Waterfall Back - - - - - - - - - - - - - Preset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Spectrum Line - - - - - - - Meter Average - - - - - - - - - - Meter Level - - - - - - - Meter Text - - - - - - - - - - Waterfall Text - - - - - - - Waterfall Axis - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - From 6f7f1f84ec80579407cc4f2a8a53ff75f302f165 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 16:49:35 -0700 Subject: [PATCH 25/37] Added presets and preset naming to the settings file. --- wfmain.cpp | 150 ++++++++++++++++++++++++++++++++++++++++++----------- wfmain.h | 1 + wfmain.ui | 2 +- 3 files changed, 122 insertions(+), 31 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index b28c917..0f4dc8c 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -63,6 +63,8 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s getSettingsFilePath(settingsFile); setupPlots(); + setDefaultColorPresets(); + loadSettings(); // Look for saved preferences setAudioDevicesUI(); @@ -72,7 +74,6 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s qDebug(logSystem()) << "Running setUIToPrefs()"; setUIToPrefs(); - setDefaultColorPresets(); loadColorPresetToUIandPlots(0); qDebug(logSystem()) << "Running setInititalTiming()"; @@ -1101,6 +1102,14 @@ void wfmain::setUIToPrefs() plot->yAxis->setRange(QCPRange(prefs.plotFloor, prefs.plotCeiling)); colorMap->setDataRange(QCPRange(prefs.plotFloor, prefs.plotCeiling)); + colorPrefsType p; + for(int pn=0; pn < numColorPresetsTotal; pn++) + { + p = colorPreset[pn]; + if(p.presetName != Q_NULLPTR) + ui->colorPresetCombo->setItemText(pn, *p.presetName); + } + ui->wfthemeCombo->setCurrentIndex(ui->wfthemeCombo->findData(prefs.wftheme)); colorMap->setGradient(static_cast(prefs.wftheme)); @@ -1362,6 +1371,55 @@ void wfmain::loadSettings() prefs.meter2Type = static_cast(settings->value("Meter2Type", defPrefs.meter2Type).toInt()); settings->endGroup(); + // Load in the color presets. The default values are already loaded. + + settings->beginGroup("ColorPresets"); + settings->value("currentColorPresetNumber", prefs.currentColorPresetNumber).toInt(); + if(prefs.currentColorPresetNumber > numColorPresetsTotal-1) + prefs.currentColorPresetNumber = 0; + + int numPresetsInFile = settings->beginReadArray("ColorPreset"); + // We will use the number of presets that the working copy of wfview + // supports, as we must never exceed the available number. + if(numPresetsInFile > 0) + { + colorPrefsType *p; + QString tempName; + for(int pn=0; pn < numColorPresetsTotal; pn++) + { + settings->setArrayIndex(pn); + p = &(colorPreset[pn]); + p->presetNum = settings->value("presetNum", p->presetNum).toInt(); + tempName = settings->value("presetName", *p->presetName).toString(); + if((!tempName.isEmpty()) && tempName.length() < 33) + { + p->presetName->clear(); + p->presetName->append(tempName); + } + p->gridColor.setNamedColor(settings->value("gridColor", p->gridColor.name(QColor::HexArgb)).toString()); + p->axisColor.setNamedColor(settings->value("axisColor", p->axisColor.name(QColor::HexArgb)).toString()); + p->textColor.setNamedColor(settings->value("textColor", p->textColor.name(QColor::HexArgb)).toString()); + p->spectrumLine.setNamedColor(settings->value("spectrumLine", p->spectrumLine.name(QColor::HexArgb)).toString()); + p->spectrumFill.setNamedColor(settings->value("spectrumFill", p->spectrumFill.name(QColor::HexArgb)).toString()); + p->underlayLine.setNamedColor(settings->value("underlayLine", p->underlayLine.name(QColor::HexArgb)).toString()); + p->underlayFill.setNamedColor(settings->value("underlayFill", p->underlayFill.name(QColor::HexArgb)).toString()); + p->plotBackground.setNamedColor(settings->value("plotBackground", p->plotBackground.name(QColor::HexArgb)).toString()); + p->tuningLine.setNamedColor(settings->value("tuningLine", p->tuningLine.name(QColor::HexArgb)).toString()); + p->wfBackground.setNamedColor(settings->value("wfBackground", p->wfBackground.name(QColor::HexArgb)).toString()); + p->wfGrid.setNamedColor(settings->value("wfGrid", p->wfGrid.name(QColor::HexArgb)).toString()); + p->wfAxis.setNamedColor(settings->value("wfAxis", p->wfAxis.name(QColor::HexArgb)).toString()); + p->wfText.setNamedColor(settings->value("wfText", p->wfText.name(QColor::HexArgb)).toString()); + p->meterLevel.setNamedColor(settings->value("meterLevel", p->meterLevel.name(QColor::HexArgb)).toString()); + p->meterAverage.setNamedColor(settings->value("meterAverage", p->meterAverage.name(QColor::HexArgb)).toString()); + p->meterPeak.setNamedColor(settings->value("meterPeak", p->meterPeak.name(QColor::HexArgb)).toString()); + p->meterLowerLine.setNamedColor(settings->value("meterLowerLine", p->meterLowerLine.name(QColor::HexArgb)).toString()); + p->meterLowText.setNamedColor(settings->value("meterLowText", p->meterLowText.name(QColor::HexArgb)).toString()); + } + } + settings->endArray(); + settings->endGroup(); + + // Load color schemes: // Per this bug: https://forum.qt.io/topic/24725/solved-qvariant-will-drop-alpha-value-when-save-qcolor/5 // the alpha channel is dropped when converting raw qvariant of QColor. Therefore, we are storing as unsigned int and converting back. @@ -1935,8 +1993,40 @@ void wfmain::saveSettings() settings->endArray(); settings->endGroup(); - // Note: X and Y get the same colors. See setPlotTheme() function + // Color presets: + settings->beginGroup("ColorPresets"); + settings->setValue("currentColorPresetNumber", prefs.currentColorPresetNumber); + settings->beginWriteArray("ColorPreset", numColorPresetsTotal); + colorPrefsType *p; + for(int pn=0; pn < numColorPresetsTotal; pn++) + { + 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("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("meterPeak", p->meterPeak.name(QColor::HexArgb)); + settings->setValue("meterLowerLine", p->meterLowerLine.name(QColor::HexArgb)); + settings->setValue("meterLowText", p->meterLowText.name(QColor::HexArgb)); + } + settings->endArray(); + settings->endGroup(); + // Note: X and Y get the same colors. See setPlotTheme() function settings->beginGroup("DarkColors"); settings->setValue("Dark_PlotBackground", prefs.colorScheme.Dark_PlotBackground.rgba()); settings->setValue("Dark_PlotAxisPen", prefs.colorScheme.Dark_PlotAxisPen.rgba()); @@ -6525,10 +6615,38 @@ void wfmain::loadColorPresetToUIandPlots(int presetNumber) useColorPreset(&p); } +void wfmain::on_colorRenamePresetBtn_clicked() +{ + int p = ui->colorPresetCombo->currentIndex(); + QString newName; + QMessageBox msgBox; + + bool ok = false; + newName = QInputDialog::getText(this, tr("QInputDialog::getText()"), + tr("Preset Name (32 characters max):"), QLineEdit::Normal, + ui->colorPresetCombo->currentText(), &ok); + if(!ok) + return; + + if(ok && (newName.length() < 33) && !newName.isEmpty()) + { + colorPreset[p].presetName->clear(); + colorPreset[p].presetName->append(newName); + ui->colorPresetCombo->setItemText(p, *(colorPreset[p].presetName)); + qInfo(logSystem()) << "Setting color preset number " << p << " to have text " << newName << ", as read in preset data: " << *(colorPreset[p].presetName) << ", and as read from combo box: " << ui->colorPresetCombo->currentText(); + } else { + if(newName.isEmpty() || (newName.length() > 32)) + { + msgBox.setText("Error, name must be at least one character and not exceed 32 characters."); + msgBox.exec(); + } + } +} void wfmain::on_colorPresetCombo_currentIndexChanged(int index) { qInfo(logSystem()) << "color preset combo box set to index: " << index; + prefs.currentColorPresetNumber = index; loadColorPresetToUIandPlots(index); } @@ -6791,31 +6909,3 @@ void wfmain::on_colorEditMeterText_editingFinished() // ---------- End color UI slots ----------// -void wfmain::on_colorRenamePresetBtn_clicked() -{ - int p = ui->colorPresetCombo->currentIndex(); - QString newName; - QMessageBox msgBox; - - bool ok = false; - newName = QInputDialog::getText(this, tr("QInputDialog::getText()"), - tr("Preset Name (32 characters max):"), QLineEdit::Normal, - ui->colorPresetCombo->currentText(), &ok); - if(!ok) - return; - - if(ok && (newName.length() < 33) && !newName.isEmpty()) - { - colorPreset[p].presetName->clear(); - colorPreset[p].presetName->append(newName); - ui->colorPresetCombo->setItemText(p, *(colorPreset[p].presetName)); - qInfo(logSystem()) << "Setting color preset number " << p << " to have text " << newName << ", as read in preset data: " << *(colorPreset[p].presetName) << ", and as read from combo box: " << ui->colorPresetCombo->currentText(); - } else { - if(newName.isEmpty() || (newName.length() > 32)) - { - msgBox.setText("Error, name must be at least one character and not exceed 32 characters."); - msgBox.exec(); - } - } - -} diff --git a/wfmain.h b/wfmain.h index 25e93f3..11fd2ec 100644 --- a/wfmain.h +++ b/wfmain.h @@ -887,6 +887,7 @@ private: bool enableRigCtlD; quint16 rigCtlPort; colors colorScheme; + int currentColorPresetNumber = 0; QString virtualSerialPort; unsigned char localAFgain; unsigned int wflength; diff --git a/wfmain.ui b/wfmain.ui index c060ab7..e0e785f 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3554,7 +3554,7 @@ - Save Preset + Save Presets From da1cd8b14fac9d4caced6750b701b73cfcfb2a3c Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 17:57:54 -0700 Subject: [PATCH 26/37] Added our "classic" color schemes back in. More tuning needed but a good start. --- wfmain.cpp | 179 +++++++++++++++++++---------------------------------- wfmain.h | 16 ++--- wfmain.ui | 15 ++--- 3 files changed, 75 insertions(+), 135 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 0f4dc8c..1130e34 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -57,13 +57,13 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s setSerialDevicesUI(); - setDefaultColors(); setDefPrefs(); getSettingsFilePath(settingsFile); setupPlots(); setDefaultColorPresets(); + setDefaultColors(); loadSettings(); // Look for saved preferences @@ -1059,9 +1059,6 @@ void wfmain::setUIToPrefs() ui->fullScreenChk->setChecked(prefs.useFullScreen); on_fullScreenChk_clicked(prefs.useFullScreen); - ui->useDarkThemeChk->setChecked(prefs.useDarkMode); - on_useDarkThemeChk_clicked(prefs.useDarkMode); - ui->useSystemThemeChk->setChecked(prefs.useSystemTheme); on_useSystemThemeChk_clicked(prefs.useSystemTheme); @@ -1298,9 +1295,9 @@ void wfmain::setupKeyShortcuts() void wfmain::setDefPrefs() { defPrefs.useFullScreen = false; - defPrefs.useDarkMode = true; defPrefs.useSystemTheme = false; defPrefs.drawPeaks = true; + defPrefs.currentColorPresetNumber = 0; defPrefs.underlayMode = underlayNone; defPrefs.underlayBufferSize = 64; defPrefs.wfAntiAlias = false; @@ -1345,7 +1342,6 @@ void wfmain::loadSettings() // UI: (full screen, dark theme, draw peaks, colors, etc) settings->beginGroup("Interface"); prefs.useFullScreen = settings->value("UseFullScreen", defPrefs.useFullScreen).toBool(); - prefs.useDarkMode = settings->value("UseDarkMode", defPrefs.useDarkMode).toBool(); prefs.useSystemTheme = settings->value("UseSystemTheme", defPrefs.useSystemTheme).toBool(); prefs.wftheme = settings->value("WFTheme", defPrefs.wftheme).toInt(); prefs.plotFloor = settings->value("plotFloor", defPrefs.plotFloor).toInt(); @@ -1419,40 +1415,6 @@ void wfmain::loadSettings() settings->endArray(); settings->endGroup(); - - // Load color schemes: - // Per this bug: https://forum.qt.io/topic/24725/solved-qvariant-will-drop-alpha-value-when-save-qcolor/5 - // the alpha channel is dropped when converting raw qvariant of QColor. Therefore, we are storing as unsigned int and converting back. - - settings->beginGroup("DarkColors"); - prefs.colorScheme.Dark_PlotBackground = QColor::fromRgba(settings->value("Dark_PlotBackground", defaultColors.Dark_PlotBackground.rgba()).toUInt()); - prefs.colorScheme.Dark_PlotAxisPen = QColor::fromRgba(settings->value("Dark_PlotAxisPen", defaultColors.Dark_PlotAxisPen.rgba()).toUInt()); - - prefs.colorScheme.Dark_PlotLegendTextColor = QColor::fromRgba(settings->value("Dark_PlotLegendTextColor", defaultColors.Dark_PlotLegendTextColor.rgba()).toUInt()); - prefs.colorScheme.Dark_PlotLegendBorderPen = QColor::fromRgba(settings->value("Dark_PlotLegendBorderPen", defaultColors.Dark_PlotLegendBorderPen.rgba()).toUInt()); - prefs.colorScheme.Dark_PlotLegendBrush = QColor::fromRgba(settings->value("Dark_PlotLegendBrush", defaultColors.Dark_PlotLegendBrush.rgba()).toUInt()); - - prefs.colorScheme.Dark_PlotTickLabel = QColor::fromRgba(settings->value("Dark_PlotTickLabel", defaultColors.Dark_PlotTickLabel.rgba()).toUInt()); - prefs.colorScheme.Dark_PlotBasePen = QColor::fromRgba(settings->value("Dark_PlotBasePen", defaultColors.Dark_PlotBasePen.rgba()).toUInt()); - prefs.colorScheme.Dark_PlotTickPen = QColor::fromRgba(settings->value("Dark_PlotTickPen", defaultColors.Dark_PlotTickPen.rgba()).toUInt()); - - prefs.colorScheme.Dark_PeakPlotLine = QColor::fromRgba(settings->value("Dark_PeakPlotLine", defaultColors.Dark_PeakPlotLine.rgba()).toUInt()); - prefs.colorScheme.Dark_TuningLine = QColor::fromRgba(settings->value("Dark_TuningLine", defaultColors.Dark_TuningLine.rgba()).toUInt()); - settings->endGroup(); - - settings->beginGroup("LightColors"); - prefs.colorScheme.Light_PlotBackground = QColor::fromRgba(settings->value("Light_PlotBackground", defaultColors.Light_PlotBackground.rgba()).toUInt()); - prefs.colorScheme.Light_PlotAxisPen = QColor::fromRgba(settings->value("Light_PlotAxisPen", defaultColors.Light_PlotAxisPen.rgba()).toUInt()); - prefs.colorScheme.Light_PlotLegendTextColor = QColor::fromRgba(settings->value("Light_PlotLegendTextColo", defaultColors.Light_PlotLegendTextColor.rgba()).toUInt()); - prefs.colorScheme.Light_PlotLegendBorderPen = QColor::fromRgba(settings->value("Light_PlotLegendBorderPen", defaultColors.Light_PlotLegendBorderPen.rgba()).toUInt()); - prefs.colorScheme.Light_PlotLegendBrush = QColor::fromRgba(settings->value("Light_PlotLegendBrush", defaultColors.Light_PlotLegendBrush.rgba()).toUInt()); - prefs.colorScheme.Light_PlotTickLabel = QColor::fromRgba(settings->value("Light_PlotTickLabel", defaultColors.Light_PlotTickLabel.rgba()).toUInt()); - prefs.colorScheme.Light_PlotBasePen = QColor::fromRgba(settings->value("Light_PlotBasePen", defaultColors.Light_PlotBasePen.rgba()).toUInt()); - prefs.colorScheme.Light_PlotTickPen = QColor::fromRgba(settings->value("Light_PlotTickPen", defaultColors.Light_PlotTickPen.rgba()).toUInt()); - prefs.colorScheme.Light_PeakPlotLine = QColor::fromRgba(settings->value("Light_PeakPlotLine", defaultColors.Light_PeakPlotLine.rgba()).toUInt()); - prefs.colorScheme.Light_TuningLine = QColor::fromRgba(settings->value("Light_TuningLine", defaultColors.Light_TuningLine.rgba()).toUInt()); - settings->endGroup(); - // Radio and Comms: C-IV addr, port to use settings->beginGroup("Radio"); prefs.radioCIVAddr = (unsigned char)settings->value("RigCIVuInt", defPrefs.radioCIVAddr).toInt(); @@ -1911,7 +1873,6 @@ void wfmain::saveSettings() settings->beginGroup("Interface"); settings->setValue("UseFullScreen", prefs.useFullScreen); settings->setValue("UseSystemTheme", prefs.useSystemTheme); - settings->setValue("UseDarkMode", prefs.useDarkMode); settings->setValue("DrawPeaks", prefs.drawPeaks); settings->setValue("underlayMode", prefs.underlayMode); settings->setValue("underlayBufferSize", prefs.underlayBufferSize); @@ -2026,51 +1987,6 @@ void wfmain::saveSettings() settings->endArray(); settings->endGroup(); - // Note: X and Y get the same colors. See setPlotTheme() function - settings->beginGroup("DarkColors"); - settings->setValue("Dark_PlotBackground", prefs.colorScheme.Dark_PlotBackground.rgba()); - settings->setValue("Dark_PlotAxisPen", prefs.colorScheme.Dark_PlotAxisPen.rgba()); - settings->setValue("Dark_PlotLegendTextColor", prefs.colorScheme.Dark_PlotLegendTextColor.rgba()); - settings->setValue("Dark_PlotLegendBorderPen", prefs.colorScheme.Dark_PlotLegendBorderPen.rgba()); - settings->setValue("Dark_PlotLegendBrush", prefs.colorScheme.Dark_PlotLegendBrush.rgba()); - settings->setValue("Dark_PlotTickLabel", prefs.colorScheme.Dark_PlotTickLabel.rgba()); - settings->setValue("Dark_PlotBasePen", prefs.colorScheme.Dark_PlotBasePen.rgba()); - settings->setValue("Dark_PlotTickPen", prefs.colorScheme.Dark_PlotTickPen.rgba()); - settings->setValue("Dark_PeakPlotLine", prefs.colorScheme.Dark_PeakPlotLine.rgba()); - settings->setValue("Dark_TuningLine", prefs.colorScheme.Dark_TuningLine.rgba()); - settings->endGroup(); - - settings->beginGroup("LightColors"); - settings->setValue("Light_PlotBackground", prefs.colorScheme.Light_PlotBackground.rgba()); - settings->setValue("Light_PlotAxisPen", prefs.colorScheme.Light_PlotAxisPen.rgba()); - settings->setValue("Light_PlotLegendTextColor", prefs.colorScheme.Light_PlotLegendTextColor.rgba()); - settings->setValue("Light_PlotLegendBorderPen", prefs.colorScheme.Light_PlotLegendBorderPen.rgba()); - settings->setValue("Light_PlotLegendBrush", prefs.colorScheme.Light_PlotLegendBrush.rgba()); - settings->setValue("Light_PlotTickLabel", prefs.colorScheme.Light_PlotTickLabel.rgba()); - settings->setValue("Light_PlotBasePen", prefs.colorScheme.Light_PlotBasePen.rgba()); - settings->setValue("Light_PlotTickPen", prefs.colorScheme.Light_PlotTickPen.rgba()); - settings->setValue("Light_PeakPlotLine", prefs.colorScheme.Light_PeakPlotLine.rgba()); - settings->setValue("Light_TuningLine", prefs.colorScheme.Light_TuningLine.rgba()); - - settings->endGroup(); - - // This is a reference to see how the preference file is encoded. - settings->beginGroup("StandardColors"); - - settings->setValue("white", QColor(Qt::white).rgba()); - settings->setValue("black", QColor(Qt::black).rgba()); - - settings->setValue("red_opaque", QColor(Qt::red).rgba()); - settings->setValue("red_translucent", QColor(255,0,0,128).rgba()); - settings->setValue("green_opaque", QColor(Qt::green).rgba()); - settings->setValue("green_translucent", QColor(0,255,0,128).rgba()); - settings->setValue("blue_opaque", QColor(Qt::blue).rgba()); - settings->setValue("blue_translucent", QColor(0,0,255,128).rgba()); - settings->setValue("cyan", QColor(Qt::cyan).rgba()); - settings->setValue("magenta", QColor(Qt::magenta).rgba()); - settings->setValue("yellow", QColor(Qt::yellow).rgba()); - settings->endGroup(); - settings->beginGroup("Server"); settings->setValue("ServerEnabled", serverConfig.enabled); @@ -2655,14 +2571,6 @@ void wfmain::showStatusBarText(QString text) ui->statusBar->showMessage(text, 5000); } -void wfmain::on_useDarkThemeChk_clicked(bool checked) -{ - //setAppTheme(checked); - setPlotTheme(wf, checked); - setPlotTheme(plot, checked); - prefs.useDarkMode = checked; -} - void wfmain::on_useSystemThemeChk_clicked(bool checked) { setAppTheme(!checked); @@ -2696,31 +2604,65 @@ void wfmain::setAppTheme(bool isCustom) void wfmain::setDefaultColors() { - defaultColors.Dark_PlotBackground = QColor(0,0,0,255); - defaultColors.Dark_PlotAxisPen = QColor(75,75,75,255); - defaultColors.Dark_PlotLegendTextColor = QColor(255,255,255,255); - defaultColors.Dark_PlotLegendBorderPen = QColor(255,255,255,255); - defaultColors.Dark_PlotLegendBrush = QColor(0,0,0,200); - defaultColors.Dark_PlotTickLabel = QColor(Qt::white); - defaultColors.Dark_PlotBasePen = QColor(Qt::white); - defaultColors.Dark_PlotTickPen = QColor(Qt::white); - defaultColors.Dark_PeakPlotLine = QColor(Qt::yellow); - defaultColors.Dark_TuningLine = QColor(Qt::cyan); + // These are some intended built-in color schemes. + // They can be user-modified and may be restored simply + // by removing the relevent color preset preference file entries. - defaultColors.Light_PlotBackground = QColor(255,255,255,255); - defaultColors.Light_PlotAxisPen = QColor(200,200,200,255); - defaultColors.Light_PlotLegendTextColor = QColor(0,0,0,255); - defaultColors.Light_PlotLegendBorderPen = QColor(0,0,0,255); - defaultColors.Light_PlotLegendBrush = QColor(255,255,255,200); - defaultColors.Light_PlotTickLabel = QColor(Qt::black); - defaultColors.Light_PlotBasePen = QColor(Qt::black); - defaultColors.Light_PlotTickPen = QColor(Qt::black); - defaultColors.Light_PeakPlotLine = QColor(Qt::blue); - defaultColors.Light_TuningLine = QColor(Qt::blue); + colorPrefsType *pDark = &colorPreset[0]; + colorPrefsType *pLight = &colorPreset[1]; + + // Dark: + pDark->presetName->clear(); + pDark->presetName->append("Dark"); + pDark->plotBackground = QColor(0,0,0,255); + pDark->axisColor = QColor(Qt::white); + pDark->textColor = QColor(255,255,255,255); + pDark->gridColor = QColor("transparent"); + pDark->spectrumFill = QColor("transparent"); + pDark->spectrumLine = QColor(Qt::yellow); + pDark->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); + pDark->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); + pDark->tuningLine = QColor(Qt::cyan); + + pDark->meterLevel = QColor("#148CD2").darker(); + pDark->meterAverage = QColor("#3FB7CD"); + pDark->meterPeak = QColor("#3CA0DB").lighter(); + pDark->meterLowerLine = QColor("#eff0f1"); + pDark->meterLowText = QColor("#eff0f1"); + + pDark->wfBackground = QColor(Qt::black); + pDark->wfAxis = QColor(Qt::white); + pDark->wfGrid = QColor("transparent"); + pDark->wfText = QColor(Qt::white); + + // Bright: + pLight->presetName->clear(); + pLight->presetName->append("Bright"); + pLight->plotBackground = QColor(Qt::white); + pLight->axisColor = QColor(200,200,200,255); + pLight->gridColor = QColor("transparent"); + pLight->textColor = QColor(Qt::black); + pLight->spectrumFill = QColor("transparent"); + pLight->spectrumLine = QColor(Qt::black); + pLight->underlayLine = QColor(Qt::blue); + pLight->tuningLine = QColor(Qt::darkBlue); + + pLight->meterAverage = QColor("#3FB7CD"); + pLight->meterPeak = QColor("#3CA0DB"); + pLight->meterLowerLine = QColor(Qt::black); + pLight->meterLowText = QColor(Qt::black); + + pLight->wfBackground = QColor(Qt::white); + pLight->wfAxis = QColor(200,200,200,255); + pLight->wfGrid = QColor("transparent"); + pLight->wfText = QColor(Qt::black); } void wfmain::setPlotTheme(QCustomPlot *plot, bool isDark) { + + // TODO: Remove this function + /* if(isDark) { plot->setBackground(prefs.colorScheme.Dark_PlotBackground); @@ -2767,6 +2709,7 @@ void wfmain::setPlotTheme(QCustomPlot *plot, bool isDark) plot->graph(0)->setPen(prefs.colorScheme.Light_PeakPlotLine); freqIndicatorLine->setPen(prefs.colorScheme.Light_TuningLine); } + */ } void wfmain::doCmd(commandtype cmddata) @@ -6909,3 +6852,11 @@ void wfmain::on_colorEditMeterText_editingFinished() // ---------- End color UI slots ----------// + +void wfmain::on_colorRevertPresetBtn_clicked() +{ + // revert to default colors: + // TODO: Add arguments to setDefaultColors() + //int pn = ui->colorPresetCombo->currentIndex(); + //setDefaultColors(); +} diff --git a/wfmain.h b/wfmain.h index 11fd2ec..f2e082d 100644 --- a/wfmain.h +++ b/wfmain.h @@ -329,14 +329,8 @@ private slots: void on_scopeEdgeCombo_currentIndexChanged(int index); - // void on_modeSelectCombo_currentIndexChanged(int index); - - void on_useDarkThemeChk_clicked(bool checked); - void on_modeSelectCombo_activated(int index); - // void on_freqDial_actionTriggered(int action); - void on_freqDial_valueChanged(int value); void on_band6mbtn_clicked(); @@ -385,7 +379,6 @@ private slots: void on_saveSettingsBtn_clicked(); - void on_debugBtn_clicked(); void on_pttEnableChk_clicked(bool checked); @@ -634,6 +627,8 @@ private slots: void on_colorRenamePresetBtn_clicked(); + void on_colorRevertPresetBtn_clicked(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -649,6 +644,7 @@ private: QCPItemLine * freqIndicatorLine; //commHandler *comm; void setAppTheme(bool isCustom); + // TODO: Remove this function void setPlotTheme(QCustomPlot *plot, bool isDark); void prepareWf(); void prepareWf(unsigned int wfLength); @@ -839,6 +835,8 @@ private: datekind datesetpoint; freqMemory mem; + + // TODO: Remove colorScheme in favor of colorPreset struct colors { QColor Dark_PlotBackground; QColor Dark_PlotAxisPen; @@ -868,7 +866,6 @@ private: struct preferences { bool useFullScreen; - bool useDarkMode; bool useSystemTheme; bool drawPeaks; underlay_t underlayMode = underlayNone; @@ -886,7 +883,6 @@ private: bool enableLAN; bool enableRigCtlD; quint16 rigCtlPort; - colors colorScheme; int currentColorPresetNumber = 0; QString virtualSerialPort; unsigned char localAFgain; @@ -910,7 +906,7 @@ private: audioSetup rxSetup; audioSetup txSetup; - + // TODO: Remove colors defaultColors; void setDefaultColors(); // populate with default values diff --git a/wfmain.ui b/wfmain.ui index e0e785f..0a68604 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2847,13 +2847,6 @@ - - - - Waterfall Dark Theme - - - @@ -2865,16 +2858,16 @@ - + - Use System Theme + Anti-Alias Waterfall - + - Anti-Alias Waterfall + Use System Theme From 9afc44ce42cbef685f83bf6ffdf5272e7d92838b Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 18:09:20 -0700 Subject: [PATCH 27/37] Refresh the meter when updating colors immediately. --- meter.cpp | 1 + wfmain.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/meter.cpp b/meter.cpp index 478f90a..b3d10a2 100644 --- a/meter.cpp +++ b/meter.cpp @@ -57,6 +57,7 @@ void meter::setColors(QColor current, QColor peak, averageColor = average; lowLineColor = lowLine; lowTextColor = lowText; + this->update(); } void meter::clearMeterOnPTTtoggle() diff --git a/wfmain.cpp b/wfmain.cpp index 1130e34..41ecbd6 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2622,7 +2622,7 @@ void wfmain::setDefaultColors() pDark->spectrumLine = QColor(Qt::yellow); pDark->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); pDark->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); - pDark->tuningLine = QColor(Qt::cyan); + pDark->tuningLine = QColor("#ff55ffff"); pDark->meterLevel = QColor("#148CD2").darker(); pDark->meterAverage = QColor("#3FB7CD"); From fa0752518d5e73af3e72d15a20af6c3dd83a2e35 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 19:39:20 -0700 Subject: [PATCH 28/37] More color tuning! --- wfmain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wfmain.cpp b/wfmain.cpp index 41ecbd6..abc4d4d 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2620,7 +2620,8 @@ void wfmain::setDefaultColors() pDark->gridColor = QColor("transparent"); pDark->spectrumFill = QColor("transparent"); pDark->spectrumLine = QColor(Qt::yellow); - pDark->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); + //pDark->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); + pDark->underlayLine = QColor("#9633ff55"); pDark->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); pDark->tuningLine = QColor("#ff55ffff"); From 2a456b2adb4d3f8133a0edc0811e9c71f589b4cd Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 20:44:58 -0700 Subject: [PATCH 29/37] Small cleanup. --- wfmain.cpp | 62 ------------------------------------------------------ wfmain.h | 32 ---------------------------- 2 files changed, 94 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index abc4d4d..128d8b2 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -985,12 +985,6 @@ void wfmain::setInitialTiming() delayedCommand->setSingleShot(false); connect(delayedCommand, SIGNAL(timeout()), this, SLOT(sendRadioCommandLoop())); - // TODO: Remove this: -// periodicPollingTimer = new QTimer(this); -// periodicPollingTimer->setInterval(10); -// periodicPollingTimer->setSingleShot(false); - //connect(periodicPollingTimer, SIGNAL(timeout()), this, SLOT(sendRadioCommandLoop())); - pttTimer = new QTimer(this); pttTimer->setInterval(180*1000); // 3 minute max transmit time in ms pttTimer->setSingleShot(true); @@ -2659,60 +2653,6 @@ void wfmain::setDefaultColors() pLight->wfText = QColor(Qt::black); } -void wfmain::setPlotTheme(QCustomPlot *plot, bool isDark) -{ - - // TODO: Remove this function - /* - if(isDark) - { - plot->setBackground(prefs.colorScheme.Dark_PlotBackground); - //plot->setBackground(QColor(0,0,0,255)); - - plot->xAxis->grid()->setPen(prefs.colorScheme.Dark_PlotAxisPen); - plot->yAxis->grid()->setPen(prefs.colorScheme.Dark_PlotAxisPen); - - plot->legend->setTextColor(prefs.colorScheme.Dark_PlotLegendTextColor); - plot->legend->setBorderPen(prefs.colorScheme.Dark_PlotLegendBorderPen); - plot->legend->setBrush(prefs.colorScheme.Dark_PlotLegendBrush); - - plot->xAxis->setTickLabelColor(prefs.colorScheme.Dark_PlotTickLabel); - plot->xAxis->setLabelColor(prefs.colorScheme.Dark_PlotTickLabel); - plot->yAxis->setTickLabelColor(prefs.colorScheme.Dark_PlotTickLabel); - plot->yAxis->setLabelColor(prefs.colorScheme.Dark_PlotTickLabel); - - plot->xAxis->setBasePen(prefs.colorScheme.Dark_PlotBasePen); - plot->xAxis->setTickPen(prefs.colorScheme.Dark_PlotTickPen); - plot->yAxis->setBasePen(prefs.colorScheme.Dark_PlotBasePen); - plot->yAxis->setTickPen(prefs.colorScheme.Dark_PlotTickPen); - plot->graph(0)->setPen(prefs.colorScheme.Dark_PeakPlotLine); - freqIndicatorLine->setPen(prefs.colorScheme.Dark_TuningLine); - } else { - //color = ui->groupBox->palette().color(QPalette::Button); - - plot->setBackground(prefs.colorScheme.Light_PlotBackground); - plot->xAxis->grid()->setPen(prefs.colorScheme.Light_PlotAxisPen); - plot->yAxis->grid()->setPen(prefs.colorScheme.Light_PlotAxisPen); - - plot->legend->setTextColor(prefs.colorScheme.Light_PlotLegendTextColor); - plot->legend->setBorderPen(prefs.colorScheme.Light_PlotLegendBorderPen); - plot->legend->setBrush(prefs.colorScheme.Light_PlotLegendBrush); - - plot->xAxis->setTickLabelColor(prefs.colorScheme.Light_PlotTickLabel); - plot->xAxis->setLabelColor(prefs.colorScheme.Light_PlotTickLabel); - plot->yAxis->setTickLabelColor(prefs.colorScheme.Light_PlotTickLabel); - plot->yAxis->setLabelColor(prefs.colorScheme.Light_PlotTickLabel); - - plot->xAxis->setBasePen(prefs.colorScheme.Light_PlotBasePen); - plot->xAxis->setTickPen(prefs.colorScheme.Light_PlotTickPen); - plot->yAxis->setBasePen(prefs.colorScheme.Light_PlotBasePen); - plot->yAxis->setTickPen(prefs.colorScheme.Light_PlotTickLabel); - plot->graph(0)->setPen(prefs.colorScheme.Light_PeakPlotLine); - freqIndicatorLine->setPen(prefs.colorScheme.Light_TuningLine); - } - */ -} - void wfmain::doCmd(commandtype cmddata) { cmds cmd = cmddata.cmd; @@ -2837,10 +2777,8 @@ void wfmain::doCmd(commandtype cmddata) doCmd(cmd); break; } - } - void wfmain::doCmd(cmds cmd) { // Use this function to take action upon a command. diff --git a/wfmain.h b/wfmain.h index f2e082d..f0d7e8e 100644 --- a/wfmain.h +++ b/wfmain.h @@ -642,10 +642,7 @@ private: QCustomPlot *plot; // line plot QCustomPlot *wf; // waterfall image QCPItemLine * freqIndicatorLine; - //commHandler *comm; void setAppTheme(bool isCustom); - // TODO: Remove this function - void setPlotTheme(QCustomPlot *plot, bool isDark); void prepareWf(); void prepareWf(unsigned int wfLength); void preparePlasma(); @@ -836,32 +833,6 @@ private: freqMemory mem; - // TODO: Remove colorScheme in favor of colorPreset - struct colors { - QColor Dark_PlotBackground; - QColor Dark_PlotAxisPen; - QColor Dark_PlotLegendTextColor; - QColor Dark_PlotLegendBorderPen; - QColor Dark_PlotLegendBrush; - QColor Dark_PlotTickLabel; - QColor Dark_PlotBasePen; - QColor Dark_PlotTickPen; - QColor Dark_PeakPlotLine; - QColor Dark_TuningLine; - - QColor Light_PlotBackground; - QColor Light_PlotAxisPen; - QColor Light_PlotLegendTextColor; - QColor Light_PlotLegendBorderPen; - QColor Light_PlotLegendBrush; - QColor Light_PlotTickLabel; - QColor Light_PlotBasePen; - QColor Light_PlotTickPen; - QColor Light_PeakPlotLine; - QColor Light_TuningLine; - - } colorScheme; - colorPrefsType colorPreset[numColorPresetsTotal]; struct preferences { @@ -906,9 +877,6 @@ private: audioSetup rxSetup; audioSetup txSetup; - // TODO: Remove - colors defaultColors; - void setDefaultColors(); // populate with default values void useColors(); // set the plot up void setDefPrefs(); // populate default values to default prefs From 8012a58bd9ceb469ecdbe870d80a2857da1b3430 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 21:22:01 -0700 Subject: [PATCH 30/37] Added separate colors for the high meter scale and the peak indicator. --- colorprefs.h | 3 +- meter.cpp | 49 ++-- meter.h | 5 +- wfmain.cpp | 53 ++-- wfmain.h | 12 +- wfmain.ui | 683 ++++++++++++++++++++++++++------------------------- 6 files changed, 433 insertions(+), 372 deletions(-) diff --git a/colorprefs.h b/colorprefs.h index 5678f64..7db11fc 100644 --- a/colorprefs.h +++ b/colorprefs.h @@ -28,7 +28,8 @@ struct colorPrefsType{ // Meters: QColor meterLevel; QColor meterAverage; - QColor meterPeak; + QColor meterPeakLevel; + QColor meterPeakScale; QColor meterLowerLine; QColor meterLowText; }; diff --git a/meter.cpp b/meter.cpp index b3d10a2..9a24035 100644 --- a/meter.cpp +++ b/meter.cpp @@ -48,13 +48,21 @@ meter::meter(QWidget *parent) : QWidget(parent) } -void meter::setColors(QColor current, QColor peak, +void meter::setColors(QColor current, QColor peakScale, QColor peakLevel, QColor average, QColor lowLine, QColor lowText) { currentColor = current; - peakColor = peak; + + peakColor = peakLevel; // color for the peak level indicator + highLineColor = peakScale; // color for the red side of the scale + highTextColor = peakScale; // color for the red side of the scale's text + averageColor = average; + + midScaleColor = QColor(Qt::yellow); + centerTuningColor = QColor(Qt::green); + lowLineColor = lowLine; lowTextColor = lowText; this->update(); @@ -299,9 +307,8 @@ void meter::drawScaleRaw(QPainter *qp) // Line: X1, Y1 -->to--> X2, Y2 qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); - } void meter::drawScaleVd(QPainter *qp) @@ -338,7 +345,7 @@ void meter::drawScaleVd(QPainter *qp) // Line: X1, Y1 -->to--> X2, Y2 qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); } @@ -349,7 +356,7 @@ void meter::drawScaleCenter(QPainter *qp) qp->setPen(lowLineColor); qp->drawText(60+mXstart,scaleTextYstart, QString("-")); - qp->setPen(Qt::green); + qp->setPen(centerTuningColor); // Attempt to draw the zero at the actual center qp->drawText(128-2+mXstart,scaleTextYstart, QString("0")); @@ -360,7 +367,7 @@ void meter::drawScaleCenter(QPainter *qp) qp->setPen(lowLineColor); qp->drawLine(mXstart,scaleLineYstart,128-32+mXstart,scaleLineYstart); - qp->setPen(Qt::green); + qp->setPen(centerTuningColor); qp->drawLine(128-32+mXstart,scaleLineYstart,128+32+mXstart,scaleLineYstart); qp->setPen(lowLineColor); @@ -394,7 +401,7 @@ void meter::drawScalePo(QPainter *qp) //qDebug() << "meter i: " << i; dnPerWatt = (213-143.0f) / 50.0f; // 1.4 dn per watt // P=5 here. - qp->setPen(Qt::yellow); + qp->setPen(midScaleColor); int k=0; for(i=mXstart+143; isetPen(Qt::red); + qp->setPen(highTextColor); for(i=mXstart+213; ito--> X2, Y2 qp->drawLine(mXstart,scaleLineYstart,213+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(213+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); (void)qp; @@ -444,7 +451,7 @@ void meter::drawScaleALC(QPainter *qp) alc +=20; } - qp->setPen(Qt::red); + qp->setPen(highTextColor); for(; isetPen(lowLineColor); qp->drawLine(mXstart,scaleLineYstart,100+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(100+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); (void)qp; @@ -495,7 +502,7 @@ void meter::drawScaleComp(QPainter *qp) // Line: X1, Y1 -->to--> X2, Y2 qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); } @@ -507,27 +514,29 @@ void meter::drawScaleSWR(QPainter *qp) // 0080=SWR2.0, // 0120=SWR3.0 + qp->setPen(lowTextColor); qp->drawText(mXstart,scaleTextYstart, QString("1.0")); qp->drawText(24+mXstart,scaleTextYstart, QString("1.3")); qp->drawText(48+mXstart,scaleTextYstart, QString("1.5")); qp->drawText(80+mXstart,scaleTextYstart, QString("2.0")); qp->drawText(100+mXstart,scaleTextYstart, QString("2.5")); + qp->setPen(highTextColor); qp->drawText(120+mXstart,scaleTextYstart, QString("3.0")); + qp->setPen(lowLineColor); qp->drawLine( 0+mXstart,scaleTextYstart, 0+mXstart, scaleTextYstart+5); qp->drawLine( 24+mXstart,scaleTextYstart, 24+mXstart, scaleTextYstart+5); qp->drawLine( 48+mXstart,scaleTextYstart, 48+mXstart, scaleTextYstart+5); qp->drawLine( 80+mXstart,scaleTextYstart, 80+mXstart, scaleTextYstart+5); qp->drawLine(100+mXstart,scaleTextYstart,100+mXstart, scaleTextYstart+5); // does not draw? + qp->setPen(highLineColor); qp->drawLine(120+mXstart,scaleTextYstart,120+mXstart, scaleTextYstart+5); qp->setPen(lowLineColor); qp->drawLine(mXstart,scaleLineYstart,100+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(100+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); - - } void meter::drawScaleId(QPainter *qp) @@ -565,7 +574,7 @@ void meter::drawScaleId(QPainter *qp) // Line: X1, Y1 -->to--> X2, Y2 qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); } @@ -594,7 +603,7 @@ void meter::drawScaleS(QPainter *qp) s = 20; i+=20; - qp->setPen(Qt::red); + qp->setPen(highTextColor); for(; isetPen(lowLineColor); - qp->drawLine(mXstart,scaleLineYstart,peakRedLevel+mXstart,scaleLineYstart); - qp->setPen(Qt::red); + qp->setPen(highLineColor); qp->drawLine(peakRedLevel+mXstart,scaleLineYstart,255+mXstart,scaleLineYstart); - } diff --git a/meter.h b/meter.h index fc29168..b57e362 100644 --- a/meter.h +++ b/meter.h @@ -30,7 +30,7 @@ public slots: void setMeterShortString(QString); QString getMeterShortString(); meterKind getMeterType(); - void setColors(QColor current, QColor peak, + void setColors(QColor current, QColor peakScale, QColor peakLevel, QColor average, QColor lowLine, QColor lowText); @@ -87,6 +87,9 @@ private: QColor highTextColor; QColor highLineColor; + QColor midScaleColor; + QColor centerTuningColor; + }; #endif // METER_H diff --git a/wfmain.cpp b/wfmain.cpp index 128d8b2..9b1f2bc 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -1401,7 +1401,8 @@ void wfmain::loadSettings() p->wfText.setNamedColor(settings->value("wfText", p->wfText.name(QColor::HexArgb)).toString()); p->meterLevel.setNamedColor(settings->value("meterLevel", p->meterLevel.name(QColor::HexArgb)).toString()); p->meterAverage.setNamedColor(settings->value("meterAverage", p->meterAverage.name(QColor::HexArgb)).toString()); - p->meterPeak.setNamedColor(settings->value("meterPeak", p->meterPeak.name(QColor::HexArgb)).toString()); + p->meterPeakLevel.setNamedColor(settings->value("meterPeakLevel", p->meterPeakLevel.name(QColor::HexArgb)).toString()); + p->meterPeakScale.setNamedColor(settings->value("meterPeakScale", p->meterPeakScale.name(QColor::HexArgb)).toString()); p->meterLowerLine.setNamedColor(settings->value("meterLowerLine", p->meterLowerLine.name(QColor::HexArgb)).toString()); p->meterLowText.setNamedColor(settings->value("meterLowText", p->meterLowText.name(QColor::HexArgb)).toString()); } @@ -1974,7 +1975,8 @@ void wfmain::saveSettings() 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("meterPeak", p->meterPeak.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)); } @@ -2621,7 +2623,8 @@ void wfmain::setDefaultColors() pDark->meterLevel = QColor("#148CD2").darker(); pDark->meterAverage = QColor("#3FB7CD"); - pDark->meterPeak = QColor("#3CA0DB").lighter(); + pDark->meterPeakScale = QColor(Qt::red); + pDark->meterPeakLevel = QColor("#3CA0DB").lighter(); pDark->meterLowerLine = QColor("#eff0f1"); pDark->meterLowText = QColor("#eff0f1"); @@ -2643,7 +2646,8 @@ void wfmain::setDefaultColors() pLight->tuningLine = QColor(Qt::darkBlue); pLight->meterAverage = QColor("#3FB7CD"); - pLight->meterPeak = QColor("#3CA0DB"); + pLight->meterPeakLevel = QColor("#3CA0DB"); + pLight->meterPeakScale = QColor(Qt::darkRed); pLight->meterLowerLine = QColor(Qt::black); pLight->meterLowText = QColor(Qt::black); @@ -6338,8 +6342,8 @@ void wfmain::useColorPreset(colorPrefsType *cp) wf->setBackground(cp->wfBackground); - ui->meterSPoWidget->setColors(cp->meterLevel, cp->meterPeak, cp->meterAverage, cp->meterLowerLine, cp->meterLowText); - ui->meter2Widget->setColors(cp->meterLevel, cp->meterPeak, cp->meterAverage, cp->meterLowerLine, cp->meterLowText); + 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); } void wfmain::setColorButtonOperations(QColor *colorStore, @@ -6434,7 +6438,8 @@ void wfmain::setDefaultColorPresets() p->meterLevel = QColor("#148CD2").darker(); p->meterAverage = QColor("#3FB7CD"); - p->meterPeak = QColor("#3CA0DB").lighter(); + p->meterPeakLevel = QColor("#3CA0DB").lighter(); + p->meterPeakScale = QColor(Qt::red); p->meterLowerLine = QColor("#eff0f1"); p->meterLowText = QColor("#eff0f1"); @@ -6485,7 +6490,8 @@ void wfmain::loadColorPresetToUIandPlots(int presetNumber) setEditAndLedFromColor(p.meterLevel, ui->colorEditMeterLevel, ui->colorSwatchMeterLevel); setEditAndLedFromColor(p.meterAverage, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); - setEditAndLedFromColor(p.meterPeak, ui->colorEditMeterPeak, ui->colorSwatchMeterPeak); + 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); @@ -6747,18 +6753,32 @@ void wfmain::on_colorEditMeterAvg_editingFinished() setColorLineEditOperations(c, ui->colorEditMeterAvg, ui->colorSwatchMeterAverage); } -// Meter Peak: -void wfmain::on_colorSetBtnMeterPeak_clicked() +// Meter Peak Level: +void wfmain::on_colorSetBtnMeterPeakLevel_clicked() { int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterPeak); - setColorButtonOperations(c, ui->colorEditMeterPeak, ui->colorSwatchMeterPeak); + QColor *c = &(colorPreset[pos].meterPeakLevel); + setColorButtonOperations(c, ui->colorEditMeterPeakLevel, ui->colorSwatchMeterPeakLevel); } -void wfmain::on_colorEditMeterPeak_editingFinished() +void wfmain::on_colorEditMeterPeakLevel_editingFinished() { int pos = ui->colorPresetCombo->currentIndex(); - QColor *c = &(colorPreset[pos].meterPeak); - setColorLineEditOperations(c, ui->colorEditMeterPeak, ui->colorSwatchMeterPeak); + 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): @@ -6799,3 +6819,6 @@ void wfmain::on_colorRevertPresetBtn_clicked() //int pn = ui->colorPresetCombo->currentIndex(); //setDefaultColors(); } + + + diff --git a/wfmain.h b/wfmain.h index f0d7e8e..d35c811 100644 --- a/wfmain.h +++ b/wfmain.h @@ -613,10 +613,6 @@ private slots: void on_colorEditMeterAvg_editingFinished(); - void on_colorSetBtnMeterPeak_clicked(); - - void on_colorEditMeterPeak_editingFinished(); - void on_colorSetBtnMeterScale_clicked(); void on_colorEditMeterScale_editingFinished(); @@ -629,6 +625,14 @@ private slots: void on_colorRevertPresetBtn_clicked(); + void on_colorSetBtnMeterPeakLevel_clicked(); + + void on_colorEditMeterPeakLevel_editingFinished(); + + void on_colorSetBtnMeterPeakScale_clicked(); + + void on_colorEditMeterPeakScale_editingFinished(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); diff --git a/wfmain.ui b/wfmain.ui index 0a68604..1dea96e 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3095,139 +3095,13 @@ 0 - 0 + -369 767 - 582 + 612 - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - Waterfall Back - - - - - - - Meter Scale - - - - - - - Meter Peak - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - - - - Text - - - - - - - - - - Grid - - - - - - - - - - - - - Meter Text - - - - - - - Spectrum Fill - - - - - - - - - - Meter Level - - - - - - - - - - Rename Preset - - - - + @@ -3240,101 +3114,10 @@ - - + + - Waterfall Text - - - - - - - Waterfall Grid - - - - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Axis + Text @@ -3373,28 +3156,22 @@ - - + + - Spectrum Line + Rename Preset - - - - - + + - Tuning Line + Meter Level - - - - - + + 90 @@ -3406,42 +3183,6 @@ - - - - - - - Pop-Out - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Waterfall Axis - - - @@ -3455,8 +3196,38 @@ - - + + + + + + + Underlay Line + + + + + + + Revert + + + + + + + + + + + + + Meter Peak Level + + + + + 90 @@ -3468,16 +3239,25 @@ - - + + + + + + + + + + + 90 + 16777215 + + - Underlay Fill + #AARRGGBB - - - @@ -3491,26 +3271,6 @@ - - - - Plot Background - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - @@ -3518,8 +3278,8 @@ - - + + 90 @@ -3531,6 +3291,145 @@ + + + + Waterfall Axis + + + + + + + Axis + + + + + + + Underlay Fill + + + + + + + Meter Scale + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + Meter Text + + + + + + + + + + Spectrum Line + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Waterfall Grid + + + + + + + + + + Waterfall Back + + + + + + + + + @@ -3544,6 +3443,42 @@ + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + Waterfall Text + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + @@ -3551,18 +3486,14 @@ - - - - - 90 - 16777215 - - - - #AARRGGBB - - + + + + + + + + @@ -3574,18 +3505,8 @@ - - - - Underlay Line - - - - - - - - + + 90 @@ -3597,13 +3518,115 @@ - - + + - Revert + Grid + + + + + + + Plot Background + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + + + + Tuning Line + + + + + + + Spectrum Fill + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Pop-Out + + + + + + + Meter Peak Scale + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + From d49b6cd082151278f6231072fb8e148994a3a72d Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 21:22:45 -0700 Subject: [PATCH 31/37] Oops, forgot to clarify the button name. --- wfmain.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index 1dea96e..3e78a4e 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3095,7 +3095,7 @@ 0 - -369 + -409 767 612 @@ -3607,7 +3607,7 @@ - Meter Peak Scale + Meter High Scale From 7e80eb0ed7e4bf29119c7c2aff33491ef1fb99d6 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 21:31:31 -0700 Subject: [PATCH 32/37] Cleaned up lots of debug info messages. --- wfmain.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 9b1f2bc..a39b0f3 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -6163,7 +6163,6 @@ void wfmain::on_underlayPeakHold_toggled(bool checked) prefs.underlayMode = underlayMode; on_clearPeakBtn_clicked(); } - } void wfmain::on_underlayPeakBuffer_toggled(bool checked) @@ -6300,7 +6299,7 @@ void wfmain::useColorPreset(colorPrefsType *cp) if(cp == Q_NULLPTR) return; - qInfo(logSystem()) << "Setting plots to color preset number " << cp->presetNum << ", with name " << *(cp->presetName); + //qInfo(logSystem()) << "Setting plots to color preset number " << cp->presetNum << ", with name " << *(cp->presetName); plot->setBackground(cp->plotBackground); @@ -6360,7 +6359,6 @@ void wfmain::setColorButtonOperations(QColor *colorStore, getSetColor(d, e); QColor t = d->getColor(); colorStore->setNamedColor(t.name(QColor::HexArgb)); - //colorStore->setBlue(100); useCurrentColorPreset(); } @@ -6412,7 +6410,7 @@ void wfmain::setDefaultColorPresets() // gets overridden after preferences are loaded for(int pn=0; pn < numColorPresetsTotal; pn++) { - qInfo(logSystem()) << "Setting default color preset " << pn; + //qInfo(logSystem()) << "Setting default color preset " << pn; colorPrefsType *p = &colorPreset[pn]; p->presetNum = pn; @@ -6448,7 +6446,7 @@ void wfmain::setDefaultColorPresets() p->wfGrid = QColor(Qt::white); p->wfText = QColor(Qt::white); - qInfo(logSystem()) << "default color preset [" << pn << "] set to pn.presetNum index [" << p->presetNum << "]" << ", with name " << *(p->presetName); + //qInfo(logSystem()) << "default color preset [" << pn << "] set to pn.presetNum index [" << p->presetNum << "]" << ", with name " << *(p->presetName); ui->colorPresetCombo->setItemText(pn, *(p->presetName)); } } @@ -6477,7 +6475,7 @@ void wfmain::loadColorPresetToUIandPlots(int presetNumber) } colorPrefsType p = colorPreset[presetNumber]; - qInfo(logSystem()) << "color preset number [" << presetNumber << "] requested for UI load, which has internal index of [" << p.presetNum << "]"; + //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); @@ -6521,7 +6519,6 @@ void wfmain::on_colorRenamePresetBtn_clicked() colorPreset[p].presetName->clear(); colorPreset[p].presetName->append(newName); ui->colorPresetCombo->setItemText(p, *(colorPreset[p].presetName)); - qInfo(logSystem()) << "Setting color preset number " << p << " to have text " << newName << ", as read in preset data: " << *(colorPreset[p].presetName) << ", and as read from combo box: " << ui->colorPresetCombo->currentText(); } else { if(newName.isEmpty() || (newName.length() > 32)) { @@ -6533,7 +6530,6 @@ void wfmain::on_colorRenamePresetBtn_clicked() void wfmain::on_colorPresetCombo_currentIndexChanged(int index) { - qInfo(logSystem()) << "color preset combo box set to index: " << index; prefs.currentColorPresetNumber = index; loadColorPresetToUIandPlots(index); } From b8ba9a16dc9db063144a27edc3c49451e7ee694d Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 23 Aug 2022 10:35:59 -0700 Subject: [PATCH 33/37] Added protection against transparent colors. Added revert feature to revert to default color preset for the selected preset. Added save single preset capability. --- wfmain.cpp | 268 +++++++++++++++++++++++++++++++++-------------------- wfmain.h | 5 +- 2 files changed, 169 insertions(+), 104 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index a39b0f3..7a4bb0d 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -63,7 +63,6 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s setupPlots(); setDefaultColorPresets(); - setDefaultColors(); loadSettings(); // Look for saved preferences @@ -1381,7 +1380,7 @@ void wfmain::loadSettings() p = &(colorPreset[pn]); p->presetNum = settings->value("presetNum", p->presetNum).toInt(); tempName = settings->value("presetName", *p->presetName).toString(); - if((!tempName.isEmpty()) && tempName.length() < 33) + if((!tempName.isEmpty()) && tempName.length() < 11) { p->presetName->clear(); p->presetName->append(tempName); @@ -2598,63 +2597,111 @@ void wfmain::setAppTheme(bool isCustom) } } -void wfmain::setDefaultColors() +void wfmain::setDefaultColors(int presetNumber) { - // These are some intended built-in color schemes. - // They can be user-modified and may be restored simply - // by removing the relevent color preset preference file entries. + // These are the default color schemes + if(presetNumber > numColorPresetsTotal-1) + return; - colorPrefsType *pDark = &colorPreset[0]; - colorPrefsType *pLight = &colorPreset[1]; + colorPrefsType *p = &colorPreset[presetNumber]; - // Dark: - pDark->presetName->clear(); - pDark->presetName->append("Dark"); - pDark->plotBackground = QColor(0,0,0,255); - pDark->axisColor = QColor(Qt::white); - pDark->textColor = QColor(255,255,255,255); - pDark->gridColor = QColor("transparent"); - pDark->spectrumFill = QColor("transparent"); - pDark->spectrumLine = QColor(Qt::yellow); - //pDark->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); - pDark->underlayLine = QColor("#9633ff55"); - pDark->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); - pDark->tuningLine = QColor("#ff55ffff"); + // Begin every parameter with these safe defaults first: + if(p->presetName == Q_NULLPTR) + { + p->presetName = new QString(); + } + p->presetName->clear(); + p->presetName->append(QString("%1").arg(presetNumber)); + p->presetNum = presetNumber; + p->gridColor = QColor(0,0,0,255); + p->axisColor = QColor(Qt::white); + p->textColor = QColor(Qt::white); + p->spectrumLine = QColor(Qt::yellow); + p->spectrumFill = QColor("transparent"); + p->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); + p->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); + p->plotBackground = QColor(Qt::black); + p->tuningLine = QColor(Qt::blue); - pDark->meterLevel = QColor("#148CD2").darker(); - pDark->meterAverage = QColor("#3FB7CD"); - pDark->meterPeakScale = QColor(Qt::red); - pDark->meterPeakLevel = QColor("#3CA0DB").lighter(); - pDark->meterLowerLine = QColor("#eff0f1"); - pDark->meterLowText = QColor("#eff0f1"); + p->meterLevel = QColor("#148CD2").darker(); + p->meterAverage = QColor("#3FB7CD"); + p->meterPeakLevel = QColor("#3CA0DB").lighter(); + p->meterPeakScale = QColor(Qt::red); + p->meterLowerLine = QColor("#eff0f1"); + p->meterLowText = QColor("#eff0f1"); - pDark->wfBackground = QColor(Qt::black); - pDark->wfAxis = QColor(Qt::white); - pDark->wfGrid = QColor("transparent"); - pDark->wfText = QColor(Qt::white); + p->wfBackground = QColor(Qt::black); + p->wfAxis = QColor(Qt::white); + p->wfGrid = QColor(Qt::white); + p->wfText = QColor(Qt::white); - // Bright: - pLight->presetName->clear(); - pLight->presetName->append("Bright"); - pLight->plotBackground = QColor(Qt::white); - pLight->axisColor = QColor(200,200,200,255); - pLight->gridColor = QColor("transparent"); - pLight->textColor = QColor(Qt::black); - pLight->spectrumFill = QColor("transparent"); - pLight->spectrumLine = QColor(Qt::black); - pLight->underlayLine = QColor(Qt::blue); - pLight->tuningLine = QColor(Qt::darkBlue); + //qInfo(logSystem()) << "default color preset [" << pn << "] set to pn.presetNum index [" << p->presetNum << "]" << ", with name " << *(p->presetName); - pLight->meterAverage = QColor("#3FB7CD"); - pLight->meterPeakLevel = QColor("#3CA0DB"); - pLight->meterPeakScale = QColor(Qt::darkRed); - pLight->meterLowerLine = QColor(Qt::black); - pLight->meterLowText = QColor(Qt::black); + switch (presetNumber) + { + case 0: + { + // Dark + p->presetName->clear(); + p->presetName->append("Dark"); + p->plotBackground = QColor(0,0,0,255); + p->axisColor = QColor(Qt::white); + p->textColor = QColor(255,255,255,255); + p->gridColor = QColor(0,0,0,255); + p->spectrumFill = QColor("transparent"); + p->spectrumLine = QColor(Qt::yellow); + p->underlayLine = QColor("#9633ff55"); + p->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); + p->tuningLine = QColor("#ff55ffff"); - pLight->wfBackground = QColor(Qt::white); - pLight->wfAxis = QColor(200,200,200,255); - pLight->wfGrid = QColor("transparent"); - pLight->wfText = QColor(Qt::black); + p->meterLevel = QColor("#148CD2").darker(); + p->meterAverage = QColor("#3FB7CD"); + p->meterPeakScale = QColor(Qt::red); + p->meterPeakLevel = QColor("#3CA0DB").lighter(); + p->meterLowerLine = QColor("#eff0f1"); + p->meterLowText = QColor("#eff0f1"); + + p->wfBackground = QColor(Qt::black); + p->wfAxis = QColor(Qt::white); + p->wfGrid = QColor("transparent"); + p->wfText = QColor(Qt::white); + break; + } + case 1: + { + // Bright + p->presetName->clear(); + p->presetName->append("Bright"); + p->plotBackground = QColor(Qt::white); + p->axisColor = QColor(200,200,200,255); + p->gridColor = QColor(255,255,255,0); + p->textColor = QColor(Qt::black); + p->spectrumFill = QColor("transparent"); + p->spectrumLine = QColor(Qt::black); + p->underlayLine = QColor(Qt::blue); + p->tuningLine = QColor(Qt::darkBlue); + + p->meterAverage = QColor("#3FB7CD"); + p->meterPeakLevel = QColor("#3CA0DB"); + p->meterPeakScale = QColor(Qt::darkRed); + p->meterLowerLine = QColor(Qt::black); + p->meterLowText = QColor(Qt::black); + + p->wfBackground = QColor(Qt::white); + p->wfAxis = QColor(200,200,200,255); + p->wfGrid = QColor("transparent"); + p->wfText = QColor(Qt::black); + break; + } + + case 2: + case 3: + case 4: + default: + break; + + } + ui->colorPresetCombo->setItemText(presetNumber, *(p->presetName)); } void wfmain::doCmd(commandtype cmddata) @@ -6250,8 +6297,26 @@ QColor wfmain::getColorFromPicker(QColor initialColor) 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; } @@ -6410,44 +6475,7 @@ void wfmain::setDefaultColorPresets() // gets overridden after preferences are loaded for(int pn=0; pn < numColorPresetsTotal; pn++) { - //qInfo(logSystem()) << "Setting default color preset " << pn; - colorPrefsType *p = &colorPreset[pn]; - - p->presetNum = pn; - if(p->presetName == Q_NULLPTR) - { - p->presetName = new QString( QString("Preset %1").arg(pn) ); - } - - // Colors are "#AARRGGBB" (AA=0xff is opaque) - // or as (r, g, b, a) - // Since the UI shows ##AARRGGBB, we should use - // that format in the code when convenient. - - p->gridColor = QColor(0,0,0,255); - p->axisColor = QColor(Qt::white); - p->textColor = QColor(Qt::white); - p->spectrumLine = QColor(Qt::yellow); - p->spectrumFill = QColor("transparent"); - p->underlayLine = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150).lighter(200); - p->underlayFill = QColor(20+200/4.0*1,70*(1.6-1/4.0), 150, 150); - p->plotBackground = QColor(Qt::black); - p->tuningLine = QColor(Qt::blue); - - p->meterLevel = QColor("#148CD2").darker(); - p->meterAverage = QColor("#3FB7CD"); - p->meterPeakLevel = QColor("#3CA0DB").lighter(); - p->meterPeakScale = QColor(Qt::red); - p->meterLowerLine = QColor("#eff0f1"); - p->meterLowText = QColor("#eff0f1"); - - p->wfBackground = QColor(Qt::black); - p->wfAxis = QColor(Qt::white); - p->wfGrid = QColor(Qt::white); - p->wfText = QColor(Qt::white); - - //qInfo(logSystem()) << "default color preset [" << pn << "] set to pn.presetNum index [" << p->presetNum << "]" << ", with name " << *(p->presetName); - ui->colorPresetCombo->setItemText(pn, *(p->presetName)); + setDefaultColors(pn); } } @@ -6508,21 +6536,21 @@ void wfmain::on_colorRenamePresetBtn_clicked() QMessageBox msgBox; bool ok = false; - newName = QInputDialog::getText(this, tr("QInputDialog::getText()"), - tr("Preset Name (32 characters max):"), QLineEdit::Normal, + 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() < 33) && !newName.isEmpty()) + 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() > 32)) + if(newName.isEmpty() || (newName.length() > 10)) { - msgBox.setText("Error, name must be at least one character and not exceed 32 characters."); + msgBox.setText("Error, name must be at least one character and not exceed 10 characters."); msgBox.exec(); } } @@ -6534,6 +6562,13 @@ void wfmain::on_colorPresetCombo_currentIndexChanged(int index) loadColorPresetToUIandPlots(index); } +void wfmain::on_colorRevertPresetBtn_clicked() +{ + int pn = ui->colorPresetCombo->currentIndex(); + setDefaultColors(pn); + loadColorPresetToUIandPlots(pn); +} + // ---------- end color helper functions ---------- // // ---------- Color UI slots ----------// @@ -6807,14 +6842,41 @@ void wfmain::on_colorEditMeterText_editingFinished() // ---------- End color UI slots ----------// - -void wfmain::on_colorRevertPresetBtn_clicked() +void wfmain::on_colorSavePresetBtn_clicked() { - // revert to default colors: - // TODO: Add arguments to setDefaultColors() - //int pn = ui->colorPresetCombo->currentIndex(); - //setDefaultColors(); + 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("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->endArray(); + settings->endGroup(); + settings->sync(); } - - - diff --git a/wfmain.h b/wfmain.h index d35c811..2504899 100644 --- a/wfmain.h +++ b/wfmain.h @@ -633,6 +633,8 @@ private slots: void on_colorEditMeterPeakScale_editingFinished(); + void on_colorSavePresetBtn_clicked(); + private: Ui::wfmain *ui; void closeEvent(QCloseEvent *event); @@ -881,7 +883,8 @@ private: audioSetup rxSetup; audioSetup txSetup; - void setDefaultColors(); // populate with default values + void setDefaultColors(int presetNumber); // populate with default values + void useColors(); // set the plot up void setDefPrefs(); // populate default values to default prefs void setTuningSteps(); From 147156780828b16bf9077a32cdf65524a7170bb8 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 23 Aug 2022 10:41:26 -0700 Subject: [PATCH 34/37] Clarified what some controls do in the UI related to color and underlay. --- wfmain.ui | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index 3e78a4e..acbeefb 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -2916,6 +2916,9 @@ + + No underlay graphics + None @@ -2929,6 +2932,9 @@ + + Indefinite peak hold + Peak Hold @@ -2939,6 +2945,9 @@ + + Peak value within the buffer + Peak @@ -2949,6 +2958,9 @@ + + Average value within the buffer + Average @@ -2972,6 +2984,9 @@ 16777215 + + Size of buffer for spectrum data. Shorter values are more responsive. + 8 @@ -3095,7 +3110,7 @@ 0 - -409 + 0 767 612 @@ -3129,6 +3144,9 @@ 16777215 + + Select a color preset here. + 1 @@ -3158,6 +3176,9 @@ + + Rename the selected color preset. Max length is 10 characters. + Rename Preset @@ -3208,6 +3229,9 @@ + + Revert the selected color preset to the default. + Revert @@ -3266,6 +3290,9 @@ 16777215 + + Color text format is #AARRGGBB, where AA is the "alpha" channel, and value "00" is totally transparent, and "ff" is totally opaque. + #AARRGGBB @@ -3481,8 +3508,11 @@ + + Saves the current preset to the settings file. + - Save Presets + Save Preset @@ -3599,6 +3629,9 @@ + + <html><head/><body><p>Pop out (or pop back in) the entire Settings tab. </p><p>NOTE: Press this button again to re-insert the tab when finished. </p></body></html> + Pop-Out From 31f62fde671eb1c4fd9cda8876e5f843d8d0e579 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 23 Aug 2022 10:47:19 -0700 Subject: [PATCH 35/37] Moved some preset controls. --- wfmain.ui | 908 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 465 insertions(+), 443 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index acbeefb..bf5d5d7 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3018,6 +3018,13 @@ + + + + Enable PTT Controls + + + @@ -3068,14 +3075,108 @@ 0 - + - Enable PTT Controls + Color scheme - + + + Preset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 90 + 0 + + + + + 90 + 16777215 + + + + Select a color preset here. + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + + Saves the current preset to the settings file. + + + Save Preset + + + + + + + Revert the selected color preset to the default. + + + Revert + + + + + + + Rename the selected color preset. Max length is 10 characters. + + + Rename Preset + + + + + + + <html><head/><body><p>Pop out (or pop back in) the entire Settings tab. </p><p>NOTE: Press this button again to re-insert the tab when finished. </p></body></html> + + + Pop-Out + + + + + Qt::Horizontal @@ -3091,6 +3192,18 @@ + + + 0 + 0 + + + + + 0 + 250 + + 0 @@ -3112,86 +3225,14 @@ 0 0 767 - 612 + 582 - - - - - 90 - 16777215 - - - - #AARRGGBB - - + + - - - - Text - - - - - - - - 90 - 16777215 - - - - Select a color preset here. - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - - - - Rename the selected color preset. Max length is 10 characters. - - - Rename Preset - - - - - - - Meter Level - - - - + @@ -3204,8 +3245,11 @@ - - + + + + + 90 @@ -3217,60 +3261,49 @@ - - - - - + + - Underlay Line - - - - - - - Revert the selected color preset to the default. - - - Revert - - - - - - - - - - - - - Meter Peak Level - - - - - - - - 90 - 16777215 - - - - #AARRGGBB + Waterfall Grid - + - + + + + Spectrum Fill + + + + + + + Underlay Fill + + + + - - + + + + Meter Average + + + + + + + Meter High Scale + + + + + 90 @@ -3282,7 +3315,24 @@ - + + + + + + + Waterfall Back + + + + + + + Plot Background + + + + @@ -3298,89 +3348,8 @@ - - - - Meter Average - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Waterfall Axis - - - - - - - Axis - - - - - - - Underlay Fill - - - - - - - Meter Scale - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - Meter Text - - - - - - - - - - Spectrum Line - - - - + 90 @@ -3392,229 +3361,7 @@ - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Waterfall Grid - - - - - - - - - - Waterfall Back - - - - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - Waterfall Text - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Saves the current preset to the settings file. - - - Save Preset - - - - - - - - - - - - - - - - Preset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - Grid - - - - - - - - - - Plot Background - - - - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - 90 - 16777215 - - - - #AARRGGBB - - - - - - - - - - - - - Tuning Line - - - - - - - Spectrum Fill - - - - @@ -3627,24 +3374,193 @@ - - - - <html><head/><body><p>Pop out (or pop back in) the entire Settings tab. </p><p>NOTE: Press this button again to re-insert the tab when finished. </p></body></html> - + + - Pop-Out + Waterfall Text - - + + + + + - Meter High Scale + Axis - + + + + + + + + + + Waterfall Axis + + + + + + + + + + Grid + + + + + + + + + + + + + + + + Tuning Line + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Text + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Meter Peak Level + + + + + + + @@ -3657,9 +3573,115 @@ - + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + + 90 + 16777215 + + + + #AARRGGBB + + + + + + + Spectrum Line + + + + + + + + + + Meter Text + + + + + + + Underlay Line + + + + + + + Meter Scale + + + + + + + Meter Level + + + From c989dba9f9fab81407cf8a937acb2e5843adea11 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 23 Aug 2022 10:56:16 -0700 Subject: [PATCH 36/37] Color preset UI now expands to fit. Finally. --- wfmain.ui | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/wfmain.ui b/wfmain.ui index bf5d5d7..fd03aa4 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -3025,6 +3025,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + @@ -3193,9 +3209,9 @@ - + 0 - 0 + 1 @@ -3216,6 +3232,9 @@ + + QAbstractScrollArea::AdjustToContents + true From d3493988af20ca9f3fbf550af757f7ff327680c8 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Tue, 23 Aug 2022 17:01:11 -0700 Subject: [PATCH 37/37] Minor ui adjustment --- wfmain.ui | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wfmain.ui b/wfmain.ui index fd03aa4..bf6abc8 100644 --- a/wfmain.ui +++ b/wfmain.ui @@ -18,7 +18,7 @@ - 3 + 0 @@ -931,6 +931,9 @@ 80 + + Sets the floor for the waterfall and spectrum displays + 160