mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 11:23:49 +08:00
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:
@@ -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)) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user