update
parent
7282a6f8d1
commit
9d3de073c0
|
@ -9,6 +9,18 @@ FluScrollablePage{
|
|||
|
||||
title:"MultiWindow"
|
||||
|
||||
property string password: ""
|
||||
|
||||
property var loginPageRegister: registerForPageResult("/login")
|
||||
|
||||
Connections{
|
||||
target: loginPageRegister
|
||||
function onResult(data)
|
||||
{
|
||||
password = data.password
|
||||
}
|
||||
}
|
||||
|
||||
FluArea{
|
||||
width: parent.width
|
||||
height: 68
|
||||
|
@ -33,30 +45,31 @@ FluScrollablePage{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FluArea{
|
||||
width: parent.width
|
||||
height: 68
|
||||
height: 130
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
|
||||
Column{
|
||||
spacing: 5
|
||||
spacing: 15
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
}
|
||||
FluText{
|
||||
text:"页面跳转,并携带参数"
|
||||
text:"页面跳转,并携带参数用户名:zhuzichu"
|
||||
}
|
||||
FluButton{
|
||||
text:"点击跳转"
|
||||
text:"点击跳转到登录"
|
||||
onClicked: {
|
||||
FluApp.navigate("/login",{username:"zhuzichu"})
|
||||
loginPageRegister.launch({username:"zhuzichu"})
|
||||
}
|
||||
}
|
||||
|
||||
FluText{
|
||||
text:"登录窗口返回过来的密码->"+password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ FluWindow {
|
|||
showError("请随便输入一个密码")
|
||||
return
|
||||
}
|
||||
onResult({password:textbox_password.text})
|
||||
window.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,13 +33,17 @@ void FluApp::run(){
|
|||
navigate(initialRoute());
|
||||
}
|
||||
|
||||
void FluApp::navigate(const QString& route,const QJsonObject& argument){
|
||||
void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegister* fluRegister){
|
||||
if(!routes().contains(route)){
|
||||
qErrnoWarning("没有找到当前路由");
|
||||
return;
|
||||
}
|
||||
bool isAppWindow = route == initialRoute();
|
||||
FramelessView *view = new FramelessView();
|
||||
if(fluRegister){
|
||||
fluRegister->to(view);
|
||||
view->setProperty("pageRegister",QVariant::fromValue(fluRegister));
|
||||
}
|
||||
view->setProperty("argument",argument);
|
||||
QMapIterator<QString, QVariant> iterator(properties);
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -59,7 +63,6 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument){
|
|||
view->setSource((routes().value(route).toString()));
|
||||
if(isAppWindow){
|
||||
QObject::connect(view->engine(), &QQmlEngine::quit, qApp, &QCoreApplication::quit);
|
||||
// QObject::connect(qApp, &QGuiApplication::aboutToQuit, qApp, [&view](){view->setSource({});});
|
||||
}else{
|
||||
view->closeDeleteLater();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QQmlContext>
|
||||
#include <QJsonObject>
|
||||
#include <QQmlEngine>
|
||||
#include "FluRegister.h"
|
||||
#include "FramelessView.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
|
@ -24,7 +25,7 @@ public:
|
|||
|
||||
Q_INVOKABLE void run();
|
||||
|
||||
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {});
|
||||
Q_INVOKABLE void navigate(const QString& route,const QJsonObject& argument = {},FluRegister* fluRegister = nullptr);
|
||||
|
||||
Q_INVOKABLE void init(QWindow *window,QMap<QString, QVariant> properties);
|
||||
|
||||
|
@ -37,9 +38,8 @@ public:
|
|||
Q_INVOKABLE void clipText(const QString& text);
|
||||
|
||||
private:
|
||||
|
||||
static FluApp* m_instance;
|
||||
QMap<QString, QVariant> properties;
|
||||
static FluApp* m_instance;
|
||||
QWindow *appWindow;
|
||||
|
||||
};
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#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);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef FLUREGISTER_H
|
||||
#define FLUREGISTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <FramelessView.h>
|
||||
#include <QJsonObject>
|
||||
#include "stdafx.h"
|
||||
|
||||
class FluRegister : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY_AUTO(FramelessView*,from)
|
||||
Q_PROPERTY_AUTO(FramelessView*,to)
|
||||
Q_PROPERTY_AUTO(QString,path);
|
||||
public:
|
||||
explicit FluRegister(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
|
|
@ -15,6 +15,7 @@ HEADERS += \
|
|||
FluApp.h \
|
||||
FluColorSet.h \
|
||||
FluColors.h \
|
||||
FluRegister.h \
|
||||
FluTheme.h \
|
||||
Fluent.h \
|
||||
FluentUI.h \
|
||||
|
@ -28,6 +29,7 @@ SOURCES += \
|
|||
FluApp.cpp \
|
||||
FluColorSet.cpp \
|
||||
FluColors.cpp \
|
||||
FluRegister.cpp \
|
||||
FluTheme.cpp \
|
||||
Fluent.cpp \
|
||||
FluentUI.cpp \
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "WindowHelper.h"
|
||||
|
||||
#include "FluRegister.h"
|
||||
|
||||
WindowHelper::WindowHelper(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
|
@ -10,11 +12,18 @@ void WindowHelper::setTitle(const QString& text){
|
|||
window->setTitle(text);
|
||||
}
|
||||
|
||||
QJsonObject WindowHelper::initWindow(FramelessView* window){
|
||||
void WindowHelper::initWindow(FramelessView* window){
|
||||
this->window = window;
|
||||
}
|
||||
|
||||
QJsonObject WindowHelper::getArgument(){
|
||||
return window->property("argument").toJsonObject();
|
||||
}
|
||||
|
||||
QVariant WindowHelper::getPageRegister(){
|
||||
return window->property("pageRegister");
|
||||
}
|
||||
|
||||
void WindowHelper::setMinimumWidth(int width){
|
||||
this->window->setMinimumWidth(width);
|
||||
}
|
||||
|
@ -31,7 +40,6 @@ void WindowHelper::updateWindow(){
|
|||
this->window->setFlag(Qt::Window,false);
|
||||
this->window->setFlag(Qt::Window,true);
|
||||
}
|
||||
|
||||
void WindowHelper::setModality(int type){
|
||||
if(type == 0){
|
||||
this->window->setModality(Qt::NonModal);
|
||||
|
@ -43,3 +51,10 @@ void WindowHelper::setModality(int type){
|
|||
this->window->setModality(Qt::NonModal);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant WindowHelper::createRegister(const QString& path){
|
||||
FluRegister *p = new FluRegister(this->window);
|
||||
p->from(this->window);
|
||||
p->path(path);
|
||||
return QVariant::fromValue(p);
|
||||
}
|
||||
|
|
|
@ -15,14 +15,17 @@ class WindowHelper : public QObject
|
|||
public:
|
||||
explicit WindowHelper(QObject *parent = nullptr);
|
||||
|
||||
Q_INVOKABLE QJsonObject initWindow(FramelessView* window);
|
||||
Q_INVOKABLE void initWindow(FramelessView* window);
|
||||
Q_INVOKABLE void setTitle(const QString& text);
|
||||
Q_INVOKABLE void setMinimumWidth(int width);
|
||||
Q_INVOKABLE void setMaximumWidth(int width);
|
||||
Q_INVOKABLE void setMinimumHeight(int height);
|
||||
Q_INVOKABLE void setMaximumHeight(int height);
|
||||
Q_INVOKABLE QJsonObject getArgument();
|
||||
Q_INVOKABLE QVariant getPageRegister();
|
||||
Q_INVOKABLE void updateWindow();
|
||||
Q_INVOKABLE void setModality(int type);
|
||||
Q_INVOKABLE QVariant createRegister(const QString& path);
|
||||
|
||||
private:
|
||||
FramelessView* window;
|
||||
|
|
|
@ -30,6 +30,8 @@ Item {
|
|||
|
||||
signal initArgument(var argument)
|
||||
|
||||
property var pageRegister
|
||||
|
||||
property int borderless:{
|
||||
if(!FluTheme.isFrameless){
|
||||
return 0
|
||||
|
@ -79,7 +81,9 @@ Item {
|
|||
target: FluApp
|
||||
function onWindowReady(view){
|
||||
if(FluApp.equalsWindow(view,window)){
|
||||
initArgument(helper.initWindow(view))
|
||||
helper.initWindow(view)
|
||||
initArgument(helper.getArgument())
|
||||
pageRegister = helper.getPageRegister()
|
||||
helper.setTitle(title)
|
||||
if(minimumWidth){
|
||||
helper.setMinimumWidth(minimumWidth)
|
||||
|
@ -111,21 +115,31 @@ Item {
|
|||
function showSuccess(text,duration,moremsg){
|
||||
infoBar.showSuccess(text,duration,moremsg);
|
||||
}
|
||||
|
||||
function showInfo(text,duration,moremsg){
|
||||
infoBar.showInfo(text,duration,moremsg);
|
||||
}
|
||||
|
||||
function showWarning(text,duration,moremsg){
|
||||
infoBar.showWarning(text,duration,moremsg);
|
||||
}
|
||||
|
||||
function showError(text,duration,moremsg){
|
||||
infoBar.showError(text,duration,moremsg);
|
||||
}
|
||||
|
||||
function close(){
|
||||
window.close()
|
||||
}
|
||||
|
||||
function onResult(data){
|
||||
function registerForPageResult(path){
|
||||
return helper.createRegister(path)
|
||||
}
|
||||
|
||||
function onResult(data){
|
||||
if(pageRegister){
|
||||
pageRegister.onResult(data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue