2023-03-06 14:22:13 +08:00
|
|
|
|
#include "FluTheme.h"
|
|
|
|
|
|
|
|
|
|
#include "FluColors.h"
|
2023-04-16 01:18:17 +08:00
|
|
|
|
#include <QPalette>
|
|
|
|
|
#include <QGuiApplication>
|
2023-03-06 14:22:13 +08:00
|
|
|
|
|
|
|
|
|
FluTheme* FluTheme::m_instance = nullptr;
|
|
|
|
|
|
|
|
|
|
FluTheme *FluTheme::getInstance()
|
|
|
|
|
{
|
|
|
|
|
if(FluTheme::m_instance == nullptr){
|
|
|
|
|
FluTheme::m_instance = new FluTheme;
|
|
|
|
|
}
|
|
|
|
|
return FluTheme::m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluTheme::FluTheme(QObject *parent)
|
|
|
|
|
: QObject{parent}
|
|
|
|
|
{
|
|
|
|
|
primaryColor(FluColors::getInstance()->Blue());
|
2023-03-28 21:37:10 +08:00
|
|
|
|
textSize(13);
|
2023-03-29 21:43:01 +08:00
|
|
|
|
nativeText(true);
|
2023-03-28 21:37:10 +08:00
|
|
|
|
frameless(true);
|
2023-04-16 01:18:17 +08:00
|
|
|
|
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());
|
|
|
|
|
});
|
2023-03-06 14:22:13 +08:00
|
|
|
|
}
|