diff --git a/autotests/kmessagewidgetautotest.h b/autotests/kmessagewidgetautotest.h --- a/autotests/kmessagewidgetautotest.h +++ b/autotests/kmessagewidgetautotest.h @@ -40,6 +40,7 @@ void testOverlappingDoubleHide(); void testHideWithNotYetShownParent(); void testNonAnimatedShowAfterAnimatedHide(); + void testResizeEvent(); }; #endif diff --git a/autotests/kmessagewidgetautotest.cpp b/autotests/kmessagewidgetautotest.cpp --- a/autotests/kmessagewidgetautotest.cpp +++ b/autotests/kmessagewidgetautotest.cpp @@ -22,6 +22,9 @@ #include #include +#include +#include +#include #include QTEST_MAIN(KMessageWidgetTest) @@ -250,3 +253,32 @@ w.show(); CHECK_FULLY_VISIBLE } + +void KMessageWidgetTest::testResizeEvent() +{ + QWidget parent; + QVBoxLayout layout(&parent); + KMessageWidget w(QStringLiteral("Erat conubia luctus, nisi in amet penatibus cursus, maecenas vitae magna orci. Pellentesque. Integer nam, semper a, inceptos dui. Tempor ultrices morbi eleifend ipsum a nibh parturient at, tristique condimentum, est. Venenatis eget sed diam vestibulum."), &parent); + w.setWordWrap(true); + w.hide(); + layout.addWidget(&w); + + QListWidget bw(&parent); + bw.addItem(QStringLiteral("Test 1")); + bw.addItem(QStringLiteral("Test 2")); + bw.addItem(QStringLiteral("Test 2")); + layout.addWidget(&bw); + + parent.show(); + w.animatedShow(); + QTest::qWait(overlappingWaitingTime * 2); + CHECK_FULLY_VISIBLE + + parent.resize(1000, parent.height()); + QTest::qWait(overlappingWaitingTime * 2); + CHECK_FULLY_VISIBLE + + parent.resize(500, parent.height()); + QTest::qWait(overlappingWaitingTime * 2); + CHECK_FULLY_VISIBLE +} diff --git a/src/kmessagewidget.cpp b/src/kmessagewidget.cpp --- a/src/kmessagewidget.cpp +++ b/src/kmessagewidget.cpp @@ -353,6 +353,10 @@ if (d->timeLine->state() == QTimeLine::NotRunning) { d->content->resize(width(), d->bestContentHeight()); + + if (height() != d->content->height()) { + setFixedHeight(d->content->height()); + } } }