Update qmlobserver with latest qmlviewer patches

Update qmlobserver with changes in qmlviewer until 376e636eccedb8d8bb.
This commit is contained in:
Kai Koehne
2010-12-10 12:27:33 +01:00
parent 77e3bfe845
commit 17d11b7be3
32 changed files with 1625 additions and 481 deletions

View File

@@ -14,5 +14,36 @@
<string>@TYPEINFO@</string>
<key>CFBundleExecutable</key>
<string>@EXECUTABLE@</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.nokia.qt.qml</string>
<key>UTTypeDescription</key>
<string>Qt Markup Language</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>qml</string>
</array>
</dict>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>LSItemContentTypes</key>
<array>
<string>com.nokia.qt.qml</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
</dict>
</plist>

View File

@@ -39,12 +39,12 @@
**
****************************************************************************/
import Qt 4.7
import QtQuick 1.0
import Qt.labs.folderlistmodel 1.0
Rectangle {
id: root
property bool keyPressed: false
property bool showFocusHighlight: false
property variant folders: folders1
property variant view: view1
width: 320
@@ -95,6 +95,19 @@ Rectangle {
view.focus = true;
folders.folder = path;
}
function keyPressed(key) {
switch (key) {
case Qt.Key_Up:
case Qt.Key_Down:
case Qt.Key_Left:
case Qt.Key_Right:
root.showFocusHighlight = true;
break;
default:
// do nothing
break;
}
}
Component {
id: folderDelegate
@@ -113,6 +126,7 @@ Rectangle {
Rectangle {
id: highlight; visible: false
anchors.fill: parent
color: palette.highlight
gradient: Gradient {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
@@ -128,12 +142,16 @@ Rectangle {
text: fileName
anchors.leftMargin: 54
font.pixelSize: 32
color: (wrapper.ListView.isCurrentItem && root.keyPressed) ? palette.highlightedText : palette.windowText
color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : palette.windowText
elide: Text.ElideRight
}
MouseArea {
id: mouseRegion
anchors.fill: parent
onPressed: {
root.showFocusHighlight = false;
wrapper.ListView.view.currentIndex = index;
}
onClicked: { if (folders == wrapper.ListView.view.model) launch() }
}
states: [
@@ -155,7 +173,15 @@ Rectangle {
width: parent.width
model: folders1
delegate: folderDelegate
highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view1.count != 0 }
highlight: Rectangle {
color: palette.highlight
visible: root.showFocusHighlight && view1.count != 0
gradient: Gradient {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
}
width: view1.currentItem == null ? 0 : view1.currentItem.width
}
highlightMoveSpeed: 1000
pressDelay: 100
focus: true
@@ -186,7 +212,7 @@ Rectangle {
NumberAnimation { properties: "x"; duration: 250 }
}
]
Keys.onPressed: { root.keyPressed = true; }
Keys.onPressed: root.keyPressed(event.key)
}
ListView {
@@ -197,7 +223,15 @@ Rectangle {
width: parent.width
model: folders2
delegate: folderDelegate
highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view2.count != 0 }
highlight: Rectangle {
color: palette.highlight
visible: root.showFocusHighlight && view2.count != 0
gradient: Gradient {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
}
width: view1.currentItem == null ? 0 : view1.currentItem.width
}
highlightMoveSpeed: 1000
pressDelay: 100
states: [
@@ -225,11 +259,11 @@ Rectangle {
NumberAnimation { properties: "x"; duration: 250 }
}
]
Keys.onPressed: { root.keyPressed = true; }
Keys.onPressed: root.keyPressed(event.key)
}
Keys.onPressed: {
root.keyPressed = true;
root.keyPressed(event.key);
if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) {
view.currentItem.launch();
event.accepted = true;

View File

@@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/browser">
<file>Browser.qml</file>
<file>images/up.png</file>
<file>images/folder.png</file>
<file>images/titlebar.sci</file>
<file>images/titlebar.png</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 662 B

After

Width:  |  Height:  |  Size: 662 B

View File

@@ -53,6 +53,11 @@ public:
return m_orientation;
}
void pauseListening() {
}
void resumeListening() {
}
void setOrientation(Orientation o) {
if (o != m_orientation) {
m_orientation = o;

View File

@@ -63,6 +63,9 @@ public:
virtual Orientation orientation() const = 0;
virtual void setOrientation(Orientation) = 0;
virtual void pauseListening() = 0;
virtual void resumeListening() = 0;
static DeviceOrientation *instance();
signals:

View File

@@ -0,0 +1,161 @@
/****************************************************************************
**
** 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 "deviceorientation.h"
#include <QtDBus>
#include <QDebug>
#define ORIENTATION_SERVICE "com.nokia.SensorService"
#define ORIENTATION_PATH "/org/maemo/contextkit/Screen/TopEdge"
#define CONTEXT_INTERFACE "org.maemo.contextkit.Property"
#define CONTEXT_CHANGED "ValueChanged"
#define CONTEXT_SUBSCRIBE "Subscribe"
#define CONTEXT_UNSUBSCRIBE "Unsubscribe"
#define CONTEXT_GET "Get"
class HarmattanOrientation : public DeviceOrientation
{
Q_OBJECT
public:
HarmattanOrientation()
: o(UnknownOrientation), sensorEnabled(false)
{
resumeListening();
// connect to the orientation change signal
bool ok = QDBusConnection::systemBus().connect(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE,
CONTEXT_CHANGED,
this,
SLOT(deviceOrientationChanged(QList<QVariant>,quint64)));
// qDebug() << "connection OK" << ok;
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_GET));
if (reply.type() != QDBusMessage::ErrorMessage) {
QList<QVariant> args;
qvariant_cast<QDBusArgument>(reply.arguments().at(0)) >> args;
deviceOrientationChanged(args, 0);
}
}
~HarmattanOrientation()
{
// unsubscribe from the orientation sensor
if (sensorEnabled)
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE));
}
inline Orientation orientation() const
{
return o;
}
void setOrientation(Orientation)
{
}
void pauseListening() {
if (sensorEnabled) {
// unsubscribe from the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE));
sensorEnabled = false;
}
}
void resumeListening() {
if (!sensorEnabled) {
// subscribe to the orientation sensor
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_SUBSCRIBE));
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
} else {
sensorEnabled = true;
}
}
}
private Q_SLOTS:
void deviceOrientationChanged(QList<QVariant> args,quint64)
{
if (args.count() == 0)
return;
Orientation newOrientation = toOrientation(args.at(0).toString());
if (newOrientation != o) {
o = newOrientation;
emit orientationChanged();
}
// qDebug() << "orientation" << args.at(0).toString();
}
private:
static Orientation toOrientation(const QString &nativeOrientation)
{
if (nativeOrientation == "top")
return Landscape;
else if (nativeOrientation == "left")
return Portrait;
else if (nativeOrientation == "bottom")
return LandscapeInverted;
else if (nativeOrientation == "right")
return PortraitInverted;
return UnknownOrientation;
}
private:
Orientation o;
bool sensorEnabled;
};
DeviceOrientation* DeviceOrientation::instance()
{
static HarmattanOrientation *o = new HarmattanOrientation;
return o;
}
#include "deviceorientation_harmattan.moc"

View File

@@ -50,23 +50,9 @@ class MaemoOrientation : public DeviceOrientation
Q_OBJECT
public:
MaemoOrientation()
: o(UnknownOrientation)
: o(UnknownOrientation), sensorEnabled(false)
{
// enable the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
// query the initial orientation
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET));
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
} else {
o = toOrientation(reply.arguments().value(0).toString());
}
resumeListening();
// connect to the orientation change signal
QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
MCE_DEVICE_ORIENTATION_SIG,
@@ -91,6 +77,40 @@ public:
{
}
void pauseListening() {
if (sensorEnabled) {
// disable the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ));
sensorEnabled = false;
}
}
void resumeListening() {
if (!sensorEnabled) {
// enable the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET));
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
} else {
Orientation orientation = toOrientation(reply.arguments().value(0).toString());
if (o != orientation) {
o = orientation;
emit orientationChanged();
}
sensorEnabled = true;
}
}
}
private Q_SLOTS:
void deviceOrientationChanged(const QString &newOrientation)
{
@@ -116,6 +136,7 @@ private:
private:
Orientation o;
bool sensorEnabled;
};
DeviceOrientation* DeviceOrientation::instance()

View File

@@ -0,0 +1,192 @@
/****************************************************************************
**
** 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 "deviceorientation.h"
#include <e32base.h>
#include <sensrvchannelfinder.h>
#include <sensrvdatalistener.h>
#include <sensrvchannel.h>
#include <sensrvorientationsensor.h>
class SymbianOrientation : public DeviceOrientation, public MSensrvDataListener
{
Q_OBJECT
public:
SymbianOrientation()
: DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0), m_channelOpen(false)
{
TRAP_IGNORE(initL());
if (!m_sensorChannel)
qWarning("No valid sensors found.");
}
~SymbianOrientation()
{
if (m_sensorChannel) {
m_sensorChannel->StopDataListening();
m_sensorChannel->CloseChannel();
delete m_sensorChannel;
}
}
void initL()
{
CSensrvChannelFinder *channelFinder = CSensrvChannelFinder::NewLC();
RSensrvChannelInfoList channelInfoList;
CleanupClosePushL(channelInfoList);
TSensrvChannelInfo searchConditions;
searchConditions.iChannelType = KSensrvChannelTypeIdOrientationData;
channelFinder->FindChannelsL(channelInfoList, searchConditions);
for (int i = 0; i < channelInfoList.Count(); ++i) {
TRAPD(error, m_sensorChannel = CSensrvChannel::NewL(channelInfoList[i]));
if (!error)
TRAP(error, m_sensorChannel->OpenChannelL());
if (!error) {
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
m_channelOpen = true;
break;
}
if (error) {
delete m_sensorChannel;
m_sensorChannel = 0;
}
}
channelInfoList.Close();
CleanupStack::Pop(&channelInfoList);
CleanupStack::PopAndDestroy(channelFinder);
}
Orientation orientation() const
{
return m_current;
}
void setOrientation(Orientation) { }
private:
DeviceOrientation::Orientation m_current;
CSensrvChannel *m_sensorChannel;
bool m_channelOpen;
void pauseListening() {
if (m_sensorChannel && m_channelOpen) {
m_sensorChannel->StopDataListening();
m_sensorChannel->CloseChannel();
m_channelOpen = false;
}
}
void resumeListening() {
if (m_sensorChannel && !m_channelOpen) {
TRAPD(error, m_sensorChannel->OpenChannelL());
if (!error) {
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
if (!error) {
m_channelOpen = true;
}
}
if (error) {
delete m_sensorChannel;
m_sensorChannel = 0;
}
}
}
void DataReceived(CSensrvChannel &channel, TInt count, TInt dataLost)
{
Q_UNUSED(dataLost)
if (channel.GetChannelInfo().iChannelType == KSensrvChannelTypeIdOrientationData) {
TSensrvOrientationData data;
for (int i = 0; i < count; ++i) {
TPckgBuf<TSensrvOrientationData> dataBuf;
channel.GetData(dataBuf);
data = dataBuf();
Orientation orientation = UnknownOrientation;
switch (data.iDeviceOrientation) {
case TSensrvOrientationData::EOrientationDisplayUp:
orientation = Portrait;
break;
case TSensrvOrientationData::EOrientationDisplayRightUp:
orientation = Landscape;
break;
case TSensrvOrientationData::EOrientationDisplayLeftUp:
orientation = LandscapeInverted;
break;
case TSensrvOrientationData::EOrientationDisplayDown:
orientation = PortraitInverted;
break;
case TSensrvOrientationData::EOrientationUndefined:
case TSensrvOrientationData::EOrientationDisplayUpwards:
case TSensrvOrientationData::EOrientationDisplayDownwards:
default:
break;
}
if (m_current != orientation && orientation != UnknownOrientation) {
m_current = orientation;
emit orientationChanged();
}
}
}
}
void DataError(CSensrvChannel& /* channel */, TSensrvErrorSeverity /* error */)
{
}
void GetDataListenerInterfaceL(TUid /* interfaceUid */, TAny*& /* interface */)
{
}
};
DeviceOrientation* DeviceOrientation::instance()
{
static SymbianOrientation *o = 0;
if (!o)
o = new SymbianOrientation;
return o;
}
#include "deviceorientation_symbian.moc"

View File

@@ -49,6 +49,7 @@
#include <QTranslator>
#include <QDebug>
#include <QMessageBox>
#include <QAtomicInt>
#include "qdeclarativetester.h"
#include "qt_private/qdeclarativedebughelper_p.h"
@@ -56,6 +57,9 @@ QT_USE_NAMESPACE
QtMsgHandler systemMsgOutput = 0;
static QDeclarativeViewer *openFile(const QString &fileName);
static void showViewer(QDeclarativeViewer *viewer);
#if defined (Q_OS_SYMBIAN)
#include <unistd.h>
#include <sys/types.h>
@@ -83,35 +87,50 @@ void myMessageOutput(QtMsgType type, const char *msg)
QWeakPointer<LoggerWidget> logger;
QString warnings;
void showWarnings()
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()) {
int argc = 0; char **argv = 0;
QApplication application(argc, argv); // QApplication() in main has been destroyed already.
Q_UNUSED(application)
QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings);
}
#endif
exit(i);
}
static QAtomicInt recursiveLock(0);
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');
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 (systemMsgOutput) { // Windows
systemMsgOutput(type, msg);
} else { // Unix
fprintf(stderr, "%s\n",msg);
fprintf(stderr, "%s\n", msg);
fflush(stderr);
}
}
#endif
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: qmlobserver [options] <filename>");
@@ -143,7 +162,11 @@ void usage()
qWarning(" -I <directory> ........................... prepend to the module import search path,");
qWarning(" display path if <directory> is empty");
qWarning(" -P <directory> ........................... 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
#ifndef NO_PRIVATE_HEADERS
qWarning(" -script <path> ........................... set the script to use");
qWarning(" -scriptopts <options>|help ............... set the script options to use");
@@ -151,7 +174,8 @@ void usage()
qWarning(" ");
qWarning(" Press F1 for interactive help");
exit(1);
exitApp(1);
}
void scriptOptsUsage()
@@ -162,6 +186,7 @@ void scriptOptsUsage()
qWarning(" play ..................................... playback an existing script");
qWarning(" testimages ............................... record images or compare images on playback");
qWarning(" testerror ................................ test 'error' property of root item on playback");
qWarning(" testskip ................................ test 'skip' property of root item on playback");
qWarning(" snapshot ................................. file being recorded is static,");
qWarning(" only one frame will be recorded or tested");
qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion");
@@ -169,11 +194,344 @@ void scriptOptsUsage()
qWarning(" saveonexit ............................... save recording on viewer exit");
qWarning(" ");
qWarning(" One of record, play or both must be specified.");
exit(1);
exitApp(1);
}
enum WarningsConfig { ShowWarnings, HideWarnings, DefaultWarnings };
struct ViewerOptions
{
ViewerOptions()
: frameless(false),
fps(0.0),
autorecord_from(0),
autorecord_to(0),
dither("none"),
runScript(false),
devkeys(false),
cache(0),
useGL(false),
fullScreen(false),
stayOnTop(false),
maximized(false),
useNativeFileBrowser(true),
experimentalGestures(false),
warningsConfig(DefaultWarnings),
sizeToView(true)
{
#if defined(Q_OS_SYMBIAN)
maximized = true;
useNativeFileBrowser = false;
#endif
#if defined(Q_WS_MAC)
useGL = true;
#endif
}
bool frameless;
double fps;
int autorecord_from;
int autorecord_to;
QString dither;
QString recordfile;
QStringList recordargs;
QStringList imports;
QStringList plugins;
QString script;
QString scriptopts;
bool runScript;
bool devkeys;
int cache;
QString translationFile;
bool useGL;
bool fullScreen;
bool stayOnTop;
bool maximized;
bool useNativeFileBrowser;
bool experimentalGestures;
WarningsConfig warningsConfig;
bool sizeToView;
QDeclarativeViewer::ScriptOptions scriptOptions;
};
static ViewerOptions opts;
static QStringList fileNames;
class Application : public QApplication
{
Q_OBJECT
public:
Application(int &argc, char **&argv)
: QApplication(argc, argv)
{}
protected:
bool event(QEvent *ev)
{
if (ev->type() != QEvent::FileOpen)
return QApplication::event(ev);
QFileOpenEvent *fev = static_cast<QFileOpenEvent *>(ev);
globalViewer->open(fev->file());
if (!globalViewer->isVisible())
showViewer(globalViewer);
return true;
}
private Q_SLOTS:
void showInitialViewer()
{
QApplication::processEvents();
QDeclarativeViewer *viewer = globalViewer;
if (!viewer)
return;
if (viewer->currentFile().isEmpty()) {
if(opts.useNativeFileBrowser)
viewer->open(initialFile);
else
viewer->openFile();
}
if (!viewer->isVisible())
showViewer(viewer);
}
};
static void parseScriptOptions()
{
QStringList options =
opts.scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts);
QDeclarativeViewer::ScriptOptions scriptOptions = 0;
for (int i = 0; i < options.count(); ++i) {
const QString &option = options.at(i);
if (option == QLatin1String("help")) {
scriptOptsUsage();
} else if (option == QLatin1String("play")) {
scriptOptions |= QDeclarativeViewer::Play;
} else if (option == QLatin1String("record")) {
scriptOptions |= QDeclarativeViewer::Record;
} else if (option == QLatin1String("testimages")) {
scriptOptions |= QDeclarativeViewer::TestImages;
} else if (option == QLatin1String("testerror")) {
scriptOptions |= QDeclarativeViewer::TestErrorProperty;
} else if (option == QLatin1String("testskip")) {
scriptOptions |= QDeclarativeViewer::TestSkipProperty;
} else if (option == QLatin1String("exitoncomplete")) {
scriptOptions |= QDeclarativeViewer::ExitOnComplete;
} else if (option == QLatin1String("exitonfailure")) {
scriptOptions |= QDeclarativeViewer::ExitOnFailure;
} else if (option == QLatin1String("saveonexit")) {
scriptOptions |= QDeclarativeViewer::SaveOnExit;
} else if (option == QLatin1String("snapshot")) {
scriptOptions |= QDeclarativeViewer::Snapshot;
} else {
scriptOptsUsage();
}
}
opts.scriptOptions = scriptOptions;
}
static void parseCommandLineOptions(const QStringList &arguments)
{
for (int i = 1; i < arguments.count(); ++i) {
bool lastArg = (i == arguments.count() - 1);
QString arg = arguments.at(i);
if (arg == "-frameless") {
opts.frameless = true;
} else if (arg == "-maximized") {
opts.maximized = true;
} else if (arg == "-fullscreen") {
opts.fullScreen = true;
} else if (arg == "-stayontop") {
opts.stayOnTop = true;
} else if (arg == "-netcache") {
if (lastArg) usage();
opts.cache = arguments.at(++i).toInt();
} else if (arg == "-recordrate") {
if (lastArg) usage();
opts.fps = arguments.at(++i).toDouble();
} else if (arg == "-recordfile") {
if (lastArg) usage();
opts.recordfile = arguments.at(++i);
} else if (arg == "-record") {
if (lastArg) usage();
opts.recordargs << arguments.at(++i);
} else if (arg == "-recorddither") {
if (lastArg) usage();
opts.dither = arguments.at(++i);
} else if (arg == "-autorecord") {
if (lastArg) usage();
QString range = arguments.at(++i);
int dash = range.indexOf('-');
if (dash > 0)
opts.autorecord_from = range.left(dash).toInt();
opts.autorecord_to = range.mid(dash+1).toInt();
} else if (arg == "-devicekeys") {
opts.devkeys = true;
} else if (arg == "-dragthreshold") {
if (lastArg) usage();
qApp->setStartDragDistance(arguments.at(++i).toInt());
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
qWarning("Qt QML Viewer version %s", QT_VERSION_STR);
exitApp(0);
} else if (arg == "-translation") {
if (lastArg) usage();
opts.translationFile = arguments.at(++i);
#if defined(Q_WS_MAC)
} else if (arg == "-no-opengl") {
opts.useGL = false;
#else
} else if (arg == "-opengl") {
opts.useGL = true;
#endif
} else if (arg == "-qmlbrowser") {
opts.useNativeFileBrowser = false;
} else if (arg == "-warnings") {
if (lastArg) usage();
QString warningsStr = arguments.at(++i);
if (warningsStr == QLatin1String("show")) {
opts.warningsConfig = ShowWarnings;
} else if (warningsStr == QLatin1String("hide")) {
opts.warningsConfig = HideWarnings;
} else {
usage();
}
} else if (arg == "-I" || arg == "-L") {
if (arg == "-L")
qWarning("-L option provided for compatibility only, use -I instead");
if (lastArg) {
QDeclarativeEngine tmpEngine;
QString paths = tmpEngine.importPathList().join(QLatin1String(":"));
qWarning("Current search path: %s", paths.toLocal8Bit().constData());
exitApp(0);
}
opts.imports << arguments.at(++i);
} else if (arg == "-P") {
if (lastArg) usage();
opts.plugins << arguments.at(++i);
} else if (arg == "-script") {
if (lastArg) usage();
opts.script = arguments.at(++i);
} else if (arg == "-scriptopts") {
if (lastArg) usage();
opts.scriptopts = arguments.at(++i);
} else if (arg == "-savescript") {
if (lastArg) usage();
opts.script = arguments.at(++i);
opts.runScript = false;
} else if (arg == "-playscript") {
if (lastArg) usage();
opts.script = arguments.at(++i);
opts.runScript = true;
} else if (arg == "-sizeviewtorootobject") {
opts.sizeToView = false;
} else if (arg == "-sizerootobjecttoview") {
opts.sizeToView = true;
} else if (arg == "-experimentalgestures") {
opts.experimentalGestures = true;
} else if (!arg.startsWith('-')) {
fileNames.append(arg);
} else if (true || arg == "-help") {
usage();
}
}
if (!opts.scriptopts.isEmpty()) {
parseScriptOptions();
if (opts.script.isEmpty())
usage();
if (!(opts.scriptOptions & QDeclarativeViewer::Record) && !(opts.scriptOptions & QDeclarativeViewer::Play))
scriptOptsUsage();
} else if (!opts.script.isEmpty()) {
usage();
}
}
static QDeclarativeViewer *createViewer()
{
Qt::WFlags wflags = (opts.frameless ? Qt::FramelessWindowHint : Qt::Widget);
if (opts.stayOnTop)
wflags |= Qt::WindowStaysOnTopHint;
QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags);
viewer->setAttribute(Qt::WA_DeleteOnClose, true);
viewer->setUseGL(opts.useGL);
if (!opts.scriptopts.isEmpty()) {
viewer->setScriptOptions(opts.scriptOptions);
viewer->setScript(opts.script);
}
#if !defined(Q_OS_SYMBIAN)
logger = viewer->warningsWidget();
if (opts.warningsConfig == ShowWarnings) {
logger.data()->setDefaultVisibility(LoggerWidget::ShowWarnings);
logger.data()->show();
} else if (opts.warningsConfig == HideWarnings){
logger.data()->setDefaultVisibility(LoggerWidget::HideWarnings);
}
#endif
if (opts.experimentalGestures)
viewer->enableExperimentalGestures();
foreach (QString lib, opts.imports)
viewer->addLibraryPath(lib);
foreach (QString plugin, opts.plugins)
viewer->addPluginPath(plugin);
viewer->setNetworkCacheSize(opts.cache);
viewer->setRecordFile(opts.recordfile);
viewer->setSizeToView(opts.sizeToView);
if (opts.fps > 0)
viewer->setRecordRate(opts.fps);
if (opts.autorecord_to)
viewer->setAutoRecord(opts.autorecord_from, opts.autorecord_to);
if (opts.devkeys)
viewer->setDeviceKeys(true);
viewer->setRecordDither(opts.dither);
if (opts.recordargs.count())
viewer->setRecordArgs(opts.recordargs);
viewer->setUseNativeFileBrowser(opts.useNativeFileBrowser);
return viewer;
}
void showViewer(QDeclarativeViewer *viewer)
{
if (opts.fullScreen)
viewer->showFullScreen();
else if (opts.maximized)
viewer->showMaximized();
else
viewer->show();
viewer->raise();
}
QDeclarativeViewer *openFile(const QString &fileName)
{
QDeclarativeViewer *viewer = globalViewer;
viewer->open(fileName);
showViewer(viewer);
return viewer;
}
int main(int argc, char ** argv)
{
#if defined (Q_OS_SYMBIAN)
@@ -182,14 +540,6 @@ int main(int argc, char ** argv)
systemMsgOutput = qInstallMsgHandler(myMessageOutput);
#endif
#if defined (Q_OS_WIN)
// Debugging output is not visible by default on Windows -
// therefore show modal dialog with errors instead.
// (Disabled in QmlObserver: We're usually running inside QtCreator anyway, see also QTCREATORBUG-2748)
// atexit(showWarnings);
#endif
#if defined (Q_WS_X11) || defined (Q_WS_MAC)
//### default to using raster graphics backend for now
bool gsSpecified = false;
@@ -205,7 +555,7 @@ int main(int argc, char ** argv)
QApplication::setGraphicsSystem("raster");
#endif
QApplication app(argc, argv);
Application app(argc, argv);
app.setApplicationName("QtQmlViewer");
app.setOrganizationName("Nokia");
app.setOrganizationDomain("nokia.com");
@@ -213,266 +563,49 @@ int main(int argc, char ** argv)
QDeclarativeViewer::registerTypes();
QDeclarativeTester::registerTypes();
bool frameless = false;
QString fileName;
double fps = 0;
int autorecord_from = 0;
int autorecord_to = 0;
QString dither = "none";
QString recordfile;
QStringList recordargs;
QStringList imports;
QStringList plugins;
QString script;
QString scriptopts;
bool runScript = false;
bool devkeys = false;
int cache = 0;
QString translationFile;
bool useGL = false;
bool fullScreen = false;
bool stayOnTop = false;
bool maximized = false;
bool useNativeFileBrowser = true;
bool experimentalGestures = false;
bool designModeBehavior = false;
bool debuggerModeBehavior = false;
WarningsConfig warningsConfig = DefaultWarnings;
bool sizeToView = true;
#if defined(Q_OS_SYMBIAN)
maximized = true;
useNativeFileBrowser = false;
#endif
#if defined(Q_WS_MAC)
useGL = true;
#endif
for (int i = 1; i < argc; ++i) {
bool lastArg = (i == argc - 1);
QString arg = argv[i];
if (arg == "-frameless") {
frameless = true;
} else if (arg == "-maximized") {
maximized = true;
} else if (arg == "-fullscreen") {
fullScreen = true;
} else if (arg == "-stayontop") {
stayOnTop = true;
} else if (arg == "-netcache") {
if (lastArg) usage();
cache = QString(argv[++i]).toInt();
} else if (arg == "-recordrate") {
if (lastArg) usage();
fps = QString(argv[++i]).toDouble();
} else if (arg == "-recordfile") {
if (lastArg) usage();
recordfile = QString(argv[++i]);
} else if (arg == "-record") {
if (lastArg) usage();
recordargs << QString(argv[++i]);
} else if (arg == "-recorddither") {
if (lastArg) usage();
dither = QString(argv[++i]);
} else if (arg == "-autorecord") {
if (lastArg) usage();
QString range = QString(argv[++i]);
int dash = range.indexOf('-');
if (dash > 0)
autorecord_from = range.left(dash).toInt();
autorecord_to = range.mid(dash+1).toInt();
} else if (arg == "-devicekeys") {
devkeys = true;
} else if (arg == "-dragthreshold") {
if (lastArg) usage();
app.setStartDragDistance(QString(argv[++i]).toInt());
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
qWarning("Qt QML Viewer version %s", QT_VERSION_STR);
exit(0);
} else if (arg == "-translation") {
if (lastArg) usage();
translationFile = argv[++i];
} else if (arg == "-opengl") {
useGL = true;
} else if (arg == "-qmlbrowser") {
useNativeFileBrowser = false;
} else if (arg == "-warnings") {
if (lastArg) usage();
QString warningsStr = QString(argv[++i]);
if (warningsStr == QLatin1String("show")) {
warningsConfig = ShowWarnings;
} else if (warningsStr == QLatin1String("hide")) {
warningsConfig = HideWarnings;
} else {
usage();
}
} else if (arg == "-I" || arg == "-L") {
if (arg == "-L")
qWarning("-L option provided for compatibility only, use -I instead");
if (lastArg) {
QDeclarativeEngine tmpEngine;
QString paths = tmpEngine.importPathList().join(QLatin1String(":"));
qWarning("Current search path: %s", paths.toLocal8Bit().constData());
exit(0);
}
imports << QString(argv[++i]);
} else if (arg == "-P") {
if (lastArg) usage();
plugins << QString(argv[++i]);
} else if (arg == "-script") {
if (lastArg) usage();
script = QString(argv[++i]);
} else if (arg == "-scriptopts") {
if (lastArg) usage();
scriptopts = QString(argv[++i]);
} else if (arg == "-savescript") {
if (lastArg) usage();
script = QString(argv[++i]);
runScript = false;
} else if (arg == "-playscript") {
if (lastArg) usage();
script = QString(argv[++i]);
runScript = true;
} else if (arg == "-sizeviewtorootobject") {
sizeToView = false;
} else if (arg == "-sizerootobjecttoview") {
sizeToView = true;
} else if (arg == "-experimentalgestures") {
experimentalGestures = true;
} else if (arg == "-designmode") {
designModeBehavior = true;
} else if (arg == "-debugger") {
debuggerModeBehavior = true;
} else if (arg[0] != '-') {
fileName = arg;
} else if (1 || arg == "-help") {
usage();
}
}
parseCommandLineOptions(app.arguments());
QTranslator qmlTranslator;
if (!translationFile.isEmpty()) {
qmlTranslator.load(translationFile);
if (!opts.translationFile.isEmpty()) {
qmlTranslator.load(opts.translationFile);
app.installTranslator(&qmlTranslator);
}
Qt::WFlags wflags = (frameless ? Qt::FramelessWindowHint : Qt::Widget);
if (stayOnTop)
wflags |= Qt::WindowStaysOnTopHint;
// enable remote debugging
QDeclarativeDebugHelper::enableDebugging();
QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags);
viewer->setAttribute(Qt::WA_DeleteOnClose, true);
if (!scriptopts.isEmpty()) {
QStringList options =
scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts);
QDeclarativeViewer::ScriptOptions scriptOptions = 0;
for (int i = 0; i < options.count(); ++i) {
const QString &option = options.at(i);
if (option == QLatin1String("help")) {
scriptOptsUsage();
} else if (option == QLatin1String("play")) {
scriptOptions |= QDeclarativeViewer::Play;
} else if (option == QLatin1String("record")) {
scriptOptions |= QDeclarativeViewer::Record;
} else if (option == QLatin1String("testimages")) {
scriptOptions |= QDeclarativeViewer::TestImages;
} else if (option == QLatin1String("testerror")) {
scriptOptions |= QDeclarativeViewer::TestErrorProperty;
} else if (option == QLatin1String("exitoncomplete")) {
scriptOptions |= QDeclarativeViewer::ExitOnComplete;
} else if (option == QLatin1String("exitonfailure")) {
scriptOptions |= QDeclarativeViewer::ExitOnFailure;
} else if (option == QLatin1String("saveonexit")) {
scriptOptions |= QDeclarativeViewer::SaveOnExit;
} else if (option == QLatin1String("snapshot")) {
scriptOptions |= QDeclarativeViewer::Snapshot;
} else {
scriptOptsUsage();
}
}
if (script.isEmpty())
usage();
if (!(scriptOptions & QDeclarativeViewer::Record) && !(scriptOptions & QDeclarativeViewer::Play))
scriptOptsUsage();
viewer->setScriptOptions(scriptOptions);
viewer->setScript(script);
} else if (!script.isEmpty()) {
usage();
}
#if !defined(Q_OS_SYMBIAN)
logger = viewer->warningsWidget();
if (warningsConfig == ShowWarnings) {
logger.data()->setDefaultVisibility(LoggerWidget::ShowWarnings);
logger.data()->show();
} else if (warningsConfig == HideWarnings){
logger.data()->setDefaultVisibility(LoggerWidget::HideWarnings);
}
#endif
if (experimentalGestures)
viewer->enableExperimentalGestures();
viewer->setDesignModeBehavior(designModeBehavior);
viewer->setStayOnTop(stayOnTop);
foreach (QString lib, imports)
viewer->addLibraryPath(lib);
foreach (QString plugin, plugins)
viewer->addPluginPath(plugin);
viewer->setNetworkCacheSize(cache);
viewer->setRecordFile(recordfile);
viewer->setSizeToView(sizeToView);
if (fps>0)
viewer->setRecordRate(fps);
if (autorecord_to)
viewer->setAutoRecord(autorecord_from,autorecord_to);
if (devkeys)
viewer->setDeviceKeys(true);
viewer->setRecordDither(dither);
if (recordargs.count())
viewer->setRecordArgs(recordargs);
viewer->setUseNativeFileBrowser(useNativeFileBrowser);
if (fullScreen && maximized)
if (opts.fullScreen && opts.maximized)
qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen.";
if (fileName.isEmpty()) {
if (fileNames.isEmpty()) {
QFile qmlapp(QLatin1String("qmlapp"));
if (qmlapp.exists() && qmlapp.open(QFile::ReadOnly)) {
QString content = QString::fromUtf8(qmlapp.readAll());
qmlapp.close();
QString content = QString::fromUtf8(qmlapp.readAll());
qmlapp.close();
int newline = content.indexOf(QLatin1Char('\n'));
if (newline >= 0)
fileName = content.left(newline);
else
fileName = content;
}
int newline = content.indexOf(QLatin1Char('\n'));
if (newline >= 0)
fileNames += content.left(newline);
else
fileNames += content;
}
}
if (!fileName.isEmpty()) {
viewer->open(fileName);
fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show();
//enable remote debugging
QDeclarativeDebugHelper::enableDebugging();
globalViewer = createViewer();
if (fileNames.isEmpty()) {
// show the initial viewer delayed.
// This prevents an initial viewer popping up while there
// are FileOpen events coming through the event queue
QTimer::singleShot(1, &app, SLOT(showInitialViewer()));
} else {
if (!useNativeFileBrowser)
viewer->openFile();
fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show();
if (useNativeFileBrowser)
viewer->openFile();
foreach (const QString &fileName, fileNames)
openFile(fileName);
}
viewer->setUseGL(useGL);
viewer->raise();
QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
return app.exec();
}
#include "main.moc"

