From 3a0f6355c8bfb0477b1c9e62a0f89c841df28de6 Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Thu, 4 Jan 2024 14:28:51 +0800 Subject: [PATCH] update --- example/qml-Qt6/page/T_Home.qml | 1 - example/qml/page/T_Home.qml | 1 - example/src/main.cpp | 4 +++ example/src/singleton.h | 33 ++++++------------- .../imports/FluentUI/Controls/FluComboBox.qml | 1 + .../imports/FluentUI/Controls/FluComboBox.qml | 1 + src/singleton.h | 9 +++-- 7 files changed, 20 insertions(+), 30 deletions(-) diff --git a/example/qml-Qt6/page/T_Home.qml b/example/qml-Qt6/page/T_Home.qml index 533b8e1e..eef98a29 100644 --- a/example/qml-Qt6/page/T_Home.qml +++ b/example/qml-Qt6/page/T_Home.qml @@ -27,7 +27,6 @@ FluScrollablePage{ id: bg fillMode:Image.PreserveAspectCrop anchors.fill: parent - asynchronous: true verticalAlignment: Qt.AlignTop sourceSize: Qt.size(960,640) source: "qrc:/example/res/image/bg_home_header.png" diff --git a/example/qml/page/T_Home.qml b/example/qml/page/T_Home.qml index 4083ba69..c042bdda 100644 --- a/example/qml/page/T_Home.qml +++ b/example/qml/page/T_Home.qml @@ -27,7 +27,6 @@ FluScrollablePage{ id: bg fillMode:Image.PreserveAspectCrop anchors.fill: parent - asynchronous: true verticalAlignment: Qt.AlignTop sourceSize: Qt.size(960,640) source: "qrc:/example/res/image/bg_home_header.png" diff --git a/example/src/main.cpp b/example/src/main.cpp index 227e8330..37805aed 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -26,6 +26,9 @@ Q_IMPORT_QML_PLUGIN(FluentUIPlugin) int main(int argc, char *argv[]) { qputenv("QT_QUICK_CONTROLS_STYLE","Basic"); +#ifdef Q_OS_WIN + qputenv("QT_QPA_PLATFORM","windows:darkmode=2"); +#endif #ifdef Q_OS_LINUX //fix bug UOSv20 does not print logs qputenv("QT_LOGGING_RULES",""); @@ -35,6 +38,7 @@ int main(int argc, char *argv[]) QGuiApplication::setOrganizationName("ZhuZiChu"); QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io"); QGuiApplication::setApplicationName("FluentUI"); + QGuiApplication::setApplicationDisplayName("FluentUI Exmaple"); QGuiApplication::setApplicationVersion(APPLICATION_VERSION); SettingsHelper::getInstance()->init(argv); Log::setup("example"); diff --git a/example/src/singleton.h b/example/src/singleton.h index c1a71ce1..5c6480c1 100644 --- a/example/src/singleton.h +++ b/example/src/singleton.h @@ -2,45 +2,32 @@ #define SINGLETON_H #include -#include -#include -#include template class Singleton { public: static T* getInstance(); - Singleton(const Singleton& other) = delete; - Singleton& operator=(const Singleton& other) = delete; - private: - static std::mutex mutex; - static T* instance; + Q_DISABLE_COPY_MOVE(Singleton) }; -template -std::mutex Singleton::mutex; -template -T* Singleton::instance; template T* Singleton::getInstance() { + static QMutex mutex; + QMutexLocker locker(&mutex); + static T* instance = nullptr; if (instance == nullptr) { - std::lock_guard locker(mutex); - if (instance == nullptr) { - instance = new T(); - } + instance = new T(); } return instance; } -#define SINGLETON(Class) \ -private: \ +#define SINGLETON(Class) \ +private: \ friend class Singleton; \ - friend struct QScopedPointerDeleter; \ - \ - public: \ - static Class* getInstance() { \ + public: \ + static Class* getInstance() { \ return Singleton::getInstance(); \ } @@ -48,6 +35,6 @@ private: \ private: \ Class() = default; \ Class(const Class& other) = delete; \ - Class& operator=(const Class& other) = delete; + Q_DISABLE_COPY_MOVE(Class); #endif // SINGLETON_H diff --git a/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml b/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml index 811ac9e0..2323229a 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml @@ -102,6 +102,7 @@ T.ComboBox { height: Math.min(contentItem.implicitHeight, control.Window.height - topMargin - bottomMargin) topMargin: 6 bottomMargin: 6 + modal: true contentItem: ListView { clip: true implicitHeight: contentHeight diff --git a/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml b/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml index a02840d7..3adf257b 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml @@ -102,6 +102,7 @@ T.ComboBox { height: Math.min(contentItem.implicitHeight, control.Window.height - topMargin - bottomMargin) topMargin: 6 bottomMargin: 6 + modal: true contentItem: ListView { clip: true implicitHeight: contentHeight diff --git a/src/singleton.h b/src/singleton.h index 4053d6f4..5c6480c1 100644 --- a/src/singleton.h +++ b/src/singleton.h @@ -23,12 +23,11 @@ T* Singleton::getInstance() { return instance; } -#define SINGLETON(Class) \ -private: \ +#define SINGLETON(Class) \ +private: \ friend class Singleton; \ - \ - public: \ - static Class* getInstance() { \ + public: \ + static Class* getInstance() { \ return Singleton::getInstance(); \ }