From 8f33403e4f70e5785b145ae483ab16992ab68431 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 2 Dec 2015 14:32:03 -0800 Subject: [PATCH] Fetch the Subsurface webservice userid if cloud credentials were given This allows users to not have to worry about this userid anymore. Both the mobile app and the desktop app can now derive the userid from the cloud storage credentials. Signed-off-by: Dirk Hohndel --- desktop-widgets/mainwindow.cpp | 1 + desktop-widgets/subsurfacewebservices.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 67666a68f..93cd2d408 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -209,6 +209,7 @@ MainWindow::MainWindow() : QMainWindow(), if (!locationProvider->hasLocationsSource()) { ui.menuFile->removeAction(ui.add_GPS_location_here); } + ui.mainErrorMessage->hide(); graphics()->setEmptyState(); initialUiSetup(); diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index d66d3653b..a11949122 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -385,10 +385,18 @@ void WebServices::resetState() SubsurfaceWebServices::SubsurfaceWebServices(QWidget *parent, Qt::WindowFlags f) : WebServices(parent, f) { QSettings s; - if (!prefs.save_userid_local || !*prefs.userid) - ui.userID->setText(s.value("subsurface_webservice_uid").toString().toUpper()); - else - ui.userID->setText(prefs.userid); + + // figure out if we know (or can determine) the user's web service userid + QString userid(prefs.userid); + if (userid.isEmpty()) + userid = s.value("subsurface_webservice_uid").toString().toUpper(); + if (userid.isEmpty() && + !same_string(prefs.cloud_storage_email, "") && + !same_string(prefs.cloud_storage_password, "")) + userid = GpsLocation::instance()->getUserid(prefs.cloud_storage_email, prefs.cloud_storage_password); + + ui.userID->setText(userid); + hidePassword(); hideUpload(); ui.progressBar->setFormat(tr("Enter User ID and click Download"));