Skip to content

Commit

Permalink
Cloud Refactor - Add Account Wizard WIP
Browse files Browse the repository at this point in the history
.. committing the work in progress

.. still needs to be completed, but for technical reasons I am
   pushing now to get into the master repository.
  • Loading branch information
liversedge committed Mar 29, 2017
1 parent ad97fbe commit 097f9ed
Show file tree
Hide file tree
Showing 18 changed files with 587 additions and 6 deletions.
389 changes: 389 additions & 0 deletions src/Cloud/AddCloudWizard.cpp

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions src/Cloud/AddCloudWizard.h
@@ -0,0 +1,152 @@
/*
* Copyright (c) 2017 Mark Liversedge (liversedge@gmail.com)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef _AddCloudWizard_h
#define _AddCloudWizard_h

#include "GoldenCheetah.h"
#include "Context.h"
#include "CloudService.h"
#include "Serial.h"
#include "Settings.h"

#include <QWizard>
#include <QFormLayout>
#include <QHeaderView>
#include <QProgressBar>
#include <QFileDialog>
#include <QCommandLinkButton>

class AddCloudWizard : public QWizard
{
Q_OBJECT

public:
AddCloudWizard(Context *context);
QSize sizeHint() const { return QSize(600,650); }

Context *context;
bool done; // have we finished?

// what type of services did we say we wanted
int type;

// which service have we selected?
QString service;

// this is cloned for our context
CloudService *cloudService;

public slots:

signals:

private slots:

};

class AddClass : public QWizardPage
{
Q_OBJECT

public:
AddClass(AddCloudWizard *);
bool validate() const { return false; }
bool isComplete() const { return false; }
int nextId() const { return 10; }

public slots:
void clicked(int);

private:
AddCloudWizard *wizard;
QSignalMapper *mapper;
};

class AddService : public QWizardPage
{
Q_OBJECT

public:
AddService(AddCloudWizard *);
void initializePage();
bool validate() const { return false; }
bool isComplete() const { return false; }
int nextId() const { return 20; }

public slots:
void clicked(QString);

private:
AddCloudWizard *wizard;
QSignalMapper *mapper;
QWidget *buttons;
QVBoxLayout *buttonlayout;
QScrollArea *scrollarea;
};

class AddAuth : public QWizardPage
{
Q_OBJECT

public:
AddAuth(AddCloudWizard *);

public slots:
void initializePage();
bool validatePage();
int nextId() const { return 30; }

//void doAuth();

private:
AddCloudWizard *wizard;
};

class AddSettings : public QWizardPage
{
Q_OBJECT

public:
AddSettings(AddCloudWizard *);
void initializePage();
bool validatePage();
int nextId() const { return 90; }

public slots:

private:
AddCloudWizard *wizard;
};

class AddFinish : public QWizardPage
{
Q_OBJECT

public:
AddFinish(AddCloudWizard *);
void initializePage();
//bool validatePage();
bool isCommitPage() { return true; }

private:
AddCloudWizard *wizard;

};

#endif // _AddCloudWizard_h
11 changes: 11 additions & 0 deletions src/Cloud/CloudService.h
Expand Up @@ -71,6 +71,7 @@ class CloudService : public QObject {
// that represents the website, so likely to just be the URL simplified
// e.g. https://www.strava.com => "Strava"
virtual QString name() { return "NONE"; }
virtual QString description() { return ""; }

// need a logo, we may resize but will keep aspect ratio
virtual QImage logo() = 0;
Expand Down Expand Up @@ -408,6 +409,16 @@ class CloudServiceFactory {

const QStringList &serviceNames() const { return names_; }
const CloudService *service(QString name) const { return services_.value(name, NULL); }
const QList<CloudService*> services() {
QList<CloudService*>returning;
QHashIterator<QString,CloudService*> i(services_);
i.toFront();
while(i.hasNext()) {
i.next();
returning << i.value();
}
return returning;
}

CloudService *newService(const QString &name, Context *context) const {
return services_.value(name)->clone(context);
Expand Down
1 change: 1 addition & 0 deletions src/Cloud/CyclingAnalytics.h
Expand Up @@ -31,6 +31,7 @@ class CyclingAnalytics : public CloudService {
public:

QString name() { return (tr("Cycling Analytics")); }
QString description() { return (tr("Upload to the power focused cycling site.")); }
QImage logo() { return QImage(":images/services/cyclinganalytics.png"); }

CyclingAnalytics(Context *context);
Expand Down
3 changes: 2 additions & 1 deletion src/Cloud/Dropbox.h
Expand Up @@ -33,7 +33,8 @@ class Dropbox : public CloudService {
CloudService *clone(Context *context) { return new Dropbox(context); }
~Dropbox();

QString name() { return (tr("Dropbox Cloud Storage")); }
QString name() { return (tr("Dropbox")); }
QString description() { return (tr("Sync activities via your cloud storage.")); }
QImage logo() { return QImage(":images/services/dropbox.png"); }

// open/connect and close/disconnect
Expand Down
3 changes: 2 additions & 1 deletion src/Cloud/GoogleDrive.h
Expand Up @@ -40,7 +40,8 @@ class GoogleDrive : public CloudService {
CloudService *clone(Context *context) { return new GoogleDrive(context); }
virtual ~GoogleDrive();

virtual QString name() { return (tr("Google Drive Cloud Storage")); }
virtual QString name() { return (tr("Google Drive")); }
virtual QString description() { return (tr("Sync your data via your cloud storage.")); }
QImage logo() { return QImage(":images/services/googledrive.png"); }

// open/connect and close/disconnect
Expand Down
3 changes: 2 additions & 1 deletion src/Cloud/LocalFileStore.h
Expand Up @@ -32,7 +32,8 @@ class LocalFileStore : public CloudService {
CloudService *clone(Context *context) { return new LocalFileStore(context); }
~LocalFileStore();

QString name() { return (tr("Local Store ") + home()); }
QString name() { return (tr("Local Store")); }
QString description() { return (tr("Sync with a local folder or thumbdrive.")); }
QImage logo() { return QImage(":images/services/localstore.png"); }


Expand Down
2 changes: 2 additions & 0 deletions src/Cloud/RideWithGPS.h
Expand Up @@ -31,6 +31,8 @@ class RideWithGPS : public CloudService {
public:

QString name() { return (tr("RideWithGPS")); }
QString description() { return(tr("Upload rides and analyse them using Google Maps.")); }

QImage logo() { return QImage(":images/services/ridewithgps.png"); }

RideWithGPS(Context *context);
Expand Down
1 change: 1 addition & 0 deletions src/Cloud/Selfloops.h
Expand Up @@ -31,6 +31,7 @@ class Selfloops : public CloudService {
public:

QString name() { return (tr("Selfloops")); }
QString description() { return tr("Upload and track your training and progress."); }
QImage logo() { return QImage(":images/services/selfloops.png"); }

Selfloops(Context *context);
Expand Down
1 change: 1 addition & 0 deletions src/Cloud/SixCycle.h
Expand Up @@ -35,6 +35,7 @@ class SixCycle : public CloudService {
~SixCycle();

QString name() { return (tr("Sixcycle")); }
QString description() { return (tr("Sync with the innovative training site.")); }
QImage logo() { return QImage(":images/services/sixcycle.png"); }

// open/connect and close/disconnect
Expand Down
3 changes: 2 additions & 1 deletion src/Cloud/SportsPlusHealth.h
Expand Up @@ -30,7 +30,8 @@ class SportsPlusHealth : public CloudService {

public:

QString name() { return (tr("SportsPlusHealth")); }
QString name() { return (tr("SportPlusHealth")); }
QString description() { return (tr("Upload to the cycling and running site.")); }
QImage logo() { return QImage(":images/services/sportplushealth.png"); }

SportsPlusHealth(Context *context);
Expand Down
1 change: 1 addition & 0 deletions src/Cloud/Strava.h
Expand Up @@ -31,6 +31,7 @@ class Strava : public CloudService {
public:

QString name() { return (tr("Strava")); }
QString description() { return (tr("Upload to the social network for cyclists and runners.")); }
QImage logo() { return QImage(":images/services/strava.png"); }

Strava(Context *context);
Expand Down
1 change: 1 addition & 0 deletions src/Cloud/TodaysPlan.h
Expand Up @@ -35,6 +35,7 @@ class TodaysPlan : public CloudService {
~TodaysPlan();

QString name() { return (tr("Today's Plan")); }
QString description() { return (tr("Sync with the smarter training site.")); }
QImage logo() { return QImage(":images/services/todaysplan.png"); }

// open/connect and close/disconnect
Expand Down
1 change: 1 addition & 0 deletions src/Cloud/TrainingStageBuch.h
Expand Up @@ -43,6 +43,7 @@ class TrainingStageBuch : public CloudService {
public:

QString name() { return (tr("TrainingStageBuch")); }
QString description() { return (tr("Upload to your online and mobile training log.")); }
QImage logo() { return QImage(":images/services/trainingstagebuch.png"); }

TrainingStageBuch(Context *context);
Expand Down
1 change: 1 addition & 0 deletions src/Cloud/Velohero.h
Expand Up @@ -36,6 +36,7 @@ class Velohero : public CloudService {
public:

QString name() { return (tr("Velohero")); }
QString description() { return (tr("Upload your rides to the independent and free cycling training log")); }
QImage logo() { return QImage(":images/services/velohero.png"); }

Velohero(Context *context);
Expand Down
15 changes: 15 additions & 0 deletions src/Gui/MainWindow.cpp
Expand Up @@ -83,6 +83,7 @@
#include "GoogleDrive.h"
#include "SixCycle.h"
#endif
#include "AddCloudWizard.h"
#include "LocalFileStore.h"
#include "CloudService.h"

Expand Down Expand Up @@ -429,6 +430,10 @@ MainWindow::MainWindow(const QDir &home)

// SHARE MENU
QMenu *shareMenu = menuBar()->addMenu(tr("Sha&re"));
shareAction = new QAction(tr("Add Cloud Account..."), this);
shareAction->setShortcut(tr("Ctrl+U"));
connect(shareAction, SIGNAL(triggered(bool)), this, SLOT(addAccount()));
shareMenu->addAction(shareAction);
shareAction = new QAction(tr("Share Online..."), this);
shareAction->setShortcut(tr("Ctrl+U"));
connect(shareAction, SIGNAL(triggered(bool)), this, SLOT(share()));
Expand Down Expand Up @@ -1997,6 +2002,16 @@ MainWindow::share()
}
}

void
MainWindow::addAccount()
{

// lets get a new cloud service account
AddCloudWizard *p = new AddCloudWizard(currentTab->context);
p->show();

}

/*----------------------------------------------------------------------
* Import Workout from Disk
*--------------------------------------------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions src/Gui/MainWindow.h
Expand Up @@ -220,6 +220,7 @@ class MainWindow : public QMainWindow
void tweetRide();
#endif
void share();
void addAccount();
void manualProcess(QString);
#if QT_VERSION > 0x050000
void uploadDropbox();
Expand Down
4 changes: 2 additions & 2 deletions src/src.pro
Expand Up @@ -695,7 +695,7 @@ HEADERS += Cloud/BodyMeasures.h Cloud/BodyMeasuresDownload.h Cloud/CalendarDownl
Cloud/OAuthDialog.h Cloud/ShareDialog.h Cloud/SportPlusHealthUploader.h Cloud/TodaysPlanBodyMeasures.h \
Cloud/TrainingstagebuchUploader.h Cloud/VeloHeroUploader.h Cloud/WithingsDownload.h \
Cloud/Strava.h Cloud/CyclingAnalytics.h Cloud/RideWithGPS.h Cloud/TrainingStageBuch.h \
Cloud/Selfloops.h Cloud/Velohero.h Cloud/SportsPlusHealth.h
Cloud/Selfloops.h Cloud/Velohero.h Cloud/SportsPlusHealth.h Cloud/AddCloudWizard.h

# core data
HEADERS += Core/Athlete.h Core/Context.h Core/DataFilter.h Core/FreeSearch.h Core/GcCalendarModel.h Core/GcUpgrade.h \
Expand Down Expand Up @@ -786,7 +786,7 @@ SOURCES += Cloud/BodyMeasures.cpp Cloud/BodyMeasuresDownload.cpp Cloud/CalendarD
Cloud/OAuthDialog.cpp Cloud/ShareDialog.cpp Cloud/SportPlusHealthUploader.cpp Cloud\TodaysPlanBodyMeasures.cpp \
Cloud/TrainingstagebuchUploader.cpp Cloud/VeloHeroUploader.cpp Cloud/WithingsDownload.cpp \
Cloud/Strava.cpp Cloud/CyclingAnalytics.cpp Cloud/RideWithGPS.cpp Cloud/TrainingStageBuch.cpp \
Cloud/Selfloops.cpp Cloud/Velohero.cpp Cloud/SportsPlusHealth.cpp
Cloud/Selfloops.cpp Cloud/Velohero.cpp Cloud/SportsPlusHealth.cpp Cloud/AddCloudWizard.cpp

## Core Data Structures
SOURCES += Core/Athlete.cpp Core/Context.cpp Core/DataFilter.cpp Core/FreeSearch.cpp Core/GcUpgrade.cpp Core/IdleTimer.cpp \
Expand Down

0 comments on commit 097f9ed

Please sign in to comment.