diff --git a/mainwindow.cpp b/mainwindow.cpp
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -76,6 +76,11 @@ MainWindow::MainWindow(QWidget *parent)
QObject::connect(ui->actionUnzoom, &QAction::triggered,
ui->plot, &Plot::unzoom);
+ QObject::connect(ui->actionDarkBackground, &QAction::toggled,
+ ui->plot, &Plot::darkBackground);
+
+ ui->plot->darkBackground(ui->actionDarkBackground->isChecked());
+
// port control signals
QObject::connect(&portControl, &PortControl::portToggled,
this, &MainWindow::onPortToggled);
diff --git a/mainwindow.ui b/mainwindow.ui
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -476,6 +476,7 @@
+
@@ -570,6 +571,17 @@
Show/hide minor grid
+
+
+ true
+
+
+ Dark Background
+
+
+ Toggle Dark Background
+
+
diff --git a/plot.cpp b/plot.cpp
--- a/plot.cpp
+++ b/plot.cpp
@@ -28,8 +28,9 @@ Plot::Plot(QWidget* parent) :
QObject::connect(&zoomer, &Zoomer::unzoomed, this, &Plot::unzoomed);
zoomer.setZoomBase();
- grid.setPen(Qt::lightGray);
grid.attach(this);
+
+ darkBackground(false);
}
void Plot::setAxis(bool autoScaled, double yAxisMin, double yAxisMax)
@@ -84,3 +85,22 @@ void Plot::unzoom()
{
zoomer.zoom(0);
}
+
+void Plot::darkBackground(bool enabled)
+{
+ if (enabled)
+ {
+ setCanvasBackground(QBrush(Qt::black));
+ grid.setPen(Qt::darkGray);
+ zoomer.setRubberBandPen(QPen(Qt::white));
+ zoomer.setTrackerPen(QPen(Qt::white));
+ }
+ else
+ {
+ setCanvasBackground(QBrush(Qt::white));
+ grid.setPen(Qt::lightGray);
+ zoomer.setRubberBandPen(QPen(Qt::black));
+ zoomer.setTrackerPen(QPen(Qt::black));
+ }
+ replot();
+}
diff --git a/plot.h b/plot.h
--- a/plot.h
+++ b/plot.h
@@ -41,6 +41,7 @@ public slots:
void showGrid(bool show = true);
void showMinorGrid(bool show = true);
void unzoom();
+ void darkBackground(bool enabled = true);
private slots:
void unzoomed();