summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-08 00:49:46 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-08 00:49:46 (GMT)
commitfac110fd9313972f001bf8b52b0254cc2d67ef66 (patch)
treea0f5dd1e08444abde9c3e6ad3f14a85b4714923a /src/declarative/qml
parent7f1eac149d76f33770f54b20fe7cd27a4e4b09d4 (diff)
downloadQt-fac110fd9313972f001bf8b52b0254cc2d67ef66.zip
Qt-fac110fd9313972f001bf8b52b0254cc2d67ef66.tar.gz
Qt-fac110fd9313972f001bf8b52b0254cc2d67ef66.tar.bz2
Fix setting of pointSize and pixelSize in different items.
Also ensure warning is issued regardless of the order both pointSize and pixelSize are set in the same item. Task-number: QTBUG-9665
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp18
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h3
2 files changed, 15 insertions, 6 deletions
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 839e0dd..49e7b79 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -619,7 +619,7 @@ void QDeclarativeEasingValueType::setPeriod(qreal period)
}
QDeclarativeFontValueType::QDeclarativeFontValueType(QObject *parent)
-: QDeclarativeValueType(parent), hasPixelSize(false)
+: QDeclarativeValueType(parent), pixelSizeSet(false), pointSizeSet(false)
{
}
@@ -627,6 +627,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 +726,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 +747,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;
}
}
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index 1fe8bd2..763177d 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -399,7 +399,8 @@ public:
private:
QFont font;
- bool hasPixelSize;
+ bool pixelSizeSet;
+ bool pointSizeSet;
};
QT_END_NAMESPACE