This commit is contained in:
朱子楚\zhuzi 2024-03-06 21:00:49 +08:00
parent 2ae2e2509a
commit 0d9d459d68
14 changed files with 112 additions and 91 deletions

View File

@ -24,7 +24,7 @@ void FluApp::run(){
navigate(initialRoute()); 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)){ if(!routes().contains(route)){
qCritical()<<"Not Found Route "<<route; qCritical()<<"Not Found Route "<<route;
return; return;
@ -36,8 +36,8 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
} }
QVariantMap properties; QVariantMap properties;
properties.insert("_route",route); properties.insert("_route",route);
if(fluRegister){ if(windowRegister){
properties.insert("_pageRegister",QVariant::fromValue(fluRegister)); properties.insert("_windowRegister",QVariant::fromValue(windowRegister));
} }
properties.insert("argument",argument); properties.insert("argument",argument);
QQuickWindow *win=nullptr; QQuickWindow *win=nullptr;
@ -61,8 +61,8 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
} }
} }
win = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties)); win = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties));
if(fluRegister){ if(windowRegister){
fluRegister->to(win); windowRegister->to(win);
} }
win->setColor(QColor(Qt::transparent)); win->setColor(QColor(Qt::transparent));
} }
@ -86,3 +86,10 @@ void FluApp::removeWindow(QQuickWindow* window){
window = nullptr; 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);
}

View File

@ -8,7 +8,7 @@
#include <QQmlContext> #include <QQmlContext>
#include <QJsonObject> #include <QJsonObject>
#include <QQmlEngine> #include <QQmlEngine>
#include "FluRegister.h" #include "FluWindowRegister.h"
#include "stdafx.h" #include "stdafx.h"
#include "singleton.h" #include "singleton.h"
@ -31,9 +31,10 @@ public:
SINGLETON(FluApp) SINGLETON(FluApp)
static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();} static FluApp *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return getInstance();}
Q_INVOKABLE void run(); 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 init(QObject *target);
Q_INVOKABLE void exit(int retCode = 0); Q_INVOKABLE void exit(int retCode = 0);
Q_INVOKABLE QVariant createWindowRegister(QQuickWindow* window,const QString& path);
void addWindow(QQuickWindow* window); void addWindow(QQuickWindow* window);
void removeWindow(QQuickWindow* window); void removeWindow(QQuickWindow* window);
private: private:

View File

@ -1,18 +0,0 @@
#include "FluRegister.h"
#include "FluApp.h"
#include <QCoreApplication>
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);
}

View File

@ -1,7 +1,6 @@
#include "FluWindowLifecycle.h" #include "FluWindowLifecycle.h"
#include "FluApp.h" #include "FluApp.h"
#include "FluRegister.h"
FluWindowLifecycle::FluWindowLifecycle(QObject *parent):QObject{parent}{ FluWindowLifecycle::FluWindowLifecycle(QObject *parent):QObject{parent}{
@ -24,10 +23,3 @@ void FluWindowLifecycle::onDestruction(){
void FluWindowLifecycle::onVisible(bool visible){ 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);
}

View File

@ -21,7 +21,6 @@ public:
Q_INVOKABLE void onDestruction(); Q_INVOKABLE void onDestruction();
Q_INVOKABLE void onVisible(bool visible); Q_INVOKABLE void onVisible(bool visible);
Q_INVOKABLE void onDestoryOnClose(); Q_INVOKABLE void onDestoryOnClose();
Q_INVOKABLE QVariant createRegister(QQuickWindow* window,const QString& path);
private: private:
QQuickWindow* _window = nullptr; QQuickWindow* _window = nullptr;
}; };

18
src/FluWindowRegister.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "FluWindowRegister.h"
#include "FluApp.h"
#include <QCoreApplication>
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);
}

View File

