Skip to content

Commit

Permalink
fix: use proper dock DnD MIME data
Browse files Browse the repository at this point in the history
对于将应用拖拽到Dock上固定的场景使用正确的MIME数据,并在不允许某应用固定到Dock上时不加入此MIME数据,以阻止Dock接受拖拽事件。此提交是占位包需求遗留问题的修复。

Log:
Bug: https://pms.uniontech.com/bug-view-279155.html
  • Loading branch information
RigoLigoRLC authored and BLumia committed Oct 18, 2024
1 parent 85906c1 commit efa6c46
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 1 addition & 3 deletions qml/FolderGridViewPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ Popup {
anchors.fill: parent
dndEnabled: true
displayFont: isWindowedMode ? DTK.fontManager.t9 : DTK.fontManager.t6
Drag.mimeData: {
"text/x-dde-launcher-dnd-desktopId": model.desktopId
}
Drag.mimeData: Helper.generateDragMimeData(model.desktopId)
visible: dndItem.currentlyDraggedId !== model.desktopId
iconSource: iconName

Expand Down
4 changes: 1 addition & 3 deletions qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ InputEventItem {
margins: 5
}
dndEnabled: !folderGridViewPopup.opened
Drag.mimeData: {
"text/x-dde-launcher-dnd-desktopId": model.desktopId
}
Drag.mimeData: Helper.generateDragMimeData(model.desktopId)
visible: dndItem.currentlyDraggedId !== model.desktopId
iconSource: (iconName && iconName !== "") ? iconName : "application-x-desktop"
icons: folderIcons
Expand Down
10 changes: 10 additions & 0 deletions qml/Helper.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,14 @@ QtObject {
crystal: itemBackgroundColor.hoveredDarkColor
}
}

function generateDragMimeData(desktopId) {
// In some cases an app is not allowed to be pinned onto dock via drag-n-drop;
// We only insert the MIME data for dde-dock in those allowed cases.
var mime = { "text/x-dde-launcher-dnd-desktopId": desktopId }
if (!DesktopIntegration.appIsDummyPackage(desktopId)) {
mime["text/x-dde-dock-dnd-appid"] = desktopId
}
return mime
}
}
4 changes: 1 addition & 3 deletions qml/windowed/FreeSortListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ Item {
Drag.hotSpot.y: height / 2
Drag.dragType: Drag.Automatic
Drag.active: mouseArea.drag.active
Drag.mimeData: {
"text/x-dde-launcher-dnd-desktopId": model.desktopId
}
Drag.mimeData: Helper.generateDragMimeData(model.desktopId)

background: ItemBackground {
id: bg
Expand Down

0 comments on commit efa6c46

Please sign in to comment.