fix(editor): resolve tab bar jitter when adding new tabs#450
fix(editor): resolve tab bar jitter when adding new tabs#450deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
755eba7 to
9d37dbf
Compare
Reviewer's GuideBatches tabbar layout and paint operations when adding a tab to eliminate jitter, refines tab width calculation logic, and avoids redundant tab text updates when toggling read-only state after reload checks. Sequence diagram for batched tabbar layout when adding a new tabsequenceDiagram
actor User
participant Window
participant Tabbar
participant DTabBar
participant QTabBarLayout as QTabBar_internal_layout
User->>Window: requestNewTab(filePath, tabName)
Window->>Tabbar: addTabWithIndex(index, filePath, tabName, tipPath)
Tabbar->>Tabbar: trimmedName = replaceMnemonic(tabName.simplified())
Tabbar->>Tabbar: setUpdatesEnabled(false)
Tabbar->>DTabBar: insertTab(index, trimmedName)
Tabbar->>DTabBar: setCurrentIndex(index)
Tabbar->>Tabbar: layout().activate()
Tabbar->>Tabbar: setIconSize(iconSize())
Tabbar->>Tabbar: layout().activate()
Tabbar->>Tabbar: setUpdatesEnabled(true)
Tabbar-->>Window: tabAddedWithStableLayout()
Window-->>User: new tab visible without jitter
Sequence diagram for avoiding redundant tab text updates on reload checksequenceDiagram
participant Window
participant Tabbar
participant Wrapper
participant TextEditor
Window->>Window: checkTabbarForReload()
Window->>Window: compute tabName with or without readOnlyStr
Window->>Tabbar: currentName()?
Tabbar-->>Window: currentTabName
alt name changed
Window->>Tabbar: setTabText(currentIndex, tabName)
else name unchanged
Window->>Tabbar: skip setTabText
end
Window->>Wrapper: textEditor()
Wrapper-->>Window: TextEditor
Window->>TextEditor: setReadOnlyPermission(isReadOnly)
TextEditor-->>Window: done
Class diagram for updated Tabbar and Window behaviorsclassDiagram
class Tabbar {
+void addTabWithIndex(int index, QString filePath, QString tabName, QString tipPath)
+QSize tabSizeHint(int index) const
+void setUpdatesEnabled(bool enabled)
+QLayout* layout()
+void setIconSize(QSize size)
+int width() const
}
class DTabBar {
+void insertTab(int index, QString text)
+void setCurrentIndex(int index)
+int count() const
}
class Window {
+void checkTabbarForReload()
-Tabbar* m_tabbar
}
class DGuiApplicationHelper {
+static bool isCompactMode()
}
class QSize {
+QSize(int width, int height)
}
Tabbar --|> DTabBar : inherits
Window --> Tabbar : uses
Tabbar ..> DGuiApplicationHelper : queries mode
Tabbar ..> QSize : returns
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:
- The new batching logic around
setUpdatesEnabled(false)/trueand doublelayout()->activate()is quite subtle; consider extracting this into a small helper (or RAII-style scope object) with a clear name so future changes don’t accidentally leave updates disabled or break the intended ordering. - When calling
layout()->activate()inaddTabWithIndex, it may be safer to guard against a nulllayout()pointer (or assert its presence) to avoid potential crashes if the widget’s layout is changed in the future.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new batching logic around `setUpdatesEnabled(false)`/`true` and double `layout()->activate()` is quite subtle; consider extracting this into a small helper (or RAII-style scope object) with a clear name so future changes don’t accidentally leave updates disabled or break the intended ordering.
- When calling `layout()->activate()` in `addTabWithIndex`, it may be safer to guard against a null `layout()` pointer (or assert its presence) to avoid potential crashes if the widget’s layout is changed in the future.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 390,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx 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 |
Batch layout operations with setUpdatesEnabled and double layout()->activate() to prevent scroll button cascade flicker. 修复新建标签页时标签栏抖动问题,通过批量布局操作和 双重layout激活消除滚动按钮级联闪烁。 Log: 修复新建标签页时标签栏抖动 PMS: BUG-353507 Influence: 新建标签页(2个及以上)时不再出现标签栏抖动现象,提升用户体验。
9d37dbf to
47037b8
Compare
|
Note
详情{
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 389,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
deepin pr auto review这段代码主要针对 以下是针对语法逻辑、代码质量、代码性能和代码安全的详细审查意见: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 其他改进建议
总结这段 diff 的整体质量较高,主要解决了 UI 渲染时的抖动问题,并优化了标签宽度的计算逻辑。
最终建议:在合并前,建议移除或条件编译掉 |
|
/merge |
Batch layout operations with setUpdatesEnabled and double layout()->activate() to prevent scroll button cascade flicker.
修复新建标签页时标签栏抖动问题,通过批量布局操作和
双重layout激活消除滚动按钮级联闪烁。
Log: 修复新建标签页时标签栏抖动
PMS: BUG-353507
Influence: 新建标签页(2个及以上)时不再出现标签栏抖动现象,提升用户体验。
Summary by Sourcery
Prevent tab bar jitter and unnecessary tab text updates when creating or reloading editor tabs.
Bug Fixes:
Enhancements: