summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-01 06:59:11 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-04 12:00:24 -0700
commitd317eefb6726314efd20ae1007c2298ecf99e772 (patch)
tree050ed5ce6d1e4418fcc7e2a0feef6b1275f74e49 /mobile-widgets/qmlmanager.cpp
parentf58bc91d8bb81feb02d059a8f69025f8f6f5a6b0 (diff)
downloadsubsurface-d317eefb6726314efd20ae1007c2298ecf99e772.tar.gz
mobile UI: setup callback for the new notification mechanism
This simply passes the text to the existing notification text mechanism. The call to processEvents() ensures that Qt processes the UI events after we updated the notification and that the user gets timely updates; otherwise the UI might look like the app is hanging. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 1d1168ac4..56d17e728 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -76,6 +76,7 @@ extern "C" void showErrorFromC(char *buf)
QMetaObject::invokeMethod(QMLManager::instance(), "registerError", Qt::AutoConnection, Q_ARG(QString, error));
}
+// this gets called from libdivecomputer
static void progressCallback(const char *text)
{
QMLManager *self = QMLManager::instance();
@@ -92,18 +93,24 @@ static void appendTextToLogStandalone(const char *text)
self->appendTextToLog(QString(text));
}
+// this callback is used from the uiNotification() function
+// the detour via callback allows us to keep the core code independent from QMLManager
+// I'm not sure it makes sense to have three different progress callbacks,
+// but the usage models (and the situations in the program flow where they are used)
+// are really vastly different...
+// this is mainly intended for the early stages of the app so the user sees that
+// things are progressing
+static void showProgress(QString msg)
+{
+ QMLManager *self = QMLManager::instance();
+ if (self)
+ self->setNotificationText(msg);
+}
+
// show the git progress in the passive notification area
extern "C" int gitProgressCB(const char *text)
{
- static QMLManager *self;
-
- if (!self)
- self = QMLManager::instance();
-
- if (self) {
- self->appendTextToLog(text);
- self->setNotificationText(text);
- }
+ showProgress(QString(text));
// return 0 so that we don't end the download
return 0;
}
@@ -162,6 +169,8 @@ void QMLManager::usbRescan()
#endif
}
+extern void (*uiNotificationCallback)(QString);
+
QMLManager::QMLManager() : m_locationServiceEnabled(false),
m_verboseEnabled(false),
m_diveListProcessing(false),
@@ -233,6 +242,7 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
}
#endif
set_error_cb(&showErrorFromC);
+ uiNotificationCallback = showProgress;
appendTextToLog("Starting " + getUserAgent());
appendTextToLog(QStringLiteral("built with libdivecomputer v%1").arg(dc_version(NULL)));
appendTextToLog(QStringLiteral("built with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()));
@@ -244,7 +254,6 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
extern QString getAndroidHWInfo();
appendTextToLog(getAndroidHWInfo());
#endif
- setStartPageText(tr("Starting..."));
if (ignore_bt) {
m_btEnabled = false;
} else {
@@ -1705,8 +1714,10 @@ QString QMLManager::getGpsFromSiteName(const QString &siteName)
void QMLManager::setNotificationText(QString text)
{
+ appendTextToLog(QStringLiteral("showProgress: ") + text);
m_notificationText = text;
emit notificationTextChanged();
+ qApp->processEvents();
}
qreal QMLManager::lastDevicePixelRatio()