Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qlabel_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// Qt-Security score:significant reason:default
4
5#ifndef QLABEL_P_H
6#define QLABEL_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "qlabel.h"
21
22#include "private/qtextdocumentlayout_p.h"
23#include "private/qwidgettextcontrol_p.h"
25#include "qframe_p.h"
26#include "qtextdocument.h"
27#if QT_CONFIG(movie)
28#include "qmovie.h"
29#endif
30#include "qpicture.h"
31#include "qpixmap.h"
32#if QT_CONFIG(menu)
33#include "qmenu.h"
34#endif
35
36#include <QtCore/qpointer.h>
37
38#include <array>
39#include <optional>
40
42
43class Q_AUTOTEST_EXPORT QLabelPrivate : public QFramePrivate
44{
45 Q_DECLARE_PUBLIC(QLabel)
46public:
47 QLabelPrivate();
48 ~QLabelPrivate();
49
50 void init();
51 void clearContents();
52 void updateLabel();
53 QSize sizeForWidth(int w) const;
54
55#if QT_CONFIG(movie)
56 void movieUpdated(const QRect &rect);
57 void movieResized(const QSize &size);
58#endif
59#ifndef QT_NO_SHORTCUT
60 void updateShortcut();
61 void buddyDeleted();
62#endif
63 inline bool needTextControl() const {
64 Q_Q(const QLabel);
65 return isTextLabel
66 && (effectiveTextFormat != Qt::PlainText
67 || (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard))
68 || q->focusPolicy() != Qt::NoFocus);
69 }
70
71 void ensureTextPopulated() const;
72 void ensureTextLayouted() const;
73 void ensureTextControl() const;
74 void sendControlEvent(QEvent *e);
75
76 void linkHovered(const QString &link);
77
78 QRectF layoutRect() const;
79 QRect documentRect() const;
80 QPoint layoutPoint(const QPoint& p) const;
81 Qt::LayoutDirection textDirection() const;
82#ifndef QT_NO_CONTEXTMENU
83 QMenu *createStandardContextMenu(const QPoint &pos);
84#endif
85
86 mutable QSize sh;
87 mutable QSize msh;
88 QString text;
89 std::optional<QIcon> icon;
90 QSize pixmapSize;
91#ifndef QT_NO_PICTURE
92 std::optional<QPicture> picture;
93#endif
94#if QT_CONFIG(movie)
95 QPointer<QMovie> movie;
96 std::array<QMetaObject::Connection, 2> movieConnections;
97#endif
98 mutable QWidgetTextControl *control = nullptr;
99 mutable QTextCursor shortcutCursor;
100#ifndef QT_NO_CURSOR
101 QCursor cursor;
102#endif
103#ifndef QT_NO_SHORTCUT
104 QPointer<QWidget> buddy;
105 int shortcutId = 0;
106#endif
107 Qt::TextFormat textformat = Qt::AutoText;
108 Qt::TextFormat effectiveTextFormat = Qt::PlainText;
109 Qt::TextInteractionFlags textInteractionFlags = Qt::LinksAccessibleByMouse;
110 mutable QSizePolicy sizePolicy;
111 int margin = 0;
112 int align = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextExpandTabs;
113 int indent = -1;
114 mutable uint valid_hints : 1;
115 uint scaledcontents : 1;
116 mutable uint textLayoutDirty : 1;
117 mutable uint textDirty : 1;
118 mutable uint isTextLabel : 1;
119 mutable uint hasShortcut : 1;
120#ifndef QT_NO_CURSOR
121 uint validCursor : 1;
122 uint onAnchor : 1;
123#endif
124 uint openExternalLinks : 1;
125 // <-- space for more bit field values here
126 QTextDocument::ResourceProvider resourceProvider = nullptr;
127
128 friend class QMessageBoxPrivate;
129};
130
131QT_END_NAMESPACE
132
133#endif // QLABEL_P_H