From 6d3666cd9db4c76be3a3328facf8e184c5d65496 Mon Sep 17 00:00:00 2001 From: chenyuanbo Date: Thu, 3 Dec 2026 14:35:11 +0800 Subject: [PATCH] fix: keep empty app tray hidden during plugin drags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Validate the drag source before activating tray drag state. 2. Suppress forced stash visibility for non-application tray items. 3. Clear drag state when the drop completes or leaves the tray. Log: Keep the empty app tray hidden when dragging quick panel plugins Influence: 1. Drag a quick panel plugin over the empty app tray position. 2. Drop a plugin at a valid dock position and verify it is placed. 3. Drag an application tray icon and verify the stash can open. fix: 修复插件拖拽时空应用托盘意外显示 1. 校验拖拽来源后再更新托盘拖拽状态。 2. 拖动普通插件时抑制空应用托盘及其占位。 3. 放下图标或离开托盘时清理拖拽状态。 Influence: 1. 从快捷面板拖动插件到空应用托盘原位置,确认箭头和占位保持隐藏。 2. 将插件拖到任务栏的合法位置,确认可以正常放置。 3. 拖动应用托盘图标,确认仍可唤出应用托盘。 Log: 修复快捷面板插件拖拽时空应用托盘意外显示的问题 PMS: BUG-384429 --- panels/dock/tray/package/TrayContainer.qml | 12 ++++++------ panels/dock/tray/traysortordermodel.cpp | 20 +++++++++++++++++++- panels/dock/tray/traysortordermodel.h | 2 ++ 3 files changed, 27 insertions(+), 7 deletions(-) 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.