Add Sync from Cloud for new athlete

.. when a new athlete is created and opened the blankstate page
   currently provides options to get data by importing files or
   downloading from a device.

.. this update adds the ability to configure a cloud service and
   start a sync straight away

.. this UX is introduced since cloud services are now much
   more ubiquitous and v3.5 introduced broad support for a wide
   range of services.
This commit is contained in:
Mark Liversedge
2020-01-20 18:50:14 +00:00
parent 8c775e5d2f
commit 835f7cff92
5 changed files with 30 additions and 2 deletions

View File

@@ -148,6 +148,14 @@ BlankStateAnalysisPage::BlankStateAnalysisPage(Context *context) : BlankStatePag
img->setIcon(QPixmap(":images/analysis.png"));
img->setIconSize(QSize(800,330));
ShortCut scCloud;
scCloud.label = tr("Connect to cloud service and download");
scCloud.buttonLabel = tr("Cloud Download");
scCloud.buttonIconPath = ":images/mac/download.png";
QPushButton *cloudButton = addToShortCuts(scCloud);
connect(cloudButton, SIGNAL(clicked()), context->mainWindow, SLOT(importCloud()));
ShortCut scImport;
scImport.label = tr("Import files from your disk or usb device");
scImport.buttonLabel = tr("Import data");

View File

@@ -42,7 +42,7 @@
//
// Main wizard - if passed a service name we are in edit mode, not add mode.
AddCloudWizard::AddCloudWizard(Context *context, QString sname) : QWizard(context->mainWindow), context(context), service(sname)
AddCloudWizard::AddCloudWizard(Context *context, QString sname, bool sync) : QWizard(context->mainWindow), context(context), service(sname), fsync(sync)
{
#ifdef Q_OS_MAC
setWizardStyle(QWizard::ModernStyle);
@@ -721,7 +721,15 @@ AddFinish::validatePage()
// in the athlete preferences
appsettings->setCValue(wizard->context->athlete->cyclist, wizard->cloudService->activeSettingName(), "true");
// start a sync straight away
if (wizard->fsync) {
CloudService *db = CloudServiceFactory::instance().newService(wizard->cloudService->id(), wizard->context);
CloudServiceSyncDialog *syncnow = new CloudServiceSyncDialog(wizard->context, db);
syncnow->open();
}
// delete the instance
delete wizard->cloudService;
return true;
}

View File

@@ -42,7 +42,7 @@ class AddCloudWizard : public QWizard
Q_OBJECT
public:
AddCloudWizard(Context *context, QString sname="");
AddCloudWizard(Context *context, QString sname="", bool sync=false);
QSize sizeHint() const { return QSize(600,650); }
Context *context;
@@ -54,6 +54,9 @@ public:
// which service have we selected?
QString service;
// sync straight away, so first timers can download from BlankState
bool fsync;
// this is cloned for our context
CloudService *cloudService;

View File

@@ -2096,6 +2096,14 @@ MainWindow::checkCloud()
currentTab->context->athlete->importFilesWhenOpeningAthlete();
}
void
MainWindow::importCloud()
{
// lets get a new cloud service account
AddCloudWizard *p = new AddCloudWizard(currentTab->context, "", true);
p->show();
}
void
MainWindow::uploadCloud(QAction *action)
{

View File

@@ -172,6 +172,7 @@ class MainWindow : public QMainWindow
void setUploadMenu();
void setSyncMenu();
void checkCloud();
void importCloud(); // used to setup and sync in one on first run (see BlankState.cpp)
void showOptions();