From 2fc99092fb71ee58e1009b9e402e7af38afd6653 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 3 Dec 2015 15:59:40 -0800 Subject: QML-UI: replace the two ways to log progress with one The logging to the UI didn't work anymore since the message area had been removed in commit 8646934ba351 ("Simple DiveList as initial Page"). This way all the updates simply land on the Log page. Signed-off-by: Dirk Hohndel --- qt-mobile/qmlmanager.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'qt-mobile/qmlmanager.cpp') diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index 2ebd11159..eb0ef7022 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -9,17 +9,21 @@ #include "qthelper.h" #include "qt-gui.h" -void qmlUiShowMessage(const char *errorString) +QMLManager *QMLManager::m_instance = NULL; + +static void appendTextToLogStandalone(const char *text) { - if (qqWindowObject && !qqWindowObject->setProperty("messageText", QVariant(errorString))) - qDebug() << "couldn't set property messageText to" << errorString; + QMLManager *mgr = QMLManager::instance(); + if (mgr) + mgr->appendTextToLog(QString(text)); } QMLManager::QMLManager() : m_locationServiceEnabled(false) { + m_instance = this; // create location manager service - locationProvider = new GpsLocation(&qmlUiShowMessage, this); + locationProvider = new GpsLocation(&appendTextToLogStandalone, this); // Initialize cloud credentials. setCloudUserName(prefs.cloud_storage_email); @@ -37,6 +41,12 @@ QMLManager::QMLManager() : QMLManager::~QMLManager() { + m_instance = NULL; +} + +QMLManager *QMLManager::instance() +{ + return m_instance; } void QMLManager::savePreferences() @@ -95,16 +105,13 @@ void QMLManager::saveCloudCredentials() void QMLManager::loadDives() { if (same_string(prefs.cloud_storage_email, "") || same_string(prefs.cloud_storage_password, "")) { - qmlUiShowMessage("Please set up cloud storage credentials"); appendTextToLog("Unable to load dives; cloud storage credentials missing"); return; } - qmlUiShowMessage("Loading dives..."); appendTextToLog("Loading dives..."); QString url; if (getCloudURL(url)) { - qmlUiShowMessage(get_error_string()); appendTextToLog(get_error_string()); return; } @@ -115,13 +122,11 @@ void QMLManager::loadDives() if (!error) { report_error("filename is now %s", fileNamePrt.data()); const char *error_string = get_error_string(); - qmlUiShowMessage(error_string); appendTextToLog(error_string); set_filename(fileNamePrt.data(), true); } else { report_error("failed to open file %s", fileNamePrt.data()); const char *error_string = get_error_string(); - qmlUiShowMessage(error_string); appendTextToLog(error_string); return; } @@ -170,24 +175,21 @@ void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QStr void QMLManager::saveChanges() { if (!loadFromCloud()) { - qmlUiShowMessage("Don't save dives without loading from the cloud, first."); + appendTextToLog("Don't save dives without loading from the cloud, first."); return; } - qmlUiShowMessage("Saving dives."); + appendTextToLog("Saving dives."); QString fileName; if (getCloudURL(fileName)) { - qmlUiShowMessage(get_error_string()); appendTextToLog(get_error_string()); return; } if (save_dives(fileName.toUtf8().data())) { - qmlUiShowMessage(get_error_string()); appendTextToLog(get_error_string()); return; } - qmlUiShowMessage("Dives saved."); appendTextToLog("Dive saved."); set_filename(fileName.toUtf8().data(), true); mark_divelist_changed(false); @@ -195,7 +197,6 @@ void QMLManager::saveChanges() void QMLManager::addDive() { - qmlUiShowMessage("Adding new dive."); appendTextToLog("Adding new dive."); DiveListModel::instance()->startAddDive(); } @@ -233,7 +234,6 @@ void QMLManager::appendTextToLog(const QString &newText) emit logTextChanged(); } - bool QMLManager::saveCloudPassword() const { return m_saveCloudPassword; -- cgit v1.2.3-70-g09d2