Merge pull request #1573 from ispyisail/fix/autonum-increment-width

Fix the Auto numbering Increment boxes cut off on Windows
This commit is contained in:
ispyisail
2026-10-21 21:40:13 +13:00
committed by GitHub
3 changed files with 68 additions and 18 deletions
@@ -92,12 +92,6 @@
</item>
<item row="2" column="4">
<widget class="QSpinBox" name="m_conductor_increase_sb">
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Increment: the value added to the counter each time a new number is dialled</string>
</property>
@@ -179,12 +173,6 @@
</item>
<item row="3" column="4">
<widget class="QSpinBox" name="m_element_increase_sb">
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Increment: the value added to the counter each time a new number is dialled</string>
</property>
@@ -255,12 +243,6 @@
</item>
<item row="4" column="4">
<widget class="QSpinBox" name="m_folio_increase_sb">
<property name="maximumSize">
<size>
<width>55</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Increment: the value added to the counter each time a new number is dialled</string>
</property>
+4
View File
@@ -312,6 +312,10 @@ qet_add_app_test(tst_folioimageload tst_folioimageload.cpp)
# edit (#1566) and gets back the height the user gave it (#1439).
qet_add_app_test(tst_selectionpanelheight tst_selectionpanelheight.cpp)
# The Auto numbering panel's Increment spin boxes get the width their style
# asks for; a fixed 55 px cut the number off on Windows (#1566).
qet_add_app_test(tst_autonumincrementwidth tst_autonumincrementwidth.cpp)
# Opening a project before the elements panel's first reload() left its tree
# item detached, and selecting the item's first child crashed in QTreeModel
# (pre-existing since a82f6de23).
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "qetapptest.h"
#include <QDockWidget>
#include <QProxyStyle>
#include <QSpinBox>
namespace {
// Spin boxes as wide as the Windows 11 style draws them: its up and down
// buttons sit side by side, so a spin box needs far more room than with
// the buttons stacked.
class WideSpinBoxStyle : public QProxyStyle
{
public:
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
const QSize &size, const QWidget *widget) const override
{
QSize s = QProxyStyle::sizeFromContents(type, option, size, widget);
if (type == CT_SpinBox)
s.rwidth() += 40;
return s;
}
};
}
// The Increment spin boxes of the Auto numbering panel get the width their
// style asks for (#1566). A fixed 55 px maximum cut off the number on
// Windows.
class tst_autonumincrementwidth : public QObject
{
Q_OBJECT
private slots:
void incrementFitsItsStyle()
{
QApplication::setStyle(new WideSpinBoxStyle);
QETDiagramEditor *editor = QetAppTest::editor();
QVERIFY(editor);
editor->resize(1600, 1000);
editor->show();
QVERIFY(QTest::qWaitForWindowExposed(editor));
const QStringList names{"m_conductor_increase_sb",
"m_element_increase_sb",
"m_folio_increase_sb"};
for (const QString &name : names) {
auto spin_box = editor->findChild<QSpinBox *>(name);
QVERIFY2(spin_box, qPrintable(name));
QVERIFY2(spin_box->isVisible(), qPrintable(name));
QVERIFY2(spin_box->width() >= spin_box->minimumSizeHint().width(),
qPrintable(QString("%1 is %2 px, its style needs %3 px")
.arg(name)
.arg(spin_box->width())
.arg(spin_box->minimumSizeHint().width())));
}
}
};
QET_APP_TEST_MAIN(tst_autonumincrementwidth)
#include "tst_autonumincrementwidth.moc"