fix: remove minHeight reset and add minHeight message handling#548
fix: remove minHeight reset and add minHeight message handling#548wjyrich merged 1 commit intolinuxdeepin:masterfrom
Conversation
1. Removed m_minHeight reset in hideEvent to preserve minimum height setting across hide/show cycles 2. Added message handling for MSG_SET_APPLET_MIN_HEIGHT to support dynamic minimum height configuration 3. The plugin now responds to external requests to set minimum height for the applet container 4. This ensures proper layout behavior when the dock content widget is hidden and shown again Log: Fixed dock network plugin layout preservation issues Influence: 1. Test hiding and showing the network plugin in dock to verify height preservation 2. Verify that external messages to set minimum height are properly processed 3. Test with different minimum height values to ensure correct layout behavior 4. Check that the plugin maintains consistent appearance after multiple hide/show cycles 5. Verify compatibility with dock container margin settings fix: 移除最小高度重置并添加最小高度消息处理 1. 移除 hideEvent 中的 m_minHeight 重置,以在隐藏/显示周期中保持最小高度 设置 2. 添加 MSG_SET_APPLET_MIN_HEIGHT 消息处理,支持动态最小高度配置 3. 插件现在能够响应外部设置应用容器最小高度的请求 4. 确保停靠栏内容部件在隐藏和再次显示时具有正确的布局行为 Log: 修复停靠栏网络插件布局保持问题 Influence: 1. 测试隐藏和显示停靠栏中的网络插件,验证高度保持功能 2. 验证外部设置最小高度的消息是否被正确处理 3. 使用不同的最小高度值测试,确保正确的布局行为 4. 检查插件在多次隐藏/显示循环后是否保持一致的显示效果 5. 验证与停靠栏容器边距设置的兼容性 PMS: BUG-356951
Reviewer's guide (collapsed on small PRs)Reviewer's GuidePreserves the dock network plugin’s minimum height across hide/show cycles and adds message-based control for the applet container’s minimum height, while keeping existing container margin handling intact. Sequence diagram for handling MSG_SET_APPLET_MIN_HEIGHT in NetworkPlugin::messagesequenceDiagram
participant ExternalSender
participant Dock
participant NetworkPlugin
participant DockContentWidget
ExternalSender->>Dock: send JSON with MSG_SET_APPLET_MIN_HEIGHT
Dock->>NetworkPlugin: message(msg)
NetworkPlugin->>NetworkPlugin: parse msg into msgObj
alt msgObj[MSG_TYPE] == MSG_SET_APPLET_MIN_HEIGHT
NetworkPlugin->>NetworkPlugin: minHeight = msgObj[MSG_DATA].toInt(-1)
alt m_dockContentWidget exists and minHeight > 0
NetworkPlugin->>DockContentWidget: setMinHeight(minHeight)
end
end
NetworkPlugin->>Dock: return result string
Updated class diagram for NetworkPlugin and DockContentWidget minHeight handlingclassDiagram
class NetworkPlugin {
+QString message(QString msg)
-DockContentWidget* m_dockContentWidget
}
class DockContentWidget {
-int m_minHeight
+void hideEvent(QHideEvent* event)
+void setMinHeight(int minHeight)
+void updateSize()
}
NetworkPlugin --> DockContentWidget : manages_minHeight
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider caching
msgObj.value(Dock::MSG_TYPE).toString()in a local variable so you don't perform the same lookup and conversion twice when handling different message types. - When processing
MSG_SET_APPLET_MIN_HEIGHT, it may be useful to validate and clamp unreasonable height values (or add a clear fallback behavior) rather than silently ignoring non-positive values.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider caching `msgObj.value(Dock::MSG_TYPE).toString()` in a local variable so you don't perform the same lookup and conversion twice when handling different message types.
- When processing `MSG_SET_APPLET_MIN_HEIGHT`, it may be useful to validate and clamp unreasonable height values (or add a clear fallback behavior) rather than silently ignoring non-positive values.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review这段代码的 diff 主要涉及网络插件在隐藏事件处理和消息响应方面的修改。以下是对代码的详细审查意见: 1. 逻辑与功能审查修改点 1:移除
修改点 2:新增
2. 代码质量与规范
3. 代码性能
4. 代码安全
总结与改进建议这段代码的修改逻辑是正确的,将内部状态的重置逻辑转变为外部消息驱动的设置逻辑,解耦了隐藏事件与属性状态。 改进建议代码片段: QString NetworkPlugin::message(const QString &msg)
{
// ... (前面的 JSON 解析代码保持不变)
const auto &msgObj = resultDoc.object();
// 提取消息类型以避免重复调用 toString()
const QString msgType = msgObj.value(Dock::MSG_TYPE).toString();
// 处理最小高度设置
if (msgType == Dock::MSG_SET_APPLET_MIN_HEIGHT) {
const int minHeight = msgObj.value(Dock::MSG_DATA).toInt(-1);
if (m_dockContentWidget && minHeight > 0) {
m_dockContentWidget->setMinHeight(minHeight);
}
}
// 处理容器边距设置
if (msgType == Dock::MSG_APPLET_CONTAINER && m_dockContentWidget) {
// 保持原有逻辑
const int data = msgObj.value(Dock::MSG_DATA).toInt(-1);
const int topMargin = (data == Dock::APPLET_CONTAINER_QUICK_PANEL) ? 6 : 10;
m_dockContentWidget->setMainLayoutMargins(QMargins(0, topMargin, 0, 0));
}
// ...
}主要优化点:
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, 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 |
Log: Fixed dock network plugin layout preservation issues
Influence:
fix: 移除最小高度重置并添加最小高度消息处理
Log: 修复停靠栏网络插件布局保持问题
Influence:
PMS: BUG-356951
Summary by Sourcery
Preserve the dock network plugin applet's minimum height across hide/show cycles and handle external messages to update it dynamically.
Bug Fixes:
Enhancements: