diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-04 14:35:39 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-06 13:08:14 +0200 |
commit | 8886462872db9cdab4d7683823fd24fb9f8920c4 (patch) | |
tree | b4120543f360d98cc01f49e55a6f93028374ea06 /tests/auto/widgets/widgets/qmdiarea | |
parent | f8c1d339ecc905e8ee442129cb54a50be7ce1c24 (diff) |
QMdiArea: Fix top level window title when using DontMaximizeSubWindowOnActivation
When trying to find the original window title, check for another
maximized sub window and use its title. Protect the calls to
setWindowTitle to prevent the original title from being cleared.
Pick-to: 6.1 5.15
Fixes: QTBUG-92240
Change-Id: I55175382ab261b4cf8b5528304adaaec4fbe2c31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qmdiarea')
-rw-r--r-- | tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 6df7c74bdc..225b349f08 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ @@ -281,6 +281,8 @@ private slots: void nativeSubWindows(); void task_209615(); void task_236750(); + void qtbug92240_title_data(); + void qtbug92240_title(); private: QMdiSubWindow *activeWindow; @@ -2697,6 +2699,45 @@ void tst_QMdiArea::task_236750() subWindow->showMinimized(); } +// QTBUG-92240: When subwindows are maximized, their title is supposed to +// appear on the main window. When DontMaximizeSubWindowOnActivation was set, +// titles of previously created maximized windows interfered, resulting in +// "QTBUG-92240 - [1] - [2]". +void tst_QMdiArea::qtbug92240_title_data() +{ + QTest::addColumn<bool>("dontMaximize"); + QTest::newRow("default") << false; + QTest::newRow("dontMaximize") << true; +} + +void tst_QMdiArea::qtbug92240_title() +{ + QFETCH(bool, dontMaximize); + +#ifdef Q_OS_MACOS + QSKIP("Not supported on macOS"); +#endif + + QMainWindow w; + const QString title = QStringLiteral("QTBUG-92240"); + w.setWindowTitle(title); + w.menuBar()->addMenu(QStringLiteral("File")); + w.show(); + + auto *mdiArea = new QMdiArea; + w.setCentralWidget(mdiArea); + if (dontMaximize) + mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation); + auto *sw1 = mdiArea->addSubWindow(new QWidget); + sw1->setWindowTitle(QStringLiteral("1")); + sw1->showMaximized(); + QTRY_COMPARE(w.windowTitle(), QLatin1String("QTBUG-92240 - [1]")); + auto *sw2 = mdiArea->addSubWindow(new QWidget); + sw2->setWindowTitle(QStringLiteral("2")); + sw2->showMaximized(); + QTRY_COMPARE(w.windowTitle(), QLatin1String("QTBUG-92240 - [2]")); +} + QTEST_MAIN(tst_QMdiArea) #include "tst_qmdiarea.moc" |