Settings QObjectification: Facebook settings

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2016-01-13 17:09:46 -02:00 committed by Dirk Hohndel
parent 0dba3c4e4a
commit 9b37c6dfa1
2 changed files with 82 additions and 6 deletions

View file

@ -1,5 +1,7 @@
#include "SettingsObjectWrapper.h"
#include <QSettings>
#include "../dive.h" // TODO: remove copy_string from dive.h
static QString tecDetails = QStringLiteral("TecDetails");
@ -398,3 +400,60 @@ void TechnicalDetailsSettings::setShowAverageDepth(short value)
prefs.show_average_depth = value;
emit showAverageDepthChanged(value);
}
FacebookSettings::FacebookSettings(QObject *parent) :
group(QStringLiteral("WebApps")),
subgroup(QStringLiteral("Facebook"))
{
}
QString FacebookSettings::accessToken() const
{
return QString(prefs.facebook.access_token);
}
QString FacebookSettings::userId() const
{
return QString(prefs.facebook.user_id);
}
QString FacebookSettings::albumId() const
{
return QString(prefs.facebook.album_id);
}
void FacebookSettings::setAccessToken (const QString& value)
{
#if SAVE_FB_CREDENTIALS
QSettings s;
s.beginGroup(group);
s.beginGroup(subgroup);
s.setValue("ConnectToken", value);
#endif
prefs.facebook.access_token = copy_string(qPrintable(value));
emit accessTokenChanged(value);
}
void FacebookSettings::setUserId(const QString& value)
{
#if SAVE_FB_CREDENTIALS
QSettings s;
s.beginGroup(group);
s.beginGroup(subgroup);
s.setValue("UserId", value);
#endif
prefs.facebook.user_id = copy_string(qPrintable(value));
emit userIdChanged(value);
}
void FacebookSettings::setAlbumId(const QString& value)
{
#if SAVE_FB_CREDENTIALS
QSettings s;
s.beginGroup(group);
s.beginGroup(subgroup);
s.setValue("AlbumId", value);
#endif
prefs.facebook.album_id = copy_string(qPrintable(value));
emit albumIdChanged(value);
}

View file

@ -149,11 +149,28 @@ signals:
/* Control the state of the Facebook preferences */
class FacebookSettings : public QObject {
Q_OBJECT
Q_PROPERTY(access_token READ WRITE setAccessToken NOTIFY accessTokenChanged);
Q_PROPERTY(user_id READ WRITE setUserId NOTIFY userIdChanged)
Q_PROPERTY(album_id READ WRITE setAlbumId NOTIFY albumIdChanged)
Q_PROPERTY(QString accessToken READ accessToken WRITE setAccessToken NOTIFY accessTokenChanged)
Q_PROPERTY(QString userId READ userId WRITE setUserId NOTIFY userIdChanged)
Q_PROPERTY(QString albumId READ albumId WRITE setAlbumId NOTIFY albumIdChanged)
public:
FacebookSettings(QObject *parent);
QString accessToken() const;
QString userId() const;
QString albumId() const;
public slots:
void setAccessToken (const QString& value);
void setUserId(const QString& value);
void setAlbumId(const QString& value);
signals:
void accessTokenChanged(const QString& value);
void userIdChanged(const QString& value);
void albumIdChanged(const QString& value);
private:
QString group;
QString subgroup;
};
/* Control the state of the Geocoding preferences */
@ -162,9 +179,9 @@ class GeocodingPreferences : public QObject {
Q_PROPERTY(bool enable_geocoding READ enableGeocoding WRITE setEnableGeocoding NOTIFY enableGeocodingChanged)
Q_PROPERTY(bool parse_dive_without_gps READ parseDiveWithoutGps WRITE setParseDiveWithoutGps NOTIFY parseDiveWithoutGpsChanged)
Q_PROPERTY(bool tag_existing_dives READ tagExistingDives WRITE setTagExistingDives NOTIFY tagExistingDivesChanged)
Q_PROPERTY(taxonomy_category first READ firstTaxonomyCategory WRITE setFirstTaxonomyCategory NOTIFY firstTaxonomyCategoryChanged)
Q_PROPERTY(taxonomy_category second READ secondTaxonomyCategory WRITE setSecondTaxonomyCategory NOTIFY secondTaxonomyCategoryChanged)
Q_PROPERTY(taxonomy_category third READ thirdTaxonomyCategory WRITE setThirdTaxonomyCategory NOTIFY thirdTaxonomyCategoryChanged)
Q_PROPERTY(taxonomy_category first_taxonomy READ firstTaxonomyCategory WRITE setFirstTaxonomyCategory NOTIFY firstTaxonomyCategoryChanged)
Q_PROPERTY(taxonomy_category second_taxonomy READ secondTaxonomyCategory WRITE setSecondTaxonomyCategory NOTIFY secondTaxonomyCategoryChanged)
Q_PROPERTY(taxonomy_category third_taxonomy READ thirdTaxonomyCategory WRITE setThirdTaxonomyCategory NOTIFY thirdTaxonomyCategoryChanged)
public:
GeocodingPreferences(QObject *parent);
};