Skip to content
Open
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
22 changes: 21 additions & 1 deletion panels/dock/tray/package/StashedItemPositioner.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import org.deepin.ds.dock.tray 1.0 as DDT

Control {
id: root
property bool itemVisible: !DDT.TraySortOrderModel.isUpdating
property bool itemVisible: {
// Startup phase: hide all items without triggering animations
if (DDT.TraySortOrderModel.startupPhase) {
return false
}
return !DDT.TraySortOrderModel.isUpdating
}

spacing: 0
padding: 0
Expand All @@ -21,6 +27,12 @@ Control {
NumberAnimation { duration: 200; easing.type: Easing.OutQuad }
}
states: [
State {
name: "startup-hidden"
when: DDT.TraySortOrderModel.startupPhase
PropertyChanges { target: root; opacity: 0.0 }
PropertyChanges { target: root; visible: false }
},
State {
when: root.itemVisible
PropertyChanges { target: root; opacity: 1.0 }
Expand All @@ -33,6 +45,14 @@ Control {
}
]
transitions: [
Transition {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Same transition precedence issue for stashed items as in TrayItemPositioner.

In this case from: "startup-hidden"; to: "*" also matches startup-hidden -> item-invisible, so the show animation runs even when the item should stay hidden. Restrict the to state (e.g., only the visible state) or adjust transition order to prevent animations for items that remain invisible after startup.

from: "startup-hidden"
to: "*"
SequentialAnimation {
PropertyAction { target: root; property: "visible"; value: true }
NumberAnimation { property: "opacity"; duration: 300; easing.type: Easing.OutQuad }
}
},
Transition {
to: "item-invisible"
SequentialAnimation {
Expand Down
23 changes: 23 additions & 0 deletions panels/dock/tray/package/TrayItemPositioner.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import org.deepin.ds.dock.tray 1.0 as DDT
Control {
id: root
property bool itemVisible: {
// Startup phase: hide all items without triggering animations
if (DDT.TraySortOrderModel.startupPhase) {
return false
}
// Update phase: hide to avoid layout flicker
if (DDT.TraySortOrderModel.isUpdating) {
return false
}
Expand Down Expand Up @@ -54,6 +59,13 @@ Control {
NumberAnimation { duration: 200; easing.type: collapsed || !DDT.TraySortOrderModel.isCollapsing ? Easing.OutQuad : Easing.InQuad }
}
states: [
State {
name: "startup-hidden"
when: DDT.TraySortOrderModel.startupPhase
PropertyChanges { target: root; opacity: 0.0 }
PropertyChanges { target: root; scale: 0.8 }
PropertyChanges { target: root; visible: false }
},
State {
when: root.itemVisible
PropertyChanges { target: root; opacity: 1.0 }
Expand All @@ -68,6 +80,17 @@ Control {
}
]
transitions: [
Transition {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Transition from "startup-hidden" to "*" may override the dedicated "item-invisible" transition.

Since from: "startup-hidden"; to: "*" matches all targets, it will also apply to startup-hidden -> item-invisible. Declared before the specific to: "item-invisible" transition, it will likely override it, causing elements that should stay hidden to briefly animate in. Consider narrowing this to a visible state only (e.g. to: "item-visible") or reordering/adjusting conditions so startup-hidden -> item-invisible uses the non-showing transition.

from: "startup-hidden"
to: "*"
SequentialAnimation {
PropertyAction { target: root; property: "visible"; value: true }
ParallelAnimation {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 300; easing.type: Easing.OutQuad }
NumberAnimation { property: "scale"; from: 0.8; to: 1.0; duration: 300; easing.type: Easing.OutBack }
}
}
},
Transition {
to: "item-invisible"
SequentialAnimation {
Expand Down
31 changes: 31 additions & 0 deletions panels/dock/tray/traysortordermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include "constants.h"
#include "trayitempositionmanager.h"

#include <QDebug>

Check warning on line 9 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 10 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 11 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 <QTimer>

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <DConfig>

Check warning on line 14 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 @@ -63,6 +64,18 @@
qDebug() << "actionsAlwaysVisibleChanged";
updateVisualIndexes();
});

// Startup phase timer: end startup phase after 500ms of no new surfaces
m_startupTimer = new QTimer(this);
m_startupTimer->setSingleShot(true);
m_startupTimer->setInterval(500);
Comment on lines +68 to +71
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Consider a fallback to end startupPhase even when no surfaces ever appear.

Since the timer only starts in onAvailableSurfacesChanged, m_startupPhase never ends if no tray surfaces ever appear and QML will keep items hidden indefinitely. Consider starting the timer once in the constructor (or adding an initial one-shot) so startupPhase finishes even when there are no surfaces.

connect(m_startupTimer, &QTimer::timeout, this, [this](){
if (m_startupPhase) {
qDebug() << "Startup phase ended, showing all tray items";
setStartupPhase(false);
}
});

updateVisualIndexes();
}

Expand Down Expand Up @@ -577,6 +590,24 @@
updateVisualIndexes();
// and also save the current sort order
saveDataToDConfig();

// During startup phase, reset timer on each new surface to batch updates
if (m_startupPhase && m_startupTimer) {
m_startupTimer->start();
}
}

bool TraySortOrderModel::startupPhase() const
{
return m_startupPhase;
}

void TraySortOrderModel::setStartupPhase(bool phase)
{
if (m_startupPhase == phase)
return;
m_startupPhase = phase;
emit startupPhaseChanged(phase);
}

void TraySortOrderModel::handlePluginVisibleChanged(const QString &surfaceId, bool visible)
Expand Down
9 changes: 9 additions & 0 deletions panels/dock/tray/traysortordermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#pragma once

#include "constants.h"

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

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "constants.h" not found.
#include <QQmlEngine>

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

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

View workflow job for this annotation

GitHub Actions / cppcheck

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

namespace Dtk {
namespace Core {
Expand All @@ -26,6 +27,7 @@
Q_PROPERTY(bool isCollapsing MEMBER m_isCollapsing NOTIFY isCollapsingChanged)
Q_PROPERTY(bool actionsAlwaysVisible MEMBER m_actionsAlwaysVisible NOTIFY actionsAlwaysVisibleChanged)
Q_PROPERTY(bool isUpdating MEMBER m_isUpdating NOTIFY isUpdatingChanged)
Q_PROPERTY(bool startupPhase READ startupPhase WRITE setStartupPhase NOTIFY startupPhaseChanged)
Q_PROPERTY(QList<QVariantMap> availableSurfaces MEMBER m_availableSurfaces NOTIFY availableSurfacesChanged)
Q_PROPERTY(QString stagedSurfaceId MEMBER m_stagedSurfaceId NOTIFY stagedDropChanged)
Q_PROPERTY(int stagedVisualIndex MEMBER m_stagedVisualIndex NOTIFY stagedDropChanged)
Expand Down Expand Up @@ -74,12 +76,17 @@
Q_INVOKABLE void stageDropPosition(const QString &surfaceId, int visualIndex);
Q_INVOKABLE void commitStagedDrop();
Q_INVOKABLE void clearStagedDrop();

// Startup phase control
bool startupPhase() const;
Q_INVOKABLE void setStartupPhase(bool phase);

signals:
void collapsedChanged(bool);
void isCollapsingChanged(bool);
void actionsAlwaysVisibleChanged(bool);
void isUpdatingChanged(bool);
void startupPhaseChanged(bool);
void visualItemCountChanged(int);
void availableSurfacesChanged(const QList<QVariantMap> &);
void stagedDropChanged();
Expand All @@ -90,7 +97,9 @@
bool m_isCollapsing = false;
bool m_actionsAlwaysVisible = false;
bool m_isUpdating = false;
bool m_startupPhase = true;
std::unique_ptr<Dtk::Core::DConfig> m_dconfig;
QTimer *m_startupTimer = nullptr;
// this is for the plugins that currently available.
QList<QVariantMap> m_availableSurfaces;
// these are the sort order data source, it might contain items that are no longer existed.
Expand Down
Loading