Skip to content

Commit 446c89a

Browse files
yixinsharkdeepin-bot[bot]
authored andcommitted
fix: pluginVisibleChanged signal needs to be sent when dragging the plugin docked to tray
as title Log: as title Pms: BUG-299881
1 parent 4552f1b commit 446c89a

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

panels/dock/tray/traysortordermodel.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#include "constants.h"
77

88
#include <QDebug>
9+
#include <QDBusMessage>
10+
#include <QDBusConnection>
11+
912
#include <DConfig>
1013

1114
namespace docktray {
@@ -116,6 +119,7 @@ bool TraySortOrderModel::dropToDockTray(const QString &draggedSurfaceId, int dro
116119
auto deferUpdateVisualIndex = qScopeGuard([this](){updateVisualIndexes();});
117120
if (m_hiddenIds.contains(draggedSurfaceId)) {
118121
m_hiddenIds.removeOne(draggedSurfaceId);
122+
handlePluginVisibleChanged(draggedSurfaceId, true);
119123
}
120124

121125
if (dropOnSurfaceId == QLatin1String("internal/action-show-stash")) {
@@ -205,6 +209,7 @@ void TraySortOrderModel::setSurfaceVisible(const QString &surfaceId, bool visibl
205209
m_hiddenIds.append(surfaceId);
206210
}
207211
}
212+
handlePluginVisibleChanged(surfaceId, visible);
208213
updateVisualIndexes();
209214
}
210215

@@ -277,6 +282,7 @@ QString TraySortOrderModel::findSection(const QString &surfaceId, const QString
277282
) {
278283
if (!m_hiddenIds.contains(surfaceId)) {
279284
m_hiddenIds.append(surfaceId);
285+
handlePluginVisibleChanged(surfaceId, false);
280286
}
281287
}
282288

@@ -516,4 +522,33 @@ void TraySortOrderModel::onAvailableSurfacesChanged()
516522
saveDataToDConfig();
517523
}
518524

525+
void TraySortOrderModel::handlePluginVisibleChanged(const QString &surfaceId, bool visible)
526+
{
527+
QStringList parts = surfaceId.split("::");
528+
if (parts.size() != 2 || parts.at(1).isEmpty()) {
529+
qWarning() << "Invalid surfaceId format:" << surfaceId;
530+
return;
531+
}
532+
533+
QDBusMessage msg = QDBusMessage::createMethodCall(
534+
"org.deepin.dde.Dock1",
535+
"/org/deepin/dde/Dock1",
536+
"org.deepin.dde.Dock1",
537+
"setItemOnDock"
538+
);
539+
540+
const QString DockQuickPlugins = "Dock_Quick_Plugins";
541+
msg << DockQuickPlugins
542+
<< parts.last()
543+
<< visible;
544+
545+
QDBusMessage reply = QDBusConnection::sessionBus().call(msg);
546+
547+
if (reply.type() == QDBusMessage::ErrorMessage) {
548+
qWarning() << "DBus call failed:" << reply.errorMessage();
549+
} else {
550+
qDebug() << "setItemOnDock call success";
551+
}
552+
}
553+
519554
}

panels/dock/tray/traysortordermodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class TraySortOrderModel : public QStandardItemModel
102102
QString registerSurfaceId(const QVariantMap &surfaceData);
103103
void loadDataFromDConfig();
104104
void saveDataToDConfig();
105+
void handlePluginVisibleChanged(const QString &surfaceId, bool visible);
105106

106107
private slots:
107108
void onAvailableSurfacesChanged();

0 commit comments

Comments
 (0)