summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/cocoa/menus/main.cpp74
-rw-r--r--tests/manual/dialogs/dialogs.pro8
-rw-r--r--tests/manual/dialogs/filedialogpanel.cpp373
-rw-r--r--tests/manual/dialogs/filedialogpanel.h93
-rw-r--r--tests/manual/dialogs/main.cpp83
-rw-r--r--tests/manual/manual.pro3
6 files changed, 626 insertions, 8 deletions
diff --git a/tests/manual/cocoa/menus/main.cpp b/tests/manual/cocoa/menus/main.cpp
index 736ca134ff..760115ce25 100644
--- a/tests/manual/cocoa/menus/main.cpp
+++ b/tests/manual/cocoa/menus/main.cpp
@@ -39,9 +39,12 @@
**
****************************************************************************/
-#include <QtGui>
-#include <QtWidgets>
-
+#include <QMainWindow>
+#include <QMenu>
+#include <QApplication>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QDebug>
class Responder : public QObject
{
@@ -49,13 +52,34 @@ class Responder : public QObject
public:
Responder(QObject *pr) :
- QObject(pr)
+ QObject(pr), visibleMenu(0), visibleSubMenu(0), enabledMenu(0), enabledSubMenu(0), visibleAction(0), enabledAction(0)
{
}
-
+ void setVisibleObjects(QMenu *vm, QMenu *vsm, QAction *va)
+ {
+ visibleMenu = vm;
+ visibleSubMenu = vsm;
+ visibleAction = va;
+ }
+ void setEnabledObjects(QMenu *em, QMenu *esm, QAction *ea)
+ {
+ enabledMenu = em;
+ enabledSubMenu = esm;
+ enabledAction = ea;
+ }
public slots:
-
-
+ void toggleVisiblity()
+ {
+ visibleMenu->menuAction()->setVisible(!visibleMenu->menuAction()->isVisible());
+ visibleSubMenu->menuAction()->setVisible(!visibleSubMenu->menuAction()->isVisible());
+ visibleAction->setVisible(!visibleAction->isVisible());
+ }
+ void toggleEnabled()
+ {
+ enabledMenu->menuAction()->setEnabled(!enabledMenu->menuAction()->isEnabled());
+ enabledSubMenu->menuAction()->setEnabled(!enabledSubMenu->menuAction()->isEnabled());
+ enabledAction->setEnabled(!enabledAction->isEnabled());
+ }
void toggleChecked(bool b)
{
QAction *a = qobject_cast<QAction *>(sender());
@@ -82,6 +106,9 @@ public slots:
m->addAction(QString("Recent File %1").arg(i + 1));
}
}
+private:
+ QMenu *visibleMenu, *visibleSubMenu, *enabledMenu, *enabledSubMenu;
+ QAction *visibleAction, *enabledAction;
};
void createWindow1()
@@ -156,6 +183,39 @@ void createWindow1()
menu2->addAction(checkableAction);
+ QMenu *menu4 = new QMenu("Toggle menu", window);
+ QAction *toggleVisiblity = new QAction("Toggle visibility", window);
+ QAction *toggleEnabled = new QAction("Toggle enabled", window);
+ QObject::connect(toggleVisiblity, SIGNAL(triggered()), r, SLOT(toggleVisiblity()));
+ QObject::connect(toggleEnabled, SIGNAL(triggered()), r, SLOT(toggleEnabled()));
+ menu4->addAction(toggleVisiblity);
+ menu4->addAction(toggleEnabled);
+ window->menuBar()->addMenu(menu4);
+
+ QMenu *menu5 = new QMenu("Visible Menu", window);
+ menu5->addAction("Dummy action");
+ window->menuBar()->addMenu(menu5);
+ QMenu *menu6 = new QMenu("Menu with visible action and submenu", window);
+ QAction *visibleAction = new QAction("Visible action", window);
+ menu6->addAction(visibleAction);
+ QMenu *subMenu6 = new QMenu("Submenu");
+ subMenu6->addAction("Dummy action");
+ menu6->addMenu(subMenu6);
+ window->menuBar()->addMenu(menu6);
+
+ QMenu *menu7 = new QMenu("Enabled Menu", window);
+ menu7->addAction("Dummy action");
+ window->menuBar()->addMenu(menu7);
+ QMenu *menu8 = new QMenu("Menu with enabled action and submenu", window);
+ QAction *enabledAction = new QAction("Enabled action", window);
+ menu8->addAction(enabledAction);
+ QMenu *subMenu8 = new QMenu("Submenu");
+ subMenu8->addAction("Dummy action");
+ menu8->addMenu(subMenu8);
+ window->menuBar()->addMenu(menu8);
+
+ r->setVisibleObjects(menu5, subMenu6, visibleAction);
+ r->setEnabledObjects(menu7, subMenu8, enabledAction);
window->show();
}
diff --git a/tests/manual/dialogs/dialogs.pro b/tests/manual/dialogs/dialogs.pro
new file mode 100644
index 0000000000..ff916d3854
--- /dev/null
+++ b/tests/manual/dialogs/dialogs.pro
@@ -0,0 +1,8 @@
+QT += core gui
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = dialogs
+TEMPLATE = app
+
+SOURCES += main.cpp filedialogpanel.cpp
+HEADERS += filedialogpanel.h
diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp
new file mode 100644
index 0000000000..4da3d6ee42
--- /dev/null
+++ b/tests/manual/dialogs/filedialogpanel.cpp
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 "filedialogpanel.h"
+
+#include <QGridLayout>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QFormLayout>
+#include <QSpacerItem>
+#include <QGroupBox>
+#include <QComboBox>
+#include <QPushButton>
+#include <QCheckBox>
+#include <QLineEdit>
+#include <QPlainTextEdit>
+#include <QLabel>
+#include <QMessageBox>
+#include <QApplication>
+
+#include <QTimer>
+#include <QDebug>
+
+struct ComboData
+{
+ const char *description;
+ int value;
+};
+
+const ComboData acceptModeComboData[] =
+{
+{"AcceptOpen", QFileDialog::AcceptOpen },
+{"AcceptSave", QFileDialog::AcceptSave }
+};
+
+const ComboData viewModeComboData[] =
+{
+ {"Detail", QFileDialog::Detail},
+ {"List", QFileDialog::List}
+};
+
+const ComboData fileModeComboData[] =
+{
+ {"AnyFile", QFileDialog::AnyFile},
+ {"ExistingFile", QFileDialog::ExistingFile},
+ {"ExistingFiles", QFileDialog::ExistingFiles},
+ {"Directory", QFileDialog::Directory},
+ {"DirectoryOnly", QFileDialog::DirectoryOnly}
+};
+
+static QComboBox *createCombo(QWidget *parent, const ComboData *d, size_t size)
+{
+ QComboBox *c = new QComboBox(parent);
+ for (size_t i = 0; i < size; ++i)
+ c->addItem(QLatin1String(d[i].description), QVariant(d[i].value));
+ return c;
+}
+
+template <class Enum>
+Enum comboBoxValue(const QComboBox *c)
+{
+ return static_cast<Enum>(c->itemData(c->currentIndex()).toInt());
+}
+
+inline void setComboBoxValue(QComboBox *c, int v)
+{
+ c->setCurrentIndex(c->findData(QVariant(v)));
+}
+
+static inline void addButton(const QString &desription, QBoxLayout *layout, QObject *receiver, const char *slotFunc)
+{
+ QPushButton *button = new QPushButton(desription);
+ QObject::connect(button, SIGNAL(clicked()), receiver, slotFunc);
+ layout->addWidget(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.
+
+class LabelLineEdit : public QLineEdit
+{
+ Q_OBJECT
+public:
+ explicit LabelLineEdit(QFileDialog::DialogLabel label, QWidget *parent = 0) : QLineEdit(parent), m_label(label), m_dirty(false)
+ {
+ connect(this, SIGNAL(textEdited(QString)), this, SLOT(setDirty()));
+ }
+
+ void restoreDefault(const QFileDialog *d)
+ {
+ setText(d->labelText(m_label));
+ m_dirty = false;
+ }
+
+ void apply(QFileDialog *d) const
+ {
+ if (m_dirty)
+ d->setLabelText(m_label, text());
+ }
+
+private slots:
+ void setDirty() { m_dirty = true; }
+
+private:
+ const QFileDialog::DialogLabel m_label;
+ bool m_dirty;
+};
+
+FileDialogPanel::FileDialogPanel(QWidget *parent)
+ : QWidget(parent)
+ , m_readOnly(new QCheckBox(tr("Read only")))
+ , m_confirmOverWrite(new QCheckBox(tr("Confirm overwrite")))
+ , m_nameFilterDetailsVisible(new QCheckBox(tr("Name filter details visible")))
+ , m_resolveSymLinks(new QCheckBox(tr("Resolve symlinks")))
+ , m_native(new QCheckBox(tr("Use native dialog")))
+ , m_acceptMode(createCombo(this, acceptModeComboData, sizeof(acceptModeComboData)/sizeof(ComboData)))
+ , m_fileMode(createCombo(this, fileModeComboData, sizeof(fileModeComboData)/sizeof(ComboData)))
+ , m_viewMode(createCombo(this, viewModeComboData, sizeof(viewModeComboData)/sizeof(ComboData)))
+ , m_defaultSuffix(new QLineEdit(this))
+ , m_directory(new QLineEdit(this))
+ , m_selectedFileName(new QLineEdit(this))
+ , m_nameFilters(new QPlainTextEdit)
+ , m_selectedNameFilter(new QLineEdit(this))
+{
+ // Options
+ QGroupBox *optionsGroupBox = new QGroupBox(tr("Options"));
+ QFormLayout *optionsLayout = new QFormLayout(optionsGroupBox);
+ optionsLayout->addRow(tr("AcceptMode:"), m_acceptMode);
+ optionsLayout->addRow(tr("FileMode:"), m_fileMode);
+ optionsLayout->addRow(tr("ViewMode:"), m_viewMode);
+ optionsLayout->addRow(m_native);
+ optionsLayout->addRow(m_confirmOverWrite);
+ optionsLayout->addRow(m_nameFilterDetailsVisible);
+ optionsLayout->addRow(m_resolveSymLinks);
+ optionsLayout->addRow(m_readOnly);
+
+ // Files
+ QGroupBox *filesGroupBox = new QGroupBox(tr("Files / Filters"));
+ QFormLayout *filesLayout = new QFormLayout(filesGroupBox);
+ filesLayout->addRow(tr("Default Suffix:"), m_defaultSuffix);
+ filesLayout->addRow(tr("Directory:"), m_directory);
+ filesLayout->addRow(tr("Selected file:"), m_selectedFileName);
+ m_nameFilters->setMaximumHeight(80);
+ filesLayout->addRow(tr("Name filters:"), m_nameFilters);
+ filesLayout->addRow(tr("Selected name filter:"), m_selectedNameFilter);
+
+ // Optional labels
+ QGroupBox *labelsGroupBox = new QGroupBox(tr("Labels"));
+ QFormLayout *labelsLayout = new QFormLayout(labelsGroupBox);
+ m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::LookIn, this));
+ labelsLayout->addRow(tr("Look in label:"), m_labelLineEdits.back());
+ m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::FileName, this));
+ labelsLayout->addRow(tr("File name label:"), m_labelLineEdits.back());
+ m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::FileType, this));
+ labelsLayout->addRow(tr("File type label:"), m_labelLineEdits.back());
+ m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::Accept, this));
+ labelsLayout->addRow(tr("Accept label:"), m_labelLineEdits.back());
+ m_labelLineEdits.push_back(new LabelLineEdit(QFileDialog::Reject, this));
+ 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);
+
+ // Main layout
+ QGridLayout *gridLayout = new QGridLayout(this);
+ gridLayout->addWidget(optionsGroupBox, 0, 0);
+ gridLayout->addWidget(filesGroupBox, 0, 1);
+ gridLayout->addWidget(labelsGroupBox, 1, 0);
+ gridLayout->addWidget(buttonsGroupBox, 1, 1);
+
+ restoreDefaults();
+}
+
+void FileDialogPanel::showModal()
+{
+ QFileDialog dialog(this);
+ applySettings(&dialog);
+ dialog.setWindowTitle(tr("Modal File Dialog Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+ dialog.exec();
+}
+
+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();
+}
+
+QString FileDialogPanel::filterString() const
+{
+ return m_nameFilters->toPlainText().trimmed().replace(QLatin1String("\n"), QLatin1String(";;"));
+}
+
+QFileDialog::Options FileDialogPanel::options() const
+{
+ QFileDialog::Options result;
+ if (!m_nameFilterDetailsVisible->isChecked())
+ result |= QFileDialog::HideNameFilterDetails;
+ if (!m_resolveSymLinks->isChecked())
+ result |= QFileDialog::DontResolveSymlinks;
+ if (m_readOnly->isChecked())
+ result |= QFileDialog::ReadOnly;
+ if (!m_confirmOverWrite->isChecked())
+ result |= QFileDialog::DontConfirmOverwrite;
+ if (!m_native->isChecked())
+ result |= QFileDialog::DontUseNativeDialog;
+ return result;
+}
+
+void FileDialogPanel::getOpenFileNames()
+{
+ QString selectedFilter = m_selectedNameFilter->text().trimmed();
+ const QStringList files =
+ QFileDialog::getOpenFileNames(this, tr("getOpenFileNames Qt %1").arg(QLatin1String(QT_VERSION_STR)),
+ m_directory->text(), filterString(), &selectedFilter, options());
+ if (!files.isEmpty()) {
+ QString result;
+ QDebug(&result).nospace()
+ << "Files: " << files
+ << "\nName filter: " << selectedFilter;
+ QMessageBox::information(this, tr("getOpenFileNames"), result, QMessageBox::Ok);
+ }
+}
+
+void FileDialogPanel::getOpenFileName()
+{
+ QString selectedFilter = m_selectedNameFilter->text().trimmed();
+ const QString file =
+ QFileDialog::getOpenFileName(this, tr("getOpenFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)),
+ m_directory->text(), filterString(), &selectedFilter, options());
+ if (!file.isEmpty()) {
+ QString result;
+ QDebug(&result).nospace()
+ << "File: " << file
+ << "\nName filter: " << selectedFilter;
+ QMessageBox::information(this, tr("getOpenFileName"), result, QMessageBox::Ok);
+ }
+}
+
+void FileDialogPanel::getSaveFileName()
+{
+ QString selectedFilter = m_selectedNameFilter->text().trimmed();
+ const QString file =
+ QFileDialog::getSaveFileName(this, tr("getSaveFileName Qt %1").arg(QLatin1String(QT_VERSION_STR)),
+ m_directory->text(), filterString(), &selectedFilter, options());
+ if (!file.isEmpty()) {
+ QString result;
+ QDebug(&result).nospace()
+ << "File: " << file
+ << "\nName filter: " << selectedFilter;
+ QMessageBox::information(this, tr("getSaveFileNames"), result, QMessageBox::Ok);
+ }
+}
+
+void FileDialogPanel::getExistingDirectory()
+{
+ const QString dir =
+ QFileDialog::getExistingDirectory(this, tr("getExistingDirectory Qt %1").arg(QLatin1String(QT_VERSION_STR)),
+ m_directory->text(), options() | QFileDialog::ShowDirsOnly);
+ if (!dir.isEmpty())
+ QMessageBox::information(this, tr("getExistingDirectory"), QLatin1String("Directory: ") + dir, QMessageBox::Ok);
+}
+
+void FileDialogPanel::restoreDefaults()
+{
+ QFileDialog d;
+ setComboBoxValue(m_acceptMode, d.acceptMode());
+ setComboBoxValue(m_fileMode, d.fileMode());
+ setComboBoxValue(m_viewMode, d.viewMode());
+ m_confirmOverWrite->setChecked(d.confirmOverwrite());
+ m_nameFilterDetailsVisible->setChecked(d.isNameFilterDetailsVisible());
+ m_resolveSymLinks->setChecked(d.resolveSymlinks());
+ m_readOnly->setChecked(d.isReadOnly());
+ m_native->setChecked(true);
+ m_directory->setText(QDir::homePath());
+ m_defaultSuffix->setText(QLatin1String(".txt"));
+ m_nameFilters->setPlainText(QLatin1String("Any files (*)\nImage files (*.png *.xpm *.jpg)\nText files (*.txt)"));
+ m_selectedFileName->setText(QString());
+ m_selectedNameFilter->setText(QString());
+ foreach (LabelLineEdit *l, m_labelLineEdits)
+ l->restoreDefault(&d);
+}
+
+void FileDialogPanel::applySettings(QFileDialog *d) const
+{
+ d->setAcceptMode(comboBoxValue<QFileDialog::AcceptMode>(m_acceptMode));
+ d->setViewMode(comboBoxValue<QFileDialog::ViewMode>(m_viewMode));
+ d->setFileMode(comboBoxValue<QFileDialog::FileMode>(m_fileMode));
+ d->setOptions(options());
+ d->setDefaultSuffix(m_defaultSuffix->text().trimmed());
+ d->setDirectory(m_directory->text().trimmed());
+ const QString file = m_selectedFileName->text().trimmed();
+ if (!file.isEmpty())
+ d->selectFile(file);
+ d->setNameFilters(m_nameFilters->toPlainText().trimmed().split(QLatin1Char('\n'), QString::SkipEmptyParts));
+ const QString filter = m_selectedNameFilter->text().trimmed();
+ if (!filter.isEmpty())
+ d->selectNameFilter(filter);
+ foreach (LabelLineEdit *l, m_labelLineEdits)
+ l->apply(d);
+ connect(d, SIGNAL(accepted()), this, SLOT(accepted()));
+}
+
+void FileDialogPanel::accepted()
+{
+ const QFileDialog *d = qobject_cast<const QFileDialog *>(sender());
+ Q_ASSERT(d);
+ m_result.clear();
+ QDebug(&m_result).nospace()
+ << "Files: " << d->selectedFiles()
+ << "\nDirectory: " << d->directory().absolutePath()
+ << "\nName filter: " << d->selectedNameFilter();
+ QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent.
+}
+
+void FileDialogPanel::showAcceptedResult()
+{
+ QMessageBox::information(this, tr("File Dialog Accepted"), m_result, QMessageBox::Ok);
+}
+
+#include "filedialogpanel.moc"
diff --git a/tests/manual/dialogs/filedialogpanel.h b/tests/manual/dialogs/filedialogpanel.h
new file mode 100644
index 0000000000..bc8b66535b
--- /dev/null
+++ b/tests/manual/dialogs/filedialogpanel.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 FILEDIALOGPANEL_H
+#define FILEDIALOGPANEL_H
+
+#include <QGroupBox>
+#include <QFileDialog>
+
+class QCheckBox;
+class QComboBox;
+class QLineEdit;
+class QPlainTextEdit;
+class LabelLineEdit;
+
+class FileDialogPanel : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit FileDialogPanel(QWidget *parent = 0);
+
+public slots:
+ void showModal();
+ void showNonModal();
+ void getOpenFileNames();
+ void getOpenFileName();
+ void getSaveFileName();
+ void getExistingDirectory();
+ void accepted();
+ void showAcceptedResult();
+ void restoreDefaults();
+
+private:
+ QString filterString() const;
+ QFileDialog::Options options() const;
+ void applySettings(QFileDialog *d) const;
+
+ QCheckBox *m_readOnly;
+ QCheckBox *m_confirmOverWrite;
+ QCheckBox *m_nameFilterDetailsVisible;
+ QCheckBox *m_resolveSymLinks;
+ QCheckBox *m_native;
+ QComboBox *m_acceptMode;
+ QComboBox *m_fileMode;
+ QComboBox *m_viewMode;
+ QLineEdit *m_defaultSuffix;
+ QLineEdit *m_directory;
+ QLineEdit *m_selectedFileName;
+ QList<LabelLineEdit *> m_labelLineEdits;
+ QPlainTextEdit *m_nameFilters;
+ QLineEdit *m_selectedNameFilter;
+ QString m_result;
+};
+
+#endif // FILEDIALOGPANEL_H
diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp
new file mode 100644
index 0000000000..ab6c623990
--- /dev/null
+++ b/tests/manual/dialogs/main.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 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 "filedialogpanel.h"
+
+#include <QMainWindow>
+#include <QApplication>
+#include <QMenuBar>
+#include <QTabWidget>
+#include <QMenu>
+#include <QAction>
+#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 {
+ Q_OBJECT
+public:
+ explicit MainWindow(QWidget *parent = 0);
+};
+
+MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
+{
+ setWindowTitle(tr("Dialogs Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+ QMenu *fileMenu = menuBar()->addMenu(tr("File"));
+ QAction *quitAction = fileMenu->addAction(tr("Quit"));
+ quitAction->setShortcut(QKeySequence(QKeySequence::Quit));
+ connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ QTabWidget *tabWidget = new QTabWidget;
+ tabWidget->addTab(new FileDialogPanel, tr("QFileDialog"));
+ setCentralWidget(tabWidget);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.move(500, 200);
+ w.show();
+ return a.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index 04bdff6abc..cfa812aaba 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -32,7 +32,8 @@ widgets/itemviews/delegate \
windowflags \
windowgeometry \
windowmodality \
-widgetgrab
+widgetgrab \
+dialogs
!contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions