/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the tools applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** 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 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** 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. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include "qdeclarative.h" #include "qmlruntime.h" #include "qdeclarativeengine.h" #include "loggerwidget.h" #include "qdeclarativetester.h" QT_USE_NAMESPACE QtMessageHandler systemMsgOutput = 0; static QDeclarativeViewer *openFile(const QString &fileName); static void showViewer(QDeclarativeViewer *viewer); QString warnings; void exitApp(int i) { #ifdef Q_OS_WIN // Debugging output is not visible by default on Windows - // therefore show modal dialog with errors instead. if (!warnings.isEmpty()) { const QString message = QStringLiteral("
") + warnings + QStringLiteral("
"); QMessageBox::warning(0, QApplication::translate("QDeclarativeViewer", "Qt QML Viewer"), message); } #endif exit(i); } QPointer logger; static QAtomicInt recursiveLock(0); void myMessageOutput(QtMsgType type, const QMessageLogContext &ctxt, const QString &msg) { if (!QCoreApplication::closingDown()) { if (!logger.isNull()) { if (recursiveLock.testAndSetOrdered(0, 1)) { QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, msg)); recursiveLock = 0; } } else { warnings += msg; warnings += QLatin1Char('\n'); } } if (systemMsgOutput) { systemMsgOutput(type, ctxt, msg); } else { // Unix fprintf(stderr, "%s\n", msg.toLocal8Bit().constData()); fflush(stderr); } } static QDeclarativeViewer* globalViewer = 0; // The qml file that is shown if the user didn't specify a QML file QString initialFile = QLatin1String("qrc:/startup/startup.qml"); void usage() { qWarning("Usage: qmlviewer [options] "); qWarning(" "); qWarning(" options:"); qWarning(" -v, -version ............................. display version"); qWarning(" -frameless ............................... run with no window frame"); qWarning(" -maximized................................ run maximized"); qWarning(" -fullscreen............................... run fullscreen"); qWarning(" -stayontop................................ keep viewer window on top"); qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view (default)"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); qWarning(" -warnings [show|hide]..................... show warnings in a separate log window"); qWarning(" -recordfile ..................... set video recording file"); qWarning(" - ImageMagick 'convert' for GIF)"); qWarning(" - png file for raw frames"); qWarning(" - 'ffmpeg' for other formats"); qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode"); qWarning(" -recordrate ........................ set recording frame rate"); qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-] ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); qWarning(" -dragthreshold .................... set mouse drag threshold size"); qWarning(" -netcache ......................... set disk cache to size bytes"); qWarning(" -translation ........... set the language to run in"); qWarning(" -I ........................... prepend to the module import search path,"); qWarning(" display path if is empty"); qWarning(" -P ........................... prepend to the plugin search path"); #if defined(Q_OS_MAC) qWarning(" -no-opengl ............................... don't use a QGLWidget for the viewport"); qWarning(" -opengl .................................. use a QGLWidget for the viewport (default)"); #else qWarning(" -no-opengl ............................... don't use a QGLWidget for the viewport (default)"); qWarning(" -opengl .................................. use a QGLWidget for the viewport"); #endif qWarning(" -script ........................... set the script to use"); qWarning(" -scriptopts |help ............... set the script options to use"); qWarning(" "); qWarning(" Press F1 for interactive help"); exitApp(1); } void scriptOptsUsage() { qWarning("Usage: qmlviewer -scriptopts