summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-10-11 19:38:24 +0200
committerGravatar Jan Mulder <jlmulder@xs4all.nl>2017-10-12 09:32:12 +0200
commitfa5e685279b66b14d8069b5214890ca7148487ef (patch)
tree00fb676df60ec5fa69e6f48a7d3129e592ad114f
parent8b8863b6407f4c80bfb3f4a51ea8eeeedf7f0ab5 (diff)
downloadsubsurface-fa5e685279b66b14d8069b5214890ca7148487ef.tar.gz
Add function for non-BT connection addresses
Simple rewrite of a piece of code separated to its own function so that is can be used in other places as well. To avoid code duplication for dynamic BT on/off switching on mobile. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
-rw-r--r--core/qt-gui.h1
-rw-r--r--subsurface-mobile-helper.cpp25
2 files changed, 16 insertions, 10 deletions
diff --git a/core/qt-gui.h b/core/qt-gui.h
index 59e79c268..1fc7d161e 100644
--- a/core/qt-gui.h
+++ b/core/qt-gui.h
@@ -7,6 +7,7 @@ void init_ui();
void run_ui();
void exit_ui();
+void set_non_bt_addresses();
#if defined(SUBSURFACE_MOBILE)
#include <QQuickWindow>
diff --git a/subsurface-mobile-helper.cpp b/subsurface-mobile-helper.cpp
index 56ad029e1..ae7143404 100644
--- a/subsurface-mobile-helper.cpp
+++ b/subsurface-mobile-helper.cpp
@@ -30,6 +30,19 @@
QObject *qqWindowObject = NULL;
+void set_non_bt_addresses() {
+#if defined(Q_OS_ANDROID)
+ connectionListModel.addAddress("FTDI");
+#elif defined(Q_OS_LINUX) // since this is in the else, it does NOT include Android
+ connectionListModel.addAddress("/dev/ttyS0");
+ connectionListModel.addAddress("/dev/ttyS1");
+ connectionListModel.addAddress("/dev/ttyS2");
+ connectionListModel.addAddress("/dev/ttyS3");
+ // this makes debugging so much easier - use the simulator
+ connectionListModel.addAddress("/tmp/ttyS1");
+#endif
+}
+
void init_ui()
{
init_qt_late();
@@ -76,16 +89,8 @@ void run_ui()
ctxt->setContextProperty("diveModel", sortModel);
ctxt->setContextProperty("gpsModel", gpsSortModel);
ctxt->setContextProperty("vendorList", vendorList);
-#if defined(Q_OS_ANDROID)
- connectionListModel.addAddress("FTDI");
-#elif defined(Q_OS_LINUX) // since this is in the else, it does NOT include Android
- connectionListModel.addAddress("/dev/ttyS0");
- connectionListModel.addAddress("/dev/ttyS1");
- connectionListModel.addAddress("/dev/ttyS2");
- connectionListModel.addAddress("/dev/ttyS3");
- // this makes debugging so much easier - use the simulator
- connectionListModel.addAddress("/tmp/ttyS1");
-#endif
+ set_non_bt_addresses();
+
ctxt->setContextProperty("connectionListModel", &connectionListModel);
ctxt->setContextProperty("logModel", MessageHandlerModel::self());