From f7812cfb66bed1fbb3f8c818e1ce98678b028042 Mon Sep 17 00:00:00 2001 From: donghualin Date: Thu, 12 Jan 2023 10:58:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E8=93=9D=E7=89=99=E5=90=8E=E5=BC=B9=E6=A1=86=E4=BE=9D=E7=84=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除设备后弹窗不再显示 Log: Influence: 点击任务栏的蓝牙图标,弹出蓝牙弹窗,然后移除蓝牙,观察蓝牙的弹窗是否存在 Bug: https://pms.uniontech.com/bug-view-181945.html Change-Id: Idcef18077d9f822b2ea3aca93442a2d098ea146b --- frame/util/dockpopupwindow.cpp | 6 ++++++ frame/util/dockpopupwindow.h | 1 + frame/window/quickpluginwindow.cpp | 6 ++++++ plugins/bluetooth/bluetoothplugin.cpp | 2 ++ 4 files changed, 15 insertions(+) diff --git a/frame/util/dockpopupwindow.cpp b/frame/util/dockpopupwindow.cpp index a38809688..ca8aa1c0a 100644 --- a/frame/util/dockpopupwindow.cpp +++ b/frame/util/dockpopupwindow.cpp @@ -89,6 +89,12 @@ void DockPopupWindow::setContent(QWidget *content) void DockPopupWindow::setExtendWidget(QWidget *widget) { m_extendWidget = widget; + connect(widget, &QWidget::destroyed, this, [ this ] { m_extendWidget = nullptr; }, Qt::UniqueConnection); +} + +QWidget *DockPopupWindow::extengWidget() const +{ + return m_extendWidget; } void DockPopupWindow::show(const QPoint &pos, const bool model) diff --git a/frame/util/dockpopupwindow.h b/frame/util/dockpopupwindow.h index e08dcb131..5d5e7b8ee 100644 --- a/frame/util/dockpopupwindow.h +++ b/frame/util/dockpopupwindow.h @@ -45,6 +45,7 @@ public: void setContent(QWidget *content); void setExtendWidget(QWidget *widget); + QWidget *extengWidget() const; public slots: void show(const QPoint &pos, const bool model = false); diff --git a/frame/window/quickpluginwindow.cpp b/frame/window/quickpluginwindow.cpp index 3579db679..c622430be 100644 --- a/frame/window/quickpluginwindow.cpp +++ b/frame/window/quickpluginwindow.cpp @@ -359,6 +359,12 @@ void QuickPluginWindow::onRequestUpdate() // 如果该插件在任务栏上,则先将其添加到临时列表中 pluginItems[dockItem->pluginItem()] = dockItem; } else { + DockPopupWindow *popupWindow = getPopWindow(); + if (popupWindow->isVisible()) { + // 该插件被移除的情况下,判断弹出窗口是否在当前的插件中打开的,如果是,则隐藏该窗口 + if (popupWindow->extengWidget() == dockItem) + popupWindow->hide(); + } // 如果该插件不在任务栏上,则先删除 dockItem->deleteLater(); countChanged = true; diff --git a/plugins/bluetooth/bluetoothplugin.cpp b/plugins/bluetooth/bluetoothplugin.cpp index ade736ce5..b7368d618 100644 --- a/plugins/bluetooth/bluetoothplugin.cpp +++ b/plugins/bluetooth/bluetoothplugin.cpp @@ -64,6 +64,8 @@ void BluetoothPlugin::init(PluginProxyInterface *proxyInter) m_proxyInter->itemAdded(this, BLUETOOTH_KEY); }); connect(m_bluetoothItem.data(), &BluetoothItem::noAdapter, [&] { + m_proxyInter->requestSetAppletVisible(this, QUICK_ITEM_KEY, false); + m_proxyInter->requestSetAppletVisible(this, BLUETOOTH_KEY, false); m_proxyInter->itemRemoved(this, BLUETOOTH_KEY); }); connect(m_bluetoothWidget.data(), &BluetoothMainWidget::requestExpand, this, [ = ] {