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 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog" >
<property name="geometry" >
<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" >
<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>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<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" >
<property name="text" >
<string>Modeless Dialog</string>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="0">
<widget class="QPushButton" name="siblingApplicationModalButton">
<property name="text">
<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>
<widget class="QPushButton" name="windowModalButton" >
<property name="text" >
<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" >
<property name="text" >
<string>Window Modal Dialog w/ no parent</string>
<item row="7" column="1">
<widget class="QPushButton" name="applicationModalChildButton">
<property name="text">
<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>
<widget class="QPushButton" name="siblingWindowModalButton" >
<property name="text" >
<item row="2" column="0">
<widget class="QPushButton" name="siblingWindowModalButton">
<property name="text">
<string>Sibling Window Modal Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applicationModalButton" >
<property name="text" >
<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>
<widget class="QPushButton" name="applicationModalNoParentButton" >
<property name="text" >
<string>Application Modal Dialog w/ no parent</string>
<item row="1" column="1">
<widget class="QPushButton" name="windowModalNoParentButton">
<property name="text">
<string>Window Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applicationModalChildButton" >
<property name="text" >
<string>Application Modal Child Widget (hidden after 5 seconds)</string>
<item row="7" column="0">
<widget class="QPushButton" name="windowModalChildButton">
<property name="text">
<string>Window Modal Child Widget</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="siblingApplicationModalButton" >
<property name="text" >
<string>Sibling Application Modal Dialog</string>
<item row="4" column="1">
<widget class="QPushButton" name="applicationModalNoParentButton">
<property name="text">
<string>Application Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<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>Note: Modal Child Widgets are invisible and hidden after 5 seconds.</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="modelessButton">
<property name="text">
<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>
@ -108,19 +127,13 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<layout class="QHBoxLayout">
<item>
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>31</height>
@ -129,8 +142,8 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton" >
<property name="text" >
<widget class="QPushButton" name="okButton">
<property name="text">
<string>Close</string>
</property>
</widget>
@ -139,7 +152,6 @@
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
@ -148,11 +160,11 @@
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>397</x>
<y>338</y>
</hint>
<hint type="destinationlabel" >
<hint type="destinationlabel">
<x>96</x>
<y>254</y>
</hint>

View File

@ -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)
{

View File

@ -1,106 +1,125 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Widget</class>
<widget class="QWidget" name="Widget" >
<property name="geometry" >
<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" >
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>40</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>New Window Type</string>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<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>
<widget class="QPushButton" name="windowButton" >
<property name="text" >
<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>
<widget class="QPushButton" name="groupLeaderButton" >
<property name="text" >
<item row="0" column="1">
<widget class="QPushButton" name="groupLeaderButton">
<property name="text">
<string>Window (Group Leader)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modelessButton" >
<property name="text" >
<item row="1" column="0">
<widget class="QPushButton" name="modelessButton">
<property name="text">
<string>Modeless Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modelessNoParentButton" >
<property name="text" >
<string>Modeless Dialog w/ no parent</string>
<item row="1" column="1">
<widget class="QPushButton" name="modelessNoParentButton">
<property name="text">
<string>Modeless Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="windowModalButton" >
<property name="text" >
<item row="2" column="0">
<widget class="QPushButton" name="windowModalButton">
<property name="text">
<string>Window Modal Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="windowModalNoParentButton" >
<property name="text" >
<string>Window Modal Dialog w/ no parent</string>
<item row="2" column="1">
<widget class="QPushButton" name="windowModalNoParentButton">
<property name="text">
<string>Window Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="windowModalChildButton" >
<property name="text" >
<string>Window Modal Child Widget (hidden after 5 seconds)</string>
<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>Application Modal Dialogs use exec()</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applicationModalButton" >
<property name="text" >
<item row="4" column="0">
<widget class="QPushButton" name="applicationModalButton">
<property name="text">
<string>Application Modal Dialog</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applicationModalNoParentButton" >
<property name="text" >
<string>Application Modal Dialog w/ no parent</string>
<item row="4" column="1">
<widget class="QPushButton" name="applicationModalNoParentButton">
<property name="text">
<string>Application Modal Dialog (no parent)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="applicationModalChildButton" >
<property name="text" >
<string>Application Modal Child Widget (hidden after 5 seconds)</string>
<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</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>