summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-08-10 00:25:29 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-08-10 00:25:29 (GMT)
commit4cbb70502828d0cac808e891f3b9e586c9c9b0c1 (patch)
treebdaadfde810d450f94085f7bfe28008d900893de
parentb1f10dc22091f80fba651e32e824175f25956313 (diff)
parentc4235f6f90613f1a877da067354b912ef0004259 (diff)
downloadQt-4cbb70502828d0cac808e891f3b9e586c9c9b0c1.zip
Qt-4cbb70502828d0cac808e891f3b9e586c9c9b0c1.tar.gz
Qt-4cbb70502828d0cac808e891f3b9e586c9c9b0c1.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/MediaLineEdit.qml4
-rw-r--r--examples/declarative/border-image/MyBorderImage.qml (renamed from examples/declarative/border-image/BorderImage.qml)14
-rw-r--r--examples/declarative/border-image/animated.qml16
-rw-r--r--examples/declarative/border-image/borders.qml4
-rw-r--r--src/declarative/fx/fx.pri6
-rw-r--r--src/declarative/fx/qfxborderimage.cpp410
-rw-r--r--src/declarative/fx/qfxborderimage.h101
-rw-r--r--src/declarative/fx/qfxborderimage_p.h94
-rw-r--r--src/declarative/fx/qfximage.cpp437
-rw-r--r--src/declarative/fx/qfximage.h36
-rw-r--r--src/declarative/fx/qfximage_p.h40
-rw-r--r--src/declarative/fx/qfximagebase.cpp182
-rw-r--r--src/declarative/fx/qfximagebase.h90
-rw-r--r--src/declarative/fx/qfximagebase_p.h82
-rw-r--r--src/declarative/fx/qfxitem.cpp14
-rw-r--r--src/declarative/fx/qfxlineedit.cpp15
-rw-r--r--src/declarative/fx/qfxpixmap.cpp1
-rw-r--r--src/declarative/fx/qfxrect.cpp13
-rw-r--r--src/declarative/fx/qfxscalegrid.cpp28
-rw-r--r--src/declarative/fx/qfxscalegrid_p.h24
-rw-r--r--src/declarative/fx/qfxtext.cpp13
-rw-r--r--src/declarative/fx/qfxtextedit.cpp15
22 files changed, 1143 insertions, 496 deletions
diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml
index b8d30ce..4a55ff5 100644
--- a/demos/declarative/flickr/content/MediaLineEdit.qml
+++ b/demos/declarative/flickr/content/MediaLineEdit.qml
@@ -47,14 +47,14 @@ Item {
]
- Image {
+ BorderImage {
id: Image
source: "pics/button.sci"
anchors.left: Container.left
anchors.right: Container.right
}
- Image {
+ BorderImage {
id: Pressed
source: "pics/button-pressed.sci"
opacity: 0
diff --git a/examples/declarative/border-image/BorderImage.qml b/examples/declarative/border-image/MyBorderImage.qml
index a809d5d..f9531df 100644
--- a/examples/declarative/border-image/BorderImage.qml
+++ b/examples/declarative/border-image/MyBorderImage.qml
@@ -12,7 +12,7 @@ Item {
id: Container
width: 240; height: 240
- Image {
+ BorderImage {
x: Container.width / 2 - width / 2
y: Container.height / 2 - height / 2
width: SequentialAnimation {
@@ -26,11 +26,11 @@ Item {
NumberAnimation { from: Container.maxHeight; to: Container.minHeight; duration: 2000; easing: "easeInOutQuad" }
}
source: Container.source
- scaleGrid.horizontalTileRule: Container.horizontalMode
- scaleGrid.verticalTileRule: Container.verticalMode
- scaleGrid.top: Container.margin
- scaleGrid.left: Container.margin
- scaleGrid.bottom: Container.margin
- scaleGrid.right: Container.margin
+ horizontalTileMode: Container.horizontalMode
+ verticalTileMode: Container.verticalMode
+ border.top: Container.margin
+ border.left: Container.margin
+ border.bottom: Container.margin
+ border.right: Container.margin
}
}
diff --git a/examples/declarative/border-image/animated.qml b/examples/declarative/border-image/animated.qml
index 58eb44c..ce4de16 100644
--- a/examples/declarative/border-image/animated.qml
+++ b/examples/declarative/border-image/animated.qml
@@ -5,47 +5,47 @@ Rect {
color: "white"
width: 1030; height: 540
- BorderImage {
+ MyBorderImage {
x: 20; y: 20; minWidth: 120; maxWidth: 240
minHeight: 120; maxHeight: 240
source: "colors.png"; margin: 30
}
- BorderImage {
+ MyBorderImage {
x: 270; y: 20; minWidth: 120; maxWidth: 240
minHeight: 120; maxHeight: 240
source: "colors.png"; margin: 30
horizontalMode: "Repeat"; verticalMode: "Repeat"
}
- BorderImage {
+ MyBorderImage {
x: 520; y: 20; minWidth: 120; maxWidth: 240
minHeight: 120; maxHeight: 240
source: "colors.png"; margin: 30
horizontalMode: "Stretch"; verticalMode: "Repeat"
}
- BorderImage {
+ MyBorderImage {
x: 770; y: 20; minWidth: 120; maxWidth: 240
minHeight: 120; maxHeight: 240
source: "colors.png"; margin: 30
horizontalMode: "Round"; verticalMode: "Round"
}
- BorderImage {
+ MyBorderImage {
x: 20; y: 280; minWidth: 60; maxWidth: 200
minHeight: 40; maxHeight: 200
source: "bw.png"; margin: 10
}
- BorderImage {
+ MyBorderImage {
x: 270; y: 280; minWidth: 60; maxWidth: 200
minHeight: 40; maxHeight: 200
source: "bw.png"; margin: 10
horizontalMode: "Repeat"; verticalMode: "Repeat"
}
- BorderImage {
+ MyBorderImage {
x: 520; y: 280; minWidth: 60; maxWidth: 200
minHeight: 40; maxHeight: 200
source: "bw.png"; margin: 10
horizontalMode: "Stretch"; verticalMode: "Repeat"
}
- BorderImage {
+ MyBorderImage {
x: 770; y: 280; minWidth: 60; maxWidth: 200
minHeight: 40; maxHeight: 200
source: "bw.png"; margin: 10
diff --git a/examples/declarative/border-image/borders.qml b/examples/declarative/border-image/borders.qml
index a4a329b..e8c581e 100644
--- a/examples/declarative/border-image/borders.qml
+++ b/examples/declarative/border-image/borders.qml
@@ -5,12 +5,12 @@ Rect {
color: "white"
width: 520; height: 280
- Image {
+ BorderImage {
x: 20; y: 20; width: 230; height: 240
smooth: true
source: "colors-stretch.sci"
}
- Image {
+ BorderImage {
x: 270; y: 20; width: 230; height: 240
smooth: true
source: "colors-round.sci"
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index a6c5281..34f4f67 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -9,9 +9,13 @@ HEADERS += \
fx/qfxflipable.h \
fx/qfxgridview.h \
fx/qfximage.h \
+ fx/qfximagebase.h \
+ fx/qfxborderimage.h \
fx/qfxpainteditem.h \
fx/qfxpainteditem_p.h \
fx/qfximage_p.h \
+ fx/qfxborderimage_p.h \
+ fx/qfximagebase_p.h \
fx/qfxitem.h \
fx/qfxitem_p.h \
fx/qfxfocusscope.h \
@@ -52,6 +56,8 @@ SOURCES += \
fx/qfxflipable.cpp \
fx/qfxgridview.cpp \
fx/qfximage.cpp \
+ fx/qfxborderimage.cpp \
+ fx/qfximagebase.cpp \
fx/qfxpainteditem.cpp \
fx/qfxitem.cpp \
fx/qfxfocusscope.cpp \
diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp
new file mode 100644
index 0000000..7e2e3c6
--- /dev/null
+++ b/src/declarative/fx/qfxborderimage.cpp
@@ -0,0 +1,410 @@
+/****************************************************************************
+**
+** 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 "qfxborderimage.h"
+#include "qfxborderimage_p.h"
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QFile>
+#include <QtDeclarative/qmlengine.h>
+
+QT_BEGIN_NAMESPACE
+
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,BorderImage,QFxBorderImage)
+
+/*!
+ \qmlclass BorderImage QFxBorderImage
+ \brief The BorderImage element allows you to add an image used as a border to a scene.
+ \inherits Item
+
+ Example:
+ \qml
+ BorderImage { border.left: 20; border.right: 10
+ border.top: 14; border.bottom: 14
+ width: 160; height: 160
+ source: "pics/qtlogo.png"
+ }
+ \endqml
+ */
+
+/*!
+ \internal
+ \class QFxBorderImage BorderImage
+ \brief The QFxBorderImage class provides an image item that you can add to a QFxView.
+
+ \ingroup group_coreitems
+
+ Example:
+ \qml
+ BorderImage { source: "pics/star.png" }
+ \endqml
+
+ A QFxBorderImage object can be instantiated in Qml using the tag \l BorderImage.
+*/
+
+QFxBorderImage::QFxBorderImage(QFxItem *parent)
+ : QFxImageBase(*(new QFxBorderImagePrivate), parent)
+{
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+}
+
+QFxBorderImage::~QFxBorderImage()
+{
+ Q_D(QFxBorderImage);
+ if (d->sciReply)
+ d->sciReply->deleteLater();
+ if (!d->sciurl.isEmpty())
+ QFxPixmap::cancelGet(d->sciurl, this);
+}
+/*!
+ \qmlproperty enum BorderImage::status
+
+ This property holds the status of image loading. It can be one of:
+ \list
+ \o Null - no image has been set
+ \o Ready - the image has been loaded
+ \o Loading - the image is currently being loaded
+ \o Error - an error occurred while loading the image
+ \endlist
+
+ \sa progress
+*/
+
+/*!
+ \qmlproperty real BorderImage::progress
+
+ This property holds the progress of image loading, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+
+ \sa status
+*/
+
+/*!
+ \qmlproperty bool BorderImage::smooth
+
+ Set this property if you want the image to be smoothly filtered when scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the image is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
+/*!
+ \qmlproperty url BorderImage::source
+
+ BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
+
+ It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies
+ \list
+ \i the grid lines describing a \l {BorderImage::border.left}{scale grid}.
+ \i an image file.
+ \endlist
+
+ The following .sci file sets grid line offsets of 10 on each side for the image \c picture.png:
+ \code
+ gridLeft: 10
+ gridTop: 10
+ gridBottom: 10
+ gridRight: 10
+ imageFile: picture.png
+ \endcode
+
+ The URL may be absolute, or relative to the URL of the component.
+*/
+
+void QFxBorderImage::setSource(const QUrl &url)
+{
+ Q_D(QFxBorderImage);
+ //equality is fairly expensive, so we bypass for simple, common case
+ if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
+ return;
+
+ if (d->sciReply) {
+ d->sciReply->deleteLater();
+ d->sciReply = 0;
+ }
+
+ if (!d->url.isEmpty())
+ QFxPixmap::cancelGet(d->url, this);
+ if (!d->sciurl.isEmpty())
+ QFxPixmap::cancelGet(d->sciurl, this);
+
+ d->url = url;
+ d->sciurl = QUrl();
+ if (d->progress != 0.0) {
+ d->progress = 0.0;
+ emit progressChanged(d->progress);
+ }
+
+ if (url.isEmpty()) {
+ d->pix = QPixmap();
+ d->status = Null;
+ d->progress = 1.0;
+ setImplicitWidth(0);
+ setImplicitHeight(0);
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+ } else {
+ d->status = Loading;
+ if (d->url.path().endsWith(QLatin1String(".sci"))) {
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+ if (d->url.scheme() == QLatin1String("file")) {
+ QFile file(d->url.toLocalFile());
+ file.open(QIODevice::ReadOnly);
+ setGridScaledImage(QFxGridScaledImage(&file));
+ } else
+#endif
+ {
+ QNetworkRequest req(d->url);
+ req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
+ d->sciReply = qmlEngine(this)->networkAccessManager()->get(req);
+ QObject::connect(d->sciReply, SIGNAL(finished()),
+ this, SLOT(sciRequestFinished()));
+ }
+ } else {
+ d->reply = QFxPixmap::get(qmlEngine(this), d->url, &d->pix);
+ if (d->reply) {
+ connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ } else {
+ //### should be unified with requestFinished
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+ }
+ }
+ }
+
+ emit statusChanged(d->status);
+}
+
+/*!
+ \qmlproperty int BorderImage::border.left
+ \qmlproperty int BorderImage::border.right
+ \qmlproperty int BorderImage::border.top
+ \qmlproperty int BorderImage::border.bottom
+
+ \target ImagexmlpropertiesscaleGrid
+
+ A scale grid uses 4 grid lines (2 horizontal and 2 vertical) to break an image into 9 sections, as shown below:
+
+ \image declarative-scalegrid.png
+
+ When the image is scaled:
+ \list
+ \i the corners (sections 1, 3, 7, and 9) are not scaled at all
+ \i the middle (section 5) is scaled both horizontally and vertically
+ \i sections 2 and 8 are scaled horizontally
+ \i sections 4 and 6 are scaled vertically
+ \endlist
+
+ Each scale grid property (left, right, top, and bottom) specifies an offset from the respective side. For example, \c{border.bottom: 10} sets the bottom scale grid line 10 pixels up from the bottom of the image.
+
+ A scale grid can also be specified using a
+ \l {BorderImage::source}{.sci file}.
+*/
+
+QFxScaleGrid *QFxBorderImage::border()
+{
+ Q_D(QFxBorderImage);
+ return d->getScaleGrid();
+}
+
+/*!
+ \qmlproperty TileMode BorderImage::horizontalTileMode
+ \qmlproperty TileMode BorderImage::verticalTileMode
+
+ This property describes how to repeat or stretch the middle parts of the border image.
+
+ \list
+ \o Stretch - Scale the image to fit to the available area.
+ \o Repeat - Tile the image until there is no more space. May crop the last image.
+ \o Round - Like Repeat, but scales the images down to ensure that the last image is not cropped.
+ \endlist
+
+ \sa examples/declarative/border-image
+*/
+QFxBorderImage::TileMode QFxBorderImage::horizontalTileMode() const
+{
+ Q_D(const QFxBorderImage);
+ return d->horizontalTileMode;
+}
+
+void QFxBorderImage::setHorizontalTileMode(TileMode t)
+{
+ Q_D(QFxBorderImage);
+ d->horizontalTileMode = t;
+}
+
+QFxBorderImage::TileMode QFxBorderImage::verticalTileMode() const
+{
+ Q_D(const QFxBorderImage);
+ return d->verticalTileMode;
+}
+
+void QFxBorderImage::setVerticalTileMode(TileMode t)
+{
+ Q_D(QFxBorderImage);
+ d->verticalTileMode = t;
+}
+
+void QFxBorderImage::setGridScaledImage(const QFxGridScaledImage& sci)
+{
+ Q_D(QFxBorderImage);
+ if (!sci.isValid()) {
+ d->status = Error;
+ emit statusChanged(d->status);
+ } else {
+ QFxScaleGrid *sg = border();
+ sg->setTop(sci.gridTop());
+ sg->setBottom(sci.gridBottom());
+ sg->setLeft(sci.gridLeft());
+ sg->setRight(sci.gridRight());
+ d->horizontalTileMode = sci.horizontalTileRule();
+ d->verticalTileMode = sci.verticalTileRule();
+
+ d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
+ d->reply = QFxPixmap::get(qmlEngine(this), d->sciurl, &d->pix);
+ if (d->reply) {
+ connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ } else {
+ //### should be unified with requestFinished
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+ }
+ }
+}
+
+void QFxBorderImage::requestFinished()
+{
+ Q_D(QFxBorderImage);
+ if (d->url.path().endsWith(QLatin1String(".sci"))) {
+ QFxPixmap::find(d->sciurl, &d->pix);
+ } else {
+ if (d->reply) {
+ //###disconnect really needed?
+ disconnect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ if (d->reply->error() != QNetworkReply::NoError)
+ d->status = Error;
+ }
+ QFxPixmap::find(d->url, &d->pix);
+ }
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+}
+
+void QFxBorderImage::sciRequestFinished()
+{
+ Q_D(QFxBorderImage);
+ if (d->sciReply->error() != QNetworkReply::NoError) {
+ d->status = Error;
+ d->sciReply->deleteLater();
+ d->sciReply = 0;
+ emit statusChanged(d->status);
+ } else {
+ QFxGridScaledImage sci(d->sciReply);
+ d->sciReply->deleteLater();
+ d->sciReply = 0;
+ setGridScaledImage(sci);
+ }
+}
+
+void QFxBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ Q_D(QFxBorderImage);
+ if (d->pix.isNull())
+ return;
+
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+
+ QPixmap pix = d->pix;
+
+ QMargins margins(border()->top(), border()->left(), border()->bottom(), border()->right());
+ QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode);
+ qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, pix, pix.rect(), margins, rules);
+ if (d->smooth) {
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ }
+}
+
+QFxBorderImage::QFxBorderImage(QFxBorderImagePrivate &dd, QFxItem *parent)
+ : QFxImageBase(dd, parent)
+{
+ setFlag(QGraphicsItem::ItemHasNoContents, false);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxborderimage.h b/src/declarative/fx/qfxborderimage.h
new file mode 100644
index 0000000..26ba9cf
--- /dev/null
+++ b/src/declarative/fx/qfxborderimage.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** 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 QFXBORDERIMAGE_H
+#define QFXBORDERIMAGE_H
+
+#include <QtNetwork/qnetworkreply.h>
+#include "qfximagebase.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QFxScaleGrid;
+class QFxGridScaledImage;
+class QFxBorderImagePrivate;
+class Q_DECLARATIVE_EXPORT QFxBorderImage : public QFxImageBase
+{
+ Q_OBJECT
+ Q_ENUMS(TileMode)
+
+ Q_PROPERTY(QFxScaleGrid *border READ border CONSTANT)
+ Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode)
+ Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode)
+
+public:
+ QFxBorderImage(QFxItem *parent=0);
+ ~QFxBorderImage();
+
+ QFxScaleGrid *border();
+
+ enum TileMode { Stretch = Qt::Stretch, Repeat = Qt::Repeat, Round = Qt::Round };
+
+ TileMode horizontalTileMode() const;
+ void setHorizontalTileMode(TileMode);
+
+ TileMode verticalTileMode() const;
+ void setVerticalTileMode(TileMode);
+
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ void setSource(const QUrl &url);
+
+protected:
+ QFxBorderImage(QFxBorderImagePrivate &dd, QFxItem *parent);
+
+private:
+ void setGridScaledImage(const QFxGridScaledImage& sci);
+
+private Q_SLOTS:
+ void requestFinished();
+ void sciRequestFinished();
+
+private:
+ Q_DISABLE_COPY(QFxBorderImage)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxBorderImage)
+};
+
+QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxBorderImage)
+QT_END_HEADER
+
+#endif // QFXBORDERIMAGE_H
diff --git a/src/declarative/fx/qfxborderimage_p.h b/src/declarative/fx/qfxborderimage_p.h
new file mode 100644
index 0000000..50f3311
--- /dev/null
+++ b/src/declarative/fx/qfxborderimage_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** 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 QFXBORDERIMAGE_P_H
+#define QFXBORDERIMAGE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qfximagebase_p.h"
+#include "qfxscalegrid_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkReply;
+class QFxBorderImagePrivate : public QFxImageBasePrivate
+{
+ Q_DECLARE_PUBLIC(QFxBorderImage)
+
+public:
+ QFxBorderImagePrivate()
+ : border(0), sciReply(0),
+ horizontalTileMode(QFxBorderImage::Stretch),
+ verticalTileMode(QFxBorderImage::Stretch)
+ {
+ }
+
+ ~QFxBorderImagePrivate()
+ {
+ }
+
+ QFxScaleGrid *getScaleGrid()
+ {
+ if (!border)
+ border = new QFxScaleGrid;
+ return border;
+ }
+
+ QFxScaleGrid *border;
+ QUrl sciurl;
+ QNetworkReply *sciReply;
+ QFxBorderImage::TileMode horizontalTileMode;
+ QFxBorderImage::TileMode verticalTileMode;
+};
+
+QT_END_NAMESPACE
+
+#endif // QFXBORDERIMAGE_P_H
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 26e2727..0cb7988 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -41,11 +41,6 @@
#include "qfximage.h"
#include "qfximage_p.h"
-#include <private/qfxperf_p.h>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#include <QFile>
-#include <QtDeclarative/qmlengine.h>
#include <QKeyEvent>
#include <QPainter>
@@ -60,13 +55,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Image,QFxImage)
\brief The Image element allows you to add bitmaps to a scene.
\inherits Item
- The Image element supports untransformed, stretched, tiled, and grid-scaled images.
+ The Image element supports untransformed, stretched and tiled.
For an explanation of stretching and tiling, see the fillMode property description.
- For an explanation of grid-scaling see the scaleGrid property description
- or the QFxScaleGrid class description.
-
Examples:
\table
\row
@@ -86,16 +78,6 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Image,QFxImage)
}
\endqml
\row
- \o \image declarative-qtlogo4.png
- \o Grid-scaled (only with fillMode: Stretch)
- \qml
- Image { scaleGrid.left: 20; scaleGrid.right: 10
- scaleGrid.top: 14; scaleGrid.bottom: 14
- width: 160; height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \row
\o \image declarative-qtlogo3.png
\o fillMode: Tile
\qml
@@ -144,33 +126,26 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Image,QFxImage)
*/
QFxImage::QFxImage(QFxItem *parent)
- : QFxItem(*(new QFxImagePrivate), parent)
+ : QFxImageBase(*(new QFxImagePrivate), parent)
{
setFlag(QGraphicsItem::ItemHasNoContents, false);
}
QFxImage::QFxImage(QFxImagePrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
+ : QFxImageBase(dd, parent)
{
setFlag(QGraphicsItem::ItemHasNoContents, false);
}
QFxImage::~QFxImage()
{
- Q_D(QFxImage);
- if (d->sciReply)
- d->sciReply->deleteLater();
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- if (!d->sciurl.isEmpty())
- QFxPixmap::cancelGet(d->sciurl, this);
}
/*!
- \property QFxImage::image
+ \property QFxImage::pixmap
\brief the image displayed in this item.
- This property contains the image currently being displayed by this item,
+ This property contains the pixmap currently being displayed by this item,
which may be empty if nothing is currently displayed. Setting the source
property overrides any setting of this property.
*/
@@ -194,37 +169,6 @@ void QFxImage::setPixmap(const QPixmap &pix)
}
/*!
- \qmlproperty int Image::scaleGrid.left
- \qmlproperty int Image::scaleGrid.right
- \qmlproperty int Image::scaleGrid.top
- \qmlproperty int Image::scaleGrid.bottom
-
- \target ImagexmlpropertiesscaleGrid
-
- A scale grid uses 4 grid lines (2 horizontal and 2 vertical) to break an image into 9 sections, as shown below:
-
- \image declarative-scalegrid.png
-
- When the image is scaled:
- \list
- \i the corners (sections 1, 3, 7, and 9) are not scaled at all
- \i the middle (section 5) is scaled both horizontally and vertically
- \i sections 2 and 8 are scaled horizontally
- \i sections 4 and 6 are scaled vertically
- \endlist
-
- Each scale grid property (left, right, top, and bottom) specifies an offset from the respective side. For example, \c scaleGrid.bottom="10" sets the bottom scale grid line 10 pixels up from the bottom of the image.
-
- A scale grid can also be specified using a
- \l {Image::source}{.sci file}.
-*/
-QFxScaleGrid *QFxImage::scaleGrid()
-{
- Q_D(QFxImage);
- return d->getScaleGrid();
-}
-
-/*!
\qmlproperty FillMode Image::fillMode
Set this property to define what happens when the image set for the item is smaller
@@ -239,10 +183,6 @@ QFxScaleGrid *QFxImage::scaleGrid()
\endlist
\image declarative-image_fillMode.gif
-
- Only fillMode: Stretch can be used with scaleGrid. Other settings
- will cause a run-time warning.
-
\sa examples/declarative/aspectratio
*/
QFxImage::FillMode QFxImage::fillMode() const
@@ -261,105 +201,6 @@ void QFxImage::setFillMode(FillMode mode)
emit fillModeChanged();
}
-void QFxImage::componentComplete()
-{
- QFxItem::componentComplete();
-}
-
-/*!
- \property QFxImage::scaleGrid
- \brief the 3x3 grid used to scale an image, excluding the corners.
-*/
-
-void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
-{
- Q_D(QFxImage);
- if (d->pix.isNull())
- return;
-
- bool oldAA = p->testRenderHint(QPainter::Antialiasing);
- bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
- if (d->smooth)
- p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
-
- QPixmap pix = d->pix;
-
- if (!d->scaleGrid || d->scaleGrid->isNull()) {
- if (width() != pix.width() || height() != pix.height()) {
- if (d->fillMode >= Tile) {
- p->save();
- p->setClipRect(0, 0, width(), height(), Qt::IntersectClip);
-
- if (d->fillMode == Tile) {
- const int pw = pix.width();
- const int ph = pix.height();
- int yy = 0;
-
- while(yy < height()) {
- int xx = 0;
- while(xx < width()) {
- p->drawPixmap(xx, yy, pix);
- xx += pw;
- }
- yy += ph;
- }
- } else if (d->fillMode == TileVertically) {
- const int ph = pix.height();
- int yy = 0;
-
- while(yy < height()) {
- p->drawPixmap(QRect(0, yy, width(), ph), pix);
- yy += ph;
- }
- } else {
- const int pw = pix.width();
- int xx = 0;
-
- while(xx < width()) {
- p->drawPixmap(QRect(xx, 0, pw, height()), pix);
- xx += pw;
- }
- }
-
- p->restore();
- } else {
- qreal widthScale = width() / qreal(pix.width());
- qreal heightScale = height() / qreal(pix.height());
-
- QTransform scale;
-
- if (d->fillMode == PreserveAspect) {
- if (widthScale < heightScale) {
- heightScale = widthScale;
- scale.translate(0, (height() - heightScale * pix.height()) / 2);
- } else if(heightScale < widthScale) {
- widthScale = heightScale;
- scale.translate((width() - widthScale * pix.width()) / 2, 0);
- }
- }
-
- scale.scale(widthScale, heightScale);
- QTransform old = p->transform();
- p->setWorldTransform(scale * old);
- p->drawPixmap(0, 0, pix);
- p->setWorldTransform(old);
- }
- } else {
- p->drawPixmap(0, 0, pix);
- }
- } else {
- QMargins margins(d->scaleGrid->top(), d->scaleGrid->left(), d->scaleGrid->bottom(), d->scaleGrid->right());
- QTileRules rules((Qt::TileRule)d->scaleGrid->horizontalTileRule(),
- (Qt::TileRule)d->scaleGrid->verticalTileRule());
- qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, pix, pix.rect(), margins, rules);
- }
-
- if (d->smooth) {
- p->setRenderHint(QPainter::Antialiasing, oldAA);
- p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
- }
-}
-
/*!
\qmlproperty enum Image::status
@@ -374,12 +215,6 @@ void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
\sa progress
*/
-QFxImage::Status QFxImage::status() const
-{
- Q_D(const QFxImage);
- return d->status;
-}
-
/*!
\qmlproperty real Image::progress
@@ -389,215 +224,107 @@ QFxImage::Status QFxImage::status() const
\sa status
*/
-qreal QFxImage::progress() const
-{
- Q_D(const QFxImage);
- return d->progress;
-}
-
/*!
- \qmlproperty url Image::source
-
- Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
+ \qmlproperty bool Image::smooth
- It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies
- \list
- \i the grid lines describing a \l {Image::scaleGrid.left}{scale grid}.
- \i an image file.
- \endlist
-
- The following .sci file sets grid line offsets of 10 on each side for the image \c picture.png:
- \code
- gridLeft: 10
- gridTop: 10
- gridBottom: 10
- gridRight: 10
- imageFile: picture.png
- \endcode
+ Set this property if you want the image to be smoothly filtered when scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the image is displayed at its natural size, this property has no visual or
+ performance effect.
- The URL may be absolute, or relative to the URL of the component.
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
*/
/*!
- \property QFxImage::source
- \brief the url of the image to be displayed in this item.
+ \qmlproperty url Image::source
- The content specified can be of any image type loadable by QImage. Alternatively,
- you can specify an sci format file, which specifies both an image and it's scale grid.
+ Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
+
+ The URL may be absolute, or relative to the URL of the component.
*/
-QUrl QFxImage::source() const
-{
- Q_D(const QFxImage);
- return d->url;
-}
-void QFxImage::setSource(const QUrl &url)
+void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxPerfTimer<QFxPerf::PixmapLoad> perf;
-#endif
Q_D(QFxImage);
- //equality is fairly expensive, so we bypass for simple, common case
- if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
+ if (d->pix.isNull())
return;
- if (d->sciReply) {
- d->sciReply->deleteLater();
- d->sciReply = 0;
- }
+ bool oldAA = p->testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- if (!d->sciurl.isEmpty())
- QFxPixmap::cancelGet(d->sciurl, this);
-
- d->url = url;
- d->sciurl = QUrl();
- if (d->progress != 0.0) {
- d->progress = 0.0;
- emit progressChanged(d->progress);
- }
+ QPixmap pix = d->pix;
- if (url.isEmpty()) {
- d->pix = QPixmap();
- d->status = Null;
- d->progress = 1.0;
- setImplicitWidth(0);
- setImplicitHeight(0);
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(1.0);
- update();
- } else {
- d->status = Loading;
- if (d->url.path().endsWith(QLatin1String(".sci"))) {
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- if (d->url.scheme() == QLatin1String("file")) {
- QFile file(d->url.toLocalFile());
- file.open(QIODevice::ReadOnly);
- setGridScaledImage(QFxGridScaledImage(&file));
- } else
-#endif
- {
- QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->sciReply = qmlEngine(this)->networkAccessManager()->get(req);
- QObject::connect(d->sciReply, SIGNAL(finished()),
- this, SLOT(sciRequestFinished()));
- }
- } else {
- d->reply = QFxPixmap::get(qmlEngine(this), d->url, &d->pix);
- if (d->reply) {
- connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
+ if (width() != pix.width() || height() != pix.height()) {
+ if (d->fillMode >= Tile) {
+ p->save();
+ p->setClipRect(0, 0, width(), height(), Qt::IntersectClip);
+
+ if (d->fillMode == Tile) {
+ const int pw = pix.width();
+ const int ph = pix.height();
+ int yy = 0;
+
+ while(yy < height()) {
+ int xx = 0;
+ while(xx < width()) {
+ p->drawPixmap(xx, yy, pix);
+ xx += pw;
+ }
+ yy += ph;
+ }
+ } else if (d->fillMode == TileVertically) {
+ const int ph = pix.height();
+ int yy = 0;
+
+ while(yy < height()) {
+ p->drawPixmap(QRect(0, yy, width(), ph), pix);
+ yy += ph;
+ }
} else {
- //### should be unified with requestFinished
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->status == Loading)
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(1.0);
- update();
+ const int pw = pix.width();
+ int xx = 0;
+
+ while(xx < width()) {
+ p->drawPixmap(QRect(xx, 0, pw, height()), pix);
+ xx += pw;
+ }
}
- }
- }
- emit statusChanged(d->status);
-}
+ p->restore();
+ } else {
+ qreal widthScale = width() / qreal(pix.width());
+ qreal heightScale = height() / qreal(pix.height());
+
+ QTransform scale;
+
+ if (d->fillMode == PreserveAspect) {
+ if (widthScale < heightScale) {
+ heightScale = widthScale;
+ scale.translate(0, (height() - heightScale * pix.height()) / 2);
+ } else if(heightScale < widthScale) {
+ widthScale = heightScale;
+ scale.translate((width() - widthScale * pix.width()) / 2, 0);
+ }
+ }
-void QFxImage::requestFinished()
-{
- Q_D(QFxImage);
- if (d->url.path().endsWith(QLatin1String(".sci"))) {
- QFxPixmap::find(d->sciurl, &d->pix);
- } else {
- if (d->reply) {
- //###disconnect really needed?
- disconnect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
- if (d->reply->error() != QNetworkReply::NoError)
- d->status = Error;
+ scale.scale(widthScale, heightScale);
+ QTransform old = p->transform();
+ p->setWorldTransform(scale * old);
+ p->drawPixmap(0, 0, pix);
+ p->setWorldTransform(old);
}
- QFxPixmap::find(d->url, &d->pix);
- }
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->status == Loading)
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(1.0);
- update();
-}
-
-void QFxImage::sciRequestFinished()
-{
- Q_D(QFxImage);
- if (d->sciReply->error() != QNetworkReply::NoError) {
- d->status = Error;
- d->sciReply->deleteLater();
- d->sciReply = 0;
- emit statusChanged(d->status);
} else {
- QFxGridScaledImage sci(d->sciReply);
- d->sciReply->deleteLater();
- d->sciReply = 0;
- setGridScaledImage(sci);
+ p->drawPixmap(0, 0, pix);
}
-}
-
-void QFxImage::requestProgress(qint64 received, qint64 total)
-{
- Q_D(QFxImage);
- if (d->status == Loading && total > 0) {
- d->progress = qreal(received)/total;
- emit progressChanged(d->progress);
- }
-}
-void QFxImage::setGridScaledImage(const QFxGridScaledImage& sci)
-{
- Q_D(QFxImage);
- if (!sci.isValid()) {
- d->status = Error;
- emit statusChanged(d->status);
- } else {
- QFxScaleGrid *sg = scaleGrid();
- sg->setTop(sci.gridTop());
- sg->setBottom(sci.gridBottom());
- sg->setLeft(sci.gridLeft());
- sg->setRight(sci.gridRight());
- sg->setHorizontalTileRule(sci.horizontalTileRule());
- sg->setVerticalTileRule(sci.verticalTileRule());
-
- d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
- d->reply = QFxPixmap::get(qmlEngine(this), d->sciurl, &d->pix);
- if (d->reply) {
- connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
- connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
- this, SLOT(requestProgress(qint64,qint64)));
- } else {
- //### should be unified with requestFinished
- setImplicitWidth(d->pix.width());
- setImplicitHeight(d->pix.height());
-
- if (d->status == Loading)
- d->status = Ready;
- d->progress = 1.0;
- emit statusChanged(d->status);
- emit sourceChanged(d->url);
- emit progressChanged(1.0);
- update();
- }
+ if (d->smooth) {
+ p->setRenderHint(QPainter::Antialiasing, oldAA);
+ p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
}
-
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index fc9cfe0..0a9d2df 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -42,30 +42,20 @@
#ifndef QFXIMAGE_H
#define QFXIMAGE_H
-#include <QtDeclarative/qfxitem.h>
#include <QtNetwork/qnetworkreply.h>
-
+#include "qfximagebase.h"
QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QFxImagePrivate;
-class QFxScaleGrid;
-class QFxGridScaledImage;
-class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem
+class QFxImagePrivate;
+class Q_DECLARATIVE_EXPORT QFxImage : public QFxImageBase
{
Q_OBJECT
- Q_ENUMS(Status)
Q_ENUMS(FillMode)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
-
- Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid)
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false)
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged);
@@ -80,41 +70,21 @@ public:
QPixmap pixmap() const;
void setPixmap(const QPixmap &);
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
-
- QUrl source() const;
- virtual void setSource(const QUrl &url);
-
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
Q_SIGNALS:
- void sourceChanged(const QUrl &);
- void statusChanged(Status);
- void progressChanged(qreal progress);
void fillModeChanged();
protected:
QFxImage(QFxImagePrivate &dd, QFxItem *parent);
- virtual void componentComplete();
-
-private Q_SLOTS:
- void requestFinished();
- void sciRequestFinished();
- void requestProgress(qint64,qint64);
private:
Q_DISABLE_COPY(QFxImage)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxImage)
- void setGridScaledImage(const QFxGridScaledImage& sci);
- QFxScaleGrid *scaleGrid();
};
QT_END_NAMESPACE
-
QML_DECLARE_TYPE(QFxImage)
-
QT_END_HEADER
#endif // QFXIMAGE_H
diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h
index 2ce41f8..8bdcc14 100644
--- a/src/declarative/fx/qfximage_p.h
+++ b/src/declarative/fx/qfximage_p.h
@@ -54,54 +54,22 @@
//
#include "qfxitem_p.h"
-#include "qfxscalegrid_p.h"
-
-#include <QtCore/qpointer.h>
+#include "qfximagebase_p.h"
QT_BEGIN_NAMESPACE
-class QSvgRenderer;
-class QWebPage;
-class QNetworkReply;
-class QIODevice;
-
-class QFxImagePrivate : public QFxItemPrivate
+class QFxImagePrivate : public QFxImageBasePrivate
{
Q_DECLARE_PUBLIC(QFxImage)
public:
QFxImagePrivate()
- : scaleGrid(0),
- fillMode(QFxImage::Stretch),
- status(QFxImage::Null), sciReply(0),
- progress(0.0)
- {
- }
-
- ~QFxImagePrivate()
+ : fillMode(QFxImage::Stretch)
{
- delete scaleGrid;
}
- void setContent(QIODevice* dev, const QString &url);
-
- QFxScaleGrid *getScaleGrid()
- {
- if (!scaleGrid)
- scaleGrid = new QFxScaleGrid;
- return scaleGrid;
- }
-
- QFxScaleGrid *scaleGrid;
- QPixmap pix;
-
QFxImage::FillMode fillMode;
- QFxImage::Status status;
- QUrl url;
- QUrl sciurl;
- QNetworkReply *sciReply;
- QPointer<QNetworkReply> reply;
- qreal progress;
+
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfximagebase.cpp b/src/declarative/fx/qfximagebase.cpp
new file mode 100644
index 0000000..f96ff6f
--- /dev/null
+++ b/src/declarative/fx/qfximagebase.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** 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 "qfximagebase.h"
+#include "qfximagebase_p.h"
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QFile>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qfxpixmap.h>
+
+QT_BEGIN_NAMESPACE
+
+QFxImageBase::QFxImageBase(QFxItem *parent)
+ : QFxItem(*(new QFxImageBasePrivate), parent)
+{
+ setFlag(QGraphicsItem::ItemHasNoContents, true);
+}
+
+QFxImageBase::QFxImageBase(QFxImageBasePrivate &dd, QFxItem *parent)
+ : QFxItem(dd, parent)
+{
+ setFlag(QGraphicsItem::ItemHasNoContents, true);
+}
+
+QFxImageBase::~QFxImageBase()
+{
+ Q_D(QFxImageBase);
+ if (!d->url.isEmpty())
+ QFxPixmap::cancelGet(d->url, this);
+}
+
+QFxImageBase::Status QFxImageBase::status() const
+{
+ Q_D(const QFxImageBase);
+ return d->status;
+}
+
+
+qreal QFxImageBase::progress() const
+{
+ Q_D(const QFxImageBase);
+ return d->progress;
+}
+
+
+/*!
+ \property QFxImage::source
+ \brief the url of the image to be displayed in this item.
+
+ The content specified can be of any image type loadable by QImage. Alternatively,
+ you can specify an sci format file, which specifies both an image and it's scale grid.
+*/
+QUrl QFxImageBase::source() const
+{
+ Q_D(const QFxImageBase);
+ return d->url;
+}
+
+void QFxImageBase::setSource(const QUrl &url)
+{
+ Q_D(QFxImageBase);
+ //equality is fairly expensive, so we bypass for simple, common case
+ if ((d->url.isEmpty() == url.isEmpty()) && url == d->url)
+ return;
+
+ if (!d->url.isEmpty())
+ QFxPixmap::cancelGet(d->url, this);
+
+ d->url = url;
+ if (d->progress != 0.0) {
+ d->progress = 0.0;
+ emit progressChanged(d->progress);
+ }
+
+ if (url.isEmpty()) {
+ d->pix = QPixmap();
+ d->status = Null;
+ d->progress = 1.0;
+ setImplicitWidth(0);
+ setImplicitHeight(0);
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+ } else {
+ d->status = Loading;
+ d->reply = QFxPixmap::get(qmlEngine(this), d->url, &d->pix);
+ if (d->reply) {
+ connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished()));
+ connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ } else {
+ //### should be unified with requestFinished
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+ }
+ }
+
+ emit statusChanged(d->status);
+}
+
+void QFxImageBase::requestFinished()
+{
+ Q_D(QFxImageBase);
+ if (d->reply) {
+ //###disconnect really needed?
+ disconnect(d->reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ if (d->reply->error() != QNetworkReply::NoError)
+ d->status = Error;
+ }
+ QFxPixmap::find(d->url, &d->pix);
+ setImplicitWidth(d->pix.width());
+ setImplicitHeight(d->pix.height());
+
+ if (d->status == Loading)
+ d->status = Ready;
+ d->progress = 1.0;
+ emit statusChanged(d->status);
+ emit sourceChanged(d->url);
+ emit progressChanged(1.0);
+ update();
+}
+
+void QFxImageBase::requestProgress(qint64 received, qint64 total)
+{
+ Q_D(QFxImageBase);
+ if (d->status == Loading && total > 0) {
+ d->progress = qreal(received)/total;
+ emit progressChanged(d->progress);
+ }
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfximagebase.h b/src/declarative/fx/qfximagebase.h
new file mode 100644
index 0000000..ce9c0c3
--- /dev/null
+++ b/src/declarative/fx/qfximagebase.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** 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 QFXIMAGEBASE_H
+#define QFXIMAGEBASE_H
+
+#include <QtDeclarative/qfxitem.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QFxImageBasePrivate;
+class QFxImageBase : public QFxItem
+{
+ Q_OBJECT
+ Q_ENUMS(Status)
+
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+
+public:
+ QFxImageBase(QFxItem *parent = 0);
+ ~QFxImageBase();
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+
+ QUrl source() const;
+ virtual void setSource(const QUrl &url);
+
+Q_SIGNALS:
+ void sourceChanged(const QUrl &);
+ void statusChanged(Status);
+ void progressChanged(qreal progress);
+
+protected:
+ QFxImageBase(QFxImageBasePrivate &dd, QFxItem *parent);
+
+private Q_SLOTS:
+ virtual void requestFinished();
+ void requestProgress(qint64,qint64);
+
+private:
+ Q_DISABLE_COPY(QFxImageBase)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxImageBase)
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QFXIMAGEBASE_H
diff --git a/src/declarative/fx/qfximagebase_p.h b/src/declarative/fx/qfximagebase_p.h
new file mode 100644
index 0000000..b468b90
--- /dev/null
+++ b/src/declarative/fx/qfximagebase_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 QFXIMAGEBASE_P_H
+#define QFXIMAGEBASE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qfxitem_p.h"
+#include <QtCore/QPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkReply;
+class QFxImageBasePrivate : public QFxItemPrivate
+{
+ Q_DECLARE_PUBLIC(QFxImageBase)
+
+public:
+ QFxImageBasePrivate()
+ : status(QFxImageBase::Null),
+ progress(0.0)
+ {
+ }
+
+ QPixmap pix;
+ QFxImageBase::Status status;
+ QUrl url;
+ QPointer<QNetworkReply> reply;
+ qreal progress;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index b36e994..66d5fc7 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -1701,20 +1701,6 @@ void QFxItem::setTransformOrigin(TransformOrigin origin)
}
/*!
- \qmlproperty bool Item::smooth
-
- Set this property if you want the item to be smoothly scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the item is displayed at its natural size, this property has no visual or
- performance effect.
- Currently, only the \c Image, \c Text , \c TextEdit and \c LineEdit items implement smooth filtering.
-
- \note Generally scaling artifacts are only visible if the item is stationary on
- the screen. A common pattern when animating an item is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
- */
-
-/*!
\property QFxItem::smooth
\brief whether the item is smoothly transformed.
diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp
index 13267f2..760344d 100644
--- a/src/declarative/fx/qfxlineedit.cpp
+++ b/src/declarative/fx/qfxlineedit.cpp
@@ -467,13 +467,26 @@ void QFxLineEdit::drawContents(QPainter *p, const QRect &r)
p->restore();
}
+/*!
+ \qmlproperty bool LineEdit::smooth
+
+ Set this property if you want the text to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
void QFxLineEditPrivate::init()
{
Q_Q(QFxLineEdit);
control->setCursorWidth(1);
control->setPasswordCharacter(QLatin1Char('*'));
control->setLayoutDirection(Qt::LeftToRight);
- q->setSmoothTransform(true);
+ q->setSmoothTransform(smooth);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFlag(QGraphicsItem::ItemHasNoContents, false);
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);
diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp
index 99b8128..43e94e5 100644
--- a/src/declarative/fx/qfxpixmap.cpp
+++ b/src/declarative/fx/qfxpixmap.cpp
@@ -164,6 +164,7 @@ bool QFxPixmap::find(const QUrl& url, QPixmap *pixmap)
}
QPixmapCache::insert(key, *pixmap);
}
+ return true;
}
/*!
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index 29321b8..0bd240e 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -591,6 +591,19 @@ void QFxRect::drawRect(QPainter &p)
}
}
+/*!
+ \qmlproperty bool Rect::smooth
+
+ Set this property if you want the item to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
QRectF QFxRect::boundingRect() const
{
Q_D(const QFxRect);
diff --git a/src/declarative/fx/qfxscalegrid.cpp b/src/declarative/fx/qfxscalegrid.cpp
index 8eb9890..4856c15 100644
--- a/src/declarative/fx/qfxscalegrid.cpp
+++ b/src/declarative/fx/qfxscalegrid.cpp
@@ -74,8 +74,7 @@ QT_BEGIN_NAMESPACE
*/
QML_DEFINE_NOCREATE_TYPE(QFxScaleGrid)
-QFxScaleGrid::QFxScaleGrid() : QObject(), _left(0), _top(0), _right(0), _bottom(0),
- _horizontalTileRule(Stretch), _verticalTileRule(Stretch)
+QFxScaleGrid::QFxScaleGrid() : QObject(), _left(0), _top(0), _right(0), _bottom(0)
{
}
@@ -124,20 +123,9 @@ void QFxScaleGrid::setBottom(int pos)
_bottom = pos;
}
-void QFxScaleGrid::setHorizontalTileRule(TileRule r)
-{
- _horizontalTileRule = r;
-}
-
-void QFxScaleGrid::setVerticalTileRule(TileRule r)
-{
- _verticalTileRule = r;
-}
-
-
QFxGridScaledImage::QFxGridScaledImage()
: _l(-1), _r(-1), _t(-1), _b(-1),
- _h(QFxScaleGrid::Stretch), _v(QFxScaleGrid::Stretch)
+ _h(QFxBorderImage::Stretch), _v(QFxBorderImage::Stretch)
{
}
@@ -159,7 +147,7 @@ QFxGridScaledImage &QFxGridScaledImage::operator=(const QFxGridScaledImage &o)
}
QFxGridScaledImage::QFxGridScaledImage(QIODevice *data)
-: _l(-1), _r(-1), _t(-1), _b(-1), _h(QFxScaleGrid::Stretch), _v(QFxScaleGrid::Stretch)
+: _l(-1), _r(-1), _t(-1), _b(-1), _h(QFxBorderImage::Stretch), _v(QFxBorderImage::Stretch)
{
int l = -1;
int r = -1;
@@ -203,17 +191,17 @@ QFxGridScaledImage::QFxGridScaledImage(QIODevice *data)
_pix = imgFile;
}
-QFxScaleGrid::TileRule QFxGridScaledImage::stringToRule(const QString &s)
+QFxBorderImage::TileMode QFxGridScaledImage::stringToRule(const QString &s)
{
if (s == QLatin1String("Stretch"))
- return QFxScaleGrid::Stretch;
+ return QFxBorderImage::Stretch;
if (s == QLatin1String("Repeat"))
- return QFxScaleGrid::Repeat;
+ return QFxBorderImage::Repeat;
if (s == QLatin1String("Round"))
- return QFxScaleGrid::Round;
+ return QFxBorderImage::Round;
qWarning() << "Unknown tile rule specified. Using Stretch";
- return QFxScaleGrid::Stretch;
+ return QFxBorderImage::Stretch;
}
bool QFxGridScaledImage::isValid() const
diff --git a/src/declarative/fx/qfxscalegrid_p.h b/src/declarative/fx/qfxscalegrid_p.h
index 483ade1..9d0a84c 100644
--- a/src/declarative/fx/qfxscalegrid_p.h
+++ b/src/declarative/fx/qfxscalegrid_p.h
@@ -47,6 +47,7 @@
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qfxpixmap.h>
#include <QtDeclarative/qml.h>
+#include "qfxborderimage.h"
QT_BEGIN_HEADER
@@ -54,6 +55,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class Q_DECLARATIVE_EXPORT QFxScaleGrid : public QObject
{
Q_OBJECT
@@ -63,8 +65,6 @@ class Q_DECLARATIVE_EXPORT QFxScaleGrid : public QObject
Q_PROPERTY(int top READ top WRITE setTop)
Q_PROPERTY(int right READ right WRITE setRight)
Q_PROPERTY(int bottom READ bottom WRITE setBottom)
- Q_PROPERTY(TileRule horizontalTileRule READ horizontalTileRule WRITE setHorizontalTileRule)
- Q_PROPERTY(TileRule verticalTileRule READ verticalTileRule WRITE setVerticalTileRule)
public:
QFxScaleGrid();
@@ -84,21 +84,11 @@ public:
int bottom() const { return _bottom; }
void setBottom(int);
- enum TileRule { Stretch = Qt::Stretch, Repeat = Qt::Repeat, Round = Qt::Round };
-
- TileRule horizontalTileRule() const { return _horizontalTileRule; }
- void setHorizontalTileRule(TileRule);
-
- TileRule verticalTileRule() const { return _verticalTileRule; }
- void setVerticalTileRule(TileRule);
-
private:
int _left;
int _top;
int _right;
int _bottom;
- TileRule _horizontalTileRule;
- TileRule _verticalTileRule;
};
class Q_DECLARATIVE_EXPORT QFxGridScaledImage
@@ -113,21 +103,21 @@ public:
int gridRight() const;
int gridTop() const;
int gridBottom() const;
- QFxScaleGrid::TileRule horizontalTileRule() const { return _h; }
- QFxScaleGrid::TileRule verticalTileRule() const { return _v; }
+ QFxBorderImage::TileMode horizontalTileRule() const { return _h; }
+ QFxBorderImage::TileMode verticalTileRule() const { return _v; }
QString pixmapUrl() const;
private:
- static QFxScaleGrid::TileRule stringToRule(const QString &);
+ static QFxBorderImage::TileMode stringToRule(const QString &);
private:
int _l;
int _r;
int _t;
int _b;
- QFxScaleGrid::TileRule _h;
- QFxScaleGrid::TileRule _v;
+ QFxBorderImage::TileMode _h;
+ QFxBorderImage::TileMode _v;
QString _pix;
};
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 0c3f4e9..c3872c4 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -809,6 +809,19 @@ void QFxText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
}
}
+/*!
+ \qmlproperty bool Text::smooth
+
+ Set this property if you want the text to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
void QFxText::componentComplete()
{
Q_D(QFxText);
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index e4001b2..dbaba79 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -1010,11 +1010,24 @@ void QFxTextEdit::updateImgCache(const QRectF &r)
emit update();
}
+/*!
+ \qmlproperty bool TextEdit::smooth
+
+ Set this property if you want the text to be smoothly scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the item is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the item is stationary on
+ the screen. A common pattern when animating an item is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+*/
+
void QFxTextEditPrivate::init()
{
Q_Q(QFxTextEdit);
- q->setSmoothTransform(true);
+ q->setSmoothTransform(smooth);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFlag(QGraphicsItem::ItemHasNoContents, false);
q->setFlag(QGraphicsItem::ItemAcceptsInputMethod);