Skip to content

Commit

Permalink
fix: the item that removed is exist yet
Browse files Browse the repository at this point in the history
undock items that removed

Issus: linuxdeepin/developer-center#4631
  • Loading branch information
wangfei committed Jan 16, 2024
1 parent b74544a commit 30acc57
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions frame/taskmanager/dbushandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);});

Check warning on line 32 in frame/taskmanager/dbushandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'name' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
if (!isWaylandSession()) {
m_xEventMonitor = new org::deepin::dde::XEventMonitor1("org.deepin.dde.XEventMonitor1", "/org/deepin/dde/XEventMonitor1", QDBusConnection::sessionBus(), this);
Expand Down
3 changes: 3 additions & 0 deletions frame/taskmanager/dbushandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 19 additions & 1 deletion frame/taskmanager/taskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "waylandmanager.h"
#include "windowinfobase.h"
#include "dbusutil.h"

#include "org_deepin_dde_kwayland_plasmawindow.h"

#include <QDir>
Expand All @@ -27,10 +26,15 @@
#include <QPixmap>

#include <cstdint>
#include <dtkcore_global.h>
#include <iterator>
#include <memory>
#include <algorithm>

#include <dutil.h>

DCORE_USE_NAMESPACE

#define SETTING DockSettings::instance()
#define XCB XCBUtils::instance()
bool shouldShowEntry(Entry *entry)
Expand Down Expand Up @@ -91,6 +95,20 @@ 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();
QList<Entry *> 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()
Expand Down

0 comments on commit 30acc57

Please sign in to comment.