@ -1,5 +1,5 @@
#ifndef FLUREGISTER_H #ifndef FLUWINDOWREGISTER_H
#define FLUREGISTER_H #define FLUWINDOWREGISTER_H
#include <QObject> #include <QObject>
#include <QQuickWindow> #include <QQuickWindow>
@ -7,19 +7,19 @@
#include "stdafx.h" #include "stdafx.h"
/** /**
* @brief The FluRegister class * @brief The FluWindowRegister class
*/ */
class FluRegister : public QObject class FluWindowRegister : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY_AUTO(QQuickWindow*,from) Q_PROPERTY_AUTO(QQuickWindow*,from)
Q_PROPERTY_AUTO(QQuickWindow*,to) Q_PROPERTY_AUTO(QQuickWindow*,to)
Q_PROPERTY_AUTO(QString,path); Q_PROPERTY_AUTO(QString,path);
public: public:
explicit FluRegister(QObject *parent = nullptr); explicit FluWindowRegister(QObject *parent = nullptr);
Q_INVOKABLE void launch(const QJsonObject& argument = {}); Q_INVOKABLE void launch(const QJsonObject& argument = {});
Q_INVOKABLE void onResult(const QJsonObject& data = {}); Q_INVOKABLE void onResult(const QJsonObject& data = {});
Q_SIGNAL void result(const QJsonObject& data); Q_SIGNAL void result(const QJsonObject& data);
}; };
#endif // FLUREGISTER_H #endif // FLUWINDOWREGISTER_H

View File

