Skip to content

Commit

Permalink
Cloud Refactor - Athlete > Accounts
Browse files Browse the repository at this point in the history
.. remove the old "passwords" tab in the config pane.

.. added a new "accounts" tab in the athlete page and
   consolidated the zones tabs to a new "zones" tab

.. edit/add actions use the wizard, delete sets the
   service to inactive (but doesn't scrub settings).
  • Loading branch information
liversedge committed Apr 4, 2017
1 parent 83e5799 commit 7b749c3
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 937 deletions.
30 changes: 21 additions & 9 deletions src/Cloud/AddCloudWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
// 90. Finalise (Confirm complete and add)
//

// Main wizard
AddCloudWizard::AddCloudWizard(Context *context) : QWizard(context->mainWindow), context(context)
// 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)
{
#ifdef Q_OS_MAC
setWizardStyle(QWizard::ModernStyle);
Expand All @@ -51,17 +51,27 @@ AddCloudWizard::AddCloudWizard(Context *context) : QWizard(context->mainWindow),
setMinimumWidth(600 *dpiXFactor);
setMinimumHeight(500 *dpiYFactor);

// title
setWindowTitle(tr("Add Cloud Wizard"));
// if we're passed the service, we're editing, otherwise
// we're adding a new one.
if (service == "") {

setWindowTitle(tr("Add Cloud Wizard"));
setPage(01, new AddClass(this)); // done
setPage(10, new AddService(this)); // done
cloudService = NULL; // not cloned yet

} else {

setWindowTitle(tr("Edit Account Details"));
cloudService = CloudServiceFactory::instance().newService(service, context);
}


setPage(01, new AddClass(this)); // done
setPage(10, new AddService(this)); // done
setPage(20, new AddAuth(this)); // done
setPage(25, new AddAthlete(this)); // done
setPage(30, new AddSettings(this)); // done
setPage(90, new AddFinish(this)); // done

cloudService = NULL; // not cloned yet
done = false;
}

Expand Down Expand Up @@ -172,7 +182,6 @@ AddService::clicked(QString p)
// reset -- particularly since we might get here from
// other pages hitting 'Back'
wizard->service = p;
const CloudService *s = CloudServiceFactory::instance().service(wizard->service);

// instatiate the cloudservice, complete with current configuration etc
if (wizard->cloudService) delete wizard->cloudService;
Expand Down Expand Up @@ -248,7 +257,7 @@ AddAuth::doAuth()
delete oauthDialog;
} else {
oauthDialog->setWindowModality(Qt::ApplicationModal);
int ret = oauthDialog->exec();
oauthDialog->exec();
token->setText(wizard->cloudService->getSetting(cname, "").toString());
}

Expand Down Expand Up @@ -602,5 +611,8 @@ AddFinish::validatePage()
appsettings->setCValue(wizard->context->athlete->cyclist,
wizard->cloudService->activeSettingName(),
"true");

// delete the instance
delete wizard->cloudService;
return true;
}
2 changes: 1 addition & 1 deletion src/Cloud/AddCloudWizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AddCloudWizard : public QWizard
Q_OBJECT

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

Context *context;
Expand Down
57 changes: 20 additions & 37 deletions src/Gui/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ConfigDialog::ConfigDialog(QDir _home, Context *context) :
QToolBar *head = addToolBar(tr("Options"));
head->setMovable(false); // oops!

setMinimumSize(800 *dpiXFactor,600 *dpiYFactor); //changed for hidpi sizing
setMinimumSize(700 *dpiXFactor,650 *dpiYFactor); //changed for hidpi sizing
#endif

// center
Expand All @@ -59,7 +59,6 @@ ConfigDialog::ConfigDialog(QDir _home, Context *context) :
// icons
static QIcon generalIcon(QPixmap(":images/toolbar/GeneralPreferences.png"));
static QIcon athleteIcon(QPixmap(":/images/toolbar/user.png"));
static QIcon passwordIcon(QPixmap(":/images/toolbar/cloud.png"));
static QIcon appearanceIcon(QPixmap(":/images/toolbar/color.png"));
static QIcon dataIcon(QPixmap(":/images/toolbar/data.png"));
static QIcon metricsIcon(QPixmap(":/images/toolbar/abacus.png"));
Expand All @@ -84,30 +83,26 @@ ConfigDialog::ConfigDialog(QDir _home, Context *context) :
connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
iconMapper->setMapping(added, 1);

added =head->addAction(passwordIcon, tr("Accounts"));
connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
iconMapper->setMapping(added, 2);

added =head->addAction(appearanceIcon, tr("Appearance"));
connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
iconMapper->setMapping(added, 3);
iconMapper->setMapping(added, 2);

added =head->addAction(dataIcon, tr("Data Fields"));
connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
iconMapper->setMapping(added, 4);
iconMapper->setMapping(added, 3);

added =head->addAction(metricsIcon, tr("Metrics"));
connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
iconMapper->setMapping(added, 5);
iconMapper->setMapping(added, 4);

added =head->addAction(intervalIcon, tr("Intervals"));
connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
iconMapper->setMapping(added, 6);
iconMapper->setMapping(added, 5);


added =head->addAction(devicesIcon, tr("Training"));
connect(added, SIGNAL(triggered()), iconMapper, SLOT(map()));
iconMapper->setMapping(added, 7);
iconMapper->setMapping(added, 6);

// more space
spacer = new QWidget(this);
Expand All @@ -133,11 +128,6 @@ ConfigDialog::ConfigDialog(QDir _home, Context *context) :
connect (general->generalPage->unitCombo, SIGNAL(currentIndexChanged(int)), athlete->athletePage, SLOT(unitChanged(int)));
connect (general->generalPage->unitCombo, SIGNAL(currentIndexChanged(int)), athlete->athletePhysPage, SLOT(unitChanged(int)));

