summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/dialogs/colordialogpanel.cpp261
-rw-r--r--tests/manual/dialogs/colordialogpanel.h86
-rw-r--r--tests/manual/dialogs/dialogs.pro4
-rw-r--r--tests/manual/dialogs/filedialogpanel.cpp105
-rw-r--r--tests/manual/dialogs/filedialogpanel.h13
-rw-r--r--tests/manual/dialogs/fontdialogpanel.cpp208
-rw-r--r--tests/manual/dialogs/fontdialogpanel.h87
-rw-r--r--tests/manual/dialogs/main.cpp5
-rw-r--r--tests/manual/lance/lance.pro1
-rw-r--r--tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp3
-rw-r--r--tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp41
-rw-r--r--tests/manual/windowflags/controls.cpp4
12 files changed, 783 insertions, 35 deletions
diff --git a/tests/manual/dialogs/colordialogpanel.cpp b/tests/manual/dialogs/colordialogpanel.cpp
new file mode 100644
index 0000000000..695e37a4c7
--- /dev/null
+++ b/tests/manual/dialogs/colordialogpanel.cpp
@@ -0,0 +1,261 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "colordialogpanel.h"
+
+#include <QGroupBox>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QMessageBox>
+#include <QSortFilterProxyModel>
+#include <QComboBox>
+#include <QTimer>
+#include <QDebug>
+
+// SVG color keyword names provided by the World Wide Web Consortium
+static inline QStringList svgColorNames()
+{
+ return QStringList()
+ << "aliceblue" << "antiquewhite" << "aqua" << "aquamarine" << "azure" << "beige" << "bisque"
+ << "black" << "blanchedalmond" << "blue" << "blueviolet" << "brown" << "burlywood" << "cadetblue"
+ << "chartreuse" << "chocolate" << "coral" << "cornflowerblue" << "cornsilk" << "crimson" << "cyan"
+ << "darkblue" << "darkcyan" << "darkgoldenrod" << "darkgray" << "darkgreen" << "darkgrey"
+ << "darkkhaki" << "darkmagenta" << "darkolivegreen" << "darkorange" << "darkorchid" << "darkred"
+ << "darksalmon" << "darkseagreen" << "darkslateblue" << "darkslategray" << "darkslategrey"
+ << "darkturquoise" << "darkviolet" << "deeppink" << "deepskyblue" << "dimgray" << "dimgrey"
+ << "dodgerblue" << "firebrick" << "floralwhite" << "forestgreen" << "fuchsia" << "gainsboro"
+ << "ghostwhite" << "gold" << "goldenrod" << "gray" << "grey" << "green" << "greenyellow"
+ << "honeydew" << "hotpink" << "indianred" << "indigo" << "ivory" << "khaki" << "lavender"
+ << "lavenderblush" << "lawngreen" << "lemonchiffon" << "lightblue" << "lightcoral" << "lightcyan"
+ << "lightgoldenrodyellow" << "lightgray" << "lightgreen" << "lightgrey" << "lightpink"
+ << "lightsalmon" << "lightseagreen" << "lightskyblue" << "lightslategray" << "lightslategrey"
+ << "lightsteelblue" << "lightyellow" << "lime" << "limegreen" << "linen" << "magenta"
+ << "maroon" << "mediumaquamarine" << "mediumblue" << "mediumorchid" << "mediumpurple"
+ << "mediumseagreen" << "mediumslateblue" << "mediumspringgreen" << "mediumturquoise"
+ << "mediumvioletred" << "midnightblue" << "mintcream" << "mistyrose" << "moccasin"
+ << "navajowhite" << "navy" << "oldlace" << "olive" << "olivedrab" << "orange" << "orangered"
+ << "orchid" << "palegoldenrod" << "palegreen" << "paleturquoise" << "palevioletred"
+ << "papayawhip" << "peachpuff" << "peru" << "pink" << "plum" << "powderblue" << "purple" << "red"
+ << "rosybrown" << "royalblue" << "saddlebrown" << "salmon" << "sandybrown" << "seagreen"
+ << "seashell" << "sienna" << "silver" << "skyblue" << "slateblue" << "slategray" << "slategrey"
+ << "snow" << "springgreen" << "steelblue" << "tan" << "teal" << "thistle" << "tomato"
+ << "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)
+ {
+ }
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
+ {
+ if (role == Qt::DisplayRole) {
+ QString name = data(index, Qt::EditRole).toString();
+ return tr("%1 (%2)").arg(name, QColor(name).name());
+ }
+ if (role == Qt::DecorationRole)
+ return QColor(data(index, Qt::EditRole).toString());
+ return QSortFilterProxyModel::data(index, role);
+ }
+};
+
+ColorDialogPanel::ColorDialogPanel(QWidget *parent)
+ : QWidget(parent)
+ , m_colorComboBox(new QComboBox)
+ , m_showAlphaChannel(new QCheckBox(tr("Show alpha channel")))
+ , m_noButtons(new QCheckBox(tr("Don't display OK/Cancel buttons")))
+ , m_dontUseNativeDialog(new QCheckBox(tr("Don't use native dialog")))
+{
+ // Options
+ QGroupBox *optionsGroupBox = new QGroupBox(tr("Options"), this);
+ QVBoxLayout *optionsLayout = new QVBoxLayout(optionsGroupBox);
+ optionsLayout->addWidget(m_showAlphaChannel);
+ optionsLayout->addWidget(m_noButtons);
+ optionsLayout->addWidget(m_dontUseNativeDialog);
+
+ // Color
+ QGroupBox *colorGroupBox = new QGroupBox(tr("Color"), this);
+ QVBoxLayout *colorLayout = new QVBoxLayout(colorGroupBox);
+ colorLayout->addWidget(m_colorComboBox);
+ m_colorComboBox->addItems(svgColorNames());
+ m_colorComboBox->setEditable(true);
+
+ QAbstractItemModel *sourceModel = m_colorComboBox->model();
+ ColorProxyModel* proxyModel = new ColorProxyModel(m_colorComboBox);
+ proxyModel->setSourceModel(sourceModel);
+ sourceModel->setParent(proxyModel);
+ m_colorComboBox->setModel(proxyModel);
+
+ // Buttons
+ 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()));
+ m_deleteModalDialogButton =
+ addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog()));
+ addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal()));
+ m_deleteNonModalDialogButton =
+ addButton(tr("Delete non-modal"), buttonsLayout, this, SLOT(deleteNonModalDialog()));
+ addButton(tr("Restore defaults"), buttonsLayout, this, SLOT(restoreDefaults()));
+ buttonsLayout->addStretch();
+
+ // Main layout
+ QHBoxLayout *mainLayout = new QHBoxLayout(this);
+ QVBoxLayout *leftLayout = new QVBoxLayout;
+ leftLayout->addWidget(optionsGroupBox);
+ leftLayout->addWidget(colorGroupBox);
+ leftLayout->addStretch();
+ mainLayout->addLayout(leftLayout);
+ mainLayout->addWidget(buttonsGroupBox);
+
+ enableDeleteModalDialogButton();
+ enableDeleteNonModalDialogButton();
+ restoreDefaults();
+}
+
+void ColorDialogPanel::execModal()
+{
+ QColorDialog dialog(this);
+ applySettings(&dialog);
+ connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted()));
+ dialog.setWindowTitle(tr("Modal Color Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+ dialog.exec();
+}
+
+void ColorDialogPanel::showModal()
+{
+ if (m_modalDialog.isNull()) {
+ static int n = 0;
+ m_modalDialog = new QColorDialog(this);
+ m_modalDialog->setModal(true);
+ connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
+ m_modalDialog->setWindowTitle(tr("Modal Color Dialog #%1 Qt %2")
+ .arg(++n)
+ .arg(QLatin1String(QT_VERSION_STR)));
+ enableDeleteModalDialogButton();
+ }
+ applySettings(m_modalDialog);
+ m_modalDialog->show();
+}
+
+void ColorDialogPanel::showNonModal()
+{
+ if (m_nonModalDialog.isNull()) {
+ static int n = 0;
+ m_nonModalDialog = new QColorDialog(this);
+ connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
+ m_nonModalDialog->setWindowTitle(tr("Non-Modal Color Dialog #%1 Qt %2")
+ .arg(++n)
+ .arg(QLatin1String(QT_VERSION_STR)));
+ enableDeleteNonModalDialogButton();
+ }
+ applySettings(m_nonModalDialog);
+ m_nonModalDialog->show();
+}
+
+void ColorDialogPanel::deleteNonModalDialog()
+{
+ if (!m_nonModalDialog.isNull())
+ delete m_nonModalDialog;
+ enableDeleteNonModalDialogButton();
+}
+
+void ColorDialogPanel::deleteModalDialog()
+{
+ if (!m_modalDialog.isNull())
+ delete m_modalDialog;
+ enableDeleteModalDialogButton();
+}
+
+void ColorDialogPanel::accepted()
+{
+ const QColorDialog *d = qobject_cast<const QColorDialog *>(sender());
+ Q_ASSERT(d);
+ m_result.clear();
+ QDebug(&m_result).nospace()
+ << "Current color: " << d->currentColor()
+ << "\nSelected color: " << d->selectedColor();
+ QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent.
+}
+
+void ColorDialogPanel::showAcceptedResult()
+{
+ QMessageBox::information(this, tr("Color Dialog Accepted"), m_result, QMessageBox::Ok);
+}
+
+void ColorDialogPanel::restoreDefaults()
+{
+ QColorDialog d;
+ m_showAlphaChannel->setChecked(d.testOption(QColorDialog::ShowAlphaChannel));
+ m_noButtons->setChecked(d.testOption(QColorDialog::NoButtons));
+ m_dontUseNativeDialog->setChecked(d.testOption(QColorDialog::DontUseNativeDialog));
+}
+
+void ColorDialogPanel::enableDeleteNonModalDialogButton()
+{
+ m_deleteNonModalDialogButton->setEnabled(!m_nonModalDialog.isNull());
+}
+
+void ColorDialogPanel::enableDeleteModalDialogButton()
+{
+ m_deleteModalDialogButton->setEnabled(!m_modalDialog.isNull());
+}
+
+void ColorDialogPanel::applySettings(QColorDialog *d) const
+{
+ d->setOption(QColorDialog::ShowAlphaChannel, m_showAlphaChannel->isChecked());
+ d->setOption(QColorDialog::NoButtons, m_noButtons->isChecked());
+ d->setOption(QColorDialog::DontUseNativeDialog, m_dontUseNativeDialog->isChecked());
+ d->setCurrentColor(QColor(m_colorComboBox->itemData(m_colorComboBox->currentIndex(), Qt::EditRole).toString()));
+}
diff --git a/tests/manual/dialogs/colordialogpanel.h b/tests/manual/dialogs/colordialogpanel.h
new file mode 100644
index 0000000000..bcd2cf6e52
--- /dev/null
+++ b/tests/manual/dialogs/colordialogpanel.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COLORDIALOGPANEL_H
+#define COLORDIALOGPANEL_H
+
+#include <QPointer>
+#include <QColorDialog>
+
+class QComboBox;
+class QCheckBox;
+class QPushButton;
+
+class ColorDialogPanel : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit ColorDialogPanel(QWidget *parent = 0);
+
+public slots:
+ void execModal();
+ void showModal();
+ void showNonModal();
+ void deleteNonModalDialog();
+ void deleteModalDialog();
+ void accepted();
+ void showAcceptedResult();
+ void restoreDefaults();
+
+private slots:
+ void enableDeleteNonModalDialogButton();
+ void enableDeleteModalDialogButton();
+
+private:
+ void applySettings(QColorDialog *d) const;
+
+ QComboBox *m_colorComboBox;
+ QCheckBox *m_showAlphaChannel;
+ QCheckBox *m_noButtons;
+ QCheckBox *m_dontUseNativeDialog;
+ QPushButton *m_deleteNonModalDialogButton;
+ QPushButton *m_deleteModalDialogButton;
+ QString m_result;
+ QPointer<QColorDialog> m_modalDialog;
+ QPointer<QColorDialog> m_nonModalDialog;
+};
+
+#endif // COLORDIALOGPANEL_H
diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro
index ff916d3854..fe40994241 100644
--- a/tests/manual/dialogs/dialogs.pro
+++ b/tests/manual/dialogs/dialogs.pro
@@ -4,5 +4,5 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = dialogs
TEMPLATE = app
-SOURCES += main.cpp filedialogpanel.cpp
-HEADERS += filedialogpanel.h
+SOURCES += main.cpp filedialogpanel.cpp colordialogpanel.cpp fontdialogpanel.cpp
+HEADERS += filedialogpanel.h colordialogpanel.h fontdialogpanel.h
diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp
index 66a5201db0..636e65b684 100644
--- a/tests/manual/dialogs/filedialogpanel.cpp
+++ b/tests/manual/dialogs/filedialogpanel.cpp
@@ -44,6 +44,7 @@
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
+#include <QGridLayout>
#include <QFormLayout>
#include <QSpacerItem>
#include <QGroupBox>
@@ -105,11 +106,13 @@ inline void setComboBoxValue(QComboBox *c, int v)
c->setCurrentIndex(c->findData(QVariant(v)));
}
-static inline void addButton(const QString &description, QBoxLayout *layout, QObject *receiver, const char *slotFunc)
+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);
+ layout->addWidget(button, row++, column);
+ return button;
}
// A line edit for editing the label fields of the dialog, keeping track of whether it has
@@ -159,6 +162,8 @@ FileDialogPanel::FileDialogPanel(QWidget *parent)
, m_selectedFileName(new QLineEdit(this))
, m_nameFilters(new QPlainTextEdit)
, m_selectedNameFilter(new QLineEdit(this))
+ , m_deleteNonModalDialogButton(0)
+ , m_deleteModalDialogButton(0)
{
// Options
QGroupBox *optionsGroupBox = new QGroupBox(tr("Options"));
@@ -197,19 +202,24 @@ FileDialogPanel::FileDialogPanel(QWidget *parent)
labelsLayout->addRow(tr("Reject label:"), m_labelLineEdits.back());
// Buttons
- QVBoxLayout *buttonLayout = new QVBoxLayout;
- buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
- addButton(tr("Show modal"), buttonLayout, this, SLOT(showModal()));
- addButton(tr("Show non-modal"), buttonLayout, this, SLOT(showNonModal()));
- addButton(tr("getOpenFileName"), buttonLayout, this, SLOT(getOpenFileName()));
- addButton(tr("getOpenFileNames"), buttonLayout, this, SLOT(getOpenFileNames()));
- addButton(tr("getSaveFileName"), buttonLayout, this, SLOT(getSaveFileName()));
- addButton(tr("getExistingDirectory"), buttonLayout, this, SLOT(getExistingDirectory()));
- addButton(tr("Restore defaults"), buttonLayout, this, SLOT(restoreDefaults()));
QGroupBox *buttonsGroupBox = new QGroupBox(tr("Show"));
- QHBoxLayout *buttonsGroupLayout = new QHBoxLayout(buttonsGroupBox);
- buttonsGroupLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::Ignored));
- buttonsGroupLayout->addLayout(buttonLayout);
+ QGridLayout *buttonLayout = new QGridLayout(buttonsGroupBox);
+ 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 non-modal"), buttonLayout, row, column, this, SLOT(showNonModal()));
+ m_deleteNonModalDialogButton =
+ addButton(tr("Delete non-modal"), buttonLayout, row, column, this, SLOT(deleteNonModalDialog()));
+ row = 0;
+ column++;
+ addButton(tr("getOpenFileName"), buttonLayout, row, column, this, SLOT(getOpenFileName()));
+ addButton(tr("getOpenFileNames"), buttonLayout, row, column, this, SLOT(getOpenFileNames()));
+ addButton(tr("getSaveFileName"), buttonLayout, row, column, this, SLOT(getSaveFileName()));
+ addButton(tr("getExistingDirectory"), buttonLayout, row, column, this, SLOT(getExistingDirectory()));
+ addButton(tr("Restore defaults"), buttonLayout, row, column, this, SLOT(restoreDefaults()));
// Main layout
QGridLayout *gridLayout = new QGridLayout(this);
@@ -218,26 +228,76 @@ FileDialogPanel::FileDialogPanel(QWidget *parent)
gridLayout->addWidget(labelsGroupBox, 1, 0);
gridLayout->addWidget(buttonsGroupBox, 1, 1);
+ enableDeleteModalDialogButton();
+ enableDeleteNonModalDialogButton();
restoreDefaults();
}
-void FileDialogPanel::showModal()
+void FileDialogPanel::execModal()
{
QFileDialog dialog(this);
applySettings(&dialog);
+ connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted()));
dialog.setWindowTitle(tr("Modal File Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR)));
dialog.exec();
}
+void FileDialogPanel::showModal()
+{
+ if (m_modalDialog.isNull()) {
+ static int n = 0;
+ m_modalDialog = new QFileDialog(this);
+ m_modalDialog->setModal(true);
+ connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
+ m_modalDialog->setWindowTitle(tr("Modal File Dialog #%1 Qt %2")
+ .arg(++n)
+ .arg(QLatin1String(QT_VERSION_STR)));
+ enableDeleteModalDialogButton();
+ }
+ applySettings(m_modalDialog);
+ m_modalDialog->show();
+}
+
void FileDialogPanel::showNonModal()
{
- QFileDialog *dialog = new QFileDialog(this);
- dialog->setAttribute(Qt::WA_DeleteOnClose);
- applySettings(dialog);
- dialog->setWindowTitle(tr("Non-Modal File Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR)));
- dialog->show();
+ if (m_nonModalDialog.isNull()) {
+ static int n = 0;
+ m_nonModalDialog = new QFileDialog(this);
+ connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
+ m_nonModalDialog->setWindowTitle(tr("Non-Modal File Dialog #%1 Qt %2")
+ .arg(++n)
+ .arg(QLatin1String(QT_VERSION_STR)));
+ enableDeleteNonModalDialogButton();
+ }
+ applySettings(m_nonModalDialog);
+ m_nonModalDialog->show();
+}
+
+void FileDialogPanel::deleteNonModalDialog()
+{
+ if (!m_nonModalDialog.isNull())
+ delete m_nonModalDialog;
+ enableDeleteNonModalDialogButton();
}
+void FileDialogPanel::deleteModalDialog()
+{
+ if (!m_modalDialog.isNull())
+ delete m_modalDialog;
+ enableDeleteModalDialogButton();
+}
+
+void FileDialogPanel::enableDeleteNonModalDialogButton()
+{
+ m_deleteNonModalDialogButton->setEnabled(!m_nonModalDialog.isNull());
+}
+
+void FileDialogPanel::enableDeleteModalDialogButton()
+{
+ m_deleteModalDialogButton->setEnabled(!m_modalDialog.isNull());
+}
+
+
QString FileDialogPanel::filterString() const
{
return m_nameFilters->toPlainText().trimmed().replace(QLatin1String("\n"), QLatin1String(";;"));
@@ -340,7 +400,9 @@ void FileDialogPanel::applySettings(QFileDialog *d) const
d->setFileMode(comboBoxValue<QFileDialog::FileMode>(m_fileMode));
d->setOptions(options());
d->setDefaultSuffix(m_defaultSuffix->text().trimmed());
- d->setDirectory(m_directory->text().trimmed());
+ const QString directory = m_directory->text().trimmed();
+ if (!directory.isEmpty())
+ d->setDirectory(directory);
const QString file = m_selectedFileName->text().trimmed();
if (!file.isEmpty())
d->selectFile(file);
@@ -350,7 +412,6 @@ void FileDialogPanel::applySettings(QFileDialog *d) const
d->selectNameFilter(filter);
foreach (LabelLineEdit *l, m_labelLineEdits)
l->apply(d);
- connect(d, SIGNAL(accepted()), this, SLOT(accepted()));
}
void FileDialogPanel::accepted()
diff --git a/tests/manual/dialogs/filedialogpanel.h b/tests/manual/dialogs/filedialogpanel.h
index 699d917e4d..7ee7cb3f60 100644
--- a/tests/manual/dialogs/filedialogpanel.h
+++ b/tests/manual/dialogs/filedialogpanel.h
@@ -44,7 +44,9 @@
#include <QGroupBox>
#include <QFileDialog>
+#include <QPointer>
+class QPushButton;
class QCheckBox;
class QComboBox;
class QLineEdit;
@@ -58,8 +60,11 @@ public:
explicit FileDialogPanel(QWidget *parent = 0);
public slots:
+ void execModal();
void showModal();
void showNonModal();
+ void deleteNonModalDialog();
+ void deleteModalDialog();
void getOpenFileNames();
void getOpenFileName();
void getSaveFileName();
@@ -68,6 +73,10 @@ public slots:
void showAcceptedResult();
void restoreDefaults();
+private slots:
+ void enableDeleteNonModalDialogButton();
+ void enableDeleteModalDialogButton();
+
private:
QString filterString() const;
QFileDialog::Options options() const;
@@ -87,7 +96,11 @@ private:
QList<LabelLineEdit *> m_labelLineEdits;
QPlainTextEdit *m_nameFilters;
QLineEdit *m_selectedNameFilter;
+ QPushButton *m_deleteNonModalDialogButton;
+ QPushButton *m_deleteModalDialogButton;
QString m_result;
+ QPointer<QFileDialog> m_modalDialog;
+ QPointer<QFileDialog> m_nonModalDialog;
};
#endif // FILEDIALOGPANEL_H
diff --git a/tests/manual/dialogs/fontdialogpanel.cpp b/tests/manual/dialogs/fontdialogpanel.cpp
new file mode 100644
index 0000000000..2bdbb0625a
--- /dev/null
+++ b/tests/manual/dialogs/fontdialogpanel.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "fontdialogpanel.h"
+
+#include <QGroupBox>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QMessageBox>
+#include <QFontComboBox>
+#include <QDoubleSpinBox>
+#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)
+ , m_fontSizeBox(new QDoubleSpinBox)
+ , m_noButtons(new QCheckBox(tr("Don't display OK/Cancel buttons")))
+ , m_dontUseNativeDialog(new QCheckBox(tr("Don't use native dialog")))
+{
+ // Options
+ QGroupBox *optionsGroupBox = new QGroupBox(tr("Options"), this);
+ QVBoxLayout *optionsLayout = new QVBoxLayout(optionsGroupBox);
+ optionsLayout->addWidget(m_noButtons);
+ optionsLayout->addWidget(m_dontUseNativeDialog);
+
+ // Font
+ QGroupBox *fontGroupBox = new QGroupBox(tr("Font"), this);
+ QHBoxLayout *fontLayout = new QHBoxLayout(fontGroupBox);
+ fontLayout->addWidget(m_fontFamilyBox);
+ fontLayout->addWidget(m_fontSizeBox);
+ m_fontSizeBox->setValue(QFont().pointSizeF());
+
+ // Buttons
+ 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()));
+ m_deleteModalDialogButton =
+ addButton(tr("Delete modal"), buttonsLayout, this, SLOT(deleteModalDialog()));
+ addButton(tr("Show non-modal"), buttonsLayout, this, SLOT(showNonModal()));
+ m_deleteNonModalDialogButton =
+ addButton(tr("Delete non-modal"), buttonsLayout, this, SLOT(deleteNonModalDialog()));
+ addButton(tr("Restore defaults"), buttonsLayout, this, SLOT(restoreDefaults()));
+ buttonsLayout->addStretch();
+
+ // Main layout
+ QHBoxLayout *mainLayout = new QHBoxLayout(this);
+ QVBoxLayout *leftLayout = new QVBoxLayout;
+ leftLayout->addWidget(optionsGroupBox);
+ leftLayout->addWidget(fontGroupBox);
+ leftLayout->addStretch();
+ mainLayout->addLayout(leftLayout);
+ mainLayout->addWidget(buttonsGroupBox);
+
+ enableDeleteModalDialogButton();
+ enableDeleteNonModalDialogButton();
+ restoreDefaults();
+}
+
+void FontDialogPanel::execModal()
+{
+ QFontDialog dialog(this);
+ applySettings(&dialog);
+ connect(&dialog, SIGNAL(accepted()), this, SLOT(accepted()));
+ dialog.setWindowTitle(tr("Modal Font Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+ dialog.exec();
+}
+
+void FontDialogPanel::showModal()
+{
+ if (m_modalDialog.isNull()) {
+ static int n = 0;
+ m_modalDialog = new QFontDialog(this);
+ m_modalDialog->setModal(true);
+ connect(m_modalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
+ m_modalDialog->setWindowTitle(tr("Modal Font Dialog #%1 Qt %2")
+ .arg(++n)
+ .arg(QLatin1String(QT_VERSION_STR)));
+ enableDeleteModalDialogButton();
+ }
+ applySettings(m_modalDialog);
+ m_modalDialog->show();
+}
+
+void FontDialogPanel::showNonModal()
+{
+ if (m_nonModalDialog.isNull()) {
+ static int n = 0;
+ m_nonModalDialog = new QFontDialog(this);
+ connect(m_nonModalDialog.data(), SIGNAL(accepted()), this, SLOT(accepted()));
+ m_nonModalDialog->setWindowTitle(tr("Non-Modal Font Dialog #%1 Qt %2")
+ .arg(++n)
+ .arg(QLatin1String(QT_VERSION_STR)));
+ enableDeleteNonModalDialogButton();
+ }
+ applySettings(m_nonModalDialog);
+ m_nonModalDialog->show();
+}
+
+void FontDialogPanel::deleteNonModalDialog()
+{
+ if (!m_nonModalDialog.isNull())
+ delete m_nonModalDialog;
+ enableDeleteNonModalDialogButton();
+}
+
+void FontDialogPanel::deleteModalDialog()
+{
+ if (!m_modalDialog.isNull())
+ delete m_modalDialog;
+ enableDeleteModalDialogButton();
+}
+
+void FontDialogPanel::accepted()
+{
+ const QFontDialog *d = qobject_cast<const QFontDialog *>(sender());
+ Q_ASSERT(d);
+ m_result.clear();
+ QDebug(&m_result).nospace()
+ << "Current font: " << d->currentFont()
+ << "\nSelected font: " << d->selectedFont();
+ QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent.
+}
+
+void FontDialogPanel::showAcceptedResult()
+{
+ QMessageBox::information(this, tr("Color Dialog Accepted"), m_result, QMessageBox::Ok);
+}
+
+void FontDialogPanel::restoreDefaults()
+{
+ QFontDialog d;
+ m_noButtons->setChecked(d.testOption(QFontDialog::NoButtons));
+ m_dontUseNativeDialog->setChecked(d.testOption(QFontDialog::DontUseNativeDialog));
+ m_fontFamilyBox->setCurrentFont(QFont());
+ m_fontSizeBox->setValue(QFont().pointSizeF());
+}
+
+void FontDialogPanel::enableDeleteNonModalDialogButton()
+{
+ m_deleteNonModalDialogButton->setEnabled(!m_nonModalDialog.isNull());
+}
+
+void FontDialogPanel::enableDeleteModalDialogButton()
+{
+ m_deleteModalDialogButton->setEnabled(!m_modalDialog.isNull());
+}
+
+void FontDialogPanel::applySettings(QFontDialog *d) const
+{
+ d->setOption(QFontDialog::NoButtons, m_noButtons->isChecked());
+ d->setOption(QFontDialog::DontUseNativeDialog, m_dontUseNativeDialog->isChecked());
+
+ QFont font = m_fontFamilyBox->currentFont();
+ font.setPointSizeF(m_fontSizeBox->value());
+ d->setCurrentFont(font);
+}
diff --git a/tests/manual/dialogs/fontdialogpanel.h b/tests/manual/dialogs/fontdialogpanel.h
new file mode 100644
index 0000000000..92f2b7313f
--- /dev/null
+++ b/tests/manual/dialogs/fontdialogpanel.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FONTDIALOGPANEL_H
+#define FONTDIALOGPANEL_H
+
+#include <QPointer>
+#include <QFontDialog>
+
+class QCheckBox;
+class QPushButton;
+class QFontComboBox;
+class QDoubleSpinBox;
+
+class FontDialogPanel : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit FontDialogPanel(QWidget *parent = 0);
+
+public slots:
+ void execModal();
+ void showModal();
+ void showNonModal();
+ void deleteNonModalDialog();
+ void deleteModalDialog();
+ void accepted();
+ void showAcceptedResult();
+ void restoreDefaults();
+
+private slots:
+ void enableDeleteNonModalDialogButton();
+ void enableDeleteModalDialogButton();
+
+private:
+ void applySettings(QFontDialog *d) const;
+
+ QFontComboBox *m_fontFamilyBox;
+ QDoubleSpinBox *m_fontSizeBox;
+ QCheckBox *m_noButtons;
+ QCheckBox *m_dontUseNativeDialog;
+ QPushButton *m_deleteNonModalDialogButton;
+ QPushButton *m_deleteModalDialogButton;
+ QString m_result;
+ QPointer<QFontDialog> m_modalDialog;
+ QPointer<QFontDialog> m_nonModalDialog;
+};
+
+#endif // FONTDIALOGPANEL_H
diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp
index c1ea7b0d8f..f137df1f49 100644
--- a/tests/manual/dialogs/main.cpp
+++ b/tests/manual/dialogs/main.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include "filedialogpanel.h"
+#include "colordialogpanel.h"
+#include "fontdialogpanel.h"
#include <QMainWindow>
#include <QApplication>
@@ -50,7 +52,6 @@
#include <QKeySequence>
// Test for dialogs, allowing to play with all dialog options for implementing native dialogs.
-// Currently, only QFileDialog is implemented.
// Compiles with Qt 4.8 and Qt 5.
class MainWindow : public QMainWindow {
@@ -68,6 +69,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
QTabWidget *tabWidget = new QTabWidget;
tabWidget->addTab(new FileDialogPanel, tr("QFileDialog"));
+ tabWidget->addTab(new ColorDialogPanel, tr("QColorDialog"));
+ tabWidget->addTab(new FontDialogPanel, tr("QFontDialog"));
setCentralWidget(tabWidget);
}
diff --git a/tests/manual/lance/lance.pro b/tests/manual/lance/lance.pro
index 177ca0e40e..430c9196e6 100644
--- a/tests/manual/lance/lance.pro
+++ b/tests/manual/lance/lance.pro
@@ -1,5 +1,6 @@
LANCELOT_DIR = $$PWD/../../auto/other/lancelot
CONFIG+=console moc
+CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += . $$LANCELOT_DIR
QT += core-private gui-private widgets printsupport
diff --git a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
index 7a8c1d159d..b5aeb023f4 100644
--- a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
+++ b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
@@ -99,6 +99,9 @@ int main(int argc, char *argv[])
m.setRowCount(500);
m.setColumnCount(250);
tv.setModel(&m);
+ tv.setSelectionMode(QAbstractItemView::SingleSelection);
+ // Comment in the line below to test selection with keyboard (space)
+ // tv.setEditTriggers(QAbstractItemView::NoEditTriggers);
SomeHandler handler(tv.horizontalHeader(), &tv);
tv.horizontalHeader()->setDefaultSectionSize(30);
tv.show();
diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
index 186203e7d8..aec2479239 100644
--- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
+++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.cpp
@@ -60,11 +60,12 @@ public:
class MyGraphicsView : public QGraphicsView
{
-
+ Q_OBJECT
public:
- MyGraphicsView() : QGraphicsView()
+ MyGraphicsView(QWidget *w, QLabel *l) : QGraphicsView(w), rubberbandLabel(l)
{
setDragMode(QGraphicsView::RubberBandDrag);
+ connect(this, SIGNAL(rubberBandChanged(QRect, QPointF, QPointF)), this, SLOT(updateRubberbandInfo(QRect, QPointF, QPointF)));
}
protected:
void mouseMoveEvent(QMouseEvent *event)
@@ -81,26 +82,46 @@ protected:
if (yglobal > bottomPos)
verticalScrollBar()->setValue(verticalScrollBar()->value() + 10);
}
+
+protected slots:
+ void updateRubberbandInfo(QRect r, QPointF from, QPointF to)
+ {
+ QString textToShow;
+ QDebug s(&textToShow);
+ s << r << from << to;
+ rubberbandLabel->setText(textToShow);
+ }
+protected:
+ QLabel *rubberbandLabel;
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- MyGraphicsView v;
+
+ QWidget w;
+ w.setLayout(new QVBoxLayout);
+ QLabel *l = new QLabel(&w);
+ MyGraphicsView *v = new MyGraphicsView(&w, l);
+
+ w.layout()->addWidget(v);
+ w.layout()->addWidget(l);
QGraphicsScene s(0.0, 0.0, 5000.0, 5000.0);
- v.setScene(&s);
- v.setInteractive(true);
- v.setRubberBandSelectionMode(Qt::IntersectsItemBoundingRect);
- s.addRect( (qreal) 0.0, 0.0, 1000.0, 50.0, QPen(),QBrush(QColor(0,0,255)));
+ v->setScene(&s);
+ v->setInteractive(true);
+ v->setRubberBandSelectionMode(Qt::IntersectsItemBoundingRect);
for (int u = 0; u < 100; ++u)
- for (int v = 0; v < 100; ++v) {
+ for (int n = 0; n < 100; ++n) {
MyGraphicsItem *item = new MyGraphicsItem();
- item->setRect(QRectF(v * 80.0, u * 80.0, 50.0, 20.0));
+ item->setRect(QRectF(n * 80.0, u * 80.0, 50.0, 20.0));
s.addItem(item);
}
- v.show();
+
+ w.show();
app.exec();
return 0;
}
+
+#include "rubberbandtest.moc"
diff --git a/tests/manual/windowflags/controls.cpp b/tests/manual/windowflags/controls.cpp
index cad84617fc..422656ff03 100644
--- a/tests/manual/windowflags/controls.cpp
+++ b/tests/manual/windowflags/controls.cpp
@@ -123,8 +123,10 @@ Qt::WindowFlags HintControl::hints() const
flags |= Qt::WindowMinimizeButtonHint;
if (windowMaximizeButtonCheckBox->isChecked())
flags |= Qt::WindowMaximizeButtonHint;
+#if QT_VERSION >= 0x050000
if (windowFullscreenButtonCheckBox->isChecked())
flags |= Qt::WindowFullscreenButtonHint;
+#endif
if (windowCloseButtonCheckBox->isChecked())
flags |= Qt::WindowCloseButtonHint;
if (windowContextHelpButtonCheckBox->isChecked())
@@ -153,7 +155,9 @@ void HintControl::setHints(Qt::WindowFlags flags)
windowSystemMenuCheckBox->setChecked(flags & Qt::WindowSystemMenuHint);
windowMinimizeButtonCheckBox->setChecked(flags & Qt::WindowMinimizeButtonHint);
windowMaximizeButtonCheckBox->setChecked(flags & Qt::WindowMaximizeButtonHint);
+#if QT_VERSION >= 0x050000
windowFullscreenButtonCheckBox->setChecked(flags & Qt::WindowFullscreenButtonHint);
+#endif
windowCloseButtonCheckBox->setChecked(flags & Qt::WindowCloseButtonHint);
windowContextHelpButtonCheckBox->setChecked(flags & Qt::WindowContextHelpButtonHint);
windowShadeButtonCheckBox->setChecked(flags & Qt::WindowShadeButtonHint);