summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-05-04 14:35:39 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-06 13:56:54 +0000
commit29dea7f3173783a97f85d84623241d8dc388c701 (patch)
treea959a176745da674b037c6cd5d98ae15c6c3e7c9 /tests
parent3b78f6d94b309708c7cd8961b09a6cfcc5caa022 (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. 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> (cherry picked from commit 8886462872db9cdab4d7683823fd24fb9f8920c4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp43
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"