View File

@@ -48,7 +48,6 @@
#include <QDir>
#include <QCryptographicHash>
#include <QGraphicsObject>
#ifndef NO_PRIVATE_HEADERS
#include <private/qabstractanimation_p.h>
#include <private/qdeclarativeitem_p.h>
@@ -56,6 +55,7 @@
QT_BEGIN_NAMESPACE
extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts,
QDeclarativeView *parent)
@@ -67,6 +67,12 @@ QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer
#ifndef NO_PRIVATE_HEADERS
QUnifiedTimer::instance()->setConsistentTiming(true);
#endif
//Font antialiasing makes tests system-specific, so disable it
QFont noAA = QApplication::font();
noAA.setStyleStrategy(QFont::NoAntialias);
QApplication::setFont(noAA);
if (options & QDeclarativeViewer::Play)
this->run();
start();
@@ -75,7 +81,7 @@ QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer
QDeclarativeTester::~QDeclarativeTester()
{
if (!hasFailed &&
options & QDeclarativeViewer::Record &&
options & QDeclarativeViewer::Record &&
options & QDeclarativeViewer::SaveOnExit)
save();
}
@@ -142,8 +148,25 @@ void QDeclarativeTester::imagefailure()
{
hasFailed = true;
if (options & QDeclarativeViewer::ExitOnFailure)
exit(-1);
if (options & QDeclarativeViewer::ExitOnFailure){
testSkip();
exit(hasFailed?-1:0);
}
}
void QDeclarativeTester::testSkip()
{
if (options & QDeclarativeViewer::TestSkipProperty){
QString e = m_view->rootObject()->property("skip").toString();
if (!e.isEmpty()) {
if(hasFailed){
qWarning() << "Test failed, but skipping it: " << e;
}else{
qWarning() << "Test skipped: " << e;
}
hasFailed = 0;
}
}
}
void QDeclarativeTester::complete()
@@ -155,7 +178,10 @@ void QDeclarativeTester::complete()
hasFailed = true;
}
}
if (options & QDeclarativeViewer::ExitOnComplete)
testSkip();
if (options & QDeclarativeViewer::ExitOnComplete)
QApplication::exit(hasFailed?-1:0);
if (hasCompleted)
@@ -207,7 +233,7 @@ void QDeclarativeTester::save()
}
ts << " }\n";
while (!mouseevents.isEmpty() &&
while (!mouseevents.isEmpty() &&
mouseevents.first().msec == fe.msec) {
MouseEvent me = mouseevents.takeFirst();
@@ -255,7 +281,16 @@ void QDeclarativeTester::updateCurrentTime(int msec)
if (options & QDeclarativeViewer::TestImages) {
img.fill(qRgb(255,255,255));
#ifdef Q_WS_MAC
bool oldSmooth = qt_applefontsmoothing_enabled;
qt_applefontsmoothing_enabled = false;
#endif
QPainter p(&img);
#ifdef Q_WS_MAC
qt_applefontsmoothing_enabled = oldSmooth;
#endif
m_view->render(&p);
}
@@ -266,7 +301,7 @@ void QDeclarativeTester::updateCurrentTime(int msec)
fe.msec = msec;
if (msec == 0 || !(options & QDeclarativeViewer::TestImages)) {
// Skip first frame, skip if not doing images
} else if (0 == (m_savedFrameEvents.count() % 60) || snapshot) {
} else if (0 == ((m_savedFrameEvents.count()-1) % 60) || snapshot) {
fe.image = img;
} else {
QCryptographicHash hash(QCryptographicHash::Md5);
@@ -317,14 +352,14 @@ void QDeclarativeTester::updateCurrentTime(int msec)
if (QDeclarativeVisualTestFrame *frame = qobject_cast<QDeclarativeVisualTestFrame *>(event)) {
if (frame->msec() < msec) {
if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) {
qWarning() << "QDeclarativeTester: Extra frame. Seen:"
qWarning() << "QDeclarativeTester(" << m_script << "): Extra frame. Seen:"
<< msec << "Expected:" << frame->msec();
imagefailure();
}
} else if (frame->msec() == msec) {
if (!frame->hash().isEmpty() && frame->hash().toUtf8() != fe.hash.toHex()) {
if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) {
qWarning() << "QDeclarativeTester: Mismatched frame hash at" << msec
qWarning() << "QDeclarativeTester(" << m_script << "): Mismatched frame hash at" << msec
<< ". Seen:" << fe.hash.toHex()
<< "Expected:" << frame->hash().toUtf8();
imagefailure();
@@ -336,9 +371,14 @@ void QDeclarativeTester::updateCurrentTime(int msec)
if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record) && !frame->image().isEmpty()) {
QImage goodImage(frame->image().toLocalFile());
if (frame->msec() == 16 && goodImage.size() != img.size()){
//Also an image mismatch, but this warning is more informative. Only checked at start though.
qWarning() << "QDeclarativeTester(" << m_script << "): Size mismatch. This test must be run at " << goodImage.size();
imagefailure();
}
if (goodImage != img) {
QString reject(frame->image().toLocalFile() + ".reject.png");
qWarning() << "QDeclarativeTester: Image mismatch. Reject saved to:"
qWarning() << "QDeclarativeTester(" << m_script << "): Image mismatch. Reject saved to:"
<< reject;
img.save(reject);
bool doDiff = (goodImage.size() == img.size());
@@ -391,7 +431,7 @@ void QDeclarativeTester::updateCurrentTime(int msec)
ke.destination = ViewPort;
}
m_savedKeyEvents.append(ke);
}
}
testscriptidx++;
}

View File

@@ -122,7 +122,7 @@ public:
int type() const { return m_type; }
void setType(int t) { m_type = t; }
int button() const { return m_button; }
void setButton(int b) { m_button = b; }
@@ -228,6 +228,7 @@ private:
void imagefailure();
void complete();
void testSkip();
enum Destination { View, ViewPort };
void addKeyEvent(Destination, QKeyEvent *);
@@ -236,7 +237,7 @@ private:
struct MouseEvent {
MouseEvent(QMouseEvent *e)
: type(e->type()), button(e->button()), buttons(e->buttons()),
: type(e->type()), button(e->button()), buttons(e->buttons()),
pos(e->pos()), modifiers(e->modifiers()), destination(View) {}
QEvent::Type type;

View File

@@ -1,14 +1,9 @@
QT += declarative script network sql
contains(QT_CONFIG, opengl) {
QT += opengl
DEFINES += GL_SUPPORTED
}
!exists($$[QT_INSTALL_HEADERS]/QtCore/private/qabstractanimation_p.h) {
DEFINES += NO_PRIVATE_HEADERS
}
INCLUDEPATH += $$PWD
HEADERS += $$PWD/qmlruntime.h \
@@ -16,25 +11,31 @@ HEADERS += $$PWD/qmlruntime.h \
$$PWD/qdeclarativetester.h \
$$PWD/deviceorientation.h \
$$PWD/loggerwidget.h
SOURCES += $$PWD/qmlruntime.cpp \
$$PWD/proxysettings.cpp \
$$PWD/qdeclarativetester.cpp \
$$PWD/loggerwidget.cpp
RESOURCES += $$PWD/qmlruntime.qrc
RESOURCES = $$PWD/browser/browser.qrc \
$$PWD/startup/startup.qrc
OTHER_FILES += toolbarstyle.css
maemo5 {
symbian:!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) {
SOURCES += $$PWD/deviceorientation_symbian.cpp
FORMS = $$PWD/recopts.ui \
$$PWD/proxysettings.ui
} else:maemo5 {
QT += dbus
HEADERS += $$PWD/texteditautoresizer_maemo5.h
SOURCES += $$PWD/deviceorientation_maemo5.cpp
FORMS += $$PWD/recopts_maemo5.ui \
FORMS = $$PWD/recopts_maemo5.ui \
$$PWD/proxysettings_maemo5.ui
} else:linux-g++-maemo {
QT += dbus
SOURCES += $$PWD/deviceorientation_harmattan.cpp
FORMS = $$PWD/recopts.ui \
$$PWD/proxysettings.ui
} else {
SOURCES += $$PWD/deviceorientation.cpp
FORMS += $$PWD/recopts.ui \
$$PWD/proxysettings.ui
FORMS = $$PWD/recopts.ui \
$$PWD/proxysettings.ui
}

View File

@@ -1,5 +1,7 @@
TEMPLATE = app
CONFIG += qt uic
### FIXME: only debug plugins are now supported.
CONFIG -= release
CONFIG += debug
@@ -15,6 +17,44 @@ exists($$PWD/qmljsdebugger/qmljsdebugger-lib.pri) {
include($$PWD/../qmljsdebugger/qmljsdebugger-lib.pri)
}
#INCLUDEPATH += ../../include/QtDeclarative
#INCLUDEPATH += ../../src/declarative/util
#INCLUDEPATH += ../../src/declarative/graphicsitems
target.path = $$[QT_INSTALL_BINS]
INSTALLS += target
wince* {
QT += xml
contains(QT_CONFIG, scripttools) {
QT += scripttools
}
contains(QT_CONFIG, phonon) {
QT += phonon
}
contains(QT_CONFIG, xmlpatterns) {
QT += xmlpatterns
}
contains(QT_CONFIG, webkit) {
QT += webkit
}
}
maemo5 {
QT += maemo5
}
symbian {
TARGET.UID3 = 0x20021317
include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
TARGET.EPOCHEAPSIZE = 0x20000 0x4000000
TARGET.CAPABILITY = NetworkServices ReadUserData
!contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) {
LIBS += -lsensrvclient -lsensrvutil
}
contains(QT_CONFIG, s60): {
LIBS += -lavkon -lcone
}
}
mac {
QMAKE_INFO_PLIST=Info_mac.plist
TARGET=QMLObserver
@@ -22,4 +62,3 @@ mac {
} else {
TARGET=qmlobserver
}

View File

@@ -54,9 +54,6 @@
# include "ui_recopts.h"
#endif
#include <qdeclarativeviewobserver.h>
#include <qdeclarativeobserverservice.h>
#include "qmlruntime.h"
#include <qdeclarativecontext.h>
#include <qdeclarativeengine.h>
@@ -67,6 +64,9 @@
#include <private/qabstractanimation_p.h>
#endif
#include <qdeclarativeviewobserver.h>
#include <qdeclarativeobserverservice.h>
#include <QSettings>
#include <QXmlStreamReader>
#include <QBuffer>
@@ -90,28 +90,74 @@
#include <QMenu>
#include <QAction>
#include <QFileDialog>
#include <QInputDialog>
#include <QTimer>
#include <QGraphicsObject>
#include <QNetworkProxyFactory>
#include <QKeyEvent>
#include <QToolBar>
#include <QMutex>
#include <QMutexLocker>
#include "proxysettings.h"
#include "deviceorientation.h"
#include <QInputDialog>
#ifdef GL_SUPPORTED
#include <QGLWidget>
#endif
#include <qt_private/qdeclarativedebughelper_p.h>
#if defined(Q_WS_S60)
#include <aknappui.h> // For locking app orientation
#endif
#include <qdeclarativetester.h>
#include <qt_private/qdeclarativedebughelper_p.h>
#include "jsdebuggeragent.h"
QT_BEGIN_NAMESPACE
class DragAndDropView : public QDeclarativeView
{
Q_OBJECT
public:
DragAndDropView(QDeclarativeViewer *parent = 0)
: QDeclarativeView(parent)
{
setAcceptDrops(true);
}
void dragEnterEvent(QDragEnterEvent *event)
{
const QMimeData *mimeData = event->mimeData();
if (mimeData->hasUrls())
event->acceptProposedAction();
}
void dragMoveEvent(QDragMoveEvent *event)
{
event->acceptProposedAction();
}
void dragLeaveEvent(QDragLeaveEvent *event)
{
event->accept();
}
void dropEvent(QDropEvent *event)
{
const QMimeData *mimeData = event->mimeData();
if (!mimeData->hasUrls())
return;
const QList<QUrl> urlList = mimeData->urls();
foreach (const QUrl &url, urlList) {
if (url.scheme() == QLatin1String("file")) {
static_cast<QDeclarativeViewer *>(parent())->open(url.toLocalFile());
event->accept();
return;
}
}
}
};
class Runtime : public QObject
{
Q_OBJECT
@@ -166,38 +212,38 @@ public:
QWidget *createWidget(QWidget *parent)
{
QMaemo5ValueButton *button = new QMaemo5ValueButton(m_text, parent);
button->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered);
QMaemo5ValueButton *button = new QMaemo5ValueButton(m_text, parent);
button->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered);
QMaemo5ListPickSelector *pick = new QMaemo5ListPickSelector(button);
button->setPickSelector(pick);
if (m_actions) {
QStringList sl;
int curIdx = -1, idx = 0;
foreach (QAction *a, m_actions->actions()) {
sl << a->text();
if (a->isChecked())
curIdx = idx;
idx++;
button->setPickSelector(pick);
if (m_actions) {
QStringList sl;
int curIdx = -1, idx = 0;
foreach (QAction *a, m_actions->actions()) {
sl << a->text();
if (a->isChecked())
curIdx = idx;
idx++;
}
pick->setModel(new QStringListModel(sl));
pick->setCurrentIndex(curIdx);
} else {
button->setEnabled(false);
}
connect(pick, SIGNAL(selected(QString)), this, SLOT(emitTriggered()));
return button;
pick->setModel(new QStringListModel(sl));
pick->setCurrentIndex(curIdx);
} else {
button->setEnabled(false);
}
connect(pick, SIGNAL(selected(QString)), this, SLOT(emitTriggered()));
return button;
}
private slots:
void emitTriggered()
{
QMaemo5ListPickSelector *pick = qobject_cast<QMaemo5ListPickSelector *>(sender());
if (!pick)
return;
int idx = pick->currentIndex();
QMaemo5ListPickSelector *pick = qobject_cast<QMaemo5ListPickSelector *>(sender());
if (!pick)
return;
int idx = pick->currentIndex();
if (m_actions && idx >= 0 && idx < m_actions->actions().count())
m_actions->actions().at(idx)->trigger();
if (m_actions && idx >= 0 && idx < m_actions->actions().count())
m_actions->actions().at(idx)->trigger();
}
private:
@@ -441,65 +487,82 @@ private:
mutable QMutex mutex;
};
class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
class SystemProxyFactory : public QNetworkProxyFactory
{
public:
SystemProxyFactory() : proxyDirty(true), httpProxyInUse(false) {
}
virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query)
{
if (proxyDirty)
setupProxy();
QString protocolTag = query.protocolTag();
if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
QList<QNetworkProxy> ret;
ret << httpProxy;
return ret;
}
#ifdef Q_OS_WIN
// systemProxyForQuery can take insanely long on Windows (QTBUG-10106)
return QNetworkProxyFactory::proxyForQuery(query);
#else
return QNetworkProxyFactory::systemProxyForQuery(query);
#endif
}
void setupProxy() {
// Don't bother locking because we know that the proxy only
// changes in response to the settings dialog and that
// the view will be reloaded.
proxyDirty = false;
httpProxyInUse = ProxySettings::httpProxyInUse();
if (httpProxyInUse)
httpProxy = ProxySettings::httpProxy();
}
void proxyChanged() {
proxyDirty = true;
}
private:
volatile bool proxyDirty;
bool httpProxyInUse;
QNetworkProxy httpProxy;
};
class NetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory
{
Q_OBJECT
public:
NetworkAccessManagerFactory() : cacheSize(0) {}
~NetworkAccessManagerFactory() {}
QNetworkAccessManager *create(QObject *parent);
void setupProxy(QNetworkAccessManager *nam)
{
class SystemProxyFactory : public QNetworkProxyFactory
{
public:
virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query)
{
QString protocolTag = query.protocolTag();
if (httpProxyInUse && (protocolTag == "http" || protocolTag == "https")) {
QList<QNetworkProxy> ret;
ret << httpProxy;
return ret;
}
#ifdef Q_OS_WIN
// systemProxyForQuery can take insanely long on Windows (QTBUG-10106)
return QNetworkProxyFactory::proxyForQuery(query);
#else
return QNetworkProxyFactory::systemProxyForQuery(query);
#endif
}
void setHttpProxy (QNetworkProxy proxy)
{
httpProxy = proxy;
httpProxyInUse = true;
}
void unsetHttpProxy ()
{
httpProxyInUse = false;
}
private:
bool httpProxyInUse;
QNetworkProxy httpProxy;
};
SystemProxyFactory *proxyFactory = new SystemProxyFactory;
if (ProxySettings::httpProxyInUse())
proxyFactory->setHttpProxy(ProxySettings::httpProxy());
else
proxyFactory->unsetHttpProxy();
nam->setProxyFactory(proxyFactory);
}
void setCacheSize(int size) {
if (size != cacheSize) {
cacheSize = size;
}
}
void proxyChanged() {
foreach (QNetworkAccessManager *nam, namList) {
static_cast<SystemProxyFactory*>(nam->proxyFactory())->proxyChanged();
}
}
static PersistentCookieJar *cookieJar;
private slots:
void managerDestroyed(QObject *obj) {
namList.removeOne(static_cast<QNetworkAccessManager*>(obj));
}
private:
QMutex mutex;
int cacheSize;
QList<QNetworkAccessManager*> namList;
};
PersistentCookieJar *NetworkAccessManagerFactory::cookieJar = 0;
@@ -520,7 +583,7 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
}
manager->setCookieJar(cookieJar);
cookieJar->setParent(0);
setupProxy(manager);
manager->setProxyFactory(new SystemProxyFactory);
if (cacheSize > 0) {
QNetworkDiskCache *cache = new QNetworkDiskCache;
cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-viewer-network-cache"));
@@ -529,6 +592,8 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
} else {
manager->setCache(0);
}
connect(manager, SIGNAL(destroyed(QObject*)), this, SLOT(managerDestroyed(QObject*)));
namList.append(manager);
qDebug() << "created new network access manager for" << parent;
return manager;
}
@@ -548,13 +613,13 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
, loggerWindow(new LoggerWidget(this))
, frame_stream(0)
, rotateAction(0)
, orientation(0)
, showWarningsWindow(0)
, designModeBehaviorAction(0)
, m_scriptOptions(0)
, tester(0)
, useQmlFileBrowser(true)
, m_centralWidget(0)
, translator(0)
{
QDeclarativeViewer::registerTypes();
@@ -589,28 +654,18 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
recdlg->warning->hide();
}
canvas = new QDeclarativeView(this);
canvas = new DragAndDropView(this);
observer = new QmlJSDebugger::QDeclarativeViewObserver(canvas, this);
new QmlJSDebugger::JSDebuggerAgent(canvas->engine());
m_centralWidget = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(m_centralWidget);
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(canvas);
m_centralWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
canvas->setAttribute(Qt::WA_OpaquePaintEvent);
canvas->setAttribute(Qt::WA_NoSystemBackground);
canvas->setFocus();
QObject::connect(observer, SIGNAL(reloadRequested()), this, SLOT(reload()));
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged()));
QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
QObject::connect(canvas->engine(), SIGNAL(quit()), this, SLOT(close()));
QObject::connect(warningsWidget(), SIGNAL(opened()), this, SLOT(warningsWidgetOpened()));
QObject::connect(warningsWidget(), SIGNAL(closed()), this, SLOT(warningsWidgetClosed()));
@@ -622,7 +677,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
setMenuBar(0);
}
setCentralWidget(m_centralWidget);
setCentralWidget(canvas);
namFactory = new NetworkAccessManagerFactory;
canvas->engine()->setNetworkAccessManagerFactory(namFactory);
@@ -655,12 +710,14 @@ void QDeclarativeViewer::setDesignModeBehavior(bool value)
void QDeclarativeViewer::enableExperimentalGestures()
{
#ifndef QT_NO_GESTURES
canvas->viewport()->grabGesture(Qt::TapGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::TapAndHoldGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::PanGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::PinchGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->grabGesture(Qt::SwipeGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent);
canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
#endif
}
QDeclarativeView *QDeclarativeViewer::view() const
@@ -676,11 +733,14 @@ LoggerWidget *QDeclarativeViewer::warningsWidget() const
void QDeclarativeViewer::createMenu()
{
QAction *openAction = new QAction(tr("&Open..."), this);
openAction->setShortcut(QKeySequence("Ctrl+O"));
openAction->setShortcuts(QKeySequence::Open);
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
QAction *openUrlAction = new QAction(tr("Open &URL..."), this);
connect(openUrlAction, SIGNAL(triggered()), this, SLOT(openUrl()));
QAction *reloadAction = new QAction(tr("&Reload"), this);
reloadAction->setShortcut(QKeySequence("Ctrl+R"));
reloadAction->setShortcuts(QKeySequence::Refresh);
connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this);
@@ -690,9 +750,6 @@ void QDeclarativeViewer::createMenu()
recordAction = new QAction(tr("Start Recording &Video"), this);
recordAction->setShortcut(QKeySequence("F9"));
connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection()));
#ifdef NO_PRIVATE_HEADERS
recordAction->setEnabled(false);
#endif
QAction *recordOptions = new QAction(tr("Video &Options..."), this);
connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions()));
@@ -715,6 +772,7 @@ void QDeclarativeViewer::createMenu()
speedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeAnimationSpeed()));
speedAction->setCheckable(true);
speedAction->setCheckable(true);
speedAction->setData(4.0f);
playSpeedMenuActions->addAction(speedAction);
@@ -753,7 +811,8 @@ void QDeclarativeViewer::createMenu()
designModeBehaviorAction->setEnabled(QmlJSDebugger::QDeclarativeObserverService::hasDebuggingClient());
connect(designModeBehaviorAction, SIGNAL(triggered(bool)), this, SLOT(setDesignModeBehavior(bool)));
connect(observer, SIGNAL(designModeBehaviorChanged(bool)), designModeBehaviorAction, SLOT(setChecked(bool)));
connect(QmlJSDebugger::QDeclarativeObserverService::instance(), SIGNAL(debuggingClientChanged(bool)), designModeBehaviorAction, SLOT(setEnabled(bool)));
connect(QmlJSDebugger::QDeclarativeObserverService::instance(), SIGNAL(debuggingClientChanged(bool)),
designModeBehaviorAction, SLOT(setEnabled(bool)));
appOnTopAction = new QAction(tr("Keep Window on Top"), this);
appOnTopAction->setCheckable(true);
@@ -769,36 +828,49 @@ void QDeclarativeViewer::createMenu()
fullscreenAction->setCheckable(true);
connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
QAction *rotateOrientation = new QAction(tr("Rotate orientation"), this);
rotateOrientation->setShortcut(QKeySequence("Ctrl+T"));
connect(rotateOrientation, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
rotateAction = new QAction(tr("Rotate orientation"), this);
rotateAction->setShortcut(QKeySequence("Ctrl+T"));
connect(rotateAction, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
orientation = new QActionGroup(this);
orientation->setExclusive(true);
connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*)));
#if defined(Q_OS_SYMBIAN)
QAction *autoOrientationAction = new QAction(tr("Auto-orientation"), this);
autoOrientationAction->setCheckable(true);
#endif
QAction *portraitAction = new QAction(tr("Portrait"), this);
portraitAction->setCheckable(true);
QAction *landscapeAction = new QAction(tr("Landscape"), this);
landscapeAction->setCheckable(true);
#if !defined(Q_OS_SYMBIAN)
QAction *portraitInvAction = new QAction(tr("Portrait (inverted)"), this);
portraitInvAction->setCheckable(true);
QAction *landscapeInvAction = new QAction(tr("Landscape (inverted)"), this);
landscapeInvAction->setCheckable(true);
#endif
QAction *aboutAction = new QAction(tr("&About Qt..."), this);
aboutAction->setMenuRole(QAction::AboutQtRole);
connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
QAction *closeAction = new QAction(tr("&Close"), this);
closeAction->setShortcuts(QKeySequence::Close);
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
QAction *quitAction = new QAction(tr("&Quit"), this);
quitAction->setShortcut(QKeySequence("Ctrl+Q"));
quitAction->setMenuRole(QAction::QuitRole);
quitAction->setShortcuts(QKeySequence::Quit);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
QMenuBar *menu = menuBar();
if (!menu)
return;
return;
#if defined(Q_WS_MAEMO_5)
menu->addAction(openAction);
menu->addAction(openUrlAction);
menu->addAction(reloadAction);
menu->addAction(snapshotAction);
@@ -819,38 +891,45 @@ void QDeclarativeViewer::createMenu()
QMenu *fileMenu = menu->addMenu(tr("&File"));
fileMenu->addAction(openAction);
fileMenu->addAction(openUrlAction);
fileMenu->addAction(reloadAction);
fileMenu->addSeparator();
fileMenu->addAction(closeAction);
#if !defined(Q_OS_SYMBIAN)
fileMenu->addAction(quitAction);
#if !defined(Q_OS_SYMBIAN)
QMenu *recordMenu = menu->addMenu(tr("&Recording"));
recordMenu->addAction(snapshotAction);
recordMenu->addAction(recordAction);
QMenu *debugMenu = menu->addMenu(tr("&Debugging"));
debugMenu->addAction(playSpeedAction);
debugMenu->addMenu(playSpeedMenu);
debugMenu->addAction(showWarningsWindow);
debugMenu->addAction(designModeBehaviorAction);
debugMenu->addAction(appOnTopAction);
#endif // ! Q_OS_SYMBIAN
QMenu *settingsMenu = menu->addMenu(tr("S&ettings"));
QMenu *settingsMenu = menu->addMenu(tr("&Settings"));
settingsMenu->addAction(proxyAction);
#if !defined(Q_OS_SYMBIAN)
#if defined(Q_OS_SYMBIAN)
settingsMenu->addAction(fullscreenAction);
#else
settingsMenu->addAction(recordOptions);
settingsMenu->addMenu(loggerWindow->preferencesMenu());
#else // ! Q_OS_SYMBIAN
settingsMenu->addAction(fullscreenAction);
#endif // Q_OS_SYMBIAN
settingsMenu->addAction(rotateOrientation);
#endif // !Q_OS_SYMBIAN
settingsMenu->addAction(rotateAction);
QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
#if defined(Q_OS_SYMBIAN)
orientation->addAction(autoOrientationAction);
#endif
orientation->addAction(portraitAction);
orientation->addAction(landscapeAction);
#if !defined(Q_OS_SYMBIAN)
orientation->addAction(portraitInvAction);
orientation->addAction(landscapeInvAction);
#endif
propertiesMenu->addActions(orientation->actions());
QMenu *helpMenu = menu->addMenu(tr("&Help"));
@@ -868,11 +947,29 @@ void QDeclarativeViewer::showProxySettings()
void QDeclarativeViewer::proxySettingsChanged()
{
namFactory->proxyChanged();
reload ();
}
void QDeclarativeViewer::rotateOrientation()
{
#if defined(Q_WS_S60)
CAknAppUi *appUi = static_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
if (appUi) {
CAknAppUi::TAppUiOrientation oldOrientation = appUi->Orientation();
QString newOrientation;
if (oldOrientation == CAknAppUi::EAppUiOrientationPortrait) {
newOrientation = QLatin1String("Landscape");
} else {
newOrientation = QLatin1String("Portrait");
}
foreach (QAction *action, orientation->actions()) {
if (action->text() == newOrientation) {
changeOrientation(action);
}
}
}
#else
QAction *current = orientation->checkedAction();
QList<QAction *> actions = orientation->actions();
int index = actions.indexOf(current);
@@ -881,6 +978,7 @@ void QDeclarativeViewer::rotateOrientation()
QAction *newOrientation = actions[(index + 1) % actions.count()];
changeOrientation(newOrientation);
#endif
}
void QDeclarativeViewer::toggleFullScreen()
@@ -978,41 +1076,41 @@ void QDeclarativeViewer::toggleRecording()
void QDeclarativeViewer::setAnimationsPaused(bool enable)
{
if (enable) {
setAnimationSpeed(0.0);
} else {
setAnimationSpeed(animationSpeed);
}
if (enable) {
setAnimationSpeed(0.0);
} else {
setAnimationSpeed(animationSpeed);
}
}
void QDeclarativeViewer::pauseAnimations() {
pauseAnimationsAction->setChecked(true);
setAnimationsPaused(true);
pauseAnimationsAction->setChecked(true);
setAnimationsPaused(true);
}
void QDeclarativeViewer::stepAnimations()
{
setAnimationSpeed(1.0);
QTimer::singleShot(m_stepSize, this, SLOT(pauseAnimations()));
}
setAnimationSpeed(1.0);
QTimer::singleShot(m_stepSize, this, SLOT(pauseAnimations()));
}
void QDeclarativeViewer::setAnimationStep()
{
bool ok;
int stepSize = QInputDialog::getInt(this, tr("Set animation step duration"),
tr("Step duration (ms):"), m_stepSize, 20, 10000, 1, &ok);
if (ok) m_stepSize = stepSize;
bool ok;
int stepSize = QInputDialog::getInt(this, tr("Set animation step duration"),
tr("Step duration (ms):"), m_stepSize, 20, 10000, 1, &ok);
if (ok) m_stepSize = stepSize;
}
void QDeclarativeViewer::changeAnimationSpeed()
{
QAction *action = qobject_cast<QAction*>(sender());
if (action) {
float f = action->data().toFloat();
animationSpeed = f;
if (!pauseAnimationsAction->isChecked())
setAnimationSpeed(animationSpeed);
}
QAction *action = qobject_cast<QAction*>(sender());
if (action) {
float f = action->data().toFloat();
animationSpeed = f;
if (!pauseAnimationsAction->isChecked())
setAnimationSpeed(animationSpeed);
}
}
void QDeclarativeViewer::addLibraryPath(const QString& lib)
@@ -1027,15 +1125,14 @@ void QDeclarativeViewer::addPluginPath(const QString& plugin)
void QDeclarativeViewer::reload()
{
observer->setDesignModeBehavior(false);
open(currentFileOrUrl);
launch(currentFileOrUrl);
}
void QDeclarativeViewer::openFile()
{
QString cur = canvas->source().toLocalFile();
if (useQmlFileBrowser) {
open("qrc:/content/Browser.qml");
open("qrc:/browser/Browser.qml");
} else {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)"));
if (!fileName.isEmpty()) {
@@ -1045,6 +1142,14 @@ void QDeclarativeViewer::openFile()
}
}
void QDeclarativeViewer::openUrl()
{
QString cur = canvas->source().toLocalFile();
QString url= QInputDialog::getText(this, tr("Open QML file"), tr("URL of main QML file:"), QLineEdit::Normal, cur);
if (!url.isEmpty())
open(url);
}
void QDeclarativeViewer::statusChanged()
{
if (canvas->status() == QDeclarativeView::Error && tester)
@@ -1077,11 +1182,7 @@ void QDeclarativeViewer::loadDummyDataFiles(const QString& directory)
QStringList list = dir.entryList();
for (int i = 0; i < list.size(); ++i) {
QString qml = list.at(i);
QFile f(dir.filePath(qml));
f.open(QIODevice::ReadOnly);
QByteArray data = f.readAll();
QDeclarativeComponent comp(canvas->engine());
comp.setData(data, QUrl());
QDeclarativeComponent comp(canvas->engine(), dir.filePath(qml));
QObject *dummyData = comp.create();
if(comp.isError()) {
@@ -1220,8 +1321,10 @@ bool QDeclarativeViewer::event(QEvent *event)
{
if (event->type() == QEvent::WindowActivate) {
Runtime::instance()->setActiveWindow(true);
DeviceOrientation::instance()->resumeListening();
} else if (event->type() == QEvent::WindowDeactivate) {
Runtime::instance()->setActiveWindow(false);
DeviceOrientation::instance()->pauseListening();
}
return QWidget::event(event);
}
@@ -1397,6 +1500,8 @@ void QDeclarativeViewer::appAboutToQuit()
// avoid crashes if messages are received after app has closed
delete loggerWindow;
loggerWindow = 0;
delete tester;
tester = 0;
}
void QDeclarativeViewer::autoStartRecording()
@@ -1431,9 +1536,24 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
{
if (!action)
return;
action->setChecked(true);
QString o = action->text();
action->setChecked(true);
#if defined(Q_WS_S60)
CAknAppUi *appUi = static_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi());
if (appUi) {
CAknAppUi::TAppUiOrientation orientation = appUi->Orientation();
if (o == QLatin1String("Auto-orientation")) {
appUi->SetOrientationL(CAknAppUi::EAppUiOrientationAutomatic);
rotateAction->setVisible(false);
} else if (o == QLatin1String("Portrait")) {
appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait);
rotateAction->setVisible(true);
} else if (o == QLatin1String("Landscape")) {
appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);
rotateAction->setVisible(true);
}
}
#else
if (o == QLatin1String("Portrait"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait);
else if (o == QLatin1String("Landscape"))
@@ -1442,6 +1562,7 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted);
else if (o == QLatin1String("Landscape (inverted)"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted);
#endif
}
void QDeclarativeViewer::orientationChanged()
@@ -1517,7 +1638,6 @@ void QDeclarativeViewer::updateSizeHints(bool initial)
QSize newWindowSize = initial ? initialSize : canvas->sizeHint();
//qWarning() << "USH:" << (initial ? "INIT:" : "V2R:") << "setting fixed size " << newWindowSize;
if (!isFullScreen() && !isMaximized()) {
m_centralWidget->setFixedSize(newWindowSize.width(), newWindowSize.height() + 32);
canvas->setFixedSize(newWindowSize);
resize(1, 1);
layout()->setSizeConstraint(QLayout::SetFixedSize);
@@ -1527,18 +1647,14 @@ void QDeclarativeViewer::updateSizeHints(bool initial)
//qWarning() << "USH: R2V: setting free size ";
layout()->setSizeConstraint(QLayout::SetNoConstraint);
layout()->activate();
setMinimumSize(minimumSizeHint());
setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
canvas->setMinimumSize(QSize(0,0));
canvas->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
m_centralWidget->setMinimumSize(QSize(0,0));
m_centralWidget->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
isRecursive = false;
}
void QDeclarativeViewer::registerTypes()
{
static bool registered = false;
@@ -1546,6 +1662,7 @@ void QDeclarativeViewer::registerTypes()
if (!registered) {
// registering only for exposing the DeviceOrientation::Orientation enum
qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,7,"Orientation","");
qmlRegisterUncreatableType<DeviceOrientation>("QtQuick",1,0,"Orientation","");
registered = true;
}
}

View File

@@ -67,7 +67,6 @@ class NetworkAccessManagerFactory;
class QTranslator;
class QActionGroup;
class QMenuBar;
class QSplitter;
class QDeclarativeViewer
: public QMainWindow
@@ -75,7 +74,7 @@ class QDeclarativeViewer
Q_OBJECT
public:
explicit QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~QDeclarativeViewer();
static void registerTypes();
@@ -88,7 +87,8 @@ public:
SaveOnExit = 0x00000010,
ExitOnComplete = 0x00000020,
ExitOnFailure = 0x00000040,
Snapshot = 0x00000080
Snapshot = 0x00000080,
TestSkipProperty = 0x00000100
};
Q_DECLARE_FLAGS(ScriptOptions, ScriptOption)
void setScript(const QString &s) { m_script = s; }
@@ -111,6 +111,7 @@ public:
QDeclarativeView *view() const;
LoggerWidget *warningsWidget() const;
QString currentFile() const { return currentFileOrUrl; }
void enableExperimentalGestures();
@@ -119,6 +120,7 @@ public slots:
void sceneResized(QSize size);
bool open(const QString&);
void openFile();
void openUrl();
void reload();
void takeSnapShot();
void toggleRecording();
@@ -163,7 +165,6 @@ private:
QString getVideoFileName();
LoggerWidget *loggerWindow;
QDeclarativeView *canvas;
QmlJSDebugger::QDeclarativeViewObserver *observer;
QSize initialSize;
@@ -183,8 +184,6 @@ private:
int record_autotime;
bool devicemode;
QAction *recordAction;
QString currentSkin;
bool scaleSkin;
RecordingDialog *recdlg;
void senseImageMagick();
@@ -199,6 +198,7 @@ private:
QAction *animationStepAction;
QAction *animationSetStepAction;
QAction *rotateAction;
QActionGroup *orientation;
QAction *showWarningsWindow;
QAction *designModeBehaviorAction;
@@ -214,8 +214,6 @@ private:
bool useQmlFileBrowser;
QWidget *m_centralWidget;
QTranslator *translator;
void loadTranslationFile(const QString& directory);

