Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qminimalintegration.cpp
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
#
include
"qminimalintegration.h"
6
#
include
"qminimalbackingstore.h"
7
8
#
include
<
QtGui
/
private
/
qpixmap_raster_p
.
h
>
9
#
include
<
QtGui
/
private
/
qguiapplication_p
.
h
>
10
#
include
<
qpa
/
qplatformfontdatabase
.
h
>
11
#
include
<
qpa
/
qplatformnativeinterface
.
h
>
12
#
include
<
qpa
/
qplatformwindow
.
h
>
13
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
14
15
#
if
defined
(
Q_OS_WIN
)
16
#
include
<
QtGui
/
private
/
qwindowsdirectwritefontdatabase_p
.
h
>
17
#
if
QT_CONFIG
(
freetype
)
18
#
include
<
QtGui
/
private
/
qwindowsfontdatabase_ft_p
.
h
>
19
#
endif
20
#
elif
defined
(
Q_OS_DARWIN
)
21
#
include
<
QtGui
/
private
/
qcoretextfontdatabase_p
.
h
>
22
#
endif
23
24
#
if
QT_CONFIG
(
fontconfig
)
25
#
include
<
QtGui
/
private
/
qgenericunixfontdatabase_p
.
h
>
26
#
endif
27
28
#
if
QT_CONFIG
(
freetype
)
29
#
include
<
QtGui
/
private
/
qfontengine_ft_p
.
h
>
30
#
include
<
QtGui
/
private
/
qfreetypefontdatabase_p
.
h
>
31
#
endif
32
33
#
if
!
defined
(
Q_OS_WIN
)
34
#
include
<
QtGui
/
private
/
qgenericunixeventdispatcher_p
.
h
>
35
#
else
36
#
include
<
QtCore
/
private
/
qeventdispatcher_win_p
.
h
>
37
#
endif
38
39
QT_BEGIN_NAMESPACE
40
41
using
namespace
Qt::StringLiterals;
42
43
class
QCoreTextFontEngine;
44
45
static
const
char
debugBackingStoreEnvironmentVariable
[] =
"QT_DEBUG_BACKINGSTORE"
;
46
47
static
inline
unsigned
parseOptions
(
const
QStringList ¶mList)
48
{
49
unsigned
options = 0;
50
for
(
const
QString ¶m : paramList) {
51
if
(param ==
"enable_fonts"_L1
)
52
options |= QMinimalIntegration::EnableFonts;
53
else
if
(param ==
"freetype"_L1
)
54
options |= QMinimalIntegration::FreeTypeFontDatabase;
55
else
if
(param ==
"fontconfig"_L1
)
56
options |= QMinimalIntegration::FontconfigDatabase;
57
}
58
return
options;
59
}
60
61
QMinimalIntegration
::
QMinimalIntegration
(
const
QStringList ¶meters)
62
:
m_fontDatabase
(
nullptr
)
63
,
m_options
(
parseOptions
(
parameters
))
64
{
65
if
(qEnvironmentVariableIsSet(
debugBackingStoreEnvironmentVariable
)
66
&& qEnvironmentVariableIntValue(
debugBackingStoreEnvironmentVariable
) > 0) {
67
m_options |=
DebugBackingStore
|
EnableFonts
;
68
}
69
70
m_primaryScreen =
new
QMinimalScreen
(
)
;
71
72
m_primaryScreen->mGeometry = QRect(0, 0, 240, 320);
73
m_primaryScreen
->
mDepth
= 32;
74
m_primaryScreen->mFormat = QImage::Format_ARGB32_Premultiplied;
75
76
QWindowSystemInterface::handleScreenAdded(m_primaryScreen);
77
}
78
79
QMinimalIntegration
::~
QMinimalIntegration
()
80
{
81
QWindowSystemInterface::handleScreenRemoved(m_primaryScreen);
82
delete
m_fontDatabase;
83
}
84
85
bool
QMinimalIntegration
::
hasCapability
(QPlatformIntegration::Capability cap)
const
86
{
87
switch
(cap) {
88
case
ThreadedPixmaps:
return
true
;
89
case
MultipleWindows:
return
true
;
90
case
RhiBasedRendering:
return
false
;
91
default
:
return
QPlatformIntegration::hasCapability(cap);
92
}
93
}
94
95
// Dummy font database that does not scan the fonts directory to be
96
// used for command line tools like qmlplugindump that do not create windows
97
// unless DebugBackingStore is activated.
98
class
DummyFontDatabase
:
public
QPlatformFontDatabase
99
{
100
public
:
101
virtual
void
populateFontDatabase
()
override
{}
102
};
103
104
QPlatformFontDatabase
*
QMinimalIntegration
::
fontDatabase
()
const
105
{
106
if
(!m_fontDatabase && (m_options & EnableFonts)) {
107
#
if
defined
(
Q_OS_WIN
)
108
if
(m_options & FreeTypeFontDatabase) {
109
#
if
QT_CONFIG
(
freetype
)
110
m_fontDatabase =
new
QWindowsFontDatabaseFT;
111
#
endif
// freetype
112
}
else
{
113
m_fontDatabase =
new
QWindowsDirectWriteFontDatabase;
114
}
115
#
elif
defined
(
Q_OS_DARWIN
)
116
if
(!(m_options & FontconfigDatabase)) {
117
if
(m_options & FreeTypeFontDatabase) {
118
#
if
QT_CONFIG
(
freetype
)
119
m_fontDatabase =
new
QCoreTextFontDatabaseEngineFactory<QFontEngineFT>;
120
#
endif
// freetype
121
}
else
{
122
m_fontDatabase =
new
QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>;
123
}
124
}
125
#
endif
126
127
if
(!m_fontDatabase) {
128
#
if
QT_CONFIG
(
fontconfig
)
129
m_fontDatabase =
new
QGenericUnixFontDatabase;
130
#
else
131
m_fontDatabase = QPlatformIntegration::fontDatabase();
132
#
endif
133
}
134
}
135
if
(!m_fontDatabase)
136
m_fontDatabase =
new
DummyFontDatabase;
137
return
m_fontDatabase;
138
}
139
140
QPlatformWindow
*
QMinimalIntegration
::
createPlatformWindow
(QWindow *window)
const
141
{
142
Q_UNUSED(window);
143
QPlatformWindow *w =
new
QPlatformWindow(window);
144
w->requestActivateWindow();
145
return
w;
146
}
147
148
QPlatformBackingStore
*
QMinimalIntegration
::
createPlatformBackingStore
(QWindow *window)
const
149
{
150
return
new
QMinimalBackingStore(window);
151
}
152
153
QAbstractEventDispatcher
*
QMinimalIntegration
::
createEventDispatcher
()
const
154
{
155
#
ifdef
Q_OS_WIN
156
return
new
QEventDispatcherWin32;
157
#
else
158
return
createUnixEventDispatcher();
159
#
endif
160
}
161
162
QPlatformNativeInterface
*
QMinimalIntegration
::
nativeInterface
()
const
163
{
164
if
(!m_nativeInterface)
165
m_nativeInterface.reset(
new
QPlatformNativeInterface);
166
return
m_nativeInterface.get();
167
}
168
169
QMinimalIntegration
*
QMinimalIntegration
::
instance
()
170
{
171
return
static_cast
<QMinimalIntegration *>(QGuiApplicationPrivate::platformIntegration());
172
}
173
174
QT_END_NAMESPACE
DummyFontDatabase
Definition
qminimalintegration.cpp:99
DummyFontDatabase::populateFontDatabase
virtual void populateFontDatabase() override
This function is called once at startup by Qt's internal font database.
Definition
qminimalintegration.cpp:101
QMinimalIntegration
Definition
qminimalintegration.h:33
QMinimalIntegration::fontDatabase
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
Definition
qminimalintegration.cpp:104
QMinimalIntegration::~QMinimalIntegration
~QMinimalIntegration()
Definition
qminimalintegration.cpp:79
QMinimalIntegration::createEventDispatcher
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
Definition
qminimalintegration.cpp:153
QMinimalIntegration::DebugBackingStore
@ DebugBackingStore
Definition
qminimalintegration.h:36
QMinimalIntegration::EnableFonts
@ EnableFonts
Definition
qminimalintegration.h:37
QMinimalIntegration::createPlatformBackingStore
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
Definition
qminimalintegration.cpp:148
QMinimalIntegration::QMinimalIntegration
QMinimalIntegration(const QStringList ¶meters)
Definition
qminimalintegration.cpp:61
QMinimalIntegration::nativeInterface
QPlatformNativeInterface * nativeInterface() const override
Definition
qminimalintegration.cpp:162
QMinimalIntegration::instance
static QMinimalIntegration * instance()
Definition
qminimalintegration.cpp:169
QMinimalIntegration::hasCapability
bool hasCapability(QPlatformIntegration::Capability cap) const override
Definition
qminimalintegration.cpp:85
QMinimalIntegration::createPlatformWindow
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
Definition
qminimalintegration.cpp:140
QMinimalScreen
Definition
qminimalintegration.h:16
QMinimalScreen::QMinimalScreen
QMinimalScreen()
Definition
qminimalintegration.h:18
QMinimalScreen::mDepth
int mDepth
Definition
qminimalintegration.h:27
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
parseOptions
static unsigned parseOptions(const QStringList ¶mList)
Definition
qminimalintegration.cpp:47
debugBackingStoreEnvironmentVariable
static const char debugBackingStoreEnvironmentVariable[]
Definition
qminimalintegration.cpp:45
qtbase
src
plugins
platforms
minimal
qminimalintegration.cpp
Generated on
for Qt by
1.18.0