minimal QPA plugin: Use fontconfig DB if available
This makes minimal a bit more useful for apps needing to access QFonts from non-UI environments. Change-Id: Idc5ca13f0c385ab9b4258e11fea7ec886515eea4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Louai Al-Khanji <louai.al-khanji@theqtcompany.com>
This commit is contained in:
parent
fce83bd9f8
commit
060e0f6628
@ -10,6 +10,8 @@ HEADERS = qminimalintegration.h \
|
|||||||
|
|
||||||
OTHER_FILES += minimal.json
|
OTHER_FILES += minimal.json
|
||||||
|
|
||||||
|
CONFIG += qpa/genericunixfontdatabase
|
||||||
|
|
||||||
PLUGIN_TYPE = platforms
|
PLUGIN_TYPE = platforms
|
||||||
PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin
|
PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin
|
||||||
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
|
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
|
||||||
|
@ -37,7 +37,14 @@
|
|||||||
#include <QtGui/private/qpixmap_raster_p.h>
|
#include <QtGui/private/qpixmap_raster_p.h>
|
||||||
#include <QtGui/private/qguiapplication_p.h>
|
#include <QtGui/private/qguiapplication_p.h>
|
||||||
#include <qpa/qplatformwindow.h>
|
#include <qpa/qplatformwindow.h>
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
|
||||||
|
#elif defined(QT_NO_FONTCONFIG)
|
||||||
#include <qpa/qplatformfontdatabase.h>
|
#include <qpa/qplatformfontdatabase.h>
|
||||||
|
#else
|
||||||
|
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
|
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
|
||||||
@ -62,7 +69,7 @@ static inline unsigned parseOptions(const QStringList ¶mList)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters)
|
QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters)
|
||||||
: m_dummyFontDatabase(0)
|
: m_fontDatabase(0)
|
||||||
, m_options(parseOptions(parameters))
|
, m_options(parseOptions(parameters))
|
||||||
{
|
{
|
||||||
if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable)
|
if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable)
|
||||||
@ -81,7 +88,7 @@ QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters)
|
|||||||
|
|
||||||
QMinimalIntegration::~QMinimalIntegration()
|
QMinimalIntegration::~QMinimalIntegration()
|
||||||
{
|
{
|
||||||
delete m_dummyFontDatabase;
|
delete m_fontDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const
|
bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const
|
||||||
@ -104,11 +111,17 @@ public:
|
|||||||
|
|
||||||
QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const
|
QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const
|
||||||
{
|
{
|
||||||
if (m_options & EnableFonts)
|
if (m_options & EnableFonts) {
|
||||||
|
#ifndef QT_NO_FONTCONFIG
|
||||||
|
if (!m_fontDatabase)
|
||||||
|
m_fontDatabase = new QGenericUnixFontDatabase;
|
||||||
|
#else
|
||||||
return QPlatformIntegration::fontDatabase();
|
return QPlatformIntegration::fontDatabase();
|
||||||
if (!m_dummyFontDatabase)
|
#endif
|
||||||
m_dummyFontDatabase = new DummyFontDatabase;
|
}
|
||||||
return m_dummyFontDatabase;
|
if (!m_fontDatabase)
|
||||||
|
m_fontDatabase = new DummyFontDatabase;
|
||||||
|
return m_fontDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const
|
QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
static QMinimalIntegration *instance();
|
static QMinimalIntegration *instance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QPlatformFontDatabase *m_dummyFontDatabase;
|
mutable QPlatformFontDatabase *m_fontDatabase;
|
||||||
unsigned m_options;
|
unsigned m_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user