diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2012-07-04 14:56:38 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-10 14:22:34 +0200 |
commit | b0b4869440fc6e5af42797cbcaa64ec30238be73 (patch) | |
tree | 208f5f90c9ee6c3a71cc9e751a9374addede67d0 /src/quick/items/qquicktextedit.cpp | |
parent | c66d00a7f53d6a6a847bc7171529273f4d089923 (diff) |
Add option to use native rasterizer for SceneGraph text
For old-style (desktop components) apps using QML 2 on regular density
displays, distance field text will look out of place. We introduce
an option to use the native rasterizer instead if you would rather
have native look and feel than scalable text items.
Change-Id: Idb38e3c89f2deab9ae1963357c6c5fb235ddeab8
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 41b6e9472d..71e5dfb57b 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -344,6 +344,42 @@ void QQuickTextEdit::setTextFormat(TextFormat format) emit textFormatChanged(d->format); } +/*! + \qmlproperty enumeration QtQuick2::TextEdit::renderType + + Override the default rendering type for this component. + + Supported render types are: + \list + \li Text.QtRendering - the default + \li Text.NativeRendering + \endlist + + Select Text.NativeRendering if you prefer text to look native on the target platform and do + not require advanced features such as transformation of the text. Using such features in + combination with the NativeRendering render type will lend poor and sometimes pixelated + results. +*/ +QQuickTextEdit::RenderType QQuickTextEdit::renderType() const +{ + Q_D(const QQuickTextEdit); + return d->renderType; +} + +void QQuickTextEdit::setRenderType(QQuickTextEdit::RenderType renderType) +{ + Q_D(QQuickTextEdit); + if (d->renderType == renderType) + return; + + d->renderType = renderType; + emit renderTypeChanged(); + d->updateDefaultTextOption(); + + if (isComponentComplete()) + updateSize(); +} + QFont QQuickTextEdit::font() const { Q_D(const QQuickTextEdit); @@ -1631,6 +1667,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * node = static_cast<QQuickTextNode *>(oldNode); } + node->setUseNativeRenderer(d->renderType == NativeRendering); node->deleteContent(); node->setMatrix(QMatrix4x4()); @@ -2040,10 +2077,13 @@ void QQuickTextEditPrivate::updateDefaultTextOption() QTextOption::WrapMode oldWrapMode = opt.wrapMode(); opt.setWrapMode(QTextOption::WrapMode(wrapMode)); - opt.setUseDesignMetrics(true); + + bool oldUseDesignMetrics = opt.useDesignMetrics(); + opt.setUseDesignMetrics(renderType != QQuickTextEdit::NativeRendering); if (oldWrapMode != opt.wrapMode() || oldAlignment != opt.alignment() - || oldTextDirection != opt.textDirection()) { + || oldTextDirection != opt.textDirection() + || oldUseDesignMetrics != opt.useDesignMetrics()) { document->setDefaultTextOption(opt); } } |