From 16a8cf7d3e2c8c5cfbd9897616d959e700e7e183 Mon Sep 17 00:00:00 2001 From: donghualin Date: Fri, 18 Nov 2022 09:22:39 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=90=8E=E5=BF=AB=E6=8D=B7=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、在插件移除后,除了从面板上将该插件的Widget移除外,删除该插件创建出来的QWidget 2、在插件对应的QWidget尺寸发生变化后,重新设置面板尺寸 3、在释放任务栏图标后,恢复ToolTip的parent Log: 修复移除插件后快捷面板显示异常的问题 Influence: 不断插入或者移除蓝牙设备,观察快捷面板是否显示正常 Bug: https://pms.uniontech.com/bug-view-171579.html Change-Id: I8168b49ad9eb047155efbd609be65f3dd263b6bc --- frame/item/components/fullquickitem.cpp | 14 +++++++++---- frame/item/components/fullquickitem.h | 1 + frame/window/quickpluginwindow.cpp | 10 +++++++++ frame/window/quickpluginwindow.h | 1 + frame/window/quicksettingcontainer.cpp | 27 ++++++++++++++----------- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/frame/item/components/fullquickitem.cpp b/frame/item/components/fullquickitem.cpp index cf9f0c92b..b83fddc29 100644 --- a/frame/item/components/fullquickitem.cpp +++ b/frame/item/components/fullquickitem.cpp @@ -27,6 +27,7 @@ FullQuickItem::FullQuickItem(PluginsItemInterface *const pluginInter, QWidget *p , m_effectWidget(new DBlurEffectWidget(this)) { initUi(); + QMetaObject::invokeMethod(this, &FullQuickItem::resizeSelf, Qt::QueuedConnection); } FullQuickItem::~FullQuickItem() @@ -42,10 +43,9 @@ QuickSettingItem::QuickSettingType FullQuickItem::type() const bool FullQuickItem::eventFilter(QObject *obj, QEvent *event) { - if (obj == m_centerWidget && event->type() == QEvent::Resize) { - m_effectWidget->setFixedHeight(m_centerWidget->height()); - setFixedHeight(m_centerWidget->height()); - } + if (obj == m_centerWidget && event->type() == QEvent::Resize) + resizeSelf(); + return QuickSettingItem::eventFilter(obj, event); } @@ -74,3 +74,9 @@ void FullQuickItem::initUi() m_centerWidget->installEventFilter(this); } + +void FullQuickItem::resizeSelf() +{ + m_effectWidget->setFixedHeight(m_centerWidget->height()); + setFixedHeight(m_centerWidget->height()); +} diff --git a/frame/item/components/fullquickitem.h b/frame/item/components/fullquickitem.h index 6c67bd659..f734d313a 100644 --- a/frame/item/components/fullquickitem.h +++ b/frame/item/components/fullquickitem.h @@ -38,6 +38,7 @@ protected: private: void initUi(); + void resizeSelf(); private: QWidget *m_centerWidget; diff --git a/frame/window/quickpluginwindow.cpp b/frame/window/quickpluginwindow.cpp index 1f671c53e..acd2ea090 100644 --- a/frame/window/quickpluginwindow.cpp +++ b/frame/window/quickpluginwindow.cpp @@ -512,6 +512,7 @@ QuickDockItem::QuickDockItem(PluginsItemInterface *pluginItem, const QJsonObject , m_position(Dock::Position::Bottom) , m_popupWindow(new DockPopupWindow) , m_contextMenu(new QMenu(this)) + , m_tipParent(nullptr) { m_popupWindow->setShadowBlurRadius(20); m_popupWindow->setRadius(6); @@ -531,6 +532,10 @@ QuickDockItem::QuickDockItem(PluginsItemInterface *pluginItem, const QJsonObject QuickDockItem::~QuickDockItem() { + QWidget *tipWidget = m_pluginItem->itemTipsWidget(m_itemKey); + if (tipWidget && tipWidget->parentWidget() == m_popupWindow) + tipWidget->setParent(m_tipParent); + m_popupWindow->deleteLater(); } @@ -604,6 +609,11 @@ void QuickDockItem::enterEvent(QEvent *event) if (!tipWidget) return; + // 记录下toolTip的parent,因为在调用DockPopupWindow的时候会将DockPopupWindow设置为toolTip的parent, + // 在DockPopupWindow对象释放的时候, 会将toolTip也一起给释放 + if (tipWidget->parentWidget() != m_popupWindow) + m_tipParent = tipWidget->parentWidget(); + switch (m_position) { case Top: m_popupWindow->setArrowDirection(DockPopupWindow::ArrowTop); diff --git a/frame/window/quickpluginwindow.h b/frame/window/quickpluginwindow.h index b36eb08a8..a8c9ba7a4 100644 --- a/frame/window/quickpluginwindow.h +++ b/frame/window/quickpluginwindow.h @@ -122,6 +122,7 @@ private: Dock::Position m_position; DockPopupWindow *m_popupWindow; QMenu *m_contextMenu; + QWidget *m_tipParent; }; #endif // QUICKPLUGINWINDOW_H diff --git a/frame/window/quicksettingcontainer.cpp b/frame/window/quicksettingcontainer.cpp index 422bbc5d9..904871a0b 100644 --- a/frame/window/quicksettingcontainer.cpp +++ b/frame/window/quicksettingcontainer.cpp @@ -157,8 +157,7 @@ bool QuickSettingContainer::eventFilter(QObject *watched, QEvent *event) { switch (event->type()) { case QEvent::Resize: { - if (watched == m_childPage) - onResizeView(); + onResizeView(); break; } case QEvent::MouseButtonPress: { @@ -221,19 +220,23 @@ void QuickSettingContainer::appendPlugin(PluginsItemInterface *itemInter, bool n void QuickSettingContainer::onPluginRemove(PluginsItemInterface *itemInter) { - for (QuickSettingItem *item : m_quickSettings) { - if (item->pluginItem() != itemInter) - continue; + QList::Iterator removeItemIter = std::find_if(m_quickSettings.begin(), m_quickSettings.end(), [ = ](QuickSettingItem *item)->bool { + return item->pluginItem() == itemInter; + }); - if (item->type() == QuickSettingItem::QuickSettingType::Full) - m_componentWidget->layout()->removeWidget(item); - else - m_pluginLayout->removeWidget(item); + QuickSettingItem *removeItem = *removeItemIter; + if (!removeItem) + return; - m_quickSettings.removeOne(item); - break; - } + if (removeItem->type() == QuickSettingItem::QuickSettingType::Full) + m_componentWidget->layout()->removeWidget(removeItem); + else + m_pluginLayout->removeWidget(removeItem); + m_quickSettings.removeOne(removeItem); + removeItem->deleteLater(); + + updateItemLayout(); onResizeView(); }