diff --git a/core/src/scopymainwindow.cpp b/core/src/scopymainwindow.cpp index 5fcba2fecb..eba0f16f5f 100644 --- a/core/src/scopymainwindow.cpp +++ b/core/src/scopymainwindow.cpp @@ -271,6 +271,7 @@ void ScopyMainWindow::initPreferences() p->init("general_use_animations", true); p->init("general_theme", "default"); p->init("general_language", "en"); + p->init("show_grid", true); p->init("general_plot_target_fps", "60"); p->init("general_show_plot_fps", true); p->init("general_use_native_dialogs", true); diff --git a/core/src/scopypreferencespage.cpp b/core/src/scopypreferencespage.cpp index 6bc068a262..5774226cdc 100644 --- a/core/src/scopypreferencespage.cpp +++ b/core/src/scopypreferencespage.cpp @@ -204,6 +204,8 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage() generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox( p, "general_show_status_bar", "Enable the status bar for displaying important messages.", generalSection)); + generalSection->contentLayout()->addWidget( + PreferencesHelper::addPreferenceCheckBox(p, "show_grid", "Show Grid", generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( p, "general_theme", "Theme", {"default", "light"}, generalSection)); generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo( diff --git a/gui/src/plotwidget.cpp b/gui/src/plotwidget.cpp index 117d661846..994517569e 100644 --- a/gui/src/plotwidget.cpp +++ b/gui/src/plotwidget.cpp @@ -60,7 +60,20 @@ PlotWidget::PlotWidget(QWidget *parent) EdgelessPlotGrid *d_grid = new EdgelessPlotGrid(); QColor majorPenColor(gridpen.color()); d_grid->setMajorPen(majorPenColor, 1.0, Qt::DashLine); - d_grid->attach(m_plot); + if(Preferences::GetInstance()->get("show_grid").toBool()) { + d_grid->attach(m_plot); + } + connect(Preferences::GetInstance(), &Preferences::preferenceChanged, this, + [=](QString preference, QVariant value) { + if(preference == "show_grid") { + if(value.toBool()) { + d_grid->attach(m_plot); + } else { + d_grid->detach(); + } + m_plot->replot(); + } + }); // QwtPlotMarker *d_origin = new QwtPlotMarker(); // d_origin->setLineStyle( QwtPlotMarker::Cross ); @@ -264,8 +277,20 @@ void PlotWidget::hideDefaultAxis() void PlotWidget::setupPlotInfo() { m_plotInfo = new PlotInfo(m_plot->canvas()); - m_plotInfo->addCustomInfo(new HDivInfo(this), InfoPosition::IP_LEFT); m_plotInfo->addCustomInfo(new FPSInfo(this), InfoPosition::IP_LEFT); + + HDivInfo *hDivInfo = new HDivInfo(this); + m_plotInfo->addCustomInfo(hDivInfo, InfoPosition::IP_LEFT); + + if(!Preferences::GetInstance()->get("show_grid").toBool()) { + hDivInfo->hide(); + } + connect(Preferences::GetInstance(), &Preferences::preferenceChanged, this, + [=](QString preference, QVariant value) { + if(preference == "show_grid") { + hDivInfo->setVisible(value.toBool()); + } + }); } bool PlotWidget::showYAxisLabels() const { return m_showYAxisLabels; }