Connect with Strava

.. the authorise button on the add cloud wizard now
   shows a 'Connect with Strava' icon

.. all other services continue to have a button that
   is labelled 'Authorise'

.. this is needed to comply with the Strava API application
   guidelines.
This commit is contained in:
Mark Liversedge
2020-01-17 16:04:27 +00:00
parent 2914f16e89
commit fca5d9eb20
5 changed files with 29 additions and 2 deletions

View File

@@ -27,6 +27,7 @@
#include "OAuthDialog.h"
#include <QMessageBox>
#include <QPixmap>
#include <QRegExp>
// WIZARD FLOW
@@ -271,13 +272,15 @@ AddAuth::AddAuth(AddCloudWizard *parent) : QWizardPage(parent), wizard(parent)
pass = new QLineEdit(this);
pass->setEchoMode(QLineEdit::Password);
pass->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
auth = new QPushButton(tr("Authorise"), this);
auth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
token = new QLabel(this);
token->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
message = new QLabel(this);
message->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// is there an icon for the authorise button?
auth = new QPushButton(tr("Authorise"), this);
auth->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// labels
comboLabel = new QLabel("");
urlLabel = new QLabel(tr("URL"));
@@ -367,6 +370,24 @@ AddAuth::initializePage()
// clone to do next few steps!
setSubTitle(QString(tr("%1 Credentials and authorisation")).arg(wizard->cloudService->uiName()));
// icon on the authorize button
if (wizard->cloudService && wizard->cloudService->authiconpath() != "") {
// scaling icon hack (193x48 is strava icon size)
QPixmap pix(wizard->cloudService->authiconpath());
QIcon authicon(pix.scaled(193*dpiXFactor, 48*dpiXFactor));
auth->setIconSize(QSize(193*dpiXFactor, 48*dpiYFactor));
// set the pushbutton
auth->setText("");
auth->setIcon(authicon);
} else {
// standard pushbutton (reset after used by strava)
auth->setText(tr("Authorise"));
auth->setIcon(QIcon());
}
// show all the widgets relevant for this service and update the value from the
// settings we have collected (which will have been defaulted).
QString cname;

View File

@@ -95,6 +95,9 @@ class CloudService : public QObject {
// need a logo, we may resize but will keep aspect ratio
virtual QImage logo() const = 0;
// an icon to put on the authorize button (mandated by strava guidelines)
virtual QString authiconpath() const { return QString(""); }
// register with capabilities of the service - emerging standard
// is a service that allows oauth, query and upload as well as download
enum { OAuth=0x01, UserPass=0x02, Upload=0x04, Download=0x08, Query=0x10} capa_;

View File

@@ -45,6 +45,8 @@ class Strava : public CloudService {
//virtual int capabilities() const { return OAuth | Upload | Download | Query ; } // Default
QString authiconpath() const { return QString(":images/services/strava_connect.png"); }
// write a file
bool writeFile(QByteArray &data, QString remotename, RideFile *ride);

View File

@@ -167,6 +167,7 @@
<file>web/googlemap/dark.css</file>
<file>images/toolbar/cloud.png</file>
<file>images/services/strava_compatible.png</file>
<file>images/services/strava_connect.png</file>
<file>images/services/cyclinganalytics.png</file>
<file>images/services/dropbox.png</file>
<file>images/services/googledrive.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB