mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Android: move OnePlus font hack earlier
We want the new default font in place before the QML engine is initialized. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c90050f449
commit
fdfa540747
1 changed files with 13 additions and 14 deletions
|
@ -61,8 +61,20 @@ void exit_ui()
|
||||||
|
|
||||||
void run_ui()
|
void run_ui()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef SUBSURFACE_MOBILE
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
if (getAndroidHWInfo().contains("/OnePlus/")) {
|
||||||
|
QFontDatabase db;
|
||||||
|
int id = QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf");
|
||||||
|
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
||||||
|
QFont newDefaultFont;
|
||||||
|
newDefaultFont.setFamily(family);
|
||||||
|
(static_cast<QApplication *>(QCoreApplication::instance()))->setFont(newDefaultFont);
|
||||||
|
qDebug() << "Detected OnePlus device, trying to force bundled font" << family;
|
||||||
|
QFont defaultFont = (static_cast<QApplication *>(QCoreApplication::instance()))->font();
|
||||||
|
qDebug() << "Qt reports default font is set as" << defaultFont.family();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
register_qml_types(&engine);
|
register_qml_types(&engine);
|
||||||
LOG_STP("run_ui qml engine started");
|
LOG_STP("run_ui qml engine started");
|
||||||
|
@ -105,19 +117,6 @@ void run_ui()
|
||||||
ctxt->setContextProperty("connectionListModel", &connectionListModel);
|
ctxt->setContextProperty("connectionListModel", &connectionListModel);
|
||||||
ctxt->setContextProperty("logModel", MessageHandlerModel::self());
|
ctxt->setContextProperty("logModel", MessageHandlerModel::self());
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
|
||||||
if (getAndroidHWInfo().contains("/OnePlus/")) {
|
|
||||||
QFontDatabase db;
|
|
||||||
int id = QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf");
|
|
||||||
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
|
||||||
QFont newDefaultFont;
|
|
||||||
newDefaultFont.setFamily(family);
|
|
||||||
(static_cast<QApplication *>(QCoreApplication::instance()))->setFont(newDefaultFont);
|
|
||||||
qDebug() << "Detected OnePlus device, trying to force bundled font" << family;
|
|
||||||
QFont defaultFont = (static_cast<QApplication *>(QCoreApplication::instance()))->font();
|
|
||||||
qDebug() << "Qt reports default font is set as" << defaultFont.family();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
||||||
LOG_STP("run_ui qml loaded");
|
LOG_STP("run_ui qml loaded");
|
||||||
qqWindowObject = engine.rootObjects().value(0);
|
qqWindowObject = engine.rootObjects().value(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue