QMdiArea: fix initial single-sub-window in TabbedView
This is somewhat of a corner case, where there is a single sub-window, setViewMode(TabbedView) is called before addSubWindow(), and the latter is called before show(). The sub-window would be active, i.e. subwindow->d_func()->isActive is true and QMdiArea::aboutToActivate() is emitted, but QMA::emitSubWindowActivated() is never called for that sub-window, resulting in that sub-window shown as unmaximized/with-a-title-bar instead of as maximized/tabbed as is expected in TabbedView. Pick-to: 6.6 6.5 Fixes: QTBUG-114188 Change-Id: Ia7b2cfd07c51867707866a1f99f70129bbdc0e3e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
17372faf3f
commit
c94bcecb22
@ -2376,6 +2376,11 @@ void QMdiArea::showEvent(QShowEvent *showEvent)
|
||||
for (QMdiSubWindow *window : copy) {
|
||||
if (!window)
|
||||
continue;
|
||||
if (d->viewMode == TabbedView && window->d_func()->isActive && !d->active) {
|
||||
d->showActiveWindowMaximized = true;
|
||||
d->emitWindowActivated(window); // Also maximizes the window
|
||||
continue;
|
||||
}
|
||||
if (!window->testAttribute(Qt::WA_Resized)) {
|
||||
QSize newSize(window->sizeHint().boundedTo(viewport()->size()));
|
||||
window->resize(newSize.expandedTo(qSmartMinSize(window)));
|
||||
|
@ -101,6 +101,7 @@ private:
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_enterInteractiveMode())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_processFocusChanged(QWidget *, QWidget *))
|
||||
friend class QMdiAreaPrivate;
|
||||
friend class QMdiArea;
|
||||
#if QT_CONFIG(tabbar)
|
||||
friend class QMdiAreaTabBar;
|
||||
#endif
|
||||
|
@ -260,6 +260,7 @@ private slots:
|
||||
void task_236750();
|
||||
void qtbug92240_title_data();
|
||||
void qtbug92240_title();
|
||||
void tabbedview_singleSubWindow();
|
||||
void tabbedview_activefirst();
|
||||
void tabbedview_activesecond();
|
||||
void tabbedview_activethird();
|
||||
@ -2728,6 +2729,21 @@ void tst_QMdiArea::qtbug92240_title()
|
||||
QTRY_COMPARE(w.windowTitle(), QLatin1String("QTBUG-92240 - [2]"));
|
||||
}
|
||||
|
||||
void tst_QMdiArea::tabbedview_singleSubWindow()
|
||||
{
|
||||
// With only one sub-window, setViewMode() before addSubWindow(); and addSubWindow()
|
||||
// before show(), ensure the sub-window is properly activated.
|
||||
QMdiArea mdiArea;
|
||||
mdiArea.setViewMode(QMdiArea::TabbedView);
|
||||
auto *w = new QWidget(&mdiArea);
|
||||
mdiArea.addSubWindow(w);
|
||||
mdiArea.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
|
||||
auto *sub = mdiArea.subWindowList().at(0);
|
||||
QCOMPARE(mdiArea.activeSubWindow(), sub);
|
||||
QVERIFY(sub->isMaximized());
|
||||
}
|
||||
|
||||
static void setupMdiAreaWithTabbedView(QMdiArea &mdiArea)
|
||||
{
|
||||
mdiArea.setViewMode(QMdiArea::TabbedView);
|
||||
|
Loading…
Reference in New Issue
Block a user