diff --git a/sources/autoNum/ui/autonumberingdockwidget.ui b/sources/autoNum/ui/autonumberingdockwidget.ui index 8fc90c33d..ac0e366c5 100644 --- a/sources/autoNum/ui/autonumberingdockwidget.ui +++ b/sources/autoNum/ui/autonumberingdockwidget.ui @@ -92,12 +92,6 @@ - - - 55 - 16777215 - - Increment: the value added to the counter each time a new number is dialled @@ -179,12 +173,6 @@ - - - 55 - 16777215 - - Increment: the value added to the counter each time a new number is dialled @@ -255,12 +243,6 @@ - - - 55 - 16777215 - - Increment: the value added to the counter each time a new number is dialled diff --git a/tests/qttest/CMakeLists.txt b/tests/qttest/CMakeLists.txt index 496e381ee..ce15d0f30 100644 --- a/tests/qttest/CMakeLists.txt +++ b/tests/qttest/CMakeLists.txt @@ -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). diff --git a/tests/qttest/tst_autonumincrementwidth.cpp b/tests/qttest/tst_autonumincrementwidth.cpp new file mode 100644 index 000000000..23b0f0150 --- /dev/null +++ b/tests/qttest/tst_autonumincrementwidth.cpp @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include "qetapptest.h" + +#include +#include +#include + +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(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"