mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-08 01:36:16 +00:00
Settings QObjectification: implement the unit settings
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
455f7bd51b
commit
ba111ce9a3
2 changed files with 170 additions and 9 deletions
|
@ -1094,6 +1094,135 @@ void DivePlannerSettings::setDecoMode(deco_mode value)
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(group);
|
s.beginGroup(group);
|
||||||
s.setValue("deco_mode", value);
|
s.setValue("deco_mode", value);
|
||||||
prefs.deco_mode = value.;
|
prefs.deco_mode = value;
|
||||||
emit decoModeChanged(value);
|
emit decoModeChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnitsSettings::UnitsSettings(QObject *parent = 0) :
|
||||||
|
QObject(parent),
|
||||||
|
group(QStringLiteral("Units"))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
units::length UnitsSettings::length() const
|
||||||
|
{
|
||||||
|
return prefs.units.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
units::pressure UnitsSettings::pressure() const
|
||||||
|
{
|
||||||
|
return prefs.units.pressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
units::volume UnitsSettings::volume() const
|
||||||
|
{
|
||||||
|
return prefs.units.volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
units::temperature UnitsSettings::temperature() const
|
||||||
|
{
|
||||||
|
return prefs.units.temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
units::weight UnitsSettings::weight() const
|
||||||
|
{
|
||||||
|
return prefs.units.weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
units::vertical_speed_time UnitsSettings::verticalSpeedTime() const
|
||||||
|
{
|
||||||
|
return prefs.units.vertical_speed_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString UnitsSettings::unitSystem() const
|
||||||
|
{
|
||||||
|
return prefs.unit_system;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UnitsSettings::coordinatesTraditional() const
|
||||||
|
{
|
||||||
|
return prefs.coordinates_traditional;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setLength(units::length value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("length", value);
|
||||||
|
prefs.units.length = value;
|
||||||
|
emit lengthChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setPressure(units::pressure value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("pressure", value);
|
||||||
|
prefs.units.pressure = value;
|
||||||
|
emit pressureChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setVolume(units::volume value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("volume", value);
|
||||||
|
prefs.units.volume = value;
|
||||||
|
emit volumeChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setTemperature(units::temperature value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("temperature", value);
|
||||||
|
prefs.units.temperature = value;
|
||||||
|
emit temperatureChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setWeight(units::weight value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("weight", value);
|
||||||
|
prefs.units.weight = value;
|
||||||
|
emit weightChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setVerticalSpeedTime(units::vertical_speed_time value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("vertical_speed_time", value);
|
||||||
|
prefs.units.vertical_speed_time = value;
|
||||||
|
emit verticalSpeedTimeChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setCoordinatesTraditional(bool value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.setValue("coordinates", value);
|
||||||
|
prefs.coordinates_traditional = value.;
|
||||||
|
emit coordinatesTraditionalChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setUnitSystem(const QString& value)
|
||||||
|
{
|
||||||
|
QSettings s;
|
||||||
|
s.setValue("unit_system", value);
|
||||||
|
prefs.unit_system = value;
|
||||||
|
|
||||||
|
if (value == QStringLiteral("metric")) {
|
||||||
|
prefs.unit_system = METRIC;
|
||||||
|
prefs.units = SI_units;
|
||||||
|
} else if (value == QStringLiteral("imperial")) {
|
||||||
|
prefs.unit_system = IMPERIAL;
|
||||||
|
prefs.units = IMPERIAL_units;
|
||||||
|
} else {
|
||||||
|
prefs.unit_system = PERSONALIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit unitSystemChanged(value);
|
||||||
|
// TODO: emit the other values here?
|
||||||
|
}
|
||||||
|
|
|
@ -407,15 +407,47 @@ private:
|
||||||
|
|
||||||
class UnitsSettings : public QObject {
|
class UnitsSettings : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(units::length length READ divelistFont WRITE setDivelistFont NOTIFY divelistFontChanged)
|
Q_PROPERTY(units::length length READ length WRITE setLength NOTIFY lengthChanged)
|
||||||
Q_PROPERTY(units::pressure pressure READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged)
|
Q_PROPERTY(units::pressure pressure READ pressure WRITE setPressure NOTIFY pressureChanged)
|
||||||
Q_PROPERTY(units::volume volume READ defaultCylinder WRITE setDefaultCylinder NOTIFY defaultCylinderChanged)
|
Q_PROPERTY(units::volume volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||||
Q_PROPERTY(units::temperature temperature READ timeFormat WRITE setTimeFormat NOTIFY timeFormatChanged)
|
Q_PROPERTY(units::temperature temperature READ temperature WRITE setTemperature NOTIFY temperatureChanged)
|
||||||
Q_PROPERTY(units::weight weight READ dateFormat WRITE setDateFormat NOTIFY dateFormatChanged)
|
Q_PROPERTY(units::weight weight READ weight WRITE setWeight NOTIFY weightChanged)
|
||||||
Q_PROPERTY(units::vertical_speed_time vertical_speed_time READ dateFormatShort WRITE setDateFormatShort NOTIFY dateFormatShortChanged)
|
Q_PROPERTY(QString unit_system READ unitSystem WRITE setUnitSystem NOTIFY unitSystemChanged)
|
||||||
Q_PROPERTY(QString unit_system READ unitSystem WRITE setUnitSystem NOTIFY unitSystemChanged)
|
|
||||||
Q_PROPERTY(bool coordinates_traditional READ coordinatesTraditional WRITE setCoordinatesTraditional NOTIFY coordinatesTraditionalChanged)
|
Q_PROPERTY(bool coordinates_traditional READ coordinatesTraditional WRITE setCoordinatesTraditional NOTIFY coordinatesTraditionalChanged)
|
||||||
|
Q_PROPERTY(units::vertical_speed_time vertical_speed_time READ verticalSpeedTime WRITE setVerticalSpeedTime NOTIFY verticalSpeedTimeChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
UnitsSettings(QObject *parent = 0);
|
||||||
|
units::length length() const;
|
||||||
|
units::pressure pressure() const;
|
||||||
|
units::volume volume() const;
|
||||||
|
units::temperature temperature() const;
|
||||||
|
units::weight weight() const;
|
||||||
|
units::vertical_speed_time verticalSpeedTime() const;
|
||||||
|
QString unitSystem() const;
|
||||||
|
bool coordinatesTraditional() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setLength(units::length value);
|
||||||
|
void setPressure(units::pressure value);
|
||||||
|
void setVolume(units::volume value);
|
||||||
|
void setTemperature(units::temperature value);
|
||||||
|
void setWeight(units::weight value);
|
||||||
|
void setVerticalSpeedTime(units::vertical_speed_time value);
|
||||||
|
void setUnitSystem(const QString& value);
|
||||||
|
void setCoordinatesTraditional(bool value);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void lengthChanged(units::length value);
|
||||||
|
void pressureChanged(units::pressure value);
|
||||||
|
void volumeChanged(units::volume value);
|
||||||
|
void temperatureChanged(units::temperature value);
|
||||||
|
void weightChanged(units::weight value);
|
||||||
|
void verticalSpeedTimeChanged(units::vertical_speed_time value);
|
||||||
|
void unitSystemChanged(const QString& value);
|
||||||
|
void coordinatesTraditionalChanged(bool value);
|
||||||
|
private:
|
||||||
|
QString group;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SettingsObjectWrapper : public QObject {
|
class SettingsObjectWrapper : public QObject {
|
||||||
|
@ -451,7 +483,7 @@ class SettingsObjectWrapper : public QObject {
|
||||||
ProxySettings *proxy;
|
ProxySettings *proxy;
|
||||||
CloudStorageSettings *cloud_storage;
|
CloudStorageSettings *cloud_storage;
|
||||||
DivePlannerSettings *planner_settings;
|
DivePlannerSettings *planner_settings;
|
||||||
|
UnitsSettings *unit_settings;
|
||||||
public:
|
public:
|
||||||
SettingsObjectWrapper(QObject *parent = NULL);
|
SettingsObjectWrapper(QObject *parent = NULL);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue