summaryrefslogtreecommitdiffstats
path: root/tools/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qml')
-rw-r--r--tools/qml/loggerwidget.cpp70
-rw-r--r--tools/qml/loggerwidget.h63
-rw-r--r--tools/qml/main.cpp118
-rw-r--r--tools/qml/qdeclarativetester.cpp3
-rw-r--r--tools/qml/qml.pri7
-rw-r--r--tools/qml/qmlruntime.cpp3
6 files changed, 227 insertions, 37 deletions
diff --git a/tools/qml/loggerwidget.cpp b/tools/qml/loggerwidget.cpp
new file mode 100644
index 0000000..015d1b0
--- /dev/null
+++ b/tools/qml/loggerwidget.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 "loggerwidget.h"
+#include <qglobal.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+LoggerWidget::LoggerWidget(QWidget *parent) :
+ QPlainTextEdit(parent),
+ m_keepClosed(false)
+{
+ setAttribute(Qt::WA_QuitOnClose, false);
+ setWindowTitle(tr("Qt Declarative UI Viewer - Logger"));
+}
+
+void LoggerWidget::append(const QString &msg)
+{
+ appendPlainText(msg);
+
+ if (!m_keepClosed && !isVisible())
+ setVisible(true);
+}
+
+void LoggerWidget::closeEvent(QCloseEvent *event)
+{
+ m_keepClosed = true;
+ QWidget::closeEvent(event);
+}
+
+QT_END_NAMESPACE
diff --git a/tools/qml/loggerwidget.h b/tools/qml/loggerwidget.h
new file mode 100644
index 0000000..5c4a701
--- /dev/null
+++ b/tools/qml/loggerwidget.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#ifndef LOGGERWIDGET_H
+#define LOGGERWIDGET_H
+
+#include <QPlainTextEdit>
+
+QT_BEGIN_NAMESPACE
+
+class LoggerWidget : public QPlainTextEdit {
+Q_OBJECT
+public:
+ LoggerWidget(QWidget *parent=0);
+public slots:
+ void append(const QString &msg);
+protected:
+ void closeEvent(QCloseEvent *event);
+private:
+ bool m_keepClosed;
+};
+
+QT_END_NAMESPACE
+
+#endif // LOGGERWIDGET_H
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 5e829a4..cba5650 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -42,16 +42,20 @@
#include "qdeclarative.h"
#include "qmlruntime.h"
#include "qdeclarativeengine.h"
+#include "loggerwidget.h"
#include <QWidget>
#include <QDir>
#include <QApplication>
#include <QTranslator>
#include <QDebug>
+#include <QMessageBox>
#include "qdeclarativetester.h"
#include "qdeclarativefolderlistmodel.h"
QT_USE_NAMESPACE
+QtMsgHandler systemMsgOutput;
+
#if defined (Q_OS_SYMBIAN)
#include <unistd.h>
#include <sys/types.h>
@@ -73,6 +77,36 @@ void myMessageOutput(QtMsgType type, const char *msg)
abort();
}
}
+
+#else // !defined (Q_OS_SYMBIAN)
+
+QWeakPointer<LoggerWidget> logger;
+
+QString warnings;
+void showWarnings()
+{
+ if (!warnings.isEmpty()) {
+ QMessageBox::warning(0, QApplication::tr("Qt Declarative UI Runtime"), warnings);
+ }
+}
+
+void myMessageOutput(QtMsgType type, const char *msg)
+{
+ if (!logger.isNull()) {
+ QString strMsg = QString::fromAscii(msg);
+ QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
+ } else {
+ warnings += msg;
+ warnings += QLatin1Char('\n');
+ }
+ if (systemMsgOutput) { // Windows
+ systemMsgOutput(type, msg);
+ } else { // Unix
+ fprintf(stderr, "%s\n",msg);
+ fflush(stderr);
+ }
+}
+
#endif
void usage()
@@ -91,6 +125,7 @@ void usage()
qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content");
qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view");
qWarning(" -qmlbrowser .............................. use a QML-based file browser");
+ qWarning(" -nolog ................................... do not show log window");
qWarning(" -recordfile <output> ..................... set video recording file");
qWarning(" - ImageMagick 'convert' for GIF)");
qWarning(" - png file for raw frames");
@@ -137,6 +172,14 @@ int main(int argc, char ** argv)
{
#if defined (Q_OS_SYMBIAN)
qInstallMsgHandler(myMessageOutput);
+#else
+ systemMsgOutput = qInstallMsgHandler(myMessageOutput);
+#endif
+
+#if defined (Q_OS_WIN)
+ // Debugging output is not visible by default on Windows -
+ // therefore show modal dialog with errors instad.
+ atexit(showWarnings);
#endif
#if defined (Q_WS_X11)
@@ -186,6 +229,7 @@ int main(int argc, char ** argv)
bool stayOnTop = false;
bool maximized = false;
bool useNativeFileBrowser = true;
+ bool showLogWidget = true;
bool sizeToView = true;
#if defined(Q_OS_SYMBIAN)
@@ -237,8 +281,8 @@ int main(int argc, char ** argv)
if (lastArg) usage();
app.setStartDragDistance(QString(argv[++i]).toInt());
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
- fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR);
- return 0;
+ qWarning("Qt Declarative UI Viewer version %s", QT_VERSION_STR);
+ exit(0);
} else if (arg == "-translation") {
if (lastArg) usage();
translationFile = argv[++i];
@@ -246,14 +290,16 @@ int main(int argc, char ** argv)
useGL = true;
} else if (arg == "-qmlbrowser") {
useNativeFileBrowser = false;
+ } else if (arg == "-nolog") {
+ showLogWidget = false;
} else if (arg == "-I" || arg == "-L") {
if (arg == "-L")
- fprintf(stderr, "-L option provided for compatibility only, use -I instead");
+ qWarning("-L option provided for compatibility only, use -I instead");
if (lastArg) {
QDeclarativeEngine tmpEngine;
QString paths = tmpEngine.importPathList().join(QLatin1String(":"));
- fprintf(stderr, "Current search path: %s\n", paths.toLocal8Bit().constData());
- return 0;
+ qWarning("Current search path: %s", paths.toLocal8Bit().constData());
+ exit(0);
}
imports << QString(argv[++i]);
} else if (arg == "-P") {
@@ -294,7 +340,14 @@ int main(int argc, char ** argv)
if (stayOnTop)
wflags |= Qt::WindowStaysOnTopHint;
- QDeclarativeViewer viewer(0, wflags);
+#if !defined(Q_OS_SYMBIAN)
+ LoggerWidget loggerWidget(0);
+ if (showLogWidget) {
+ logger = &loggerWidget;
+ }
+#endif
+
+ QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags);
if (!scriptopts.isEmpty()) {
QStringList options =
scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts);
@@ -330,45 +383,45 @@ int main(int argc, char ** argv)
if (!(scriptOptions & QDeclarativeViewer::Record) && !(scriptOptions & QDeclarativeViewer::Play))
scriptOptsUsage();
- viewer.setScriptOptions(scriptOptions);
- viewer.setScript(script);
+ viewer->setScriptOptions(scriptOptions);
+ viewer->setScript(script);
} else if (!script.isEmpty()) {
usage();
}
- viewer.addLibraryPath(QCoreApplication::applicationDirPath());
+ viewer->addLibraryPath(QCoreApplication::applicationDirPath());
foreach (QString lib, imports)
- viewer.addLibraryPath(lib);
+ viewer->addLibraryPath(lib);
foreach (QString plugin, plugins)
- viewer.addPluginPath(plugin);
+ viewer->addPluginPath(plugin);
- viewer.setNetworkCacheSize(cache);
- viewer.setRecordFile(recordfile);
- viewer.setSizeToView(sizeToView);
+ viewer->setNetworkCacheSize(cache);
+ viewer->setRecordFile(recordfile);
+ viewer->setSizeToView(sizeToView);
if (resizeview)
- viewer.setScaleView();
+ viewer->setScaleView();
if (fps>0)
- viewer.setRecordRate(fps);
+ viewer->setRecordRate(fps);
if (autorecord_to)
- viewer.setAutoRecord(autorecord_from,autorecord_to);
+ viewer->setAutoRecord(autorecord_from,autorecord_to);
if (!skin.isEmpty()) {
if (skin == "list") {
- foreach (QString s, viewer.builtinSkins())
+ foreach (QString s, viewer->builtinSkins())
qWarning() << qPrintable(s);
exit(0);
} else {
- viewer.setSkin(skin);
+ viewer->setSkin(skin);
}
}
if (devkeys)
- viewer.setDeviceKeys(true);
- viewer.setRecordDither(dither);
+ viewer->setDeviceKeys(true);
+ viewer->setRecordDither(dither);
if (recordargs.count())
- viewer.setRecordArgs(recordargs);
+ viewer->setRecordArgs(recordargs);
- viewer.setUseNativeFileBrowser(useNativeFileBrowser);
+ viewer->setUseNativeFileBrowser(useNativeFileBrowser);
if (fullScreen && maximized)
qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen.";
@@ -387,16 +440,19 @@ int main(int argc, char ** argv)
}
if (!fileName.isEmpty()) {
- viewer.open(fileName);
- fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show();
+ viewer->open(fileName);
+ fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show();
} else {
if (!useNativeFileBrowser)
- viewer.openFile();
- fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show();
+ viewer->openFile();
+ fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show();
if (useNativeFileBrowser)
- viewer.openFile();
+ viewer->openFile();
}
- viewer.setUseGL(useGL);
- viewer.raise();
- return app.exec();
+ viewer->setUseGL(useGL);
+ viewer->raise();
+
+ int rv = app.exec();
+ delete viewer;
+ exit(rv);
}
diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp
index 11fa22f..6a6048a 100644
--- a/tools/qml/qdeclarativetester.cpp
+++ b/tools/qml/qdeclarativetester.cpp
@@ -251,7 +251,8 @@ void QDeclarativeTester::updateCurrentTime(int msec)
m_view->render(&p);
}
- bool snapshot = msec == 16 && options & QDeclarativeViewer::Snapshot;
+ bool snapshot = msec == 16 && (options & QDeclarativeViewer::Snapshot
+ || (testscript && testscript->count() == 2));
FrameEvent fe;
fe.msec = msec;
diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri
index c48e919..d343c76 100644
--- a/tools/qml/qml.pri
+++ b/tools/qml/qml.pri
@@ -10,11 +10,13 @@ HEADERS += $$PWD/qmlruntime.h \
$$PWD/proxysettings.h \
$$PWD/qdeclarativetester.h \
$$PWD/deviceorientation.h \
- $$PWD/qdeclarativefolderlistmodel.h
+ $$PWD/qdeclarativefolderlistmodel.h \
+ $$PWD/loggerwidget.h
SOURCES += $$PWD/qmlruntime.cpp \
$$PWD/proxysettings.cpp \
$$PWD/qdeclarativetester.cpp \
- $$PWD/qdeclarativefolderlistmodel.cpp
+ $$PWD/qdeclarativefolderlistmodel.cpp \
+ $$PWD/loggerwidget.cpp
RESOURCES = $$PWD/qmlruntime.qrc
maemo5 {
@@ -26,4 +28,3 @@ FORMS = $$PWD/recopts.ui \
$$PWD/proxysettings.ui
include(../shared/deviceskin/deviceskin.pri)
-
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 7b4706b..87a4d21 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -1000,7 +1000,6 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
t.start();
canvas->setSource(url);
- qWarning() << "Wall startup time:" << t.elapsed();
return true;
}
@@ -1431,7 +1430,7 @@ void QDeclarativeViewer::registerTypes()
if (!registered) {
// registering only for exposing the DeviceOrientation::Orientation enum
- qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation");
+ qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation","");
registered = true;
}
}