Sort out the hide controls state persistence in fast and wide graphs

QWidget::isVisible()  and QWidget::isHidden()  unsurprisingly are  not
directly complementary, in this case QWidget::isHidden() is the needed
functionality.

Thanks to Mike W9MDB for the initial version of this change.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7702 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2017-06-04 22:51:26 +00:00
parent b8194cf199
commit 25d4eb8de7
3 changed files with 19 additions and 18 deletions

View File

@ -1,8 +1,11 @@
#include "fastgraph.h" #include "fastgraph.h"
#include "commons.h" #include "commons.h"
#include <QSettings> #include <QSettings>
#include <QApplication> #include <QApplication>
#include "fastplot.h" #include "fastplot.h"
#include "SettingsGroup.hpp"
#include "ui_fastgraph.h" #include "ui_fastgraph.h"
#include "moc_fastgraph.cpp" #include "moc_fastgraph.cpp"
@ -21,8 +24,8 @@ FastGraph::FastGraph(QSettings * settings, QWidget *parent) :
installEventFilter(parent); //Installing the filter installEventFilter(parent); //Installing the filter
ui->fastPlot->setCursor(Qt::CrossCursor); ui->fastPlot->setCursor(Qt::CrossCursor);
//Restore user's settings //Restore user's settings
m_settings->beginGroup("FastGraph"); SettingsGroup g {m_settings, "FastGraph"};
restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ());
ui->fastPlot->setPlotZero(m_settings->value("PlotZero", 0).toInt()); ui->fastPlot->setPlotZero(m_settings->value("PlotZero", 0).toInt());
ui->fastPlot->setPlotGain(m_settings->value("PlotGain", 0).toInt()); ui->fastPlot->setPlotGain(m_settings->value("PlotGain", 0).toInt());
@ -31,33 +34,30 @@ FastGraph::FastGraph(QSettings * settings, QWidget *parent) :
ui->fastPlot->setGreenZero(m_settings->value("GreenZero", 0).toInt()); ui->fastPlot->setGreenZero(m_settings->value("GreenZero", 0).toInt());
ui->greenZeroSlider->setValue(ui->fastPlot->m_greenZero); ui->greenZeroSlider->setValue(ui->fastPlot->m_greenZero);
ui->controls_widget->setVisible (!m_settings->value("HideControls", false).toBool ()); ui->controls_widget->setVisible (!m_settings->value("HideControls", false).toBool ());
m_settings->endGroup();
connect (ui->fastPlot, &FPlotter::fastPick, this, &FastGraph::fastPick); connect (ui->fastPlot, &FPlotter::fastPick, this, &FastGraph::fastPick);
} }
FastGraph::~FastGraph()
{
saveSettings();
}
void FastGraph::closeEvent (QCloseEvent * e) void FastGraph::closeEvent (QCloseEvent * e)
{ {
saveSettings (); saveSettings ();
QDialog::closeEvent (e); QDialog::closeEvent (e);
} }
FastGraph::~FastGraph ()
{
}
void FastGraph::saveSettings() void FastGraph::saveSettings()
{ {
//Save user's settings //Save user's settings
m_settings->beginGroup("FastGraph"); SettingsGroup g {m_settings, "FastGraph"};
m_settings->setValue ("geometry", saveGeometry ()); m_settings->setValue ("geometry", saveGeometry ());
m_settings->setValue("PlotZero",ui->fastPlot->m_plotZero); m_settings->setValue("PlotZero",ui->fastPlot->m_plotZero);
m_settings->setValue("PlotGain",ui->fastPlot->m_plotGain); m_settings->setValue("PlotGain",ui->fastPlot->m_plotGain);
m_settings->setValue("GreenZero",ui->fastPlot->m_greenZero); m_settings->setValue("GreenZero",ui->fastPlot->m_greenZero);
m_settings->setValue("GreenGain",ui->fastPlot->m_greenGain); m_settings->setValue("GreenGain",ui->fastPlot->m_greenGain);
m_settings->setValue("HideControls",!ui->controls_widget->isVisible ()); m_settings->setValue ("HideControls", ui->controls_widget->isHidden ());
m_settings->endGroup();
} }
void FastGraph::plotSpec(bool diskData, int UTCdisk) void FastGraph::plotSpec(bool diskData, int UTCdisk)

View File

@ -14,13 +14,9 @@ class FastGraph : public QDialog
{ {
Q_OBJECT Q_OBJECT
protected:
void closeEvent (QCloseEvent *) override;
void keyPressEvent( QKeyEvent *e ) override;
public: public:
explicit FastGraph(QSettings *, QWidget *parent = 0); explicit FastGraph(QSettings *, QWidget *parent = 0);
~FastGraph(); ~FastGraph ();
void plotSpec(bool diskData, int UTCdisk); void plotSpec(bool diskData, int UTCdisk);
void saveSettings(); void saveSettings();
@ -36,6 +32,10 @@ private slots:
void on_greenZeroSlider_valueChanged(int value); void on_greenZeroSlider_valueChanged(int value);
void on_pbAutoLevel_clicked(); void on_pbAutoLevel_clicked();
protected:
void closeEvent (QCloseEvent *) override;
void keyPressEvent( QKeyEvent *e ) override;
private: private:
QSettings * m_settings; QSettings * m_settings;
float m_ave; float m_ave;

View File

@ -1,4 +1,5 @@
#include "widegraph.h" #include "widegraph.h"
#include <algorithm> #include <algorithm>
#include <QApplication> #include <QApplication>
#include <QSettings> #include <QSettings>
@ -6,8 +7,8 @@
#include "commons.h" #include "commons.h"
#include "Configuration.hpp" #include "Configuration.hpp"
#include "MessageBox.hpp" #include "MessageBox.hpp"
#include "moc_widegraph.cpp"
#include "SettingsGroup.hpp" #include "SettingsGroup.hpp"
#include "moc_widegraph.cpp"
namespace namespace
{ {
@ -140,7 +141,7 @@ void WideGraph::saveSettings() //saveS
m_settings->setValue ("UserPalette", QVariant::fromValue (m_userPalette.colours ())); m_settings->setValue ("UserPalette", QVariant::fromValue (m_userPalette.colours ()));
m_settings->setValue("Flatten",m_bFlatten); m_settings->setValue("Flatten",m_bFlatten);
m_settings->setValue("UseRef",m_bRef); m_settings->setValue("UseRef",m_bRef);
m_settings->setValue("HideControls",!ui->controls_widget->isVisible()); m_settings->setValue ("HideControls", ui->controls_widget->isHidden ());
} }
void WideGraph::drawRed(int ia, int ib) void WideGraph::drawRed(int ia, int ib)