update
parent
1601b64883
commit
155960c15b
|
@ -15,20 +15,16 @@ FRAMELESSHELPER_USE_NAMESPACE
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
FramelessHelper::Quick::initialize();
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
//6.4及以下监听系统深色模式变化
|
||||
#ifdef Q_OS_WIN
|
||||
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
|
||||
#endif
|
||||
//将样式设置为Basic,不然会导致组件显示异常
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
QGuiApplication::setOrganizationName("ZhuZiChu");
|
||||
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
||||
QGuiApplication::setApplicationName("FluentUI");
|
||||
// QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
|
||||
QGuiApplication app(argc, argv);
|
||||
FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
// FramelessHelper::Core::setApplicationOSThemeAware();
|
||||
// FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
|
||||
// FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||
AppInfo* appInfo = new AppInfo();
|
||||
IPC ipc(0);
|
||||
QString activeWindowEvent = "activeWindow";
|
||||
|
|
|
@ -61,9 +61,9 @@ qt_add_qml_module(fluentuiplugin
|
|||
|
||||
#链接库
|
||||
target_link_libraries(fluentuiplugin PUBLIC
|
||||
Qt::Core
|
||||
Qt::Quick
|
||||
Qt::Qml
|
||||
Qt::CorePrivate
|
||||
Qt::QuickPrivate
|
||||
Qt::QmlPrivate
|
||||
)
|
||||
|
||||
#链接库 win32库 不然mingw会编译错误
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "Def.h"
|
||||
#include "FluColors.h"
|
||||
#include <QPalette>
|
||||
#include <QtGui/qpa/qplatformtheme.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QGuiApplication>
|
||||
|
||||
FluTheme* FluTheme::m_instance = nullptr;
|
||||
|
@ -30,8 +32,9 @@ FluTheme::FluTheme(QObject *parent)
|
|||
bool FluTheme::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
Q_UNUSED(obj);
|
||||
if (event->type() == QEvent::ApplicationPaletteChange)
|
||||
if (event->type() == QEvent::ApplicationPaletteChange || event->type() == QEvent::ThemeChange)
|
||||
{
|
||||
_systemDark = systemDark();
|
||||
Q_EMIT darkChanged();
|
||||
event->accept();
|
||||
return true;
|
||||
|
@ -41,9 +44,10 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
|
|||
|
||||
bool FluTheme::systemDark()
|
||||
{
|
||||
QPalette palette = qApp->palette();
|
||||
QColor color = palette.color(QPalette::Window).rgb();
|
||||
return !(color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 > 255 / 2);
|
||||
if (const QPlatformTheme * const theme = QGuiApplicationPrivate::platformTheme()) {
|
||||
return (theme->appearance() == QPlatformTheme::Appearance::Dark);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FluTheme::dark(){
|
||||
|
@ -52,7 +56,7 @@ bool FluTheme::dark(){
|
|||
}else if(_darkMode == Fluent_DarkMode::Fluent_DarkModeType::Light){
|
||||
return false;
|
||||
}else if(_darkMode == Fluent_DarkMode::Fluent_DarkModeType::System){
|
||||
return systemDark();
|
||||
return _systemDark;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
Q_SIGNAL void darkChanged();
|
||||
private:
|
||||
bool _dark;
|
||||
bool _systemDark;
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
bool systemDark();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue