Skip to content
Merged
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
17 changes: 13 additions & 4 deletions panels/dock/tray/package/TrayContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Item {
property bool dragExited: false
property string source: ""
property string surfaceId: ""

onEntered: function (dragEvent) {
dragExited = false
isDropped = false
Expand All @@ -161,11 +162,19 @@ Item {
onPositionChanged: function (dragEvent) {
let surfaceId = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-surfaceId")
let pos = root.isHorizontal ? drag.x : drag.y
let currentItemIndex = pos / (root.itemVisualSize + root.itemSpacing)
let currentPosMapToItem = pos % (root.itemVisualSize + root.itemSpacing)
let isBefore = currentPosMapToItem < root.itemVisualSize / 2
dropHoverIndex = Math.floor(currentItemIndex)
let dropIdx = DDT.TrayItemPositionManager.itemIndexByPoint(Qt.point(drag.x, drag.y))
let currentItemIndex = dropIdx.index
let isBefore = dropIdx.isBefore
let isStash = dragEvent.getDataAsString("text/x-dde-shell-tray-dnd-sectionType") === "stashed"
dropHoverIndex = dropIdx.index

// 检查当前悬停位置是否是禁止拖拽的插件
let modelIndex = DDT.TraySortOrderModel.getModelIndexByVisualIndex(currentItemIndex)
let sectionType =root.model.data(modelIndex, DDT.TraySortOrderModel.SectionTypeRole)
if (sectionType === "fixed") {
dragEvent.accepted = false
return
}

// 检查 ActionShowStashDelegate 是否显示
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The comment is in Chinese. Consider using English for consistency: '// Check if ActionShowStashDelegate is visible'

Suggested change
// 检查 ActionShowStashDelegate 是否显示
// Check if ActionShowStashDelegate is visible

Copilot uses AI. Check for mistakes.
let showStashActionVisible = false
Expand Down
15 changes: 15 additions & 0 deletions panels/dock/tray/traysortordermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ void TraySortOrderModel::updateVisualIndexes()
// "internal/action-toggle-quick-settings"
results = findItems("internal/action-toggle-quick-settings");
Q_ASSERT(!results.isEmpty());
results[0]->setData(SECTION_FIXED, TraySortOrderModel::SectionTypeRole);
results[0]->setData(currentVisualIndex, TraySortOrderModel::VisualIndexRole);
currentVisualIndex++;

Expand Down Expand Up @@ -551,4 +552,18 @@ void TraySortOrderModel::handlePluginVisibleChanged(const QString &surfaceId, bo
}
}

QModelIndex TraySortOrderModel::getModelIndexByVisualIndex(int visualIndex) const
{
for (int i = 0; i < rowCount(); i++) {
QModelIndex index = this->index(i, 0);
int itemVisualIndex = data(index, VisualIndexRole).toInt();
bool visibility = data(index, VisibilityRole).toBool();

if (visibility && itemVisualIndex == visualIndex) {
return index;
}
}
return QModelIndex();
}

}
1 change: 1 addition & 0 deletions panels/dock/tray/traysortordermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TraySortOrderModel : public QStandardItemModel
Q_INVOKABLE bool dropToDockTray(const QString & draggedSurfaceId, int dropVisualIndex, bool isBefore);
Q_INVOKABLE void setSurfaceVisible(const QString & surfaceId, bool visible);
Q_INVOKABLE bool isDisplayedSurface(const QString &surfaceId) const;
Q_INVOKABLE QModelIndex getModelIndexByVisualIndex(int visualIndex) const;

signals:
void collapsedChanged(bool);
Expand Down