summaryrefslogtreecommitdiffstats
path: root/tests/manual/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/dialogs')
-rw-r--r--tests/manual/dialogs/CMakeLists.txt21
-rw-r--r--tests/manual/dialogs/colordialogpanel.cpp50
-rw-r--r--tests/manual/dialogs/colordialogpanel.h33
-rw-r--r--tests/manual/dialogs/filedialogpanel.cpp81
-rw-r--r--tests/manual/dialogs/filedialogpanel.h40
-rw-r--r--tests/manual/dialogs/fontdialogpanel.cpp48
-rw-r--r--tests/manual/dialogs/fontdialogpanel.h33
-rw-r--r--tests/manual/dialogs/main.cpp41
-rw-r--r--tests/manual/dialogs/messageboxpanel.cpp33
-rw-r--r--tests/manual/dialogs/messageboxpanel.h31
-rw-r--r--tests/manual/dialogs/printdialogpanel.cpp53
-rw-r--r--tests/manual/dialogs/printdialogpanel.h63
-rw-r--r--tests/manual/dialogs/utils.cpp68
-rw-r--r--tests/manual/dialogs/utils.h45
-rw-r--r--tests/manual/dialogs/wizardpanel.cpp65
-rw-r--r--tests/manual/dialogs/wizardpanel.h34
16 files changed, 192 insertions, 547 deletions
diff --git a/tests/manual/dialogs/CMakeLists.txt b/tests/manual/dialogs/CMakeLists.txt
index d449c191fe..1900b68540 100644
--- a/tests/manual/dialogs/CMakeLists.txt
+++ b/tests/manual/dialogs/CMakeLists.txt
@@ -1,10 +1,11 @@
-# Generated from dialogs.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## dialogs Binary:
#####################################################################
-qt_add_manual_test(dialogs
+qt_internal_add_manual_test(dialogs
GUI
SOURCES
colordialogpanel.cpp colordialogpanel.h
@@ -14,25 +15,27 @@ qt_add_manual_test(dialogs
messageboxpanel.cpp messageboxpanel.h
utils.cpp utils.h
wizardpanel.cpp wizardpanel.h
- PUBLIC_LIBRARIES
+ NO_PCH_SOURCES
+ filedialogpanel.cpp # undef QT_NO_FOREACH
+ utils.cpp # undef QT_NO_FOREACH
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
-#### Keys ignored in scope 1:.:.:dialogs.pro:<TRUE>:
-# TEMPLATE = "app"
-
## Scopes:
#####################################################################
-qt_extend_target(dialogs CONDITION TARGET Qt::PrintSupport
- PUBLIC_LIBRARIES
+qt_internal_extend_target(dialogs CONDITION TARGET Qt::PrintSupport
+ LIBRARIES
Qt::PrintSupport
)
-qt_extend_target(dialogs CONDITION NOT (QT_FEATURE_printer EQUAL FALSE)
+qt_internal_extend_target(dialogs CONDITION NOT (QT_FEATURE_printer EQUAL FALSE)
SOURCES
printdialogpanel.cpp printdialogpanel.h printdialogpanel.ui
+ NO_PCH_SOURCES
+ printdialogpanel.cpp # undef QT_NO_FOREACH
ENABLE_AUTOGEN_TOOLS
uic
)
diff --git a/tests/manual/dialogs/colordialogpanel.cpp b/tests/manual/dialogs/colordialogpanel.cpp
index e2e0fbcdee..c9052263b6 100644
--- a/tests/manual/dialogs/colordialogpanel.cpp
+++ b/tests/manual/dialogs/colordialogpanel.cpp
@@ -1,32 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "colordialogpanel.h"
+#include "utils.h"
#include <QGroupBox>
#include <QCheckBox>
@@ -69,23 +45,14 @@ 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:
- ColorProxyModel(QObject *parent = 0) : QSortFilterProxyModel(parent)
+ ColorProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent)
{
}
- 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();
@@ -128,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()));
@@ -162,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;
@@ -176,6 +145,7 @@ void ColorDialogPanel::showModal()
.arg(QLatin1String(QT_VERSION_STR)));
enableDeleteModalDialogButton();
}
+ m_modalDialog->setWindowModality(modality);
applySettings(m_modalDialog);
m_modalDialog->show();
}
diff --git a/tests/manual/dialogs/colordialogpanel.h b/tests/manual/dialogs/colordialogpanel.h
index 988518a1c8..06eff59945 100644
--- a/tests/manual/dialogs/colordialogpanel.h
+++ b/tests/manual/dialogs/colordialogpanel.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef COLORDIALOGPANEL_H
#define COLORDIALOGPANEL_H
@@ -42,11 +17,11 @@ class ColorDialogPanel : public QWidget
{
Q_OBJECT
public:
- explicit ColorDialogPanel(QWidget *parent = 0);
+ explicit ColorDialogPanel(QWidget *parent = nullptr);
public slots:
void execModal();
- void showModal();
+ void showModal(Qt::WindowModality modality);
void showNonModal();
void deleteNonModalDialog();
void deleteModalDialog();
diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp
index 0fa1bc9dc2..2f47c5ad0a 100644
--- a/tests/manual/dialogs/filedialogpanel.cpp
+++ b/tests/manual/dialogs/filedialogpanel.cpp
@@ -1,30 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "filedialogpanel.h"
#include "utils.h"
@@ -68,15 +45,6 @@ const FlagData fileModeComboData[] =
{"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
// been modified by the user to avoid applying Qt's default texts to native dialogs.
@@ -84,7 +52,7 @@ class LabelLineEdit : public QLineEdit
{
Q_OBJECT
public:
- explicit LabelLineEdit(QFileDialog::DialogLabel label, QWidget *parent = 0) : QLineEdit(parent), m_label(label), m_dirty(false)
+ explicit LabelLineEdit(QFileDialog::DialogLabel label, QWidget *parent = nullptr) : QLineEdit(parent), m_label(label), m_dirty(false)
{
connect(this, SIGNAL(textEdited(QString)), this, SLOT(setDirty()));
}
@@ -118,6 +86,7 @@ FileDialogPanel::FileDialogPanel(QWidget *parent)
, m_resolveSymLinks(new QCheckBox(tr("Resolve symlinks")))
, m_native(new QCheckBox(tr("Use native dialog")))
, m_customDirIcons(new QCheckBox(tr("Don't use custom directory icons")))
+ , m_noIconProvider(new QCheckBox(tr("Null icon provider")))
, m_acceptMode(createCombo(this, acceptModeComboData, sizeof(acceptModeComboData)/sizeof(FlagData)))
, m_fileMode(createCombo(this, fileModeComboData, sizeof(fileModeComboData)/sizeof(FlagData)))
, m_viewMode(createCombo(this, viewModeComboData, sizeof(viewModeComboData)/sizeof(FlagData)))
@@ -145,6 +114,7 @@ FileDialogPanel::FileDialogPanel(QWidget *parent)
optionsLayout->addRow(m_resolveSymLinks);
optionsLayout->addRow(m_readOnly);
optionsLayout->addRow(m_customDirIcons);
+ optionsLayout->addRow(m_noIconProvider);
// Files
QGroupBox *filesGroupBox = new QGroupBox(tr("Files / Filters"));
@@ -177,9 +147,12 @@ FileDialogPanel::FileDialogPanel(QWidget *parent)
int row = 0;
int column = 0;
addButton(tr("Exec modal"), buttonLayout, row, column, this, SLOT(execModal()));
- addButton(tr("Show modal"), buttonLayout, row, column, this, SLOT(showModal()));
- m_deleteModalDialogButton =
- addButton(tr("Delete modal"), buttonLayout, row, column, this, SLOT(deleteModalDialog()));
+ addButton(tr("Show application modal"), buttonLayout, row, column,
+ [this]() { showModal(Qt::ApplicationModal); });
+ 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()));
m_deleteNonModalDialogButton =
addButton(tr("Delete non-modal"), buttonLayout, row, column, this, SLOT(deleteNonModalDialog()));
@@ -218,7 +191,7 @@ void FileDialogPanel::execModal()
dialog.exec();
}
-void FileDialogPanel::showModal()
+void FileDialogPanel::showModal(Qt::WindowModality modality)
{
if (m_modalDialog.isNull()) {
static int n = 0;
@@ -230,6 +203,7 @@ void FileDialogPanel::showModal()
.arg(QLatin1String(QT_VERSION_STR)));
enableDeleteModalDialogButton();
}
+ m_modalDialog->setWindowModality(modality);
applySettings(m_modalDialog);
m_modalDialog->show();
}
@@ -326,7 +300,6 @@ void FileDialogPanel::getOpenFileNames()
void FileDialogPanel::getOpenFileUrls()
{
-#if QT_VERSION >= 0x050000
QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QList<QUrl> files =
QFileDialog::getOpenFileUrls(this, tr("getOpenFileNames Qt %1").arg(QLatin1String(QT_VERSION_STR)),
@@ -339,7 +312,6 @@ void FileDialogPanel::getOpenFileUrls()
<< "\nName filter: " << selectedFilter;
QMessageBox::information(this, tr("getOpenFileNames"), result, QMessageBox::Ok);
}
-#endif // Qt 5
}
void FileDialogPanel::getOpenFileName()
@@ -359,7 +331,6 @@ void FileDialogPanel::getOpenFileName()
void FileDialogPanel::getOpenFileUrl()
{
-#if QT_VERSION >= 0x050000
QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QUrl file =
QFileDialog::getOpenFileUrl(this, tr("getOpenFileUrl Qt %1").arg(QLatin1String(QT_VERSION_STR)),
@@ -372,7 +343,6 @@ void FileDialogPanel::getOpenFileUrl()
<< "\nName filter: " << selectedFilter;
QMessageBox::information(this, tr("getOpenFileName"), result, QMessageBox::Ok);
}
-#endif // Qt 5
}
void FileDialogPanel::getSaveFileName()
@@ -392,7 +362,6 @@ void FileDialogPanel::getSaveFileName()
void FileDialogPanel::getSaveFileUrl()
{
-#if QT_VERSION >= 0x050000
QString selectedFilter = m_selectedNameFilter->text().trimmed();
const QUrl file =
QFileDialog::getSaveFileUrl(this, tr("getSaveFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)),
@@ -405,7 +374,6 @@ void FileDialogPanel::getSaveFileUrl()
<< "\nName filter: " << selectedFilter;
QMessageBox::information(this, tr("getSaveFileNames"), result, QMessageBox::Ok);
}
-#endif // Qt 5
}
void FileDialogPanel::getExistingDirectory()
@@ -419,14 +387,12 @@ void FileDialogPanel::getExistingDirectory()
void FileDialogPanel::getExistingDirectoryUrl()
{
-#if QT_VERSION >= 0x050000
const QUrl dir =
QFileDialog::getExistingDirectoryUrl(this, tr("getExistingDirectory Qt %1").arg(QLatin1String(QT_VERSION_STR)),
currentDirectoryUrl(), options() | QFileDialog::ShowDirsOnly,
allowedSchemes());
if (!dir.isEmpty())
QMessageBox::information(this, tr("getExistingDirectory"), QLatin1String("Directory: ") + dir.toString(), QMessageBox::Ok);
-#endif // Qt 5
}
void FileDialogPanel::restoreDefaults()
@@ -440,7 +406,7 @@ void FileDialogPanel::restoreDefaults()
m_confirmOverWrite->setChecked(!d.testOption(QFileDialog::DontConfirmOverwrite));
m_nameFilterDetailsVisible->setChecked(!d.testOption(QFileDialog::HideNameFilterDetails));
m_resolveSymLinks->setChecked(!d.testOption(QFileDialog::DontResolveSymlinks));
- m_readOnly->setChecked(d.isReadOnly());
+ m_readOnly->setChecked(d.testOption(QFileDialog::ReadOnly));
m_native->setChecked(true);
m_customDirIcons->setChecked(d.testOption(QFileDialog::DontUseCustomDirectoryIcons));
m_directory->setText(QDir::homePath());
@@ -453,12 +419,19 @@ void FileDialogPanel::restoreDefaults()
l->restoreDefault(&d);
}
-void FileDialogPanel::applySettings(QFileDialog *d) const
+void FileDialogPanel::applySettings(QFileDialog *d)
{
d->setAcceptMode(comboBoxValue<QFileDialog::AcceptMode>(m_acceptMode));
d->setViewMode(comboBoxValue<QFileDialog::ViewMode>(m_viewMode));
d->setFileMode(comboBoxValue<QFileDialog::FileMode>(m_fileMode));
d->setOptions(options());
+ if (m_noIconProvider->isChecked()) {
+ m_origIconProvider = d->iconProvider();
+ d->setIconProvider(nullptr);
+ } else if (m_origIconProvider) {
+ d->setIconProvider(m_origIconProvider);
+ }
+
d->setDefaultSuffix(m_defaultSuffix->text().trimmed());
const QString directory = m_directory->text().trimmed();
if (!directory.isEmpty())
@@ -473,11 +446,9 @@ void FileDialogPanel::applySettings(QFileDialog *d) const
if (!filter.isEmpty())
d->selectNameFilter(filter);
} else {
-#if QT_VERSION >= 0x050000
d->setMimeTypeFilters(filters);
if (!filter.isEmpty())
d->selectMimeTypeFilter(filter);
-#endif // Qt 5
}
foreach (LabelLineEdit *l, m_labelLineEdits)
l->apply(d);
@@ -504,14 +475,10 @@ void FileDialogPanel::accepted()
Q_ASSERT(d);
m_result.clear();
QDebug(&m_result).nospace()
-#if QT_VERSION >= 0x050000
<< "URLs: " << d->selectedUrls() << '\n'
-#endif
<< "Files: " << d->selectedFiles()
<< "\nDirectory: "
-#if QT_VERSION >= 0x050000
<< d->directoryUrl() << ", "
-#endif
<< d->directory().absolutePath()
<< "\nName filter: " << d->selectedNameFilter();
QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent.
diff --git a/tests/manual/dialogs/filedialogpanel.h b/tests/manual/dialogs/filedialogpanel.h
index 0bad3e7456..3acf193121 100644
--- a/tests/manual/dialogs/filedialogpanel.h
+++ b/tests/manual/dialogs/filedialogpanel.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef FILEDIALOGPANEL_H
#define FILEDIALOGPANEL_H
@@ -34,6 +9,8 @@
#include <QPointer>
QT_BEGIN_NAMESPACE
+
+class QAbstractFileIconProvider;
class QPushButton;
class QCheckBox;
class QComboBox;
@@ -47,11 +24,11 @@ class FileDialogPanel : public QWidget
{
Q_OBJECT
public:
- explicit FileDialogPanel(QWidget *parent = 0);
+ explicit FileDialogPanel(QWidget *parent = nullptr);
public slots:
void execModal();
- void showModal();
+ void showModal(Qt::WindowModality modality);
void showNonModal();
void deleteNonModalDialog();
void deleteModalDialog();
@@ -77,7 +54,7 @@ private:
QString filterString() const;
QFileDialog::Options options() const;
QStringList allowedSchemes() const;
- void applySettings(QFileDialog *d) const;
+ void applySettings(QFileDialog *d);
QFormLayout *filesLayout;
QCheckBox *m_showDirsOnly;
@@ -87,6 +64,9 @@ private:
QCheckBox *m_resolveSymLinks;
QCheckBox *m_native;
QCheckBox *m_customDirIcons;
+ QCheckBox *m_noIconProvider = nullptr;
+ QAbstractFileIconProvider *m_origIconProvider = nullptr;
+
QComboBox *m_acceptMode;
QComboBox *m_fileMode;
QComboBox *m_viewMode;
diff --git a/tests/manual/dialogs/fontdialogpanel.cpp b/tests/manual/dialogs/fontdialogpanel.cpp
index 8ed52a8a75..4d599c456d 100644
--- a/tests/manual/dialogs/fontdialogpanel.cpp
+++ b/tests/manual/dialogs/fontdialogpanel.cpp
@@ -1,32 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "fontdialogpanel.h"
+#include "utils.h"
#include <QGroupBox>
#include <QCheckBox>
@@ -39,15 +15,6 @@
#include <QTimer>
#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)
: QWidget(parent)
, m_fontFamilyBox(new QFontComboBox)
@@ -80,7 +47,9 @@ FontDialogPanel::FontDialogPanel(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()));
@@ -112,7 +81,7 @@ void FontDialogPanel::execModal()
dialog.exec();
}
-void FontDialogPanel::showModal()
+void FontDialogPanel::showModal(Qt::WindowModality modality)
{
if (m_modalDialog.isNull()) {
static int n = 0;
@@ -124,6 +93,7 @@ void FontDialogPanel::showModal()
.arg(QLatin1String(QT_VERSION_STR)));
enableDeleteModalDialogButton();
}
+ m_modalDialog->setWindowModality(modality);
applySettings(m_modalDialog);
m_modalDialog->show();
}
@@ -196,12 +166,10 @@ void FontDialogPanel::applySettings(QFontDialog *d) const
{
d->setOption(QFontDialog::NoButtons, m_noButtons->isChecked());
d->setOption(QFontDialog::DontUseNativeDialog, m_dontUseNativeDialog->isChecked());
-#if QT_VERSION >= 0x050000
d->setOption(QFontDialog::ScalableFonts, m_scalableFilter->isChecked());
d->setOption(QFontDialog::NonScalableFonts, m_nonScalableFilter->isChecked());
d->setOption(QFontDialog::MonospacedFonts, m_monospacedFilter->isChecked());
d->setOption(QFontDialog::ProportionalFonts, m_proportionalFilter->isChecked());
-#endif // Qt 5
QFont font = m_fontFamilyBox->currentFont();
font.setPointSizeF(m_fontSizeBox->value());
diff --git a/tests/manual/dialogs/fontdialogpanel.h b/tests/manual/dialogs/fontdialogpanel.h
index dd7fb1413a..db3f2fc3f4 100644
--- a/tests/manual/dialogs/fontdialogpanel.h
+++ b/tests/manual/dialogs/fontdialogpanel.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef FONTDIALOGPANEL_H
#define FONTDIALOGPANEL_H
@@ -43,11 +18,11 @@ class FontDialogPanel : public QWidget
{
Q_OBJECT
public:
- explicit FontDialogPanel(QWidget *parent = 0);
+ explicit FontDialogPanel(QWidget *parent = nullptr);
public slots:
void execModal();
- void showModal();
+ void showModal(Qt::WindowModality modality);
void showNonModal();
void deleteNonModalDialog();
void deleteModalDialog();
diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp
index 2676ceeb52..d8b3f3c567 100644
--- a/tests/manual/dialogs/main.cpp
+++ b/tests/manual/dialogs/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "filedialogpanel.h"
#include "colordialogpanel.h"
@@ -52,22 +27,16 @@ static bool optNoPrinter = false;
class AboutDialog : public QDialog
{
public:
- explicit AboutDialog(QWidget *parent = 0);
+ explicit AboutDialog(QWidget *parent = nullptr);
};
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QFormLayout *mainLayout = new QFormLayout(this);
-#if QT_VERSION >= 0x050600
mainLayout->addRow(new QLabel(QLibraryInfo::build()));
-#else
- mainLayout->addRow(new QLabel(QLatin1String("Qt ") + QLatin1String(QT_VERSION_STR )));
-#endif
mainLayout->addRow("Style:", new QLabel(qApp->style()->objectName()));
-#if QT_VERSION >= 0x050600
mainLayout->addRow("DPR:", new QLabel(QString::number(qApp->devicePixelRatio())));
-#endif
const QString resolution = QString::number(logicalDpiX()) + QLatin1Char(',')
+ QString::number(logicalDpiY()) + QLatin1String("dpi");
mainLayout->addRow("Resolution:", new QLabel(resolution));
@@ -79,7 +48,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
class MainWindow : public QMainWindow {
Q_OBJECT
public:
- explicit MainWindow(QWidget *parent = 0);
+ explicit MainWindow(QWidget *parent = nullptr);
public slots:
void aboutDialog();
@@ -129,9 +98,7 @@ int main(int argc, char *argv[])
for (int a = 1; a < argc; ++a) {
if (!qstrcmp(argv[a], "-n")) {
qDebug("AA_DontUseNativeDialogs");
-#if QT_VERSION >= 0x050700
QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
-#endif
} else if (!qstrcmp(argv[a], "-p")) {
optNoPrinter = true; // Avoid startup slowdown by printer code
}
diff --git a/tests/manual/dialogs/messageboxpanel.cpp b/tests/manual/dialogs/messageboxpanel.cpp
index 6a305523ea..1d03072123 100644
--- a/tests/manual/dialogs/messageboxpanel.cpp
+++ b/tests/manual/dialogs/messageboxpanel.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "messageboxpanel.h"
@@ -138,11 +113,9 @@ void MessageBoxPanel::setupMessageBox(QMessageBox &box)
if (box.standardButtons() == QMessageBox::StandardButtons())
box.setStandardButtons(QMessageBox::Ok); // just to have something.
-#if QT_VERSION >= 0x050000
box.setCheckBox(0);
if (m_checkboxText->text().length() > 0)
box.setCheckBox(new QCheckBox(m_checkboxText->text()));
-#endif // Qt 5
box.setIcon((QMessageBox::Icon) m_iconComboBox->currentIndex());
}
@@ -167,14 +140,12 @@ void MessageBoxPanel::doExec()
QString sres;
sres.setNum(res, 16);
m_resultLabel->setText(QString::fromLatin1("Return value (hex): %1").arg(sres));
-#if QT_VERSION >= 0x050000
if (m_msgbox->checkBox()) {
if (m_msgbox->checkBox()->isChecked())
m_checkBoxResult->setText(QString::fromLatin1("Checkbox was checked"));
else
m_checkBoxResult->setText(QString::fromLatin1("Checkbox was not checked"));
}
-#endif // Qt 5
}
void MessageBoxPanel::doShowApply()
diff --git a/tests/manual/dialogs/messageboxpanel.h b/tests/manual/dialogs/messageboxpanel.h
index 1e37b5c6df..c84657562b 100644
--- a/tests/manual/dialogs/messageboxpanel.h
+++ b/tests/manual/dialogs/messageboxpanel.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MESSAGEBOXPANEL_H
#define MESSAGEBOXPANEL_H
@@ -47,7 +22,7 @@ class MessageBoxPanel : public QWidget
{
Q_OBJECT
public:
- explicit MessageBoxPanel(QWidget *parent = 0);
+ explicit MessageBoxPanel(QWidget *parent = nullptr);
~MessageBoxPanel();
public slots:
diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp
index 29dc33285b..716faa48c6 100644
--- a/tests/manual/dialogs/printdialogpanel.cpp
+++ b/tests/manual/dialogs/printdialogpanel.cpp
@@ -1,30 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#ifndef QT_NO_PRINTER
@@ -157,17 +134,19 @@ QTextStream &operator<<(QTextStream &s, const QRectF &rect)
QTextStream &operator<<(QTextStream &s, const QPrinter &printer)
{
- s << '"' << printer.printerName() << "\"\nPaper #" <<printer.paperSize()
- << " \"" << printer.paperName() << '"'
- << (printer.orientation() == QPrinter::Portrait ? ", Portrait" : ", Landscape");
+ const auto pageLayout = printer.pageLayout();
+ const auto pageSize = pageLayout.pageSize();
+ s << '"' << printer.printerName() << "\"\nPaper #" << pageSize.id()
+ << " \"" << pageSize.name() << '"'
+ << (pageLayout.orientation() == QPageLayout::Portrait ? ", Portrait" : ", Landscape");
if (printer.fullPage())
s << ", full page";
s << "\nPaper size: "
- << printer.paperSize(QPrinter::Point) << "pt "
- << printer.paperSize(QPrinter::Millimeter) << "mm "
- << "\n " << printer.paperSize(QPrinter::DevicePixel) << "device pt "
- << printer.paperSize(QPrinter::Inch) << "inch "
- << "\nPagedPaintDevSize: " << printer.pageSizeMM() << "mm"
+ << pageSize.sizePoints() << "pt "
+ << pageSize.size(QPageSize::Millimeter) << "mm "
+ << "\n " << pageSize.sizePixels(printer.resolution()) << " device pt "
+ << pageSize.size(QPageSize::Inch) << "inch "
+ << "\n " << pageSize.size(QPageSize::Millimeter) << "mm"
<< "\nLogical resolution : " << printer.logicalDpiX() << ',' << printer.logicalDpiY() << "DPI"
<< "\nPhysical resolution: " << printer.physicalDpiX() << ',' << printer.physicalDpiY() << "DPI"
<< "\nPaperRect: " << printer.paperRect(QPrinter::Point) << "pt "
@@ -236,7 +215,7 @@ static bool print(QPrinter *printer, QString *errorMessage)
return false;
}
- const QRectF pageF = printer->pageRect();
+ const QRectF pageF = printer->pageRect(QPrinter::DevicePixel);
QFont font = painter.font();
font.setFamily("Courier");
@@ -289,7 +268,7 @@ static bool print(QPrinter *printer, QWidget *dialogParent)
class PrintPreviewDialog : public QPrintPreviewDialog {
Q_OBJECT
public:
- explicit PrintPreviewDialog(QPrinter *printer, QWidget *parent = 0) : QPrintPreviewDialog(printer, parent)
+ explicit PrintPreviewDialog(QPrinter *printer, QWidget *parent = nullptr) : QPrintPreviewDialog(printer, parent)
{
connect(this, SIGNAL(paintRequested(QPrinter*)), this, SLOT(slotPaintRequested(QPrinter*)));
}
diff --git a/tests/manual/dialogs/printdialogpanel.h b/tests/manual/dialogs/printdialogpanel.h
index 6bf465f527..a8d54e8aa2 100644
--- a/tests/manual/dialogs/printdialogpanel.h
+++ b/tests/manual/dialogs/printdialogpanel.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PRINTDIALOGPANEL_H
#define PRINTDIALOGPANEL_H
@@ -33,9 +8,7 @@
#include "ui_printdialogpanel.h"
-#if QT_VERSION >= 0x050300
#include <QPageLayout>
-#endif
#include <QPrinter>
#include <QWidget>
@@ -50,36 +23,11 @@ QT_END_NAMESPACE
class PageSizeControl;
class OptionsControl;
-#if QT_VERSION < 0x050300
-// Copied from class QPageLayout introduced in Qt 5.3
-namespace QPageLayout
-{
- enum Unit {
- Millimeter,
- Point,
- Inch,
- Pica,
- Didot,
- Cicero
- };
-
- enum Orientation {
- Portrait,
- Landscape
- };
-
- enum Mode {
- StandardMode, // Paint Rect includes margins
- FullPageMode // Paint Rect excludes margins
- };
-}
-#endif
-
class PrintDialogPanel : public QWidget
{
Q_OBJECT
public:
- explicit PrintDialogPanel(QWidget *parent = 0);
+ explicit PrintDialogPanel(QWidget *parent = nullptr);
~PrintDialogPanel();
private slots:
@@ -107,12 +55,7 @@ private:
bool m_blockSignals;
Ui::PrintDialogPanel m_panel;
-#if QT_VERSION >= 0x050300
QPageLayout m_pageLayout;
-#else
- QPrinter m_printerLayout;
- QPrinter::Unit m_units;
-#endif
QScopedPointer<QPrinter> m_printer;
};
diff --git a/tests/manual/dialogs/utils.cpp b/tests/manual/dialogs/utils.cpp
index e584f0d6ff..bfb61cd8df 100644
--- a/tests/manual/dialogs/utils.cpp
+++ b/tests/manual/dialogs/utils.cpp
@@ -1,34 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "utils.h"
#include <QCheckBox>
+#include <QGridLayout>
+#include <QPushButton>
#include <QVBoxLayout>
QComboBox *createCombo(QWidget *parent, const FlagData *d, size_t size)
@@ -91,3 +70,38 @@ int OptionsControl::intValue() const
}
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;
+}
diff --git a/tests/manual/dialogs/utils.h b/tests/manual/dialogs/utils.h
index cac0f1af18..3db08ce44e 100644
--- a/tests/manual/dialogs/utils.h
+++ b/tests/manual/dialogs/utils.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef UTILS_H
#define UTILS_H
@@ -35,7 +10,12 @@
#include <QPair>
#include <QList>
+#include <functional>
+
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.
struct FlagData
@@ -76,4 +56,15 @@ private:
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
diff --git a/tests/manual/dialogs/wizardpanel.cpp b/tests/manual/dialogs/wizardpanel.cpp
index 8e8af5f556..5e413960e3 100644
--- a/tests/manual/dialogs/wizardpanel.cpp
+++ b/tests/manual/dialogs/wizardpanel.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "wizardpanel.h"
@@ -73,7 +48,7 @@ class WizardStyleControl : public QGroupBox
{
Q_OBJECT
public:
- WizardStyleControl(QWidget *parent = 0);
+ WizardStyleControl(QWidget *parent = nullptr);
void setWizardStyle(int style);
QWizard::WizardStyle wizardStyle() const;
@@ -90,7 +65,7 @@ WizardStyleControl::WizardStyleControl(QWidget *parent)
, m_group(new QButtonGroup(this))
{
m_group->setExclusive(true);
- connect(m_group, SIGNAL(buttonClicked(int)), this, SIGNAL(wizardStyleChanged(int)));
+ connect(m_group, &QButtonGroup::idClicked, this, &WizardStyleControl::wizardStyleChanged);
QVBoxLayout *vLayout = new QVBoxLayout(this);
QRadioButton *radioButton = new QRadioButton(tr("None/OS Default"), this);
m_group->addButton(radioButton, QWizard::NStyles);
@@ -132,7 +107,7 @@ void WizardStyleControl::setWizardStyle(int wizardStyle)
class WizardOptionsControl : public QGroupBox
{
public:
- explicit WizardOptionsControl(QWidget *parent = 0);
+ explicit WizardOptionsControl(QWidget *parent = nullptr);
QWizard::WizardOption wizardOptions() const;
void setWizardOptions(int options);
@@ -214,9 +189,9 @@ void Wizard::changeWizardStyle(int newStyle)
class WizardPage : public QWizardPage
{
public:
- explicit WizardPage(const QString &title, QWidget *parent = 0);
+ explicit WizardPage(const QString &title, QWidget *parent = nullptr);
- void initializePage();
+ void initializePage() override;
private:
WizardStyleControl *m_styleControl;
@@ -254,10 +229,10 @@ Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags)
addPage(new WizardPage(tr("Page 3"), this));
}
-// A dialog using a Wizard as child widget (emulating Qt Designer).
+// A dialog using a Wizard as child widget (emulating Qt Widgets Designer).
class WizardEmbeddingDialog : public QDialog {
public:
- explicit WizardEmbeddingDialog(QWidget *parent = 0);
+ explicit WizardEmbeddingDialog(QWidget *parent = nullptr);
Wizard *wizard() const { return m_wizard; }
@@ -296,8 +271,14 @@ WizardPanel::WizardPanel(QWidget *parent)
gridLayout->addWidget(m_styleControl, 0, 1);
QGroupBox *buttonGroupBox = new QGroupBox(this);
QVBoxLayout *vLayout = new QVBoxLayout(buttonGroupBox);
- QPushButton *button = new QPushButton(tr("Show modal"), this);
- connect(button, SIGNAL(clicked()), this, SLOT(showModal()));
+ QPushButton *button = new QPushButton(tr("Exec modal"), this);
+ 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);
button = new QPushButton(tr("Show non-modal"), this);
connect(button, SIGNAL(clicked()), this, SLOT(showNonModal()));
@@ -310,13 +291,23 @@ WizardPanel::WizardPanel(QWidget *parent)
gridLayout->addWidget(buttonGroupBox, 1, 1);
}
-void WizardPanel::showModal()
+void WizardPanel::execModal()
{
Wizard wizard(this);
applyParameters(&wizard);
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()
{
Wizard *wizard = new Wizard(this);
diff --git a/tests/manual/dialogs/wizardpanel.h b/tests/manual/dialogs/wizardpanel.h
index 0a937f7d31..42765aeaef 100644
--- a/tests/manual/dialogs/wizardpanel.h
+++ b/tests/manual/dialogs/wizardpanel.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef WIZARDPANEL_H
#define WIZARDPANEL_H
@@ -41,10 +16,11 @@ class WizardPanel : public QWidget
{
Q_OBJECT
public:
- explicit WizardPanel(QWidget *parent = 0);
+ explicit WizardPanel(QWidget *parent = nullptr);
public slots:
- void showModal();
+ void execModal();
+ void showModal(Qt::WindowModality modality);
void showNonModal();
void showEmbedded();