Ensure headless QPA plugin uses fusion style

This commit is contained in:
Kovid Goyal 2020-02-05 14:12:09 +05:30
parent 652841175d
commit 982b3b20c9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 35 additions and 2 deletions

View File

@ -20,6 +20,7 @@ class QCoreTextFontEngine;
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformfontdatabase.h>
#include <qpa/qplatformtheme.h>
QT_BEGIN_NAMESPACE
@ -128,4 +129,35 @@ HeadlessIntegration *HeadlessIntegration::instance()
return static_cast<HeadlessIntegration *>(QGuiApplicationPrivate::platformIntegration());
}
static QString themeName() { return QStringLiteral("headless"); }
QStringList HeadlessIntegration::themeNames() const
{
return QStringList(themeName());
}
// Restrict the styles to "fusion" to prevent native styles requiring native
// window handles (eg Windows Vista style) from being used.
class HeadlessTheme : public QPlatformTheme
{
public:
HeadlessTheme() {}
QVariant themeHint(ThemeHint h) const override
{
switch (h) {
case StyleNames:
return QVariant(QStringList(QStringLiteral("fusion")));
default:
break;
}
return QPlatformTheme::themeHint(h);
}
};
QPlatformTheme *HeadlessIntegration::createPlatformTheme(const QString &name) const
{
return name == themeName() ? new HeadlessTheme() : nullptr;
}
QT_END_NAMESPACE

View File

@ -43,6 +43,8 @@ public:
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QAbstractEventDispatcher *createEventDispatcher() const;
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
QStringList themeNames() const override;
QPlatformTheme *createPlatformTheme(const QString &name) const override;
unsigned options() const { return 0; }
@ -56,4 +58,3 @@ private:
};
QT_END_NAMESPACE