From 14721175416772d23c9757e74b78ec8be448aac7 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 14 Jan 2021 17:04:37 -0800 Subject: cleanup: create separate UI entry points for desktop and mobile This doesn't really change anything, but makes the code easier to read. Signed-off-by: Dirk Hohndel --- core/qt-gui.h | 4 +++- subsurface-helper.cpp | 13 +++++++++---- subsurface-mobile-main.cpp | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/qt-gui.h b/core/qt-gui.h index 9bfe0e001..dc0fb2348 100644 --- a/core/qt-gui.h +++ b/core/qt-gui.h @@ -5,12 +5,14 @@ void init_qt_late(); void init_ui(); -void run_ui(); void exit_ui(); void set_non_bt_addresses(); #if defined(SUBSURFACE_MOBILE) #include +void run_mobile_ui(); +#else +void run_ui(); #endif #endif // QT_GUI_H diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 6b92fe203..c8cb8f8ee 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -68,9 +68,9 @@ void exit_ui() free((void *)existing_filename); } -void run_ui() -{ #ifdef SUBSURFACE_MOBILE +void run_mobile_ui() +{ #if defined(Q_OS_ANDROID) // work around an odd interaction between the OnePlus flavor of Android and Qt font handling if (getAndroidHWInfo().contains("/OnePlus/")) { @@ -187,11 +187,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() diff --git a/subsurface-mobile-main.cpp b/subsurface-mobile-main.cpp index 7ceebcc5f..89a1f4c64 100644 --- a/subsurface-mobile-main.cpp +++ b/subsurface-mobile-main.cpp @@ -76,7 +76,7 @@ int main(int argc, char **argv) init_proxy(); if (!quit) - run_ui(); + run_mobile_ui(); exit_ui(); taglist_free(g_tag_list); parse_xml_exit(); -- cgit v1.2.3-70-g09d2