diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-12-03 15:59:40 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-12-03 16:01:17 -0800 |
commit | 2fc99092fb71ee58e1009b9e402e7af38afd6653 (patch) | |
tree | 3d171d386b03da33dd61c0c0c3e8292f4197829f /qt-mobile | |
parent | d20e25419f527d92c06de7b4008e2816544b6125 (diff) | |
download | subsurface-2fc99092fb71ee58e1009b9e402e7af38afd6653.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile')
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 32 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.h | 5 |
2 files changed, 19 insertions, 18 deletions
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; diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index f91417519..22feadba3 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -6,8 +6,6 @@ #include "gpslocation.h" -void qmlUiShowMessage(const char *errorString); - class QMLManager : public QObject { Q_OBJECT @@ -23,6 +21,8 @@ public: QMLManager(); ~QMLManager(); + static QMLManager *instance(); + QString cloudUserName() const; void setCloudUserName(const QString &cloudUserName); @@ -70,6 +70,7 @@ private: int m_timeThreshold; GpsLocation *locationProvider; bool m_loadFromCloud; + static QMLManager *m_instance; signals: void cloudUserNameChanged(); |