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
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
6
7#include <QtGui/private/qpixmap_raster_p.h>
8#include <QtGui/private/qguiapplication_p.h>
9#include <qpa/qplatformfontdatabase.h>
10#include <qpa/qplatformnativeinterface.h>
11#include <qpa/qplatformwindow.h>
12#include <qpa/qwindowsysteminterface.h>
13
14#if defined(Q_OS_WIN)
15# include <QtGui/private/qwindowsfontdatabase_p.h>
16# if QT_CONFIG(freetype)
17# include <QtGui/private/qwindowsfontdatabase_ft_p.h>
18# endif
19#elif defined(Q_OS_DARWIN)
20# include <QtGui/private/qcoretextfontdatabase_p.h>
21#endif
22
23#if QT_CONFIG(fontconfig)
24# include <QtGui/private/qgenericunixfontdatabase_p.h>
25#endif
26
27#if QT_CONFIG(freetype)
28#include <QtGui/private/qfontengine_ft_p.h>
29#include <QtGui/private/qfreetypefontdatabase_p.h>
30#endif
31
32#if !defined(Q_OS_WIN)
33#include <QtGui/private/qgenericunixeventdispatcher_p.h>
34#else
35#include <QtCore/private/qeventdispatcher_win_p.h>
36#endif
37
39
40using namespace Qt::StringLiterals;
41
43
44static const char debugBackingStoreEnvironmentVariable[] = "QT_DEBUG_BACKINGSTORE";
45
46static inline unsigned parseOptions(const QStringList &paramList)
47{
48 unsigned options = 0;
49 for (const QString &param : paramList) {
50 if (param == "enable_fonts"_L1)
52 else if (param == "freetype"_L1)
54 else if (param == "fontconfig"_L1)
56 }
57 return options;
58}
59
61 : m_fontDatabase(nullptr)
62 , m_options(parseOptions(parameters))
63{
67 }
68
69 m_primaryScreen = new QMinimalScreen();
70
71 m_primaryScreen->mGeometry = QRect(0, 0, 240, 320);
72 m_primaryScreen->mDepth = 32;
74
76}
77
79{
81 delete m_fontDatabase;
82}
83
85{
86 switch (cap) {
87 case ThreadedPixmaps: return true;
88 case MultipleWindows: return true;
89 case RhiBasedRendering: return false;
91 }
92}
93
94// Dummy font database that does not scan the fonts directory to be
95// used for command line tools like qmlplugindump that do not create windows
96// unless DebugBackingStore is activated.
98{
99public:
100 virtual void populateFontDatabase() override {}
101};
102
104{
105 if (!m_fontDatabase && (m_options & EnableFonts)) {
106#if defined(Q_OS_WIN)
107 if (m_options & FreeTypeFontDatabase) {
108# if QT_CONFIG(freetype)
109 m_fontDatabase = new QWindowsFontDatabaseFT;
110# endif // freetype
111 } else {
112 m_fontDatabase = new QWindowsFontDatabase;
113 }
114#elif defined(Q_OS_DARWIN)
115 if (!(m_options & FontconfigDatabase)) {
116 if (m_options & FreeTypeFontDatabase) {
117# if QT_CONFIG(freetype)
118 m_fontDatabase = new QCoreTextFontDatabaseEngineFactory<QFontEngineFT>;
119# endif // freetype
120 } else {
121 m_fontDatabase = new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>;
122 }
123 }
124#endif
125
126 if (!m_fontDatabase) {
127#if QT_CONFIG(fontconfig)
128 m_fontDatabase = new QGenericUnixFontDatabase;
129#else
130 m_fontDatabase = QPlatformIntegration::fontDatabase();
131#endif
132 }
133 }
134 if (!m_fontDatabase)
135 m_fontDatabase = new DummyFontDatabase;
136 return m_fontDatabase;
137}
138
140{
143 w->requestActivateWindow();
144 return w;
145}
146
151
153{
154#ifdef Q_OS_WIN
155 return new QEventDispatcherWin32;
156#else
157 return createUnixEventDispatcher();
158#endif
159}
160
162{
163 if (!m_nativeInterface)
164 m_nativeInterface.reset(new QPlatformNativeInterface);
165 return m_nativeInterface.get();
166}
167
172
virtual void populateFontDatabase() override
This function is called once at startup by Qt's internal font database.
static QPlatformIntegration * platformIntegration()
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QPlatformBackingStore * createPlatformBackingStore(QWindow *window) const override
Factory function for QPlatformBackingStore.
QMinimalIntegration(const QStringList &parameters)
QPlatformNativeInterface * nativeInterface() const override
static QMinimalIntegration * instance()
bool hasCapability(QPlatformIntegration::Capability cap) const override
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
QImage::Format mFormat
The QPlatformBackingStore class provides the drawing area for top-level windows.
The QPlatformFontDatabase class makes it possible to customize how fonts are discovered and how they ...
virtual bool hasCapability(Capability cap) const
virtual QPlatformFontDatabase * fontDatabase() const
Accessor for the platform integration's fontdatabase.
Capability
Capabilities are used to determine specific features of a platform integration.
The QPlatformNativeInterface class provides an abstraction for retrieving native resource handles.
The QPlatformWindow class provides an abstraction for top-level windows.
\inmodule QtCore\reentrant
Definition qrect.h:30
T * get() const noexcept
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary=false)
Should be called by the implementation whenever a new screen is added.
static void handleScreenRemoved(QPlatformScreen *screen)
Should be called by the implementation whenever a screen is removed.
\inmodule QtGui
Definition qwindow.h:63
Font database for Windows.
Combined button and popup list for selecting options.
SharedPointerFileDialogOptions m_options
QPlatformFontDatabase QGenericUnixFontDatabase
static const char debugBackingStoreEnvironmentVariable[]
GLfloat GLfloat GLfloat w
[0]
GLenum const GLint * param
GLenum cap
Options parseOptions()
Definition main.cpp:369
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
#define Q_UNUSED(x)
QObject::connect nullptr
aWidget window() -> setWindowTitle("New Window Title")
[2]