Skip to content

Commit f153a59

Browse files
robertkilldeepin-bot[bot]
authored andcommitted
fix: The tray application flashes an icon when opened
Improve tray item visibility handling during updates - Add `isUpdating` flag to TraySortOrderModel to track visual index updates - Hide tray items during model updates to prevent visual glitches - Only show drop hover indicators during active drag operations - Add `itemVisible` checks to delegate visibility conditions This ensures smoother visual transitions when the tray model is being updated and prevents artifacts during drag operations. pms: BUG-289521
1 parent c2ef52a commit f153a59

6 files changed

Lines changed: 16 additions & 3 deletions

File tree

panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ AppletItemButton {
2929

3030
padding: 0
3131

32-
visible: !Drag.active
32+
visible: !Drag.active && itemVisible
3333
hoverEnabled: inputEventsEnabled
3434

3535
function updatePluginMargins()

panels/dock/tray/package/ActionShowStashDelegate.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.deepin.ds.dock.tray 1.0 as DDT
1212

1313
AppletItemButton {
1414
id: root
15-
property bool isDropHover: model.visualIndex === dropHoverIndex && dropHoverIndex !== -1
15+
property bool isDropHover: model.visualIndex === dropHoverIndex && dropHoverIndex !== -1 && Panel.contextDragging
1616

1717
icon.name: {
1818
switch (Panel.position) {

panels/dock/tray/package/StashedItemPositioner.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
import QtQuick
66
import QtQuick.Controls
7+
import org.deepin.ds.dock.tray 1.0 as DDT
78

89
Control {
910
id: root
10-
property bool itemVisible: true
11+
property bool itemVisible: !DDT.TraySortOrderModel.isUpdating
1112

1213
spacing: 0
1314
padding: 0

panels/dock/tray/package/TrayItemPositioner.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import org.deepin.ds.dock.tray 1.0 as DDT
99
Control {
1010
id: root
1111
property bool itemVisible: {
12+
if (DDT.TraySortOrderModel.isUpdating) {
13+
return false
14+
}
1215
if (model.sectionType === "collapsable") return !collapsed && model.visibility
1316
return model.sectionType !== "stashed" && model.visibility
1417
}

panels/dock/tray/traysortordermodel.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ QStandardItem *TraySortOrderModel::createTrayItem(const QString &name,
328328

329329
void TraySortOrderModel::updateVisualIndexes()
330330
{
331+
m_isUpdating = true;
332+
emit isUpdatingChanged(true);
333+
331334
for (int i = 0; i < rowCount(); i++) {
332335
item(i)->setData(-1, TraySortOrderModel::VisualIndexRole);
333336
}
@@ -440,6 +443,9 @@ void TraySortOrderModel::updateVisualIndexes()
440443

441444
// update visible item count property
442445
setProperty("visualItemCount", currentVisualIndex);
446+
447+
m_isUpdating = false;
448+
emit isUpdatingChanged(false);
443449

444450
qDebug() << "update" << m_visualItemCount << currentVisualIndex;
445451
}

panels/dock/tray/traysortordermodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class TraySortOrderModel : public QStandardItemModel
2525
Q_PROPERTY(bool collapsed MEMBER m_collapsed NOTIFY collapsedChanged)
2626
Q_PROPERTY(bool isCollapsing MEMBER m_isCollapsing NOTIFY isCollapsingChanged)
2727
Q_PROPERTY(bool actionsAlwaysVisible MEMBER m_actionsAlwaysVisible NOTIFY actionsAlwaysVisibleChanged)
28+
Q_PROPERTY(bool isUpdating MEMBER m_isUpdating NOTIFY isUpdatingChanged)
2829
Q_PROPERTY(QList<QVariantMap> availableSurfaces MEMBER m_availableSurfaces NOTIFY availableSurfacesChanged)
2930
public:
3031
// enum SectionTypes {
@@ -67,6 +68,7 @@ class TraySortOrderModel : public QStandardItemModel
6768
void collapsedChanged(bool);
6869
void isCollapsingChanged(bool);
6970
void actionsAlwaysVisibleChanged(bool);
71+
void isUpdatingChanged(bool);
7072
void visualItemCountChanged(int);
7173
void availableSurfacesChanged(const QList<QVariantMap> &);
7274

@@ -75,6 +77,7 @@ class TraySortOrderModel : public QStandardItemModel
7577
bool m_collapsed = false;
7678
bool m_isCollapsing = false;
7779
bool m_actionsAlwaysVisible = false;
80+
bool m_isUpdating = false;
7881
std::unique_ptr<Dtk::Core::DConfig> m_dconfig;
7982
// this is for the plugins that currently available.
8083
QList<QVariantMap> m_availableSurfaces;

0 commit comments

Comments
 (0)