diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-06-07 05:59:11 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-06-07 06:01:21 (GMT) |
commit | a4f4fff60d20e509cb57bd0dab30533e1e299aee (patch) | |
tree | 4f4416e01cfbf5ec7e16b0bf33f85e42078edb55 /src/declarative | |
parent | f410fb06c584fa0e893ab6066ea8b03a5323fe07 (diff) | |
download | Qt-a4f4fff60d20e509cb57bd0dab30533e1e299aee.zip Qt-a4f4fff60d20e509cb57bd0dab30533e1e299aee.tar.gz Qt-a4f4fff60d20e509cb57bd0dab30533e1e299aee.tar.bz2 |
Keep reported point/pixel size in sync.
This allows you to, for example, bind to a Text's font.pixelSize, even
if one was never explicitly set.
Task-number: QTBUG-11111
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qdeclarativevaluetype.cpp | 12 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativevaluetype_p.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index dbc25bb..c17ec95 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -47,6 +47,8 @@ QT_BEGIN_NAMESPACE +Q_DECL_IMPORT extern int qt_defaultDpi(); + template<typename T> int qmlRegisterValueTypeEnums(const char *qmlName) { @@ -909,6 +911,11 @@ void QDeclarativeFontValueType::setStrikeout(bool b) qreal QDeclarativeFontValueType::pointSize() const { + if (font.pointSizeF() == -1) { + if (dpi.isNull) + dpi = qt_defaultDpi(); + return font.pixelSize() * qreal(72.) / qreal(dpi); + } return font.pointSizeF(); } @@ -929,6 +936,11 @@ void QDeclarativeFontValueType::setPointSize(qreal size) int QDeclarativeFontValueType::pixelSize() const { + if (font.pixelSize() == -1) { + if (dpi.isNull) + dpi = qt_defaultDpi(); + return (font.pointSizeF() * dpi) / qreal(72.); + } return font.pixelSize(); } diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index 3eaecc1..4b1bbd6 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -55,6 +55,7 @@ #include "qdeclarativeproperty.h" #include "private/qdeclarativeproperty_p.h" +#include "private/qdeclarativenullablevalue_p_p.h" #include <QtCore/qobject.h> #include <QtCore/qrect.h> @@ -547,6 +548,7 @@ private: QFont font; bool pixelSizeSet; bool pointSizeSet; + mutable QDeclarativeNullableValue<int> dpi; }; QT_END_NAMESPACE |