password = new PasswordConfig(_home, context);
HelpWhatsThis *passwordHelp = new HelpWhatsThis(password);
password->setWhatsThis(passwordHelp->getWhatsThisText(HelpWhatsThis::Preferences_Passwords));
pagesWidget->addWidget(password);

appearance = new AppearanceConfig(_home, context);
HelpWhatsThis *appearanceHelp = new HelpWhatsThis(appearance);
appearance->setWhatsThis(appearanceHelp->getWhatsThisText(HelpWhatsThis::Preferences_Appearance));
Expand Down Expand Up @@ -222,7 +212,6 @@ void ConfigDialog::saveClicked()
changed |= general->saveClicked();
changed |= athlete->saveClicked();
changed |= appearance->saveClicked();
changed |= password->saveClicked();
changed |= metric->saveClicked();
changed |= data->saveClicked();
changed |= train->saveClicked();
Expand Down Expand Up @@ -299,6 +288,8 @@ qint32 GeneralConfig::saveClicked()
AthleteConfig::AthleteConfig(QDir home, Context *context) :
home(home), context(context)
{
//static QIcon passwordIcon(QPixmap(":/images/toolbar/cloud.png")); //Not used for now

// the widgets
athletePage = new AboutRiderPage(this, context);
HelpWhatsThis *athleteHelp = new HelpWhatsThis(athletePage);
Expand All @@ -324,6 +315,10 @@ AthleteConfig::AthleteConfig(QDir home, Context *context) :
HelpWhatsThis *paceZoneHelp = new HelpWhatsThis(paceZonePage);
paceZonePage->setWhatsThis(paceZoneHelp->getWhatsThisText(HelpWhatsThis::Preferences_Athlete_TrainingZones_Pace));

credentialsPage = new CredentialsPage(context);
HelpWhatsThis *credentialsHelp = new HelpWhatsThis(credentialsPage);
credentialsPage->setWhatsThis(credentialsHelp->getWhatsThisText(HelpWhatsThis::Preferences_Passwords));

autoImportPage = new AutoImportPage(context);
HelpWhatsThis *autoImportHelp = new HelpWhatsThis(autoImportPage);
autoImportPage->setWhatsThis(autoImportHelp->getWhatsThisText(HelpWhatsThis::Preferences_Athlete_Autoimport));
Expand All @@ -337,13 +332,17 @@ AthleteConfig::AthleteConfig(QDir home, Context *context) :
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0,0,0,0);

QTabWidget *zonesTab = new QTabWidget(this);
zonesTab->addTab(zonePage, tr("Power Zones"));
zonesTab->addTab(hrZonePage, tr("Heartrate Zones"));
zonesTab->addTab(paceZonePage, tr("Pace Zones"));

QTabWidget *tabs = new QTabWidget(this);
tabs->addTab(athletePage, tr("About"));
tabs->addTab(modelPage, tr("Model"));
tabs->addTab(athletePhysPage, tr("Measures"));
tabs->addTab(zonePage, tr("Power Zones"));
tabs->addTab(hrZonePage, tr("Heartrate Zones"));
tabs->addTab(paceZonePage, tr("Pace Zones"));
tabs->addTab(zonesTab, tr("Zones"));
tabs->addTab(credentialsPage, tr("Accounts"));
tabs->addTab(autoImportPage, tr("Auto Import"));
tabs->addTab(backupPage, tr("Backup"));

Expand All @@ -360,6 +359,7 @@ qint32 AthleteConfig::saveClicked()
state |= zonePage->saveClicked();
state |= hrZonePage->saveClicked();
state |= paceZonePage->saveClicked();
state |= credentialsPage->saveClicked();
state |= autoImportPage->saveClicked();
state |= backupPage->saveClicked();

Expand All @@ -383,23 +383,6 @@ qint32 AppearanceConfig::saveClicked()
return appearancePage->saveClicked();
}

// PASSWORD CONFIG
PasswordConfig::PasswordConfig(QDir home, Context *context) :
home(home), context(context)
{
passwordPage = new CredentialsPage(this, context);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(passwordPage);

layout->setSpacing(0);
setContentsMargins(0,0,0,0);
}

qint32 PasswordConfig::saveClicked()
{
return passwordPage->saveClicked();
}

// METADATA CONFIG
DataConfig::DataConfig(QDir home, Context *context) :
home(home), context(context)
Expand Down
20 changes: 1 addition & 19 deletions src/Gui/ConfigDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class AthleteConfig : public QWidget
AthleteConfig(QDir home, Context *context);
AboutRiderPage *athletePage;
AboutModelPage *modelPage;
CredentialsPage *credentialsPage;
RiderPhysPage *athletePhysPage;

public slots:
Expand Down Expand Up @@ -97,24 +98,6 @@ class AppearanceConfig : public QWidget
ColorsPage *appearancePage;
};

// PASSWORDS PAGE
class PasswordConfig : public QWidget
{
Q_OBJECT

public:
PasswordConfig(QDir home, Context *context);

public slots:
qint32 saveClicked();

private:
QDir home;
Context *context;

CredentialsPage *passwordPage;
};

// METADATA PAGE
class DataConfig : public QWidget
{
Expand Down Expand Up @@ -218,7 +201,6 @@ class ConfigDialog : public QMainWindow
GeneralConfig *general;
AthleteConfig *athlete;
AppearanceConfig *appearance;
PasswordConfig *password;
DataConfig *data;
MetricConfig *metric;
IntervalConfig *interval;
Expand Down
Loading

0 comments on commit 7b749c3

Please sign in to comment.