Add font function to OffscreenTheme to run unit tests with offscreen

Two unit tests fail at the moment with the offscreen theme because
the font function of the offscreen theme does not return a monospace
font when asked for a monospace font. This patch fixes it.

Change-Id: Id682c75e2a94b246cffe97b342b1b562bac82a68
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Andreas Buhr 2020-11-23 16:44:17 +01:00
parent b051b18490
commit b7d4af3586

View File

@ -275,6 +275,20 @@ public:
}
return QPlatformTheme::themeHint(h);
}
virtual const QFont *font(Font type = SystemFont) const override
{
static QFont systemFont(QLatin1String("Sans Serif"), 9);
static QFont fixedFont(QLatin1String("monospace"), 9);
switch (type) {
case QPlatformTheme::SystemFont:
return &systemFont;
case QPlatformTheme::FixedFont:
return &fixedFont;
default:
return nullptr;
}
}
};
QPlatformTheme *QOffscreenIntegration::createPlatformTheme(const QString &name) const