diff --git a/panels/dock/tray/package/TrayContainer.qml b/panels/dock/tray/package/TrayContainer.qml index 9ad6bb49c..ef6379dde 100644 --- a/panels/dock/tray/package/TrayContainer.qml +++ b/panels/dock/tray/package/TrayContainer.qml @@ -157,13 +157,13 @@ Item { surfaceId = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId") source = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-source") console.log(surfaceId, source) - // Make action icons (collapse/show stash) visible while dragging over tray - DDT.TraySortOrderModel.actionsAlwaysVisible = true if (source !== "" && DDT.TraySortOrderModel.isDisplayedSurface(surfaceId)) { dragEvent.accepted = false - } else { - dragEvent.accepted = true + return } + + DDT.TraySortOrderModel.setTrayDragActive(true, surfaceId) + dragEvent.accepted = true } onPositionChanged: function (dragEvent) { @@ -241,7 +241,7 @@ Item { onStashDropSucceeded() } } - DDT.TraySortOrderModel.actionsAlwaysVisible = false + DDT.TraySortOrderModel.setTrayDragActive(false) dropHoverIndex = -1 } @@ -251,7 +251,7 @@ Item { DDT.TraySortOrderModel.clearStagedDrop() // Hide action icons when drag leaves tray without dropping if (!isDropped) { - DDT.TraySortOrderModel.actionsAlwaysVisible = false + DDT.TraySortOrderModel.setTrayDragActive(false) } } diff --git a/panels/dock/tray/traysortordermodel.cpp b/panels/dock/tray/traysortordermodel.cpp index 371e6853b..cdef42538 100644 --- a/panels/dock/tray/traysortordermodel.cpp +++ b/panels/dock/tray/traysortordermodel.cpp @@ -71,6 +71,24 @@ TraySortOrderModel::~TraySortOrderModel() // dtor } +void TraySortOrderModel::setTrayDragActive(bool active, const QString &surfaceId) +{ + const bool suppressStashAction = active && !surfaceId.startsWith("application-tray::"); + const bool activeChanged = m_actionsAlwaysVisible != active; + const bool suppressionChanged = m_suppressStashActionDuringDrag != suppressStashAction; + if (!activeChanged && !suppressionChanged) { + return; + } + + m_actionsAlwaysVisible = active; + m_suppressStashActionDuringDrag = suppressStashAction; + if (activeChanged) { + emit actionsAlwaysVisibleChanged(active); + } else { + updateVisualIndexes(); + } +} + bool TraySortOrderModel::dropToStashTray(const QString &draggedSurfaceId, int dropVisualIndex, bool isBefore) { Q_UNUSED(dropVisualIndex) @@ -393,7 +411,7 @@ void TraySortOrderModel::updateVisualIndexes() // the visual index of stashed items are also for their sort order, but the index // number is independently from these non-stashed items. int stashedVisualIndex = 0; - bool showStashActionVisible = m_actionsAlwaysVisible; + bool showStashActionVisible = m_actionsAlwaysVisible && !m_suppressStashActionDuringDrag; for (const QString & id : std::as_const(m_stashedIds)) { QList results = findItems(id); if (results.isEmpty()) continue; diff --git a/panels/dock/tray/traysortordermodel.h b/panels/dock/tray/traysortordermodel.h index 4f3165f79..b9f19f8ad 100644 --- a/panels/dock/tray/traysortordermodel.h +++ b/panels/dock/tray/traysortordermodel.h @@ -62,6 +62,7 @@ class TraySortOrderModel : public QStandardItemModel explicit TraySortOrderModel(QObject *parent = nullptr); ~TraySortOrderModel(); + Q_INVOKABLE void setTrayDragActive(bool active, const QString &surfaceId = QString()); Q_INVOKABLE bool dropToStashTray(const QString & draggedSurfaceId, int dropVisualIndex, bool isBefore); Q_INVOKABLE bool dropToDockTray(const QString & draggedSurfaceId, int dropVisualIndex, bool isBefore); Q_INVOKABLE void setSurfaceVisible(const QString & surfaceId, bool visible); @@ -89,6 +90,7 @@ class TraySortOrderModel : public QStandardItemModel bool m_collapsed = false; bool m_isCollapsing = false; bool m_actionsAlwaysVisible = false; + bool m_suppressStashActionDuringDrag = false; bool m_isUpdating = false; std::unique_ptr m_dconfig; // this is for the plugins that currently available.