diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-11-29 12:06:45 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-04 12:07:58 +0100 |
commit | 17333720e05bbe5d84d246c0850c8c2c047a141e (patch) | |
tree | f916a46b939d04ea70667e05205e5d1fbdcf43b1 /src/plugins/platforms/minimal/qminimalintegration.cpp | |
parent | 03ae80359f8b0cb39ae5e95902383869314716d9 (diff) |
Minimal plugin: Use a dummy font database for command line tools.
Suppress warnings like:
QFontDatabase: Cannot find font directory '...' - is Qt installed correctly?
occurring for example when using qmlplugindump.
Add option flags (similar to Windows plugin) to the integration
class to be used for QT_DEBUG_BACKINGSTORE and other functionality.
Add a dummy font database with empty populate() function to be
used unless the debug flag for the backing store is used.
Task-number: QTBUG-33674
Task-number: QTCREATORBUG-10685
Change-Id: I7eaff3025de12e6b0471a3430f986b0cd810e22c
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/plugins/platforms/minimal/qminimalintegration.cpp')
-rw-r--r-- | src/plugins/platforms/minimal/qminimalintegration.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index a08cede76a..76b4b5b0eb 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -50,11 +50,31 @@ #include <QtGui/private/qpixmap_raster_p.h> #include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformwindow.h> +#include <qpa/qplatformfontdatabase.h> QT_BEGIN_NAMESPACE -QMinimalIntegration::QMinimalIntegration() +static const char debugBackingStoreEnvironmentVariable[] = "QT_DEBUG_BACKINGSTORE"; + +static inline unsigned parseOptions(const QStringList ¶mList) +{ + unsigned options = 0; + foreach (const QString ¶m, paramList) { + if (param == QLatin1String("enable_fonts")) + options |= QMinimalIntegration::EnableFonts; + } + return options; +} + +QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters) + : m_dummyFontDatabase(0) + , m_options(parseOptions(parameters)) { + if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable) + && qgetenv(debugBackingStoreEnvironmentVariable).toInt() > 0) { + m_options |= DebugBackingStore | EnableFonts; + } + QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); @@ -64,6 +84,11 @@ QMinimalIntegration::QMinimalIntegration() screenAdded(mPrimaryScreen); } +QMinimalIntegration::~QMinimalIntegration() +{ + delete m_dummyFontDatabase; +} + bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { @@ -73,6 +98,24 @@ bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) co } } +// Dummy font database that does not scan the fonts directory to be +// used for command line tools like qmlplugindump that do not create windows +// unless DebugBackingStore is activated. +class DummyFontDatabase : public QPlatformFontDatabase +{ +public: + virtual void populateFontDatabase() {} +}; + +QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const +{ + if (m_options & EnableFonts) + return QPlatformIntegration::fontDatabase(); + if (!m_dummyFontDatabase) + m_dummyFontDatabase = new DummyFontDatabase; + return m_dummyFontDatabase; +} + QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const { Q_UNUSED(window); @@ -95,4 +138,9 @@ QAbstractEventDispatcher *QMinimalIntegration::createEventDispatcher() const #endif } +QMinimalIntegration *QMinimalIntegration::instance() +{ + return static_cast<QMinimalIntegration *>(QGuiApplicationPrivate::platformIntegration()); +} + QT_END_NAMESPACE |