-
Notifications
You must be signed in to change notification settings - Fork 55
fix: support string list in notification hints #1135
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
Conversation
1. Added LIST_VALUE_SEGMENT constant for string list serialization 2. Modified convertHintsToString to handle QStringList values by joining with separator 3. Updated parseHint to reconstruct QStringList from serialized format 4. Improved action handling in NotificationManager to properly process string list hints 5. Added deprecation warning for old string format hints These changes were necessary to properly support complex hint values in notifications, particularly for action parameters that may contain multiple values. The previous implementation only supported simple string values, which limited functionality. fix: 支持通知提示中的字符串列表 1. 添加 LIST_VALUE_SEGMENT 常量用于字符串列表序列化 2. 修改 convertHintsToString 方法以处理 QStringList 值并使用分隔符连接 3. 更新 parseHint 方法从序列化格式重建 QStringList 4. 改进 NotificationManager 中的动作处理以正确处理字符串列表提示 5. 为旧的字符串格式提示添加弃用警告 这些变更是为了在通知中正确支持复杂的提示值,特别是可能包含多个值的动作参 数。之前的实现仅支持简单字符串值,限制了功能。 pms: BUG-317649
deepin pr auto review代码审查意见:
综合以上意见,建议对代码进行如下修改: // 修改1:将QString value的声明移动到函数开头
QString value;
// 修改2:使用QVariant::type()来检查类型
if (it.value().type() == QVariant::StringList) {
QStringList tmp = it.value().toStringList();
value = tmp.join(LIST_VALUE_SEGMENT);
} else {
value = it.value().toString();
}
// 修改3:使用qWarning输出警告信息
qWarning(notifyLog) << "Deprecate hint format, use string list instead of string."
<< "actionId:" << actionId << ", value:" << i.value();
// 修改4:先检查类型再进行转换
if (i.value().type() == QVariant::StringList) {
args = i.value().toStringList();
} else {
args = i.value().toString().split(",");
}
// 修改5:使用<<操作符格式化输出日志
qDebug(notifyLog) << "Action invoked:" << actionId << ", args:" << args;
// 修改6:添加错误处理逻辑
if (args.isEmpty()) {
qWarning(notifyLog) << "Empty args for action:" << actionId;
// 或者抛出异常
}
// 修改7:使用中文注释
// 命令 |
Reviewer's GuideThis PR introduces a dedicated serialization segment for QStringList in notification hints, updates serialization/deserialization methods accordingly, and extends NotificationManager action handling to support list-based hint values while deprecating the old string format. Class diagram for updated notification componentsclassDiagram
class NotifyEntity {
+convertHintsToString(const QVariantMap &map): QString
+parseHint(const QString &hint): QVariantMap
}
class NotificationManager {
+doActionInvoked(const NotifyEntity &entity, const QString &actionId): void
}
Flow diagram for updated
|
| Change | Details | Files |
|---|---|---|
| Introduce dedicated serialization for string list hints |
|
panels/notification/common/notifyentity.cpp |
| Extend NotificationManager to support list-based action hints |
|
panels/notification/server/notificationmanager.cpp |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
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 @18202781743 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| QString value; | ||
| if (it.value().typeId() == QMetaType::QStringList) { | ||
| QStringList tmp = it.value().toStringList(); | ||
| value = tmp.join(LIST_VALUE_SEGMENT); |
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.
issue (bug_risk): Delimiter may appear in data and break parsing
Consider escaping LIST_VALUE_SEGMENT in list elements or using a safer serialization method like JSON or base64 to prevent parsing errors.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, mhduiy 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) |
with separator
string list hints
These changes were necessary to properly support complex hint values
in notifications, particularly for action parameters that may contain
multiple values. The previous implementation only supported simple
string values, which limited functionality.
fix: 支持通知提示中的字符串列表
这些变更是为了在通知中正确支持复杂的提示值,特别是可能包含多个值的动作参
数。之前的实现仅支持简单字符串值,限制了功能。
pms: BUG-317649
Summary by Sourcery
Support and process QStringList values in notification hints by enhancing serialization/deserialization and action handling, and emit deprecation warnings for legacy formats.
New Features:
Enhancements: