diff options
author | Friedemann Kleint <[email protected]> | 2010-09-29 12:23:45 +0200 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2010-09-29 12:23:45 +0200 |
commit | 18688c9a236cc21b6c956fd968ae5796ea5657bb (patch) | |
tree | 02f5e98ab37e7e7fc75d865023fd2cdca062a4f8 /src/tools/qml | |
parent | 5c583fb0df5d95d3d67655af9ea1cd8d55dfe647 (diff) | |
parent | 32fff3f6cd41a67703a6e3525d82a852a3393be4 (diff) |
Merge remote branch 'origin/2.1'
Diffstat (limited to 'src/tools/qml')
31 files changed, 0 insertions, 5752 deletions
diff --git a/src/tools/qml/qml.pro b/src/tools/qml/qml.pro deleted file mode 100644 index 5af8d71c73b..00000000000 --- a/src/tools/qml/qml.pro +++ /dev/null @@ -1,23 +0,0 @@ -TEMPLATE = subdirs - -contains(QT_CONFIG, declarative) { - - include(../../private_headers.pri) - exists($${QT_PRIVATE_HEADERS}/QtDeclarative/private/qdeclarativemetatype_p.h) { - SUBDIRS += qmldump ../../../share/qtcreator/qmljsdebugger qmlobserver - CONFIG += ordered - } else { - warning() - warning("QmlDump utility has been disabled") - warning("The helper depends on on private headers from QtDeclarative module.") - warning("This means the Qml editor will lack correct completion and type checking.") - warning("To enable it, pass 'QT_PRIVATE_HEADERS=$QTDIR/include' to qmake, where $QTDIR is the source directory of qt.") - warning() - warning("QmlObserver has been disabled") - warning("This application depends on private headers from QtDeclarative module.") - warning("This means the QML debugging facilities will be limited.") - warning("To enable it, pass 'QT_PRIVATE_HEADERS=$QTDIR/include' to qmake, where $QTDIR is the source directory of qt.") - warning() - } -} - diff --git a/src/tools/qml/qmldump/Info.plist b/src/tools/qml/qmldump/Info.plist deleted file mode 100644 index cb0561b6f09..00000000000 --- a/src/tools/qml/qmldump/Info.plist +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>NSHumanReadableCopyright</key> - <string>(C) 2008-2010 Nokia Corporation -Commercial Usage - -Licensees holding valid Qt Commercial licenses may use this file in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. - -GNU Lesser General Public License Usage - -Alternatively, this plugin 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.</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleSignature</key> - <string>@TYPEINFO@</string> - <key>CFBundleExecutable</key> - <string>@EXECUTABLE@</string> - <key>CFBundleIdentifier</key> - <string>com.nokia.qtcreator.qmldump</string> - <key>CFBundleVersion</key> - <string>2.1.80</string> - <key>CFBundleShortVersionString</key> - <string>2.1.80</string> - <key>LSUIElement</key> - <string>1</string> -</dict> -</plist> diff --git a/src/tools/qml/qmldump/main.cpp b/src/tools/qml/qmldump/main.cpp deleted file mode 100644 index 61211ee07d9..00000000000 --- a/src/tools/qml/qmldump/main.cpp +++ /dev/null @@ -1,375 +0,0 @@ -#include <QApplication> -#include <QSet> -#include <QXmlStreamWriter> -#include <QXmlStreamReader> - -#include <QMetaObject> -#include <QMetaProperty> -#include <QPushButton> -#include <QDebug> -#include <iostream> -#include <QtDeclarative> -#include <QtCore/private/qobject_p.h> -#include <QtCore/private/qmetaobject_p.h> -#include <QtDeclarative/private/qdeclarativemetatype_p.h> -#include <QtDeclarative/private/qdeclarativeopenmetaobject_p.h> -#include <QtDeclarative/QDeclarativeView> - -static QHash<QByteArray, const QDeclarativeType *> qmlTypeByCppName; -static QHash<QByteArray, QByteArray> cppToQml; - -QByteArray convertToQmlType(const QByteArray &cppName) -{ - QByteArray qmlName = cppToQml.value(cppName, cppName); - qmlName.replace("::", "."); - qmlName.replace("/", "."); - return qmlName; -} - -void erasure(QByteArray *typeName, bool *isList, bool *isPointer) -{ - static QByteArray declListPrefix = "QDeclarativeListProperty<"; - - if (typeName->endsWith('*')) { - *isPointer = true; - typeName->truncate(typeName->length() - 1); - erasure(typeName, isList, isPointer); - } else if (typeName->startsWith(declListPrefix)) { - *isList = true; - typeName->truncate(typeName->length() - 1); // get rid of the suffix '>' - *typeName = typeName->mid(declListPrefix.size()); - erasure(typeName, isList, isPointer); - } - - *typeName = convertToQmlType(*typeName); -} - -void processMetaObject(const QMetaObject *meta, QSet<const QMetaObject *> *metas) -{ - if (! meta || metas->contains(meta)) - return; - - // dynamic meta objects break things badly - const QMetaObjectPrivate *mop = reinterpret_cast<const QMetaObjectPrivate *>(meta->d.data); - if (!(mop->flags & DynamicMetaObject)) - metas->insert(meta); - - processMetaObject(meta->superClass(), metas); -} - -void processObject(QObject *object, QSet<const QMetaObject *> *metas) -{ - if (! object) - return; - - const QMetaObject *meta = object->metaObject(); - qDebug() << "Processing object" << meta->className(); - processMetaObject(meta, metas); - - for (int index = 0; index < meta->propertyCount(); ++index) { - QMetaProperty prop = meta->property(index); - if (QDeclarativeMetaType::isQObject(prop.userType())) { - qDebug() << " Processing property" << prop.name(); - QObject *oo = QDeclarativeMetaType::toQObject(prop.read(object)); - if (oo && !metas->contains(oo->metaObject())) - processObject(oo, metas); - } - } -} - -void processDeclarativeType(const QDeclarativeType *ty, QSet<const QMetaObject *> *metas) -{ - processMetaObject(ty->metaObject(), metas); -} - -void writeType(QXmlStreamAttributes *attrs, QByteArray typeName) -{ - bool isList = false, isPointer = false; - erasure(&typeName, &isList, &isPointer); - attrs->append(QXmlStreamAttribute("type", typeName)); - if (isList) - attrs->append(QXmlStreamAttribute("isList", "true")); -} - -void dump(const QMetaProperty &prop, QXmlStreamWriter *xml) -{ - xml->writeStartElement("property"); - - QXmlStreamAttributes attributes; - attributes.append(QXmlStreamAttribute("name", QString::fromUtf8(prop.name()))); - - writeType(&attributes, prop.typeName()); - - xml->writeAttributes(attributes); - xml->writeEndElement(); -} - -void dump(const QMetaMethod &meth, QXmlStreamWriter *xml) -{ - if (meth.methodType() == QMetaMethod::Signal) { - if (meth.access() != QMetaMethod::Protected) - return; // nothing to do. - } else if (meth.access() != QMetaMethod::Public) { - return; // nothing to do. - } - - QByteArray name = meth.signature(); - int lparenIndex = name.indexOf('('); - if (lparenIndex == -1) { - return; // invalid signature - } - - name = name.left(lparenIndex); - - - QString elementName = QLatin1String("method"); - - QXmlStreamAttributes attributes; - if (meth.methodType() == QMetaMethod::Signal) - elementName = QLatin1String("signal"); - - xml->writeStartElement(elementName); - - attributes.append(QXmlStreamAttribute("name", name)); - - const QString typeName = convertToQmlType(meth.typeName()); - if (! typeName.isEmpty()) - attributes.append(QXmlStreamAttribute("type", typeName)); - - xml->writeAttributes(attributes); - - for (int i = 0; i < meth.parameterTypes().size(); ++i) { - QByteArray argName = meth.parameterNames().at(i); - - xml->writeStartElement("param"); - - QXmlStreamAttributes attrs; - - if (! argName.isEmpty()) - attrs.append(QXmlStreamAttribute("name", argName)); - - writeType(&attrs, meth.parameterTypes().at(i)); - xml->writeAttributes(attrs); - - xml->writeEndElement(); - } - - xml->writeEndElement(); -} - -void dump(const QMetaEnum &e, QXmlStreamWriter *xml) -{ - xml->writeStartElement("enum"); - - QXmlStreamAttributes attributes; - attributes.append(QXmlStreamAttribute("name", QString::fromUtf8(e.name()))); // ### FIXME - xml->writeAttributes(attributes); - - for (int index = 0; index < e.keyCount(); ++index) { - xml->writeStartElement("enumerator"); - - QXmlStreamAttributes attributes; - attributes.append(QXmlStreamAttribute("name", QString::fromUtf8(e.key(index)))); - attributes.append(QXmlStreamAttribute("value", QString::number(e.value(index)))); - xml->writeAttributes(attributes); - - xml->writeEndElement(); - } - - xml->writeEndElement(); -} - -class FriendlyQObject: public QObject -{ -public: - static const QMetaObject *qtMeta() { return &staticQtMetaObject; } -}; - -void dump(const QMetaObject *meta, QXmlStreamWriter *xml) -{ - QByteArray qmlTypeName = convertToQmlType(meta->className()); - - xml->writeStartElement("type"); - - QXmlStreamAttributes attributes; - attributes.append(QXmlStreamAttribute("name", qmlTypeName)); - - if (const QDeclarativeType *qmlTy = qmlTypeByCppName.value(meta->className())) { - attributes.append(QXmlStreamAttribute("version", QString("%1.%2").arg(qmlTy->majorVersion()).arg(qmlTy->minorVersion()))); - } - - for (int index = meta->classInfoCount() - 1 ; index >= 0 ; --index) { - QMetaClassInfo classInfo = meta->classInfo(index); - if (QLatin1String(classInfo.name()) == QLatin1String("DefaultProperty")) { - attributes.append(QXmlStreamAttribute("defaultProperty", QLatin1String(classInfo.value()))); - break; - } - } - - QString version; - - if (meta->superClass()) - attributes.append(QXmlStreamAttribute("extends", convertToQmlType(meta->superClass()->className()))); - - if (! version.isEmpty()) - attributes.append(QXmlStreamAttribute("version", version)); - - xml->writeAttributes(attributes); - - for (int index = meta->enumeratorOffset(); index < meta->enumeratorCount(); ++index) - dump(meta->enumerator(index), xml); - - for (int index = meta->propertyOffset(); index < meta->propertyCount(); ++index) - dump(meta->property(index), xml); - - for (int index = meta->methodOffset(); index < meta->methodCount(); ++index) - dump(meta->method(index), xml); - - xml->writeEndElement(); -} - -void writeEasingCurve(QXmlStreamWriter *xml) -{ - xml->writeStartElement("type"); - { - QXmlStreamAttributes attributes; - attributes.append(QXmlStreamAttribute("name", "QEasingCurve")); - attributes.append(QXmlStreamAttribute("extends", "Qt.Easing")); - xml->writeAttributes(attributes); - } - - xml->writeEndElement(); -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - if (argc != 1 && argc != 3) { - qWarning() << "Usage: qmldump [plugin/import/path plugin.uri]"; - return 1; - } - - QString pluginImportName; - QString pluginImportPath; - if (argc == 3) { - pluginImportPath = QString(argv[1]); - pluginImportName = QString(argv[2]); - } - - QDeclarativeView view; - QDeclarativeEngine *engine = view.engine(); - if (!pluginImportPath.isEmpty()) - engine->addImportPath(pluginImportPath); - - QByteArray importCode; - importCode += "import Qt 4.7;\n"; - if (pluginImportName.isEmpty()) { - importCode += "import Qt.labs.particles 4.7;\n"; - importCode += "import Qt.labs.gestures 4.7;\n"; - importCode += "import Qt.labs.folderlistmodel 4.7;\n"; - importCode += "import QtWebKit 1.0;\n"; - } else { - importCode += QString("import %0 1.0;\n").arg(pluginImportName).toAscii(); - } - - { - QByteArray code = importCode; - code += "Item {}"; - QDeclarativeComponent c(engine); - - c.setData(code, QUrl("xxx")); - c.create(); - if (!c.errors().isEmpty()) - qDebug() << c.errorString(); - } - - cppToQml.insert("QString", "string"); - cppToQml.insert("QDeclarativeEasingValueType::Type", "Type"); - - QSet<const QMetaObject *> metas; - - metas.insert(FriendlyQObject::qtMeta()); - - QMultiHash<QByteArray, QByteArray> extensions; - foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) { - qmlTypeByCppName.insert(ty->metaObject()->className(), ty); - if (ty->isExtendedType()) { - extensions.insert(ty->typeName(), ty->metaObject()->className()); - } else { - cppToQml.insert(ty->metaObject()->className(), ty->qmlTypeName()); - } - processDeclarativeType(ty, &metas); - } - - // Adjust qml names of extended objects. - // The chain ends up being: - // __extended__.originalname - the base object - // __extension_0_.originalname - first extension - // .. - // __extension_n-2_.originalname - second to last extension - // originalname - last extension - foreach (const QByteArray &extendedCpp, extensions.keys()) { - const QByteArray extendedQml = cppToQml.value(extendedCpp); - cppToQml.insert(extendedCpp, "__extended__." + extendedQml); - QList<QByteArray> extensionCppNames = extensions.values(extendedCpp); - for (int i = 0; i < extensionCppNames.size() - 1; ++i) { - QByteArray adjustedName = QString("__extension__%1.%2").arg(QString::number(i), QString(extendedQml)).toAscii(); - cppToQml.insert(extensionCppNames.value(i), adjustedName); - } - cppToQml.insert(extensionCppNames.last(), extendedQml); - } - - foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) { - if (ty->isExtendedType()) - continue; - - QByteArray tyName = ty->qmlTypeName(); - tyName = tyName.mid(tyName.lastIndexOf('/') + 1); - - QByteArray code = importCode; - code += tyName; - code += " {}\n"; - - QDeclarativeComponent c(engine); - c.setData(code, QUrl("xxx")); - - QObject *object = c.create(); - if (object) - processObject(object, &metas); - else - qDebug() << "Could not create" << tyName << ":" << c.errorString(); - } - - QByteArray bytes; - QXmlStreamWriter xml(&bytes); - xml.setAutoFormatting(true); - - xml.writeStartDocument("1.0"); - xml.writeStartElement("module"); - - QMap<QString, const QMetaObject *> nameToMeta; - foreach (const QMetaObject *meta, metas) { - nameToMeta.insert(convertToQmlType(meta->className()), meta); - } - foreach (const QMetaObject *meta, nameToMeta) { - dump(meta, &xml); - } - - // define QEasingCurve as an extension of Qt.Easing - writeEasingCurve(&xml); - - xml.writeEndElement(); - xml.writeEndDocument(); - - std::cout << bytes.constData(); - - QTimer timer; - timer.setSingleShot(true); - timer.setInterval(0); - QObject::connect(&timer, SIGNAL(timeout()), &app, SLOT(quit())); - - timer.start(); - - return app.exec(); -} diff --git a/src/tools/qml/qmldump/qmldump.pro b/src/tools/qml/qmldump/qmldump.pro deleted file mode 100644 index 31700e75496..00000000000 --- a/src/tools/qml/qmldump/qmldump.pro +++ /dev/null @@ -1,21 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2010-02-24T10:21:38 -# -#------------------------------------------------- - -TARGET = qmldump -QT += declarative -CONFIG += console - -TEMPLATE = app - -SOURCES += main.cpp - -include(../../../../qtcreator.pri) -include(../../../private_headers.pri) -DESTDIR = $$IDE_BIN_PATH -include(../../../rpath.pri) - -OTHER_FILES += Info.plist -macx:QMAKE_INFO_PLIST = Info.plist diff --git a/src/tools/qml/qmlobserver/Info_mac.plist b/src/tools/qml/qmlobserver/Info_mac.plist deleted file mode 100644 index 80ca6a35269..00000000000 --- a/src/tools/qml/qmlobserver/Info_mac.plist +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> -<plist version="0.1"> -<dict> - <key>CFBundleIconFile</key> - <string>@ICON@</string> - <key>CFBundleIdentifier</key> - <string>com.nokia.qt.qml</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleGetInfoString</key> - <string>Created by Qt/QMake</string> - <key>CFBundleSignature</key> - <string>@TYPEINFO@</string> - <key>CFBundleExecutable</key> - <string>@EXECUTABLE@</string> -</dict> -</plist> diff --git a/src/tools/qml/qmlobserver/content/Browser.qml b/src/tools/qml/qmlobserver/content/Browser.qml deleted file mode 100644 index ff2bb476473..00000000000 --- a/src/tools/qml/qmlobserver/content/Browser.qml +++ /dev/null @@ -1,284 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 -import Qt.labs.folderlistmodel 1.0 - -Rectangle { - id: root - property bool keyPressed: false - property variant folders: folders1 - property variant view: view1 - width: 320 - height: 480 - color: palette.window - - FolderListModel { - id: folders1 - nameFilters: [ "*.qml" ] - folder: qmlViewerFolder - } - FolderListModel { - id: folders2 - nameFilters: [ "*.qml" ] - folder: qmlViewerFolder - } - - SystemPalette { id: palette } - - function down(path) { - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitLeft"; - } else { - view = view1 - folders = folders1; - view2.state = "exitLeft"; - } - view.x = root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } - function up() { - var path = folders.parentFolder; - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitRight"; - } else { - view = view1 - folders = folders1; - view2.state = "exitRight"; - } - view.x = -root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } - - Component { - id: folderDelegate - Rectangle { - id: wrapper - function launch() { - if (folders.isFolder(index)) { - down(filePath); - } else { - qmlViewer.launch(filePath); - } - } - width: root.width - height: 52 - color: "transparent" - Rectangle { - id: highlight; visible: false - anchors.fill: parent - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } - } - Item { - width: 48; height: 48 - Image { source: "images/folder.png"; anchors.centerIn: parent; visible: folders.isFolder(index)} - } - Text { - id: nameText - anchors.fill: parent; verticalAlignment: Text.AlignVCenter - text: fileName - anchors.leftMargin: 54 - font.pixelSize: 32 - color: (wrapper.ListView.isCurrentItem && root.keyPressed) ? palette.highlightedText : palette.windowText - elide: Text.ElideRight - } - MouseArea { - id: mouseRegion - anchors.fill: parent - onClicked: { if (folders == wrapper.ListView.view.model) launch() } - } - states: [ - State { - name: "pressed" - when: mouseRegion.pressed - PropertyChanges { target: highlight; visible: true } - PropertyChanges { target: nameText; color: palette.highlightedText } - } - ] - } - } - - ListView { - id: view1 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: 0 - width: parent.width - model: folders1 - delegate: folderDelegate - highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view1.count != 0 } - highlightMoveSpeed: 1000 - pressDelay: 100 - focus: true - state: "current" - states: [ - State { - name: "current" - PropertyChanges { target: view1; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view1; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view1; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } - } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - NumberAnimation { properties: "x"; duration: 250 } - } - ] - Keys.onPressed: { root.keyPressed = true; } - } - - ListView { - id: view2 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: parent.width - width: parent.width - model: folders2 - delegate: folderDelegate - highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view2.count != 0 } - highlightMoveSpeed: 1000 - pressDelay: 100 - states: [ - State { - name: "current" - PropertyChanges { target: view2; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view2; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view2; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } - } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - } - ] - Keys.onPressed: { root.keyPressed = true; } - } - - Keys.onPressed: { - root.keyPressed = true; - if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { - view.currentItem.launch(); - event.accepted = true; - } else if (event.key == Qt.Key_Left) { - up(); - } - } - - BorderImage { - source: "images/titlebar.sci"; - width: parent.width; - height: 52 - y: -7 - id: titleBar - - Rectangle { - id: upButton - width: 48 - height: titleBar.height - 7 - color: "transparent" - - Image { anchors.centerIn: parent; source: "images/up.png" } - MouseArea { id: upRegion; anchors.centerIn: parent - width: 56 - height: 56 - onClicked: if (folders.parentFolder != "") up() - } - states: [ - State { - name: "pressed" - when: upRegion.pressed - PropertyChanges { target: upButton; color: palette.highlight } - } - ] - } - Rectangle { - color: "gray" - x: 48 - width: 1 - height: 44 - } - - Text { - anchors.left: upButton.right; anchors.right: parent.right; height: parent.height - anchors.leftMargin: 4; anchors.rightMargin: 4 - text: folders.folder - color: "white" - elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter - font.pixelSize: 32 - } - } -} diff --git a/src/tools/qml/qmlobserver/content/images/folder.png b/src/tools/qml/qmlobserver/content/images/folder.png Binary files differdeleted file mode 100644 index e53e2ad464e..00000000000 --- a/src/tools/qml/qmlobserver/content/images/folder.png +++ /dev/null diff --git a/src/tools/qml/qmlobserver/content/images/titlebar.png b/src/tools/qml/qmlobserver/content/images/titlebar.png Binary files differdeleted file mode 100644 index 51c90082d05..00000000000 --- a/src/tools/qml/qmlobserver/content/images/titlebar.png +++ /dev/null diff --git a/src/tools/qml/qmlobserver/content/images/titlebar.sci b/src/tools/qml/qmlobserver/content/images/titlebar.sci deleted file mode 100644 index 0418d94cd60..00000000000 --- a/src/tools/qml/qmlobserver/content/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/src/tools/qml/qmlobserver/content/images/up.png b/src/tools/qml/qmlobserver/content/images/up.png Binary files differdeleted file mode 100644 index b05f8025d01..00000000000 --- a/src/tools/qml/qmlobserver/content/images/up.png +++ /dev/null diff --git a/src/tools/qml/qmlobserver/deviceorientation.cpp b/src/tools/qml/qmlobserver/deviceorientation.cpp deleted file mode 100644 index e7c70d5fde7..00000000000 --- a/src/tools/qml/qmlobserver/deviceorientation.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "deviceorientation.h" - -QT_USE_NAMESPACE - -class DefaultDeviceOrientation : public DeviceOrientation -{ - Q_OBJECT -public: - DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::Portrait) {} - - Orientation orientation() const { - return m_orientation; - } - - void setOrientation(Orientation o) { - if (o != m_orientation) { - m_orientation = o; - emit orientationChanged(); - } - } - - Orientation m_orientation; -}; - -DeviceOrientation* DeviceOrientation::instance() -{ - static DefaultDeviceOrientation *o = 0; - if (!o) - o = new DefaultDeviceOrientation; - return o; -} - -#include "deviceorientation.moc" - diff --git a/src/tools/qml/qmlobserver/deviceorientation.h b/src/tools/qml/qmlobserver/deviceorientation.h deleted file mode 100644 index 817bfc8528c..00000000000 --- a/src/tools/qml/qmlobserver/deviceorientation.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ORIENTATION_H -#define ORIENTATION_H - -#include <QObject> - -QT_BEGIN_NAMESPACE - -class DeviceOrientationPrivate; -class DeviceOrientation : public QObject -{ - Q_OBJECT - Q_ENUMS(Orientation) -public: - enum Orientation { - UnknownOrientation, - Portrait, - Landscape, - PortraitInverted, - LandscapeInverted - }; - - virtual Orientation orientation() const = 0; - virtual void setOrientation(Orientation) = 0; - - static DeviceOrientation *instance(); - -signals: - void orientationChanged(); - -protected: - DeviceOrientation() {} - -private: - DeviceOrientationPrivate *d_ptr; - friend class DeviceOrientationPrivate; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/tools/qml/qmlobserver/deviceorientation_maemo5.cpp b/src/tools/qml/qmlobserver/deviceorientation_maemo5.cpp deleted file mode 100644 index e942579b70d..00000000000 --- a/src/tools/qml/qmlobserver/deviceorientation_maemo5.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "deviceorientation.h" -#include <QtDBus> - -#include <mce/mode-names.h> -#include <mce/dbus-names.h> - -class MaemoOrientation : public DeviceOrientation -{ - Q_OBJECT -public: - MaemoOrientation() - : o(UnknownOrientation) - { - // 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()); - } - - // connect to the orientation change signal - QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF, - MCE_DEVICE_ORIENTATION_SIG, - this, - SLOT(deviceOrientationChanged(QString))); - } - - ~MaemoOrientation() - { - // disable the orientation sensor - QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH, - MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ)); - } - - inline Orientation orientation() const - { - return o; - } - - void setOrientation(Orientation o) - { - } - -private Q_SLOTS: - void deviceOrientationChanged(const QString &newOrientation) - { - o = toOrientation(newOrientation); - - emit orientationChanged(); -// printf("%d\n", o); - } - -private: - static Orientation toOrientation(const QString &nativeOrientation) - { - if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE) - return Landscape; - else if (nativeOrientation == MCE_ORIENTATION_LANDSCAPE_INVERTED) - return LandscapeInverted; - else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT) - return Portrait; - else if (nativeOrientation == MCE_ORIENTATION_PORTRAIT_INVERTED) - return PortraitInverted; - return UnknownOrientation; - } - -private: - Orientation o; -}; - -DeviceOrientation* DeviceOrientation::instance() -{ - static MaemoOrientation *o = new MaemoOrientation; - return o; -} - -#include "deviceorientation_maemo5.moc" diff --git a/src/tools/qml/qmlobserver/loggerwidget.cpp b/src/tools/qml/qmlobserver/loggerwidget.cpp deleted file mode 100644 index 8aa029f3d00..00000000000 --- a/src/tools/qml/qmlobserver/loggerwidget.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qglobal.h> -#include <QDebug> -#include <QSettings> -#include <QActionGroup> -#include <QMenu> -#include <QPlainTextEdit> -#ifdef Q_WS_MAEMO_5 -# include <QScrollArea> -# include <QVBoxLayout> -# include "texteditautoresizer_maemo5.h" -#endif - -#include "loggerwidget.h" - -QT_BEGIN_NAMESPACE - -LoggerWidget::LoggerWidget(QWidget *parent) : - QMainWindow(parent), - m_visibilityOrigin(SettingsOrigin) -{ - setAttribute(Qt::WA_QuitOnClose, false); - setWindowTitle(tr("Warnings")); - - m_plainTextEdit = new QPlainTextEdit(); - -#ifdef Q_WS_MAEMO_5 - new TextEditAutoResizer(m_plainTextEdit); - setAttribute(Qt::WA_Maemo5StackedWindow); - QScrollArea *area = new QScrollArea(); - area->setWidget(m_plainTextEdit); - area->setWidgetResizable(true); - setCentralWidget(area); -#else - setCentralWidget(m_plainTextEdit); -#endif - readSettings(); - setupPreferencesMenu(); -} - -void LoggerWidget::append(const QString &msg) -{ - m_plainTextEdit->appendPlainText(msg); - - if (!isVisible() && (defaultVisibility() == AutoShowWarnings)) - setVisible(true); -} - -LoggerWidget::Visibility LoggerWidget::defaultVisibility() const -{ - return m_visibility; -} - -void LoggerWidget::setDefaultVisibility(LoggerWidget::Visibility visibility) -{ - if (m_visibility == visibility) - return; - - m_visibility = visibility; - m_visibilityOrigin = CommandLineOrigin; - - m_preferencesMenu->setEnabled(m_visibilityOrigin == SettingsOrigin); -} - -QMenu *LoggerWidget::preferencesMenu() -{ - return m_preferencesMenu; -} - -QAction *LoggerWidget::showAction() -{ - return m_showWidgetAction; -} - -void LoggerWidget::readSettings() -{ - QSettings settings; - QString warningsPreferences = settings.value("warnings", "hide").toString(); - if (warningsPreferences == "show") { - m_visibility = ShowWarnings; - } else if (warningsPreferences == "hide") { - m_visibility = HideWarnings; - } else { - m_visibility = AutoShowWarnings; - } -} - -void LoggerWidget::saveSettings() -{ - if (m_visibilityOrigin != SettingsOrigin) - return; - - QString value = "autoShow"; - if (defaultVisibility() == ShowWarnings) { - value = "show"; - } else if (defaultVisibility() == HideWarnings) { - value = "hide"; - } - - QSettings settings; - settings.setValue("warnings", value); -} - -void LoggerWidget::warningsPreferenceChanged(QAction *action) -{ - Visibility newSetting = static_cast<Visibility>(action->data().toInt()); - m_visibility = newSetting; - saveSettings(); -} - -void LoggerWidget::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - emit opened(); -} - -void LoggerWidget::closeEvent(QCloseEvent *event) -{ - QWidget::closeEvent(event); - emit closed(); -} - -void LoggerWidget::setupPreferencesMenu() -{ - m_preferencesMenu = new QMenu(tr("Warnings")); - QActionGroup *warnings = new QActionGroup(m_preferencesMenu); - warnings->setExclusive(true); - - connect(warnings, SIGNAL(triggered(QAction*)), this, SLOT(warningsPreferenceChanged(QAction*))); - - QAction *showWarningsPreference = new QAction(tr("Show by default"), m_preferencesMenu); - showWarningsPreference->setCheckable(true); - showWarningsPreference->setData(LoggerWidget::ShowWarnings); - warnings->addAction(showWarningsPreference); - m_preferencesMenu->addAction(showWarningsPreference); - - QAction *hideWarningsPreference = new QAction(tr("Hide by default"), m_preferencesMenu); - hideWarningsPreference->setCheckable(true); - hideWarningsPreference->setData(LoggerWidget::HideWarnings); - warnings->addAction(hideWarningsPreference); - m_preferencesMenu->addAction(hideWarningsPreference); - - QAction *autoWarningsPreference = new QAction(tr("Show for first warning"), m_preferencesMenu); - autoWarningsPreference->setCheckable(true); - autoWarningsPreference->setData(LoggerWidget::AutoShowWarnings); - warnings->addAction(autoWarningsPreference); - m_preferencesMenu->addAction(autoWarningsPreference); - - switch (defaultVisibility()) { - case LoggerWidget::ShowWarnings: - showWarningsPreference->setChecked(true); - break; - case LoggerWidget::HideWarnings: - hideWarningsPreference->setChecked(true); - break; - default: - autoWarningsPreference->setChecked(true); - } -} - -QT_END_NAMESPACE diff --git a/src/tools/qml/qmlobserver/loggerwidget.h b/src/tools/qml/qmlobserver/loggerwidget.h deleted file mode 100644 index 13c319f91af..00000000000 --- a/src/tools/qml/qmlobserver/loggerwidget.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LOGGERWIDGET_H -#define LOGGERWIDGET_H - -#include <QMainWindow> -#include <QMetaType> - -QT_BEGIN_NAMESPACE - -class QPlainTextEdit; -class QMenu; -class QAction; - -class LoggerWidget : public QMainWindow { - Q_OBJECT -public: - LoggerWidget(QWidget *parent=0); - - enum Visibility { ShowWarnings, HideWarnings, AutoShowWarnings }; - - Visibility defaultVisibility() const; - void setDefaultVisibility(Visibility visibility); - - QMenu *preferencesMenu(); - QAction *showAction(); - -public slots: - void append(const QString &msg); - -private slots: - void warningsPreferenceChanged(QAction *action); - void readSettings(); - void saveSettings(); - -protected: - void showEvent(QShowEvent *event); - void closeEvent(QCloseEvent *event); - -signals: - void opened(); - void closed(); - -private: - void setupPreferencesMenu(); - - QMenu *m_preferencesMenu; - QAction *m_showWidgetAction; - QPlainTextEdit *m_plainTextEdit; - - enum ConfigOrigin { CommandLineOrigin, SettingsOrigin }; - ConfigOrigin m_visibilityOrigin; - Visibility m_visibility; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(LoggerWidget::Visibility) - -#endif // LOGGERWIDGET_H diff --git a/src/tools/qml/qmlobserver/main.cpp b/src/tools/qml/qmlobserver/main.cpp deleted file mode 100644 index f04640d970e..00000000000 --- a/src/tools/qml/qmlobserver/main.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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" - -QT_USE_NAMESPACE - -QtMsgHandler systemMsgOutput = 0; - -#if defined (Q_OS_SYMBIAN) -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -void myMessageOutput(QtMsgType type, const char *msg) -{ - static int fd = -1; - if (fd == -1) - fd = ::open("E:\\qml.log", O_WRONLY | O_CREAT); - - ::write(fd, msg, strlen(msg)); - ::write(fd, "\n", 1); - ::fsync(fd); - - switch (type) { - case QtFatalMsg: - abort(); - } -} - -#else // !defined (Q_OS_SYMBIAN) - -QWeakPointer<LoggerWidget> logger; - -QString warnings; -void showWarnings() -{ - 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); - } -} - -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() -{ - qWarning("Usage: qmlviewer [options] <filename>"); - qWarning(" "); - qWarning(" options:"); - qWarning(" -v, -version ............................. display version"); - qWarning(" -frameless ............................... run with no window frame"); - qWarning(" -maximized................................ run maximized"); - qWarning(" -fullscreen............................... run fullscreen"); - qWarning(" -stayontop................................ keep viewer window on top"); - qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); - qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view (default)"); - qWarning(" -qmlbrowser .............................. use a QML-based file browser"); - qWarning(" -warnings [show|hide]..................... show warnings in a separate log window"); - qWarning(" -recordfile <output> ..................... set video recording file"); - qWarning(" - ImageMagick 'convert' for GIF)"); - qWarning(" - png file for raw frames"); - qWarning(" - 'ffmpeg' for other formats"); - qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode"); - qWarning(" -recordrate <fps> ........................ set recording frame rate"); - qWarning(" -record arg .............................. add a recording process argument"); - qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop"); - qWarning(" -devicekeys .............................. use numeric keys (see F1)"); - qWarning(" -dragthreshold <size> .................... set mouse drag threshold size"); - qWarning(" -netcache <size> ......................... set disk cache to size bytes"); - qWarning(" -translation <translationfile> ........... set the language to run in"); - 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"); - qWarning(" -opengl .................................. use a QGLWidget for the viewport"); - qWarning(" -script <path> ........................... set the script to use"); - qWarning(" -scriptopts <options>|help ............... set the script options to use"); - - qWarning(" "); - qWarning(" Press F1 for interactive help"); - exit(1); -} - -void scriptOptsUsage() -{ - qWarning("Usage: qmlviewer -scriptopts <option>[,<option>...] ..."); - qWarning(" options:"); - qWarning(" record ................................... record a new script"); - 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(" snapshot ................................. file being recorded is static,"); - qWarning(" only one frame will be recorded or tested"); - qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion"); - qWarning(" exitonfailure ............................ immediately exit the viewer on script failure"); - qWarning(" saveonexit ............................... save recording on viewer exit"); - qWarning(" "); - qWarning(" One of record, play or both must be specified."); - exit(1); -} - -enum WarningsConfig { ShowWarnings, HideWarnings, DefaultWarnings }; - -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 instead. - atexit(showWarnings); -#endif - -#if defined (Q_WS_X11) || defined (Q_WS_MAC) - //### default to using raster graphics backend for now - bool gsSpecified = false; - for (int i = 0; i < argc; ++i) { - QString arg = argv[i]; - if (arg == "-graphicssystem") { - gsSpecified = true; - break; - } - } - - if (!gsSpecified) - QApplication::setGraphicsSystem("raster"); -#endif - - QApplication app(argc, argv); - app.setApplicationName("QtQmlViewer"); - app.setOrganizationName("Nokia"); - app.setOrganizationDomain("nokia.com"); - - 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(); - } - } - - QTranslator qmlTranslator; - if (!translationFile.isEmpty()) { - qmlTranslator.load(translationFile); - app.installTranslator(&qmlTranslator); - } - - Qt::WFlags wflags = (frameless ? Qt::FramelessWindowHint : Qt::Widget); - if (stayOnTop) - wflags |= Qt::WindowStaysOnTopHint; - - 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); - - // FIXME debug mode is always on for qml observer - debuggerModeBehavior = true; - viewer->setDebugMode(debuggerModeBehavior); - - 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) - qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen."; - - if (fileName.isEmpty()) { - QFile qmlapp(QLatin1String("qmlapp")); - if (qmlapp.exists() && qmlapp.open(QFile::ReadOnly)) { - QString content = QString::fromUtf8(qmlapp.readAll()); - qmlapp.close(); - - int newline = content.indexOf(QLatin1Char('\n')); - if (newline >= 0) - fileName = content.left(newline); - else - fileName = content; - } - } - - if (!fileName.isEmpty()) { - viewer->open(fileName); - fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); - } else { - if (!useNativeFileBrowser) - viewer->openFile(); - fullScreen ? viewer->showFullScreen() : maximized ? viewer->showMaximized() : viewer->show(); - if (useNativeFileBrowser) - viewer->openFile(); - } - viewer->setUseGL(useGL); - viewer->raise(); - - return app.exec(); -} diff --git a/src/tools/qml/qmlobserver/proxysettings.cpp b/src/tools/qml/qmlobserver/proxysettings.cpp deleted file mode 100644 index ffaa4c0a29f..00000000000 --- a/src/tools/qml/qmlobserver/proxysettings.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <QIntValidator> -#include <QSettings> - -#include "proxysettings.h" - -QT_BEGIN_NAMESPACE - -ProxySettings::ProxySettings (QWidget * parent) - : QDialog (parent), Ui::ProxySettings() -{ - setupUi (this); - -#if !defined Q_WS_MAEMO_5 - // the onscreen keyboard can't cope with masks - proxyServerEdit->setInputMask ("000.000.000.000;_"); -#endif - QIntValidator *validator = new QIntValidator (0, 9999, this); - proxyPortEdit->setValidator (validator); - - QSettings settings; - proxyCheckBox->setChecked (settings.value ("http_proxy/use", 0).toBool ()); - proxyServerEdit->insert (settings.value ("http_proxy/hostname", "").toString ()); - proxyPortEdit->insert (settings.value ("http_proxy/port", "80").toString ()); - usernameEdit->insert (settings.value ("http_proxy/username", "").toString ()); - passwordEdit->insert (settings.value ("http_proxy/password", "").toString ()); -} - -ProxySettings::~ProxySettings() -{ -} - -void ProxySettings::accept () -{ - QSettings settings; - - settings.setValue ("http_proxy/use", proxyCheckBox->isChecked ()); - settings.setValue ("http_proxy/hostname", proxyServerEdit->text ()); - settings.setValue ("http_proxy/port", proxyPortEdit->text ()); - settings.setValue ("http_proxy/username", usernameEdit->text ()); - settings.setValue ("http_proxy/password", passwordEdit->text ()); - - QDialog::accept (); -} - -QNetworkProxy ProxySettings::httpProxy () -{ - QSettings settings; - QNetworkProxy proxy; - - bool proxyInUse = settings.value ("http_proxy/use", 0).toBool (); - if (proxyInUse) { - proxy.setType (QNetworkProxy::HttpProxy); - proxy.setHostName (settings.value ("http_proxy/hostname", "").toString ());// "192.168.220.5" - proxy.setPort (settings.value ("http_proxy/port", 80).toInt ()); // 8080 - proxy.setUser (settings.value ("http_proxy/username", "").toString ()); - proxy.setPassword (settings.value ("http_proxy/password", "").toString ()); - //QNetworkProxy::setApplicationProxy (proxy); - } - else { - proxy.setType (QNetworkProxy::NoProxy); - } - return proxy; -} - -bool ProxySettings::httpProxyInUse() -{ - QSettings settings; - return settings.value ("http_proxy/use", 0).toBool (); -} - -QT_END_NAMESPACE diff --git a/src/tools/qml/qmlobserver/proxysettings.h b/src/tools/qml/qmlobserver/proxysettings.h deleted file mode 100644 index 5d4d137a999..00000000000 --- a/src/tools/qml/qmlobserver/proxysettings.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PROXYSETTINGS_H -#define PROXYSETTINGS_H - -#include <QDialog> -#include <QNetworkProxy> -#ifdef Q_WS_MAEMO_5 -#include "ui_proxysettings_maemo5.h" -#else -#include "ui_proxysettings.h" -#endif - -QT_BEGIN_NAMESPACE -/** -*/ -class ProxySettings : public QDialog, public Ui::ProxySettings -{ - -Q_OBJECT - -public: - ProxySettings(QWidget * parent = 0); - - ~ProxySettings(); - - static QNetworkProxy httpProxy (); - static bool httpProxyInUse (); - -public slots: - virtual void accept (); -}; - -QT_END_NAMESPACE - -#endif // PROXYSETTINGS_H diff --git a/src/tools/qml/qmlobserver/proxysettings.ui b/src/tools/qml/qmlobserver/proxysettings.ui deleted file mode 100644 index 84e39fe03db..00000000000 --- a/src/tools/qml/qmlobserver/proxysettings.ui +++ /dev/null @@ -1,115 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProxySettings</class> - <widget class="QDialog" name="ProxySettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>318</width> - <height>199</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QCheckBox" name="proxyCheckBox"> - <property name="text"> - <string>Use http proxy</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="serverAddressLabel"> - <property name="text"> - <string>Server Address:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="proxyServerEdit"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Port:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="proxyPortEdit"/> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="usernameLabel"> - <property name="text"> - <string>Username:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="usernameEdit"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="passwordLabel"> - <property name="text"> - <string>Password:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="passwordEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="5" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ProxySettings</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ProxySettings</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/tools/qml/qmlobserver/proxysettings_maemo5.ui b/src/tools/qml/qmlobserver/proxysettings_maemo5.ui deleted file mode 100644 index 83f0c2a9de2..00000000000 --- a/src/tools/qml/qmlobserver/proxysettings_maemo5.ui +++ /dev/null @@ -1,177 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProxySettings</class> - <widget class="QDialog" name="ProxySettings"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>449</width> - <height>164</height> - </rect> - </property> - <property name="windowTitle"> - <string>HTTP Proxy</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <property name="leftMargin"> - <number>16</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>16</number> - </property> - <property name="bottomMargin"> - <number>8</number> - </property> - <property name="horizontalSpacing"> - <number>16</number> - </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QCheckBox" name="proxyCheckBox"> - <property name="text"> - <string>Use HTTP Proxy</string> - </property> - </widget> - </item> - <item row="0" column="1" rowspan="2"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" rowspan="2"> - <widget class="QWidget" name="widget" native="true"> - <layout class="QGridLayout" name="gridLayout"> - <property name="horizontalSpacing"> - <number>16</number> - </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="serverAddressLabel"> - <property name="text"> - <string>Server</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="proxyServerEdit"> - <property name="placeholderText"> - <string>Name or IP</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Port</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="proxyPortEdit"> - <property name="text"> - <string>8080</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="usernameLabel"> - <property name="text"> - <string>Username</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="usernameEdit"/> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="passwordLabel"> - <property name="text"> - <string>Password</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="passwordEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="2" column="1"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>proxyCheckBox</tabstop> - <tabstop>proxyServerEdit</tabstop> - <tabstop>proxyPortEdit</tabstop> - <tabstop>usernameEdit</tabstop> - <tabstop>passwordEdit</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ProxySettings</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>318</x> - <y>100</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>116</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ProxySettings</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>318</x> - <y>100</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>116</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/tools/qml/qmlobserver/qdeclarativetester.cpp b/src/tools/qml/qmlobserver/qdeclarativetester.cpp deleted file mode 100644 index 9864df63cec..00000000000 --- a/src/tools/qml/qmlobserver/qdeclarativetester.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qdeclarativetester.h> -#include <QDebug> -#include <QApplication> -#include <qdeclarativeview.h> -#include <QFile> -#include <QDeclarativeComponent> -#include <QDir> -#include <QCryptographicHash> -#include <private/qabstractanimation_p.h> -#include <private/qdeclarativeitem_p.h> - -QT_BEGIN_NAMESPACE - - -QDeclarativeTester::QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions opts, - QDeclarativeView *parent) -: QAbstractAnimation(parent), m_script(script), m_view(parent), filterEvents(true), options(opts), - testscript(0), hasCompleted(false), hasFailed(false) -{ - parent->viewport()->installEventFilter(this); - parent->installEventFilter(this); - QUnifiedTimer::instance()->setConsistentTiming(true); - if (options & QDeclarativeViewer::Play) - this->run(); - start(); -} - -QDeclarativeTester::~QDeclarativeTester() -{ - if (!hasFailed && - options & QDeclarativeViewer::Record && - options & QDeclarativeViewer::SaveOnExit) - save(); -} - -int QDeclarativeTester::duration() const -{ - return -1; -} - -void QDeclarativeTester::addMouseEvent(Destination dest, QMouseEvent *me) -{ - MouseEvent e(me); - e.destination = dest; - m_mouseEvents << e; -} - -void QDeclarativeTester::addKeyEvent(Destination dest, QKeyEvent *ke) -{ - KeyEvent e(ke); - e.destination = dest; - m_keyEvents << e; -} - -bool QDeclarativeTester::eventFilter(QObject *o, QEvent *e) -{ - if (!filterEvents) - return false; - - Destination destination; - if (o == m_view) { - destination = View; - } else if (o == m_view->viewport()) { - destination = ViewPort; - } else { - return false; - } - - switch (e->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: - addKeyEvent(destination, (QKeyEvent *)e); - return true; - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - case QEvent::MouseButtonDblClick: - addMouseEvent(destination, (QMouseEvent *)e); - return true; - default: - break; - } - return false; -} - -void QDeclarativeTester::executefailure() -{ - hasFailed = true; - - if (options & QDeclarativeViewer::ExitOnFailure) - exit(-1); -} - -void QDeclarativeTester::imagefailure() -{ - hasFailed = true; - - if (options & QDeclarativeViewer::ExitOnFailure) - exit(-1); -} - -void QDeclarativeTester::complete() -{ - if ((options & QDeclarativeViewer::TestErrorProperty) && !hasFailed) { - QString e = m_view->rootObject()->property("error").toString(); - if (!e.isEmpty()) { - qWarning() << "Test failed:" << e; - hasFailed = true; - } - } - if (options & QDeclarativeViewer::ExitOnComplete) - QApplication::exit(hasFailed?-1:0); - - if (hasCompleted) - return; - hasCompleted = true; - - if (options & QDeclarativeViewer::Play) - qWarning("Script playback complete"); -} - -void QDeclarativeTester::run() -{ - QDeclarativeComponent c(m_view->engine(), m_script + QLatin1String(".qml")); - - testscript = qobject_cast<QDeclarativeVisualTest *>(c.create()); - if (testscript) testscript->setParent(this); - else { executefailure(); exit(-1); } - testscriptidx = 0; -} - -void QDeclarativeTester::save() -{ - QString filename = m_script + QLatin1String(".qml"); - QFileInfo filenameInfo(filename); - QDir saveDir = filenameInfo.absoluteDir(); - saveDir.mkpath("."); - - QFile file(filename); - file.open(QIODevice::WriteOnly); - QTextStream ts(&file); - - ts << "import Qt.VisualTest 4.7\n\n"; - ts << "VisualTest {\n"; - - int imgCount = 0; - QList<KeyEvent> keyevents = m_savedKeyEvents; - QList<MouseEvent> mouseevents = m_savedMouseEvents; - for (int ii = 0; ii < m_savedFrameEvents.count(); ++ii) { - const FrameEvent &fe = m_savedFrameEvents.at(ii); - ts << " Frame {\n"; - ts << " msec: " << fe.msec << "\n"; - if (!fe.hash.isEmpty()) { - ts << " hash: \"" << fe.hash.toHex() << "\"\n"; - } else if (!fe.image.isNull()) { - QString filename = filenameInfo.baseName() + "." + QString::number(imgCount) + ".png"; - fe.image.save(m_script + "." + QString::number(imgCount) + ".png"); - imgCount++; - ts << " image: \"" << filename << "\"\n"; - } - ts << " }\n"; - - while (!mouseevents.isEmpty() && - mouseevents.first().msec == fe.msec) { - MouseEvent me = mouseevents.takeFirst(); - - ts << " Mouse {\n"; - ts << " type: " << me.type << "\n"; - ts << " button: " << me.button << "\n"; - ts << " buttons: " << me.buttons << "\n"; - ts << " x: " << me.pos.x() << "; y: " << me.pos.y() << "\n"; - ts << " modifiers: " << me.modifiers << "\n"; - if (me.destination == ViewPort) - ts << " sendToViewport: true\n"; - ts << " }\n"; - } - - while (!keyevents.isEmpty() && - keyevents.first().msec == fe.msec) { - KeyEvent ke = keyevents.takeFirst(); - - ts << " Key {\n"; - ts << " type: " << ke.type << "\n"; - ts << " key: " << ke.key << "\n"; - ts << " modifiers: " << ke.modifiers << "\n"; - ts << " text: \"" << ke.text.toUtf8().toHex() << "\"\n"; - ts << " autorep: " << (ke.autorep?"true":"false") << "\n"; - ts << " count: " << ke.count << "\n"; - if (ke.destination == ViewPort) - ts << " sendToViewport: true\n"; - ts << " }\n"; - } - } - - ts << "}\n"; - file.close(); -} - -void QDeclarativeTester::updateCurrentTime(int msec) -{ - QDeclarativeItemPrivate::setConsistentTime(msec); - if (!testscript && msec > 16 && options & QDeclarativeViewer::Snapshot) - return; - - QImage img(m_view->width(), m_view->height(), QImage::Format_RGB32); - - if (options & QDeclarativeViewer::TestImages) { - img.fill(qRgb(255,255,255)); - QPainter p(&img); - m_view->render(&p); - } - - bool snapshot = msec == 16 && (options & QDeclarativeViewer::Snapshot - || (testscript && testscript->count() == 2)); - - FrameEvent fe; - 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) { - fe.image = img; - } else { - QCryptographicHash hash(QCryptographicHash::Md5); - hash.addData((const char *)img.bits(), img.bytesPerLine() * img.height()); - fe.hash = hash.result(); - } - m_savedFrameEvents.append(fe); - - // Deliver mouse events - filterEvents = false; - - if (!testscript) { - for (int ii = 0; ii < m_mouseEvents.count(); ++ii) { - MouseEvent &me = m_mouseEvents[ii]; - me.msec = msec; - QMouseEvent event(me.type, me.pos, me.button, me.buttons, me.modifiers); - - if (me.destination == View) { - QCoreApplication::sendEvent(m_view, &event); - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - } - } - - for (int ii = 0; ii < m_keyEvents.count(); ++ii) { - KeyEvent &ke = m_keyEvents[ii]; - ke.msec = msec; - QKeyEvent event(ke.type, ke.key, ke.modifiers, ke.text, ke.autorep, ke.count); - - if (ke.destination == View) { - QCoreApplication::sendEvent(m_view, &event); - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - } - } - m_savedMouseEvents.append(m_mouseEvents); - m_savedKeyEvents.append(m_keyEvents); - } - - m_mouseEvents.clear(); - m_keyEvents.clear(); - - // Advance test script - while (testscript && testscript->count() > testscriptidx) { - - QObject *event = testscript->event(testscriptidx); - - if (QDeclarativeVisualTestFrame *frame = qobject_cast<QDeclarativeVisualTestFrame *>(event)) { - if (frame->msec() < msec) { - if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record)) { - qWarning() << "QDeclarativeTester: 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 - << ". Seen:" << fe.hash.toHex() - << "Expected:" << frame->hash().toUtf8(); - imagefailure(); - } - } - } else if (frame->msec() > msec) { - break; - } - - if (options & QDeclarativeViewer::TestImages && !(options & QDeclarativeViewer::Record) && !frame->image().isEmpty()) { - QImage goodImage(frame->image().toLocalFile()); - if (goodImage != img) { - QString reject(frame->image().toLocalFile() + ".reject.png"); - qWarning() << "QDeclarativeTester: Image mismatch. Reject saved to:" - << reject; - img.save(reject); - bool doDiff = (goodImage.size() == img.size()); - if (doDiff) { - QImage diffimg(m_view->width(), m_view->height(), QImage::Format_RGB32); - diffimg.fill(qRgb(255,255,255)); - QPainter p(&diffimg); - int diffCount = 0; - for (int x = 0; x < img.width(); ++x) { - for (int y = 0; y < img.height(); ++y) { - if (goodImage.pixel(x,y) != img.pixel(x,y)) { - ++diffCount; - p.drawPoint(x,y); - } - } - } - QString diff(frame->image().toLocalFile() + ".diff.png"); - diffimg.save(diff); - qWarning().nospace() << " Diff (" << diffCount << " pixels differed) saved to: " << diff; - } - imagefailure(); - } - } - } else if (QDeclarativeVisualTestMouse *mouse = qobject_cast<QDeclarativeVisualTestMouse *>(event)) { - QPoint pos(mouse->x(), mouse->y()); - QPoint globalPos = m_view->mapToGlobal(QPoint(0, 0)) + pos; - QMouseEvent event((QEvent::Type)mouse->type(), pos, globalPos, (Qt::MouseButton)mouse->button(), (Qt::MouseButtons)mouse->buttons(), (Qt::KeyboardModifiers)mouse->modifiers()); - - MouseEvent me(&event); - me.msec = msec; - if (!mouse->sendToViewport()) { - QCoreApplication::sendEvent(m_view, &event); - me.destination = View; - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - me.destination = ViewPort; - } - m_savedMouseEvents.append(me); - } else if (QDeclarativeVisualTestKey *key = qobject_cast<QDeclarativeVisualTestKey *>(event)) { - - QKeyEvent event((QEvent::Type)key->type(), key->key(), (Qt::KeyboardModifiers)key->modifiers(), QString::fromUtf8(QByteArray::fromHex(key->text().toUtf8())), key->autorep(), key->count()); - - KeyEvent ke(&event); - ke.msec = msec; - if (!key->sendToViewport()) { - QCoreApplication::sendEvent(m_view, &event); - ke.destination = View; - } else { - QCoreApplication::sendEvent(m_view->viewport(), &event); - ke.destination = ViewPort; - } - m_savedKeyEvents.append(ke); - } - testscriptidx++; - } - - filterEvents = true; - - if (testscript && testscript->count() <= testscriptidx) { - //if (msec == 16) //for a snapshot, leave it up long enough to see - // (void)::sleep(1); - complete(); - } -} - -void QDeclarativeTester::registerTypes() -{ - qmlRegisterType<QDeclarativeVisualTest>("Qt.VisualTest", 4,7, "VisualTest"); - qmlRegisterType<QDeclarativeVisualTestFrame>("Qt.VisualTest", 4,7, "Frame"); - qmlRegisterType<QDeclarativeVisualTestMouse>("Qt.VisualTest", 4,7, "Mouse"); - qmlRegisterType<QDeclarativeVisualTestKey>("Qt.VisualTest", 4,7, "Key"); -} - -QT_END_NAMESPACE diff --git a/src/tools/qml/qmlobserver/qdeclarativetester.h b/src/tools/qml/qmlobserver/qdeclarativetester.h deleted file mode 100644 index 021869d93a3..00000000000 --- a/src/tools/qml/qmlobserver/qdeclarativetester.h +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETESTER_H -#define QDECLARATIVETESTER_H - -#include <QEvent> -#include <QMouseEvent> -#include <QKeyEvent> -#include <QImage> -#include <QUrl> -#include <qmlruntime.h> -#include <qdeclarativelist.h> -#include <qdeclarative.h> -#include <QAbstractAnimation> - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTest : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty<QObject> events READ events CONSTANT) - Q_CLASSINFO("DefaultProperty", "events") -public: - QDeclarativeVisualTest() {} - - QDeclarativeListProperty<QObject> events() { return QDeclarativeListProperty<QObject>(this, m_events); } - - int count() const { return m_events.count(); } - QObject *event(int idx) { return m_events.at(idx); } - -private: - QList<QObject *> m_events; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTest) - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTestFrame : public QObject -{ - Q_OBJECT - Q_PROPERTY(int msec READ msec WRITE setMsec) - Q_PROPERTY(QString hash READ hash WRITE setHash) - Q_PROPERTY(QUrl image READ image WRITE setImage) -public: - QDeclarativeVisualTestFrame() : m_msec(-1) {} - - int msec() const { return m_msec; } - void setMsec(int m) { m_msec = m; } - - QString hash() const { return m_hash; } - void setHash(const QString &hash) { m_hash = hash; } - - QUrl image() const { return m_image; } - void setImage(const QUrl &image) { m_image = image; } - -private: - int m_msec; - QString m_hash; - QUrl m_image; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTestFrame) - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTestMouse : public QObject -{ - Q_OBJECT - Q_PROPERTY(int type READ type WRITE setType) - Q_PROPERTY(int button READ button WRITE setButton) - Q_PROPERTY(int buttons READ buttons WRITE setButtons) - Q_PROPERTY(int x READ x WRITE setX) - Q_PROPERTY(int y READ y WRITE setY) - Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers) - Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport) -public: - QDeclarativeVisualTestMouse() : m_type(0), m_button(0), m_buttons(0), m_x(0), m_y(0), m_modifiers(0), m_viewport(false) {} - - 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; } - - int buttons() const { return m_buttons; } - void setButtons(int b) { m_buttons = b; } - - int x() const { return m_x; } - void setX(int x) { m_x = x; } - - int y() const { return m_y; } - void setY(int y) { m_y = y; } - - int modifiers() const { return m_modifiers; } - void setModifiers(int modifiers) { m_modifiers = modifiers; } - - bool sendToViewport() const { return m_viewport; } - void setSendToViewport(bool v) { m_viewport = v; } -private: - int m_type; - int m_button; - int m_buttons; - int m_x; - int m_y; - int m_modifiers; - bool m_viewport; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTestMouse) - -QT_BEGIN_NAMESPACE - -class QDeclarativeVisualTestKey : public QObject -{ - Q_OBJECT - Q_PROPERTY(int type READ type WRITE setType) - Q_PROPERTY(int key READ key WRITE setKey) - Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers) - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(bool autorep READ autorep WRITE setAutorep) - Q_PROPERTY(int count READ count WRITE setCount) - Q_PROPERTY(bool sendToViewport READ sendToViewport WRITE setSendToViewport) -public: - QDeclarativeVisualTestKey() : m_type(0), m_key(0), m_modifiers(0), m_autorep(false), m_count(0), m_viewport(false) {} - - int type() const { return m_type; } - void setType(int t) { m_type = t; } - - int key() const { return m_key; } - void setKey(int k) { m_key = k; } - - int modifiers() const { return m_modifiers; } - void setModifiers(int m) { m_modifiers = m; } - - QString text() const { return m_text; } - void setText(const QString &t) { m_text = t; } - - bool autorep() const { return m_autorep; } - void setAutorep(bool a) { m_autorep = a; } - - int count() const { return m_count; } - void setCount(int c) { m_count = c; } - - bool sendToViewport() const { return m_viewport; } - void setSendToViewport(bool v) { m_viewport = v; } -private: - int m_type; - int m_key; - int m_modifiers; - QString m_text; - bool m_autorep; - int m_count; - bool m_viewport; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeVisualTestKey) - -QT_BEGIN_NAMESPACE - -class QDeclarativeTester : public QAbstractAnimation -{ -public: - QDeclarativeTester(const QString &script, QDeclarativeViewer::ScriptOptions options, QDeclarativeView *parent); - ~QDeclarativeTester(); - - static void registerTypes(); - - virtual int duration() const; - - void run(); - void save(); - - void executefailure(); -protected: - virtual void updateCurrentTime(int msecs); - virtual bool eventFilter(QObject *, QEvent *); - -private: - QString m_script; - - void imagefailure(); - void complete(); - - enum Destination { View, ViewPort }; - void addKeyEvent(Destination, QKeyEvent *); - void addMouseEvent(Destination, QMouseEvent *); - QDeclarativeView *m_view; - - struct MouseEvent { - MouseEvent(QMouseEvent *e) - : type(e->type()), button(e->button()), buttons(e->buttons()), - pos(e->pos()), modifiers(e->modifiers()), destination(View) {} - - QEvent::Type type; - Qt::MouseButton button; - Qt::MouseButtons buttons; - QPoint pos; - Qt::KeyboardModifiers modifiers; - Destination destination; - - int msec; - }; - struct KeyEvent { - KeyEvent(QKeyEvent *e) - : type(e->type()), key(e->key()), modifiers(e->modifiers()), text(e->text()), - autorep(e->isAutoRepeat()), count(e->count()), destination(View) {} - QEvent::Type type; - int key; - Qt::KeyboardModifiers modifiers; - QString text; - bool autorep; - ushort count; - Destination destination; - - int msec; - }; - struct FrameEvent { - QImage image; - QByteArray hash; - int msec; - }; - QList<MouseEvent> m_mouseEvents; - QList<KeyEvent> m_keyEvents; - - QList<MouseEvent> m_savedMouseEvents; - QList<KeyEvent> m_savedKeyEvents; - QList<FrameEvent> m_savedFrameEvents; - bool filterEvents; - - QDeclarativeViewer::ScriptOptions options; - int testscriptidx; - QDeclarativeVisualTest *testscript; - - bool hasCompleted; - bool hasFailed; -}; - - -QT_END_NAMESPACE - -#endif // QDECLARATIVETESTER_H diff --git a/src/tools/qml/qmlobserver/qml.icns b/src/tools/qml/qmlobserver/qml.icns Binary files differdeleted file mode 100644 index c76051626a1..00000000000 --- a/src/tools/qml/qmlobserver/qml.icns +++ /dev/null diff --git a/src/tools/qml/qmlobserver/qml.pri b/src/tools/qml/qmlobserver/qml.pri deleted file mode 100644 index 7d9a503fb69..00000000000 --- a/src/tools/qml/qmlobserver/qml.pri +++ /dev/null @@ -1,36 +0,0 @@ -QT += declarative script network sql - -contains(QT_CONFIG, opengl) { - QT += opengl - DEFINES += GL_SUPPORTED -} - -INCLUDEPATH += $$PWD - -HEADERS += $$PWD/qmlruntime.h \ - $$PWD/proxysettings.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 - -OTHER_FILES += toolbarstyle.css - -maemo5 { - QT += dbus - HEADERS += $$PWD/texteditautoresizer_maemo5.h - SOURCES += $$PWD/deviceorientation_maemo5.cpp - FORMS += $$PWD/recopts_maemo5.ui \ - $$PWD/proxysettings_maemo5.ui -} else { - SOURCES += $$PWD/deviceorientation.cpp - FORMS += $$PWD/recopts.ui \ - $$PWD/proxysettings.ui -} diff --git a/src/tools/qml/qmlobserver/qmlobserver.pro b/src/tools/qml/qmlobserver/qmlobserver.pro deleted file mode 100644 index 765a1f839fc..00000000000 --- a/src/tools/qml/qmlobserver/qmlobserver.pro +++ /dev/null @@ -1,30 +0,0 @@ -TEMPLATE = app -QT += declarative - -include(qml.pri) - -SOURCES += main.cpp -include(../../../../qtcreator.pri) - -include(../../../../share/qtcreator/qmljsdebugger/qmljsdebugger.pri) -include(../../../libs/utils/utils.pri) -mac { - qmljsLibraryTarget = $$qtLibraryName(QmlJSDebugger) - utilsLibraryTarget = $$qtLibraryName(Utils) -} - - -include(../../../private_headers.pri) -DESTDIR = $$IDE_BIN_PATH -include(../../../rpath.pri) - -mac { - QMAKE_INFO_PLIST=Info_mac.plist - TARGET=QMLObserver - ICON=qml.icns - QMAKE_POST_LINK=install_name_tool -change @executable_path/../PlugIns/lib$${qmljsLibraryTarget}.1.dylib @executable_path/../../../../PlugIns/lib$${qmljsLibraryTarget}.1.dylib \'$$DESTDIR/$${TARGET}.app/Contents/MacOS/$$TARGET\' \ - && install_name_tool -change @executable_path/../PlugIns/lib$${utilsLibraryTarget}.1.dylib @executable_path/../../../../PlugIns/lib$${utilsLibraryTarget}.1.dylib \'$$DESTDIR/$${TARGET}.app/Contents/MacOS/$$TARGET\' -} else { - TARGET=qmlobserver -} - diff --git a/src/tools/qml/qmlobserver/qmlruntime.cpp b/src/tools/qml/qmlobserver/qmlruntime.cpp deleted file mode 100644 index 0fbacbe3648..00000000000 --- a/src/tools/qml/qmlobserver/qmlruntime.cpp +++ /dev/null @@ -1,1581 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qdeclarativeview.h> - -#ifdef hz -#undef hz -#endif -#ifdef Q_WS_MAEMO_5 -# include <QMaemo5ValueButton> -# include <QMaemo5ListPickSelector> -# include <QWidgetAction> -# include <QStringListModel> -# include "ui_recopts_maemo5.h" -#else -# include "ui_recopts.h" -#endif - -#include <qdeclarativeviewobserver.h> -#include <qdeclarativeobserverservice.h> -#include <utils/crumblepath.h> - -#include "qmlruntime.h" -#include <qdeclarativecontext.h> -#include <qdeclarativeengine.h> -#include <qdeclarativenetworkaccessmanagerfactory.h> -#include "qdeclarative.h" -#include <QAbstractAnimation> -#include <private/qabstractanimation_p.h> - -#include <QSettings> -#include <QXmlStreamReader> -#include <QBuffer> -#include <QNetworkReply> -#include <QNetworkCookieJar> -#include <QNetworkDiskCache> -#include <QNetworkAccessManager> -#include <QSignalMapper> -#include <QDeclarativeComponent> -#include <QWidget> -#include <QApplication> -#include <QTranslator> -#include <QDir> -#include <QTextBrowser> -#include <QFile> -#include <QFileInfo> -#include <QVBoxLayout> -#include <QProgressDialog> -#include <QProcess> -#include <QMenuBar> -#include <QMenu> -#include <QAction> -#include <QFileDialog> -#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 <qdeclarativetester.h> -#include "jsdebuggeragent.h" - -QT_BEGIN_NAMESPACE - -class Runtime : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool isActiveWindow READ isActiveWindow NOTIFY isActiveWindowChanged) - Q_PROPERTY(DeviceOrientation::Orientation orientation READ orientation NOTIFY orientationChanged) - -public: - static Runtime* instance() - { - static Runtime *instance = 0; - if (!instance) - instance = new Runtime; - return instance; - } - - bool isActiveWindow() const { return activeWindow; } - void setActiveWindow(bool active) - { - if (active == activeWindow) - return; - activeWindow = active; - emit isActiveWindowChanged(); - } - - DeviceOrientation::Orientation orientation() const { return DeviceOrientation::instance()->orientation(); } - -Q_SIGNALS: - void isActiveWindowChanged(); - void orientationChanged(); - -private: - Runtime(QObject *parent=0) : QObject(parent), activeWindow(false) - { - connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), - this, SIGNAL(orientationChanged())); - } - - bool activeWindow; -}; - - - -#if defined(Q_WS_MAEMO_5) - -class Maemo5PickerAction : public QWidgetAction { - Q_OBJECT -public: - Maemo5PickerAction(const QString &text, QActionGroup *actions, QObject *parent) - : QWidgetAction(parent), m_text(text), m_actions(actions) - { } - - QWidget *createWidget(QWidget *parent) - { - 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++; - } - 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(); - - if (m_actions && idx >= 0 && idx < m_actions->actions().count()) - m_actions->actions().at(idx)->trigger(); - } - -private: - QString m_text; - QPointer<QActionGroup> m_actions; -}; - -#endif // Q_WS_MAEMO_5 - -static struct { const char *name, *args; } ffmpegprofiles[] = { - {"Maximum Quality", "-sameq"}, - {"High Quality", "-qmax 2"}, - {"Medium Quality", "-qmax 6"}, - {"Low Quality", "-qmax 16"}, - {"Custom ffmpeg arguments", ""}, - {0,0} -}; - -class RecordingDialog : public QDialog, public Ui::RecordingOptions { - Q_OBJECT - -public: - RecordingDialog(QWidget *parent) : QDialog(parent) - { - setupUi(this); -#ifndef Q_WS_MAEMO_5 - hz->setValidator(new QDoubleValidator(hz)); -#endif - for (int i=0; ffmpegprofiles[i].name; ++i) { - profile->addItem(ffmpegprofiles[i].name); - } - } - - void setArguments(QString a) - { - int i; - for (i=0; ffmpegprofiles[i].args[0]; ++i) { - if (ffmpegprofiles[i].args == a) { - profile->setCurrentIndex(i); - args->setText(QLatin1String(ffmpegprofiles[i].args)); - return; - } - } - customargs = a; - args->setText(a); - profile->setCurrentIndex(i); - } - - QString arguments() const - { - int i = profile->currentIndex(); - return ffmpegprofiles[i].args[0] ? QLatin1String(ffmpegprofiles[i].args) : customargs; - } - - void setOriginalSize(const QSize &s) - { - QString str = tr("Original (%1x%2)").arg(s.width()).arg(s.height()); - -#ifdef Q_WS_MAEMO_5 - sizeCombo->setItemText(0, str); -#else - sizeOriginal->setText(str); - if (sizeWidth->value()<=1) { - sizeWidth->setValue(s.width()); - sizeHeight->setValue(s.height()); - } -#endif - } - - void showffmpegOptions(bool b) - { -#ifdef Q_WS_MAEMO_5 - profileLabel->setVisible(b); - profile->setVisible(b); - ffmpegHelp->setVisible(b); - args->setVisible(b); -#else - ffmpegOptions->setVisible(b); -#endif - } - - void showRateOptions(bool b) - { -#ifdef Q_WS_MAEMO_5 - rateLabel->setVisible(b); - rateCombo->setVisible(b); -#else - rateOptions->setVisible(b); -#endif - } - - void setVideoRate(int rate) - { -#ifdef Q_WS_MAEMO_5 - int idx; - if (rate >= 60) - idx = 0; - else if (rate >= 50) - idx = 2; - else if (rate >= 25) - idx = 3; - else if (rate >= 24) - idx = 4; - else if (rate >= 20) - idx = 5; - else if (rate >= 15) - idx = 6; - else - idx = 7; - rateCombo->setCurrentIndex(idx); -#else - if (rate == 24) - hz24->setChecked(true); - else if (rate == 25) - hz25->setChecked(true); - else if (rate == 50) - hz50->setChecked(true); - else if (rate == 60) - hz60->setChecked(true); - else { - hzCustom->setChecked(true); - hz->setText(QString::number(rate)); - } -#endif - } - - int videoRate() const - { -#ifdef Q_WS_MAEMO_5 - switch (rateCombo->currentIndex()) { - case 0: return 60; - case 1: return 50; - case 2: return 25; - case 3: return 24; - case 4: return 20; - case 5: return 15; - case 7: return 10; - default: return 60; - } -#else - if (hz24->isChecked()) - return 24; - else if (hz25->isChecked()) - return 25; - else if (hz50->isChecked()) - return 50; - else if (hz60->isChecked()) - return 60; - else { - return hz->text().toInt(); - } -#endif - } - - QSize videoSize() const - { -#ifdef Q_WS_MAEMO_5 - switch (sizeCombo->currentIndex()) { - case 0: return QSize(); - case 1: return QSize(640,480); - case 2: return QSize(320,240); - case 3: return QSize(1280,720); - default: return QSize(); - } -#else - if (sizeOriginal->isChecked()) - return QSize(); - else if (size720p->isChecked()) - return QSize(1280,720); - else if (sizeVGA->isChecked()) - return QSize(640,480); - else if (sizeQVGA->isChecked()) - return QSize(320,240); - else - return QSize(sizeWidth->value(), sizeHeight->value()); -#endif - } - - - -private slots: - void pickProfile(int i) - { - if (ffmpegprofiles[i].args[0]) { - args->setText(QLatin1String(ffmpegprofiles[i].args)); - } else { - args->setText(customargs); - } - } - - void storeCustomArgs(QString s) - { - setArguments(s); - } - -private: - QString customargs; -}; - -class PersistentCookieJar : public QNetworkCookieJar { -public: - PersistentCookieJar(QObject *parent) : QNetworkCookieJar(parent) { load(); } - ~PersistentCookieJar() { save(); } - - virtual QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const - { - QMutexLocker lock(&mutex); - return QNetworkCookieJar::cookiesForUrl(url); - } - - virtual bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url) - { - QMutexLocker lock(&mutex); - return QNetworkCookieJar::setCookiesFromUrl(cookieList, url); - } - -private: - void save() - { - QMutexLocker lock(&mutex); - QList<QNetworkCookie> list = allCookies(); - QByteArray data; - foreach (QNetworkCookie cookie, list) { - if (!cookie.isSessionCookie()) { - data.append(cookie.toRawForm()); - data.append("\n"); - } - } - QSettings settings; - settings.setValue("Cookies",data); - } - - void load() - { - QMutexLocker lock(&mutex); - QSettings settings; - QByteArray data = settings.value("Cookies").toByteArray(); - setAllCookies(QNetworkCookie::parseCookies(data)); - } - - mutable QMutex mutex; -}; - -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -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; - } - } - - static PersistentCookieJar *cookieJar; - QMutex mutex; - int cacheSize; -}; - -PersistentCookieJar *NetworkAccessManagerFactory::cookieJar = 0; - -static void cleanup_cookieJar() -{ - delete NetworkAccessManagerFactory::cookieJar; - NetworkAccessManagerFactory::cookieJar = 0; -} - -QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) -{ - QMutexLocker lock(&mutex); - QNetworkAccessManager *manager = new QNetworkAccessManager(parent); - if (!cookieJar) { - qAddPostRoutine(cleanup_cookieJar); - cookieJar = new PersistentCookieJar(0); - } - manager->setCookieJar(cookieJar); - cookieJar->setParent(0); - setupProxy(manager); - if (cacheSize > 0) { - QNetworkDiskCache *cache = new QNetworkDiskCache; - cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-viewer-network-cache")); - cache->setMaximumCacheSize(cacheSize); - manager->setCache(cache); - } else { - manager->setCache(0); - } - qDebug() << "created new network access manager for" << parent; - return manager; -} - -// -// Event filter that ensures the crumble path width is always the canvas width -// -class CrumblePathResizer : public QObject -{ - Q_OBJECT -public: - CrumblePathResizer(Utils::CrumblePath *crumblePathWidget, QObject *parent = 0) : - QObject(parent), - m_crumblePathWidget(crumblePathWidget) - { - } - - bool eventFilter(QObject *obj, QEvent *event) - { - if (event->type() == QEvent::Resize) { - QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event); - m_crumblePathWidget->resize(resizeEvent->size().width(), m_crumblePathWidget->height()); - } - return QObject::eventFilter(obj, event); - } - -private: - QWidget *m_crumblePathWidget; -}; - -QString QDeclarativeViewer::getVideoFileName() -{ - QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames"); - QStringList types; - if (ffmpegAvailable) types += tr("Common Video files")+QLatin1String(" (*.avi *.mpeg *.mov)"); - if (convertAvailable) types += tr("GIF Animation")+QLatin1String(" (*.gif)"); - types += tr("Individual PNG frames")+QLatin1String(" (*.png)"); - if (ffmpegAvailable) types += tr("All ffmpeg formats (*.*)"); - return QFileDialog::getSaveFileName(this, title, "", types.join(";; ")); -} - -QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) - : QMainWindow(parent, flags) - , loggerWindow(new LoggerWidget(this)) - , frame_stream(0) - , orientation(0) - , showWarningsWindow(0) - , designModeBehaviorAction(0) - , m_scriptOptions(0) - , tester(0) - , useQmlFileBrowser(true) - , m_centralWidget(0) - , m_crumblePathWidget(0) - , translator(0) -{ - QDeclarativeViewer::registerTypes(); - setWindowTitle(tr("Qt QML Viewer")); -#ifdef Q_WS_MAEMO_5 - setAttribute(Qt::WA_Maemo5StackedWindow); -// setPalette(QApplication::palette("QLabel")); -#endif - - devicemode = false; - canvas = 0; - record_autotime = 0; - record_rate = 50; - record_args += QLatin1String("-sameq"); - - recdlg = new RecordingDialog(this); - connect(recdlg->pickfile, SIGNAL(clicked()), this, SLOT(pickRecordingFile())); - senseFfmpeg(); - senseImageMagick(); - if (!ffmpegAvailable) - recdlg->showffmpegOptions(false); - if (!ffmpegAvailable && !convertAvailable) - recdlg->showRateOptions(false); - QString warn; - if (!ffmpegAvailable) { - if (!convertAvailable) - warn = tr("ffmpeg and ImageMagick not available - no video output"); - else - warn = tr("ffmpeg not available - GIF and PNG outputs only"); - recdlg->warning->setText(warn); - } else { - recdlg->warning->hide(); - } - - canvas = new QDeclarativeView(this); - observer = new QmlJSDebugger::QDeclarativeViewObserver(canvas, this); - if (!(flags & Qt::FramelessWindowHint)) { - m_crumblePathWidget = new Utils::CrumblePath(canvas); -#ifndef Q_WS_MAC - m_crumblePathWidget->setStyleSheet("QWidget { border-bottom: 1px solid black; }"); -#endif - m_crumblePathWidget->setVisible(observer->designModeBehavior()); - - // CrumblePath is not in a layout, so that it overlays the central widget - // The event filter ensures that its width stays in sync nevertheless - CrumblePathResizer *resizer = new CrumblePathResizer(m_crumblePathWidget, m_crumblePathWidget); - canvas->installEventFilter(resizer); - } - - 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())); - if (m_crumblePathWidget) { - QObject::connect(observer, SIGNAL(inspectorContextCleared()), m_crumblePathWidget, SLOT(clear())); - QObject::connect(observer, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString))); - QObject::connect(observer, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement())); - QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), observer, SLOT(setObserverContext(int))); - QObject::connect(observer, SIGNAL(designModeBehaviorChanged(bool)), m_crumblePathWidget, SLOT(setVisible(bool))); - } - QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); - - QObject::connect(warningsWidget(), SIGNAL(opened()), this, SLOT(warningsWidgetOpened())); - QObject::connect(warningsWidget(), SIGNAL(closed()), this, SLOT(warningsWidgetClosed())); - - if (!(flags & Qt::FramelessWindowHint)) { - createMenu(); - changeOrientation(orientation->actions().value(0)); - } else { - setMenuBar(0); - } - - setCentralWidget(m_centralWidget); - - namFactory = new NetworkAccessManagerFactory; - canvas->engine()->setNetworkAccessManagerFactory(namFactory); - - connect(&autoStartTimer, SIGNAL(timeout()), this, SLOT(autoStartRecording())); - connect(&autoStopTimer, SIGNAL(timeout()), this, SLOT(autoStopRecording())); - connect(&recordTimer, SIGNAL(timeout()), this, SLOT(recordFrame())); - connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), - this, SLOT(orientationChanged()), Qt::QueuedConnection); - autoStartTimer.setSingleShot(true); - autoStopTimer.setSingleShot(true); - recordTimer.setSingleShot(false); - - QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(appAboutToQuit())); -} - -QDeclarativeViewer::~QDeclarativeViewer() -{ - delete loggerWindow; - canvas->engine()->setNetworkAccessManagerFactory(0); - delete namFactory; -} - -void QDeclarativeViewer::setDesignModeBehavior(bool value) -{ - if (designModeBehaviorAction) - designModeBehaviorAction->setChecked(value); - observer->setDesignModeBehavior(value); -} - -void QDeclarativeViewer::setDebugMode(bool on) -{ - observer->setDebugMode(on); -} - -void QDeclarativeViewer::enableExperimentalGestures() -{ - 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); -} - -QDeclarativeView *QDeclarativeViewer::view() const -{ - return canvas; -} - -LoggerWidget *QDeclarativeViewer::warningsWidget() const -{ - return loggerWindow; -} - -void QDeclarativeViewer::createMenu() -{ - QAction *openAction = new QAction(tr("&Open..."), this); - openAction->setShortcut(QKeySequence("Ctrl+O")); - connect(openAction, SIGNAL(triggered()), this, SLOT(openFile())); - - QAction *reloadAction = new QAction(tr("&Reload"), this); - reloadAction->setShortcut(QKeySequence("Ctrl+R")); - connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload())); - - QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this); - snapshotAction->setShortcut(QKeySequence("F3")); - connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot())); - - recordAction = new QAction(tr("Start Recording &Video"), this); - recordAction->setShortcut(QKeySequence("F9")); - connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection())); - - QAction *recordOptions = new QAction(tr("Video &Options..."), this); - connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions())); - - QMenu *playSpeedMenu = new QMenu(tr("Animation Speed"), this); - QActionGroup *playSpeedMenuActions = new QActionGroup(this); - playSpeedMenuActions->setExclusive(true); - - QAction *speedAction = playSpeedMenu->addAction(tr("1x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setChecked(true); - animationSpeed = 1.0f; - speedAction->setData(1.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.5x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(2.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.25x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(4.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.125x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(8.0f); - playSpeedMenuActions->addAction(speedAction); - - speedAction = playSpeedMenu->addAction(tr("0.1x"), this, SLOT(changeAnimationSpeed())); - speedAction->setCheckable(true); - speedAction->setData(10.0f); - playSpeedMenuActions->addAction(speedAction); - - pauseAnimationsAction = playSpeedMenu->addAction(tr("Pause"), this, SLOT(setAnimationsPaused(bool))); - pauseAnimationsAction->setCheckable(true); - pauseAnimationsAction->setShortcut(QKeySequence("Ctrl+.")); - - animationStepAction = playSpeedMenu->addAction(tr("Pause and step"), this, SLOT(stepAnimations())); - animationStepAction->setShortcut(QKeySequence("Ctrl+,")); - - animationSetStepAction = playSpeedMenu->addAction(tr("Set step"), this, SLOT(setAnimationStep())); - m_stepSize = 40; - - QAction *playSpeedAction = new QAction(tr("Animations"), this); - playSpeedAction->setMenu(playSpeedMenu); - - showWarningsWindow = new QAction(tr("Show Warnings"), this); - showWarningsWindow->setCheckable((true)); - showWarningsWindow->setChecked(loggerWindow->isVisible()); - connect(showWarningsWindow, SIGNAL(triggered(bool)), this, SLOT(showWarnings(bool))); - - designModeBehaviorAction = new QAction(tr("&Observer Mode"), this); - designModeBehaviorAction->setShortcut(QKeySequence("Ctrl+D")); - designModeBehaviorAction->setCheckable(true); - designModeBehaviorAction->setChecked(observer->designModeBehavior()); - 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))); - - QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this); - connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings())); - - QAction *fullscreenAction = new QAction(tr("Full Screen"), this); - 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())); - - orientation = new QActionGroup(this); - orientation->setExclusive(true); - connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*))); - - QAction *portraitAction = new QAction(tr("Portrait"), this); - portraitAction->setCheckable(true); - QAction *landscapeAction = new QAction(tr("Landscape"), this); - landscapeAction->setCheckable(true); - QAction *portraitInvAction = new QAction(tr("Portrait (inverted)"), this); - portraitInvAction->setCheckable(true); - QAction *landscapeInvAction = new QAction(tr("Landscape (inverted)"), this); - landscapeInvAction->setCheckable(true); - - QAction *aboutAction = new QAction(tr("&About Qt..."), this); - connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - - QAction *quitAction = new QAction(tr("&Quit"), this); - quitAction->setShortcut(QKeySequence("Ctrl+Q")); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - QMenuBar *menu = menuBar(); - if (!menu) - return; - -#if defined(Q_WS_MAEMO_5) - menu->addAction(openAction); - menu->addAction(reloadAction); - - menu->addAction(snapshotAction); - menu->addAction(recordAction); - - menu->addAction(recordOptions); - menu->addAction(proxyAction); - - menu->addAction(playSpeedMenu); - menu->addAction(showWarningsWindow); - - orientation->addAction(landscapeAction); - orientation->addAction(portraitAction); - menu->addAction(new Maemo5PickerAction(tr("Set orientation"), orientation, this)); - menu->addAction(fullscreenAction); - return; -#endif // Q_WS_MAEMO_5 - - QMenu *fileMenu = menu->addMenu(tr("&File")); - fileMenu->addAction(openAction); - fileMenu->addAction(reloadAction); - fileMenu->addSeparator(); - 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->addAction(showWarningsWindow); - debugMenu->addAction(designModeBehaviorAction); -#endif // ! Q_OS_SYMBIAN - - QMenu *settingsMenu = menu->addMenu(tr("S&ettings")); - settingsMenu->addAction(proxyAction); -#if !defined(Q_OS_SYMBIAN) - settingsMenu->addAction(recordOptions); - settingsMenu->addMenu(loggerWindow->preferencesMenu()); -#else // ! Q_OS_SYMBIAN - settingsMenu->addAction(fullscreenAction); -#endif // Q_OS_SYMBIAN - settingsMenu->addAction(rotateOrientation); - - QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties")); - - orientation->addAction(portraitAction); - orientation->addAction(landscapeAction); - orientation->addAction(portraitInvAction); - orientation->addAction(landscapeInvAction); - propertiesMenu->addActions(orientation->actions()); - - QMenu *helpMenu = menu->addMenu(tr("&Help")); - helpMenu->addAction(aboutAction); -} - -void QDeclarativeViewer::showProxySettings() -{ - ProxySettings settingsDlg (this); - - connect (&settingsDlg, SIGNAL (accepted()), this, SLOT (proxySettingsChanged ())); - - settingsDlg.exec(); -} - -void QDeclarativeViewer::proxySettingsChanged() -{ - reload (); -} - -void QDeclarativeViewer::rotateOrientation() -{ - QAction *current = orientation->checkedAction(); - QList<QAction *> actions = orientation->actions(); - int index = actions.indexOf(current); - if (index < 0) - return; - - QAction *newOrientation = actions[(index + 1) % actions.count()]; - changeOrientation(newOrientation); -} - -void QDeclarativeViewer::toggleFullScreen() -{ - if (isFullScreen()) - showMaximized(); - else - showFullScreen(); -} - -void QDeclarativeViewer::showWarnings(bool show) -{ - loggerWindow->setVisible(show); -} - -void QDeclarativeViewer::warningsWidgetOpened() -{ - showWarningsWindow->setChecked(true); -} - -void QDeclarativeViewer::warningsWidgetClosed() -{ - showWarningsWindow->setChecked(false); -} - -void QDeclarativeViewer::takeSnapShot() -{ - static int snapshotcount = 1; - QString snapFileName = QString(QLatin1String("snapshot%1.png")).arg(snapshotcount); - QPixmap::grabWidget(canvas).save(snapFileName); - qDebug() << "Wrote" << snapFileName; - ++snapshotcount; -} - -void QDeclarativeViewer::pickRecordingFile() -{ - QString fileName = getVideoFileName(); - if (!fileName.isEmpty()) - recdlg->file->setText(fileName); -} - -void QDeclarativeViewer::chooseRecordingOptions() -{ - // File - recdlg->file->setText(record_file); - - // Size - recdlg->setOriginalSize(canvas->size()); - - // Rate - recdlg->setVideoRate(record_rate); - - - // Profile - recdlg->setArguments(record_args.join(" ")); - if (recdlg->exec()) { - // File - record_file = recdlg->file->text(); - // Size - record_outsize = recdlg->videoSize(); - // Rate - record_rate = recdlg->videoRate(); - // Profile - record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts); - } -} - -void QDeclarativeViewer::toggleRecordingWithSelection() -{ - if (!recordTimer.isActive()) { - if (record_file.isEmpty()) { - QString fileName = getVideoFileName(); - if (fileName.isEmpty()) - return; - if (!fileName.contains(QRegExp(".[^\\/]*$"))) - fileName += ".avi"; - setRecordFile(fileName); - } - } - toggleRecording(); -} - -void QDeclarativeViewer::toggleRecording() -{ - if (record_file.isEmpty()) { - toggleRecordingWithSelection(); - return; - } - bool recording = !recordTimer.isActive(); - recordAction->setText(recording ? tr("&Stop Recording Video\tF9") : tr("&Start Recording Video\tF9")); - setRecording(recording); -} - -void QDeclarativeViewer::setAnimationsPaused(bool enable) -{ - if (enable) { - setAnimationSpeed(0.0); - } else { - setAnimationSpeed(animationSpeed); - } -} - -void QDeclarativeViewer::pauseAnimations() { - pauseAnimationsAction->setChecked(true); - setAnimationsPaused(true); -} - -void QDeclarativeViewer::stepAnimations() -{ - 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; -} - -void QDeclarativeViewer::changeAnimationSpeed() -{ - 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) -{ - canvas->engine()->addImportPath(lib); -} - -void QDeclarativeViewer::addPluginPath(const QString& plugin) -{ - canvas->engine()->addPluginPath(plugin); -} - -void QDeclarativeViewer::reload() -{ - observer->setDesignModeBehavior(false); - open(currentFileOrUrl); -} - -void QDeclarativeViewer::openFile() -{ - QString cur = canvas->source().toLocalFile(); - if (useQmlFileBrowser) { - open("qrc:/content/Browser.qml"); - } else { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)")); - if (!fileName.isEmpty()) { - QFileInfo fi(fileName); - open(fi.absoluteFilePath()); - } - } -} - -void QDeclarativeViewer::statusChanged() -{ - if (canvas->status() == QDeclarativeView::Error && tester) - tester->executefailure(); - - if (canvas->status() == QDeclarativeView::Ready) { - initialSize = canvas->initialSize(); - updateSizeHints(true); - } -} - -void QDeclarativeViewer::launch(const QString& file_or_url) -{ - QMetaObject::invokeMethod(this, "open", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); -} - -void QDeclarativeViewer::loadTranslationFile(const QString& directory) -{ - if (!translator) { - translator = new QTranslator(this); - QApplication::installTranslator(translator); - } - - translator->load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n")); -} - -void QDeclarativeViewer::loadDummyDataFiles(const QString& directory) -{ - QDir dir(directory+"/dummydata", "*.qml"); - 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()); - QObject *dummyData = comp.create(); - - if(comp.isError()) { - QList<QDeclarativeError> errors = comp.errors(); - foreach (const QDeclarativeError &error, errors) { - qWarning() << error; - } - if (tester) tester->executefailure(); - } - - if (dummyData) { - qWarning() << "Loaded dummy data:" << dir.filePath(qml); - qml.truncate(qml.length()-4); - canvas->rootContext()->setContextProperty(qml, dummyData); - dummyData->setParent(this); - } - } -} - -bool QDeclarativeViewer::open(const QString& file_or_url) -{ - currentFileOrUrl = file_or_url; - - QUrl url; - QFileInfo fi(file_or_url); - if (fi.exists()) - url = QUrl::fromLocalFile(fi.absoluteFilePath()); - else - url = QUrl(file_or_url); - setWindowTitle(tr("%1 - Qt QML Viewer").arg(file_or_url)); - - if (!m_script.isEmpty()) - tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas); - - delete canvas->rootObject(); - canvas->engine()->clearComponentCache(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("qmlViewer", this); -#ifdef Q_OS_SYMBIAN - ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone -#else - ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath()); -#endif - - ctxt->setContextProperty("runtime", Runtime::instance()); - - QString fileName = url.toLocalFile(); - if (!fileName.isEmpty()) { - fi.setFile(fileName); - if (fi.exists()) { - if (fi.suffix().toLower() != QLatin1String("qml")) { - qWarning() << "qml cannot open non-QML file" << fileName; - return false; - } - - QFileInfo fi(fileName); - loadTranslationFile(fi.path()); - loadDummyDataFiles(fi.path()); - } else { - qWarning() << "qml cannot find file:" << fileName; - return false; - } - } - - QTime t; - t.start(); - - canvas->setSource(url); - - return true; -} - -void QDeclarativeViewer::setAutoRecord(int from, int to) -{ - if (from==0) from=1; // ensure resized - record_autotime = to-from; - autoStartTimer.setInterval(from); - autoStartTimer.start(); -} - -void QDeclarativeViewer::setRecordArgs(const QStringList& a) -{ - record_args = a; -} - -void QDeclarativeViewer::setRecordFile(const QString& f) -{ - record_file = f; -} - -void QDeclarativeViewer::setRecordRate(int fps) -{ - record_rate = fps; -} - -void QDeclarativeViewer::sceneResized(QSize) -{ - updateSizeHints(); -} - -void QDeclarativeViewer::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_0 && devicemode) - exit(0); - else if (event->key() == Qt::Key_F1 || (event->key() == Qt::Key_1 && devicemode)) { - qDebug() << "F1 - help\n" - << "F2 - save test script\n" - << "F3 - take PNG snapshot\n" - << "F4 - show items and state\n" - << "F5 - reload QML\n" - << "F6 - show object tree\n" - << "F7 - show timing\n" - << "F9 - toggle video recording\n" - << "F10 - toggle orientation\n" - << "device keys: 0=quit, 1..8=F1..F8" - ; - } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) { - if (tester && m_scriptOptions & Record) - tester->save(); - } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) { - takeSnapShot(); - } else if (event->key() == Qt::Key_F5 || (event->key() == Qt::Key_5 && devicemode)) { - reload(); - } else if (event->key() == Qt::Key_F9 || (event->key() == Qt::Key_9 && devicemode)) { - toggleRecording(); - } else if (event->key() == Qt::Key_F10) { - rotateOrientation(); - } - - QWidget::keyPressEvent(event); -} - -bool QDeclarativeViewer::event(QEvent *event) -{ - if (event->type() == QEvent::WindowActivate) { - Runtime::instance()->setActiveWindow(true); - } else if (event->type() == QEvent::WindowDeactivate) { - Runtime::instance()->setActiveWindow(false); - } - return QWidget::event(event); -} - -void QDeclarativeViewer::senseImageMagick() -{ - QProcess proc; - proc.start("convert", QStringList() << "-h"); - proc.waitForFinished(2000); - QString help = proc.readAllStandardOutput(); - convertAvailable = help.contains("ImageMagick"); -} - -void QDeclarativeViewer::senseFfmpeg() -{ - QProcess proc; - proc.start("ffmpeg", QStringList() << "-h"); - proc.waitForFinished(2000); - QString ffmpegHelp = proc.readAllStandardOutput(); - ffmpegAvailable = ffmpegHelp.contains("-s "); - ffmpegHelp = tr("Video recording uses ffmpeg:")+"\n\n"+ffmpegHelp; - - QDialog *d = new QDialog(recdlg); - QVBoxLayout *l = new QVBoxLayout(d); - QTextBrowser *b = new QTextBrowser(d); - QFont f = b->font(); - f.setFamily("courier"); - b->setFont(f); - b->setText(ffmpegHelp); - l->addWidget(b); - d->setLayout(l); - ffmpegHelpWindow = d; - connect(recdlg->ffmpegHelp,SIGNAL(clicked()), ffmpegHelpWindow, SLOT(show())); -} - -void QDeclarativeViewer::setRecording(bool on) -{ - if (on == recordTimer.isActive()) - return; - - int period = int(1000/record_rate+0.5); - QUnifiedTimer::instance()->setTimingInterval(on ? period:16); - QUnifiedTimer::instance()->setConsistentTiming(on); - if (on) { - canvas->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); - recordTimer.setInterval(period); - recordTimer.start(); - frame_fmt = record_file.right(4).toLower(); - frame = QImage(canvas->width(),canvas->height(),QImage::Format_RGB32); - if (frame_fmt != ".png" && (!convertAvailable || frame_fmt != ".gif")) { - // Stream video to ffmpeg - - QProcess *proc = new QProcess(this); - connect(proc, SIGNAL(finished(int)), this, SLOT(ffmpegFinished(int))); - frame_stream = proc; - - QStringList args; - args << "-y"; - args << "-r" << QString::number(record_rate); - args << "-f" << "rawvideo"; - args << "-pix_fmt" << (frame_fmt == ".gif" ? "rgb24" : "rgb32"); - args << "-s" << QString("%1x%2").arg(canvas->width()).arg(canvas->height()); - args << "-i" << "-"; - if (record_outsize.isValid()) { - args << "-s" << QString("%1x%2").arg(record_outsize.width()).arg(record_outsize.height()); - args << "-aspect" << QString::number(double(canvas->width())/canvas->height()); - } - args += record_args; - args << record_file; - proc->start("ffmpeg",args); - - } else { - // Store frames, save to GIF/PNG - frame_stream = 0; - } - } else { - canvas->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); - recordTimer.stop(); - if (frame_stream) { - qDebug() << "Saving video..."; - frame_stream->close(); - qDebug() << "Wrote" << record_file; - } else { - QProgressDialog progress(tr("Saving frames..."), tr("Cancel"), 0, frames.count()+10, this); - progress.setWindowModality(Qt::WindowModal); - - int frame=0; - QStringList inputs; - qDebug() << "Saving frames..."; - - QString framename; - bool png_output = false; - if (record_file.right(4).toLower()==".png") { - if (record_file.contains('%')) - framename = record_file; - else - framename = record_file.left(record_file.length()-4)+"%04d"+record_file.right(4); - png_output = true; - } else { - framename = "tmp-frame%04d.png"; - png_output = false; - } - foreach (QImage* img, frames) { - progress.setValue(progress.value()+1); - if (progress.wasCanceled()) - break; - QString name; - name.sprintf(framename.toLocal8Bit(),frame++); - if (record_outsize.isValid()) - *img = img->scaled(record_outsize,Qt::IgnoreAspectRatio,Qt::SmoothTransformation); - if (record_dither=="ordered") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name); - else if (record_dither=="threshold") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name); - else if (record_dither=="floyd") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name); - else - img->save(name); - inputs << name; - delete img; - } - - if (!progress.wasCanceled()) { - if (png_output) { - framename.replace(QRegExp("%\\d*."),"*"); - qDebug() << "Wrote frames" << framename; - inputs.clear(); // don't remove them - } else { - // ImageMagick and gifsicle for GIF encoding - progress.setLabelText(tr("Converting frames to GIF file...")); - QStringList args; - args << "-delay" << QString::number(period/10); - args << inputs; - args << record_file; - qDebug() << "Converting..." << record_file << "(this may take a while)"; - if (0!=QProcess::execute("convert", args)) { - qWarning() << "Cannot run ImageMagick 'convert' - recorded frames not converted"; - inputs.clear(); // don't remove them - qDebug() << "Wrote frames tmp-frame*.png"; - } else { - if (record_file.right(4).toLower() == ".gif") { - qDebug() << "Compressing..." << record_file; - if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << record_file << record_file)) - qWarning() << "Cannot run 'gifsicle' - not compressed"; - } - qDebug() << "Wrote" << record_file; - } - } - } - - progress.setValue(progress.maximum()-1); - foreach (QString name, inputs) - QFile::remove(name); - - frames.clear(); - } - } - qDebug() << "Recording: " << (recordTimer.isActive()?"ON":"OFF"); -} - -void QDeclarativeViewer::ffmpegFinished(int code) -{ - qDebug() << "ffmpeg returned" << code << frame_stream->readAllStandardError(); -} - -void QDeclarativeViewer::appAboutToQuit() -{ - // avoid QGLContext errors about invalid contexts on exit - canvas->setViewport(0); - - // avoid crashes if messages are received after app has closed - delete loggerWindow; - loggerWindow = 0; -} - -void QDeclarativeViewer::autoStartRecording() -{ - setRecording(true); - autoStopTimer.setInterval(record_autotime); - autoStopTimer.start(); -} - -void QDeclarativeViewer::autoStopRecording() -{ - setRecording(false); -} - -void QDeclarativeViewer::recordFrame() -{ - canvas->QWidget::render(&frame); - if (frame_stream) { - if (frame_fmt == ".gif") { - // ffmpeg can't do 32bpp with gif - QImage rgb24 = frame.convertToFormat(QImage::Format_RGB888); - frame_stream->write((char*)rgb24.bits(),rgb24.numBytes()); - } else { - frame_stream->write((char*)frame.bits(),frame.numBytes()); - } - } else { - frames.append(new QImage(frame)); - } -} - -void QDeclarativeViewer::changeOrientation(QAction *action) -{ - if (!action) - return; - action->setChecked(true); - - QString o = action->text(); - if (o == QLatin1String("Portrait")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait); - else if (o == QLatin1String("Landscape")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape); - else if (o == QLatin1String("Portrait (inverted)")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted); - else if (o == QLatin1String("Landscape (inverted)")) - DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted); -} - -void QDeclarativeViewer::orientationChanged() -{ - updateSizeHints(); -} - -void QDeclarativeViewer::setDeviceKeys(bool on) -{ - devicemode = on; -} - -void QDeclarativeViewer::setNetworkCacheSize(int size) -{ - namFactory->setCacheSize(size); -} - -void QDeclarativeViewer::setUseGL(bool useGL) -{ -#ifdef GL_SUPPORTED - if (useGL) { - QGLFormat format = QGLFormat::defaultFormat(); -#ifdef Q_WS_MAC - format.setSampleBuffers(true); -#else - format.setSampleBuffers(false); -#endif - - QGLWidget *glWidget = new QGLWidget(format); - //### potentially faster, but causes junk to appear if top-level is Item, not Rectangle - //glWidget->setAutoFillBackground(false); - - canvas->setViewport(glWidget); - } -#else - Q_UNUSED(useGL) -#endif -} - -void QDeclarativeViewer::setUseNativeFileBrowser(bool use) -{ - useQmlFileBrowser = !use; -} - -void QDeclarativeViewer::setSizeToView(bool sizeToView) -{ - QDeclarativeView::ResizeMode resizeMode = sizeToView ? QDeclarativeView::SizeRootObjectToView : QDeclarativeView::SizeViewToRootObject; - if (resizeMode != canvas->resizeMode()) { - canvas->setResizeMode(resizeMode); - updateSizeHints(); - } -} - -void QDeclarativeViewer::setAnimationSpeed(float f) -{ - QUnifiedTimer::instance()->setSlowdownFactor(f); - QUnifiedTimer::instance()->setSlowModeEnabled(f != 1.0); -} - -void QDeclarativeViewer::updateSizeHints(bool initial) -{ - static bool isRecursive = false; - - if (isRecursive) - return; - isRecursive = true; - - if (initial || (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject)) { - 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); - layout()->activate(); - } - } - //qWarning() << "USH: R2V: setting free size "; - layout()->setSizeConstraint(QLayout::SetNoConstraint); - layout()->activate(); - - 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; - - if (!registered) { - // registering only for exposing the DeviceOrientation::Orientation enum - qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,7,"Orientation",""); - registered = true; - } -} - -QT_END_NAMESPACE - -#include "qmlruntime.moc" diff --git a/src/tools/qml/qmlobserver/qmlruntime.h b/src/tools/qml/qmlobserver/qmlruntime.h deleted file mode 100644 index a0a07f1888c..00000000000 --- a/src/tools/qml/qmlobserver/qmlruntime.h +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIEWER_H -#define QDECLARATIVEVIEWER_H - -#include <QMainWindow> -#include <QTimer> -#include <QTime> -#include <QList> - -#include "loggerwidget.h" - -namespace QmlJSDebugger { - class QDeclarativeViewObserver; -} -namespace Utils { - class CrumblePath; -} - -QT_BEGIN_NAMESPACE - -class QDeclarativeView; -class PreviewDeviceSkin; -class QDeclarativeTestEngine; -class QProcess; -class RecordingDialog; -class QDeclarativeTester; -class QNetworkReply; -class QNetworkCookieJar; -class NetworkAccessManagerFactory; -class QTranslator; -class QActionGroup; -class QMenuBar; -class QSplitter; - -class QDeclarativeViewer - : public QMainWindow -{ - Q_OBJECT - -public: - explicit QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0); - ~QDeclarativeViewer(); - - static void registerTypes(); - - enum ScriptOption { - Play = 0x00000001, - Record = 0x00000002, - TestImages = 0x00000004, - TestErrorProperty = 0x00000008, - SaveOnExit = 0x00000010, - ExitOnComplete = 0x00000020, - ExitOnFailure = 0x00000040, - Snapshot = 0x00000080 - }; - Q_DECLARE_FLAGS(ScriptOptions, ScriptOption) - void setScript(const QString &s) { m_script = s; } - void setScriptOptions(ScriptOptions opt) { m_scriptOptions = opt; } - void setRecordDither(const QString& s) { record_dither = s; } - void setRecordRate(int fps); - void setRecordFile(const QString&); - void setRecordArgs(const QStringList&); - void setRecording(bool on); - bool isRecording() const { return recordTimer.isActive(); } - void setAutoRecord(int from, int to); - void setDeviceKeys(bool); - void setNetworkCacheSize(int size); - void addLibraryPath(const QString& lib); - void addPluginPath(const QString& plugin); - void setUseGL(bool use); - void setUseNativeFileBrowser(bool); - void setSizeToView(bool sizeToView); - - QDeclarativeView *view() const; - LoggerWidget *warningsWidget() const; - - void enableExperimentalGestures(); - -public slots: - void setDesignModeBehavior(bool value); - void setDebugMode(bool on); - void sceneResized(QSize size); - bool open(const QString&); - void openFile(); - void reload(); - void takeSnapShot(); - void toggleRecording(); - void toggleRecordingWithSelection(); - void ffmpegFinished(int code); - void showProxySettings (); - void proxySettingsChanged (); - void rotateOrientation(); - void statusChanged(); - void setAnimationsPaused(bool); - void pauseAnimations(); - void stepAnimations(); - void setAnimationStep(); - void changeAnimationSpeed(); - void launch(const QString &); - -protected: - virtual void keyPressEvent(QKeyEvent *); - virtual bool event(QEvent *); - void createMenu(); - -private slots: - void appAboutToQuit(); - - void autoStartRecording(); - void autoStopRecording(); - void recordFrame(); - void chooseRecordingOptions(); - void pickRecordingFile(); - void toggleFullScreen(); - void changeOrientation(QAction*); - void orientationChanged(); - - void showWarnings(bool show); - void warningsWidgetOpened(); - void warningsWidgetClosed(); - -private: - void setAnimationSpeed(float f); - void updateSizeHints(bool initial = false); - - QString getVideoFileName(); - - LoggerWidget *loggerWindow; - - QDeclarativeView *canvas; - QmlJSDebugger::QDeclarativeViewObserver *observer; - QSize initialSize; - QString currentFileOrUrl; - QTimer recordTimer; - QString frame_fmt; - QImage frame; - QList<QImage*> frames; - QProcess* frame_stream; - QTimer autoStartTimer; - QTimer autoStopTimer; - QString record_dither; - QString record_file; - QSize record_outsize; - QStringList record_args; - int record_rate; - int record_autotime; - bool devicemode; - QAction *recordAction; - QString currentSkin; - bool scaleSkin; - RecordingDialog *recdlg; - - void senseImageMagick(); - void senseFfmpeg(); - QWidget *ffmpegHelpWindow; - bool ffmpegAvailable; - bool convertAvailable; - - float animationSpeed; - int m_stepSize; - QAction *pauseAnimationsAction; - QAction *animationStepAction; - QAction *animationSetStepAction; - - QActionGroup *orientation; - QAction *showWarningsWindow; - QAction *designModeBehaviorAction; - - QString m_script; - ScriptOptions m_scriptOptions; - QDeclarativeTester *tester; - - QNetworkReply *wgtreply; - QString wgtdir; - NetworkAccessManagerFactory *namFactory; - - bool useQmlFileBrowser; - - QWidget *m_centralWidget; - Utils::CrumblePath *m_crumblePathWidget; - - QTranslator *translator; - void loadTranslationFile(const QString& directory); - - void loadDummyDataFiles(const QString& directory); -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeViewer::ScriptOptions) - -QT_END_NAMESPACE - -#endif diff --git a/src/tools/qml/qmlobserver/qmlruntime.qrc b/src/tools/qml/qmlobserver/qmlruntime.qrc deleted file mode 100644 index 4136eafa526..00000000000 --- a/src/tools/qml/qmlobserver/qmlruntime.qrc +++ /dev/null @@ -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> diff --git a/src/tools/qml/qmlobserver/recopts.ui b/src/tools/qml/qmlobserver/recopts.ui deleted file mode 100644 index ce2da307673..00000000000 --- a/src/tools/qml/qmlobserver/recopts.ui +++ /dev/null @@ -1,513 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>RecordingOptions</class> - <widget class="QDialog" name="RecordingOptions"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>316</width> - <height>436</height> - </rect> - </property> - <property name="windowTitle"> - <string>Video options</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>File:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="file"/> - </item> - <item> - <widget class="QToolButton" name="pickfile"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Size</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QRadioButton" name="sizeOriginal"> - <property name="text"> - <string/> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QRadioButton" name="sizeVGA"> - <property name="text"> - <string>VGA</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QRadioButton" name="size720p"> - <property name="text"> - <string>720p</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QRadioButton" name="sizeQVGA"> - <property name="text"> - <string>QVGA</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="3"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QRadioButton" name="sizeCustom"> - <property name="text"> - <string>Width:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="sizeWidth"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>9999</number> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Height:</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="sizeHeight"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>9999</number> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="0" column="2"> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="rateOptions"> - <property name="title"> - <string>Rate</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0"> - <widget class="QRadioButton" name="hz60"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>60Hz</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QRadioButton" name="hz50"> - <property name="text"> - <string>50Hz</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QRadioButton" name="hz25"> - <property name="text"> - <string>25Hz</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="4"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="QRadioButton" name="hzCustom"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="hz"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Hz</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="1" column="2"> - <widget class="QRadioButton" name="hz24"> - <property name="text"> - <string>24Hz</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="ffmpegOptions"> - <property name="title"> - <string>Profile</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0" colspan="3"> - <widget class="QComboBox" name="profile"/> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QLineEdit" name="args"/> - </item> - <item row="1" column="2"> - <widget class="QToolButton" name="ffmpegHelp"> - <property name="text"> - <string>Help</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QLabel" name="warning"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>file</tabstop> - <tabstop>pickfile</tabstop> - <tabstop>sizeOriginal</tabstop> - <tabstop>sizeVGA</tabstop> - <tabstop>size720p</tabstop> - <tabstop>sizeQVGA</tabstop> - <tabstop>sizeCustom</tabstop> - <tabstop>sizeWidth</tabstop> - <tabstop>sizeHeight</tabstop> - <tabstop>hz60</tabstop> - <tabstop>hz25</tabstop> - <tabstop>hz50</tabstop> - <tabstop>hz24</tabstop> - <tabstop>hzCustom</tabstop> - <tabstop>hz</tabstop> - <tabstop>profile</tabstop> - <tabstop>args</tabstop> - <tabstop>ffmpegHelp</tabstop> - <tabstop>buttonBox</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>hzCustom</sender> - <signal>clicked()</signal> - <receiver>hz</receiver> - <slot>setFocus()</slot> - <hints> - <hint type="sourcelabel"> - <x>43</x> - <y>257</y> - </hint> - <hint type="destinationlabel"> - <x>129</x> - <y>262</y> - </hint> - </hints> - </connection> - <connection> - <sender>hz</sender> - <signal>textChanged(QString)</signal> - <receiver>hzCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>143</x> - <y>262</y> - </hint> - <hint type="destinationlabel"> - <x>43</x> - <y>257</y> - </hint> - </hints> - </connection> - <connection> - <sender>hz</sender> - <signal>selectionChanged()</signal> - <receiver>hzCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>143</x> - <y>262</y> - </hint> - <hint type="destinationlabel"> - <x>43</x> - <y>257</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>RecordingOptions</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>60</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>RecordingOptions</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>92</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>profile</sender> - <signal>activated(int)</signal> - <receiver>RecordingOptions</receiver> - <slot>pickProfile(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>92</x> - <y>329</y> - </hint> - <hint type="destinationlabel"> - <x>48</x> - <y>194</y> - </hint> - </hints> - </connection> - <connection> - <sender>args</sender> - <signal>textEdited(QString)</signal> - <receiver>RecordingOptions</receiver> - <slot>storeCustomArgs(QString)</slot> - <hints> - <hint type="sourcelabel"> - <x>128</x> - <y>357</y> - </hint> - <hint type="destinationlabel"> - <x>102</x> - <y>189</y> - </hint> - </hints> - </connection> - <connection> - <sender>sizeWidth</sender> - <signal>valueChanged(int)</signal> - <receiver>sizeCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>108</x> - <y>133</y> - </hint> - <hint type="destinationlabel"> - <x>48</x> - <y>133</y> - </hint> - </hints> - </connection> - <connection> - <sender>sizeHeight</sender> - <signal>valueChanged(int)</signal> - <receiver>sizeCustom</receiver> - <slot>toggle()</slot> - <hints> - <hint type="sourcelabel"> - <x>212</x> - <y>133</y> - </hint> - <hint type="destinationlabel"> - <x>64</x> - <y>129</y> - </hint> - </hints> - </connection> - </connections> - <slots> - <signal>filePicked(QString)</signal> - <signal>argumentsPicked(QString)</signal> - <slot>pickFile()</slot> - <slot>pickProfile(int)</slot> - <slot>storeCustomArgs(QString)</slot> - </slots> -</ui> diff --git a/src/tools/qml/qmlobserver/recopts_maemo5.ui b/src/tools/qml/qmlobserver/recopts_maemo5.ui deleted file mode 100644 index 3bb5ecabd91..00000000000 --- a/src/tools/qml/qmlobserver/recopts_maemo5.ui +++ /dev/null @@ -1,254 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>RecordingOptions</class> - <widget class="QDialog" name="RecordingOptions"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>469</width> - <height>142</height> - </rect> - </property> - <property name="windowTitle"> - <string>Video options</string> - </property> - <layout class="QGridLayout" name="gridLayout" columnstretch="0,2,0"> - <property name="sizeConstraint"> - <enum>QLayout::SetMinAndMaxSize</enum> - </property> - <property name="leftMargin"> - <number>16</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>16</number> - </property> - <property name="bottomMargin"> - <number>8</number> - </property> - <property name="horizontalSpacing"> - <number>16</number> - </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <item row="0" column="1"> - <widget class="QLineEdit" name="file"/> - </item> - <item row="0" column="2" rowspan="3"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>72</width> - <height>56</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Size</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="sizeCombo"> - <item> - <property name="text"> - <string/> - </property> - </item> - <item> - <property name="text"> - <string>VGA</string> - </property> - </item> - <item> - <property name="text"> - <string>QVGA</string> - </property> - </item> - <item> - <property name="text"> - <string>720p</string> - </property> - </item> - </widget> - </item> - <item row="2" column="0" rowspan="2"> - <widget class="QLabel" name="rateLabel"> - <property name="text"> - <string>Rate</string> - </property> - </widget> - </item> - <item row="2" column="1" rowspan="2"> - <widget class="QComboBox" name="rateCombo"> - <item> - <property name="text"> - <string>60 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>50 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>25 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>24 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>20 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>15 Hz</string> - </property> - </item> - <item> - <property name="text"> - <string>10 Hz</string> - </property> - </item> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="args"/> - </item> - <item row="4" column="1"> - <widget class="QComboBox" name="profile"/> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="profileLabel"> - <property name="text"> - <string>Profile</string> - </property> - </widget> - </item> - <item row="6" column="0" colspan="2"> - <widget class="QLabel" name="warning"> - <property name="text"> - <string notr="true">warning</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="2" rowspan="3"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QPushButton" name="pickfile"> - <property name="text"> - <string>File</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QPushButton" name="ffmpegHelp"> - <property name="text"> - <string>Options</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>RecordingOptions</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>60</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>RecordingOptions</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>258</x> - <y>424</y> - </hint> - <hint type="destinationlabel"> - <x>92</x> - <y>219</y> - </hint> - </hints> - </connection> - <connection> - <sender>profile</sender> - <signal>activated(int)</signal> - <receiver>RecordingOptions</receiver> - <slot>pickProfile(int)</slot> - <hints> - <hint type="sourcelabel"> - <x>92</x> - <y>329</y> - </hint> - <hint type="destinationlabel"> - <x>48</x> - <y>194</y> - </hint> - </hints> - </connection> - <connection> - <sender>args</sender> - <signal>textEdited(QString)</signal> - <receiver>RecordingOptions</receiver> - <slot>storeCustomArgs(QString)</slot> - <hints> - <hint type="sourcelabel"> - <x>128</x> - <y>357</y> - </hint> - <hint type="destinationlabel"> - <x>102</x> - <y>189</y> - </hint> - </hints> - </connection> - </connections> - <slots> - <signal>filePicked(QString)</signal> - <signal>argumentsPicked(QString)</signal> - <slot>pickFile()</slot> - <slot>pickProfile(int)</slot> - <slot>storeCustomArgs(QString)</slot> - </slots> -</ui> diff --git a/src/tools/qml/qmlobserver/texteditautoresizer_maemo5.h b/src/tools/qml/qmlobserver/texteditautoresizer_maemo5.h deleted file mode 100644 index bb5567a4c27..00000000000 --- a/src/tools/qml/qmlobserver/texteditautoresizer_maemo5.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation ([email protected]) -** -** This file is part of the examples 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 [email protected]. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui/qplaintextedit.h> -#include <QtGui/qtextedit.h> -#include <QtGui/qabstractkineticscroller.h> -#include <QtGui/qscrollarea.h> -#include <QtDebug> - -#ifndef TEXTEDITAUTORESIZER_H -#define TEXTEDITAUTORESIZER_H - -class TextEditAutoResizer : public QObject -{ - Q_OBJECT -public: - TextEditAutoResizer(QWidget *parent) - : QObject(parent), plainTextEdit(qobject_cast<QPlainTextEdit *>(parent)), - textEdit(qobject_cast<QTextEdit *>(parent)), edit(qobject_cast<QFrame *>(parent)) - { - // parent must either inherit QPlainTextEdit or QTextEdit! - Q_ASSERT(plainTextEdit || textEdit); - - connect(parent, SIGNAL(textChanged()), this, SLOT(textEditChanged())); - connect(parent, SIGNAL(cursorPositionChanged()), this, SLOT(textEditChanged())); - - textEditChanged(); - } - -private Q_SLOTS: - inline void textEditChanged(); - -private: - QPlainTextEdit *plainTextEdit; - QTextEdit *textEdit; - QFrame *edit; -}; - -void TextEditAutoResizer::textEditChanged() -{ - QTextDocument *doc = textEdit ? textEdit->document() : plainTextEdit->document(); - QRect cursor = textEdit ? textEdit->cursorRect() : plainTextEdit->cursorRect(); - - QSize s = doc->size().toSize(); - if (plainTextEdit) - s.setHeight((s.height() + 2) * edit->fontMetrics().lineSpacing()); - - const QRect fr = edit->frameRect(); - const QRect cr = edit->contentsRect(); - - edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height() - 1))); - - // make sure the cursor is visible in case we have a QAbstractScrollArea parent - QPoint pos = edit->pos(); - QWidget *pw = edit->parentWidget(); - while (pw) { - if (qobject_cast<QScrollArea *>(pw)) - break; - pw = pw->parentWidget(); - } - - if (pw) { - QScrollArea *area = static_cast<QScrollArea *>(pw); - QPoint scrollto = area->widget()->mapFrom(edit, cursor.center()); - QPoint margin(10 + cursor.width(), 2 * cursor.height()); - - if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) { - scroller->ensureVisible(scrollto, margin.x(), margin.y()); - } else { - area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y()); - } - } -} - -#endif |