kopia lustrzana https://gitlab.com/eliggett/wfview
Now using preferences, read and write. Current settings are not written
at this time.merge-requests/1/merge
rodzic
59c5113f43
commit
973dec0b25
1
main.cpp
1
main.cpp
|
@ -14,6 +14,7 @@ int main(int argc, char *argv[])
|
||||||
a.setOrganizationDomain("nodomain");
|
a.setOrganizationDomain("nodomain");
|
||||||
a.setApplicationName("RigView");
|
a.setApplicationName("RigView");
|
||||||
|
|
||||||
|
a.setWheelScrollLines(1); // one line per wheel click
|
||||||
wfmain w;
|
wfmain w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
|
154
wfmain.cpp
154
wfmain.cpp
|
@ -10,6 +10,8 @@ wfmain::wfmain(QWidget *parent) :
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
theParent = parent;
|
theParent = parent;
|
||||||
|
setDefaultColors(); // set of UI colors with defaults populated
|
||||||
|
loadSettings(); // Look for default settings
|
||||||
plot = ui->plot; // rename it waterfall.
|
plot = ui->plot; // rename it waterfall.
|
||||||
wf = ui->waterfall;
|
wf = ui->waterfall;
|
||||||
tracer = new QCPItemTracer(plot);
|
tracer = new QCPItemTracer(plot);
|
||||||
|
@ -113,7 +115,7 @@ wfmain::wfmain(QWidget *parent) :
|
||||||
colorMap->data()->setValueRange(QCPRange(0, wfLength-1));
|
colorMap->data()->setValueRange(QCPRange(0, wfLength-1));
|
||||||
colorMap->data()->setKeyRange(QCPRange(0, spectWidth-1));
|
colorMap->data()->setKeyRange(QCPRange(0, spectWidth-1));
|
||||||
colorMap->setDataRange(QCPRange(0, 160));
|
colorMap->setDataRange(QCPRange(0, 160));
|
||||||
colorMap->setGradient(QCPColorGradient::gpJet);
|
colorMap->setGradient(QCPColorGradient::gpJet); // TODO: Add preference
|
||||||
colorMapData = new QCPColorMapData(spectWidth, wfLength, QCPRange(0, spectWidth-1), QCPRange(0, wfLength-1));
|
colorMapData = new QCPColorMapData(spectWidth, wfLength, QCPRange(0, spectWidth-1), QCPRange(0, wfLength-1));
|
||||||
colorMap->setData(colorMapData);
|
colorMap->setData(colorMapData);
|
||||||
spectRowCurrent = 0;
|
spectRowCurrent = 0;
|
||||||
|
@ -127,12 +129,12 @@ wfmain::wfmain(QWidget *parent) :
|
||||||
plot->graph(1)->setBrush(QBrush(color));
|
plot->graph(1)->setBrush(QBrush(color));
|
||||||
|
|
||||||
drawPeaks = false;
|
drawPeaks = false;
|
||||||
ui->drawPeakChk->setChecked(false);
|
// ui->drawPeakChk->setChecked(false);
|
||||||
|
|
||||||
ui->freqMhzLineEdit->setValidator( new QDoubleValidator(0, 100, 6, this));
|
ui->freqMhzLineEdit->setValidator( new QDoubleValidator(0, 100, 6, this));
|
||||||
|
|
||||||
delayedCommand = new QTimer(this);
|
delayedCommand = new QTimer(this);
|
||||||
delayedCommand->setInterval(100); // ms. 250 was fine.
|
delayedCommand->setInterval(100); // ms. 250 was fine. TODO: Find practical maximum with margin on pi
|
||||||
delayedCommand->setSingleShot(true);
|
delayedCommand->setSingleShot(true);
|
||||||
connect(delayedCommand, SIGNAL(timeout()), this, SLOT(runDelayedCommand()));
|
connect(delayedCommand, SIGNAL(timeout()), this, SLOT(runDelayedCommand()));
|
||||||
|
|
||||||
|
@ -143,17 +145,20 @@ wfmain::wfmain(QWidget *parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial state of UI:
|
// Initial state of UI:
|
||||||
// TODO: Use QSettings and/or argv to set.
|
ui->fullScreenChk->setChecked(prefs.useFullScreen);
|
||||||
ui->fullScreenChk->setChecked(true);
|
on_fullScreenChk_clicked(prefs.useFullScreen);
|
||||||
ui->useDarkThemeChk->setChecked(true);
|
|
||||||
ui->drawPeakChk->setChecked(true);
|
ui->useDarkThemeChk->setChecked(prefs.useDarkMode);
|
||||||
on_useDarkThemeChk_clicked(true);
|
on_useDarkThemeChk_clicked(prefs.useDarkMode);
|
||||||
on_fullScreenChk_clicked(true);
|
|
||||||
on_drawPeakChk_clicked(true);
|
ui->drawPeakChk->setChecked(prefs.drawPeaks);
|
||||||
|
on_drawPeakChk_clicked(prefs.drawPeaks);
|
||||||
|
drawPeaks = prefs.drawPeaks;
|
||||||
|
|
||||||
getInitialRigState();
|
getInitialRigState();
|
||||||
oldFreqDialVal = ui->freqDial->value();
|
oldFreqDialVal = ui->freqDial->value();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wfmain::~wfmain()
|
wfmain::~wfmain()
|
||||||
|
@ -162,19 +167,69 @@ wfmain::~wfmain()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wfmain::setDefPrefs()
|
||||||
|
{
|
||||||
|
defPrefs.useFullScreen = true;
|
||||||
|
defPrefs.useDarkMode = true;
|
||||||
|
defPrefs.drawPeaks = true;
|
||||||
|
defPrefs.radioCIVAddr = 0x94;
|
||||||
|
defPrefs.serialPortRadio = QString("/dev/ttyUSB0");
|
||||||
|
defPrefs.enablePTT = false;
|
||||||
|
defPrefs.niceTS = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void wfmain::loadSettings()
|
void wfmain::loadSettings()
|
||||||
{
|
{
|
||||||
qDebug() << "Loading settings from " << settings.fileName();
|
qDebug() << "Loading settings from " << settings.fileName();
|
||||||
|
|
||||||
// Basic things to load:
|
// Basic things to load:
|
||||||
|
|
||||||
// UI: (full screen, dark theme, draw peaks, colors, etc)
|
// 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.drawPeaks = settings.value("DrawPeaks", defPrefs.drawPeaks).toBool();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
// Radio and Comms: C-IV addr, port to use
|
// Radio and Comms: C-IV addr, port to use
|
||||||
|
settings.beginGroup("Radio");
|
||||||
|
prefs.radioCIVAddr = (unsigned char) settings.value("RigCIVuInt", defPrefs.radioCIVAddr).toInt();
|
||||||
|
prefs.serialPortRadio = settings.value("SerialPortRadio", defPrefs.serialPortRadio).toString();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
// Misc. user settings (enable PTT, draw peaks, etc)
|
// Misc. user settings (enable PTT, draw peaks, etc)
|
||||||
|
settings.beginGroup("Controls");
|
||||||
|
prefs.enablePTT = settings.value("EnablePTT", defPrefs.enablePTT).toBool();
|
||||||
|
prefs.niceTS = settings.value("NiceTS", defPrefs.niceTS).toBool();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
// Memory channels
|
// Memory channels
|
||||||
|
|
||||||
|
settings.beginGroup("Memory");
|
||||||
|
int size = settings.beginReadArray("Channel");
|
||||||
|
int chan = 0;
|
||||||
|
double freq;
|
||||||
|
unsigned char mode;
|
||||||
|
bool isSet;
|
||||||
|
// preset_kind temp;
|
||||||
|
|
||||||
|
for(int i=0; i < size; i++)
|
||||||
|
{
|
||||||
|
settings.setArrayIndex(i);
|
||||||
|
chan = settings.value("chan", 0).toInt();
|
||||||
|
freq = settings.value("freq", 12.345).toDouble();
|
||||||
|
mode = settings.value("mode", 0).toInt();
|
||||||
|
isSet = settings.value("isSet", false).toBool();
|
||||||
|
|
||||||
|
if(isSet)
|
||||||
|
{
|
||||||
|
mem.setPreset(chan, freq, (mode_kind)mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.endArray();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfmain::saveSettings()
|
void wfmain::saveSettings()
|
||||||
|
@ -210,13 +265,67 @@ void wfmain::saveSettings()
|
||||||
{
|
{
|
||||||
temp = mem.getPreset((int)i);
|
temp = mem.getPreset((int)i);
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
|
settings.setValue("chan", i);
|
||||||
settings.setValue("freq", temp.frequency);
|
settings.setValue("freq", temp.frequency);
|
||||||
settings.setValue("mode", temp.mode);
|
settings.setValue("mode", temp.mode);
|
||||||
|
settings.setValue("isSet", temp.isSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
// Note: X and Y get the same colors. See setPlotTheme() function
|
||||||
|
|
||||||
|
settings.beginGroup("DarkColors");
|
||||||
|
|
||||||
|
settings.setValue("Dark_PlotBackground", QColor(0,0,0,255));
|
||||||
|
settings.setValue("Dark_PlotAxisPen", QColor(75,75,75,255));
|
||||||
|
|
||||||
|
settings.setValue("Dark_PlotLegendTextColor", QColor(255,255,255,255));
|
||||||
|
settings.setValue("Dark_PlotLegendBorderPen", QColor(255,255,255,255));
|
||||||
|
settings.setValue("Dark_PlotLegendBrush", QColor(0,0,0,200));
|
||||||
|
|
||||||
|
settings.setValue("Dark_PlotTickLabel", QColor(Qt::white));
|
||||||
|
settings.setValue("Dark_PlotBasePen", QColor(Qt::white));
|
||||||
|
settings.setValue("Dark_PlotTickPen", QColor(Qt::white));
|
||||||
|
settings.setValue("Dark_PlotFreqTracer", QColor(Qt::yellow));
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
settings.beginGroup("LightColors");
|
||||||
|
|
||||||
|
settings.setValue("Light_PlotBackground", QColor(255,255,255,255));
|
||||||
|
settings.setValue("Light_PlotAxisPen", QColor(200,200,200,255));
|
||||||
|
|
||||||
|
settings.setValue("Light_PlotLegendTextColor", QColor(0,0,0,255));
|
||||||
|
settings.setValue("Light_PlotLegendBorderPen", QColor(0,0,0,255));
|
||||||
|
settings.setValue("Light_PlotLegendBrush", QColor(255,255,255,200));
|
||||||
|
|
||||||
|
settings.setValue("Light_PlotTickLabel", QColor(Qt::black));
|
||||||
|
settings.setValue("Light_PlotBasePen", QColor(Qt::black));
|
||||||
|
settings.setValue("Light_PlotTickPen", QColor(Qt::black));
|
||||||
|
settings.setValue("Light_PlotFreqTracer", QColor(Qt::blue));
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
// This is a reference to see how the preference file is encoded.
|
||||||
|
settings.beginGroup("StandardColors");
|
||||||
|
|
||||||
|
settings.setValue("white", QColor(Qt::white));
|
||||||
|
settings.setValue("black", QColor(Qt::black));
|
||||||
|
|
||||||
|
settings.setValue("red_opaque", QColor(Qt::red));
|
||||||
|
settings.setValue("red_translucent", QColor(255,0,0,128));
|
||||||
|
settings.setValue("green_opaque", QColor(Qt::green));
|
||||||
|
settings.setValue("green_translucent", QColor(0,255,0,128));
|
||||||
|
settings.setValue("blue_opaque", QColor(Qt::blue));
|
||||||
|
settings.setValue("blue_translucent", QColor(0,0,255,128));
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
|
||||||
settings.sync(); // Automatic, not needed (supposedly)
|
settings.sync(); // Automatic, not needed (supposedly)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,6 +398,29 @@ void wfmain::setAppTheme(bool isDark)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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_PlotFreqTracer = QColor(Qt::yellow);
|
||||||
|
|
||||||
|
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_PlotFreqTracer = QColor(Qt::blue);
|
||||||
|
}
|
||||||
|
|
||||||
void wfmain::setPlotTheme(QCustomPlot *plot, bool isDark)
|
void wfmain::setPlotTheme(QCustomPlot *plot, bool isDark)
|
||||||
{
|
{
|
||||||
QColor color;
|
QColor color;
|
||||||
|
|
40
wfmain.h
40
wfmain.h
|
@ -225,6 +225,46 @@ private:
|
||||||
cmds cmdOut;
|
cmds cmdOut;
|
||||||
QVector <cmds> cmdOutQue;
|
QVector <cmds> cmdOutQue;
|
||||||
freqMemory mem;
|
freqMemory mem;
|
||||||
|
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_PlotFreqTracer;
|
||||||
|
|
||||||
|
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_PlotFreqTracer;
|
||||||
|
|
||||||
|
} colorScheme;
|
||||||
|
|
||||||
|
struct preferences {
|
||||||
|
bool useFullScreen;
|
||||||
|
bool useDarkMode;
|
||||||
|
bool drawPeaks;
|
||||||
|
unsigned char radioCIVAddr;
|
||||||
|
QString serialPortRadio;
|
||||||
|
bool enablePTT;
|
||||||
|
bool niceTS;
|
||||||
|
|
||||||
|
} prefs;
|
||||||
|
|
||||||
|
preferences defPrefs;
|
||||||
|
colors defaultColors;
|
||||||
|
|
||||||
|
void setDefaultColors(); // populate with default values
|
||||||
|
void useColors(); // set the plot up
|
||||||
|
void setDefPrefs(); // populate default values to default prefs
|
||||||
|
|
||||||
int oldFreqDialVal;
|
int oldFreqDialVal;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="mainTab">
|
<widget class="QWidget" name="mainTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
Ładowanie…
Reference in New Issue