diff options
Diffstat (limited to 'tests/manual/dialogs/colordialogpanel.cpp')
-rw-r--r-- | tests/manual/dialogs/colordialogpanel.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/manual/dialogs/colordialogpanel.cpp b/tests/manual/dialogs/colordialogpanel.cpp index 100edd76a1..c9052263b6 100644 --- a/tests/manual/dialogs/colordialogpanel.cpp +++ b/tests/manual/dialogs/colordialogpanel.cpp @@ -1,7 +1,8 @@ // Copyright (C) 2016 The Qt Company Ltd. -// 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 #include "colordialogpanel.h" +#include "utils.h" #include <QGroupBox> #include <QCheckBox> @@ -44,15 +45,6 @@ static inline QStringList svgColorNames() << "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 { public: @@ -60,7 +52,7 @@ public: { } - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { if (role == Qt::DisplayRole) { QString name = data(index, Qt::EditRole).toString(); @@ -103,7 +95,9 @@ ColorDialogPanel::ColorDialogPanel(QWidget *parent) QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show")); QVBoxLayout *buttonsLayout = new QVBoxLayout(buttonsGroupBox); 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 = addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog())); addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal())); @@ -137,7 +131,7 @@ void ColorDialogPanel::execModal() dialog.exec(); } -void ColorDialogPanel::showModal() +void ColorDialogPanel::showModal(Qt::WindowModality modality) { if (m_modalDialog.isNull()) { static int n = 0; @@ -151,6 +145,7 @@ void ColorDialogPanel::showModal() .arg(QLatin1String(QT_VERSION_STR))); enableDeleteModalDialogButton(); } + m_modalDialog->setWindowModality(modality); applySettings(m_modalDialog); m_modalDialog->show(); } |