@ -39,7 +39,7 @@ Button{
id:color_dialog id:color_dialog
implicitWidth: 326 implicitWidth: 326
implicitHeight: 560 implicitHeight: 560
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside closePolicy: Popup.CloseOnEscape
Rectangle{ Rectangle{
id:layout_actions id:layout_actions
width: parent.width width: parent.width
@ -280,7 +280,6 @@ Button{
onPressed:(mouse)=> handleMouse(mouse) onPressed:(mouse)=> handleMouse(mouse)
} }
} }
FluClip{ FluClip{
width: 40 width: 40
height: 200 height: 200

View File

@ -37,15 +37,30 @@ Button {
visible: control.visualFocus visible: control.visualFocus
radius:4 radius:4
} }
color:{ gradient: Gradient {
if(!enabled){ GradientStop { position: 0.33; color: control.normalColor }
return disableColor GradientStop { position: 1.0; color: Qt.darker(control.normalColor,1.3) }
}
if(pressed){
return pressedColor
}
return hovered ? hoverColor :normalColor
} }
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 { contentItem: FluText {
text: control.text text: control.text

View File

@ -31,8 +31,6 @@ Window {
return FluTheme.windowBackgroundColor return FluTheme.windowBackgroundColor
} }
property bool stayTop: false property bool stayTop: false
property var _pageRegister
property string _route
property bool showDark: false property bool showDark: false
property bool showClose: true property bool showClose: true
property bool showMinimize: true property bool showMinimize: true
@ -65,6 +63,8 @@ Window {
property int _realHeight property int _realHeight
property int _realWidth property int _realWidth
property int _appBarHeight: appBar.height property int _appBarHeight: appBar.height
property var _windowRegister
property string _route
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
@ -280,7 +280,7 @@ Window {
if(FluTools.isWindows10OrGreater()){ if(FluTools.isWindows10OrGreater()){
return undefined return undefined
} }
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined return undefined
} }
return com_border return com_border
@ -310,9 +310,6 @@ Window {
function showError(text,duration,moremsg){ function showError(text,duration,moremsg){
infoBar.showError(text,duration,moremsg) infoBar.showError(text,duration,moremsg)
} }
function registerForWindowResult(path){
return lifecycle.createRegister(window,path)
}
function moveWindowToDesktopCenter(){ function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()] screen = Qt.application.screens[FluTools.cursorScreenIndex()]
var taskBarHeight = FluTools.getTaskBarHeight(window) var taskBarHeight = FluTools.getTaskBarHeight(window)
@ -326,9 +323,12 @@ Window {
window.minimumHeight = window.height window.minimumHeight = window.height
} }
} }
function registerForWindowResult(path){
return FluApp.createWindowRegister(window,path)
}
function onResult(data){ function onResult(data){
if(_pageRegister){ if(_windowRegister){
_pageRegister.onResult(data) _windowRegister.onResult(data)
} }
} }
function layoutContainer(){ function layoutContainer(){

View File

@ -502,12 +502,6 @@ Module {
Parameter { name: "visible"; type: "bool" } Parameter { name: "visible"; type: "bool" }
} }
Method { name: "onDestoryOnClose" } Method { name: "onDestoryOnClose" }
Method {
name: "createRegister"
type: "QVariant"
Parameter { name: "window"; type: "QQuickWindow"; isPointer: true }
Parameter { name: "path"; type: "string" }
}
} }
Component { Component {
name: "FluWindowType" name: "FluWindowType"
@ -2386,7 +2380,7 @@ Module {
} }
Property { Property {
name: "buttonDark" name: "buttonDark"
type: "FluToggleSwitch_QMLTYPE_22" type: "FluToggleSwitch_QMLTYPE_21"
isReadonly: true isReadonly: true
isPointer: true isPointer: true
} }
@ -3044,15 +3038,15 @@ Module {
defaultProperty: "data" defaultProperty: "data"
Property { name: "logo"; type: "QUrl" } Property { name: "logo"; type: "QUrl" }
Property { name: "title"; type: "string" } Property { name: "title"; type: "string" }
Property { name: "items"; type: "FluObject_QMLTYPE_149"; isPointer: true } Property { name: "items"; type: "FluObject_QMLTYPE_156"; isPointer: true }
Property { name: "footerItems"; type: "FluObject_QMLTYPE_149"; isPointer: true } Property { name: "footerItems"; type: "FluObject_QMLTYPE_156"; isPointer: true }
Property { name: "displayMode"; type: "int" } Property { name: "displayMode"; type: "int" }
Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true } Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true }
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true } Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
Property { name: "topPadding"; type: "int" } Property { name: "topPadding"; type: "int" }
Property { name: "pageMode"; type: "int" } Property { name: "pageMode"; type: "int" }
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_38"; isPointer: true } Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_33"; isPointer: true }
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_38"; isPointer: true } Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_33"; isPointer: true }
Property { name: "navCompactWidth"; type: "int" } Property { name: "navCompactWidth"; type: "int" }
Property { name: "navTopMargin"; type: "int" } Property { name: "navTopMargin"; type: "int" }
Property { name: "cellHeight"; type: "int" } Property { name: "cellHeight"; type: "int" }
@ -3869,8 +3863,6 @@ Module {
Property { name: "appBar"; type: "QQuickItem"; isPointer: true } Property { name: "appBar"; type: "QQuickItem"; isPointer: true }
Property { name: "backgroundColor"; type: "QColor" } Property { name: "backgroundColor"; type: "QColor" }
Property { name: "stayTop"; type: "bool" } Property { name: "stayTop"; type: "bool" }
Property { name: "_pageRegister"; type: "QVariant" }
Property { name: "_route"; type: "string" }
Property { name: "showDark"; type: "bool" } Property { name: "showDark"; type: "bool" }
Property { name: "showClose"; type: "bool" } Property { name: "showClose"; type: "bool" }
Property { name: "showMinimize"; type: "bool" } Property { name: "showMinimize"; type: "bool" }
@ -3888,6 +3880,8 @@ Module {
Property { name: "_realHeight"; type: "int" } Property { name: "_realHeight"; type: "int" }
Property { name: "_realWidth"; type: "int" } Property { name: "_realWidth"; type: "int" }
Property { name: "_appBarHeight"; 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 } Property { name: "content"; type: "QObject"; isList: true; isReadonly: true }
Signal { name: "showSystemMenu" } Signal { name: "showSystemMenu" }
Signal { Signal {
@ -3931,13 +3925,13 @@ Module {
Parameter { name: "duration"; type: "QVariant" } Parameter { name: "duration"; type: "QVariant" }
Parameter { name: "moremsg"; type: "QVariant" } Parameter { name: "moremsg"; type: "QVariant" }
} }
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
Method { name: "fixWindowSize"; type: "QVariant" }
Method { Method {
name: "registerForWindowResult" name: "registerForWindowResult"
type: "QVariant" type: "QVariant"
Parameter { name: "path"; type: "QVariant" } Parameter { name: "path"; type: "QVariant" }
} }
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
Method { name: "fixWindowSize"; type: "QVariant" }
Method { Method {
name: "onResult" name: "onResult"
type: "QVariant" type: "QVariant"

View File

@ -39,7 +39,7 @@ Button{
id:color_dialog id:color_dialog
implicitWidth: 326 implicitWidth: 326
implicitHeight: 560 implicitHeight: 560
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside closePolicy: Popup.CloseOnEscape
Rectangle{ Rectangle{
id:layout_actions id:layout_actions
width: parent.width width: parent.width
@ -280,7 +280,6 @@ Button{
onPressed:(mouse)=> handleMouse(mouse) onPressed:(mouse)=> handleMouse(mouse)
} }
} }
FluClip{ FluClip{
width: 40 width: 40
height: 200 height: 200

View File

@ -38,15 +38,30 @@ Button {
visible: control.visualFocus visible: control.visualFocus
radius:4 radius:4
} }
color:{ gradient: Gradient {
if(!enabled){ GradientStop { position: 0.33; color: control.normalColor }
return disableColor GradientStop { position: 1.0; color: Qt.darker(control.normalColor,1.3) }
}
if(pressed){
return pressedColor
}
return hovered ? hoverColor :normalColor
} }
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 { contentItem: FluText {
text: control.text text: control.text

View File

@ -30,8 +30,6 @@ Window {
return FluTheme.windowBackgroundColor return FluTheme.windowBackgroundColor
} }
property bool stayTop: false property bool stayTop: false
property var _pageRegister
property string _route
property bool showDark: false property bool showDark: false
property bool showClose: true property bool showClose: true
property bool showMinimize: true property bool showMinimize: true
@ -64,6 +62,8 @@ Window {
property int _realHeight property int _realHeight
property int _realWidth property int _realWidth
property int _appBarHeight: appBar.height property int _appBarHeight: appBar.height
property var _windowRegister
property string _route
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
@ -279,7 +279,7 @@ Window {
if(FluTools.isWindows10OrGreater()){ if(FluTools.isWindows10OrGreater()){
return undefined return undefined
} }
if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined return undefined
} }
return com_border return com_border
@ -309,9 +309,6 @@ Window {
function showError(text,duration,moremsg){ function showError(text,duration,moremsg){
infoBar.showError(text,duration,moremsg) infoBar.showError(text,duration,moremsg)
} }
function registerForWindowResult(path){
return lifecycle.createRegister(window,path)
}
function moveWindowToDesktopCenter(){ function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()] screen = Qt.application.screens[FluTools.cursorScreenIndex()]
var taskBarHeight = FluTools.getTaskBarHeight(window) var taskBarHeight = FluTools.getTaskBarHeight(window)
@ -325,9 +322,12 @@ Window {
window.minimumHeight = window.height window.minimumHeight = window.height
} }
} }
function registerForWindowResult(path){
return FluApp.createWindowRegister(window,path)
}
function onResult(data){ function onResult(data){
if(_pageRegister){ if(_windowRegister){
_pageRegister.onResult(data) _windowRegister.onResult(data)
} }
} }
function layoutContainer(){ function layoutContainer(){