diff options
author | Ian Walters <ian.walters@nokia.com> | 2009-05-07 07:12:21 (GMT) |
---|---|---|
committer | Ian Walters <ian.walters@nokia.com> | 2009-05-07 07:12:21 (GMT) |
commit | 2d76308b923717e613a499894440185fa618b5e7 (patch) | |
tree | 4098c1d75855127a1a36d6f65ca9b00d7cc12f02 | |
parent | 56b9afeb8547b724e0e061b1c7bbf8fb62874567 (diff) | |
parent | 84dc4e1c5c48d38b4a59fab22e49162de091beff (diff) | |
download | Qt-2d76308b923717e613a499894440185fa618b5e7.zip Qt-2d76308b923717e613a499894440185fa618b5e7.tar.gz Qt-2d76308b923717e613a499894440185fa618b5e7.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | demos/declarative/flickr/content/ImageDetails.qml | 5 | ||||
-rw-r--r-- | src/declarative/canvas/qsimplecanvas.cpp | 4 | ||||
-rw-r--r-- | src/declarative/canvas/qsimplecanvas_software.cpp | 5 | ||||
-rw-r--r-- | src/declarative/canvas/qsimplecanvasitem.cpp | 8 | ||||
-rw-r--r-- | src/declarative/canvas/qsimplecanvasitem.h | 11 | ||||
-rw-r--r-- | src/declarative/canvas/qsimplecanvasitem_p.h | 25 | ||||
-rw-r--r-- | src/declarative/debugger/debugger.pri | 8 | ||||
-rw-r--r-- | src/declarative/debugger/qmldebugger.cpp | 31 | ||||
-rw-r--r-- | src/declarative/debugger/qmldebugger.h | 3 | ||||
-rw-r--r-- | src/declarative/debugger/qmldebuggerstatus.cpp | 54 | ||||
-rw-r--r-- | src/declarative/debugger/qmldebuggerstatus.h | 67 | ||||
-rw-r--r-- | src/declarative/debugger/qmlpropertyview.cpp | 121 | ||||
-rw-r--r-- | src/declarative/debugger/qmlpropertyview_p.h | 70 | ||||
-rw-r--r-- | tools/qmlviewer/main.cpp | 4 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 83 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.h | 1 |
16 files changed, 458 insertions, 42 deletions
diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 955f85d..6c354f6 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -60,8 +60,9 @@ Flipable { text: "<b>Published:</b> " + Container.photoDate } Text { id: TagsLabel; color: "white"; x: 220; anchors.top: Date.bottom; text: Container.photoTags == "" ? "" : "<b>Tags:</b> " } - Text { id: Tags; color: "white"; width: parent.width-x-20; anchors.left: TagsLabel.right; anchors.top: Date.bottom; elide: "ElideRight" - text: Container.photoTags == "" ? "" : Container.photoTags } + Text { id: Tags; color: "white"; width: parent.width-x-20; + anchors.left: TagsLabel.right; anchors.top: Date.bottom; + elide: "ElideRight"; text: Container.photoTags } ScrollBar { id: ScrollBar; x: 720; y: Flickable.y; width: 7; height: Flickable.height; opacity: 0; flickableArea: Flickable; clip: true } diff --git a/src/declarative/canvas/qsimplecanvas.cpp b/src/declarative/canvas/qsimplecanvas.cpp index 9de9464..e1dd0e8 100644 --- a/src/declarative/canvas/qsimplecanvas.cpp +++ b/src/declarative/canvas/qsimplecanvas.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(fullUpdate, GFX_CANVAS_FULL_UPDATE); DEFINE_BOOL_CONFIG_OPTION(continuousUpdate, GFX_CANVAS_CONTINUOUS_UPDATE); -DEFINE_BOOL_CONFIG_OPTION(useGraphicsView, QFX_USE_GRAPHICSVIEW); +DEFINE_BOOL_CONFIG_OPTION(useSimpleCanvas, QFX_USE_SIMPLECANVAS); template<class T, int s = 60> class CircularList @@ -556,7 +556,7 @@ QSimpleCanvas::QSimpleCanvas(CanvasMode mode, QWidget *parent) QSimpleCanvas::QSimpleCanvas(QWidget *parent) : QWidget(parent), d(new QSimpleCanvasPrivate(this)) { - d->init(useGraphicsView()?SimpleCanvas:GraphicsView); + d->init(useSimpleCanvas()?SimpleCanvas:GraphicsView); } void QSimpleCanvasPrivate::init(QSimpleCanvas::CanvasMode mode) diff --git a/src/declarative/canvas/qsimplecanvas_software.cpp b/src/declarative/canvas/qsimplecanvas_software.cpp index c130a62..194024d 100644 --- a/src/declarative/canvas/qsimplecanvas_software.cpp +++ b/src/declarative/canvas/qsimplecanvas_software.cpp @@ -172,6 +172,11 @@ void QSimpleCanvasItemPrivate::paint(QPainter &p) if (clip) p.restore(); + + if (debuggerStatus && debuggerStatus->selected) { + p.setWorldTransform(data()->transformActive); + p.fillRect(q->boundingRect(), QColor(255, 0, 0, 80)); + } } void QSimpleCanvasItemPrivate::paintChild(QPainter &p, QSimpleCanvasItem *c) diff --git a/src/declarative/canvas/qsimplecanvasitem.cpp b/src/declarative/canvas/qsimplecanvasitem.cpp index 62a44e4..ba33a41 100644 --- a/src/declarative/canvas/qsimplecanvasitem.cpp +++ b/src/declarative/canvas/qsimplecanvasitem.cpp @@ -1380,6 +1380,14 @@ QSimpleCanvasItem::operator QGraphicsItem *() return d->graphicsItem; } +QSimpleCanvasItem::operator QmlDebuggerStatus *() +{ + Q_D(QSimpleCanvasItem); + if(!d->debuggerStatus) + d->debuggerStatus = new QSimpleCanvasItemDebuggerStatus(this); + return d->debuggerStatus; +} + QPointF QSimpleCanvasItemPrivate::transformOrigin() const { Q_Q(const QSimpleCanvasItem); diff --git a/src/declarative/canvas/qsimplecanvasitem.h b/src/declarative/canvas/qsimplecanvasitem.h index 83f19c3..cab8492 100644 --- a/src/declarative/canvas/qsimplecanvasitem.h +++ b/src/declarative/canvas/qsimplecanvasitem.h @@ -42,10 +42,11 @@ #ifndef QSIMPLECANVASITEM_H #define QSIMPLECANVASITEM_H -#include <qfxglobal.h> -#include <qsimplecanvas.h> -#include <QObject> -#include <QGraphicsItem> +#include <QtDeclarative/qfxglobal.h> +#include <QtDeclarative/qmldebuggerstatus.h> +#include <QtDeclarative/qsimplecanvas.h> +#include <QtCore/qobject.h> +#include <QtGui/qgraphicsitem.h> class QPainter; QT_BEGIN_HEADER @@ -70,6 +71,7 @@ class Q_DECLARATIVE_EXPORT QSimpleCanvasItem : public QObject { Q_OBJECT Q_CAST_INTERFACES(QGraphicsItem) + Q_CAST_INTERFACES(QmlDebuggerStatus) Q_DECLARE_PRIVATE(QSimpleCanvasItem) Q_ENUMS(TransformOrigin) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin); @@ -94,6 +96,7 @@ public: QSimpleCanvasItem(QSimpleCanvasItem *parent=0); virtual ~QSimpleCanvasItem(); operator QGraphicsItem *(); + operator QmlDebuggerStatus *(); bool clip() const; void setClip(bool); diff --git a/src/declarative/canvas/qsimplecanvasitem_p.h b/src/declarative/canvas/qsimplecanvasitem_p.h index 27a75bd..cfe0bba 100644 --- a/src/declarative/canvas/qsimplecanvasitem_p.h +++ b/src/declarative/canvas/qsimplecanvasitem_p.h @@ -110,6 +110,22 @@ public: #endif }; +class QSimpleCanvasItemDebuggerStatus : public QmlDebuggerStatus +{ +public: + QSimpleCanvasItemDebuggerStatus(QSimpleCanvasItem *i) + : item(i), selected(false) {} + + virtual void setSelectedState(bool state) + { + selected = state; + item->update(); + } + + QSimpleCanvasItem *item; + bool selected; +}; + class QSimpleCanvasFilter; class QGraphicsQSimpleCanvasItem; class QSimpleCanvasItemPrivate : public QObjectPrivate @@ -117,7 +133,8 @@ class QSimpleCanvasItemPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QSimpleCanvasItem); public: QSimpleCanvasItemPrivate() - : parent(0), canvas(0), filter(0), clip(QSimpleCanvasItem::NoClip), + : parent(0), canvas(0), debuggerStatus(0), filter(0), + clip(QSimpleCanvasItem::NoClip), origin(QSimpleCanvasItem::TopLeft), options(QSimpleCanvasItem::NoOption), focusable(false), wantsActiveFocusPanelPendingCanvas(false), hasBeenActiveFocusPanel(false), @@ -127,12 +144,16 @@ public: { } - virtual ~QSimpleCanvasItemPrivate() {} + virtual ~QSimpleCanvasItemPrivate() + { + if(debuggerStatus) delete debuggerStatus; + } QSimpleCanvasItem *parent; QSimpleCanvas *canvas; QList<QSimpleCanvasItem *> children; + QSimpleCanvasItemDebuggerStatus *debuggerStatus; QSimpleCanvasFilter *filter; QSimpleCanvasItem::ClipType clip:3; diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index ea5219a..31a1d5b 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -1,3 +1,7 @@ -SOURCES += debugger/qmldebugger.cpp +SOURCES += debugger/qmldebugger.cpp \ + debugger/qmldebuggerstatus.cpp \ + debugger/qmlpropertyview.cpp -HEADERS += debugger/qmldebugger.h +HEADERS += debugger/qmldebugger.h \ + debugger/qmldebuggerstatus.h \ + debugger/qmlpropertyview_p.h diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp index a1956f9..634385b 100644 --- a/src/declarative/debugger/qmldebugger.cpp +++ b/src/declarative/debugger/qmldebugger.cpp @@ -46,6 +46,7 @@ #include <QTextBlock> #include <QtGui/qtabwidget.h> #include <QtDeclarative/qmlbindablevalue.h> +#include <QtDeclarative/qmldebuggerstatus.h> #include <private/qmlboundsignal_p.h> #include <private/qmlcontext_p.h> #include <private/qmlengine_p.h> @@ -56,9 +57,11 @@ #include <QtGui/qpushbutton.h> #include <QtGui/qtablewidget.h> #include <QtGui/qevent.h> +#include <private/qmlpropertyview_p.h> QmlDebugger::QmlDebugger(QWidget *parent) -: QWidget(parent), m_tree(0), m_warnings(0), m_watchers(0), m_text(0) +: QWidget(parent), m_tree(0), m_warnings(0), m_watchers(0), m_properties(0), + m_text(0) { QHBoxLayout *layout = new QHBoxLayout; setLayout(layout); @@ -96,6 +99,9 @@ QmlDebugger::QmlDebugger(QWidget *parent) m_watchers->setSelectionMode(QTableWidget::NoSelection); tabs->addTab(m_watchers, "Watchers"); + m_properties = new QmlPropertyView(this); + tabs->addTab(m_properties, "Properties"); + splitter->addWidget(tabs); splitter->setStretchFactor(1, 2); @@ -119,6 +125,7 @@ public: int endLine; QUrl url; + QPointer<QObject> object; QPointer<QmlBindableValue> bindableValue; }; @@ -144,6 +151,26 @@ void QmlDebugger::itemDoubleClicked(QTreeWidgetItem *i) void QmlDebugger::itemClicked(QTreeWidgetItem *i) { QmlDebuggerItem *item = static_cast<QmlDebuggerItem *>(i); + + if(m_selectedItem) { + QmlDebuggerStatus *debug = + qobject_cast<QmlDebuggerStatus *>(m_selectedItem); + Q_ASSERT(debug); + debug->setSelectedState(false); + m_selectedItem = 0; + } + + if(item->object) { + QmlDebuggerStatus *debug = + qobject_cast<QmlDebuggerStatus *>(item->object); + if(debug) { + debug->setSelectedState(true); + m_selectedItem = item->object; + } + + m_properties->setObject(item->object); + } + if(item->url.scheme() == QLatin1String("file")) { QString f = item->url.toLocalFile(); QFile file(f); @@ -194,6 +221,8 @@ bool QmlDebugger::makeItem(QObject *obj, QmlDebuggerItem *item) QString text; + item->object = obj; + if(QmlBindableValue *bv = qobject_cast<QmlBindableValue *>(obj)) { QmlExpressionPrivate *p = bv->d; diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h index e04eb2e..35ff92c 100644 --- a/src/declarative/debugger/qmldebugger.h +++ b/src/declarative/debugger/qmldebugger.h @@ -57,6 +57,7 @@ class QTreeWidgetItem; class QPlainTextEdit; class QmlDebuggerItem; class QTableWidget; +class QmlPropertyView; class QmlDebugger : public QWidget { Q_OBJECT @@ -78,10 +79,12 @@ private: QTreeWidget *m_tree; QTreeWidget *m_warnings; QTableWidget *m_watchers; + QmlPropertyView *m_properties; QPlainTextEdit *m_text; QPointer<QObject> m_object; QList<QPair<quint32, QPair<int, QString> > > m_expressions; QSet<quint32> m_watchedIds; + QPointer<QObject> m_selectedItem; }; QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebuggerstatus.cpp b/src/declarative/debugger/qmldebuggerstatus.cpp new file mode 100644 index 0000000..d46a21d --- /dev/null +++ b/src/declarative/debugger/qmldebuggerstatus.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmldebuggerstatus.h" + +QT_BEGIN_NAMESPACE + +QmlDebuggerStatus::~QmlDebuggerStatus() +{ +} + +void QmlDebuggerStatus::setSelectedState(bool) +{ +} + +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebuggerstatus.h b/src/declarative/debugger/qmldebuggerstatus.h new file mode 100644 index 0000000..8c6355d --- /dev/null +++ b/src/declarative/debugger/qmldebuggerstatus.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLDEBUGGERSTATUS_P_H +#define QMLDEBUGGERSTATUS_P_H + +#include <QtCore/qobject.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class Q_DECLARATIVE_EXPORT QmlDebuggerStatus +{ +public: + virtual ~QmlDebuggerStatus(); + + virtual void setSelectedState(bool); +}; +Q_DECLARE_INTERFACE(QmlDebuggerStatus, "com.trolltech.qml.QmlDebuggerStatus"); + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QLMDEBUGGERSTATUS_P_H + diff --git a/src/declarative/debugger/qmlpropertyview.cpp b/src/declarative/debugger/qmlpropertyview.cpp new file mode 100644 index 0000000..2434c58 --- /dev/null +++ b/src/declarative/debugger/qmlpropertyview.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlpropertyview_p.h" +#include <QtGui/qboxlayout.h> +#include <QtGui/qtreewidget.h> +#include <QtCore/qmetaobject.h> + +QmlPropertyView::QmlPropertyView(QWidget *parent) +: QWidget(parent), m_tree(0) +{ + QVBoxLayout *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + setLayout(layout); + + m_tree = new QTreeWidget(this); + m_tree->setHeaderLabels(QStringList() << "Property" << "Value"); + + m_tree->setColumnCount(2); + + layout->addWidget(m_tree); +} + +class QmlPropertyViewItem : public QObject, public QTreeWidgetItem +{ +Q_OBJECT +public: + QmlPropertyViewItem(QTreeWidget *widget); + + QObject *object; + QMetaProperty property; + +public slots: + void refresh(); +}; + +QmlPropertyViewItem::QmlPropertyViewItem(QTreeWidget *widget) +: QTreeWidgetItem(widget) +{ +} + +void QmlPropertyViewItem::refresh() +{ + setText(1, property.read(object).toString()); +} + +void QmlPropertyView::setObject(QObject *object) +{ + m_object = object; + + m_tree->clear(); + if(!m_object) + return; + + const QMetaObject *mo = object->metaObject(); + for(int ii = 0; ii < mo->propertyCount(); ++ii) { + QmlPropertyViewItem *item = new QmlPropertyViewItem(m_tree); + + QMetaProperty p = mo->property(ii); + item->object = object; + item->property = p; + + item->setText(0, QLatin1String(p.name())); + + static int refreshIdx = -1; + if(refreshIdx == -1) + refreshIdx = QmlPropertyViewItem::staticMetaObject.indexOfMethod("refresh()"); + + if(p.hasNotifySignal()) + QMetaObject::connect(object, p.notifySignalIndex(), + item, refreshIdx); + + item->refresh(); + } +} + +void QmlPropertyView::refresh() +{ + setObject(m_object); +} + +#include "qmlpropertyview.moc" diff --git a/src/declarative/debugger/qmlpropertyview_p.h b/src/declarative/debugger/qmlpropertyview_p.h new file mode 100644 index 0000000..fce9941 --- /dev/null +++ b/src/declarative/debugger/qmlpropertyview_p.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLPROPERTYVIEW_P_H +#define QMLPROPERTYVIEW_P_H + +#include <QtGui/qwidget.h> +#include <QtCore/qpointer.h> + +QT_BEGIN_NAMESPACE + +class QTreeWidget; +class QmlPropertyView : public QWidget +{ + Q_OBJECT +public: + QmlPropertyView(QWidget *parent = 0); + + void setObject(QObject *); + +public slots: + void refresh(); + +private: + QPointer<QObject> m_object; + QTreeWidget *m_tree; +}; + +QT_END_NAMESPACE + +#endif // QMLPROPERTYVIEW_P_H + diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 3f74ef6..379fda9 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -26,7 +26,7 @@ void usage() qWarning(" -v, -version ............................. display version"); qWarning(" -frameless ............................... run with no window frame"); qWarning(" -skin <qvfbskindir> ...................... run with a skin window frame"); - qWarning(" -recordfile <output> ..................... set output file"); + qWarning(" -recordfile <output> ..................... set video recording file"); qWarning(" - ImageMagick 'convert' for GIF)"); qWarning(" - png file for raw frames"); qWarning(" - 'ffmpeg' for other formats"); @@ -69,7 +69,7 @@ int main(int argc, char ** argv) int autorecord_from = 0; int autorecord_to = 0; QString dither = "none"; - QString recordfile = "animation.gif"; + QString recordfile; QString skin; bool devkeys = false; bool cache = false; diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 04054ec..8457972 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -31,6 +31,7 @@ #include <QFile> #include <QFileInfo> #include <QVBoxLayout> +#include <QProgressDialog> #include <QProcess> #include <QMenuBar> #include <QMenu> @@ -86,15 +87,15 @@ void QmlViewer::createMenuBar() fileMenu->addSeparator(); fileMenu->addAction(quitAction); - /*QMenu *recordMenu = menuBar()->addMenu(tr("&Recording")); + QMenu *recordMenu = menuBar()->addMenu(tr("&Recording")); - QAction *snapshotAction = new QAction(tr("&Take Snapsot"), this); + QAction *snapshotAction = new QAction(tr("&Take Snapsot\tF3"), this); connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot())); recordMenu->addAction(snapshotAction); - recordAction = new QAction(tr("&Start Recording Video"), this); - connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecording())); - recordMenu->addAction(recordAction);*/ + recordAction = new QAction(tr("Start Recording &Video\tF2"), this); + connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection())); + recordMenu->addAction(recordAction); QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); QAction *aboutAction = new QAction(tr("&About Qt..."), this); @@ -111,13 +112,31 @@ void QmlViewer::takeSnapShot() ++snapshotcount; } +void QmlViewer::toggleRecordingWithSelection() +{ + if (!recordTimer.isActive()) { + QString fileName = QFileDialog::getSaveFileName(this, tr("Save Video File"), "", tr("Common Video files (*.avi *.mpeg *.mov);; GIF Animation (*.gif);; Individual PNG frames (*.png);; All ffmpeg formats (*.*)")); + if (fileName.isEmpty()) + return; + if (!fileName.contains(QRegExp(".[^\\/]*$"))) + fileName += ".avi"; + setRecordFile(fileName); + } + toggleRecording(); +} + void QmlViewer::toggleRecording() { - bool recording = recordTimer.isActive(); - //recordAction->setText(recording ? tr("&Start Recording Video") : tr("&End Recording Video")); - setRecording(!recording); + if (record_file.isEmpty()) { + toggleRecordingWithSelection(); + return; + } + bool recording = !recordTimer.isActive(); + recordAction->setText(recording ? tr("&Stop Recording Video\tF2") : tr("&Start Recording Video\tF2")); + setRecording(recording); } + void QmlViewer::reload() { openQml(currentFileName); @@ -389,6 +408,9 @@ void QmlViewer::setRecording(bool on) 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..."; @@ -406,6 +428,9 @@ void QmlViewer::setRecording(bool on) 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_dither=="ordered") @@ -420,31 +445,35 @@ void QmlViewer::setRecording(bool on) delete img; } - if (png_output) { - framename.replace(QRegExp("%\\d*."),"*"); - qDebug() << "Wrote frames" << framename; - inputs.clear(); // don't remove them - } else { - // ImageMagick and gifsicle for GIF encoding - QStringList args; - args << "-delay" << QString::number(record_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"; + if (!progress.wasCanceled()) { + if (png_output) { + framename.replace(QRegExp("%\\d*."),"*"); + qDebug() << "Wrote frames" << framename; 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"; + // ImageMagick and gifsicle for GIF encoding + progress.setLabelText(tr("Converting frames to GIF file...")); + QStringList args; + args << "-delay" << QString::number(record_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; } - qDebug() << "Wrote" << record_file; } } + progress.setValue(progress.maximum()-1); foreach (QString name, inputs) QFile::remove(name); diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 405e8d9..fc8a427 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -50,6 +50,7 @@ public slots: void reload(); void takeSnapShot(); void toggleRecording(); + void toggleRecordingWithSelection(); protected: virtual void keyPressEvent(QKeyEvent *); |