mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Settings update: Add UpdateManagerSettings to SettingsObjectWrapper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4f2057cd30
commit
5c8b87b5fd
3 changed files with 89 additions and 4 deletions
|
@ -43,6 +43,12 @@ enum deco_mode {
|
||||||
VPMB
|
VPMB
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool dont_check_for_updates;
|
||||||
|
char *last_version_used;
|
||||||
|
char *next_check;
|
||||||
|
} update_manager_prefs_t;
|
||||||
|
|
||||||
struct preferences {
|
struct preferences {
|
||||||
const char *divelist_font;
|
const char *divelist_font;
|
||||||
const char *default_filename;
|
const char *default_filename;
|
||||||
|
@ -134,6 +140,7 @@ struct preferences {
|
||||||
bool git_local_only;
|
bool git_local_only;
|
||||||
short cloud_timeout;
|
short cloud_timeout;
|
||||||
locale_prefs_t locale; //: TODO: move the rest of locale based info here.
|
locale_prefs_t locale; //: TODO: move the rest of locale based info here.
|
||||||
|
update_manager_prefs_t update_manager;
|
||||||
};
|
};
|
||||||
enum unit_system_values {
|
enum unit_system_values {
|
||||||
METRIC,
|
METRIC,
|
||||||
|
|
|
@ -2,10 +2,60 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
#include "../dive.h" // TODO: remove copy_string from dive.h
|
#include "../dive.h" // TODO: remove copy_string from dive.h
|
||||||
|
|
||||||
|
|
||||||
|
UpdateManagerSettings::UpdateManagerSettings(QObject *parent) : QObject(parent), group("UpdateManager")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UpdateManagerSettings::dontCheckForUpdates() const
|
||||||
|
{
|
||||||
|
return prefs.update_manager.dont_check_for_updates;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString UpdateManagerSettings::lastVersionUsed() const
|
||||||
|
{
|
||||||
|
return prefs.update_manager.last_version_used;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate UpdateManagerSettings::nextCheck() const
|
||||||
|
{
|
||||||
|
return QDate::fromString(QString(prefs.update_manager.next_check));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateManagerSettings::setDontCheckForUpdates(bool value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("DontCheckForUpdates", value);
|
||||||
|
prefs.update_manager.dont_check_for_updates = value;
|
||||||
|
emit dontCheckForUpdatesChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateManagerSettings::setLastVersionUsed(const QString& value)\
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("LastVersionUsed", value);
|
||||||
|
free (prefs.update_manager.last_version_used);
|
||||||
|
prefs.update_manager.last_version_used = copy_string(qPrintable(value));
|
||||||
|
emit lastVersionUsedChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateManagerSettings::setNextCheck(const QDate& date)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("NextCheck", date);
|
||||||
|
free (prefs.update_manager.next_check);
|
||||||
|
prefs.update_manager.next_check = copy_string(qPrintable(date.toString()));
|
||||||
|
emit nextCheckChanged(date);
|
||||||
|
}
|
||||||
|
|
||||||
static QString tecDetails = QStringLiteral("TecDetails");
|
static QString tecDetails = QStringLiteral("TecDetails");
|
||||||
|
|
||||||
PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent):
|
PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent):
|
||||||
|
@ -1628,7 +1678,8 @@ QObject(parent),
|
||||||
display_settings(new DisplaySettingsObjectWrapper(this)),
|
display_settings(new DisplaySettingsObjectWrapper(this)),
|
||||||
language_settings(new LanguageSettingsObjectWrapper(this)),
|
language_settings(new LanguageSettingsObjectWrapper(this)),
|
||||||
animation_settings(new AnimationsSettingsObjectWrapper(this)),
|
animation_settings(new AnimationsSettingsObjectWrapper(this)),
|
||||||
location_settings(new LocationServiceSettingsObjectWrapper(this))
|
location_settings(new LocationServiceSettingsObjectWrapper(this)),
|
||||||
|
update_manager_settings(new UpdateManagerSettings(this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,30 @@
|
||||||
* and QWidget frontends. This class will be huge, since
|
* and QWidget frontends. This class will be huge, since
|
||||||
* I need tons of properties, one for each option. */
|
* I need tons of properties, one for each option. */
|
||||||
|
|
||||||
|
class UpdateManagerSettings : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool dont_check_for_updates READ dontCheckForUpdates WRITE setDontCheckForUpdates NOTIFY dontCheckForUpdatesChanged)
|
||||||
|
Q_PROPERTY(QString last_version_used READ lastVersionUsed WRITE setLastVersionUsed NOTIFY lastVersionUsedChanged)
|
||||||
|
Q_PROPERTY(QDate next_check READ nextCheck WRITE nextCheckChanged)
|
||||||
|
public:
|
||||||
|
UpdateManagerSettings(QObject *parent);
|
||||||
|
bool dontCheckForUpdates() const;
|
||||||
|
QString lastVersionUsed() const;
|
||||||
|
QDate nextCheck() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setDontCheckForUpdates(bool value);
|
||||||
|
void setLastVersionUsed(const QString& value);
|
||||||
|
void setNextCheck(const QDate& date);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void dontCheckForUpdatesChanged(bool value);
|
||||||
|
void lastVersionUsedChanged(const QString& value);
|
||||||
|
void nextCheckChanged(const QDate& date);
|
||||||
|
private:
|
||||||
|
QString group;
|
||||||
|
};
|
||||||
|
|
||||||
/* Control the state of the Partial Pressure Graphs preferences */
|
/* Control the state of the Partial Pressure Graphs preferences */
|
||||||
class PartialPressureGasSettings : public QObject {
|
class PartialPressureGasSettings : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -53,7 +77,7 @@ class TechnicalDetailsSettings : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(double modpO2 READ modp02 WRITE setModp02 NOTIFY modpO2Changed)
|
Q_PROPERTY(double modpO2 READ modp02 WRITE setModp02 NOTIFY modpO2Changed)
|
||||||
Q_PROPERTY(bool ead READ ead WRITE setEad NOTIFY eadChanged)
|
Q_PROPERTY(bool ead READ ead WRITE setEad NOTIFY eadChanged)
|
||||||
Q_PROPERTY(bool mod READ mod WRITE setMod NOTIFY modChanged);
|
Q_PROPERTY(bool mod READ mod WRITE setMod NOTIFY modChanged)
|
||||||
Q_PROPERTY(bool dcceiling READ dcceiling WRITE setDCceiling NOTIFY dcceilingChanged)
|
Q_PROPERTY(bool dcceiling READ dcceiling WRITE setDCceiling NOTIFY dcceilingChanged)
|
||||||
Q_PROPERTY(bool redceiling READ redceiling WRITE setRedceiling NOTIFY redceilingChanged)
|
Q_PROPERTY(bool redceiling READ redceiling WRITE setRedceiling NOTIFY redceilingChanged)
|
||||||
Q_PROPERTY(bool calcceiling READ calcceiling WRITE setCalcceiling NOTIFY calcceilingChanged)
|
Q_PROPERTY(bool calcceiling READ calcceiling WRITE setCalcceiling NOTIFY calcceilingChanged)
|
||||||
|
@ -621,6 +645,9 @@ class SettingsObjectWrapper : public QObject {
|
||||||
Q_PROPERTY(LanguageSettingsObjectWrapper* language MEMBER language_settings CONSTANT)
|
Q_PROPERTY(LanguageSettingsObjectWrapper* language MEMBER language_settings CONSTANT)
|
||||||
Q_PROPERTY(AnimationsSettingsObjectWrapper* animation MEMBER animation_settings CONSTANT)
|
Q_PROPERTY(AnimationsSettingsObjectWrapper* animation MEMBER animation_settings CONSTANT)
|
||||||
Q_PROPERTY(LocationServiceSettingsObjectWrapper* Location MEMBER location_settings CONSTANT)
|
Q_PROPERTY(LocationServiceSettingsObjectWrapper* Location MEMBER location_settings CONSTANT)
|
||||||
|
|
||||||
|
Q_PROPERTY(UpdateManagerSettings* update MEMBER update_manager_settings CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SettingsObjectWrapper *instance();
|
static SettingsObjectWrapper *instance();
|
||||||
|
|
||||||
|
@ -637,7 +664,7 @@ public:
|
||||||
LanguageSettingsObjectWrapper *language_settings;
|
LanguageSettingsObjectWrapper *language_settings;
|
||||||
AnimationsSettingsObjectWrapper *animation_settings;
|
AnimationsSettingsObjectWrapper *animation_settings;
|
||||||
LocationServiceSettingsObjectWrapper *location_settings;
|
LocationServiceSettingsObjectWrapper *location_settings;
|
||||||
|
UpdateManagerSettings *update_manager_settings;
|
||||||
private:
|
private:
|
||||||
SettingsObjectWrapper(QObject *parent = NULL);
|
SettingsObjectWrapper(QObject *parent = NULL);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue