|
6 | 6 | #include "constants.h" |
7 | 7 |
|
8 | 8 | #include <QDebug> |
| 9 | +#include <QDBusMessage> |
| 10 | +#include <QDBusConnection> |
| 11 | + |
9 | 12 | #include <DConfig> |
10 | 13 |
|
11 | 14 | namespace docktray { |
@@ -116,6 +119,7 @@ bool TraySortOrderModel::dropToDockTray(const QString &draggedSurfaceId, int dro |
116 | 119 | auto deferUpdateVisualIndex = qScopeGuard([this](){updateVisualIndexes();}); |
117 | 120 | if (m_hiddenIds.contains(draggedSurfaceId)) { |
118 | 121 | m_hiddenIds.removeOne(draggedSurfaceId); |
| 122 | + handlePluginVisibleChanged(draggedSurfaceId, true); |
119 | 123 | } |
120 | 124 |
|
121 | 125 | if (dropOnSurfaceId == QLatin1String("internal/action-show-stash")) { |
@@ -205,6 +209,7 @@ void TraySortOrderModel::setSurfaceVisible(const QString &surfaceId, bool visibl |
205 | 209 | m_hiddenIds.append(surfaceId); |
206 | 210 | } |
207 | 211 | } |
| 212 | + handlePluginVisibleChanged(surfaceId, visible); |
208 | 213 | updateVisualIndexes(); |
209 | 214 | } |
210 | 215 |
|
@@ -277,6 +282,7 @@ QString TraySortOrderModel::findSection(const QString &surfaceId, const QString |
277 | 282 | ) { |
278 | 283 | if (!m_hiddenIds.contains(surfaceId)) { |
279 | 284 | m_hiddenIds.append(surfaceId); |
| 285 | + handlePluginVisibleChanged(surfaceId, false); |
280 | 286 | } |
281 | 287 | } |
282 | 288 |
|
@@ -516,4 +522,33 @@ void TraySortOrderModel::onAvailableSurfacesChanged() |
516 | 522 | saveDataToDConfig(); |
517 | 523 | } |
518 | 524 |
|
| 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 | + |
519 | 554 | } |
0 commit comments