diff options
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 62 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 32 |
2 files changed, 92 insertions, 2 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 6d66c9864..7c6001984 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -6,6 +6,65 @@ #include "../dive.h" // TODO: remove copy_string from dive.h +DiveComputerSettings::DiveComputerSettings(QObject *parent): + QObject(parent), group(QStringLiteral("DiveComputer")) +{ +} + +QString DiveComputerSettings::dc_vendor() const +{ + return prefs.dive_computer.vendor; +} + +QString DiveComputerSettings::dc_product() const +{ + return prefs.dive_computer.product; +} + +QString DiveComputerSettings::dc_device() const +{ + return prefs.dive_computer.device; +} + +int DiveComputerSettings::downloadMode() const +{ + return prefs.dive_computer.download_mode; +} + +void DiveComputerSettings::setVendor(const QString& vendor) +{ + QSettings s; + s.beginGroup(group); + s.setValue("dive_computer_vendor", vendor); + free(prefs.dive_computer.vendor); + prefs.dive_computer.vendor = copy_string(qPrintable(vendor)); +} + +void DiveComputerSettings::setProduct(const QString& product) +{ + QSettings s; + s.beginGroup(group); + s.setValue("dive_computer_product", product); + free(prefs.dive_computer.product); + prefs.dive_computer.product = copy_string(qPrintable(product)); +} + +void DiveComputerSettings::setDevice(const QString& device) +{ + QSettings s; + s.beginGroup(group); + s.setValue("dive_computer_device", device); + free(prefs.dive_computer.device); + prefs.dive_computer.device = copy_string(qPrintable(device)); +} + +void DiveComputerSettings::setDownloadMode(int mode) +{ + QSettings s; + s.beginGroup(group); + s.setValue("dive_computer_download_mode", mode); + prefs.dive_computer.download_mode = mode; +} UpdateManagerSettings::UpdateManagerSettings(QObject *parent) : QObject(parent), group("UpdateManager") { @@ -1679,7 +1738,8 @@ QObject(parent), language_settings(new LanguageSettingsObjectWrapper(this)), animation_settings(new AnimationsSettingsObjectWrapper(this)), location_settings(new LocationServiceSettingsObjectWrapper(this)), - update_manager_settings(new UpdateManagerSettings(this)) + update_manager_settings(new UpdateManagerSettings(this)), + dive_computer_settings(new DiveComputerSettings(this)) { } diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index 392bf068b..472150a42 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -11,6 +11,34 @@ * and QWidget frontends. This class will be huge, since * I need tons of properties, one for each option. */ +class DiveComputerSettings : public QObject { + Q_OBJECT + Q_PROPERTY(QString vendor READ dc_vendor WRITE setVendor NOTIFY vendorChanged) + Q_PROPERTY(QString product READ dc_product WRITE setProduct NOTIFY productChanged) + Q_PROPERTY(QString device READ dc_device WRITE setDevice NOTIFY deviceChanged) + Q_PROPERTY(int download_mode READ downloadMode WRITE setDownloadMode NOTIFY downloadModeChanged) +public: + DiveComputerSettings(QObject *parent); + QString dc_vendor() const; + QString dc_product() const; + QString dc_device() const; + int downloadMode() const; + +public slots: + void setVendor(const QString& vendor); + void setProduct(const QString& product); + void setDevice(const QString& device); + void setDownloadMode(int mode); + +signals: + void vendorChanged(const QString& vendor); + void productChanged(const QString& product); + void deviceChanged(const QString& device); + void downloadModeChanged(int mode); +private: + QString group; + +}; class UpdateManagerSettings : public QObject { Q_OBJECT Q_PROPERTY(bool dont_check_for_updates READ dontCheckForUpdates WRITE setDontCheckForUpdates NOTIFY dontCheckForUpdatesChanged) @@ -647,7 +675,7 @@ class SettingsObjectWrapper : public QObject { Q_PROPERTY(LocationServiceSettingsObjectWrapper* Location MEMBER location_settings CONSTANT) Q_PROPERTY(UpdateManagerSettings* update MEMBER update_manager_settings CONSTANT) - + Q_PROPERTY(DiveComputerSettings* dive_computer MEMBER dive_computer_settings CONSTANT) public: static SettingsObjectWrapper *instance(); @@ -665,6 +693,8 @@ public: AnimationsSettingsObjectWrapper *animation_settings; LocationServiceSettingsObjectWrapper *location_settings; UpdateManagerSettings *update_manager_settings; + DiveComputerSettings *dive_computer_settings; + private: SettingsObjectWrapper(QObject *parent = NULL); }; |