main
zhuzichu 2023-04-20 00:15:13 +08:00
parent 51aef3f3ec
commit aba33c4d1f
2 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,8 @@ int main(int argc, char *argv[])
{ {
//将样式设置为Basic不然会导致组件显示异常 //将样式设置为Basic不然会导致组件显示异常
qputenv("QT_QUICK_CONTROLS_STYLE","Basic"); qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
//6.4及以下监听系统深色模式变化
qputenv("QT_QPA_PLATFORM","windows:darkmode=2");
QCoreApplication::setOrganizationName("ZhuZiChu"); QCoreApplication::setOrganizationName("ZhuZiChu");
QCoreApplication::setOrganizationDomain("https://zhuzichu520.github.io"); QCoreApplication::setOrganizationDomain("https://zhuzichu520.github.io");
QCoreApplication::setApplicationName("FluentUI"); QCoreApplication::setApplicationName("FluentUI");

View File

@ -34,6 +34,7 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
Q_UNUSED(obj); Q_UNUSED(obj);
if (event->type() == QEvent::ApplicationPaletteChange) if (event->type() == QEvent::ApplicationPaletteChange)
{ {
qDebug()<<"--------->";
Q_EMIT darkChanged(); Q_EMIT darkChanged();
event->accept(); event->accept();
return true; return true;
@ -43,7 +44,7 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event)
bool FluTheme::systemDark() bool FluTheme::systemDark()
{ {
QPalette palette = (qobject_cast<QGuiApplication *>(QCoreApplication::instance()))->palette(); QPalette palette = (qobject_cast<QGuiApplication *>(QGuiApplication::instance()))->palette();
QColor color = palette.color(QPalette::Window).rgb(); QColor color = palette.color(QPalette::Window).rgb();
return !(color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 > 255 / 2); return !(color.red() * 0.2126 + color.green() * 0.7152 + color.blue() * 0.0722 > 255 / 2);
} }