From d5744a39bd4bc280a459461c35404f91bb6e7352 Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Thu, 20 Apr 2023 09:15:28 +0800 Subject: [PATCH] update --- example/T_TextBox.qml | 3 ++- example/T_Theme.qml | 6 +++++- example/main.cpp | 6 +++--- src/FluTheme.cpp | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/example/T_TextBox.qml b/example/T_TextBox.qml index def000a..d201916 100644 --- a/example/T_TextBox.qml +++ b/example/T_TextBox.qml @@ -54,11 +54,12 @@ FluScrollablePage{ FluArea{ Layout.fillWidth: true - height: 68 + height: 36+multiine_textbox.height paddings: 10 Layout.topMargin: 20 FluMultilineTextBox{ + id:multiine_textbox Layout.topMargin: 20 placeholderText: "多行输入框" Layout.preferredWidth: 300 diff --git a/example/T_Theme.qml b/example/T_Theme.qml index f0405e4..4aacdba 100644 --- a/example/T_Theme.qml +++ b/example/T_Theme.qml @@ -58,7 +58,11 @@ FluScrollablePage{ Layout.topMargin: 5 selected: FluTheme.dark clickFunc:function(){ - FluTheme.dark = !FluTheme.dark + if(FluTheme.dark){ + FluTheme.darkMode = FluDarkMode.Light + }else{ + FluTheme.darkMode = FluDarkMode.Dark + } } } FluText{ diff --git a/example/main.cpp b/example/main.cpp index 066e054..52ba0c3 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -14,9 +14,9 @@ int main(int argc, char *argv[]) qputenv("QT_QUICK_CONTROLS_STYLE","Basic"); //6.4及以下监听系统深色模式变化 qputenv("QT_QPA_PLATFORM","windows:darkmode=2"); - QCoreApplication::setOrganizationName("ZhuZiChu"); - QCoreApplication::setOrganizationDomain("https://zhuzichu520.github.io"); - QCoreApplication::setApplicationName("FluentUI"); + QGuiApplication::setOrganizationName("ZhuZiChu"); + QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io"); + QGuiApplication::setApplicationName("FluentUI"); // QQuickWindow::setGraphicsApi(QSGRendererInterface::Software); QGuiApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); diff --git a/src/FluTheme.cpp b/src/FluTheme.cpp index 9a3de1d..553a003 100644 --- a/src/FluTheme.cpp +++ b/src/FluTheme.cpp @@ -26,7 +26,7 @@ FluTheme::FluTheme(QObject *parent) nativeText(false); frameless(true); darkMode(Fluent_DarkMode::Fluent_DarkModeType::Light); - (qobject_cast(QCoreApplication::instance()))->installEventFilter(this); + qApp->installEventFilter(this); } bool FluTheme::eventFilter(QObject *obj, QEvent *event) @@ -43,7 +43,7 @@ bool FluTheme::eventFilter(QObject *obj, QEvent *event) bool FluTheme::systemDark() { - QPalette palette = (qobject_cast(QGuiApplication::instance()))->palette(); + 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); }