cabana: fix dark theme detection to work with system theme (#35690)

fix dark theme detection to work with system theme
This commit is contained in:
Dean Lee
2025-07-12 00:16:38 +08:00
committed by GitHub
parent bd5586da55
commit be4e995d9b
6 changed files with 16 additions and 6 deletions
+8 -1
View File
@@ -191,8 +191,15 @@ DoubleValidator::DoubleValidator(QObject *parent) : QDoubleValidator(parent) {
}
namespace utils {
bool isDarkTheme() {
QColor windowColor = QApplication::palette().color(QPalette::Window);
return windowColor.lightness() < 128;
}
QPixmap icon(const QString &id) {
bool dark_theme = settings.theme == DARK_THEME;
bool dark_theme = isDarkTheme();
QPixmap pm;
QString key = "bootstrap_" % id % (dark_theme ? "1" : "0");
if (!QPixmapCache::find(key, &pm)) {
+2
View File
@@ -98,7 +98,9 @@ public:
};
namespace utils {
QPixmap icon(const QString &id);
bool isDarkTheme();
void setTheme(int theme);
QString formatSeconds(double sec, bool include_milliseconds = false, bool absolute_time = false);
inline void drawStaticText(QPainter *p, const QRect &r, const QStaticText &text) {