Skip to content

fix(viewer): keep last thumbnail visible on context menu - #185

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/eaglefrom
Resurgamz:feature/fix-BUG247309
Nov 24, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/eaglefrom
Resurgamz:feature/fix-BUG247309

Conversation

@Resurgamz

@Resurgamz Resurgamz commented Nov 20, 2026 •

Copy link
Copy Markdown

问题

看图打开较多图片后切换到最后一张,在主图区域唤起右键菜单时,底部缩略图栏会自动向左滚动,导致最后一张缩略图被挤出可视区,不再显示当前正在查看的图片。

PMS:https://pms.uniontech.com/bug-view-247309.html

根因

缩略图栏由 MyImageListWidget 管理,位置通过移动子控件 LibImgViewListView 的 x 坐标实现。

  1. LibCommonService::eventFilter(service/commonservice.cpp:82)对任意右键都 emit sigRightMousePress();

  2. MyImageListWidget 收到该信号后无条件调用 animationStart(true, 0, 400) 复位缩略图栏(viewpanel/contents/imgviewwidget.cpp);

  3. animationStart 复位时,位置被"拖动边界"钳制,其下界为:

    LEFT_LISTVIEW_MOVE_MAXLEN - offsetRowMove = 60 - (rowWidth - 9*35) = 375 - rowWidth
    

    隐含假设缩略图可视宽度恒为 375px。

当真实可视宽度 width < 375px 时,最后一张的正确位置 width - rowWidth 小于该下界,被抬升到 375 - rowWidth,列表整体右移,末张缩略图被挤出可视区右侧。

故障机日志(deepin-image-viewer 5.9.20.9,窗口 770px)按工具栏固定布局推算缩略图可视宽度 ≈ 227px < 375px,命中缺陷;全屏/宽窗口不易复现。

修复

将 animationStart 与 eventFilter 两处"拖动边界"的下界,由"375px 魔数"统一改为真实可视宽度,并用 qMin(0, ...) 保证内容不足一屏时不强制右移(保持原有左对齐/居中行为):

int minRangeX = qMin(0, this->geometry().width() - rowWidth);
moveRangeX = moveRangeX > LEFT_LISTVIEW_MOVE_MAXLEN ? LEFT_LISTVIEW_MOVE_MAXLEN : moveRangeX;
moveRangeX = moveRangeX < minRangeX ? minRangeX : moveRangeX;

同时移除因此不再使用的 RIGHT_LISTVIEW_MOVE_UPDATE 宏,并更新 SPDX 年份范围。

回归影响面

  • 内容溢出(本 bug 场景):下界 375-rowWidth → width-rowWidth,右对齐最后一张时不再被抬升;拖动到末尾也可完整显示末张。
  • 内容不足一屏(图片较少):qMin(0, width-rowWidth)=0,下界仍为 0,原有左对齐/居中行为不变。
  • animationStart(复位)与 eventFilter(拖动)两处边界现已一致。

本地验证

  • 基于 develop/eagle 最新代码(e586bf4)应用,imageviewer 目标编译通过(无告警)。
  • 单元测试:imgviewwidget 相关 8 个用例(含 animationStart、animationStart_400、moveCenterWidget、thumbnailIsMoving、sigRightMousePress)全部通过。

复现/回归步骤

  1. 窄窗口(约 < 830px)打开多张图片;
  2. 切换到最后一张;
  3. 主图区唤起右键菜单;
  4. 预期:缩略图栏不移动,末张始终完整可见。

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Replace the thumbnail strip’s hard-coded movement lower bound with one based on the widget’s actual width, keeping the final thumbnail visible while preserving behavior when the content fits; remove the obsolete movement constant.

  • libimageviewer/viewpanel/contents/imgviewwidget.cpp L139-144, L400-404 (+2 small edits)

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 ✨

@Resurgamz
Resurgamz force-pushed the feature/fix-BUG247309 branch from 027d858 to 6deff6c Compare November 20, 2026 09:54
The thumbnail reset animation clamped the strip with a hard-coded 375px
visible width, pushing the last thumbnail out of view when the window
was narrower. Use the real widget width as the lower bound instead.

缩略图复位动画用硬编码 375px 可视宽度做边界钳制,窗口较窄时会把
最后一张缩略图挤出可视区。改用控件真实宽度作为下界。

Log: 修复切到最后一张时右键菜单导致缩略图前滚
PMS: BUG-247309
Influence: 缩略图栏定位正确,右键菜单不再使最后一张缩略图移出可视区。
@Resurgamz
Resurgamz force-pushed the feature/fix-BUG247309 branch from 6deff6c to ab9fa32 Compare November 20, 2026 10:26
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: max-lvs, Resurgamz

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

@Resurgamz

Copy link
Copy Markdown
Author

/merge

@deepin-bot
deepin-bot Bot merged commit 6749023 into linuxdeepin:develop/eagle Nov 24, 2026
20 checks passed
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.

3 participants