From 448b9c00be5f6a2e61cc6f3d673e8669d5b350b4 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 28 Mar 2012 08:04:26 +0200 Subject: [PATCH] windowmodality test: Allow exec() with ApplicationModal dialogs Add a checkbox to the main window and dialog .ui files to allow exec()ing ApplicationModal dialogs. Change-Id: I4d8a4be136d0f6b688938a8020a6ebcc69a9dfe8 Reviewed-by: Friedemann Kleint --- tests/manual/windowmodality/dialog.ui | 178 ++++++++++++++------------ tests/manual/windowmodality/main.cpp | 12 +- tests/manual/windowmodality/widget.ui | 142 +++++++++++--------- 3 files changed, 184 insertions(+), 148 deletions(-) diff --git a/tests/manual/windowmodality/dialog.ui b/tests/manual/windowmodality/dialog.ui index 91c6bf2dc9..65129ce574 100644 --- a/tests/manual/windowmodality/dialog.ui +++ b/tests/manual/windowmodality/dialog.ui @@ -1,106 +1,125 @@ - - - - + + Dialog - - + + 0 0 - 400 - 420 + 565 + 361 - + Dialog - - - 9 - - - 6 - + - - - Modality Types + + + Select the type of dialog to create: - - - 9 - - - 6 - - - - - Modeless Dialog + + + + + Sibling Application Modal Dialog - - - - Modeless Dialog w/ no parent - - - - - - + + + Window Modal Dialog - - - - Window Modal Dialog w/ no parent + + + + Application Modal Child Widget - - - - Window Modal Child Widget (hidden after 5 seconds) - - - - - - + + + Sibling Window Modal Dialog - - - + + + + Modeless Dialog (no parent) + + + + + + Application Modal - - - - Application Modal Dialog w/ no parent + + + + Window Modal Dialog (no parent) - - - - Application Modal Child Widget (hidden after 5 seconds) + + + + Window Modal Child Widget - - - - Sibling Application Modal Dialog + + + + Application Modal Dialog (no parent) + + + + + + + + 0 + 0 + + + + + 11 + + + + Note: Modal Child Widgets are invisible and hidden after 5 seconds. + + + + + + + Modeless Dialog + + + + + + + + 11 + + + + Application Modal Dialogs use exec() + + + true @@ -108,19 +127,13 @@ - - - 0 - - - 6 - + - + Qt::Horizontal - + 131 31 @@ -129,8 +142,8 @@ - - + + Close @@ -139,7 +152,6 @@ - @@ -148,11 +160,11 @@ Dialog accept() - + 397 338 - + 96 254 diff --git a/tests/manual/windowmodality/main.cpp b/tests/manual/windowmodality/main.cpp index db3a0b072f..cfd7658064 100644 --- a/tests/manual/windowmodality/main.cpp +++ b/tests/manual/windowmodality/main.cpp @@ -93,7 +93,10 @@ private: Dialog *dialog = new Dialog(parent); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setWindowModality(windowModality); - dialog->show(); + if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) + dialog->exec(); + else + dialog->show(); } void newChildWidget(Qt::WindowModality windowModality) { @@ -107,7 +110,7 @@ private: bool event(QEvent *event) { if (event->type() == QEvent::WindowBlocked) - setPalette(Qt::red); + setPalette(Qt::darkGray); else if (event->type() == QEvent::WindowUnblocked) setPalette(QPalette()); return QWidget::event(event); @@ -156,7 +159,10 @@ private: Dialog *dialog = new Dialog(withParent ? this : 0); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setWindowModality(windowModality); - dialog->show(); + if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) + dialog->exec(); + else + dialog->show(); } void newChildWidget(Qt::WindowModality windowModality) { diff --git a/tests/manual/windowmodality/widget.ui b/tests/manual/windowmodality/widget.ui index cc3bf854ec..96158025a2 100644 --- a/tests/manual/windowmodality/widget.ui +++ b/tests/manual/windowmodality/widget.ui @@ -1,106 +1,125 @@ - - - - + + Widget - - + + 0 0 - 568 - 473 + 558 + 268 - + Form - - - 40 - - - 6 - + - - - New Window Type + + + Select the type of window to create: - - - 8 - - - 6 - - - - + + + + Window - - - + + + Window (Group Leader) - - - + + + Modeless Dialog - - - - Modeless Dialog w/ no parent + + + + Modeless Dialog (no parent) - - - + + + Window Modal Dialog - - - - Window Modal Dialog w/ no parent + + + + Window Modal Dialog (no parent) - - - - Window Modal Child Widget (hidden after 5 seconds) + + + + + 11 + + + + Application Modal Dialogs use exec() + + + true - - - + + + Application Modal Dialog - - - - Application Modal Dialog w/ no parent + + + + Application Modal Dialog (no parent) - - - - Application Modal Child Widget (hidden after 5 seconds) + + + + + 0 + 0 + + + + + 11 + + + + Note: Modal Child Widgets are invisible and hidden after 5 seconds. + + + + + + + Application Modal Child Widget + + + + + + + Window Modal Child Widget @@ -109,7 +128,6 @@ -