diff --git a/src/barplot.cpp b/src/barplot.cpp --- a/src/barplot.cpp +++ b/src/barplot.cpp @@ -19,9 +19,10 @@ #include "barplot.h" #include "barscaledraw.h" +#include "utils.h" -BarPlot::BarPlot(ChannelManager* channelMan, QWidget* parent) : - QwtPlot(parent), barChart(channelMan) +BarPlot::BarPlot(ChannelManager* channelMan, PlotMenu* menu, QWidget* parent) : + QwtPlot(parent), _menu(menu), barChart(channelMan) { _channelMan = channelMan; barChart.attach(this); @@ -31,6 +32,11 @@ BarPlot::BarPlot(ChannelManager* channel update(); connect(_channelMan, &ChannelManager::dataAdded, this, &BarPlot::update); connect(_channelMan, &ChannelManager::numOfChannelsChanged, this, &BarPlot::update); + + // connect to menu + connect(&menu->darkBackgroundAction, SELECT::OVERLOAD_OF(&QAction::toggled), + this, &BarPlot::darkBackground); + darkBackground(menu->darkBackgroundAction.isChecked()); } void BarPlot::update() @@ -52,3 +58,17 @@ void BarPlot::setYAxis(bool autoScaled, setAxisScale(QwtPlot::yLeft, yMin, yMax); } } + + +void BarPlot::darkBackground(bool enabled) +{ + if (enabled) + { + setCanvasBackground(QBrush(Qt::black)); + } + else + { + setCanvasBackground(QBrush(Qt::white)); + } + replot(); +}