Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support drag and drop image #161

Merged
merged 1 commit into from
May 8, 2024
Merged

Conversation

kegechen
Copy link
Contributor

@kegechen kegechen commented May 8, 2024

add "text/uri-list" format to support drag and drop image

mimedata 中有 text/uri-list 就支持图片拖拽到浏览器和(企业)微信了

@kegechen kegechen requested review from 18202781743 and asterwyx May 8, 2024 05:46
@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • cachePixmap函数中,文件名后缀从`.png'变更为'.png',确保了文件名的唯一性,避免了覆盖同一个图片文件的问题。
  • QDataStream的使用增加了代码的健壮性,通过设置版本号为QDataStream::Qt_5_11,保证了与Qt 5.11的兼容性。
  • info.m_formatMap.insert(TextUriListLiteral, QUrl::fromLocalFile(pixFileName).toEncoded());这行代码将文件路径编码后存储在info.m_formatMap中,避免了潜在的文本编码问题。

是否建议立即修改:

建议修改的地方:

  • setImageData函数中,QFileQDataStream的异常处理和错误检查可以进一步细化,确保所有潜在的异常情况都被处理。
  • 考虑在cachePixmap函数中添加更多错误处理的逻辑,例如当srcPix.save失败时,应该记录错误并返回false,而不是静默地继续。
  • setImageData函数中,当reader.canRead()返回false时,应该记录一条日志,说明为什么无法读取文件,而不仅仅是输出错误信息。
  • setImageData函数中,当pix.fromImageReader(&reader)失败时,应该记录一条日志,说明为什么无法将文件转换为QPixmap对象。
  • 检查TextUriListLiteral是否已经在info.m_formatMap中存在,以避免重复插入相同的内容。
  • 确保所有的文件路径都经过适当的处理,例如使用QDirQStandardPaths来处理路径,以避免潜在的跨平台问题。

@kegechen kegechen requested review from ssk-wh and yixinshark May 8, 2024 05:48
ssk-wh
ssk-wh previously approved these changes May 8, 2024
add "text/uri-list" format to support drag and drop image
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kegechen, ssk-wh

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kegechen kegechen merged commit 6c51f22 into linuxdeepin:master May 8, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants