Skip to content

Centre Button content on a whole pixel - #14700

Open
omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-8782
Open

omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-8782

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

Button centred its content with anchors.horizontalCenter, and Qt rounds the button's centre and the content row's centre separately. Once a layout gives a button a whole-pixel width, that can put the content a whole pixel right of centre. The Network panel's speed-test header action is one: its RowLayout makes it 29 px wide, the icon row is 16.98 px, and the row lands at x 7 where the centre is 6.01. At scale 1.25 that is 7 px of highlight left of the icon and 5 px right, which is what #8782 reports from a stock install.

The row is now placed with x: Math.round((root.width - width) / 2), which keeps it on a whole pixel and within half a pixel of the centre at any width. leftAlign keeps its inset. An x is not mirrored the way an anchor is, so the mirrored case is computed explicitly and lands where the old mirrored left anchor put it. Every Button in the shell gets the same correction, by at most a pixel and always towards the centre; none of them sets leftAlign.

test/shell.d/button-centering-test.sh builds buttons with icon, text and mixed content at whole and fractional widths, plain and mirrored, and requires the content on a whole pixel within half a pixel of the centre. It also checks that leftAlign keeps its inset on either side. On quattro it fails at odd widths for icons and plain text alike.

#8787 addresses the other half of #8782, the box being taller than wide, by moving these two actions to PanelActionButton. That component centres its icon with anchors.centerIn, which rounds the same way, so if #8787 lands these two actions would need the same correction there. @fabianbehrendt measured this 7/5 offset on #8787 and proposed rounding the row's position, which this follows.

Fixes #8782

anchors.horizontalCenter rounds the button's centre and the row's separately, so once a layout gives a button a whole-pixel width the content can land a pixel right of centre. The Network panel's speed-test action gets width 29 from its RowLayout and its icon row sits at x 7 where the centre is 6.01; at scale 1.25 that is 7 px of highlight left of the icon and 5 right. The row is now placed with a rounded x, which keeps it on a whole pixel within half a pixel of the centre. An x is not mirrored the way an anchor is, so leftAlign mirrors its inset explicitly, as the left anchor it replaces did.

Fabian Behrendt measured the same 7/5 offset on #8787 and proposed rounding the row's position.

Co-Authored-By: Fabian Behrendt <7931874+fabianbehrendt@users.noreply.github.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Button now rounds its content’s horizontal position once, rather than letting Qt round two centers separately.

  • Keeps the existing leftAlign inset, including mirrored layouts.
  • Adds checks for icon, text, and mixed content at whole and fractional widths.
  • No actionable issues found.

Reviews (1) · Last reviewed commit: "Centre Button content on a whole pixel" · Reviewed by Greptile

@jandrusk

Copy link
Copy Markdown

Heads-up: #14721 fixes the same thing (#8782) in shell/Ui/Button.qml with whole-pixel centering too. This one also handles leftAlign under LayoutMirroring, so it's the more complete of the two, but it'd be good to settle on one so they don't conflict.

@jandrusk jandrusk mentioned this pull request Oct 12, 2026
4 tasks done
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Read at 5f08540 against quattro; nothing was run. Claude Opus 5.5 classified this as a bug fix, but the second opinion (Codex Medium) could not be asked because today's review budget is spent, so the classification is unsettled. It gets no class label and is not verified on a worker this pass.

Two things the reading did find, for whoever picks it up next:

The diff still merges cleanly with quattro's newer Button.qml (the label-fitting change), since the two touch different lines. Waiting on a pass with the second opinion available, which will classify it and, if it is agreed to be a bug, reproduce it on a worker against a shipped button.

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.

Wi-Fi network panel: QR / speed-test header highlight doesn't line up with the button

2 participants