add light/dark mode detection
This commit is contained in:
@ -13,9 +13,12 @@
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QPalette>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
|
||||
@ -84,6 +87,16 @@ void purge_directory(const QString &dir)
|
||||
}
|
||||
}
|
||||
|
||||
// compare black level of foreground and background color
|
||||
bool is_light_theme()
|
||||
{
|
||||
QPalette p;
|
||||
int fg = p.brush(QPalette::Active, QPalette::WindowText).color().black();
|
||||
int bg = p.brush(QPalette::Active, QPalette::Window).color().black();
|
||||
|
||||
return (fg > bg);
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// c-basic-offset: 4
|
||||
// End:
|
||||
|
||||
@ -28,6 +28,9 @@ extern bool has_exe(const QString &exe);
|
||||
// recursively purge a directory
|
||||
extern void purge_directory(const QString &dir);
|
||||
|
||||
// flag if light or dark theme
|
||||
extern bool is_light_theme();
|
||||
|
||||
#endif
|
||||
// Local Variables:
|
||||
// c-basic-offset: 4
|
||||
|
||||
Reference in New Issue
Block a user