From 0d9d459d68988ea45ddb6211c73ccd80bd7faa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Wed, 6 Mar 2024 21:00:49 +0800 Subject: [PATCH] update --- src/FluApp.cpp | 17 +++++++--- src/FluApp.h | 5 +-- src/FluRegister.cpp | 18 ----------- src/FluWindowLifecycle.cpp | 8 ----- src/FluWindowLifecycle.h | 1 - src/FluWindowRegister.cpp | 18 +++++++++++ src/{FluRegister.h => FluWindowRegister.h} | 12 +++---- .../FluentUI/Controls/FluColorPicker.qml | 3 +- .../FluentUI/Controls/FluFilledButton.qml | 31 ++++++++++++++----- .../imports/FluentUI/Controls/FluWindow.qml | 16 +++++----- src/Qt5/imports/FluentUI/plugins.qmltypes | 24 ++++++-------- .../FluentUI/Controls/FluColorPicker.qml | 3 +- .../FluentUI/Controls/FluFilledButton.qml | 31 ++++++++++++++----- .../imports/FluentUI/Controls/FluWindow.qml | 16 +++++----- 14 files changed, 112 insertions(+), 91 deletions(-) delete mode 100644 src/FluRegister.cpp create mode 100644 src/FluWindowRegister.cpp rename src/{FluRegister.h => FluWindowRegister.h} (64%) diff --git a/src/FluApp.cpp b/src/FluApp.cpp index 55e869b9..377b38f0 100644 --- a/src/FluApp.cpp +++ b/src/FluApp.cpp @@ -24,7 +24,7 @@ void FluApp::run(){ navigate(initialRoute()); } -void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){ +void FluApp::navigate(const QString& route,const QJsonObject& argument,FluWindowRegister* windowRegister){ if(!routes().contains(route)){ qCritical()<<"Not Found Route "<(component.createWithInitialProperties(properties)); - if(fluRegister){ - fluRegister->to(win); + if(windowRegister){ + windowRegister->to(win); } win->setColor(QColor(Qt::transparent)); } @@ -86,3 +86,10 @@ void FluApp::removeWindow(QQuickWindow* window){ window = nullptr; } } + +QVariant FluApp::createWindowRegister(QQuickWindow* window,const QString& path){ + FluWindowRegister *p = new FluWindowRegister(window); + p->from(window); + p->path(path); + return QVariant::fromValue(p); +} diff --git a/src/FluApp.h b/src/FluApp.h index ffefdd78..cb454fd7 100644 --- a/src/FluApp.h +++ b/src/FluApp.h @@ -8,7 +8,7 @@ #include #include #include -#include "FluRegister.h" +#include "FluWindowRegister.h" #include "stdafx.h" #include "singleton.h" @@ -31,9 +31,10 @@ public: SINGLETON(FluApp) static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();} Q_INVOKABLE void run(); - Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr); + Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluWindowRegister* windowRegister = nullptr); Q_INVOKABLE void init(QObject *target); Q_INVOKABLE void exit(int retCode = 0); + Q_INVOKABLE QVariant createWindowRegister(QQuickWindow* window,const QString& path); void addWindow(QQuickWindow* window); void removeWindow(QQuickWindow* window); private: diff --git a/src/FluRegister.cpp b/src/FluRegister.cpp deleted file mode 100644 index bedf4c0f..00000000 --- a/src/FluRegister.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "FluRegister.h" - -#include "FluApp.h" -#include - -FluRegister::FluRegister(QObject *parent):QObject{parent}{ - from(nullptr); - to(nullptr); - path(""); -} - -void FluRegister::launch(const QJsonObject& argument){ - FluApp::getInstance()->navigate(path(),argument,this); -} - -void FluRegister::onResult(const QJsonObject& data){ - Q_EMIT result(data); -} diff --git a/src/FluWindowLifecycle.cpp b/src/FluWindowLifecycle.cpp index c12e4c44..e2d87167 100644 --- a/src/FluWindowLifecycle.cpp +++ b/src/FluWindowLifecycle.cpp @@ -1,7 +1,6 @@ #include "FluWindowLifecycle.h" #include "FluApp.h" -#include "FluRegister.h" FluWindowLifecycle::FluWindowLifecycle(QObject *parent):QObject{parent}{ @@ -24,10 +23,3 @@ void FluWindowLifecycle::onDestruction(){ void FluWindowLifecycle::onVisible(bool visible){ } - -QVariant FluWindowLifecycle::createRegister(QQuickWindow* window,const QString& path){ - FluRegister *p = new FluRegister(window); - p->from(window); - p->path(path); - return QVariant::fromValue(p); -} diff --git a/src/FluWindowLifecycle.h b/src/FluWindowLifecycle.h index 9c6643d2..809af001 100644 --- a/src/FluWindowLifecycle.h +++ b/src/FluWindowLifecycle.h @@ -21,7 +21,6 @@ public: Q_INVOKABLE void onDestruction(); Q_INVOKABLE void onVisible(bool visible); Q_INVOKABLE void onDestoryOnClose(); - Q_INVOKABLE QVariant createRegister(QQuickWindow* window,const QString& path); private: QQuickWindow* _window = nullptr; }; diff --git a/src/FluWindowRegister.cpp b/src/FluWindowRegister.cpp new file mode 100644 index 00000000..b2fa678b --- /dev/null +++ b/src/FluWindowRegister.cpp @@ -0,0 +1,18 @@ +#include "FluWindowRegister.h" + +#include "FluApp.h" +#include + +FluWindowRegister::FluWindowRegister(QObject *parent):QObject{parent}{ + from(nullptr); + to(nullptr); + path(""); +} + +void FluWindowRegister::launch(const QJsonObject& argument){ + FluApp::getInstance()->navigate(path(),argument,this); +} + +void FluWindowRegister::onResult(const QJsonObject& data){ + Q_EMIT result(data); +} diff --git a/src/FluRegister.h b/src/FluWindowRegister.h similarity index 64% rename from src/FluRegister.h rename to src/FluWindowRegister.h index 51e91c35..cda59497 100644 --- a/src/FluRegister.h +++ b/src/FluWindowRegister.h @@ -1,5 +1,5 @@ -#ifndef FLUREGISTER_H -#define FLUREGISTER_H +#ifndef FLUWINDOWREGISTER_H +#define FLUWINDOWREGISTER_H #include #include @@ -7,19 +7,19 @@ #include "stdafx.h" /** - * @brief The FluRegister class + * @brief The FluWindowRegister class */ -class FluRegister : public QObject +class FluWindowRegister : public QObject { Q_OBJECT Q_PROPERTY_AUTO(QQuickWindow*,from) Q_PROPERTY_AUTO(QQuickWindow*,to) Q_PROPERTY_AUTO(QString,path); public: - explicit FluRegister(QObject *parent = nullptr); + explicit FluWindowRegister(QObject *parent = nullptr); Q_INVOKABLE void launch(const QJsonObject& argument = {}); Q_INVOKABLE void onResult(const QJsonObject& data = {}); Q_SIGNAL void result(const QJsonObject& data); }; -#endif // FLUREGISTER_H +#endif // FLUWINDOWREGISTER_H diff --git a/src/Qt5/imports/FluentUI/Controls/FluColorPicker.qml b/src/Qt5/imports/FluentUI/Controls/FluColorPicker.qml index e80aa6f2..f04f0074 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluColorPicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluColorPicker.qml @@ -39,7 +39,7 @@ Button{ id:color_dialog implicitWidth: 326 implicitHeight: 560 - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside + closePolicy: Popup.CloseOnEscape Rectangle{ id:layout_actions width: parent.width @@ -280,7 +280,6 @@ Button{ onPressed:(mouse)=> handleMouse(mouse) } } - FluClip{ width: 40 height: 200 diff --git a/src/Qt5/imports/FluentUI/Controls/FluFilledButton.qml b/src/Qt5/imports/FluentUI/Controls/FluFilledButton.qml index 89d50b76..25702ebf 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluFilledButton.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluFilledButton.qml @@ -37,15 +37,30 @@ Button { visible: control.visualFocus radius:4 } - color:{ - if(!enabled){ - return disableColor - } - if(pressed){ - return pressedColor - } - return hovered ? hoverColor :normalColor + gradient: Gradient { + GradientStop { position: 0.33; color: control.normalColor } + GradientStop { position: 1.0; color: Qt.darker(control.normalColor,1.3) } } + Rectangle{ + radius: parent.radius + anchors{ + fill: parent + topMargin: 1 + leftMargin: 1 + rightMargin: 1 + bottomMargin: 2 + } + color:{ + if(!enabled){ + return disableColor + } + if(pressed){ + return pressedColor + } + return hovered ? hoverColor :normalColor + } + } + } contentItem: FluText { text: control.text diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 771c2ab9..e904b893 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -31,8 +31,6 @@ Window { return FluTheme.windowBackgroundColor } property bool stayTop: false - property var _pageRegister - property string _route property bool showDark: false property bool showClose: true property bool showMinimize: true @@ -65,6 +63,8 @@ Window { property int _realHeight property int _realWidth property int _appBarHeight: appBar.height + property var _windowRegister + property string _route id:window color:"transparent" Component.onCompleted: { @@ -280,7 +280,7 @@ Window { if(FluTools.isWindows10OrGreater()){ return undefined } - if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ + if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){ return undefined } return com_border @@ -310,9 +310,6 @@ Window { function showError(text,duration,moremsg){ infoBar.showError(text,duration,moremsg) } - function registerForWindowResult(path){ - return lifecycle.createRegister(window,path) - } function moveWindowToDesktopCenter(){ screen = Qt.application.screens[FluTools.cursorScreenIndex()] var taskBarHeight = FluTools.getTaskBarHeight(window) @@ -326,9 +323,12 @@ Window { window.minimumHeight = window.height } } + function registerForWindowResult(path){ + return FluApp.createWindowRegister(window,path) + } function onResult(data){ - if(_pageRegister){ - _pageRegister.onResult(data) + if(_windowRegister){ + _windowRegister.onResult(data) } } function layoutContainer(){ diff --git a/src/Qt5/imports/FluentUI/plugins.qmltypes b/src/Qt5/imports/FluentUI/plugins.qmltypes index 121c1fff..07a83c6b 100644 --- a/src/Qt5/imports/FluentUI/plugins.qmltypes +++ b/src/Qt5/imports/FluentUI/plugins.qmltypes @@ -502,12 +502,6 @@ Module { Parameter { name: "visible"; type: "bool" } } Method { name: "onDestoryOnClose" } - Method { - name: "createRegister" - type: "QVariant" - Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } - Parameter { name: "path"; type: "string" } - } } Component { name: "FluWindowType" @@ -2386,7 +2380,7 @@ Module { } Property { name: "buttonDark" - type: "FluToggleSwitch_QMLTYPE_22" + type: "FluToggleSwitch_QMLTYPE_21" isReadonly: true isPointer: true } @@ -3044,15 +3038,15 @@ Module { defaultProperty: "data" Property { name: "logo"; type: "QUrl" } Property { name: "title"; type: "string" } - Property { name: "items"; type: "FluObject_QMLTYPE_149"; isPointer: true } - Property { name: "footerItems"; type: "FluObject_QMLTYPE_149"; isPointer: true } + Property { name: "items"; type: "FluObject_QMLTYPE_156"; isPointer: true } + Property { name: "footerItems"; type: "FluObject_QMLTYPE_156"; isPointer: true } Property { name: "displayMode"; type: "int" } Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true } Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true } Property { name: "topPadding"; type: "int" } Property { name: "pageMode"; type: "int" } - Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_38"; isPointer: true } - Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_38"; isPointer: true } + Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_33"; isPointer: true } + Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_33"; isPointer: true } Property { name: "navCompactWidth"; type: "int" } Property { name: "navTopMargin"; type: "int" } Property { name: "cellHeight"; type: "int" } @@ -3869,8 +3863,6 @@ Module { Property { name: "appBar"; type: "QQuickItem"; isPointer: true } Property { name: "backgroundColor"; type: "QColor" } Property { name: "stayTop"; type: "bool" } - Property { name: "_pageRegister"; type: "QVariant" } - Property { name: "_route"; type: "string" } Property { name: "showDark"; type: "bool" } Property { name: "showClose"; type: "bool" } Property { name: "showMinimize"; type: "bool" } @@ -3888,6 +3880,8 @@ Module { Property { name: "_realHeight"; type: "int" } Property { name: "_realWidth"; type: "int" } Property { name: "_appBarHeight"; type: "int" } + Property { name: "_windowRegister"; type: "QVariant" } + Property { name: "_route"; type: "string" } Property { name: "content"; type: "QObject"; isList: true; isReadonly: true } Signal { name: "showSystemMenu" } Signal { @@ -3931,13 +3925,13 @@ Module { Parameter { name: "duration"; type: "QVariant" } Parameter { name: "moremsg"; type: "QVariant" } } + Method { name: "moveWindowToDesktopCenter"; type: "QVariant" } + Method { name: "fixWindowSize"; type: "QVariant" } Method { name: "registerForWindowResult" type: "QVariant" Parameter { name: "path"; type: "QVariant" } } - Method { name: "moveWindowToDesktopCenter"; type: "QVariant" } - Method { name: "fixWindowSize"; type: "QVariant" } Method { name: "onResult" type: "QVariant" diff --git a/src/Qt6/imports/FluentUI/Controls/FluColorPicker.qml b/src/Qt6/imports/FluentUI/Controls/FluColorPicker.qml index f99c8fae..2faf8288 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluColorPicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluColorPicker.qml @@ -39,7 +39,7 @@ Button{ id:color_dialog implicitWidth: 326 implicitHeight: 560 - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside + closePolicy: Popup.CloseOnEscape Rectangle{ id:layout_actions width: parent.width @@ -280,7 +280,6 @@ Button{ onPressed:(mouse)=> handleMouse(mouse) } } - FluClip{ width: 40 height: 200 diff --git a/src/Qt6/imports/FluentUI/Controls/FluFilledButton.qml b/src/Qt6/imports/FluentUI/Controls/FluFilledButton.qml index fe2b6a55..edc889b9 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluFilledButton.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluFilledButton.qml @@ -38,15 +38,30 @@ Button { visible: control.visualFocus radius:4 } - color:{ - if(!enabled){ - return disableColor - } - if(pressed){ - return pressedColor - } - return hovered ? hoverColor :normalColor + gradient: Gradient { + GradientStop { position: 0.33; color: control.normalColor } + GradientStop { position: 1.0; color: Qt.darker(control.normalColor,1.3) } } + Rectangle{ + radius: parent.radius + anchors{ + fill: parent + topMargin: 1 + leftMargin: 1 + rightMargin: 1 + bottomMargin: 2 + } + color:{ + if(!enabled){ + return disableColor + } + if(pressed){ + return pressedColor + } + return hovered ? hoverColor :normalColor + } + } + } contentItem: FluText { text: control.text diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 22d42028..a00e83ab 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -30,8 +30,6 @@ Window { return FluTheme.windowBackgroundColor } property bool stayTop: false - property var _pageRegister - property string _route property bool showDark: false property bool showClose: true property bool showMinimize: true @@ -64,6 +62,8 @@ Window { property int _realHeight property int _realWidth property int _appBarHeight: appBar.height + property var _windowRegister + property string _route id:window color:"transparent" Component.onCompleted: { @@ -279,7 +279,7 @@ Window { if(FluTools.isWindows10OrGreater()){ return undefined } - if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ + if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){ return undefined } return com_border @@ -309,9 +309,6 @@ Window { function showError(text,duration,moremsg){ infoBar.showError(text,duration,moremsg) } - function registerForWindowResult(path){ - return lifecycle.createRegister(window,path) - } function moveWindowToDesktopCenter(){ screen = Qt.application.screens[FluTools.cursorScreenIndex()] var taskBarHeight = FluTools.getTaskBarHeight(window) @@ -325,9 +322,12 @@ Window { window.minimumHeight = window.height } } + function registerForWindowResult(path){ + return FluApp.createWindowRegister(window,path) + } function onResult(data){ - if(_pageRegister){ - _pageRegister.onResult(data) + if(_windowRegister){ + _windowRegister.onResult(data) } } function layoutContainer(){