diff --git a/frame/taskmanager/dbushandler.cpp b/frame/taskmanager/dbushandler.cpp index dddc3dab7..ea3a8adc7 100644 --- a/frame/taskmanager/dbushandler.cpp +++ b/frame/taskmanager/dbushandler.cpp @@ -22,6 +22,13 @@ DBusHandler::DBusHandler(TaskManager *taskmanager, QObject *parent) , m_xEventMonitor(nullptr) , m_launcher(new org::deepin::dde::Launcher1(launcherService, launcherPath, QDBusConnection::sessionBus(), this)) { + QDBusInterface *interAM = new QDBusInterface(ApplicationManager1DBusName, "/org/desktopspec/ApplicationManager1", "org.desktopspec.DBus.ObjectManager"); + if (interAM->isValid()) { + connect(interAM, SIGNAL(InterfacesRemoved(const QDBusObjectPath &, const QStringList &)), this, SIGNAL(appUninstalled(const QDBusObjectPath &, const QStringList &))); + } else { + qWarning() << "The interface of AM is invalid:" << interAM->lastError(); + } + connect(m_wmSwitcher, &org::deepin::dde::WMSwitcher1::WMChanged, this, [&](QString name) {m_taskmanager->setWMName(name);}); if (!isWaylandSession()) { m_xEventMonitor = new org::deepin::dde::XEventMonitor1("org.deepin.dde.XEventMonitor1", "/org/deepin/dde/XEventMonitor1", QDBusConnection::sessionBus(), this); diff --git a/frame/taskmanager/dbushandler.h b/frame/taskmanager/dbushandler.h index e6e38db54..c3ce4876a 100644 --- a/frame/taskmanager/dbushandler.h +++ b/frame/taskmanager/dbushandler.h @@ -66,6 +66,9 @@ class DBusHandler : public QObject bool newStartManagerAvaliable(); void sendFailedDockNotification(const QString &appName); +Q_SIGNALS: + void appUninstalled(const QDBusObjectPath &objectPath, const QStringList &interfaces); + private Q_SLOTS: void handleWlActiveWindowChange(); void onActiveWindowButtonRelease(int type, int x, int y, const QString &key); diff --git a/frame/taskmanager/taskmanager.cpp b/frame/taskmanager/taskmanager.cpp index d66b8fa61..ae4c9b03e 100644 --- a/frame/taskmanager/taskmanager.cpp +++ b/frame/taskmanager/taskmanager.cpp @@ -17,7 +17,6 @@ #include "waylandmanager.h" #include "windowinfobase.h" #include "dbusutil.h" - #include "org_deepin_dde_kwayland_plasmawindow.h" #include @@ -27,10 +26,15 @@ #include #include +#include #include #include #include +#include + +DCORE_USE_NAMESPACE + #define SETTING DockSettings::instance() #define XCB XCBUtils::instance() bool shouldShowEntry(Entry *entry) @@ -91,6 +95,21 @@ TaskManager::TaskManager(QObject *parent) connect(m_x11Manager, &X11Manager::requestHandleActiveWindowChange, this, &TaskManager::handleActiveWindowChanged); connect(m_x11Manager, &X11Manager::requestAttachOrDetachWindow, this, &TaskManager::attachOrDetachWindow); } + connect(m_dbusHandler, &DBusHandler::appUninstalled, this, [this] (const QDBusObjectPath &objectPath, const QStringList &interfaces) { + Q_UNUSED(interfaces) + QString desktopFile = DUtil::unescapeFromObjectPath(objectPath.path()); + QString desktopName = desktopFile.split('/').last(); + Entry *desktopEntry = nullptr; + QList entries = m_entries->getEntries(); + auto desktopEntryIter = std::find_if(entries.begin(), entries.end(), [desktopName] (Entry *entry) { + return entry->getDesktopFile().contains(desktopName); + }); + if (desktopEntryIter != entries.end()) { + undockEntry(*desktopEntryIter); + } else { + qWarning() << "The entry which is to be removed is not found!"; + } + }); } TaskManager::~TaskManager()