aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-03-02 08:25:43 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-20 03:15:43 +0100
commitab1e510121c8a679fdaca12ccd30e0f7ac12a26b (patch)
tree68c377ba468a667c43211f005ead5b49b16e49f3 /src/quick/util
parentb143d3fb589e7ce7171c9975679fa47181a6a10f (diff)
Migrate gui dependencies from QtQml to QtQuick.
Ensure that users of declarative that have no need for functionality provided by the Qt Gui module do not have to link against it. Any use of QtGui functionality is delegated to providers that can be installed by another library; QtQuick adds default providers for this functionality when linked against QtQml. Task-number: QTBUG-24559 Change-Id: I5e6a58a4198732dc2f8f52f71abfa1152b871aa7 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/quick/util')
-rw-r--r--src/quick/util/qquickanimation.cpp43
-rw-r--r--src/quick/util/qquickapplication.cpp124
-rw-r--r--src/quick/util/qquickapplication_p.h86
-rw-r--r--src/quick/util/qquickglobal.cpp530
-rw-r--r--src/quick/util/qquickvaluetypes.cpp468
-rw-r--r--src/quick/util/qquickvaluetypes_p.h310
-rw-r--r--src/quick/util/util.pri9
7 files changed, 1537 insertions, 33 deletions
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index 33a5d0a438..fc1e6ec89f 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -1755,38 +1755,19 @@ void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
}
switch (type) {
- case QVariant::Rect: {
- variant.setValue(QQmlStringConverters::rectFFromString(variant.toString()).toRect());
- break;
- }
- case QVariant::RectF: {
- variant.setValue(QQmlStringConverters::rectFFromString(variant.toString()));
- break;
- }
- case QVariant::Point: {
- variant.setValue(QQmlStringConverters::pointFFromString(variant.toString()).toPoint());
- break;
- }
- case QVariant::PointF: {
- variant.setValue(QQmlStringConverters::pointFFromString(variant.toString()));
- break;
- }
- case QVariant::Size: {
- variant.setValue(QQmlStringConverters::sizeFFromString(variant.toString()).toSize());
- break;
- }
- case QVariant::SizeF: {
- variant.setValue(QQmlStringConverters::sizeFFromString(variant.toString()));
- break;
- }
- case QVariant::Color: {
- variant.setValue(QQmlStringConverters::colorFromString(variant.toString()));
- break;
- }
- case QVariant::Vector3D: {
- variant.setValue(QQmlStringConverters::vector3DFromString(variant.toString()));
+ case QVariant::Rect:
+ case QVariant::RectF:
+ case QVariant::Point:
+ case QVariant::PointF:
+ case QVariant::Size:
+ case QVariant::SizeF:
+ case QVariant::Color:
+ case QVariant::Vector3D:
+ {
+ bool ok = false;
+ variant = QQmlStringConverters::variantFromString(variant.toString(), type, &ok);
+ }
break;
- }
default:
if (QQmlValueTypeFactory::isValueType((uint)type)) {
variant.convert((QVariant::Type)type);
diff --git a/src/quick/util/qquickapplication.cpp b/src/quick/util/qquickapplication.cpp
new file mode 100644
index 0000000000..55ebb11d29
--- /dev/null
+++ b/src/quick/util/qquickapplication.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickapplication_p.h"
+
+#include <private/qobject_p.h>
+#include <QtGui/QGuiApplication>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickApplicationPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickApplication)
+public:
+ QQuickApplicationPrivate()
+ : isActive(QGuiApplication::focusWindow() != 0),
+ direction(QGuiApplication::layoutDirection())
+ {
+ }
+
+private:
+ bool isActive;
+ Qt::LayoutDirection direction;
+};
+
+/*
+ This object and its properties are documented as part of the Qt object,
+ in qqmlengine.cpp
+*/
+
+QQuickApplication::QQuickApplication(QObject *parent)
+ : QObject(*new QQuickApplicationPrivate(), parent)
+{
+ if (qApp) {
+ qApp->installEventFilter(this);
+ }
+}
+
+QQuickApplication::~QQuickApplication()
+{
+}
+
+bool QQuickApplication::active() const
+{
+ Q_D(const QQuickApplication);
+ return d->isActive;
+}
+
+Qt::LayoutDirection QQuickApplication::layoutDirection() const
+{
+ Q_D(const QQuickApplication);
+ return d->direction;
+}
+
+QObject *QQuickApplication::inputPanel() const
+{
+ static bool warned = false;
+ if (!warned) {
+ qWarning() << "Qt.application.inputPanel is deprecated, use Qt.inputMethod instead";
+ warned = true;
+ }
+ return qGuiApp->inputMethod();
+}
+
+bool QQuickApplication::eventFilter(QObject *, QEvent *event)
+{
+ Q_D(QQuickApplication);
+ if ((event->type() == QEvent::ApplicationActivate) ||
+ (event->type() == QEvent::ApplicationDeactivate)) {
+ bool wasActive = d->isActive;
+ d->isActive = (event->type() == QEvent::ApplicationActivate);
+ if (d->isActive != wasActive) {
+ emit activeChanged();
+ }
+ } else if (event->type() == QEvent::LayoutDirectionChange) {
+ Qt::LayoutDirection newDirection = QGuiApplication::layoutDirection();
+ if (d->direction != newDirection) {
+ d->direction = newDirection;
+ emit layoutDirectionChanged();
+ }
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h
new file mode 100644
index 0000000000..e8a3cd58ca
--- /dev/null
+++ b/src/quick/util/qquickapplication_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKAPPLICATION_P_H
+#define QQUICKAPPLICATION_P_H
+
+#include <QtCore/QObject>
+#include <qqml.h>
+#include <private/qtquickglobal_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+
+class QQuickApplicationPrivate;
+class Q_QUICK_PRIVATE_EXPORT QQuickApplication : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool active READ active NOTIFY activeChanged)
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged)
+ Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT)
+
+public:
+ explicit QQuickApplication(QObject *parent = 0);
+ virtual ~QQuickApplication();
+ bool active() const;
+ Qt::LayoutDirection layoutDirection() const;
+ QT_DEPRECATED QObject *inputPanel() const;
+
+Q_SIGNALS:
+ void activeChanged();
+ void layoutDirectionChanged();
+
+private:
+ bool eventFilter(QObject *, QEvent *event);
+
+ Q_DISABLE_COPY(QQuickApplication)
+ Q_DECLARE_PRIVATE(QQuickApplication)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickApplication)
+
+QT_END_HEADER
+
+#endif // QQUICKAPPLICATION_P_H
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
new file mode 100644
index 0000000000..b99cb7a1d4
--- /dev/null
+++ b/src/quick/util/qquickglobal.cpp
@@ -0,0 +1,530 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qquickvaluetypes_p.h>
+#include <private/qquickapplication_p.h>
+#include <private/qqmlglobal_p.h>
+
+#include <QtGui/QGuiApplication>
+#include <QtGui/qdesktopservices.h>
+#include <QtGui/qfontdatabase.h>
+
+
+QT_BEGIN_NAMESPACE
+
+class QQuickColorProvider : public QQmlColorProvider
+{
+public:
+ static inline QColor QColorFromString(const QString &s)
+ {
+ // Should we also handle #rrggbb here?
+ if (s.length() == 9 && s.startsWith(QLatin1Char('#'))) {
+ uchar a = fromHex(s, 1);
+ uchar r = fromHex(s, 3);
+ uchar g = fromHex(s, 5);
+ uchar b = fromHex(s, 7);
+ return QColor(r, g, b, a);
+ }
+
+ return QColor(s);
+ }
+
+ QVariant colorFromString(const QString &s, bool *ok)
+ {
+ QColor c(QColorFromString(s));
+ if (c.isValid()) {
+ if (ok) *ok = true;
+ return QVariant(c);
+ }
+
+ if (ok) *ok = false;
+ return QVariant();
+ }
+
+ unsigned rgbaFromString(const QString &s, bool *ok)
+ {
+ QColor c(QColorFromString(s));
+ if (c.isValid()) {
+ if (ok) *ok = true;
+ return c.rgba();
+ }
+
+ if (ok) *ok = false;
+ return 0;
+ }
+
+ QString stringFromRgba(unsigned rgba)
+ {
+ QColor c(QColor::fromRgba(rgba));
+ if (c.isValid()) {
+ return QVariant(c).toString();
+ }
+
+ return QString();
+ }
+
+ QVariant fromRgbF(double r, double g, double b, double a)
+ {
+ return QVariant(QColor::fromRgbF(r, g, b, a));
+ }
+
+ QVariant fromHslF(double h, double s, double l, double a)
+ {
+ return QVariant(QColor::fromHslF(h, s, l, a));
+ }
+
+ QVariant lighter(const QVariant &var, qreal factor)
+ {
+ QColor color = var.value<QColor>();
+ color = color.lighter(int(qRound(factor*100.)));
+ return QVariant::fromValue(color);
+ }
+
+ QVariant darker(const QVariant &var, qreal factor)
+ {
+ QColor color = var.value<QColor>();
+ color = color.darker(int(qRound(factor*100.)));
+ return QVariant::fromValue(color);
+ }
+
+ QVariant tint(const QVariant &baseVar, const QVariant &tintVar)
+ {
+ QColor tintColor = tintVar.value<QColor>();
+
+ int tintAlpha = tintColor.alpha();
+ if (tintAlpha == 0xFF) {
+ return tintVar;
+ } else if (tintAlpha == 0x00) {
+ return baseVar;
+ }
+
+ // tint the base color and return the final color
+ QColor baseColor = baseVar.value<QColor>();
+ qreal a = tintColor.alphaF();
+ qreal inv_a = 1.0 - a;
+
+ qreal r = tintColor.redF() * a + baseColor.redF() * inv_a;
+ qreal g = tintColor.greenF() * a + baseColor.greenF() * inv_a;
+ qreal b = tintColor.blueF() * a + baseColor.blueF() * inv_a;
+
+ return QVariant::fromValue(QColor::fromRgbF(r, g, b, a + inv_a * baseColor.alphaF()));
+ }
+
+private:
+ static uchar fromHex(const uchar c, const uchar c2)
+ {
+ uchar rv = 0;
+ if (c >= '0' && c <= '9')
+ rv += (c - '0') * 16;
+ else if (c >= 'A' && c <= 'F')
+ rv += (c - 'A' + 10) * 16;
+ else if (c >= 'a' && c <= 'f')
+ rv += (c - 'a' + 10) * 16;
+
+ if (c2 >= '0' && c2 <= '9')
+ rv += (c2 - '0');
+ else if (c2 >= 'A' && c2 <= 'F')
+ rv += (c2 - 'A' + 10);
+ else if (c2 >= 'a' && c2 <= 'f')
+ rv += (c2 - 'a' + 10);
+
+ return rv;
+ }
+
+ static inline uchar fromHex(const QString &s, int idx)
+ {
+ uchar c = s.at(idx).toAscii();
+ uchar c2 = s.at(idx + 1).toAscii();
+ return fromHex(c, c2);
+ }
+};
+
+
+class QQuickValueTypeProvider : public QQmlValueTypeProvider
+{
+public:
+ static QVector3D vector3DFromString(const QString &s, bool *ok)
+ {
+ if (s.count(QLatin1Char(',')) == 2) {
+ int index = s.indexOf(QLatin1Char(','));
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+
+ bool xGood, yGood, zGood;
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ qreal zCoord = s.mid(index2+1).toDouble(&zGood);
+
+ if (xGood && yGood && zGood) {
+ if (ok) *ok = true;
+ return QVector3D(xCoord, yCoord, zCoord);
+ }
+ }
+
+ if (ok) *ok = false;
+ return QVector3D();
+ }
+
+ static QVector4D vector4DFromString(const QString &s, bool *ok)
+ {
+ if (s.count(QLatin1Char(',')) == 3) {
+ int index = s.indexOf(QLatin1Char(','));
+ int index2 = s.indexOf(QLatin1Char(','), index+1);
+ int index3 = s.indexOf(QLatin1Char(','), index2+1);
+
+ bool xGood, yGood, zGood, wGood;
+ qreal xCoord = s.left(index).toDouble(&xGood);
+ qreal yCoord = s.mid(index+1, index2-index-1).toDouble(&yGood);
+ qreal zCoord = s.mid(index2+1, index3-index2-1).toDouble(&zGood);
+ qreal wCoord = s.mid(index3+1).toDouble(&wGood);
+
+ if (xGood && yGood && zGood && wGood) {
+ if (ok) *ok = true;
+ return QVector4D(xCoord, yCoord, zCoord, wCoord);
+ }
+ }
+
+ if (ok) *ok = false;
+ return QVector4D();
+ }
+
+ bool create(int type, QQmlValueType *&v)
+ {
+ switch (type) {
+ case QMetaType::QColor:
+ v = new QQuickColorValueType;
+ return true;
+ case QMetaType::QVector2D:
+ v = new QQuickVector2DValueType;
+ return true;
+ case QMetaType::QVector3D:
+ v = new QQuickVector3DValueType;
+ return true;
+ case QMetaType::QVector4D:
+ v = new QQuickVector4DValueType;
+ return true;
+ case QMetaType::QQuaternion:
+ v = new QQuickQuaternionValueType;
+ return true;
+ case QMetaType::QMatrix4x4:
+ v = new QQuickMatrix4x4ValueType;
+ return true;
+ case QMetaType::QFont:
+ v = new QQuickFontValueType;
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ bool init(int type, void *data, size_t n)
+ {
+ if (type == QMetaType::QColor) {
+ Q_ASSERT(n >= sizeof(QColor));
+ QColor *color = reinterpret_cast<QColor *>(data);
+ new (color) QColor();
+ return true;
+ }
+
+ return false;
+ }
+
+ bool destroy(int type, void *data, size_t n)
+ {
+ if (type == QMetaType::QColor) {
+ Q_ASSERT(n >= sizeof(QColor));
+ QColor *color = reinterpret_cast<QColor *>(data);
+ color->~QColor();
+ return true;
+ }
+
+ return false;
+ }
+
+ bool copy(int type, const void *src, void *dst, size_t n)
+ {
+ if (type == QMetaType::QColor) {
+ Q_ASSERT(n >= sizeof(QColor));
+ const QColor *srcColor = reinterpret_cast<const QColor *>(src);
+ QColor *dstColor = reinterpret_cast<QColor *>(dst);
+ new (dstColor) QColor(*srcColor);
+ return true;
+ }
+
+ return false;
+ }
+
+ bool create(int type, int argc, const void *argv[], QVariant *v)
+ {
+ switch (type) {
+ case QMetaType::QVector3D:
+ if (argc == 1) {
+ const float *xyz = reinterpret_cast<const float*>(argv[0]);
+ QVector3D v3(xyz[0], xyz[1], xyz[2]);
+ *v = QVariant(v3);
+ return true;
+ }
+ break;
+ case QMetaType::QVector4D:
+ if (argc == 1) {
+ const float *xyzw = reinterpret_cast<const float*>(argv[0]);
+ QVector4D v4(xyzw[0], xyzw[1], xyzw[2], xyzw[3]);
+ *v = QVariant(v4);
+ return true;
+ }
+ break;
+ }
+
+ return false;
+ }
+
+ bool createFromString(int type, const QString &s, void *data, size_t n)
+ {
+ bool ok = false;
+
+ switch (type) {
+ case QMetaType::QColor:
+ {
+ Q_ASSERT(n >= sizeof(QColor));
+ QColor *color = reinterpret_cast<QColor *>(data);
+ new (color) QColor(QQuickColorProvider::QColorFromString(s));
+ return true;
+ }
+ case QMetaType::QVector3D:
+ {
+ Q_ASSERT(n >= sizeof(QVector3D));
+ QVector3D *v3 = reinterpret_cast<QVector3D *>(data);
+ new (v3) QVector3D(vector3DFromString(s, &ok));
+ return true;
+ }
+ case QMetaType::QVector4D:
+ {
+ Q_ASSERT(n >= sizeof(QVector4D));
+ QVector4D *v4 = reinterpret_cast<QVector4D *>(data);
+ new (v4) QVector4D(vector4DFromString(s, &ok));
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ bool createStringFrom(int type, const void *data, QString *s)
+ {
+ if (type == QMetaType::QColor) {
+ const QColor *color = reinterpret_cast<const QColor *>(data);
+ new (s) QString(QVariant(*color).toString());
+ return true;
+ }
+
+ return false;
+ }
+
+ bool variantFromString(const QString &s, QVariant *v)
+ {
+ QColor c(QQuickColorProvider::QColorFromString(s));
+ if (c.isValid()) {
+ *v = QVariant::fromValue(c);
+ return true;
+ }
+
+ bool ok = false;
+
+ QVector3D v3 = vector3DFromString(s, &ok);
+ if (ok) {
+ *v = QVariant::fromValue(v3);
+ return true;
+ }
+
+ QVector4D v4 = vector4DFromString(s, &ok);
+ if (ok) {
+ *v = QVariant::fromValue(v4);
+ return true;
+ }
+
+ return false;
+ }
+
+ bool variantFromString(int type, const QString &s, QVariant *v)
+ {
+ bool ok = false;
+
+ switch (type) {
+ case QMetaType::QColor:
+ {
+ QColor c(QQuickColorProvider::QColorFromString(s));
+ *v = QVariant::fromValue(c);
+ return true;
+ }
+ case QMetaType::QVector3D:
+ *v = QVariant::fromValue(vector3DFromString(s, &ok));
+ return true;
+ case QMetaType::QVector4D:
+ *v = QVariant::fromValue(vector4DFromString(s, &ok));
+ return true;
+ }
+
+ return false;
+ }
+
+ bool store(int type, const void *src, void *dst, size_t n)
+ {
+ switch (type) {
+ case QMetaType::QColor:
+ {
+ Q_ASSERT(n >= sizeof(QColor));
+ const QRgb *rgb = reinterpret_cast<const QRgb *>(src);
+ QColor *color = reinterpret_cast<QColor *>(dst);
+ new (color) QColor(QColor::fromRgba(*rgb));
+ return true;
+ }
+ case QMetaType::QVector3D:
+ {
+ Q_ASSERT(n >= sizeof(QVector3D));
+ const QVector3D *srcVector = reinterpret_cast<const QVector3D *>(src);
+ QVector3D *dstVector = reinterpret_cast<QVector3D *>(dst);
+ new (dstVector) QVector3D(*srcVector);
+ return true;
+ }
+ case QMetaType::QVector4D:
+ {
+ Q_ASSERT(n >= sizeof(QVector4D));
+ const QVector4D *srcVector = reinterpret_cast<const QVector4D *>(src);
+ QVector4D *dstVector = reinterpret_cast<QVector4D *>(dst);
+ new (dstVector) QVector4D(*srcVector);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ bool read(int srcType, const void *src, int dstType, void *dst)
+ {
+ if (dstType == QMetaType::QColor) {
+ QColor *dstColor = reinterpret_cast<QColor *>(dst);
+ if (srcType == QMetaType::QColor) {
+ const QColor *srcColor = reinterpret_cast<const QColor *>(src);
+ *dstColor = *srcColor;
+ } else {
+ *dstColor = QColor();
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ bool write(int type, const void *src, void *dst, size_t n)
+ {
+ if (type == QMetaType::QColor) {
+ Q_ASSERT(n >= sizeof(QColor));
+ const QColor *srcColor = reinterpret_cast<const QColor *>(src);
+ QColor *dstColor = reinterpret_cast<QColor *>(dst);
+ if (*dstColor != *srcColor) {
+ *dstColor = *srcColor;
+ return true;
+ }
+ }
+
+ return false;
+ }
+};
+
+
+class QQuickGuiProvider : public QQmlGuiProvider
+{
+public:
+ QQuickApplication *application(QObject *parent)
+ {
+ return new QQuickApplication(parent);
+ }
+
+ QInputMethod *inputMethod()
+ {
+ return qGuiApp->inputMethod();
+ }
+
+ QStringList fontFamilies()
+ {
+ QFontDatabase database;
+ return database.families();
+ }
+
+ bool openUrlExternally(QUrl &url)
+ {
+#ifndef QT_NO_DESKTOPSERVICES
+ return QDesktopServices::openUrl(url);
+#else
+ return false;
+#endif
+ }
+};
+
+
+static QQuickValueTypeProvider *getValueTypeProvider()
+{
+ static QQuickValueTypeProvider valueTypeProvider;
+ return &valueTypeProvider;
+}
+
+static QQuickColorProvider *getColorProvider()
+{
+ static QQuickColorProvider colorProvider;
+ return &colorProvider;
+}
+
+static QQuickGuiProvider *getGuiProvider()
+{
+ static QQuickGuiProvider guiProvider;
+ return &guiProvider;
+}
+
+static bool initializeProviders()
+{
+ QQml_addValueTypeProvider(getValueTypeProvider());
+ QQml_setColorProvider(getColorProvider());
+ QQml_setGuiProvider(getGuiProvider());
+ return true;
+}
+
+static bool initialized = initializeProviders();
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp
new file mode 100644
index 0000000000..179f840acd
--- /dev/null
+++ b/src/quick/util/qquickvaluetypes.cpp
@@ -0,0 +1,468 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qquickvaluetypes_p.h>
+
+#include <qtquickglobal.h>
+#include <private/qqmlvaluetype_p.h>
+#include <private/qfont_p.h>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace QQuickValueTypes {
+
+void registerValueTypes()
+{
+ QQmlValueTypeFactory::registerValueTypes();
+
+ qmlRegisterValueTypeEnums<QQuickFontValueType>("QtQuick", 2, 0, "Font");
+}
+
+}
+
+QQuickColorValueType::QQuickColorValueType(QObject *parent)
+ : QQmlValueTypeBase<QColor>(parent)
+{
+}
+
+QString QQuickColorValueType::toString() const
+{
+ // to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
+ return QVariant(v).toString();
+}
+
+qreal QQuickColorValueType::r() const
+{
+ return v.redF();
+}
+
+qreal QQuickColorValueType::g() const
+{
+ return v.greenF();
+}
+
+qreal QQuickColorValueType::b() const
+{
+ return v.blueF();
+}
+
+qreal QQuickColorValueType::a() const
+{
+ return v.alphaF();
+}
+
+void QQuickColorValueType::setR(qreal r)
+{
+ v.setRedF(r);
+}
+
+void QQuickColorValueType::setG(qreal g)
+{
+ v.setGreenF(g);
+}
+
+void QQuickColorValueType::setB(qreal b)
+{
+ v.setBlueF(b);
+}
+
+void QQuickColorValueType::setA(qreal a)
+{
+ v.setAlphaF(a);
+}
+
+
+QQuickVector2DValueType::QQuickVector2DValueType(QObject *parent)
+ : QQmlValueTypeBase<QVector2D>(parent)
+{
+}
+
+QString QQuickVector2DValueType::toString() const
+{
+ return QString(QLatin1String("QVector2D(%1, %2)")).arg(v.x()).arg(v.y());
+}
+
+qreal QQuickVector2DValueType::x() const
+{
+ return v.x();
+}
+
+qreal QQuickVector2DValueType::y() const
+{
+ return v.y();
+}
+
+void QQuickVector2DValueType::setX(qreal x)
+{
+ v.setX(x);
+}
+
+void QQuickVector2DValueType::setY(qreal y)
+{
+ v.setY(y);
+}
+
+
+QQuickVector3DValueType::QQuickVector3DValueType(QObject *parent)
+ : QQmlValueTypeBase<QVector3D>(parent)
+{
+}
+
+QString QQuickVector3DValueType::toString() const
+{
+ return QString(QLatin1String("QVector3D(%1, %2, %3)")).arg(v.x()).arg(v.y()).arg(v.z());
+}
+
+qreal QQuickVector3DValueType::x() const
+{
+ return v.x();
+}
+
+qreal QQuickVector3DValueType::y() const
+{
+ return v.y();
+}
+
+qreal QQuickVector3DValueType::z() const
+{
+ return v.z();
+}
+
+void QQuickVector3DValueType::setX(qreal x)
+{
+ v.setX(x);
+}
+
+void QQuickVector3DValueType::setY(qreal y)
+{
+ v.setY(y);
+}
+
+void QQuickVector3DValueType::setZ(qreal z)
+{
+ v.setZ(z);
+}
+
+
+QQuickVector4DValueType::QQuickVector4DValueType(QObject *parent)
+ : QQmlValueTypeBase<QVector4D>(parent)
+{
+}
+
+QString QQuickVector4DValueType::toString() const
+{
+ return QString(QLatin1String("QVector4D(%1, %2, %3, %4)")).arg(v.x()).arg(v.y()).arg(v.z()).arg(v.w());
+}
+
+qreal QQuickVector4DValueType::x() const
+{
+ return v.x();
+}
+
+qreal QQuickVector4DValueType::y() const
+{
+ return v.y();
+}
+
+qreal QQuickVector4DValueType::z() const
+{
+ return v.z();
+}
+
+qreal QQuickVector4DValueType::w() const
+{
+ return v.w();
+}
+
+void QQuickVector4DValueType::setX(qreal x)
+{
+ v.setX(x);
+}
+
+void QQuickVector4DValueType::setY(qreal y)
+{
+ v.setY(y);
+}
+
+void QQuickVector4DValueType::setZ(qreal z)
+{
+ v.setZ(z);
+}
+
+void QQuickVector4DValueType::setW(qreal w)
+{
+ v.setW(w);
+}
+
+
+QQuickQuaternionValueType::QQuickQuaternionValueType(QObject *parent)
+ : QQmlValueTypeBase<QQuaternion>(parent)
+{
+}
+
+QString QQuickQuaternionValueType::toString() const
+{
+ return QString(QLatin1String("QQuaternion(%1, %2, %3, %4)")).arg(v.scalar()).arg(v.x()).arg(v.y()).arg(v.z());
+}
+
+qreal QQuickQuaternionValueType::scalar() const
+{
+ return v.scalar();
+}
+
+qreal QQuickQuaternionValueType::x() const
+{
+ return v.x();
+}
+
+qreal QQuickQuaternionValueType::y() const
+{
+ return v.y();
+}
+
+qreal QQuickQuaternionValueType::z() const
+{
+ return v.z();
+}
+
+void QQuickQuaternionValueType::setScalar(qreal scalar)
+{
+ v.setScalar(scalar);
+}
+
+void QQuickQuaternionValueType::setX(qreal x)
+{
+ v.setX(x);
+}
+
+void QQuickQuaternionValueType::setY(qreal y)
+{
+ v.setY(y);
+}
+
+void QQuickQuaternionValueType::setZ(qreal z)
+{
+ v.setZ(z);
+}
+
+
+QQuickMatrix4x4ValueType::QQuickMatrix4x4ValueType(QObject *parent)
+ : QQmlValueTypeBase<QMatrix4x4>(parent)
+{
+}
+
+QString QQuickMatrix4x4ValueType::toString() const
+{
+ return QString(QLatin1String("QMatrix4x4(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)"))
+ .arg(v(0, 0)).arg(v(0, 1)).arg(v(0, 2)).arg(v(0, 3))
+ .arg(v(1, 0)).arg(v(1, 1)).arg(v(1, 2)).arg(v(1, 3))
+ .arg(v(2, 0)).arg(v(2, 1)).arg(v(2, 2)).arg(v(2, 3))
+ .arg(v(3, 0)).arg(v(3, 1)).arg(v(3, 2)).arg(v(3, 3));
+}
+
+
+QQuickFontValueType::QQuickFontValueType(QObject *parent)
+ : QQmlValueTypeBase<QFont>(parent),
+ pixelSizeSet(false),
+ pointSizeSet(false)
+{
+}
+
+void QQuickFontValueType::onLoad()
+{
+ pixelSizeSet = false;
+ pointSizeSet = false;
+}
+
+QString QQuickFontValueType::toString() const
+{
+ return QString(QLatin1String("QFont(%1)")).arg(v.toString());
+}
+
+QString QQuickFontValueType::family() const
+{
+ return v.family();
+}
+
+void QQuickFontValueType::setFamily(const QString &family)
+{
+ v.setFamily(family);
+}
+
+bool QQuickFontValueType::bold() const
+{
+ return v.bold();
+}
+
+void QQuickFontValueType::setBold(bool b)
+{
+ v.setBold(b);
+}
+
+QQuickFontValueType::FontWeight QQuickFontValueType::weight() const
+{
+ return (QQuickFontValueType::FontWeight)v.weight();
+}
+
+void QQuickFontValueType::setWeight(QQuickFontValueType::FontWeight w)
+{
+ v.setWeight((QFont::Weight)w);
+}
+
+bool QQuickFontValueType::italic() const
+{
+ return v.italic();
+}
+
+void QQuickFontValueType::setItalic(bool b)
+{
+ v.setItalic(b);
+}
+
+bool QQuickFontValueType::underline() const
+{
+ return v.underline();
+}
+
+void QQuickFontValueType::setUnderline(bool b)
+{
+ v.setUnderline(b);
+}
+
+bool QQuickFontValueType::overline() const
+{
+ return v.overline();
+}
+
+void QQuickFontValueType::setOverline(bool b)
+{
+ v.setOverline(b);
+}
+
+bool QQuickFontValueType::strikeout() const
+{
+ return v.strikeOut();
+}
+
+void QQuickFontValueType::setStrikeout(bool b)
+{
+ v.setStrikeOut(b);
+}
+
+qreal QQuickFontValueType::pointSize() const
+{
+ if (v.pointSizeF() == -1) {
+ if (dpi.isNull)
+ dpi = qt_defaultDpi();
+ return v.pixelSize() * qreal(72.) / qreal(dpi);
+ }
+ return v.pointSizeF();
+}
+
+void QQuickFontValueType::setPointSize(qreal size)
+{
+ if (pixelSizeSet) {
+ qWarning() << "Both point size and pixel size set. Using pixel size.";
+ return;
+ }
+
+ if (size >= 0.0) {
+ pointSizeSet = true;
+ v.setPointSizeF(size);
+ } else {
+ pointSizeSet = false;
+ }
+}
+
+int QQuickFontValueType::pixelSize() const
+{
+ if (v.pixelSize() == -1) {
+ if (dpi.isNull)
+ dpi = qt_defaultDpi();
+ return (v.pointSizeF() * dpi) / qreal(72.);
+ }
+ return v.pixelSize();
+}
+
+void QQuickFontValueType::setPixelSize(int size)
+{
+ if (size >0) {
+ if (pointSizeSet)
+ qWarning() << "Both point size and pixel size set. Using pixel size.";
+ v.setPixelSize(size);
+ pixelSizeSet = true;
+ } else {
+ pixelSizeSet = false;
+ }
+}
+
+QQuickFontValueType::Capitalization QQuickFontValueType::capitalization() const
+{
+ return (QQuickFontValueType::Capitalization)v.capitalization();
+}
+
+void QQuickFontValueType::setCapitalization(QQuickFontValueType::Capitalization c)
+{
+ v.setCapitalization((QFont::Capitalization)c);
+}
+
+qreal QQuickFontValueType::letterSpacing() const
+{
+ return v.letterSpacing();
+}
+
+void QQuickFontValueType::setLetterSpacing(qreal size)
+{
+ v.setLetterSpacing(QFont::AbsoluteSpacing, size);
+}
+
+qreal QQuickFontValueType::wordSpacing() const
+{
+ return v.wordSpacing();
+}
+
+void QQuickFontValueType::setWordSpacing(qreal size)
+{
+ v.setWordSpacing(size);
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h
new file mode 100644
index 0000000000..d2767db329
--- /dev/null
+++ b/src/quick/util/qquickvaluetypes_p.h
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKVALUETYPES_P_H
+#define QQUICKVALUETYPES_P_H
+
+#include <qqml.h>
+#include <qtquickglobal.h>
+#include <private/qqmlvaluetype_p.h>
+
+#include <QtGui/QColor>
+#include <QtGui/QVector2D>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
+#include <QtGui/QQuaternion>
+#include <QtGui/QMatrix4x4>
+#include <QtGui/QFont>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+namespace QQuickValueTypes {
+
+void registerValueTypes();
+
+}
+
+class Q_AUTOTEST_EXPORT QQuickColorValueType : public QQmlValueTypeBase<QColor>
+{
+ Q_PROPERTY(qreal r READ r WRITE setR)
+ Q_PROPERTY(qreal g READ g WRITE setG)
+ Q_PROPERTY(qreal b READ b WRITE setB)
+ Q_PROPERTY(qreal a READ a WRITE setA)
+ Q_OBJECT
+public:
+ QQuickColorValueType(QObject *parent = 0);
+
+ virtual QString toString() const;
+
+ qreal r() const;
+ qreal g() const;
+ qreal b() const;
+ qreal a() const;
+ void setR(qreal);
+ void setG(qreal);
+ void setB(qreal);
+ void setA(qreal);
+};
+
+class Q_AUTOTEST_EXPORT QQuickVector2DValueType : public QQmlValueTypeBase<QVector2D>
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_OBJECT
+public:
+ QQuickVector2DValueType(QObject *parent = 0);
+
+ virtual QString toString() const;
+
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
+};
+
+class Q_AUTOTEST_EXPORT QQuickVector3DValueType : public QQmlValueTypeBase<QVector3D>
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal z READ z WRITE setZ)
+ Q_OBJECT
+public:
+ QQuickVector3DValueType(QObject *parent = 0);
+
+ virtual QString toString() const;
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+};
+
+class Q_AUTOTEST_EXPORT QQuickVector4DValueType : public QQmlValueTypeBase<QVector4D>
+{
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal z READ z WRITE setZ)
+ Q_PROPERTY(qreal w READ w WRITE setW)
+ Q_OBJECT
+public:
+ QQuickVector4DValueType(QObject *parent = 0);
+
+ virtual QString toString() const;
+
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ qreal w() const;
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+ void setW(qreal);
+};
+
+class Q_AUTOTEST_EXPORT QQuickQuaternionValueType : public QQmlValueTypeBase<QQuaternion>
+{
+ Q_PROPERTY(qreal scalar READ scalar WRITE setScalar)
+ Q_PROPERTY(qreal x READ x WRITE setX)
+ Q_PROPERTY(qreal y READ y WRITE setY)
+ Q_PROPERTY(qreal z READ z WRITE setZ)
+ Q_OBJECT
+public:
+ QQuickQuaternionValueType(QObject *parent = 0);
+
+ virtual QString toString() const;
+
+ qreal scalar() const;
+ qreal x() const;
+ qreal y() const;
+ qreal z() const;
+ void setScalar(qreal);
+ void setX(qreal);
+ void setY(qreal);
+ void setZ(qreal);
+};
+
+class Q_AUTOTEST_EXPORT QQuickMatrix4x4ValueType : public QQmlValueTypeBase<QMatrix4x4>
+{
+ Q_PROPERTY(qreal m11 READ m11 WRITE setM11)
+ Q_PROPERTY(qreal m12 READ m12 WRITE setM12)
+ Q_PROPERTY(qreal m13 READ m13 WRITE setM13)
+ Q_PROPERTY(qreal m14 READ m14 WRITE setM14)
+ Q_PROPERTY(qreal m21 READ m21 WRITE setM21)
+ Q_PROPERTY(qreal m22 READ m22 WRITE setM22)
+ Q_PROPERTY(qreal m23 READ m23 WRITE setM23)
+ Q_PROPERTY(qreal m24 READ m24 WRITE setM24)
+ Q_PROPERTY(qreal m31 READ m31 WRITE setM31)
+ Q_PROPERTY(qreal m32 READ m32 WRITE setM32)
+ Q_PROPERTY(qreal m33 READ m33 WRITE setM33)
+ Q_PROPERTY(qreal m34 READ m34 WRITE setM34)
+ Q_PROPERTY(qreal m41 READ m41 WRITE setM41)
+ Q_PROPERTY(qreal m42 READ m42 WRITE setM42)
+ Q_PROPERTY(qreal m43 READ m43 WRITE setM43)
+ Q_PROPERTY(qreal m44 READ m44 WRITE setM44)
+ Q_OBJECT
+public:
+ QQuickMatrix4x4ValueType(QObject *parent = 0);
+
+ virtual QString toString() const;
+
+ qreal m11() const { return v(0, 0); }
+ qreal m12() const { return v(0, 1); }
+ qreal m13() const { return v(0, 2); }
+ qreal m14() const { return v(0, 3); }
+ qreal m21() const { return v(1, 0); }
+ qreal m22() const { return v(1, 1); }
+ qreal m23() const { return v(1, 2); }
+ qreal m24() const { return v(1, 3); }
+ qreal m31() const { return v(2, 0); }
+ qreal m32() const { return v(2, 1); }
+ qreal m33() const { return v(2, 2); }
+ qreal m34() const { return v(2, 3); }
+ qreal m41() const { return v(3, 0); }
+ qreal m42() const { return v(3, 1); }
+ qreal m43() const { return v(3, 2); }
+ qreal m44() const { return v(3, 3); }
+
+ void setM11(qreal value) { v(0, 0) = value; }
+ void setM12(qreal value) { v(0, 1) = value; }
+ void setM13(qreal value) { v(0, 2) = value; }
+ void setM14(qreal value) { v(0, 3) = value; }
+ void setM21(qreal value) { v(1, 0) = value; }
+ void setM22(qreal value) { v(1, 1) = value; }
+ void setM23(qreal value) { v(1, 2) = value; }
+ void setM24(qreal value) { v(1, 3) = value; }
+ void setM31(qreal value) { v(2, 0) = value; }
+ void setM32(qreal value) { v(2, 1) = value; }
+ void setM33(qreal value) { v(2, 2) = value; }
+ void setM34(qreal value) { v(2, 3) = value; }
+ void setM41(qreal value) { v(3, 0) = value; }
+ void setM42(qreal value) { v(3, 1) = value; }
+ void setM43(qreal value) { v(3, 2) = value; }
+ void setM44(qreal value) { v(3, 3) = value; }
+};
+
+class Q_AUTOTEST_EXPORT QQuickFontValueType : public QQmlValueTypeBase<QFont>
+{
+ Q_OBJECT
+ Q_ENUMS(FontWeight)
+ Q_ENUMS(Capitalization)
+
+ Q_PROPERTY(QString family READ family WRITE setFamily)
+ Q_PROPERTY(bool bold READ bold WRITE setBold)
+ Q_PROPERTY(FontWeight weight READ weight WRITE setWeight)
+ Q_PROPERTY(bool italic READ italic WRITE setItalic)
+ Q_PROPERTY(bool underline READ underline WRITE setUnderline)
+ Q_PROPERTY(bool overline READ overline WRITE setOverline)
+ Q_PROPERTY(bool strikeout READ strikeout WRITE setStrikeout)
+ Q_PROPERTY(qreal pointSize READ pointSize WRITE setPointSize)
+ Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize)
+ Q_PROPERTY(Capitalization capitalization READ capitalization WRITE setCapitalization)
+ Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing)
+ Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing)
+
+public:
+ enum FontWeight { Light = QFont::Light,
+ Normal = QFont::Normal,
+ DemiBold = QFont::DemiBold,
+ Bold = QFont::Bold,
+ Black = QFont::Black };
+ enum Capitalization { MixedCase = QFont::MixedCase,
+ AllUppercase = QFont::AllUppercase,
+ AllLowercase = QFont::AllLowercase,
+ SmallCaps = QFont::SmallCaps,
+ Capitalize = QFont::Capitalize };
+
+ QQuickFontValueType(QObject *parent = 0);
+
+ virtual QString toString() const;
+
+ QString family() const;
+ void setFamily(const QString &);
+
+ bool bold() const;
+ void setBold(bool b);
+
+ FontWeight weight() const;
+ void setWeight(FontWeight);
+
+ bool italic() const;
+ void setItalic(bool b);
+
+ bool underline() const;
+ void setUnderline(bool b);
+
+ bool overline() const;
+ void setOverline(bool b);
+
+ bool strikeout() const;
+ void setStrikeout(bool b);
+
+ qreal pointSize() const;
+ void setPointSize(qreal size);
+
+ int pixelSize() const;
+ void setPixelSize(int size);
+
+ Capitalization capitalization() const;
+ void setCapitalization(Capitalization);
+
+ qreal letterSpacing() const;
+ void setLetterSpacing(qreal spacing);
+
+ qreal wordSpacing() const;
+ void setWordSpacing(qreal spacing);
+
+ void onLoad();
+
+private:
+ bool pixelSizeSet;
+ bool pointSizeSet;
+ mutable QQmlNullableValue<int> dpi;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QQUICKVALUETYPES_P_H
diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri
index d720ef02c9..3d93b9f2f5 100644
--- a/src/quick/util/util.pri
+++ b/src/quick/util/util.pri
@@ -1,4 +1,5 @@
SOURCES += \
+ $$PWD/qquickapplication.cpp\
$$PWD/qquickutilmodule.cpp\
$$PWD/qquickconnections.cpp \
$$PWD/qquickpackage.cpp \
@@ -26,9 +27,12 @@ SOURCES += \
$$PWD/qquicklistcompositor.cpp \
$$PWD/qquickpathinterpolator.cpp \
$$PWD/qquickimageprovider.cpp \
- $$PWD/qquicksvgparser.cpp
+ $$PWD/qquicksvgparser.cpp \
+ $$PWD/qquickvaluetypes.cpp \
+ $$PWD/qquickglobal.cpp
HEADERS += \
+ $$PWD/qquickapplication_p.h\
$$PWD/qquickutilmodule_p.h\
$$PWD/qquickconnections_p.h \
$$PWD/qquickpackage_p.h \
@@ -60,4 +64,5 @@ HEADERS += \
$$PWD/qquicklistcompositor_p.h \
$$PWD/qquickpathinterpolator_p.h \
$$PWD/qquickimageprovider.h \
- $$PWD/qquicksvgparser_p.h
+ $$PWD/qquicksvgparser_p.h \
+ $$PWD/qquickvaluetypes_p.h