commit
cb94db8a97
|
@ -1,6 +1,8 @@
|
||||||
#include "FluTheme.h"
|
#include "FluTheme.h"
|
||||||
|
|
||||||
#include "FluColors.h"
|
#include "FluColors.h"
|
||||||
|
#include <QPalette>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
FluTheme* FluTheme::m_instance = nullptr;
|
FluTheme* FluTheme::m_instance = nullptr;
|
||||||
|
|
||||||
|
@ -19,5 +21,13 @@ FluTheme::FluTheme(QObject *parent)
|
||||||
textSize(13);
|
textSize(13);
|
||||||
nativeText(true);
|
nativeText(true);
|
||||||
frameless(true);
|
frameless(true);
|
||||||
dark(false);
|
std::function<bool()> isDark = [](){
|
||||||
|
QPalette palette = (qobject_cast<QGuiApplication *>(QCoreApplication::instance()))->palette();
|
||||||
|
QColor color = palette.color(QPalette::Window).rgb();
|
||||||
|
return !(color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 > 255 / 2);
|
||||||
|
};
|
||||||
|
dark(isDark());
|
||||||
|
connect(qobject_cast<QGuiApplication *>(QCoreApplication::instance()), &QGuiApplication::paletteChanged, this, [=] (const QPalette &) {
|
||||||
|
dark(isDark());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue