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
12 changes: 6 additions & 6 deletions panels/dock/tray/package/TrayContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -241,7 +241,7 @@ Item {
onStashDropSucceeded()
}
}
DDT.TraySortOrderModel.actionsAlwaysVisible = false
DDT.TraySortOrderModel.setTrayDragActive(false)
dropHoverIndex = -1
}

Expand All @@ -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)
}
}

Expand Down
20 changes: 19 additions & 1 deletion panels/dock/tray/traysortordermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<QStandardItem *> results = findItems(id);
if (results.isEmpty()) continue;
Expand Down
2 changes: 2 additions & 0 deletions panels/dock/tray/traysortordermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<Dtk::Core::DConfig> m_dconfig;
// this is for the plugins that currently available.
Expand Down