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
+
+
+
+ -
+