From a7e8a5e4cf1f063c790d303bd668dc72e48ca9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Wed, 28 Jun 2023 02:28:34 +0800 Subject: [PATCH] update --- example/qml/page/T_TableView.qml | 4 ++++ example/src/main.cpp | 2 +- src/FluApp.cpp | 5 +++++ src/FluApp.h | 2 ++ src/FluTools.cpp | 4 ++++ src/FluTools.h | 1 + src/WindowHelper.cpp | 8 -------- src/WindowHelper.h | 5 ----- src/imports/FluentUI/Controls/FluNavigationView.qml | 5 ++--- src/imports/FluentUI/Controls/FluWindow.qml | 7 +------ 10 files changed, 20 insertions(+), 23 deletions(-) diff --git a/example/qml/page/T_TableView.qml b/example/qml/page/T_TableView.qml index 7ea60418..344208b8 100644 --- a/example/qml/page/T_TableView.qml +++ b/example/qml/page/T_TableView.qml @@ -13,6 +13,10 @@ FluContentPage{ loadData(1,1000) } + Component.onDestruction: { + console.debug("T_TableView已经销毁") + } + function loadData(page,count){ var numbers = [100, 300, 500, 1000]; function getRandomAge() { diff --git a/example/src/main.cpp b/example/src/main.cpp index 009a6090..4aaa93cd 100644 --- a/example/src/main.cpp +++ b/example/src/main.cpp @@ -25,8 +25,8 @@ int main(int argc, char *argv[]) FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial); FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); - FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); #ifdef Q_OS_MACOS + FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false); #endif AppInfo* appInfo = new AppInfo(); diff --git a/src/FluApp.cpp b/src/FluApp.cpp index ffdfb5c5..4dae223c 100644 --- a/src/FluApp.cpp +++ b/src/FluApp.cpp @@ -109,3 +109,8 @@ QJsonArray FluApp::awesomelist(const QString& keyword) void FluApp::closeApp(){ qApp->exit(0); } + +void FluApp::deleteWindow(QQuickWindow* window){ + wnds.remove(window->winId()); + window->deleteLater(); +} diff --git a/src/FluApp.h b/src/FluApp.h index ecdbcbfa..90b057a1 100644 --- a/src/FluApp.h +++ b/src/FluApp.h @@ -73,6 +73,8 @@ public: */ Q_INVOKABLE void closeApp(); + Q_INVOKABLE void deleteWindow(QQuickWindow* window); + public: /** * @brief wnds diff --git a/src/FluTools.cpp b/src/FluTools.cpp index 5f8aaced..d012b363 100644 --- a/src/FluTools.cpp +++ b/src/FluTools.cpp @@ -87,3 +87,7 @@ void FluTools::setOverrideCursor(Qt::CursorShape shape){ void FluTools::restoreOverrideCursor(){ qApp->restoreOverrideCursor(); } + +void FluTools::deleteItem(QObject *p){ + p->deleteLater(); +} diff --git a/src/FluTools.h b/src/FluTools.h index 43ff6b88..a045e043 100644 --- a/src/FluTools.h +++ b/src/FluTools.h @@ -58,6 +58,7 @@ public: Q_INVOKABLE void restoreOverrideCursor(); + Q_INVOKABLE void deleteItem(QObject *p); }; #endif // FLUTOOLS_H diff --git a/src/WindowHelper.cpp b/src/WindowHelper.cpp index 40730e39..baf84e72 100644 --- a/src/WindowHelper.cpp +++ b/src/WindowHelper.cpp @@ -1,7 +1,6 @@ #include "WindowHelper.h" #include "FluRegister.h" -#include "FluApp.h" WindowHelper::WindowHelper(QObject *parent) : QObject{parent} @@ -19,10 +18,3 @@ QVariant WindowHelper::createRegister(QQuickWindow* window,const QString& path){ p->path(path); return QVariant::fromValue(p); } - -void WindowHelper::deleteWindow(){ - if(this->window){ - FluApp::getInstance()->wnds.remove(this->window->winId()); - this->window->deleteLater(); - } -} diff --git a/src/WindowHelper.h b/src/WindowHelper.h index cf798de4..d2596498 100644 --- a/src/WindowHelper.h +++ b/src/WindowHelper.h @@ -24,11 +24,6 @@ public: */ Q_INVOKABLE void initWindow(QQuickWindow* window); - /** - * @brief deleteWindow 销毁窗口,释放资源,QML中的Window close并不会销毁窗口,只是把窗口隐藏了 - */ - Q_INVOKABLE void deleteWindow(); - /** * @brief createRegister 创建一个FluRegsiter对象,在FluWindow中registerForWindowResult方法调用 * @param window diff --git a/src/imports/FluentUI/Controls/FluNavigationView.qml b/src/imports/FluentUI/Controls/FluNavigationView.qml index d5c7a069..21557324 100644 --- a/src/imports/FluentUI/Controls/FluNavigationView.qml +++ b/src/imports/FluentUI/Controls/FluNavigationView.qml @@ -31,7 +31,6 @@ Item { id:control QtObject{ id:d - property var pageMap: ({}) property var stackItems: [] property int displayMode: FluNavigationView.Open property bool enableNavigationPanel: false @@ -519,7 +518,7 @@ Item { disabled: nav_swipe.depth <= 1 iconSize: 13 onClicked: { - nav_swipe.pop() + FluTools.deleteItem(nav_swipe.pop()) d.stackItems.pop() var item = d.stackItems[d.stackItems.length-1] if(item.idx<(nav_list.count - layout_footer.count)){ @@ -997,7 +996,7 @@ Item { case FluNavigationView.SingleTask: while(nav_swipe.currentItem !== page) { - nav_swipe.pop() + FluTools.deleteItem(nav_swipe.pop()) d.stackItems.pop() } return diff --git a/src/imports/FluentUI/Controls/FluWindow.qml b/src/imports/FluentUI/Controls/FluWindow.qml index 5a4edacc..67ee8c61 100644 --- a/src/imports/FluentUI/Controls/FluWindow.qml +++ b/src/imports/FluentUI/Controls/FluWindow.qml @@ -44,11 +44,6 @@ Window { id: bg anchors.fill: parent color: backgroundColor - Behavior on color{ - ColorAnimation { - duration: 300 - } - } } Item{ id:container @@ -78,7 +73,7 @@ Window { return helper.createRegister(window,path) } function deleteWindow(){ - helper.deleteWindow() + FluApp.deleteWindow(window) } function onResult(data){ if(pageRegister){