feat: enhance drag-and-drop visual feedback and folder icon animation #716
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Mar 3, 2026
Merged
feat: enhance drag-and-drop visual feedback and folder icon animation #716deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
feat: 增强拖放视觉反馈和文件夹图标动画效果 提供拖动应用到文件夹的动画效果,实现应用原地缩小以及位移到相应的文件夹的应用位置, 采用方案为获取鼠标位置大小,然后采用hotspot的坐标偏移,获取应用图标中心点,然后转为icon坐标系的坐标图标应该放置的应用图标中心点,从而解决由于缩放图标会产生的位置偏移问题。 另外去除 girdview 是由于计算位置正确,但是存在着显示问题却会偏移像素级位置,所以去除。 采用dragAndfolderBackground 为 文件夹的背景, 也是对应的drag时候的图标的背景。 PMS: BUG-288931 BUG-315679
deepin pr auto reviewGit Diff 代码审查报告总体评价这段代码主要实现了拖拽图标到文件夹的动画效果,增强了用户体验。代码结构基本合理,但在一些细节上可以进一步优化。以下是详细的审查意见。 详细审查1. 代码语法与逻辑优点
改进建议
2. 代码质量优点
改进建议
3. 代码性能优点
改进建议
4. 代码安全优点
改进建议
具体代码改进建议1. 提取公共属性为组件// DragAndDropManager.qml
QtObject {
id: root
property string currentlyDraggedId
property string currentlyDraggedIconName
property bool mergeAnimPending: false
property string mergeAnimTargetIcon: ""
property string mergeAnimTargetIcon2: ""
property real mergeAnimStartX: 0
property real mergeAnimStartY: 0
property real mergeSize: 0
signal dragEnded()
function reset() {
currentlyDraggedId = ""
currentlyDraggedIconName = ""
mergeAnimPending = false
mergeAnimTargetIcon = ""
mergeAnimTargetIcon2 = ""
mergeAnimStartX = 0
mergeAnimStartY = 0
mergeSize = 0
}
}2. 优化文件夹图标布局计算// IconItemDelegate.qml
function getItemX(index) {
const col = index % maxIconCount
return spacing + col * (itemWidth + spacing)
}
function getItemY(index) {
const row = Math.floor(index / maxIconCount)
return spacing + row * (itemHeight + spacing)
}3. 改进动画性能// IconItemDelegate.qml
ParallelAnimation {
id: iconIntroAnim
onStarted: root.iconIntroAnimRunning = true
PropertyAnimation {
target: folderIcon
properties: "scale,x,y"
to: {
"scale": (itemWidth / root.maxIconSizeInFolder) * root.iconScaleFactor,
"x": iconItem.getItemX(index),
"y": iconItem.getItemY(index)
}
duration: 400
easing.type: Easing.OutExpo
}
onFinished: {
root.iconIntroAnimRunning = false
// 不在这里重置dndItem属性,由设置它们的代码负责
}
}4. 添加输入验证// FullscreenFrame.qml
onDropped: function (drop) {
let dragId = drop.getDataAsString("text/x-dde-launcher-dnd-desktopId")
if (!dragId || dragId === "") {
console.warn("Invalid drag ID received")
return
}
// 添加边界检查
if (drop.x < 0 || drop.x > width || drop.y < 0 || drop.y > height) {
console.warn("Drop position out of bounds")
return
}
// 其余代码...
}总结这段代码实现了拖拽动画功能,整体质量良好,但存在一些可以改进的地方:
建议在后续版本中逐步实施这些改进,以提高代码质量和可维护性。 |
BLumia
approved these changes
Mar 3, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/forcemerge |
|
This pr force merged! (status: behind) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: 增强拖放视觉反馈和文件夹图标动画效果
提供拖动应用到文件夹的动画效果,实现应用原地缩小以及位移到相应的文件夹的应用位置,
采用方案为获取鼠标位置大小,然后采用hotspot的坐标偏移,获取应用图标中心点,然后转为icon坐标系的坐标图标应该放置的应用图标中心点,从而解决由于缩放图标会产生的位置偏移问题。
另外去除 girdview
是由于计算位置正确,但是存在着显示问题却会偏移像素级位置,所以去除。
采用dragAndfolderBackground 为 文件夹的背景,
也是对应的drag时候的图标的背景。
PMS: BUG-288931 BUG-315679