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

View File

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

View File

@ -1,4 +1,5 @@
#include "widegraph.h"
#include <algorithm>
#include <QApplication>
#include <QSettings>
@ -6,8 +7,8 @@
#include "commons.h"
#include "Configuration.hpp"
#include "MessageBox.hpp"
#include "moc_widegraph.cpp"
#include "SettingsGroup.hpp"
#include "moc_widegraph.cpp"
namespace
{
@ -140,7 +141,7 @@ void WideGraph::saveSettings() //saveS
m_settings->setValue ("UserPalette", QVariant::fromValue (m_userPalette.colours ()));
m_settings->setValue("Flatten",m_bFlatten);
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)