diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2016-01-22 17:46:15 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-24 21:26:57 -0800 |
commit | b01bca7953808332e216d1254256c1bfb57017c5 (patch) | |
tree | 88876a7df5408ca781b832156a5c7c45d56c0cf9 /subsurface-core/subsurface-qt | |
parent | ac3ba70fdb4f08034a0d5e0bacd3f4fa7fc0b4d7 (diff) | |
download | subsurface-b01bca7953808332e216d1254256c1bfb57017c5.tar.gz |
Finalize the Settings
This was the hammer part of the settings, now I need to make it able to compile ;p
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/subsurface-qt')
-rw-r--r-- | subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp | 65 | ||||
-rw-r--r-- | subsurface-core/subsurface-qt/SettingsObjectWrapper.h | 83 |
2 files changed, 134 insertions, 14 deletions
diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp index ec36e069e..8a7695b1e 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp @@ -8,6 +8,13 @@ static QString tecDetails = QStringLiteral("TecDetails"); +PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent): + QObject(parent), + group("TecDetails") +{ + +} + short PartialPressureGasSettings::showPo2() const { return prefs.pp_graphs.po2; @@ -93,6 +100,11 @@ void PartialPressureGasSettings::setPheThreshold(double value) } +TechnicalDetailsSettings::TechnicalDetailsSettings(QObject* parent): QObject(parent) +{ + +} + double TechnicalDetailsSettings:: modp02() const { return prefs.modpO2; @@ -203,7 +215,12 @@ short int TechnicalDetailsSettings::mod() const return prefs.mod; } -void TechnicalDetailsSettings::setModpO2(double value) +bool TechnicalDetailsSettings::showPicturesInProfile() const +{ + return prefs.show_pictures_in_profile; +} + +void TechnicalDetailsSettings::setModp02(double value) { QSettings s; s.beginGroup(tecDetails); @@ -212,6 +229,15 @@ void TechnicalDetailsSettings::setModpO2(double value) emit modpO2Changed(value); } +void TechnicalDetailsSettings::setShowPicturesInProfile(bool value) +{ + QSettings s; + s.beginGroup(tecDetails); + s.setValue("show_pictures_in_profile", value); + prefs.show_pictures_in_profile = value; + emit showPicturesInProfileChanged(value); +} + void TechnicalDetailsSettings::setEad(short value) { QSettings s; @@ -230,7 +256,7 @@ void TechnicalDetailsSettings::setMod(short value) emit modChanged(value); } -void TechnicalDetailsSettings::setDcceiling(short value) +void TechnicalDetailsSettings::setDCceiling(short value) { QSettings s; s.beginGroup(tecDetails); @@ -405,6 +431,8 @@ void TechnicalDetailsSettings::setShowAverageDepth(short value) emit showAverageDepthChanged(value); } + + FacebookSettings::FacebookSettings(QObject *parent) : group(QStringLiteral("WebApps")), subgroup(QStringLiteral("Facebook")) @@ -651,6 +679,11 @@ CloudStorageSettings::CloudStorageSettings(QObject *parent) : } +bool CloudStorageSettings::gitLocalOnly() const +{ + return prefs.git_local_only; +} + QString CloudStorageSettings::password() const { return QString(prefs.cloud_storage_password); @@ -787,6 +820,16 @@ void CloudStorageSettings::setCloudUrl(const QString& value) /* no-op */ Q_UNUSED(value); } +void CloudStorageSettings::setGitUrl(const QString& value) +{ + Q_UNUSED(value); /* no op */ +} + +void CloudStorageSettings::setGitLocalOnly(bool value) +{ + prefs.git_local_only = value; +} + DivePlannerSettings::DivePlannerSettings(QObject *parent) : QObject(parent), group(QStringLiteral("Planner")) @@ -1486,3 +1529,21 @@ void LanguageSettingsObjectWrapper::setDateFormatOverride(bool value) prefs.date_format_override = value.; emit dateFormatOverrideChanged(value); } + +SettingsObjectWrapper::SettingsObjectWrapper(QObject* parent): +QObject(parent), + techDetails(new TechnicalDetailsSettings()), + pp_gas(new PartialPressureGasSettings()), + facebook(new FacebookSettings()), + geocoding(new GeocodingPreferences()), + proxy(new ProxySettings()), + cloud_storage(new CloudStorageSettings()), + planner_settings(new DivePlannerSettings()), + unit_settings(new UnitsSettings()), + general_settings(new GeneralSettingsObjectWrapper()), + display_settings(new DisplaySettingsObjectWrapper()), + language_settings(new LanguageSettingsObjectWrapper()), + animation_settings(new AnimationsSettingsObjectWrapper()), + location_settings(new LocationServiceSettingsObjectWrapper()) +{ +} diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h index 6ce1ac12a..2b28d21bd 100644 --- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.h +++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.h @@ -45,6 +45,8 @@ signals: void po2ThresholdChanged(double value); void pn2ThresholdChanged(double value); void pheThresholdChanged(double value); +private: + QString group; }; class TechnicalDetailsSettings : public QObject { @@ -71,7 +73,7 @@ class TechnicalDetailsSettings : public QObject { Q_PROPERTY(bool gf_low_at_maxdepth READ gfLowAtMaxDepth WRITE setGfLowAtMaxDepth NOTIFY gfLowAtMaxDepthChanged) Q_PROPERTY(short display_unused_tanks READ displayUnusedTanks WRITE setDisplayUnusedTanks NOTIFY displayUnusedTanksChanged) Q_PROPERTY(short show_average_depth READ showAverageDepth WRITE setShowAverageDepth NOTIFY showAverageDepthChanged) - + Q_PROPERTY(bool show_pictures_in_profile READ showPicturesInProfile WRITE setShowPicturesInProfile NOTIFY showPicturesInProfileChanged) public: TechnicalDetailsSettings(QObject *parent); @@ -97,6 +99,7 @@ public: bool gfLowAtMaxDepth() const; short displayUnusedTanks() const; short showAverageDepth() const; + bool showPicturesInProfile() const; public slots: void setMod(short value); @@ -121,6 +124,7 @@ public slots: void setGfLowAtMaxDepth(bool value); void setDisplayUnusedTanks(short value); void setShowAverageDepth(short value); + void setShowPicturesInProfile(bool value); signals: void modpO2Changed(double value); @@ -145,6 +149,7 @@ signals: void gfLowAtMaxDepthChanged(bool value); void displayUnusedTanksChanged(short value); void showAverageDepthChanged(short value); + void showPicturesInProfileChanged(bool value); }; /* Control the state of the Facebook preferences */ @@ -257,6 +262,7 @@ class CloudStorageSettings : public QObject { Q_PROPERTY(QString userid READ userId WRITE setUserId NOTIFY userIdChanged) Q_PROPERTY(QString base_url READ baseUrl WRITE setBaseUrl NOTIFY baseUrlChanged) Q_PROPERTY(QString git_url READ gitUrl WRITE setGitUrl NOTIFY gitUrlChanged) + Q_PROPERTY(bool git_local_only READ gitLocalOnly WRITE setGitLocalOnly NOTIFY gitLocalOnlyChanged) Q_PROPERTY(bool save_password_local READ savePasswordLocal WRITE setSavePasswordLocal NOTIFY savePasswordLocalChanged) Q_PROPERTY(short verification_status READ verificationStatus WRITE setVerificationStatus NOTIFY verificationStatusChanged) Q_PROPERTY(bool background_sync READ backgroundSync WRITE setBackgroundSync NOTIFY backgroundSyncChanged) @@ -272,6 +278,7 @@ public: bool savePasswordLocal() const; short verificationStatus() const; bool backgroundSync() const; + bool gitLocalOnly() const; public slots: void setPassword(const QString& value); @@ -284,6 +291,7 @@ public slots: void setSavePasswordLocal(bool value); void setVerificationStatus(short value); void setBackgroundSync(bool value); + void setGitLocalOnly(bool value); signals: void passwordChanged(const QString& value); @@ -296,6 +304,7 @@ signals: void savePasswordLocalChanged(bool value); void verificationStatusChanged(short value); void backgroundSyncChanged(bool value); + void gitLocalOnlyChanged(bool value); private: QString group; }; @@ -401,9 +410,6 @@ signals: private: QString group; }; -/* Monster class, should be breaken into a few more understandable classes later, wich will be easy to do: -* grab the Q_PROPERTYES and create a wrapper class like the ones above. -*/ class UnitsSettings : public QObject { Q_OBJECT @@ -554,15 +560,62 @@ private: QString group; }; -class SettingsObjectWrapper : public QObject { +class AnimationsSettingsObjectWrapper : public QObject { Q_OBJECT - Q_PROPERTY(int animation_speed READ animationSpeed WRITE setAnimationSpeed NOTIFY animationSpeedChanged) - Q_PROPERTY(short save_userid_local READ saveUserIdLocal WRITE setSaveUserIdLocal NOTIFY saveUserIdLocalChanged) - Q_PROPERTY(bool show_pictures_in_profile READ showPicturesInProfile WRITE setShowPicturesInProfile NOTIFY showPicturesInProfileChanged) +public: + AnimationsSettingsObjectWrapper(QObject *parent); + int animationSpeed() const; + +public slots: + void setAnimationSpeed(int value); + +signals: + void animationSpeedChanged(int value); + +private: + QString group; +}; + +class LocationServiceSettingsObjectWrapper : public QObject { + Q_OBJECT Q_PROPERTY(int time_threshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged) Q_PROPERTY(int distance_threshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged) - Q_PROPERTY(bool git_local_only READ gitLocalOnly WRITE setGitLocalOnly NOTIFY gitLocalOnlyChanged) +public: + LocationServiceSettingsObjectWrapper(QObject *parent); + int timeThreshold() const; + int distanceThreshold() const; +public slots: + void setTimeThreshold(int value); + void setDistanceThreshold(int value); +signals: + void timeThresholdChanged(int value); + void distanceThresholdChanged(int value); +private: + QString group; +}; + +class SettingsObjectWrapper : public QObject { + Q_OBJECT + Q_PROPERTY(short save_userid_local READ saveUserIdLocal WRITE setSaveUserIdLocal NOTIFY saveUserIdLocalChanged) + + Q_PROPERTY(TechnicalDetailsSettings* techical_details MEMBER techDetails CONSTANT) + Q_PROPERTY(PartialPressureGasSettings* pp_gas MEMBER pp_gas CONSTANT) + Q_PROPERTY(FacebookSettings* facebook MEMBER facebook CONSTANT) + Q_PROPERTY(GeocodingPreferences* geocoding MEMBER geocoding CONSTANT) + Q_PROPERTY(ProxySettings* proxy MEMBER proxy CONSTANT) + Q_PROPERTY(CloudStorageSettings* cloud_storage MEMBER cloud_storage CONSTANT) + Q_PROPERTY(DivePlannerSettings* planner MEMBER planner_settings CONSTANT) + Q_PROPERTY(UnitsSettings* units MEMBER unit_settings CONSTANT) + + Q_PROPERTY(GeneralSettingsObjectWrapper* general MEMBER general_settings CONSTANT) + Q_PROPERTY(DisplaySettingsObjectWrapper* display MEMBER display_settings CONSTANT) + Q_PROPERTY(LanguageSettingsObjectWrapper* language MEMBER language_settings CONSTANT) + Q_PROPERTY(AnimationsSettingsObjectWrapper* animation MEMBER animation_settings CONSTANT) + Q_PROPERTY(LocationServiceSettingsObjectWrapper* Location MEMBER location_settings CONSTANT) +public: + SettingsObjectWrapper(QObject *parent = NULL); + short saveUserIdLocal() const; TechnicalDetailsSettings *techDetails; PartialPressureGasSettings *pp_gas; @@ -574,8 +627,14 @@ class SettingsObjectWrapper : public QObject { UnitsSettings *unit_settings; GeneralSettingsObjectWrapper *general_settings; DisplaySettingsObjectWrapper *display_settings; -public: - SettingsObjectWrapper(QObject *parent = NULL); + LanguageSettingsObjectWrapper *language_settings; + AnimationsSettingsObjectWrapper *animation_settings; + LocationServiceSettingsObjectWrapper *location_settings; + +public slots: + void setSaveUserIdLocal(short value); +signals: + void saveUserIdLocalChanged(short value); }; -#endif
\ No newline at end of file +#endif |