From 0e0b8d102711e3e15f2750ae352387a9a0db2b35 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 17 Sep 2022 01:12:12 +0800 Subject: [PATCH] Revive dark theme detection The code was removed in 199d770e152275d01da6134b802f2e16fa4e96af and now revived. --- src/gui/utils.cpp | 9 +++++++++ src/gui/utils.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index b40dcbbf6..99d31997c 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -34,8 +34,10 @@ #endif #include +#include #include #include +#include #include #include #include @@ -54,6 +56,13 @@ #include "base/utils/fs.h" #include "base/utils/version.h" +bool Utils::Gui::isDarkTheme() +{ + const QPalette palette = qApp->palette(); + const QColor &color = palette.color(QPalette::Active, QPalette::Base); + return (color.lightness() < 127); +} + QPixmap Utils::Gui::scaledPixmap(const QIcon &icon, const QWidget *widget, const int height) { Q_UNUSED(widget); // TODO: remove it diff --git a/src/gui/utils.h b/src/gui/utils.h index 58c9ac27f..ccf67f172 100644 --- a/src/gui/utils.h +++ b/src/gui/utils.h @@ -38,6 +38,8 @@ class QWidget; namespace Utils::Gui { + bool isDarkTheme(); + QPixmap scaledPixmap(const QIcon &icon, const QWidget *widget, int height); QPixmap scaledPixmap(const Path &path, const QWidget *widget, int height = 0); QPixmap scaledPixmapSvg(const Path &path, const QWidget *widget, int height);