Manual dialogs test: Add option to turn off the printer panel

On Linux, the printer panel impacts the application startup time,which
can be annoying when testing other dialogs.

Change-Id: Id13446047cf50765951a6bb5182ee50cae983457
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Friedemann Kleint 2018-11-09 12:59:38 +01:00 committed by Liang Qi
parent 49bbc9df99
commit 79ed504f10

View File

@ -44,6 +44,8 @@
#include <QAction>
#include <QKeySequence>
static bool optNoPrinter = false;
// Test for dialogs, allowing to play with all dialog options for implementing native dialogs.
// Compiles with Qt 4.8 and Qt 5.
@ -109,6 +111,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
tabWidget->addTab(new WizardPanel, tr("QWizard"));
tabWidget->addTab(new MessageBoxPanel, tr("QMessageBox"));
#ifndef QT_NO_PRINTER
if (!optNoPrinter)
tabWidget->addTab(new PrintDialogPanel, tr("QPrintDialog"));
#endif
setCentralWidget(tabWidget);
@ -123,14 +126,16 @@ void MainWindow::aboutDialog()
int main(int argc, char *argv[])
{
#if QT_VERSION >= 0x050700
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
}
}
#endif // Qt 5
QApplication a(argc, argv);
MainWindow w;