2012-10-25 10:45:13 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-10-25 10:45:13 +00:00
|
|
|
**
|
2013-05-24 13:49:24 +00:00
|
|
|
** This file is part of the test suite of the Qt Toolkit.
|
2012-10-25 10:45:13 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-10-25 10:45:13 +00:00
|
|
|
** 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
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-10-25 10:45:13 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** 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.
|
2012-10-25 10:45:13 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "filedialogpanel.h"
|
2013-01-29 17:47:20 +00:00
|
|
|
#include "colordialogpanel.h"
|
2013-02-04 13:51:15 +00:00
|
|
|
#include "fontdialogpanel.h"
|
2013-11-01 11:46:42 +00:00
|
|
|
#include "printdialogpanel.h"
|
2013-03-05 13:45:51 +00:00
|
|
|
#include "wizardpanel.h"
|
2013-06-11 18:27:28 +00:00
|
|
|
#include "messageboxpanel.h"
|
2012-10-25 10:45:13 +00:00
|
|
|
|
2018-04-05 07:47:48 +00:00
|
|
|
#include <QLibraryInfo>
|
|
|
|
#include <QDialogButtonBox>
|
2012-10-25 10:45:13 +00:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QTabWidget>
|
2018-04-05 07:47:48 +00:00
|
|
|
#include <QFormLayout>
|
2012-10-25 10:45:13 +00:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QKeySequence>
|
|
|
|
|
2018-11-09 11:59:38 +00:00
|
|
|
static bool optNoPrinter = false;
|
|
|
|
|
2012-10-25 10:45:13 +00:00
|
|
|
// Test for dialogs, allowing to play with all dialog options for implementing native dialogs.
|
|
|
|
// Compiles with Qt 4.8 and Qt 5.
|
|
|
|
|
2018-04-05 07:47:48 +00:00
|
|
|
class AboutDialog : public QDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AboutDialog(QWidget *parent = 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
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));
|
|
|
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal);
|
|
|
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
|
|
|
mainLayout->addRow(buttonBox);
|
|
|
|
}
|
|
|
|
|
2012-10-25 10:45:13 +00:00
|
|
|
class MainWindow : public QMainWindow {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit MainWindow(QWidget *parent = 0);
|
2018-04-05 07:47:48 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void aboutDialog();
|
2012-10-25 10:45:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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()));
|
2014-03-31 12:17:29 +00:00
|
|
|
QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
|
|
|
|
QAction *action = editMenu->addAction(tr("Cut"));
|
2018-11-14 13:58:47 +00:00
|
|
|
action->setShortcut(QKeySequence(QKeySequence::Cut));
|
2014-03-31 12:17:29 +00:00
|
|
|
action = editMenu->addAction(tr("Copy"));
|
|
|
|
action->setShortcut(QKeySequence(QKeySequence::Copy));
|
|
|
|
action = editMenu->addAction(tr("Paste"));
|
|
|
|
action->setShortcut(QKeySequence(QKeySequence::Paste));
|
|
|
|
action = editMenu->addAction(tr("Select All"));
|
|
|
|
action->setShortcut(QKeySequence(QKeySequence::SelectAll));
|
2018-04-05 07:47:48 +00:00
|
|
|
QMenu *aboutMenu = menuBar()->addMenu(tr("&About"));
|
|
|
|
QAction *aboutAction = aboutMenu->addAction(tr("About..."), this, SLOT(aboutDialog()));
|
|
|
|
aboutAction->setShortcut(Qt::Key_F1);
|
2012-10-25 10:45:13 +00:00
|
|
|
QTabWidget *tabWidget = new QTabWidget;
|
|
|
|
tabWidget->addTab(new FileDialogPanel, tr("QFileDialog"));
|
2013-01-29 17:47:20 +00:00
|
|
|
tabWidget->addTab(new ColorDialogPanel, tr("QColorDialog"));
|
2013-02-04 13:51:15 +00:00
|
|
|
tabWidget->addTab(new FontDialogPanel, tr("QFontDialog"));
|
2013-03-05 13:45:51 +00:00
|
|
|
tabWidget->addTab(new WizardPanel, tr("QWizard"));
|
2013-06-11 18:27:28 +00:00
|
|
|
tabWidget->addTab(new MessageBoxPanel, tr("QMessageBox"));
|
2013-11-01 11:46:42 +00:00
|
|
|
#ifndef QT_NO_PRINTER
|
2018-11-09 11:59:38 +00:00
|
|
|
if (!optNoPrinter)
|
|
|
|
tabWidget->addTab(new PrintDialogPanel, tr("QPrintDialog"));
|
2013-11-01 11:46:42 +00:00
|
|
|
#endif
|
2012-10-25 10:45:13 +00:00
|
|
|
setCentralWidget(tabWidget);
|
|
|
|
}
|
|
|
|
|
2018-04-05 07:47:48 +00:00
|
|
|
void MainWindow::aboutDialog()
|
|
|
|
{
|
|
|
|
AboutDialog dialog(this);
|
|
|
|
dialog.setWindowTitle(tr("About Dialogs"));
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2012-10-25 10:45:13 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2016-08-15 14:02:39 +00:00
|
|
|
for (int a = 1; a < argc; ++a) {
|
|
|
|
if (!qstrcmp(argv[a], "-n")) {
|
|
|
|
qDebug("AA_DontUseNativeDialogs");
|
2018-11-09 11:59:38 +00:00
|
|
|
#if QT_VERSION >= 0x050700
|
2016-08-15 14:02:39 +00:00
|
|
|
QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
|
2018-11-09 11:59:38 +00:00
|
|
|
#endif
|
|
|
|
} else if (!qstrcmp(argv[a], "-p")) {
|
|
|
|
optNoPrinter = true; // Avoid startup slowdown by printer code
|
2016-08-15 14:02:39 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-15 16:26:53 +00:00
|
|
|
|
2012-10-25 10:45:13 +00:00
|
|
|
QApplication a(argc, argv);
|
|
|
|
MainWindow w;
|
|
|
|
w.move(500, 200);
|
|
|
|
w.show();
|
|
|
|
return a.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "main.moc"
|