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:
Gabriel de Dietrich 2016-03-07 14:34:40 -08:00
parent fce83bd9f8
commit 060e0f6628
3 changed files with 22 additions and 7 deletions

View File

@ -10,6 +10,8 @@ HEADERS = qminimalintegration.h \
OTHER_FILES += minimal.json
CONFIG += qpa/genericunixfontdatabase
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -

View File

@ -37,7 +37,14 @@
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/private/qguiapplication_p.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>
#else
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#endif
#if !defined(Q_OS_WIN)
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
@ -62,7 +69,7 @@ static inline unsigned parseOptions(const QStringList &paramList)
}
QMinimalIntegration::QMinimalIntegration(const QStringList &parameters)
: m_dummyFontDatabase(0)
: m_fontDatabase(0)
, m_options(parseOptions(parameters))
{
if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable)
@ -81,7 +88,7 @@ QMinimalIntegration::QMinimalIntegration(const QStringList &parameters)
QMinimalIntegration::~QMinimalIntegration()
{
delete m_dummyFontDatabase;
delete m_fontDatabase;
}
bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@ -104,11 +111,17 @@ public:
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();
if (!m_dummyFontDatabase)
m_dummyFontDatabase = new DummyFontDatabase;
return m_dummyFontDatabase;
#endif
}
if (!m_fontDatabase)
m_fontDatabase = new DummyFontDatabase;
return m_fontDatabase;
}
QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const

View File

@ -79,7 +79,7 @@ public:
static QMinimalIntegration *instance();
private:
mutable QPlatformFontDatabase *m_dummyFontDatabase;
mutable QPlatformFontDatabase *m_fontDatabase;
unsigned m_options;
};