66#include " constants.h"
77
88#include < QDebug>
9+ #include < QDBusMessage>
10+ #include < QDBusConnection>
11+
912#include < DConfig>
1013
1114namespace 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+ QString pluginId = surfaceId.split (" ::" ).last ();
528+ if (pluginId.isEmpty ()) {
529+ qWarning () << " surfaceId format has error:" << 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+ << pluginId
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+ }
519552}
553+
554+ }
0 commit comments