Update tests/manual/windowmodality to test native dialogs
Window- and ApplicationModal native dialogs need to send WindowBlocked and WindowUnblocked events as well. This will let us test that they work properly. Change-Id: Iaa4ddb79bb0872f9ab1e61336a5decb262472283 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
parent
cff46983a8
commit
3fa70d9c74
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>574</width>
|
<width>515</width>
|
||||||
<height>300</height>
|
<height>480</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -20,49 +20,140 @@
|
|||||||
<string>Select the type of dialog to create:</string>
|
<string>Select the type of dialog to create:</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="6" column="0">
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="QPushButton" name="siblingApplicationModalButton">
|
<widget class="QCheckBox" name="useThisAsParentCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Application Modal Dialog (sibling)</string>
|
<string>Use this window as parent for newly created dialogs</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QPushButton" name="windowModalButton">
|
<widget class="QPushButton" name="modelessCustomDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Window Modal Dialog</string>
|
<string>Custom Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QPushButton" name="applicationModalNoParentButton">
|
<widget class="QPushButton" name="modelessColorDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Application Modal Dialog (no parent)</string>
|
<string>Color Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<widget class="QPushButton" name="modelessFontDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QPushButton" name="applicationModalButton">
|
<widget class="QPushButton" name="windowModalCustomDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Application Modal</string>
|
<string>Custom Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QPushButton" name="windowModalNoParentButton">
|
<widget class="QPushButton" name="windowModalColorDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Window Modal Dialog (no parent)</string>
|
<string>Color Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="5" column="2">
|
||||||
<widget class="QPushButton" name="modelessNoParentButton">
|
<widget class="QPushButton" name="windowModalFileDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Modeless Dialog (no parent)</string>
|
<string>File Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="6" column="0">
|
||||||
|
<widget class="QPushButton" name="windowModalFontDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QPushButton" name="windowModalPageSetupDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Page Setup Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="2">
|
||||||
|
<widget class="QPushButton" name="windowModalPrintDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Print Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
|
<widget class="QPushButton" name="applicationModalCustomDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Custom Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="1">
|
||||||
|
<widget class="QPushButton" name="applicationModalColorDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="2">
|
||||||
|
<widget class="QPushButton" name="applicationModalFileDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="0">
|
||||||
|
<widget class="QPushButton" name="applicationModalFontDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="1">
|
||||||
|
<widget class="QPushButton" name="applicationModalPageSetupDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Page Setup Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="2">
|
||||||
|
<widget class="QPushButton" name="applicationModalPrintDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Print Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="applicationModalNoteLabel">
|
||||||
|
<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>Native Application Modal Dialogs use static API instead of exec()</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0" colspan="3">
|
||||||
<widget class="QCheckBox" name="applicationModalUseExecCheckBox">
|
<widget class="QCheckBox" name="applicationModalUseExecCheckBox">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
@ -77,17 +168,91 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="7" column="0" colspan="3">
|
||||||
<widget class="QPushButton" name="modelessButton">
|
<widget class="QLabel" name="windowModalNoteLabel">
|
||||||
|
<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">
|
<property name="text">
|
||||||
<string>Modeless Dialog</string>
|
<string>Native Window Modal Dialogs use open()</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="8" column="0" colspan="3">
|
||||||
<widget class="QPushButton" name="siblingWindowModalButton">
|
<widget class="QLabel" name="applicationModalDialogsLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Window Modal Dialog (sibling)</string>
|
<string>Application Modal Dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="windowModalDialogsLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Window Modal Dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="modelessDialogsLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Modeless (Non-Modal) Dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="3">
|
||||||
|
<widget class="QCheckBox" name="createSiblingDialogCheckBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Create new dialogs as siblings of this dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -114,6 +279,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Close</string>
|
<string>Close</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -138,5 +306,21 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>useThisAsParentCheckBox</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>createSiblingDialogCheckBox</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>260</x>
|
||||||
|
<y>39</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>260</x>
|
||||||
|
<y>60</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -44,53 +44,124 @@
|
|||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
|
#include <QtWidgets/QColorDialog>
|
||||||
|
#include <QtWidgets/QFileDialog>
|
||||||
|
#include <QtWidgets/QFontDialog>
|
||||||
|
#include <QtPrintSupport/QPageSetupDialog>
|
||||||
|
#include <QtPrintSupport/QPrintDialog>
|
||||||
|
|
||||||
class Dialog : public QDialog, public Ui::Dialog
|
enum DialogType
|
||||||
|
{
|
||||||
|
CustomDialogType,
|
||||||
|
ColorDialogType,
|
||||||
|
FileDialogType,
|
||||||
|
FontDialogType,
|
||||||
|
PageSetupDialogType,
|
||||||
|
PrintDialogType
|
||||||
|
};
|
||||||
|
|
||||||
|
class CustomDialog : public QDialog, public Ui::Dialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Dialog(QWidget *parent = 0)
|
CustomDialog(QWidget *parent = 0)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
connect(this, SIGNAL(finished(int)), SLOT(dialogFinished(int)));
|
|
||||||
connect(this, SIGNAL(accepted()), SLOT(dialogAccepted()));
|
// hide the "Create new dialogs as siblings of this dialog" button when
|
||||||
connect(this, SIGNAL(rejected()), SLOT(dialogRejected()));
|
// we don't have a parent of our own (they would be parentless anyway)
|
||||||
|
if (!parent) {
|
||||||
|
createSiblingDialogCheckBox->setChecked(false);
|
||||||
|
createSiblingDialogCheckBox->setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_modelessButton_clicked()
|
void on_modelessCustomDialogButton_clicked()
|
||||||
{ newDialog(Qt::NonModal, this); }
|
{ newDialog(CustomDialogType, Qt::NonModal); }
|
||||||
void on_modelessNoParentButton_clicked()
|
void on_modelessColorDialogButton_clicked()
|
||||||
{ newDialog(Qt::NonModal, 0); }
|
{ newDialog(ColorDialogType, Qt::NonModal); }
|
||||||
void on_windowModalButton_clicked()
|
void on_modelessFontDialogButton_clicked()
|
||||||
{ newDialog(Qt::WindowModal, this); }
|
{ newDialog(FontDialogType, Qt::NonModal); }
|
||||||
void on_windowModalNoParentButton_clicked()
|
|
||||||
{ newDialog(Qt::WindowModal, 0); }
|
|
||||||
void on_siblingWindowModalButton_clicked()
|
|
||||||
{ newDialog(Qt::WindowModal, parentWidget()); }
|
|
||||||
void on_applicationModalButton_clicked()
|
|
||||||
{ newDialog(Qt::ApplicationModal, this); }
|
|
||||||
void on_applicationModalNoParentButton_clicked()
|
|
||||||
{ newDialog(Qt::ApplicationModal, 0); }
|
|
||||||
void on_siblingApplicationModalButton_clicked()
|
|
||||||
{ newDialog(Qt::ApplicationModal, parentWidget()); }
|
|
||||||
|
|
||||||
void dialogFinished(int result)
|
void on_windowModalCustomDialogButton_clicked()
|
||||||
{ qDebug() << "Dialog finished, result" << result; }
|
{ newDialog(CustomDialogType, Qt::WindowModal); }
|
||||||
void dialogAccepted()
|
void on_windowModalColorDialogButton_clicked()
|
||||||
{ qDebug() << "Dialog accepted"; }
|
{ newDialog(ColorDialogType, Qt::WindowModal); }
|
||||||
void dialogRejected()
|
void on_windowModalFileDialogButton_clicked()
|
||||||
{ qDebug() << "Dialog rejected"; }
|
{ newDialog(FileDialogType, Qt::WindowModal); }
|
||||||
|
void on_windowModalFontDialogButton_clicked()
|
||||||
|
{ newDialog(FontDialogType, Qt::WindowModal); }
|
||||||
|
void on_windowModalPageSetupDialogButton_clicked()
|
||||||
|
{ newDialog(PageSetupDialogType, Qt::WindowModal); }
|
||||||
|
void on_windowModalPrintDialogButton_clicked()
|
||||||
|
{ newDialog(PrintDialogType, Qt::WindowModal); }
|
||||||
|
|
||||||
|
void on_applicationModalCustomDialogButton_clicked()
|
||||||
|
{ newDialog(CustomDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalColorDialogButton_clicked()
|
||||||
|
{ newDialog(ColorDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalFileDialogButton_clicked()
|
||||||
|
{ newDialog(FileDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalFontDialogButton_clicked()
|
||||||
|
{ newDialog(FontDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalPageSetupDialogButton_clicked()
|
||||||
|
{ newDialog(PageSetupDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalPrintDialogButton_clicked()
|
||||||
|
{ newDialog(PrintDialogType, Qt::ApplicationModal); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void newDialog(Qt::WindowModality windowModality, QWidget *parent)
|
void newDialog(DialogType dialogType, Qt::WindowModality windowModality)
|
||||||
{
|
{
|
||||||
Dialog *dialog = new Dialog(parent);
|
QWidget *parent = 0;
|
||||||
|
if (useThisAsParentCheckBox->isChecked())
|
||||||
|
parent = this;
|
||||||
|
else if (createSiblingDialogCheckBox->isChecked())
|
||||||
|
parent = parentWidget();
|
||||||
|
|
||||||
|
QDialog *dialog;
|
||||||
|
switch (dialogType) {
|
||||||
|
case CustomDialogType:
|
||||||
|
dialog = new CustomDialog(parent);
|
||||||
|
break;
|
||||||
|
case ColorDialogType:
|
||||||
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) {
|
||||||
|
QColorDialog::getColor(Qt::white, parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialog = new QColorDialog(parent);
|
||||||
|
break;
|
||||||
|
case FileDialogType:
|
||||||
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) {
|
||||||
|
QFileDialog::getOpenFileName(parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialog = new QFileDialog(parent);
|
||||||
|
break;
|
||||||
|
case FontDialogType:
|
||||||
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) {
|
||||||
|
bool unused = false;
|
||||||
|
QFontDialog::getFont(&unused, parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialog = new QFontDialog(parent);
|
||||||
|
break;
|
||||||
|
case PageSetupDialogType:
|
||||||
|
dialog = new QPageSetupDialog(parent);
|
||||||
|
break;
|
||||||
|
case PrintDialogType:
|
||||||
|
dialog = new QPrintDialog(parent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->setWindowModality(windowModality);
|
dialog->setWindowModality(windowModality);
|
||||||
|
|
||||||
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked())
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked())
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
|
else if (windowModality == Qt::WindowModal)
|
||||||
|
dialog->open();
|
||||||
else
|
else
|
||||||
dialog->show();
|
dialog->show();
|
||||||
}
|
}
|
||||||
@ -123,27 +194,89 @@ private slots:
|
|||||||
w->setAttribute(Qt::WA_GroupLeader);
|
w->setAttribute(Qt::WA_GroupLeader);
|
||||||
w->show();
|
w->show();
|
||||||
}
|
}
|
||||||
void on_modelessButton_clicked()
|
|
||||||
{ newDialog(Qt::NonModal); }
|
void on_modelessCustomDialogButton_clicked()
|
||||||
void on_modelessNoParentButton_clicked()
|
{ newDialog(CustomDialogType, Qt::NonModal); }
|
||||||
{ newDialog(Qt::NonModal, false); }
|
void on_modelessColorDialogButton_clicked()
|
||||||
void on_windowModalButton_clicked()
|
{ newDialog(ColorDialogType, Qt::NonModal); }
|
||||||
{ newDialog(Qt::WindowModal); }
|
void on_modelessFontDialogButton_clicked()
|
||||||
void on_windowModalNoParentButton_clicked()
|
{ newDialog(FontDialogType, Qt::NonModal); }
|
||||||
{ newDialog(Qt::WindowModal, false); }
|
|
||||||
void on_applicationModalButton_clicked()
|
void on_windowModalCustomDialogButton_clicked()
|
||||||
{ newDialog(Qt::ApplicationModal); }
|
{ newDialog(CustomDialogType, Qt::WindowModal); }
|
||||||
void on_applicationModalNoParentButton_clicked()
|
void on_windowModalColorDialogButton_clicked()
|
||||||
{ newDialog(Qt::ApplicationModal, false); }
|
{ newDialog(ColorDialogType, Qt::WindowModal); }
|
||||||
|
void on_windowModalFileDialogButton_clicked()
|
||||||
|
{ newDialog(FileDialogType, Qt::WindowModal); }
|
||||||
|
void on_windowModalFontDialogButton_clicked()
|
||||||
|
{ newDialog(FontDialogType, Qt::WindowModal); }
|
||||||
|
void on_windowModalPageSetupDialogButton_clicked()
|
||||||
|
{ newDialog(PageSetupDialogType, Qt::WindowModal); }
|
||||||
|
void on_windowModalPrintDialogButton_clicked()
|
||||||
|
{ newDialog(PrintDialogType, Qt::WindowModal); }
|
||||||
|
|
||||||
|
void on_applicationModalCustomDialogButton_clicked()
|
||||||
|
{ newDialog(CustomDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalColorDialogButton_clicked()
|
||||||
|
{ newDialog(ColorDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalFileDialogButton_clicked()
|
||||||
|
{ newDialog(FileDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalFontDialogButton_clicked()
|
||||||
|
{ newDialog(FontDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalPageSetupDialogButton_clicked()
|
||||||
|
{ newDialog(PageSetupDialogType, Qt::ApplicationModal); }
|
||||||
|
void on_applicationModalPrintDialogButton_clicked()
|
||||||
|
{ newDialog(PrintDialogType, Qt::ApplicationModal); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void newDialog(Qt::WindowModality windowModality, bool withParent = true)
|
void newDialog(DialogType dialogType, Qt::WindowModality windowModality)
|
||||||
{
|
{
|
||||||
Dialog *dialog = new Dialog(withParent ? this : 0);
|
QWidget *parent = 0;
|
||||||
|
if (useThisAsParentCheckBox->isChecked())
|
||||||
|
parent = this;
|
||||||
|
|
||||||
|
QDialog *dialog;
|
||||||
|
switch (dialogType) {
|
||||||
|
case CustomDialogType:
|
||||||
|
dialog = new CustomDialog(parent);
|
||||||
|
break;
|
||||||
|
case ColorDialogType:
|
||||||
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) {
|
||||||
|
QColorDialog::getColor(Qt::white, parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialog = new QColorDialog(parent);
|
||||||
|
break;
|
||||||
|
case FileDialogType:
|
||||||
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) {
|
||||||
|
QFileDialog::getOpenFileName(parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialog = new QFileDialog(parent);
|
||||||
|
break;
|
||||||
|
case FontDialogType:
|
||||||
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked()) {
|
||||||
|
bool unused = false;
|
||||||
|
QFontDialog::getFont(&unused, parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dialog = new QFontDialog(parent);
|
||||||
|
break;
|
||||||
|
case PageSetupDialogType:
|
||||||
|
dialog = new QPageSetupDialog(parent);
|
||||||
|
break;
|
||||||
|
case PrintDialogType:
|
||||||
|
dialog = new QPrintDialog(parent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->setWindowModality(windowModality);
|
dialog->setWindowModality(windowModality);
|
||||||
|
|
||||||
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked())
|
if (windowModality == Qt::ApplicationModal && applicationModalUseExecCheckBox->isChecked())
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
|
else if (windowModality == Qt::WindowModal)
|
||||||
|
dialog->open();
|
||||||
else
|
else
|
||||||
dialog->show();
|
dialog->show();
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
SOURCES = main.cpp
|
SOURCES = main.cpp
|
||||||
FORMS = widget.ui dialog.ui
|
FORMS = widget.ui dialog.ui
|
||||||
QT += widgets
|
QT += widgets printsupport
|
||||||
|
@ -6,56 +6,231 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>519</width>
|
<width>622</width>
|
||||||
<height>207</height>
|
<height>462</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Select the type of window to create:</string>
|
<string>Select the type of window to create:</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="2" column="1">
|
<item row="2" column="0" colspan="3">
|
||||||
<widget class="QPushButton" name="windowModalNoParentButton">
|
<widget class="QLabel" name="topLevelWindowsLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Window Modal Dialog (no parent)</string>
|
<string>Top-level Windows</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="15" column="0" colspan="3">
|
||||||
<widget class="QPushButton" name="windowModalButton">
|
<widget class="QLabel" name="applicationModalNoteLabel">
|
||||||
|
<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">
|
<property name="text">
|
||||||
<string>Window Modal Dialog</string>
|
<string>Note: Native Application Modal Dialogs use static API instead of exec()</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="14" column="2">
|
||||||
<widget class="QPushButton" name="modelessNoParentButton">
|
<widget class="QPushButton" name="applicationModalPrintDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Modeless Dialog (no parent)</string>
|
<string>Print Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QPushButton" name="modelessButton">
|
<widget class="QPushButton" name="windowButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Modeless Dialog</string>
|
<string>Window</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="13" column="1">
|
||||||
<widget class="QPushButton" name="applicationModalButton">
|
<widget class="QPushButton" name="applicationModalColorDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Application Modal Dialog</string>
|
<string>Color Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="9" column="0">
|
||||||
|
<widget class="QPushButton" name="windowModalFontDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="14" column="0">
|
||||||
|
<widget class="QPushButton" name="applicationModalFontDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="2">
|
||||||
|
<widget class="QPushButton" name="modelessFontDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="14" column="1">
|
||||||
|
<widget class="QPushButton" name="applicationModalPageSetupDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Page Setup Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
|
<widget class="QPushButton" name="windowModalCustomDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Custom Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<widget class="QPushButton" name="windowModalPageSetupDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Page Setup Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QPushButton" name="modelessColorDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="13" column="2">
|
||||||
|
<widget class="QPushButton" name="applicationModalFileDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>File Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="windowModalDialogsLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Window Modal Dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="modelessDialogsLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Modeless (Non-Modal) Dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="11" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="applicationModalDialogsLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Application Modal Dialogs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QPushButton" name="groupLeaderButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Window (Group Leader)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="2">
|
||||||
|
<widget class="QPushButton" name="windowModalPrintDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Print Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="windowModalNoteLabel">
|
||||||
|
<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: Window Modal Dialogs use open()</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1">
|
||||||
|
<widget class="QPushButton" name="windowModalColorDialogButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="0" colspan="3">
|
||||||
<widget class="QCheckBox" name="applicationModalUseExecCheckBox">
|
<widget class="QCheckBox" name="applicationModalUseExecCheckBox">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
@ -70,24 +245,34 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="8" column="2">
|
||||||
<widget class="QPushButton" name="applicationModalNoParentButton">
|
<widget class="QPushButton" name="windowModalFileDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Application Modal Dialog (no parent)</string>
|
<string>File Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="13" column="0">
|
||||||
<widget class="QPushButton" name="groupLeaderButton">
|
<widget class="QPushButton" name="applicationModalCustomDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Window (Group Leader)</string>
|
<string>Custom Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QPushButton" name="windowButton">
|
<widget class="QPushButton" name="modelessCustomDialogButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Window</string>
|
<string>Custom Dialog</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="3">
|
||||||
|
<widget class="QCheckBox" name="useThisAsParentCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use this window as parent for newly created dialogs</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user