/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the tools applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the Technology Preview License Agreement accompanying ** this package. ** ** 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, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** ** ** ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qdeclarative.h" #include "qmlruntime.h" #include "qdeclarativeengine.h" #include "loggerwidget.h" #include #include #include #include #include #include #include #include "qdeclarativetester.h" QT_USE_NAMESPACE QtMsgHandler 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()) { QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings); } #endif exit(i); } QWeakPointer logger; static QAtomicInt recursiveLock(0); #if defined (Q_OS_SYMBIAN) #include #include #include #include #endif void myMessageOutput(QtMsgType type, const char *msg) { QString strMsg = QString::fromLatin1(msg); if (!QCoreApplication::closingDown()) { if (!logger.isNull()) { if (recursiveLock.testAndSetOrdered(0, 1)) { QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); recursiveLock = 0; } } else { warnings += strMsg; warnings += QLatin1Char('\n'); } } #if defined (Q_OS_SYMBIAN) static int fd = -1; if (fd == -1) fd = ::open("E:\\qml.log", O_WRONLY | O_CREAT); ::write(fd, msg, strlen(msg)); ::write(fd, "\n", 1); ::fsync(fd); switch (type) { case QtFatalMsg: abort(); } #endif if (systemMsgOutput) { systemMsgOutput(type, msg); } else { // Unix fprintf(stderr, "%s\n", msg); fflush(stderr); } } static QDeclarativeViewer* globalViewer = 0; // The qml file that is shown if the user didn't specify a QML file QString initialFile = "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_WS_MAC) qWarning(" -no-opengl ............................... don't use a QGLWidget for the viewport"); #else 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