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