Add window-modal show option to dialogs manual test
This provides an easy way to test window modality using a ready available test. Change-Id: Ia23736c61fd56dda8f72ae19f5f102163951271b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
9ec7cbc774
commit
701852e17b
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "colordialogpanel.h"
|
#include "colordialogpanel.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
@ -44,15 +45,6 @@ static inline QStringList svgColorNames()
|
|||||||
<< "turquoise" << "violet" << "wheat" << "white" << "whitesmoke" << "yellow" << "yellowgreen";
|
<< "turquoise" << "violet" << "wheat" << "white" << "whitesmoke" << "yellow" << "yellowgreen";
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QPushButton *addButton(const QString &description, QVBoxLayout *layout,
|
|
||||||
QObject *receiver, const char *slotFunc)
|
|
||||||
{
|
|
||||||
QPushButton *button = new QPushButton(description);
|
|
||||||
QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc);
|
|
||||||
layout->addWidget(button);
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ColorProxyModel : public QSortFilterProxyModel
|
class ColorProxyModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -103,7 +95,9 @@ ColorDialogPanel::ColorDialogPanel(QWidget *parent)
|
|||||||
QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show"));
|
QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show"));
|
||||||
QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox);
|
QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox);
|
||||||
addButton(tr("Exec modal"), buttonsLayout, this, SLOT(execModal()));
|
addButton(tr("Exec modal"), buttonsLayout, this, SLOT(execModal()));
|
||||||
addButton(tr("Show modal"), buttonsLayout, this, SLOT(showModal()));
|
addButton(tr("Show application modal"), buttonsLayout,
|
||||||
|
[this]() { showModal(Qt::ApplicationModal); });
|
||||||
|
addButton(tr("Show window modal"), buttonsLayout, [this]() { showModal(Qt::WindowModal); });
|
||||||
m_deleteModalDialogButton =
|
m_deleteModalDialogButton =
|
||||||
addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog()));
|
addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog()));
|
||||||
addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal()));
|
addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal()));
|
||||||
@ -137,7 +131,7 @@ void ColorDialogPanel::execModal()
|
|||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorDialogPanel::showModal()
|
void ColorDialogPanel::showModal(Qt::WindowModality modality)
|
||||||
{
|
{
|
||||||
if (m_modalDialog.isNull()) {
|
if (m_modalDialog.isNull()) {
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
@ -151,6 +145,7 @@ void ColorDialogPanel::showModal()
|
|||||||
.arg(QLatin1String(QT_VERSION_STR)));
|
.arg(QLatin1String(QT_VERSION_STR)));
|
||||||
enableDeleteModalDialogButton();
|
enableDeleteModalDialogButton();
|
||||||
}
|
}
|
||||||
|
m_modalDialog->setWindowModality(modality);
|
||||||
applySettings(m_modalDialog);
|
applySettings(m_modalDialog);
|
||||||
m_modalDialog->show();
|
m_modalDialog->show();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void execModal();
|
void execModal();
|
||||||
void showModal();
|
void showModal(Qt::WindowModality modality);
|
||||||
void showNonModal();
|
void showNonModal();
|
||||||
void deleteNonModalDialog();
|
void deleteNonModalDialog();
|
||||||
void deleteModalDialog();
|
void deleteModalDialog();
|
||||||
|
@ -43,15 +43,6 @@ const FlagData fileModeComboData[] =
|
|||||||
{"Directory", QFileDialog::Directory}
|
{"Directory", QFileDialog::Directory}
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline QPushButton *addButton(const QString &description, QGridLayout *layout,
|
|
||||||
int &row, int column, QObject *receiver, const char *slotFunc)
|
|
||||||
{
|
|
||||||
QPushButton *button = new QPushButton(description);
|
|
||||||
QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc);
|
|
||||||
layout->addWidget(button, row++, column);
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A line edit for editing the label fields of the dialog, keeping track of whether it has
|
// A line edit for editing the label fields of the dialog, keeping track of whether it has
|
||||||
// been modified by the user to avoid applying Qt's default texts to native dialogs.
|
// been modified by the user to avoid applying Qt's default texts to native dialogs.
|
||||||
|
|
||||||
@ -152,9 +143,12 @@ FileDialogPanel::FileDialogPanel(QWidget *parent)
|
|||||||
int row = 0;
|
int row = 0;
|
||||||
int column = 0;
|
int column = 0;
|
||||||
addButton(tr("Exec modal"), buttonLayout, row, column, this, SLOT(execModal()));
|
addButton(tr("Exec modal"), buttonLayout, row, column, this, SLOT(execModal()));
|
||||||
addButton(tr("Show modal"), buttonLayout, row, column, this, SLOT(showModal()));
|
addButton(tr("Show application modal"), buttonLayout, row, column,
|
||||||
m_deleteModalDialogButton =
|
[this]() { showModal(Qt::ApplicationModal); });
|
||||||
addButton(tr("Delete modal"), buttonLayout, row, column, this, SLOT(deleteModalDialog()));
|
addButton(tr("Show window modal"), buttonLayout, row, column,
|
||||||
|
[this]() { showModal(Qt::WindowModal); });
|
||||||
|
m_deleteModalDialogButton = addButton(tr("Delete modal"), buttonLayout, row, column, this,
|
||||||
|
SLOT(deleteModalDialog()));
|
||||||
addButton(tr("Show non-modal"), buttonLayout, row, column, this, SLOT(showNonModal()));
|
addButton(tr("Show non-modal"), buttonLayout, row, column, this, SLOT(showNonModal()));
|
||||||
m_deleteNonModalDialogButton =
|
m_deleteNonModalDialogButton =
|
||||||
addButton(tr("Delete non-modal"), buttonLayout, row, column, this, SLOT(deleteNonModalDialog()));
|
addButton(tr("Delete non-modal"), buttonLayout, row, column, this, SLOT(deleteNonModalDialog()));
|
||||||
@ -193,7 +187,7 @@ void FileDialogPanel::execModal()
|
|||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialogPanel::showModal()
|
void FileDialogPanel::showModal(Qt::WindowModality modality)
|
||||||
{
|
{
|
||||||
if (m_modalDialog.isNull()) {
|
if (m_modalDialog.isNull()) {
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
@ -205,6 +199,7 @@ void FileDialogPanel::showModal()
|
|||||||
.arg(QLatin1String(QT_VERSION_STR)));
|
.arg(QLatin1String(QT_VERSION_STR)));
|
||||||
enableDeleteModalDialogButton();
|
enableDeleteModalDialogButton();
|
||||||
}
|
}
|
||||||
|
m_modalDialog->setWindowModality(modality);
|
||||||
applySettings(m_modalDialog);
|
applySettings(m_modalDialog);
|
||||||
m_modalDialog->show();
|
m_modalDialog->show();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void execModal();
|
void execModal();
|
||||||
void showModal();
|
void showModal(Qt::WindowModality modality);
|
||||||
void showNonModal();
|
void showNonModal();
|
||||||
void deleteNonModalDialog();
|
void deleteNonModalDialog();
|
||||||
void deleteModalDialog();
|
void deleteModalDialog();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "fontdialogpanel.h"
|
#include "fontdialogpanel.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
@ -14,15 +15,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
static inline QPushButton *addButton(const QString &description, QVBoxLayout *layout,
|
|
||||||
QObject *receiver, const char *slotFunc)
|
|
||||||
{
|
|
||||||
QPushButton *button = new QPushButton(description);
|
|
||||||
QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc);
|
|
||||||
layout->addWidget(button);
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
FontDialogPanel::FontDialogPanel(QWidget *parent)
|
FontDialogPanel::FontDialogPanel(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_fontFamilyBox(new QFontComboBox)
|
, m_fontFamilyBox(new QFontComboBox)
|
||||||
@ -55,7 +47,9 @@ FontDialogPanel::FontDialogPanel(QWidget *parent)
|
|||||||
QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show"));
|
QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show"));
|
||||||
QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox);
|
QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox);
|
||||||
addButton(tr("Exec modal"), buttonsLayout, this, SLOT(execModal()));
|
addButton(tr("Exec modal"), buttonsLayout, this, SLOT(execModal()));
|
||||||
addButton(tr("Show modal"), buttonsLayout, this, SLOT(showModal()));
|
addButton(tr("Show application modal"), buttonsLayout,
|
||||||
|
[this]() { showModal(Qt::ApplicationModal); });
|
||||||
|
addButton(tr("Show window modal"), buttonsLayout, [this]() { showModal(Qt::WindowModal); });
|
||||||
m_deleteModalDialogButton =
|
m_deleteModalDialogButton =
|
||||||
addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog()));
|
addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog()));
|
||||||
addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal()));
|
addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal()));
|
||||||
@ -87,7 +81,7 @@ void FontDialogPanel::execModal()
|
|||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontDialogPanel::showModal()
|
void FontDialogPanel::showModal(Qt::WindowModality modality)
|
||||||
{
|
{
|
||||||
if (m_modalDialog.isNull()) {
|
if (m_modalDialog.isNull()) {
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
@ -99,6 +93,7 @@ void FontDialogPanel::showModal()
|
|||||||
.arg(QLatin1String(QT_VERSION_STR)));
|
.arg(QLatin1String(QT_VERSION_STR)));
|
||||||
enableDeleteModalDialogButton();
|
enableDeleteModalDialogButton();
|
||||||
}
|
}
|
||||||
|
m_modalDialog->setWindowModality(modality);
|
||||||
applySettings(m_modalDialog);
|
applySettings(m_modalDialog);
|
||||||
m_modalDialog->show();
|
m_modalDialog->show();
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void execModal();
|
void execModal();
|
||||||
void showModal();
|
void showModal(Qt::WindowModality modality);
|
||||||
void showNonModal();
|
void showNonModal();
|
||||||
void deleteNonModalDialog();
|
void deleteNonModalDialog();
|
||||||
void deleteModalDialog();
|
void deleteModalDialog();
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size)
|
QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size)
|
||||||
@ -66,3 +68,38 @@ int OptionsControl::intValue() const
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QGridLayout *layout, int &row, int column,
|
||||||
|
QObject *receiver, const char *slotFunc)
|
||||||
|
{
|
||||||
|
QPushButton *button = new QPushButton(description);
|
||||||
|
QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc);
|
||||||
|
layout->addWidget(button, row++, column);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QGridLayout *layout, int &row, int column,
|
||||||
|
std::function<void()> fn)
|
||||||
|
{
|
||||||
|
QPushButton *button = new QPushButton(description);
|
||||||
|
QObject::connect(button, &QPushButton::clicked, fn);
|
||||||
|
layout->addWidget(button, row++, column);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QVBoxLayout *layout, QObject *receiver,
|
||||||
|
const char *slotFunc)
|
||||||
|
{
|
||||||
|
QPushButton *button = new QPushButton(description);
|
||||||
|
QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc);
|
||||||
|
layout->addWidget(button);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QVBoxLayout *layout, std::function<void()> fn)
|
||||||
|
{
|
||||||
|
QPushButton *button = new QPushButton(description);
|
||||||
|
QObject::connect(button, &QPushButton::clicked, fn);
|
||||||
|
layout->addWidget(button);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
@ -10,7 +10,12 @@
|
|||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||||
|
|
||||||
// Associate enum/flag value with a description.
|
// Associate enum/flag value with a description.
|
||||||
struct FlagData
|
struct FlagData
|
||||||
@ -51,4 +56,15 @@ private:
|
|||||||
QList<CheckBoxFlagPair> m_checkBoxes;
|
QList<CheckBoxFlagPair> m_checkBoxes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QGridLayout *layout, int &row, int column,
|
||||||
|
QObject *receiver, const char *slotFunc);
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QGridLayout *layout, int &row, int column,
|
||||||
|
std::function<void()> fn);
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QVBoxLayout *layout, QObject *receiver,
|
||||||
|
const char *slotFunc);
|
||||||
|
|
||||||
|
QPushButton *addButton(const QString &description, QVBoxLayout *layout, std::function<void()> fn);
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
@ -271,8 +271,14 @@ WizardPanel::WizardPanel(QWidget *parent)
|
|||||||
gridLayout->addWidget(m_styleControl, 0, 1);
|
gridLayout->addWidget(m_styleControl, 0, 1);
|
||||||
QGroupBox *buttonGroupBox = new QGroupBox(this);
|
QGroupBox *buttonGroupBox = new QGroupBox(this);
|
||||||
QVBoxLayout *vLayout = new QVBoxLayout(buttonGroupBox);
|
QVBoxLayout *vLayout = new QVBoxLayout(buttonGroupBox);
|
||||||
QPushButton *button = new QPushButton(tr("Show modal"), this);
|
QPushButton *button = new QPushButton(tr("Exec modal"), this);
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(showModal()));
|
connect(button, SIGNAL(clicked()), this, SLOT(execModal()));
|
||||||
|
vLayout->addWidget(button);
|
||||||
|
button = new QPushButton(tr("Show application modal"), this);
|
||||||
|
connect(button, &QPushButton::clicked, [this]() { showModal(Qt::ApplicationModal); });
|
||||||
|
vLayout->addWidget(button);
|
||||||
|
button = new QPushButton(tr("Show window modal"), this);
|
||||||
|
connect(button, &QPushButton::clicked, [this]() { showModal(Qt::WindowModal); });
|
||||||
vLayout->addWidget(button);
|
vLayout->addWidget(button);
|
||||||
button = new QPushButton(tr("Show non-modal"), this);
|
button = new QPushButton(tr("Show non-modal"), this);
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(showNonModal()));
|
connect(button, SIGNAL(clicked()), this, SLOT(showNonModal()));
|
||||||
@ -285,13 +291,23 @@ WizardPanel::WizardPanel(QWidget *parent)
|
|||||||
gridLayout->addWidget(buttonGroupBox, 1, 1);
|
gridLayout->addWidget(buttonGroupBox, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WizardPanel::showModal()
|
void WizardPanel::execModal()
|
||||||
{
|
{
|
||||||
Wizard wizard(this);
|
Wizard wizard(this);
|
||||||
applyParameters(&wizard);
|
applyParameters(&wizard);
|
||||||
wizard.exec();
|
wizard.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WizardPanel::showModal(Qt::WindowModality modality)
|
||||||
|
{
|
||||||
|
Wizard *wizard = new Wizard(this);
|
||||||
|
applyParameters(wizard);
|
||||||
|
wizard->setModal(true);
|
||||||
|
wizard->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
wizard->setWindowModality(modality);
|
||||||
|
wizard->show();
|
||||||
|
}
|
||||||
|
|
||||||
void WizardPanel::showNonModal()
|
void WizardPanel::showNonModal()
|
||||||
{
|
{
|
||||||
Wizard *wizard = new Wizard(this);
|
Wizard *wizard = new Wizard(this);
|
||||||
|
@ -19,7 +19,8 @@ public:
|
|||||||
explicit WizardPanel(QWidget *parent = nullptr);
|
explicit WizardPanel(QWidget *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showModal();
|
void execModal();
|
||||||
|
void showModal(Qt::WindowModality modality);
|
||||||
void showNonModal();
|
void showNonModal();
|
||||||
void showEmbedded();
|
void showEmbedded();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user