diff options
Diffstat (limited to 'subsurface-helper.cpp')
| -rw-r--r-- | subsurface-helper.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index c3249f03f..11f471a8b 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -25,6 +25,7 @@ #include "profile-widget/qmlprofile.h" #include "core/downloadfromdcthread.h" #include "core/subsurfacestartup.h" // for testqml +#include "core/metrics.h" #include "qt-models/diveimportedmodel.h" #else #include "desktop-widgets/mainwindow.h" @@ -67,12 +68,14 @@ void exit_ui() free((void *)existing_filename); } -void run_ui() -{ #ifdef SUBSURFACE_MOBILE +void run_mobile_ui(double initial_font_size) +{ #if defined(Q_OS_ANDROID) // work around an odd interaction between the OnePlus flavor of Android and Qt font handling if (getAndroidHWInfo().contains("/OnePlus/")) { + QFontInfo qfi(defaultModelFont()); + double basePointSize = qfi.pointSize(); QFontDatabase db; int id = QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular.ttf"); QStringList fontFamilies = QFontDatabase::applicationFontFamilies(id); @@ -80,6 +83,7 @@ void run_ui() QString family = fontFamilies.at(0); QFont newDefaultFont; newDefaultFont.setFamily(family); + newDefaultFont.setPointSize(basePointSize); (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(); @@ -123,9 +127,13 @@ void run_ui() ctxt->setContextProperty("diveModel", MobileModels::instance()->listModel()); set_non_bt_addresses(); + // we need to setup the initial font size before the QML UI is instantiated + ThemeInterface *themeInterface = ThemeInterface::instance(); + themeInterface->setInitialFontSize(initial_font_size); + ctxt->setContextProperty("connectionListModel", &connectionListModel); ctxt->setContextProperty("logModel", MessageHandlerModel::self()); - ctxt->setContextProperty("subsurfaceTheme", ThemeInterface::instance()); + ctxt->setContextProperty("subsurfaceTheme", themeInterface); qmlRegisterUncreatableType<QMLManager>("org.subsurfacedivelog.mobile",1,0,"ExportType","Enum is not a type"); @@ -183,11 +191,16 @@ void run_ui() qml_window->setWidth(width); #endif // not Q_OS_ANDROID and not Q_OS_IOS qml_window->show(); -#else + qApp->exec(); +} +#else // SUBSURFACE_MOBILE +// just run the desktop UI +void run_ui() +{ MainWindow::instance()->show(); -#endif // SUBSURFACE_MOBILE qApp->exec(); } +#endif // SUBSURFACE_MOBILE Q_DECLARE_METATYPE(duration_t) static void register_meta_types() |