FluWindowd新增launchMode枚举值,支持Standard、SingleTask、SingleInstance
parent
f43bfec992
commit
ab0fcf5d9c
|
@ -3,6 +3,7 @@ CONFIG += c++17
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
|
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
stdafx.h \
|
||||||
ChatController.h \
|
ChatController.h \
|
||||||
AppInfo.h
|
AppInfo.h
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ FluWindow {
|
||||||
minimumHeight: 600
|
minimumHeight: 600
|
||||||
maximumWidth: 500
|
maximumWidth: 500
|
||||||
maximumHeight: 600
|
maximumHeight: 600
|
||||||
|
launchMode: FluWindow.SingleTask
|
||||||
|
|
||||||
title:"关于"
|
title:"关于"
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,33 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
|
||||||
QQmlEngine *engine = qmlEngine(appWindow);
|
QQmlEngine *engine = qmlEngine(appWindow);
|
||||||
QQmlComponent component(engine, routes().value(route).toString());
|
QQmlComponent component(engine, routes().value(route).toString());
|
||||||
QVariantMap properties;
|
QVariantMap properties;
|
||||||
|
properties.insert("route",route);
|
||||||
if(fluRegister){
|
if(fluRegister){
|
||||||
properties.insert("pageRegister",QVariant::fromValue(fluRegister));
|
properties.insert("pageRegister",QVariant::fromValue(fluRegister));
|
||||||
}
|
}
|
||||||
properties.insert("argument",argument);
|
properties.insert("argument",argument);
|
||||||
QQuickWindow *view = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties));
|
QQuickWindow *view = qobject_cast<QQuickWindow*>(component.createWithInitialProperties(properties));
|
||||||
|
|
||||||
|
int launchMode = view->property("launchMode").toInt();
|
||||||
|
if(launchMode==1){
|
||||||
|
for (auto& pair : wnds) {
|
||||||
|
QString r = pair->property("route").toString();
|
||||||
|
if(r == route){
|
||||||
|
pair->requestActivate();
|
||||||
|
delete view;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if(launchMode==2){
|
||||||
|
for (auto& pair : wnds) {
|
||||||
|
QString r = pair->property("route").toString();
|
||||||
|
if(r == route){
|
||||||
|
pair->close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(FluTheme::getInstance()->frameless()){
|
if(FluTheme::getInstance()->frameless()){
|
||||||
view->setFlag(Qt::FramelessWindowHint,true);
|
view->setFlag(Qt::FramelessWindowHint,true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,21 @@ import FluentUI
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
|
|
||||||
id:window
|
|
||||||
|
enum LaunchMode {
|
||||||
|
Standard,
|
||||||
|
SingleTask,
|
||||||
|
SingleInstance
|
||||||
|
}
|
||||||
|
|
||||||
default property alias content: container.data
|
default property alias content: container.data
|
||||||
|
property int launchMode: FluWindow.Standard
|
||||||
|
property string route
|
||||||
property var argument:({})
|
property var argument:({})
|
||||||
property var pageRegister
|
property var pageRegister
|
||||||
signal initArgument(var argument)
|
signal initArgument(var argument)
|
||||||
|
|
||||||
|
id:window
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
color: {
|
color: {
|
||||||
if(active){
|
if(active){
|
||||||
|
|
Loading…
Reference in New Issue