aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile
diff options
context:
space:
mode:
Diffstat (limited to 'qt-mobile')
-rw-r--r--qt-mobile/qml/CloudCredentials.qml2
-rw-r--r--qt-mobile/qml/main.qml4
-rw-r--r--qt-mobile/qmlmanager.cpp37
-rw-r--r--qt-mobile/qmlmanager.h8
4 files changed, 27 insertions, 24 deletions
diff --git a/qt-mobile/qml/CloudCredentials.qml b/qt-mobile/qml/CloudCredentials.qml
index de33f886c..aa7c57651 100644
--- a/qt-mobile/qml/CloudCredentials.qml
+++ b/qt-mobile/qml/CloudCredentials.qml
@@ -24,7 +24,7 @@ Item {
width: subsurfaceTheme.columnWidth - 2 * Kirigami.Units.gridUnit
onVisibleChanged: {
- if (visible && !manager.accessingCloud) {
+ if (visible && manager.accessingCloud < 0) {
manager.appendTextToLog("Credential scrn: show kbd was: " + (Qt.inputMethod.isVisible ? "visible" : "invisible"))
Qt.inputMethod.show()
login.forceActiveFocus()
diff --git a/qt-mobile/qml/main.qml b/qt-mobile/qml/main.qml
index c011ba4c1..3ed5aeac9 100644
--- a/qt-mobile/qml/main.qml
+++ b/qt-mobile/qml/main.qml
@@ -21,8 +21,8 @@ Kirigami.ApplicationWindow {
property QtObject notification: null
property bool showingDiveList: false
onAccessingCloudChanged: {
- if (accessingCloud) {
- showPassiveNotification("Accessing Subsurface Cloud Storage", 500000);
+ if (accessingCloud >= 0) {
+ showPassiveNotification("Accessing Subsurface Cloud Storage " + accessingCloud +"%", 500000);
} else {
hidePassiveNotification();
}
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 5589bffd5..57705c363 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -69,7 +69,7 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
qDebug() << "Starting" << getUserAgent();
qDebug() << QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion());
setStartPageText(tr("Starting..."));
- setAccessingCloud(false);
+ setAccessingCloud(-1);
// create location manager service
locationProvider = new GpsLocation(&appendTextToLogStandalone, this);
set_git_update_cb(&gitProgressCB);
@@ -105,7 +105,7 @@ void QMLManager::openLocalThenRemote(QString url)
appendTextToLog(QStringLiteral("%1 dives loaded from cache").arg(i));
}
appendTextToLog(QStringLiteral("have cloud credentials, trying to connect"));
- setAccessingCloud(true);
+ setAccessingCloud(0);
tryRetrieveDataFromBackend();
}
@@ -218,7 +218,7 @@ void QMLManager::tryRetrieveDataFromBackend()
void QMLManager::loadDives()
{
- setAccessingCloud(true);
+ setAccessingCloud(0);
checkCredentialsAndExecute(&QMLManager::loadDivesWithValidCredentials);
}
@@ -247,7 +247,7 @@ void QMLManager::handleSslErrors(const QList<QSslError> &errors)
}
reply->abort();
reply->deleteLater();
- setAccessingCloud(false);
+ setAccessingCloud(-1);
}
void QMLManager::handleError(QNetworkReply::NetworkError nError)
@@ -257,14 +257,14 @@ void QMLManager::handleError(QNetworkReply::NetworkError nError)
setStartPageText(RED_FONT + tr("Cannot open cloud storage: %1").arg(errorString) + END_FONT);
reply->abort();
reply->deleteLater();
- setAccessingCloud(false);
+ setAccessingCloud(-1);
}
void QMLManager::retrieveUserid()
{
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
appendTextToLog(QStringLiteral("Cloud storage connection not working correctly: %1").arg(QString(reply->readAll())));
- setAccessingCloud(false);
+ setAccessingCloud(-1);
return;
}
setCredentialStatus(VALID);
@@ -272,7 +272,7 @@ void QMLManager::retrieveUserid()
if (userid.isEmpty()) {
if (same_string(prefs.cloud_storage_email, "") || same_string(prefs.cloud_storage_password, "")) {
appendTextToLog("cloud user name or password are empty, can't retrieve web user id");
- setAccessingCloud(false);
+ setAccessingCloud(-1);
return;
}
appendTextToLog(QStringLiteral("calling getUserid with user %1").arg(prefs.cloud_storage_email));
@@ -292,6 +292,7 @@ void QMLManager::retrieveUserid()
void QMLManager::loadDiveProgress(int percent)
{
QString text(tr("Loading dive list from cloud storage."));
+ setAccessingCloud(percent);
while (percent > 0) {
text.append(".");
percent -= 10;
@@ -304,7 +305,7 @@ void QMLManager::loadDivesWithValidCredentials()
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) {
appendTextToLog(QStringLiteral("Cloud storage connection not working correctly: ") + reply->readAll());
setStartPageText(RED_FONT + tr("Cannot connect to cloud storage") + END_FONT);
- setAccessingCloud(false);
+ setAccessingCloud(-1);
return;
}
setCredentialStatus(VALID);
@@ -316,7 +317,7 @@ void QMLManager::loadDivesWithValidCredentials()
QString errorString(get_error_string());
appendTextToLog(errorString);
setStartPageText(RED_FONT + tr("Cloud storage error: %1").arg(errorString) + END_FONT);
- setAccessingCloud(false);
+ setAccessingCloud(-1);
return;
}
QByteArray fileNamePrt = QFile::encodeName(url);
@@ -324,14 +325,14 @@ void QMLManager::loadDivesWithValidCredentials()
qDebug() << "local cache was current, no need to modify dive list";
appendTextToLog("Cloud sync shows local cache was current");
setLoadFromCloud(true);
- setAccessingCloud(false);
+ setAccessingCloud(-1);
return;
}
clear_dive_file_data();
DiveListModel::instance()->clear();
int error = parse_file(fileNamePrt.data());
- setAccessingCloud(false);
+ setAccessingCloud(-1);
if (!error) {
report_error("filename is now %s", fileNamePrt.data());
const char *error_string = get_error_string();
@@ -707,14 +708,16 @@ void QMLManager::saveChanges()
appendTextToLog(get_error_string());
return;
}
- if (prefs.git_local_only == false)
- setAccessingCloud(true);
+ if (prefs.git_local_only == false) {
+ setAccessingCloud(0);
+ qApp->processEvents(); // make sure that the notification is actually shown
+ }
if (save_dives(fileName.toUtf8().data())) {
appendTextToLog(get_error_string());
- setAccessingCloud(false);
+ setAccessingCloud(-1);
return;
}
- setAccessingCloud(false);
+ setAccessingCloud(-1);
appendTextToLog("Updated dive list saved.");
set_filename(fileName.toUtf8().data(), true);
mark_divelist_changed(false);
@@ -1007,12 +1010,12 @@ QString QMLManager::getVersion() const
return versionRe.cap(1);
}
-bool QMLManager::accessingCloud() const
+int QMLManager::accessingCloud() const
{
return m_accessingCloud;
}
-void QMLManager::setAccessingCloud(bool status)
+void QMLManager::setAccessingCloud(int status)
{
m_accessingCloud = status;
emit accessingCloudChanged();
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 2d7e913ef..1db4a34ec 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -21,7 +21,7 @@ class QMLManager : public QObject {
Q_PROPERTY(QString startPageText READ startPageText WRITE setStartPageText NOTIFY startPageTextChanged)
Q_PROPERTY(bool verboseEnabled READ verboseEnabled WRITE setVerboseEnabled NOTIFY verboseEnabledChanged)
Q_PROPERTY(credentialStatus_t credentialStatus READ credentialStatus WRITE setCredentialStatus NOTIFY credentialStatusChanged)
- Q_PROPERTY(bool accessingCloud READ accessingCloud WRITE setAccessingCloud NOTIFY accessingCloudChanged)
+ Q_PROPERTY(int accessingCloud READ accessingCloud WRITE setAccessingCloud NOTIFY accessingCloudChanged)
public:
QMLManager();
@@ -68,8 +68,8 @@ public:
QString logText() const;
void setLogText(const QString &logText);
- bool accessingCloud() const;
- void setAccessingCloud(bool status);
+ int accessingCloud() const;
+ void setAccessingCloud(int status);
typedef void (QMLManager::*execute_function_type)();
@@ -131,7 +131,7 @@ private:
QNetworkRequest request;
struct dive *deletedDive;
struct dive_trip *deletedTrip;
- bool m_accessingCloud;
+ int m_accessingCloud;
credentialStatus_t m_credentialStatus;
qreal m_lastDevicePixelRatio;