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());
}
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 "<<route;
return;
@ -36,8 +36,8 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
}
QVariantMap properties;
properties.insert("_route",route);
if(fluRegister){
properties.insert("_pageRegister",QVariant::fromValue(fluRegister));
if(windowRegister){
properties.insert("_windowRegister",QVariant::fromValue(windowRegister));
}
properties.insert("argument",argument);
QQuickWindow *win=nullptr;
@ -61,8 +61,8 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
}
}
win = qobject_cast<QQuickWindow*>(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);
}

View File

@ -8,7 +8,7 @@
#include <QQmlContext>
#include <QJsonObject>
#include <QQmlEngine>
#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:

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 "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);
}

View File

@ -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;
};

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
#define FLUREGISTER_H
#ifndef FLUWINDOWREGISTER_H
#define FLUWINDOWREGISTER_H
#include <QObject>
#include <QQuickWindow>
@ -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

View File

@ -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

View File

@ -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

View File

@ -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(){

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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(){