summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativevaluetype.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qdeclarativevaluetype.cpp')
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp46
1 files changed, 13 insertions, 33 deletions
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 839e0dd..261c84a 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -47,10 +47,6 @@
QT_BEGIN_NAMESPACE
-#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
-Q_DECLARE_METATYPE(QEasingCurve);
-#endif
-
template<typename T>
int qmlRegisterValueTypeEnums(const char *qmlName)
{
@@ -82,29 +78,18 @@ QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
// ### Optimize
for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
valueTypes[ii] = valueType(ii);
-#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
- easingType = qMetaTypeId<QEasingCurve>();
- easingValueType = valueType(easingType);
-#endif
}
QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory()
{
for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
delete valueTypes[ii];
-#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
- delete easingValueType;
-#endif
}
bool QDeclarativeValueTypeFactory::isValueType(int idx)
{
if ((uint)idx < QVariant::UserType)
return true;
-#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
- if (idx == qMetaTypeId<QEasingCurve>())
- return true;
-#endif
return false;
}
@@ -116,9 +101,6 @@ void QDeclarativeValueTypeFactory::registerValueTypes()
QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const
{
-#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
- if (idx == easingType) return easingValueType;
-#endif
return valueTypes[idx];
}
@@ -140,17 +122,11 @@ QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
return new QDeclarativeRectFValueType;
case QVariant::Vector3D:
return new QDeclarativeVector3DValueType;
-#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
case QVariant::EasingCurve:
return new QDeclarativeEasingValueType;
-#endif
case QVariant::Font:
return new QDeclarativeFontValueType;
default:
-#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
- if (t == qMetaTypeId<QEasingCurve>())
- return new QDeclarativeEasingValueType;
-#endif
return 0;
}
}
@@ -566,11 +542,7 @@ void QDeclarativeEasingValueType::write(QObject *obj, int idx, QDeclarativePrope
QVariant QDeclarativeEasingValueType::value()
{
-#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
return QVariant(easing);
-#else
- return QVariant::fromValue<QEasingCurve>(easing);
-#endif
}
void QDeclarativeEasingValueType::setValue(QVariant value)
@@ -619,7 +591,7 @@ void QDeclarativeEasingValueType::setPeriod(qreal period)
}
QDeclarativeFontValueType::QDeclarativeFontValueType(QObject *parent)
-: QDeclarativeValueType(parent), hasPixelSize(false)
+: QDeclarativeValueType(parent), pixelSizeSet(false), pointSizeSet(false)
{
}
@@ -627,6 +599,8 @@ void QDeclarativeFontValueType::read(QObject *obj, int idx)
{
void *a[] = { &font, 0 };
QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+ pixelSizeSet = false;
+ pointSizeSet = false;
}
void QDeclarativeFontValueType::write(QObject *obj, int idx, QDeclarativePropertyPrivate::WriteFlags flags)
@@ -724,13 +698,17 @@ qreal QDeclarativeFontValueType::pointSize() const
void QDeclarativeFontValueType::setPointSize(qreal size)
{
- if (hasPixelSize) {
+ if (pixelSizeSet) {
qWarning() << "Both point size and pixel size set. Using pixel size.";
return;
}
- if (size >= 0.0)
+ if (size >= 0.0) {
+ pointSizeSet = true;
font.setPointSizeF(size);
+ } else {
+ pointSizeSet = false;
+ }
}
int QDeclarativeFontValueType::pixelSize() const
@@ -741,10 +719,12 @@ int QDeclarativeFontValueType::pixelSize() const
void QDeclarativeFontValueType::setPixelSize(int size)
{
if (size >=0) {
+ if (pointSizeSet)
+ qWarning() << "Both point size and pixel size set. Using pixel size.";
font.setPixelSize(size);
- hasPixelSize = true;
+ pixelSizeSet = true;
} else {
- hasPixelSize = false;
+ pixelSizeSet = false;
}
}