Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquicktextutil_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKTEXTUTIL_P_H
5#define QQUICKTEXTUTIL_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQml/qqml.h>
19#include <QtQml/qqmlincubator.h>
20#include <QtQuick/qquickitem.h>
21#include <QtQuick/qquickwindow.h>
22#include <QtCore/private/qglobal_p.h>
23
25
26class QQuickTextUtil : public QObject // For the benefit of translations.
27{
29public:
30 template <typename Private> static void setCursorDelegate(Private *d, QQmlComponent *delegate);
31 template <typename Private> static void createCursor(Private *d);
32
33 template <typename T> static typename T::RenderType textRenderType();
34
35 static qreal alignedX(qreal textWidth, qreal itemWidth, int alignment);
36 static qreal alignedY(qreal textHeight, qreal itemHeight, int alignment);
37
38private:
42 const QRectF &cursorRectangle,
43 const char *className);
44
45};
46
47template <typename Private>
49{
50 if (d->cursorComponent == delegate)
51 return;
52
53 typename Private::Public *parent = d->q_func();
54
55 if (d->cursorComponent) {
58 }
59
60 delete d->cursorItem;
61 d->cursorItem = 0;
62 d->cursorPending = true;
63
64 d->cursorComponent = delegate;
65
66 if (parent->isCursorVisible() && parent->isComponentComplete())
68
69 Q_EMIT parent->cursorDelegateChanged();
70}
71
72template <typename Private>
74{
75 if (!d->cursorPending)
76 return;
77
78 d->cursorPending = false;
79
80 typename Private::Public *parent = d->q_func();
81 if (d->cursorComponent) {
82 d->cursorItem = createCursor(
83 d->cursorComponent,
84 parent,
85 parent->cursorRectangle(),
86 Private::Public::staticMetaObject.className());
87 }
88
89 d->setNativeCursorEnabled(!d->cursorItem);
90 d->updateType = Private::UpdatePaintNode;
91 parent->update();
92}
93
94template <typename T>
95typename T::RenderType QQuickTextUtil::textRenderType()
96{
97 switch (QQuickWindow::textRenderType()) {
98 case QQuickWindow::QtTextRendering:
99 return T::QtRendering;
100 case QQuickWindow::NativeTextRendering:
101 return T::NativeRendering;
102 case QQuickWindow::CurveTextRendering:
103 return T::CurveRendering;
104 }
105
106 Q_UNREACHABLE_RETURN(T::QtRendering);
107}
108
110
111#endif
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
The QQmlComponent class encapsulates a QML component definition.
Status
\qmltype Component \instantiates QQmlComponent\inqmlmodule QtQml
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
static qreal alignedX(qreal textWidth, qreal itemWidth, int alignment)
static void createCursor(Private *d)
static qreal alignedY(qreal textHeight, qreal itemHeight, int alignment)
static T::RenderType textRenderType()
static void setCursorDelegate(Private *d, QQmlComponent *delegate)
\inmodule QtCore\reentrant
Definition qrect.h:484
void statusChanged(QQmlComponent::Status status)
[1]
Definition qlogging.cpp:11
uint alignment
Combined button and popup list for selecting options.
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
static qreal component(const QPointF &point, unsigned int i)
#define Q_OBJECT
#define Q_EMIT
double qreal
Definition qtypes.h:187
const char className[16]
[1]
Definition qwizard.cpp:100
myObject disconnect()
[26]