sync: from linuxdeepin/dde-session-shell#451
Merged
Merged
Conversation
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#31
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates UserFrameList to correctly parent its central widget and align its maximum height with the scroll area during layout recalculations. Class diagram for updated UserFrameList structureclassDiagram
class UserFrameList {
- QWidget* m_centerWidget
- DFlowLayout* m_flowLayout
- QScrollArea* m_scrollArea
+ void initUI()
+ void updateLayout(int width)
}
UserFrameList --> QWidget : m_centerWidget
UserFrameList --> DFlowLayout : m_flowLayout
UserFrameList --> QScrollArea : m_scrollArea
%% Highlight changes
%% m_centerWidget is now constructed with 'this' as parent
%% updateLayout now sets m_centerWidget maximum height to m_scrollArea height
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
Author
deepin pr auto review我对这段代码进行审查,提供以下改进意见: 1. 语法逻辑方面:
2. 代码质量方面:
3. 代码性能方面:
4. 代码安全方面:
改进建议代码示例:// 在类定义中添加常量
static const int UserFrameListVerticalMargin = 20;
static const int DoubleLayoutMultiplier = 2;
void UserFrameList::updateLayout(int width)
{
// 参数有效性检查
if (width <= 0) {
qWarning() << "Invalid width provided to updateLayout:" << width;
return;
}
const int count = m_flowLayout->count(); // 缓存count值
const int countWidth = /* 计算逻辑 */;
const int userWidgetHeight = /* 计算逻辑 */;
// 禁用更新以提高性能
setUpdatesEnabled(false);
if (countWidth > 0) {
if (count <= count) {
m_scrollArea->setFixedSize(countWidth, userWidgetHeight + UserFrameListVerticalMargin);
m_centerWidget->setMaximumHeight(m_scrollArea->height());
} else {
m_scrollArea->setFixedSize(countWidth, (userWidgetHeight + UserFrameSpacing) * DoubleLayoutMultiplier);
}
}
// 重新启用更新
setUpdatesEnabled(true);
}这些改进可以提高代码的健壮性、可读性和性能,同时减少潜在的错误。 |
yixinshark
approved these changes
Aug 18, 2025
Contributor
Author
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-ci-robot, 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 |
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.
Synchronize source files from linuxdeepin/dde-session-shell.
Source-pull-request: linuxdeepin/dde-session-shell#31
Summary by Sourcery
Sync changes from linuxdeepin/dde-session-shell and improve UserFrameList widget initialization and layout constraints
Enhancements: