From 2776e24964a49c98bd807351ccdffebaed5e2eea Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 31 Jul 2009 15:36:20 +1000 Subject: Other minor API review changes. --- src/declarative/extra/qfxanimatedimageitem.cpp | 2 +- src/declarative/fx/qfximage.cpp | 20 ++++++++++---------- src/declarative/fx/qfximage.h | 2 +- src/declarative/fx/qfximage_p.h | 5 ++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp index 44a1d67..daacdac 100644 --- a/src/declarative/extra/qfxanimatedimageitem.cpp +++ b/src/declarative/extra/qfxanimatedimageitem.cpp @@ -197,7 +197,7 @@ void QFxAnimatedImageItem::setSource(const QUrl &url) if (url.isEmpty()) { delete d->_movie; - d->status = Idle; + d->status = Null; } else { d->status = Loading; QNetworkRequest req(d->url); diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 98e8985..605e1ea 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -167,13 +167,12 @@ QFxImage::~QFxImage() } /*! - \property QFxImage::pixmap + \property QFxImage::image \brief the image displayed in this item. This property contains the image currently being displayed by this item, - which may be an empty pixmap if nothing is currently displayed. If this - property is set, the source property will be unset. This property is intended - to be used only in C++, not in QML. + which may be empty if nothing is currently displayed. Setting the source + property overrides any setting of this property. */ QPixmap QFxImage::pixmap() const { @@ -184,9 +183,9 @@ QPixmap QFxImage::pixmap() const void QFxImage::setPixmap(const QPixmap &pix) { Q_D(QFxImage); - d->url = QUrl(); + if (!d->url.isEmpty()) + return; d->pix = pix; - d->opaque=false; setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); @@ -454,7 +453,8 @@ void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) This property holds the status of image loading. It can be one of: \list - \o Idle - no image has been set, or the image has been loaded + \o Null - no image has been set + \o Ready - the image has been loaded \o Loading - the images is currently being loaded \o Error - an error occurred while loading the image \endlist @@ -546,8 +546,8 @@ void QFxImage::setSource(const QUrl &url) } if (url.isEmpty()) { - setPixmap(QPixmap()); - d->status = Idle; + d->pix = QPixmap(); + d->status = Null; d->progress = 1.0; setImplicitWidth(0); setImplicitHeight(0); @@ -605,7 +605,7 @@ void QFxImage::requestFinished() setImplicitHeight(d->pix.height()); if (d->status == Loading) - d->status = Idle; + d->status = Ready; d->progress = 1.0; emit statusChanged(d->status); emit sourceChanged(d->url); diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 9573ce5..9ab4456 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -84,7 +84,7 @@ public: bool smoothTransform() const; void setSmoothTransform(bool); - enum Status { Idle, Loading, Error }; + enum Status { Null, Ready, Loading, Error }; Status status() const; qreal progress() const; diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h index a9ad054..32529c4 100644 --- a/src/declarative/fx/qfximage_p.h +++ b/src/declarative/fx/qfximage_p.h @@ -70,9 +70,9 @@ class QFxImagePrivate : public QFxItemPrivate public: QFxImagePrivate() - : scaleGrid(0), smooth(false), opaque(false), + : scaleGrid(0), smooth(false), fillMode(QFxImage::Stretch), - status(QFxImage::Idle), sciReply(0), + status(QFxImage::Null), sciReply(0), progress(0.0) { } @@ -94,7 +94,6 @@ public: QFxScaleGrid *scaleGrid; QPixmap pix; bool smooth : 1; - bool opaque : 1; QFxImage::FillMode fillMode; QFxImage::Status status; -- cgit v0.12 From ff5ebbf9f99e9b489dba7e98814ddfdccf2cf71c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 31 Jul 2009 15:52:03 +1000 Subject: Get rid of QFxItem::options. They can all be set directly with QGraphicsItem flags or functions. --- src/declarative/fx/qfxcomponentinstance.cpp | 4 +-- src/declarative/fx/qfxflickable.cpp | 10 +++--- src/declarative/fx/qfxflickable.h | 2 +- src/declarative/fx/qfxfocusrealm.cpp | 2 +- src/declarative/fx/qfxgridview.cpp | 2 +- src/declarative/fx/qfxitem.cpp | 49 ----------------------------- src/declarative/fx/qfxitem.h | 12 ------- src/declarative/fx/qfxitem_p.h | 2 -- src/declarative/fx/qfxlistview.cpp | 2 +- src/declarative/fx/qfxpathview.cpp | 8 ++--- src/declarative/fx/qfxpathview.h | 2 +- src/declarative/fx/qfxpathview_p.h | 3 +- 12 files changed, 18 insertions(+), 80 deletions(-) diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp index a85b25d..f38d170 100644 --- a/src/declarative/fx/qfxcomponentinstance.cpp +++ b/src/declarative/fx/qfxcomponentinstance.cpp @@ -73,13 +73,13 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,ComponentInstance,QFxComponentIn QFxComponentInstance::QFxComponentInstance(QFxItem *parent) : QFxItem(*(new QFxComponentInstancePrivate), parent) { - setOptions(IsFocusRealm); + setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); } QFxComponentInstance::QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent) : QFxItem(dd, parent) { - setOptions(IsFocusRealm); + setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); } /*! diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 4b504cb..d413e42 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -111,7 +111,7 @@ void QFxFlickablePrivate::init() QObject::connect(&_tl, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding())); q->setAcceptedMouseButtons(Qt::LeftButton); - q->setOptions(QFxItem::ChildMouseFilter); + q->setFiltersChildEvents(true); QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged())); QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged())); QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked())); @@ -1062,20 +1062,20 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) return false; } -bool QFxFlickable::mouseFilter(QGraphicsSceneMouseEvent *e) +bool QFxFlickable::sceneEventFilter(QGraphicsItem *i, QEvent *e) { if (!isVisible()) - return false; + return QFxItem::sceneEventFilter(i, e); switch (e->type()) { case QEvent::GraphicsSceneMousePress: case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMouseRelease: - return sendMouseEvent(e); + return sendMouseEvent(static_cast(e)); default: break; } - return false; + return QFxItem::sceneEventFilter(i, e); } /*! diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h index a6c2a6c..4fcaf44 100644 --- a/src/declarative/fx/qfxflickable.h +++ b/src/declarative/fx/qfxflickable.h @@ -151,7 +151,7 @@ Q_SIGNALS: void pageChanged(); protected: - virtual bool mouseFilter(QGraphicsSceneMouseEvent *); + virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/declarative/fx/qfxfocusrealm.cpp b/src/declarative/fx/qfxfocusrealm.cpp index e22d721..4484378 100644 --- a/src/declarative/fx/qfxfocusrealm.cpp +++ b/src/declarative/fx/qfxfocusrealm.cpp @@ -63,7 +63,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FocusRealm,QFxFocusRealm) QFxFocusRealm::QFxFocusRealm(QFxItem *parent) : QFxItem(parent) { - setOptions(IsFocusRealm); + setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); } QFxFocusRealm::~QFxFocusRealm() diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 8df6f2a..eb85c20 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -325,7 +325,7 @@ public: void QFxGridViewPrivate::init() { Q_Q(QFxGridView); - q->setOptions(QFxGridView::IsFocusRealm); + q->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(sizeChange())); QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(sizeChange())); } diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 5eb2516..b658563 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1622,17 +1622,6 @@ QPointF QFxItemPrivate::computeTransformOrigin() const } } -QFxItem::Options QFxItem::options() const -{ - Q_D(const QFxItem); - return (QFxItem::Options)d->options; -} - -bool QFxItem::mouseFilter(QGraphicsSceneMouseEvent *) -{ - return false; -} - bool QFxItem::sceneEvent(QEvent *event) { bool rv = QGraphicsItem::sceneEvent(event); @@ -1851,44 +1840,6 @@ bool QFxItem::hasActiveFocus() const return QGraphicsItem::hasFocus(); } -bool QFxItem::sceneEventFilter(QGraphicsItem *w, QEvent *e) -{ - switch(e->type()) { - case QEvent::GraphicsSceneMouseDoubleClick: - case QEvent::GraphicsSceneMouseMove: - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseRelease: - if (mouseFilter(static_cast(e))) - return true; - break; - default: - break; - } - - return QGraphicsItem::sceneEventFilter(w, e); -} - -void QFxItem::setOptions(Options options, bool set) -{ - Q_D(QFxItem); - Options old = (Options)d->options; - - if (options & IsFocusRealm) { - if (!set) { - qWarning("QFxItem::setOptions: Cannot unset IsFocusRealm"); - return; - } - } - - if (set) - d->options |= options; - else - d->options &= ~options; - - setFiltersChildEvents(d->options & ChildMouseFilter); - setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy, d->options & IsFocusRealm); -} - void QFxItem::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) { } diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index d9a7621..e832a67 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -151,11 +151,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_CLASSINFO("DefaultProperty", "data") public: - enum Option { NoOption = 0x00000000, - ChildMouseFilter = 0x00000002, - IsFocusRealm = 0x00000080 }; - Q_DECLARE_FLAGS(Options, Option) - enum TransformOrigin { TopLeft, Top, TopRight, Left, Center, Right, @@ -193,9 +188,6 @@ public: bool keepMouseGrab() const; void setKeepMouseGrab(bool); - Options options() const; - void setOptions(Options, bool set = true); - qreal width() const; void setWidth(qreal); @@ -227,11 +219,9 @@ Q_SIGNALS: protected: bool isComponentComplete() const; - virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); virtual bool sceneEvent(QEvent *); virtual bool event(QEvent *); virtual QVariant itemChange(GraphicsItemChange, const QVariant &); - virtual bool mouseFilter(QGraphicsSceneMouseEvent *); virtual void mouseUngrabEvent(); void setImplicitWidth(qreal); @@ -272,8 +262,6 @@ private: Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxItem) }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QFxItem::Options) - // ### move to QGO template T qobject_cast(QGraphicsItem *item) diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index ae95fb5..674eada 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -78,7 +78,6 @@ public: _componentComplete(true), _keepMouse(false), _anchorLines(0), _stateGroup(0), origin(QFxItem::TopLeft), - options(QFxItem::NoOption), widthValid(false), heightValid(false), width(0), height(0) {} ~QFxItemPrivate() @@ -177,7 +176,6 @@ public: QmlStateGroup *_stateGroup; QFxItem::TransformOrigin origin:4; - int options:10; bool widthValid:1; bool heightValid:1; diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index a78fed5..f976aec 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -392,7 +392,7 @@ public: void QFxListViewPrivate::init() { Q_Q(QFxListView); - q->setOptions(QFxListView::IsFocusRealm); + q->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(refill())); QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(refill())); } diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index ee3ad2b..17f6dd3 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -535,17 +535,17 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) return false; } -bool QFxPathView::mouseFilter(QGraphicsSceneMouseEvent *e) +bool QFxPathView::sceneEventFilter(QGraphicsItem *i, QEvent *e) { if (!isVisible()) - return false; + return QFxItem::sceneEventFilter(i, e); switch (e->type()) { case QEvent::GraphicsSceneMousePress: case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMouseRelease: { - bool ret = sendMouseEvent(e); + bool ret = sendMouseEvent(static_cast(e)); if (e->type() == QEvent::GraphicsSceneMouseRelease) return ret; break; @@ -554,7 +554,7 @@ bool QFxPathView::mouseFilter(QGraphicsSceneMouseEvent *e) break; } - return false; + return QFxItem::sceneEventFilter(i, e); } void QFxPathViewPrivate::regenerate() diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h index 9d91006..4b8f12d 100644 --- a/src/declarative/fx/qfxpathview.h +++ b/src/declarative/fx/qfxpathview.h @@ -108,7 +108,7 @@ protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *); bool sendMouseEvent(QGraphicsSceneMouseEvent *event); - bool mouseFilter(QGraphicsSceneMouseEvent *e); + bool sceneEventFilter(QGraphicsItem *, QEvent *); private Q_SLOTS: void refill(); diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h index eeccc87..eb5a1b1 100644 --- a/src/declarative/fx/qfxpathview_p.h +++ b/src/declarative/fx/qfxpathview_p.h @@ -87,7 +87,8 @@ public: Q_Q(QFxPathView); _offset = 0; q->setAcceptedMouseButtons(Qt::NoButton); - q->setOptions(QFxItem::ChildMouseFilter | QFxItem::IsFocusRealm); + q->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); + q->setFiltersChildEvents(true); q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); } -- cgit v0.12 From 1d9f240811e4717d1744756b891e0b3d48a918be Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 31 Jul 2009 15:58:51 +1000 Subject: Make QFxScaleGrid private As per API review --- src/declarative/fx/fx.pri | 2 +- src/declarative/fx/qfximage.h | 7 ++- src/declarative/fx/qfximage_p.h | 1 + src/declarative/fx/qfxitem.cpp | 1 - src/declarative/fx/qfxscalegrid.cpp | 2 +- src/declarative/fx/qfxscalegrid.h | 119 ------------------------------------ src/declarative/fx/qfxscalegrid_p.h | 119 ++++++++++++++++++++++++++++++++++++ src/declarative/fx/qfxwebview.cpp | 1 - 8 files changed, 126 insertions(+), 126 deletions(-) delete mode 100644 src/declarative/fx/qfxscalegrid.h create mode 100644 src/declarative/fx/qfxscalegrid_p.h diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index e43c0cb..2c98dd3 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -31,7 +31,7 @@ HEADERS += \ fx/qfxrect_p.h \ fx/qfxrepeater.h \ fx/qfxrepeater_p.h \ - fx/qfxscalegrid.h \ + fx/qfxscalegrid_p.h \ fx/qfxlineedit.h \ fx/qfxlineedit_p.h \ fx/qfxtextedit.h \ diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 9ab4456..9c2ef30 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -43,7 +43,6 @@ #define QFXIMAGE_H #include -#include #include @@ -53,6 +52,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QFxImagePrivate; +class QFxScaleGrid; +class QFxGridScaledImage; + class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem { Q_OBJECT @@ -72,8 +74,6 @@ public: QFxImage(QFxItem *parent=0); ~QFxImage(); - QFxScaleGrid *scaleGrid(); - enum FillMode { Stretch, PreserveAspect, Tile, TileVertically, TileHorizontally }; FillMode fillMode() const; void setFillMode(FillMode); @@ -112,6 +112,7 @@ private: Q_DISABLE_COPY(QFxImage) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxImage) void setGridScaledImage(const QFxGridScaledImage& sci); + QFxScaleGrid *scaleGrid(); }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h index 32529c4..41b628c 100644 --- a/src/declarative/fx/qfximage_p.h +++ b/src/declarative/fx/qfximage_p.h @@ -54,6 +54,7 @@ // #include "qfxitem_p.h" +#include "qfxscalegrid_p.h" #include diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 5eb2516..6488e0d 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -55,7 +55,6 @@ #include "qlistmodelinterface.h" #include "qfxanchors_p.h" -#include "qfxscalegrid.h" #include "qfxview.h" #include "qmlstategroup.h" diff --git a/src/declarative/fx/qfxscalegrid.cpp b/src/declarative/fx/qfxscalegrid.cpp index abe8e0d..74ef0a1 100644 --- a/src/declarative/fx/qfxscalegrid.cpp +++ b/src/declarative/fx/qfxscalegrid.cpp @@ -41,7 +41,7 @@ #include #include -#include "qfxscalegrid.h" +#include "qfxscalegrid_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h deleted file mode 100644 index 986bcda..0000000 --- a/src/declarative/fx/qfxscalegrid.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** 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 QFXSCALEGRID_H -#define QFXSCALEGRID_H - -#include -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class Q_DECLARATIVE_EXPORT QFxScaleGrid : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int left READ left WRITE setLeft) - Q_PROPERTY(int top READ top WRITE setTop) - Q_PROPERTY(int right READ right WRITE setRight) - Q_PROPERTY(int bottom READ bottom WRITE setBottom) -public: - QFxScaleGrid(); - ~QFxScaleGrid(); - - bool isNull() const; - - int left() const { return _left; } - void setLeft(int); - - int top() const { return _top; } - void setTop(int); - - int right() const { return _right; } - void setRight(int); - - int bottom() const { return _bottom; } - void setBottom(int); - -private: - int _left; - int _top; - int _right; - int _bottom; -}; - -class Q_DECLARATIVE_EXPORT QFxGridScaledImage -{ -public: - QFxGridScaledImage(); - QFxGridScaledImage(const QFxGridScaledImage &); - QFxGridScaledImage(QIODevice*); - QFxGridScaledImage &operator=(const QFxGridScaledImage &); - bool isValid() const; - int gridLeft() const; - int gridRight() const; - int gridTop() const; - int gridBottom() const; - - QString pixmapUrl() const; - -private: - int _l; - int _r; - int _t; - int _b; - QString _pix; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxScaleGrid) - -QT_END_HEADER - -#endif // QFXSCALEGRID_H diff --git a/src/declarative/fx/qfxscalegrid_p.h b/src/declarative/fx/qfxscalegrid_p.h new file mode 100644 index 0000000..986bcda --- /dev/null +++ b/src/declarative/fx/qfxscalegrid_p.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** 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 QFXSCALEGRID_H +#define QFXSCALEGRID_H + +#include +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class Q_DECLARATIVE_EXPORT QFxScaleGrid : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int left READ left WRITE setLeft) + Q_PROPERTY(int top READ top WRITE setTop) + Q_PROPERTY(int right READ right WRITE setRight) + Q_PROPERTY(int bottom READ bottom WRITE setBottom) +public: + QFxScaleGrid(); + ~QFxScaleGrid(); + + bool isNull() const; + + int left() const { return _left; } + void setLeft(int); + + int top() const { return _top; } + void setTop(int); + + int right() const { return _right; } + void setRight(int); + + int bottom() const { return _bottom; } + void setBottom(int); + +private: + int _left; + int _top; + int _right; + int _bottom; +}; + +class Q_DECLARATIVE_EXPORT QFxGridScaledImage +{ +public: + QFxGridScaledImage(); + QFxGridScaledImage(const QFxGridScaledImage &); + QFxGridScaledImage(QIODevice*); + QFxGridScaledImage &operator=(const QFxGridScaledImage &); + bool isValid() const; + int gridLeft() const; + int gridRight() const; + int gridTop() const; + int gridBottom() const; + + QString pixmapUrl() const; + +private: + int _l; + int _r; + int _t; + int _b; + QString _pix; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QFxScaleGrid) + +QT_END_HEADER + +#endif // QFXSCALEGRID_H diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 75cb624..47199ef 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -55,7 +55,6 @@ #include "qml.h" #include "qmlengine.h" #include "qmlstate.h" -#include "qfxscalegrid.h" #include "qlistmodelinterface.h" #include "qfxwebview.h" -- cgit v0.12 From 48f64dde600d86d7585140bec3658bb8adc37a45 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 31 Jul 2009 15:59:25 +1000 Subject: Use new enum ints (should be ids!) --- demos/declarative/flickr/content/ImageDetails.qml | 6 +++--- demos/declarative/flickr/flickr.qml | 4 ++-- demos/declarative/flickr/flickr2.qml | 2 +- examples/declarative/snow/ImageBatch.qml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 9d5f069..a18c230 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -79,7 +79,7 @@ Flipable { Rect { anchors.fill: parent; color: "black"; opacity: 0.4; border.color: "white"; border.width: 2 } - Progress { anchors.centerIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status } + Progress { anchors.centerIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status!=1 } Flickable { id: Flick; width: Container.width - 10; height: Container.height - 10 x: 5; y: 5; clip: true; @@ -98,7 +98,7 @@ Flipable { smooth: !Flick.moving onStatusChanged : { // Default scale shows the entire image. - if (status == 0 && width != 0) { + if (status == 1 && width != 0) { Slider.minimum = Math.min(Flick.width / width, Flick.height / height); prevScale = Math.min(Slider.minimum, 1); Slider.value = prevScale; @@ -118,7 +118,7 @@ Flipable { } Slider { - id: Slider; x: 25; y: 374; visible: { BigImage.status == 0 && maximum > minimum } + id: Slider; x: 25; y: 374; visible: { BigImage.status == 1 && maximum > minimum } onValueChanged: { if (BigImage.width * value > Flick.width) { var xoff = (Flick.width/2 + Flick.xPosition) * value / prevScale; diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 21ac284..57fc349 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -66,7 +66,7 @@ Item { Rect { id: WhiteRect; anchors.fill: parent; color: "white"; radius: 5 - Loading { x: 26; y: 26; visible: Thumb.status } + Loading { x: 26; y: 26; visible: Thumb.status!=1 } Image { id: Thumb; source: imagePath; x: 5; y: 5 } Item { @@ -124,7 +124,7 @@ Item { Image { source: "content/pics/background.png"; anchors.fill: parent } - Loading { anchors.centerIn: parent; visible: FeedModel.status != 0 } + Loading { anchors.centerIn: parent; visible: FeedModel.status } GridView { id: PhotoGridView; model: FeedModel; delegate: PhotoDelegate; cacheBuffer: 100 diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index 136e604..c972edf 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -66,7 +66,7 @@ Item { Rect { id: WhiteRect; anchors.fill: parent; color: "white"; radius: 5 - Loading { x: 26; y: 26; visible: Thumb.status } + Loading { x: 26; y: 26; visible: Thumb.status!=1 } Image { id: Thumb; source: imagePath; x: 5; y: 5 } Item { diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml index 8aa4bb2..edf120e 100644 --- a/examples/declarative/snow/ImageBatch.qml +++ b/examples/declarative/snow/ImageBatch.qml @@ -42,8 +42,8 @@ GridView { width: MyGrid.imageWidth; height: MyGrid.imageHeight; Image { id: Image; source: url; fillMode: "PreserveAspect"; smooth: true; anchors.fill: parent; - opacity: (status == 0)?1:0; opacity: Behavior { NumberAnimation { properties: "opacity" } } } - Loading { anchors.centerIn: parent; visible: Image.status } + opacity: (status == 1)?1:0; opacity: Behavior { NumberAnimation { properties: "opacity" } } } + Loading { anchors.centerIn: parent; visible: Image.status!=1 } states: State { name: "selected" -- cgit v0.12 From fb496d96b65a9e470d46d73ede00cf58a519a80f Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Sat, 1 Aug 2009 21:28:29 +1000 Subject: Add CONSTANT --- src/declarative/fx/qfxlineedit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h index 0f56818..846ef52 100644 --- a/src/declarative/fx/qfxlineedit.h +++ b/src/declarative/fx/qfxlineedit.h @@ -60,7 +60,7 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QmlFont *font READ font) + Q_PROPERTY(QmlFont *font READ font CONSTANT) Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(QFxText::HAlignment hAlign READ hAlign WRITE setHAlign) -- cgit v0.12 From 28c809e996963ba938ce05590da44d260ce70c75 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Sat, 1 Aug 2009 23:58:29 +1000 Subject: Documentation --- src/declarative/fx/qfximage.cpp | 4 +- src/declarative/fx/qfxloader.cpp | 2 +- src/declarative/util/qmlfontfamily.cpp | 38 +++++++++-- src/declarative/util/qmlpalette.cpp | 118 ++++++++++++++++++++++++++++----- src/declarative/util/qmlpalette.h | 1 + src/declarative/util/qmlscript.cpp | 2 +- 6 files changed, 140 insertions(+), 25 deletions(-) diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 605e1ea..5976cd5 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -455,7 +455,7 @@ void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) \list \o Null - no image has been set \o Ready - the image has been loaded - \o Loading - the images is currently being loaded + \o Loading - the image is currently being loaded \o Error - an error occurred while loading the image \endlist @@ -484,7 +484,7 @@ qreal QFxImage::progress() const } /*! - \qmlproperty string Image::source + \qmlproperty url Image::source Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. diff --git a/src/declarative/fx/qfxloader.cpp b/src/declarative/fx/qfxloader.cpp index 7cf85af..6d06ee9 100644 --- a/src/declarative/fx/qfxloader.cpp +++ b/src/declarative/fx/qfxloader.cpp @@ -174,7 +174,7 @@ void QFxLoaderPrivate::_q_sourceLoaded() } /*! - \qmlproperty url Loader::item + \qmlproperty Item Loader::item This property holds the top-level item created from source. */ QFxItem *QFxLoader::item() const diff --git a/src/declarative/util/qmlfontfamily.cpp b/src/declarative/util/qmlfontfamily.cpp index a82527b..73688c1 100644 --- a/src/declarative/util/qmlfontfamily.cpp +++ b/src/declarative/util/qmlfontfamily.cpp @@ -74,12 +74,13 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,FontFamily,QmlFontFamily) \ingroup group_utility \brief This item allows using fonts by name or url. + Example: \code - FontFamily { id: FixedFont; name: "Courier" } - FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + FontFamily { id: FixedFont; name: "Courier" } + FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } - Text { text: "Fixed-size font"; font.family: FixedFont.name } - Text { text: "Fancy font"; font.family: WebFont.name } + Text { text: "Fixed-size font"; font.family: FixedFont.name } + Text { text: "Fancy font"; font.family: WebFont.name } \endcode */ QmlFontFamily::QmlFontFamily(QObject *parent) @@ -92,8 +93,8 @@ QmlFontFamily::~QmlFontFamily() } /*! - \qmlproperty FontFamily::source - The source for the font. + \qmlproperty url FontFamily::source + The url of the font to load. */ QUrl QmlFontFamily::source() const { @@ -126,6 +127,20 @@ void QmlFontFamily::setSource(const QUrl &url) } } +/*! + \qmlproperty string FontFamily::name + + This property holds the name of the font family. + It is set automatically when a font is loaded using the \c url property. + + Use this to set the \c font.family property of a \c Text item. + + Example: + \qml + FontFamily { id: WebFont; source: "http://www.mysite.com/myfont.ttf" } + Text { text: "Fancy font"; font.family: WebFont.name } + \endqml +*/ QString QmlFontFamily::name() const { Q_D(const QmlFontFamily); @@ -141,6 +156,17 @@ void QmlFontFamily::setName(const QString &name) emit nameChanged(); } +/*! + \qmlproperty enum FontFamily::status + + This property holds the status of font loading. It can be one of: + \list + \o Null - no font has been set + \o Ready - the font has been loaded + \o Loading - the font is currently being loaded + \o Error - an error occurred while loading the font + \endlist +*/ QmlFontFamily::Status QmlFontFamily::status() const { Q_D(const QmlFontFamily); diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp index 25576f1..6fade03 100644 --- a/src/declarative/util/qmlpalette.cpp +++ b/src/declarative/util/qmlpalette.cpp @@ -60,19 +60,19 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Palette,QmlPalette) \brief The Palette item gives access to the Qt palettes. \sa QPalette - + Example: \code - Palette { id: MyPalette; colorGroup: "Active" } - - Rect { - width: 640; height: 480 - color: MyPalette.window - Text { - anchors.fill: parent - text: "Hello!"; color: MyPalette.windowText - } + Palette { id: MyPalette; colorGroup: "Active" } + + Rect { + width: 640; height: 480 + color: MyPalette.window + Text { + anchors.fill: parent + text: "Hello!"; color: MyPalette.windowText } - \endcode + } + \endcode */ QmlPalette::QmlPalette(QObject *parent) : QObject(*(new QmlPalettePrivate), parent) @@ -88,8 +88,10 @@ QmlPalette::~QmlPalette() } /*! - \qmlproperty Palette::window - \brief The window (general background) color of the current color group. + \qmlproperty color Palette::window + The window (general background) color of the current color group. + + \sa QPalette::ColorRole */ QColor QmlPalette::window() const { @@ -98,8 +100,10 @@ QColor QmlPalette::window() const } /*! - \qmlproperty Palette::windowText - \brief The window text (general foreground) color of the current color group. + \qmlproperty color Palette::windowText + The window text (general foreground) color of the current color group. + + \sa QPalette::ColorRole */ QColor QmlPalette::windowText() const { @@ -107,82 +111,166 @@ QColor QmlPalette::windowText() const return d->palette.color(d->group, QPalette::WindowText); } +/*! + \qmlproperty color Palette::base + The base color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::base() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Base); } +/*! + \qmlproperty color Palette::alternateBase + The alternate base color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::alternateBase() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::AlternateBase); } +/*! + \qmlproperty color Palette::button + The button color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::button() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Button); } +/*! + \qmlproperty color Palette::buttonText + The button text foreground color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::buttonText() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::ButtonText); } +/*! + \qmlproperty color Palette::light + The light color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::light() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Light); } +/*! + \qmlproperty color Palette::midlight + The midlight color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::midlight() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Midlight); } +/*! + \qmlproperty color Palette::dark + The dark color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::dark() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Dark); } +/*! + \qmlproperty color Palette::mid + The mid color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::mid() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Mid); } +/*! + \qmlproperty color Palette::shadow + The shadow color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::shadow() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Shadow); } +/*! + \qmlproperty color Palette::highlight + The highlight color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::highlight() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::Highlight); } +/*! + \qmlproperty color Palette::highlightedText + The highlighted text color of the current color group. + + \sa QPalette::ColorRole +*/ QColor QmlPalette::highlightedText() const { Q_D(const QmlPalette); return d->palette.color(d->group, QPalette::HighlightedText); } +/*! + \qmlproperty color Palette::lighter +*/ QColor QmlPalette::lighter(const QColor& color) const { return color.lighter(); } +/*! + \qmlproperty color Palette::darker +*/ QColor QmlPalette::darker(const QColor& color) const { return color.darker(); } +/*! + \qmlproperty enum Palette::colorGroup + + The color group of the palette. It can be one of: + \list + \o Active - used for the window that has focus. + \o Inactive - used for other windows. + \o Disabled - used for widgets that are disabled for some reason. + \endlist + + \sa QPalette::ColorGroup +*/ QmlPalette::ColorGroup QmlPalette::colorGroup() const { Q_D(const QmlPalette); diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h index b601881..7de5e0e 100644 --- a/src/declarative/util/qmlpalette.h +++ b/src/declarative/util/qmlpalette.h @@ -102,6 +102,7 @@ public: ColorGroup colorGroup() const; void setColorGroup(ColorGroup); + // FIXME: Move to utility class? Q_INVOKABLE QColor lighter(const QColor&) const; Q_INVOKABLE QColor darker(const QColor&) const; diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index ca9aad5..5651981 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -127,7 +127,7 @@ void QmlScript::setScript(const QString &script) } /*! - \qmlproperty string Script::source + \qmlproperty url Script::source Setting this property causes the Script element to read JavaScript code from the file specified. -- cgit v0.12