From 460925b3f1dd9d2301b9c69558bd68843cd5f978 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 24 Jul 2017 15:15:18 +0200 Subject: Add a way to set the default render type of text-like elements f3446071da8357620d0c8593a04e3b4fbba88f21 introduced a build-time way to select the default render type of text-like elements. This patch adds also a way to select it at runtime, via a setter on QQuickWindow. (QQuickWindow has been chosen as convenience, rather than adding another namespace/class to just have this setter.) Given that QT_QUICK_DEFAULT_TEXT_RENDER_TYPE was never documented, I've taken the liberty of changing the accepted values for it (to match the new enumerator names in QQuickWindow, rather than the ones in QQuickText/QQuickTextEdit/etc.). [ChangeLog][QtQuick][QQuickWindow] It is now possible to set the default render type of text-like elements globally via the QQuickWindow::setTextRenderType() function. If you were using the (undocumented) QT_QUICK_DEFAULT_TEXT_RENDER_TYPE macro when building Qt Quick for the same purpose, note that the macro value needs now to be set to the "NativeTextRendering" value, instead of "NativeRendering". Change-Id: Id4b2dc3ec823971486e445ca4173b8be848fb4e3 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktextutil_p.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/quick/items/qquicktextutil_p.h') diff --git a/src/quick/items/qquicktextutil_p.h b/src/quick/items/qquicktextutil_p.h index 01055c95ec..bad5e738a8 100644 --- a/src/quick/items/qquicktextutil_p.h +++ b/src/quick/items/qquicktextutil_p.h @@ -54,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -64,6 +65,7 @@ public: template static void setCursorDelegate(Private *d, QQmlComponent *delegate); template static void createCursor(Private *d); + template static typename T::RenderType textRenderType(); static qreal alignedX(qreal textWidth, qreal itemWidth, int alignment); static qreal alignedY(qreal textHeight, qreal itemHeight, int alignment); @@ -124,6 +126,20 @@ void QQuickTextUtil::createCursor(Private *d) parent->update(); } +template +typename T::RenderType QQuickTextUtil::textRenderType() +{ + switch (QQuickWindow::textRenderType()) { + case QQuickWindow::QtTextRendering: + return T::QtRendering; + case QQuickWindow::NativeTextRendering: + return T::NativeRendering; + } + + Q_UNREACHABLE(); + return T::QtRendering; +} + QT_END_NAMESPACE #endif -- cgit v1.2.3