Skip to content

fix(sidebar): align catalog scrollbar to far-right edge - #347

Open
F-windy wants to merge 1 commit into
linuxdeepin:masterfrom
F-windy:fix/align-catalog-scrollbar
Open

fix(sidebar): align catalog scrollbar to far-right edge#347
F-windy wants to merge 1 commit into
linuxdeepin:masterfrom
F-windy:fix/align-catalog-scrollbar

Conversation

@F-windy

@F-windy F-windy commented Aug 28, 2026

Copy link
Copy Markdown

概述

修复 CatalogWidget 目录侧边栏垂直滚动条内缩 9px 的问题,使其与侧边栏其余 4 个可滚动组件(缩略图、书签、批注、搜索)统一为 0px 右边距,滚动条贴齐侧边栏右边缘。

问题

CatalogWidgetmainLayout(QVBoxLayout)未设置 contentsMargins,使用 Qt 默认 9px 四边边距,导致 CatalogTreeView 的垂直滚动条距侧边栏右边缘内缩 9px,"floating inside an inset gutter"。

其余 4 个侧边栏组件均显式设置了 setContentsMargins(0, *, 0, 0),唯独 CatalogWidget 遗漏。

修改

仅 1 行,在 reader/sidebar/CatalogWidget.cpp:51 添加:

mainLayout->setContentsMargins(0, 0, 0, 0);

设计规范依据

依据 DTK/UOS Design 规范 layout-density.md

Vertical scrollbars should land on the far-right edge of the content area instead of floating inside inset gutters.

hard-fails.md 亦将 "vertical scrollbar still floats inside an inset gutter" 列为阻断性缺陷。

验证

  • 本地编译通过(cmake + make 100%)
  • 运行时验证:目录侧边栏滚动条现已贴齐右边缘,与其他组件一致

关联

PMS: BUG-375255

Summary by Sourcery

Bug Fixes:

  • Align the catalog sidebar scrollbar with the far-right edge by removing the layout's default outer margins.

1. Set mainLayout contentsMargins to (0,0,0,0) in CatalogWidget
2. CatalogTreeView vertical scrollbar no longer floats 9px inside
3. Aligns CatalogWidget with other 4 sidebar scroll components

Log: fix catalog sidebar scrollbar floating inside 9px gutter
Influence: catalog scrollbar now lands on sidebar far-right edge

fix(sidebar): 目录侧边栏滚动条对齐至右边缘

1. 设置 CatalogWidget mainLayout contentsMargins 为 (0,0,0,0)
2. 目录树垂直滚动条不再内缩 9px
3. 与侧边栏其余 4 个滚动组件统一边距

Log: 修复目录侧边栏滚动条内缩 9px 的问题
PMS: BUG-375255
Influence: 目录滚动条现贴齐侧边栏右边缘,与其他组件一致
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: F-windy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes the CatalogWidget scrollbar’s 9px inset by explicitly setting its main layout margins to zero, bringing it into alignment with the other scrollable sidebar components and the DTK/UOS layout-density requirement.

File-Level Changes

Change Details Files
Remove the default layout margins so the catalog scrollbar aligns with the sidebar’s far-right edge.
  • Set the catalog widget’s main vertical layout contents margins to zero on all sides.
  • Match the spacing behavior already used by the thumbnail, bookmark, annotation, and search sidebar components.
reader/sidebar/CatalogWidget.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on 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 issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on 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 dismiss on 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 review to 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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次修改仅新增1行代码,设置 CatalogWidget 的 mainLayout 内容边距为 (0,0,0,0),修复目录侧边栏滚动条内缩 9px 的问题,与侧边栏其余 4 个滚动组件统一边距,修改精准且符合 commit 目的。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 语法正确,逻辑清晰。mainLayout->setContentsMargins(0, 0, 0, 0) 是 Qt QVBoxLayout 的标准 API 调用,参数类型和数量正确,调用位置在 mainLayout 创建之后、添加子控件之前,逻辑合理。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码结构清晰,修改精准。仅1行代码变更,直接解决问题,与侧边栏其余4个组件(缩略图、书签、批注、搜索)的 setContentsMargins 调用保持一致,无重复代码,无需额外注释。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,资源使用合理。setContentsMargins 是 O(1) 操作,仅设置布局边距属性,不涉及任何计算或资源分配,对性能无影响。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 存在0个安全漏洞。本次修改仅设置布局边距,不涉及用户输入、文件操作、网络通信或内存管理,无安全风险。


💡 改进建议代码示例

// 本次修改无需改进,代码已是最优实现
// reader/sidebar/CatalogWidget.cpp - initWidget()
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);  // 设置边距为0,滚动条贴齐右边缘

本报告由 AI 代码审查工具自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants