mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure headless QPA plugin uses fusion style
This commit is contained in:
parent
652841175d
commit
982b3b20c9
@ -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
|
||||
|
@ -42,7 +42,9 @@ public:
|
||||
QPlatformWindow *createPlatformWindow(QWindow *window) const;
|
||||
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
|
||||
QAbstractEventDispatcher *createEventDispatcher() const;
|
||||
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user