View File

@@ -1,9 +0,0 @@
<RCC>
<qresource prefix="/">
<file>content/Browser.qml</file>
<file>content/images/up.png</file>
<file>content/images/folder.png</file>
<file>content/images/titlebar.sci</file>
<file>content/images/titlebar.png</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,179 @@
/****************************************************************************
**
** 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 QtDeclarative module 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$
**
****************************************************************************/
import QtQuick 1.0
Rectangle {
id: myApp
width: 411
height: 411
color: "transparent"
property alias logoState : myApp.state
signal animationFinished
Item {
id: sketchBlueHolder
width: sketchLogo.width
height: sketchLogo.height
Image {
id: image1
x: -44
y: -45
smooth: true
source: "shadow.png"
}
Item {
clip: true
width: sketchLogo.width
height: sketchLogo.height
Image {
id: sketchLogo
smooth: true
source: "qt-sketch.jpg"
}
Image {
id: blueLogo
y: -420
smooth: true
source: "qt-blue.jpg"
}
}
}
states: [
State {
name: "showBlueprint"
PropertyChanges {
target: blueLogo
y: 0
}
PropertyChanges {
target: sketchLogo
opacity: 0
}
},
State {
extend: "showBlueprint"
name: "finale"
PropertyChanges {
target: fullLogo
opacity: 1
}
PropertyChanges {
target: backLogo
opacity: 1
scale: 1
}
PropertyChanges {
target: frontLogo
opacity: 1
scale: 1
}
PropertyChanges {
target: qtText
opacity: 1
scale: 1
}
PropertyChanges {
target: sketchBlueHolder
opacity: 0
scale: 1.4
}
}
]
transitions: [
Transition {
to: "showBlueprint"
SequentialAnimation {
NumberAnimation { property: "y"; duration: 600; easing.type: "OutBounce" }
PropertyAction { target: sketchLogo; property: "opacity" }
}
},
Transition {
to: "finale"
PropertyAction { target: fullLogo; property: "opacity" }
SequentialAnimation {
NumberAnimation { target: backLogo; properties: "scale, opacity"; duration: 300 }
NumberAnimation { target: frontLogo; properties: "scale, opacity"; duration: 300 }
ParallelAnimation {
NumberAnimation { target: qtText; properties: "opacity, scale"; duration: 400; easing.type: "OutQuad" }
NumberAnimation { target: sketchBlueHolder; property: "opacity"; duration: 300; easing.type: "OutQuad" }
NumberAnimation { target: sketchBlueHolder; property: "scale"; duration: 320; easing.type: "OutQuad" }
}
PauseAnimation { duration: 1000 }
ScriptAction { script: myApp.animationFinished() }
}
}
]
Item {
id: fullLogo
opacity: 0
Image {
id: backLogo
x: -16
y: -41
opacity: 0
scale: 0.7
smooth: true
source: "qt-back.png"
}
Image {
id: frontLogo
x: -17
y: -41
opacity: 0
scale: 1.2
smooth: true
source: "qt-front.png"
}
Image {
id: qtText
x: -10
y: -41
opacity: 0
scale: 1.2
smooth: true
source: "qt-text.png"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,173 @@
/****************************************************************************
**
** 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 QtDeclarative module 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$
**
****************************************************************************/
import QtQuick 1.0
Rectangle {
id: treatsApp
width: 800
height: 480
color: "darkgrey"
Component.onCompleted: treatsApp.state = "part1"
signal animationFinished
Item {
width: 800
height: 480
anchors.centerIn: parent
clip: true
Logo {
id: logo
x: 165
y: 35
rotation: -15
scale: 0.6
opacity: 0
onAnimationFinished: treatsApp.animationFinished();
}
Item {
id: quickblur
x: 800//325
y: 344
Image {
id: blurText
source: "quick-blur.png"
}
Image {
id: quickregular
x: -1
y: 0
opacity: 0
source: "quick-regular.png"
}
Image {
id: star
x: -1
y: 0
opacity: 0
source: "white-star.png"
smooth: true
NumberAnimation on rotation {
from: 0
to: 360
loops: NumberAnimation.Infinite
running: true
duration: 2000
}
}
}
}
states: [
State {
name: "part1"
PropertyChanges {
target: logo
scale: 0.8
opacity: 1
rotation: 0
}
PropertyChanges {
target: treatsApp
color: "black"
}
PropertyChanges {
target: logo
y: 10
}
PropertyChanges {
target: quickblur
x: logo.x + 145
}
PropertyChanges {
target: blurText
opacity: 0
}
PropertyChanges {
target: quickregular
opacity: 1
}
PropertyChanges {
target: star
x: -7
y: -37
}
}
]
transitions: [
Transition {
ParallelAnimation {
NumberAnimation { target: logo; property: "opacity"; duration: 500 }
NumberAnimation { target: logo; property: "scale"; duration: 4000; }
NumberAnimation { target: logo; property: "rotation"; duration: 2000; easing.type: "OutBack"}
ColorAnimation { duration: 3000}
SequentialAnimation {
PauseAnimation { duration: 1000 }
ScriptAction { script: logo.logoState = "showBlueprint" }
PauseAnimation { duration: 800 }
ScriptAction { script: logo.logoState = "finale" }
PauseAnimation { duration: 800 }
ParallelAnimation {
NumberAnimation { target: quickblur; property: "x"; duration: 200;}
SequentialAnimation {
PauseAnimation { duration: 200}
ParallelAnimation {
NumberAnimation { target: blurText; property: "opacity"; duration: 300;}
NumberAnimation { target: quickregular; property: "opacity"; duration: 300;}
}
NumberAnimation { target: star; property: "opacity"; from: 0; to: 1; duration: 500 }
PauseAnimation { duration: 200 }
NumberAnimation { target: star; property: "opacity"; from: 1; to: 0; duration: 500 }
}
SequentialAnimation {
PauseAnimation { duration: 150}
NumberAnimation { target: logo; property: "y"; duration: 300; easing.type: "OutBounce" }
}
}
}
}
}
]
} // treatsApp

View File

@@ -0,0 +1,16 @@
<RCC>
<qresource prefix="/startup">
<file>Logo.qml</file>
<file>qt-back.png</file>
<file>qt-blue.jpg</file>
<file>qt-front.png</file>
<file>qt-sketch.jpg</file>
<file>qt-text.png</file>
<file>quick-blur.png</file>
<file>quick-regular.png</file>
<file>shadow.png</file>
<file>startup.qml</file>
<file>startup.qrc</file>
<file>white-star.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB