diff options
-rw-r--r-- | src/quick/items/qquicktext.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 5 | ||||
-rw-r--r-- | src/quick/items/qquicktextedit_p_p.h | 7 | ||||
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 5 | ||||
-rw-r--r-- | src/quick/items/qquicktextinput_p_p.h | 7 | ||||
-rw-r--r-- | src/quick/items/qquicktextutil_p.h | 16 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 51 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.h | 9 | ||||
-rw-r--r-- | src/quick/items/qquickwindow_p.h | 1 | ||||
-rw-r--r-- | tools/qmlscene/main.cpp | 20 |
10 files changed, 111 insertions, 20 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 5ca0bb5f79..07cc1ff76e 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -80,11 +80,7 @@ QQuickTextPrivate::QQuickTextPrivate() , elideMode(QQuickText::ElideNone), hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop) , format(QQuickText::AutoText), wrapMode(QQuickText::NoWrap) , style(QQuickText::Normal) -#if defined(QT_QUICK_DEFAULT_TEXT_RENDER_TYPE) - , renderType(QQuickText::QT_QUICK_DEFAULT_TEXT_RENDER_TYPE) -#else - , renderType(QQuickText::QtRendering) -#endif + , renderType(QQuickTextUtil::textRenderType<QQuickText>()) , updateType(UpdatePaintNode) , maximumLineCountValid(false), updateOnComponentComplete(true), richText(false) , styledText(false), widthExceeded(false), heightExceeded(false), internalWidthUpdate(false) @@ -2827,7 +2823,7 @@ void QQuickText::hoverLeaveEvent(QHoverEvent *event) Supported render types are: \list - \li Text.QtRendering - the default + \li Text.QtRendering \li Text.NativeRendering \endlist @@ -2835,6 +2831,8 @@ void QQuickText::hoverLeaveEvent(QHoverEvent *event) 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. + + The default rendering type is determined by \l QQuickWindow::textRenderType(). */ QQuickText::RenderType QQuickText::renderType() const { diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index f22c5f00be..193f804c13 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -45,7 +45,6 @@ #include "qquickwindow.h" #include "qquicktextnode_p.h" #include "qquicktextnodeengine_p.h" -#include "qquicktextutil_p.h" #include <QtCore/qmath.h> #include <QtGui/qguiapplication.h> @@ -495,7 +494,7 @@ void QQuickTextEdit::setTextFormat(TextFormat format) Supported render types are: \list - \li Text.QtRendering - the default + \li Text.QtRendering \li Text.NativeRendering \endlist @@ -503,6 +502,8 @@ void QQuickTextEdit::setTextFormat(TextFormat format) 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. + + The default rendering type is determined by \l QQuickWindow::textRenderType(). */ QQuickTextEdit::RenderType QQuickTextEdit::renderType() const { diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h index 03bce00cb0..455fffbcbc 100644 --- a/src/quick/items/qquicktextedit_p_p.h +++ b/src/quick/items/qquicktextedit_p_p.h @@ -53,6 +53,7 @@ #include "qquicktextedit_p.h" #include "qquickimplicitsizeitem_p_p.h" +#include "qquicktextutil_p.h" #include <QtQml/qqml.h> #include <QtCore/qlist.h> @@ -112,11 +113,7 @@ public: , quickDocument(0), lastSelectionStart(0), lastSelectionEnd(0), lineCount(0) , hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop) , format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap) -#if defined(QT_QUICK_DEFAULT_TEXT_RENDER_TYPE) - , renderType(QQuickTextEdit::QT_QUICK_DEFAULT_TEXT_RENDER_TYPE) -#else - , renderType(QQuickTextEdit::QtRendering) -#endif + , renderType(QQuickTextUtil::textRenderType<QQuickTextEdit>()) , contentDirection(Qt::LayoutDirectionAuto) , mouseSelectionMode(QQuickTextEdit::SelectCharacters) #if QT_CONFIG(im) diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 06ad0a9dbf..d01d604171 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -40,7 +40,6 @@ #include "qquicktextinput_p.h" #include "qquicktextinput_p_p.h" #include "qquickwindow.h" -#include "qquicktextutil_p.h" #include <private/qqmlglobal_p.h> #include <private/qv4scopedvalue_p.h> @@ -157,7 +156,7 @@ void QQuickTextInput::setText(const QString &s) Supported render types are: \list - \li Text.QtRendering - the default + \li Text.QtRendering \li Text.NativeRendering \endlist @@ -165,6 +164,8 @@ void QQuickTextInput::setText(const QString &s) 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. + + The default rendering type is determined by \l QQuickWindow::textRenderType(). */ QQuickTextInput::RenderType QQuickTextInput::renderType() const { diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h index 0bf5779a53..c3218197a4 100644 --- a/src/quick/items/qquicktextinput_p_p.h +++ b/src/quick/items/qquicktextinput_p_p.h @@ -43,6 +43,7 @@ #include "qquicktextinput_p.h" #include "qquicktext_p.h" #include "qquickimplicitsizeitem_p_p.h" +#include "qquicktextutil_p.h" #include <QtQml/qqml.h> #include <QtCore/qelapsedtimer.h> @@ -122,11 +123,7 @@ public: , vAlign(QQuickTextInput::AlignTop) , wrapMode(QQuickTextInput::NoWrap) , m_echoMode(QQuickTextInput::Normal) -#if defined(QT_QUICK_DEFAULT_TEXT_RENDER_TYPE) - , renderType(QQuickTextInput::QT_QUICK_DEFAULT_TEXT_RENDER_TYPE) -#else - , renderType(QQuickTextInput::QtRendering) -#endif + , renderType(QQuickTextUtil::textRenderType<QQuickTextInput>()) , updateType(UpdatePaintNode) , mouseSelectionMode(QQuickTextInput::SelectCharacters) , m_layoutDirection(Qt::LayoutDirectionAuto) 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 <QtQml/qqml.h> #include <QtQml/qqmlincubator.h> #include <QtQuick/qquickitem.h> +#include <QtQuick/qquickwindow.h> QT_BEGIN_NAMESPACE @@ -64,6 +65,7 @@ public: template <typename Private> static void setCursorDelegate(Private *d, QQmlComponent *delegate); template <typename Private> static void createCursor(Private *d); + template <typename T> 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> +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 diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 7b331251f0..bc99f49667 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -93,6 +93,12 @@ extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_ bool QQuickWindowPrivate::defaultAlphaBuffer = false; +#if defined(QT_QUICK_DEFAULT_TEXT_RENDER_TYPE) +QQuickWindow::TextRenderType QQuickWindowPrivate::textRenderType = QQuickWindow::QT_QUICK_DEFAULT_TEXT_RENDER_TYPE; +#else +QQuickWindow::TextRenderType QQuickWindowPrivate::textRenderType = QQuickWindow::QtTextRendering; +#endif + void QQuickWindowPrivate::updateFocusItemTransform() { #if QT_CONFIG(im) @@ -3825,6 +3831,23 @@ QQmlIncubationController *QQuickWindow::incubationController() const */ /*! + \enum QQuickWindow::TextRenderType + \since 5.10 + + This enum describes the default render type of text-like elements in Qt + Quick (\l Text, \l TextInput, etc.). + + Select NativeTextRendering 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 NativeTextRendering + render type will lend poor and sometimes pixelated results. + + \value QtTextRendering Use Qt's own rasterization algorithm. + + \value NativeTextRendering Use the operating system's native rasterizer for text. +*/ + +/*! \fn void QQuickWindow::beforeSynchronizing() This signal is emitted before the scene graph is synchronized with the QML state. @@ -4846,6 +4869,34 @@ QSGNinePatchNode *QQuickWindow::createNinePatchNode() const return isSceneGraphInitialized() ? d->context->sceneGraphContext()->createNinePatchNode() : nullptr; } +/*! + \since 5.10 + + Returns the render type of text-like elements in Qt Quick. + The default is QQuickWindow::QtTextRendering. + + \sa setTextRenderType() +*/ +QQuickWindow::TextRenderType QQuickWindow::textRenderType() +{ + return QQuickWindowPrivate::textRenderType; +} + +/*! + \since 5.10 + + Sets the default render type of text-like elements in Qt Quick to \a renderType. + + \note setting the render type will only affect elements created afterwards; + the render type of existing elements will not be modified. + + \sa textRenderType() +*/ +void QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType renderType) +{ + QQuickWindowPrivate::textRenderType = renderType; +} + #include "moc_qquickwindow.cpp" QT_END_NAMESPACE diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index d1a16fbeb6..022c4738f2 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -100,6 +100,12 @@ public: }; Q_ENUM(SceneGraphError) + enum TextRenderType { + QtTextRendering, + NativeTextRendering + }; + Q_ENUM(TextRenderType) + explicit QQuickWindow(QWindow *parent = Q_NULLPTR); explicit QQuickWindow(QQuickRenderControl *renderControl); @@ -170,6 +176,9 @@ public: QSGImageNode *createImageNode() const; QSGNinePatchNode *createNinePatchNode() const; + static TextRenderType textRenderType(); + static void setTextRenderType(TextRenderType renderType); + Q_SIGNALS: void frameSwapped(); Q_REVISION(2) void openglContextCreated(QOpenGLContext *context); diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 14564a7f55..837ef11d25 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -279,6 +279,7 @@ public: mutable QQuickWindowIncubationController *incubationController; static bool defaultAlphaBuffer; + static QQuickWindow::TextRenderType textRenderType; static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1); diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index f411c6becc..fc8b9c5292 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -159,6 +159,7 @@ struct Options , coreProfile(false) , verbose(false) , applicationType(DefaultQmlApplicationType) + , textRenderType(QQuickWindow::textRenderType()) { // QtWebEngine needs a shared context in order for the GPU thread to // upload textures. @@ -182,6 +183,7 @@ struct Options QVector<Qt::ApplicationAttribute> applicationAttributes; QString translationFile; QmlApplicationType applicationType; + QQuickWindow::TextRenderType textRenderType; }; #if defined(QMLSCENE_BUNDLE) @@ -377,6 +379,7 @@ static void usage() #ifdef QT_WIDGETS_LIB puts(" --apptype [gui|widgets] ...........Select which application class to use. Default is widgets."); #endif + puts(" --textrendertype [qt|native].......Select the default render type for text-like elements."); puts(" -I <path> ........................ Add <path> to the list of import paths"); puts(" -P <path> ........................ Add <path> to the list of plugin paths"); puts(" -translation <translationfile> ... Set the language to run in"); @@ -456,6 +459,19 @@ static QUrl parseUrlArgument(const QString &arg) return url; } +static QQuickWindow::TextRenderType parseTextRenderType(const QString &renderType) +{ + if (renderType == QLatin1String("qt")) + return QQuickWindow::QtTextRendering; + else if (renderType == QLatin1String("native")) + return QQuickWindow::NativeTextRendering; + + usage(); + + Q_UNREACHABLE(); + return QQuickWindow::QtTextRendering; +} + int main(int argc, char ** argv) { Options options; @@ -536,6 +552,8 @@ int main(int argc, char ** argv) pluginPaths.append(arguments.at(++i)); else if (lowerArgument == QLatin1String("--apptype")) ++i; // Consume previously parsed argument + else if (lowerArgument == QLatin1String("--textrendertype") && i + 1 < size) + options.textRenderType = parseTextRenderType(arguments.at(++i)); else if (lowerArgument == QLatin1String("--help") || lowerArgument == QLatin1String("-help") || lowerArgument == QLatin1String("--h") @@ -564,6 +582,8 @@ int main(int argc, char ** argv) } #endif + QQuickWindow::setTextRenderType(options.textRenderType); + QUnifiedTimer::instance()->setSlowModeEnabled(options.slowAnimations); if (options.url.isEmpty()) |