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:
|
||||
|
||||
Reference in New Issue
Block a user