# HG changeset patch
# User Antonio Muci <
a....@inwind.it>
# Date 1781552080 -7200
# Mon Jun 15 21:34:40 2026 +0200
# Node ID 38d32d6d81f7f9886c12d0b6db0af287001f788a
# Parent 9806d49225a505445a9b2bbde5037e3ffa6f1006
commit: fix wrong size of commit button on Qt6
This commit redoes verbatim what was proposed in 2024 in
https://groups.google.com/g/thg-dev/c/o0AgzdVKazo/m/4soNAHtFBgAJ by Matt
Harbison.
At the time, it was rejected because ".width() at this point wouldn't return
reasonable value because the widget isn't laid out yet".
On my system (Fedora 44, PyQt6), print(committb.width()) prints 100 and fixes
the visual issue, without breaking when run under PyQt5. However, I only tested
on my system with PyQt5 and PyQt6. For example, I did not do any Windows
testing.
The patch also removes the function menuButtonWidth(), which has no callers
left. The introduction of menuButtonWidth() can be tracked back to afe08b4e6fd6
from 2011.
Fixes #5968 (that also contains screenshots before and after the change).
diff --git a/tortoisehg/hgqt/commit.py b/tortoisehg/hgqt/commit.py
--- a/tortoisehg/hgqt/commit.py
+++ b/tortoisehg/hgqt/commit.py
@@ -484,13 +484,6 @@ class CommitWidget(QWidget, qtlib.TaskWi
opt = QStyleOptionToolButton()
opt.initFrom(self)
return opt
- def menuButtonWidth(self):
- style = self.style()
- opt = self.styleOption()
- opt.features = QStyleOptionToolButton.ToolButtonFeature.MenuButtonPopup
- rect = style.subControlRect(QStyle.ComplexControl.CC_ToolButton, opt,
- QStyle.SubControl.SC_ToolButtonMenu, self)
- return rect.width()
def setBold(self):
f = self.font()
f.setWeight(QFont.Weight.Bold)
@@ -504,7 +497,7 @@ class CommitWidget(QWidget, qtlib.TaskWi
committb.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup)
fmk = lambda s: committb.fontMetrics().horizontalAdvance(hglib.tounicode(s[2]))
committb._width = (max(pycompat.maplist(fmk, acts))
- + 4*committb.menuButtonWidth())
+ + committb.width())
class CommitButtonMenu(QMenu):
def __init__(self, parent, repo):