diff --git a/fastgraph.cpp b/fastgraph.cpp index 11fb37931..dbc697bcc 100644 --- a/fastgraph.cpp +++ b/fastgraph.cpp @@ -1,8 +1,11 @@ #include "fastgraph.h" + #include "commons.h" #include #include #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) diff --git a/fastgraph.h b/fastgraph.h index d19bdaba4..92a54b93c 100644 --- a/fastgraph.h +++ b/fastgraph.h @@ -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; diff --git a/widegraph.cpp b/widegraph.cpp index 7fc4664bb..19a16b223 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -1,4 +1,5 @@ #include "widegraph.h" + #include #include #include @@ -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)