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 <Friedemann.Kleint@nokia.com>
This commit is contained in:
Bradley T. Hughes 2012-03-28 08:04:26 +02:00 committed by Qt by Nokia
parent 6c45614cbe
commit 448b9c00be
3 changed files with 184 additions and 148 deletions

View File

@ -1,106 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>420</height>
<width>565</width>
<height>361</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Modality Types</string>
<string>Select the type of dialog to create:</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="modelessButton" >
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="0">
<widget class="QPushButton" name="siblingApplicationModalButton">
<property name="text">
<string>Modeless Dialog</string>
<string>Sibling Application Modal Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modelessNoParentButton" >
<property name="text" >
<string>Modeless Dialog w/ no parent</string>
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QPushButton" name="windowModalButton">
<property name="text">
<string>Window Modal Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="windowModalNoParentButton" >
<item row="7" column="1">
<widget class="QPushButton" name="applicationModalChildButton">
<property name="text">
<string>Window Modal Dialog w/ no parent</string>
<string>Application Modal Child Widget</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="windowModalChildButton" >
<property name="text" >
<string>Window Modal Child Widget (hidden after 5 seconds)</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QPushButton" name="siblingWindowModalButton">
<property name="text">
<string>Sibling Window Modal Dialog</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QPushButton" name="modelessNoParentButton">
<property name="text">
<string>Modeless Dialog (no parent)</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="applicationModalButton">
<property name="text">
<string>Application Modal</string>
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QPushButton" name="windowModalNoParentButton">
<property name="text">
<string>Window Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="windowModalChildButton">
<property name="text">
<string>Window Modal Child Widget</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="applicationModalNoParentButton">
<property name="text">
<string>Application Modal Dialog w/ no parent</string>
<string>Application Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applicationModalChildButton" >
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="modalChildWidgetInfoLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Application Modal Child Widget (hidden after 5 seconds)</string>
<string>Note: Modal Child Widgets are invisible and hidden after 5 seconds.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="siblingApplicationModalButton" >
<item row="0" column="0">
<widget class="QPushButton" name="modelessButton">
<property name="text">
<string>Sibling Application Modal Dialog</string>
<string>Modeless Dialog</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="applicationModalUseExecCheckBox">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Application Modal Dialogs use exec()</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
@ -109,18 +128,12 @@
</item>
<item>
<layout class="QHBoxLayout">
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>31</height>
@ -139,7 +152,6 @@
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>

View File

@ -93,6 +93,9 @@ private:
Dialog *dialog = new Dialog(parent);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowModality(windowModality);
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,6 +159,9 @@ private:
Dialog *dialog = new Dialog(withParent ? this : 0);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowModality(windowModality);
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked())
dialog->exec();
else
dialog->show();
}
void newChildWidget(Qt::WindowModality windowModality)

View File

@ -1,106 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Widget</class>
<widget class="QWidget" name="Widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>473</height>
<width>558</width>
<height>268</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout">
<property name="margin" >
<number>40</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>New Window Type</string>
<string>Select the type of window to create:</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>8</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="windowButton">
<property name="text">
<string>Window</string>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QPushButton" name="groupLeaderButton">
<property name="text">
<string>Window (Group Leader)</string>
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QPushButton" name="modelessButton">
<property name="text">
<string>Modeless Dialog</string>
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QPushButton" name="modelessNoParentButton">
<property name="text">
<string>Modeless Dialog w/ no parent</string>
<string>Modeless Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QPushButton" name="windowModalButton">
<property name="text">
<string>Window Modal Dialog</string>
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QPushButton" name="windowModalNoParentButton">
<property name="text">
<string>Window Modal Dialog w/ no parent</string>
<string>Window Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="windowModalChildButton" >
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="applicationModalUseExecCheckBox">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Window Modal Child Widget (hidden after 5 seconds)</string>
<string>Application Modal Dialogs use exec()</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<item row="4" column="0">
<widget class="QPushButton" name="applicationModalButton">
<property name="text">
<string>Application Modal Dialog</string>
</property>
</widget>
</item>
<item>
<item row="4" column="1">
<widget class="QPushButton" name="applicationModalNoParentButton">
<property name="text">
<string>Application Modal Dialog w/ no parent</string>
<string>Application Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="modalChildWidgetInfoLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Note: Modal Child Widgets are invisible and hidden after 5 seconds.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QPushButton" name="applicationModalChildButton">
<property name="text">
<string>Application Modal Child Widget (hidden after 5 seconds)</string>
<string>Application Modal Child Widget</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="windowModalChildButton">
<property name="text">
<string>Window Modal Child Widget</string>
</property>
</widget>
</item>
@ -109,7 +128,6 @@
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>