Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions panels/dock/tray/traysortordermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "traysortordermodel.h"
#include "constants.h"

Check warning on line 6 in panels/dock/tray/traysortordermodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "constants.h" not found.

#include <QDebug>

Check warning on line 8 in panels/dock/tray/traysortordermodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusMessage>

Check warning on line 9 in panels/dock/tray/traysortordermodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnection>

Check warning on line 10 in panels/dock/tray/traysortordermodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <DConfig>

Check warning on line 12 in panels/dock/tray/traysortordermodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace docktray {

Expand Down Expand Up @@ -116,6 +119,7 @@
auto deferUpdateVisualIndex = qScopeGuard([this](){updateVisualIndexes();});
if (m_hiddenIds.contains(draggedSurfaceId)) {
m_hiddenIds.removeOne(draggedSurfaceId);
handlePluginVisibleChanged(draggedSurfaceId, true);
}

if (dropOnSurfaceId == QLatin1String("internal/action-show-stash")) {
Expand Down Expand Up @@ -205,6 +209,7 @@
m_hiddenIds.append(surfaceId);
}
}
handlePluginVisibleChanged(surfaceId, visible);
updateVisualIndexes();
}

Expand Down Expand Up @@ -277,6 +282,7 @@
) {
if (!m_hiddenIds.contains(surfaceId)) {
m_hiddenIds.append(surfaceId);
handlePluginVisibleChanged(surfaceId, false);
}
}

Expand Down Expand Up @@ -516,4 +522,33 @@
saveDataToDConfig();
}

void TraySortOrderModel::handlePluginVisibleChanged(const QString &surfaceId, bool visible)
{
QStringList parts = surfaceId.split("::");
if (parts.size() != 2 || parts.at(1).isEmpty()) {
qWarning() << "Invalid surfaceId format:" << surfaceId;
return;
}

QDBusMessage msg = QDBusMessage::createMethodCall(
"org.deepin.dde.Dock1",
"/org/deepin/dde/Dock1",
"org.deepin.dde.Dock1",
"setItemOnDock"
);

const QString DockQuickPlugins = "Dock_Quick_Plugins";
msg << DockQuickPlugins
<< parts.last()
<< visible;

QDBusMessage reply = QDBusConnection::sessionBus().call(msg);

if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << "DBus call failed:" << reply.errorMessage();
} else {
qDebug() << "setItemOnDock call success";
}
}

}
1 change: 1 addition & 0 deletions panels/dock/tray/traysortordermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@
QString registerSurfaceId(const QVariantMap &surfaceData);
void loadDataFromDConfig();
void saveDataToDConfig();
void handlePluginVisibleChanged(const QString &surfaceId, bool visible);

private slots:

Check warning on line 107 in panels/dock/tray/traysortordermodel.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If slots is a macro then please configure it.
void onAvailableSurfacesChanged();
};

Expand Down