-
Notifications
You must be signed in to change notification settings - Fork 55
feat: enhance notification icon handling #1188
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: enhance notification icon handling #1188
Conversation
as title Log: as title
deepin pr auto review关键摘要:
是否建议立即修改:
|
Reviewer's GuideRefactored notification icon handling to fully support inline base64 data URIs, replace temporary file usage with a direct encoding function, and streamline fallback behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @yixinshark - I've reviewed your changes - here's some feedback:
- The method
decodeImageToBase64is actually encoding an image into a base64 data URI—consider renaming it to something likeencodeImageToBase64and add a null‐image guard to avoid producing invalid URIs. - The
imagePathOfNotificationchange removed the fallback to the application-x-desktop icon; please reintroduce a sensible default return value so you don’t end up returning an empty string when no image is provided. - You recreate the QRegularExpression on every call—consider making it a static or precompiled pattern to avoid unnecessary overhead.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The method `decodeImageToBase64` is actually encoding an image into a base64 data URI—consider renaming it to something like `encodeImageToBase64` and add a null‐image guard to avoid producing invalid URIs.
- The `imagePathOfNotification` change removed the fallback to the application-x-desktop icon; please reintroduce a sensible default return value so you don’t end up returning an empty string when no image is provided.
- You recreate the QRegularExpression on every call—consider making it a static or precompiled pattern to avoid unnecessary overhead.
## Individual Comments
### Comment 1
<location> `panels/notification/bubble/bubbleitem.cpp:96` </location>
<code_context>
}
-static QImage decodeImageFromBase64(const QString &arg)
+static QString decodeImageToBase64(const QImage &image, const char *format = "PNG")
{
- if (arg.startsWith("data:image/")) {
</code_context>
<issue_to_address>
Function name may be misleading regarding its purpose.
Consider renaming the function to encodeImageToBase64 or imageToBase64Uri to better reflect that it encodes a QImage to a base64 data URI.
Suggested implementation:
```cpp
static QString encodeImageToBase64(const QImage &image, const char *format = "PNG")
```
If this function is called elsewhere in the file or project, those call sites should also be updated to use the new name `encodeImageToBase64`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if (arg.startsWith("data:image/")) { | ||
| // iconPath is a string representing an inline image. | ||
| QStringList strs = arg.split("base64,"); | ||
| if (strs.length() == 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Function name may be misleading regarding its purpose.
Consider renaming the function to encodeImageToBase64 or imageToBase64Uri to better reflect that it encodes a QImage to a base64 data URI.
Suggested implementation:
static QString encodeImageToBase64(const QImage &image, const char *format = "PNG")
If this function is called elsewhere in the file or project, those call sites should also be updated to use the new name encodeImageToBase64.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
as title
Log: as title
Summary by Sourcery
Convert notification icon handling to generate and return base64 data URIs instead of writing temporary files and using theme fallbacks
Enhancements: