Color preferences. We can now set a single color and also detach the

settings tab.
monitor
Elliott Liggett 2022-08-21 00:17:44 -07:00
rodzic 4b0ce8537e
commit b77715e0d8
7 zmienionych plików z 437 dodań i 65 usunięć

30
colorprefs.h 100644
Wyświetl plik

@ -0,0 +1,30 @@
#ifndef COLORPREFS_H
#define COLORPREFS_H
#include <QColor>
#include <QString>
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

Wyświetl plik

@ -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;

Wyświetl plik

@ -13,7 +13,8 @@ public:
StateOk,
StateOkBlue,
StateWarning,
StateError
StateError,
StateBlank
};

Wyświetl plik

@ -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();
}

Wyświetl plik

@ -37,6 +37,7 @@
#include "rigctld.h"
#include "aboutbox.h"
#include "selectradio.h"
#include "colorprefs.h"
#include <qcustomplot.h>
#include <qserialportinfo.h>
@ -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);

365
wfmain.ui
Wyświetl plik

@ -3090,7 +3090,7 @@
</size>
</property>
<property name="title">
<string>User-defined colors</string>
<string>User-defined Color Editor</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
@ -3104,87 +3104,186 @@
<x>0</x>
<y>0</y>
<width>767</width>
<height>192</height>
<height>372</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="3">
<spacer name="horizontalSpacer_29">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
<item row="11" column="2">
<widget class="QLedLabel" name="colorSwatchMeterAverage" native="true"/>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="colorSetBtnGrid">
<property name="text">
<string>Grid...</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>PushButton</string>
</property>
</widget>
<item row="4" column="2">
<widget class="QLedLabel" name="colorSwatchPlotBackground" native="true"/>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_46">
<widget class="QLineEdit" name="colorEditText">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>TextLabel</string>
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_4">
<item row="8" column="1">
<widget class="QLineEdit" name="colorEditOverlayFill">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>PushButton</string>
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="pushButton_2">
<item row="7" column="2">
<widget class="QLedLabel" name="colorSwatchOverlayLine" native="true"/>
</item>
<item row="6" column="2">
<widget class="QLedLabel" name="colorSwatchSpecLine_2" native="true"/>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="colorSetBtnOverlayLine">
<property name="text">
<string>PushButton</string>
<string>Overlay Line</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="colorEditPlotBackground">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="colorRenamePreset">
<property name="text">
<string>Rename Preset</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLedLabel" name="colorSwatchText" native="true"/>
</item>
<item row="12" column="1">
<widget class="QLineEdit" name="colorEditMeterPeak">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QPushButton" name="colorSetBtnMeterAvg">
<property name="text">
<string>Meter Average</string>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QLedLabel" name="colorSwatchMeterPeak" native="true"/>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="colorEditMeterAvg">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QPushButton" name="colorSetBtnSpecFill">
<property name="text">
<string>Spectrum Fill</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="colorSetBtnPlotBackground">
<widget class="QLabel" name="colorPresetLabel">
<property name="text">
<string>Plot Background...</string>
<string>Preset:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="colorLabelGrid">
<item row="1" column="1">
<widget class="QComboBox" name="colorPresetCombo">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QWidget" name="colorDummyLed" native="true"/>
</item>
<item row="10" column="2">
<widget class="QLedLabel" name="colorSwatchMeterLevel" native="true"/>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="colorEditSpecLine">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>GRID</string>
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_45">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="2" column="2">
<widget class="QLedLabel" name="colorSwatchGrid" native="true">
<property name="minimumSize">
<size>
@ -3200,8 +3299,15 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="colorLinePlotBackground">
<item row="5" column="0">
<widget class="QPushButton" name="colorSetBtnSpecLine">
<property name="text">
<string>Spectrum Line</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="colorEditOverlayLine">
<property name="maximumSize">
<size>
<width>90</width>
@ -3213,8 +3319,149 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLedLabel" name="colorSwatchPlotBackground" native="true"/>
<item row="2" column="1">
<widget class="QLineEdit" name="colorEditGrid">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="colorSetBtnPlotBackground">
<property name="text">
<string>Plot Background</string>
</property>
</widget>
</item>
<item row="1" column="7">
<spacer name="colorHorizSpacerTopLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="colorSetBtnText">
<property name="text">
<string>Text</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QPushButton" name="colorSetBtnMeterLevel">
<property name="text">
<string>Meter Level</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLedLabel" name="colorSwatchSpecLine" native="true"/>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="colorSetBtnGrid">
<property name="text">
<string>Grid</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="colorMakeCurrentBtn">
<property name="text">
<string>Make Current</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="colorSavePresetBtn">
<property name="text">
<string>Save Preset</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLedLabel" name="colorSwatchOverlayFill" native="true"/>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="colorEditMeterLevel">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="colorEditSpecFill">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QPushButton" name="colorSetBtnMeterPeak">
<property name="text">
<string>Meter Peak</string>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="colorPopOutBtn">
<property name="text">
<string>Pop-Out</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QPushButton" name="colorSetBtnOverlayFill">
<property name="text">
<string>Overlay Fill</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QPushButton" name="colorSetBtnTuningLine">
<property name="text">
<string>Tuning Line</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="colorEditTuningLine">
<property name="maximumSize">
<size>
<width>90</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>#AARRGGBB</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLedLabel" name="colorSwatchTuningLine" native="true"/>
</item>
</layout>
</widget>

Wyświetl plik

@ -176,6 +176,7 @@ SOURCES += main.cpp\
aboutbox.cpp
HEADERS += wfmain.h \
colorprefs.h \
commhandler.h \
rigcommander.h \
freqmemory.h \