Skip to content

Commit

Permalink
fix dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
iltommi committed Sep 17, 2024
1 parent f072310 commit 2b1578d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/graphics/nTics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
#include <QColorDialog>
#include <array>


inline bool isDarkMode() {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
const auto scheme = QGuiApplication::styleHints()->colorScheme();
return scheme == Qt::ColorScheme::Dark;
#else
const QPalette defaultPalette;
const auto text = defaultPalette.color(QPalette::WindowText);
const auto window = defaultPalette.color(QPalette::Window);
return text.lightness() > window.lightness();
#endif // QT_VERSION
}

nTics::~nTics() {
QSettings my_set("neutrino","");
my_set.beginGroup("nPreferences");
Expand All @@ -45,6 +58,7 @@ nTics::nTics(nView *view) : QGraphicsItem(),
gridVisible(false),
gridThickness(1.0)
{
ticsColor=isDarkMode() ? QColor(Qt::white) : QColor(Qt::black);
QSettings my_set("neutrino","");
my_set.beginGroup("nPreferences");
rulerVisible=my_set.value("rulerVisible",rulerVisible).toBool();
Expand Down

0 comments on commit 2b1578d

Please sign in to comment.