FluWindowd新增launchMode枚举值,支持Standard、SingleTask、SingleInstance

main
zhuzihcu 2023-04-13 17:41:34 +08:00
parent f43bfec992
commit ab0fcf5d9c
4 changed files with 37 additions and 3 deletions

View File

@ -3,6 +3,7 @@ CONFIG += c++17
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_WARNING_OUTPUT
HEADERS += \
stdafx.h \
ChatController.h \
AppInfo.h

View File

@ -13,6 +13,7 @@ FluWindow {
minimumHeight: 600
maximumWidth: 500
maximumHeight: 600
launchMode: FluWindow.SingleTask
title:"关于"

View File

@ -58,11 +58,33 @@ void FluApp::navigate(const QString& route,const QJsonObject& argument,FluRegist
QQmlEngine *engine = qmlEngine(appWindow);
QQmlComponent component(engine, routes().value(route).toString());
QVariantMap properties;
properties.insert("route",route);
if(fluRegister){
properties.insert("pageRegister",QVariant::fromValue(fluRegister));
}
properties.insert("argument",argument);
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()){
view->setFlag(Qt::FramelessWindowHint,true);
}

View File

@ -6,11 +6,21 @@ import FluentUI
ApplicationWindow {
id:window
enum LaunchMode {
Standard,
SingleTask,
SingleInstance
}
default property alias content: container.data
property int launchMode: FluWindow.Standard
property string route
property var argument:({})
property var pageRegister
signal initArgument(var argument)
id:window
background: Rectangle{
color: {
if(active){