From 59d2d735e6e55174090ef90c9fa5febc7a5c61e0 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Mon, 22 Aug 2022 09:44:00 -0700 Subject: [PATCH] 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 - - - - - -