mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Wire up duration units preference UI
Now we track the preference, but we don't act on it, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
38b9185974
commit
876b479d69
5 changed files with 47 additions and 8 deletions
|
@ -11,6 +11,13 @@
|
||||||
else \
|
else \
|
||||||
prefs.units.field = default_prefs.units.field
|
prefs.units.field = default_prefs.units.field
|
||||||
|
|
||||||
|
#define GET_UNIT3(name, field, f, l, type) \
|
||||||
|
v = s.value(QString(name)); \
|
||||||
|
if (v.isValid() && v.toInt() >= (f) && v.toInt() <= (l)) \
|
||||||
|
prefs.units.field = (type)v.toInt(); \
|
||||||
|
else \
|
||||||
|
prefs.units.field = default_prefs.units.field
|
||||||
|
|
||||||
#define GET_BOOL(name, field) \
|
#define GET_BOOL(name, field) \
|
||||||
v = s.value(QString(name)); \
|
v = s.value(QString(name)); \
|
||||||
if (v.isValid()) \
|
if (v.isValid()) \
|
||||||
|
|
|
@ -1626,6 +1626,11 @@ int UnitsSettings::verticalSpeedTime() const
|
||||||
return prefs.units.vertical_speed_time;
|
return prefs.units.vertical_speed_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UnitsSettings::durationUnits() const
|
||||||
|
{
|
||||||
|
return prefs.units.duration_units;
|
||||||
|
}
|
||||||
|
|
||||||
QString UnitsSettings::unitSystem() const
|
QString UnitsSettings::unitSystem() const
|
||||||
{
|
{
|
||||||
return prefs.unit_system == METRIC ? QStringLiteral("metric")
|
return prefs.unit_system == METRIC ? QStringLiteral("metric")
|
||||||
|
@ -1705,6 +1710,17 @@ void UnitsSettings::setVerticalSpeedTime(int value)
|
||||||
emit verticalSpeedTimeChanged(value);
|
emit verticalSpeedTimeChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnitsSettings::setDurationUnits(int value)
|
||||||
|
{
|
||||||
|
if (value == prefs.units.duration_units)
|
||||||
|
return;
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(group);
|
||||||
|
s.setValue("duration_units", value);
|
||||||
|
prefs.units.duration_units = (units::DURATION) value;
|
||||||
|
emit durationUnitChanged(value);
|
||||||
|
}
|
||||||
|
|
||||||
void UnitsSettings::setCoordinatesTraditional(bool value)
|
void UnitsSettings::setCoordinatesTraditional(bool value)
|
||||||
{
|
{
|
||||||
if (value == prefs.coordinates_traditional)
|
if (value == prefs.coordinates_traditional)
|
||||||
|
@ -2180,6 +2196,7 @@ void SettingsObjectWrapper::load()
|
||||||
GET_UNIT("weight", weight, units::LBS, units::KG);
|
GET_UNIT("weight", weight, units::LBS, units::KG);
|
||||||
}
|
}
|
||||||
GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS);
|
GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS);
|
||||||
|
GET_UNIT3("duration_units", duration_units, units::MIXED, units::ALWAYS_HOURS, units::DURATION);
|
||||||
GET_BOOL("coordinates", coordinates_traditional);
|
GET_BOOL("coordinates", coordinates_traditional);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
s.beginGroup("TecDetails");
|
s.beginGroup("TecDetails");
|
||||||
|
|
|
@ -511,6 +511,7 @@ class UnitsSettings : public QObject {
|
||||||
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(int vertical_speed_time READ verticalSpeedTime WRITE setVerticalSpeedTime NOTIFY verticalSpeedTimeChanged)
|
Q_PROPERTY(int vertical_speed_time READ verticalSpeedTime WRITE setVerticalSpeedTime NOTIFY verticalSpeedTimeChanged)
|
||||||
|
Q_PROPERTY(int duration_units READ durationUnits WRITE setDurationUnits NOTIFY durationUnitChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UnitsSettings(QObject *parent = 0);
|
UnitsSettings(QObject *parent = 0);
|
||||||
|
@ -520,6 +521,7 @@ public:
|
||||||
int temperature() const;
|
int temperature() const;
|
||||||
int weight() const;
|
int weight() const;
|
||||||
int verticalSpeedTime() const;
|
int verticalSpeedTime() const;
|
||||||
|
int durationUnits() const;
|
||||||
QString unitSystem() const;
|
QString unitSystem() const;
|
||||||
bool coordinatesTraditional() const;
|
bool coordinatesTraditional() const;
|
||||||
|
|
||||||
|
@ -530,6 +532,7 @@ public slots:
|
||||||
void setTemperature(int value);
|
void setTemperature(int value);
|
||||||
void setWeight(int value);
|
void setWeight(int value);
|
||||||
void setVerticalSpeedTime(int value);
|
void setVerticalSpeedTime(int value);
|
||||||
|
void setDurationUnits(int value);
|
||||||
void setUnitSystem(const QString& value);
|
void setUnitSystem(const QString& value);
|
||||||
void setCoordinatesTraditional(bool value);
|
void setCoordinatesTraditional(bool value);
|
||||||
|
|
||||||
|
@ -542,6 +545,7 @@ signals:
|
||||||
void verticalSpeedTimeChanged(int value);
|
void verticalSpeedTimeChanged(int value);
|
||||||
void unitSystemChanged(const QString& value);
|
void unitSystemChanged(const QString& value);
|
||||||
void coordinatesTraditionalChanged(bool value);
|
void coordinatesTraditionalChanged(bool value);
|
||||||
|
void durationUnitChanged(int value);
|
||||||
private:
|
private:
|
||||||
const QString group = QStringLiteral("Units");
|
const QString group = QStringLiteral("Units");
|
||||||
};
|
};
|
||||||
|
|
23
core/units.h
23
core/units.h
|
@ -255,6 +255,11 @@ struct units {
|
||||||
SECONDS,
|
SECONDS,
|
||||||
MINUTES
|
MINUTES
|
||||||
} vertical_speed_time;
|
} vertical_speed_time;
|
||||||
|
enum DURATION {
|
||||||
|
MIXED,
|
||||||
|
MINUTES_ONLY,
|
||||||
|
ALWAYS_HOURS
|
||||||
|
} duration_units;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -264,15 +269,17 @@ struct units {
|
||||||
* actually use. Similarly, C instead of Kelvin.
|
* actually use. Similarly, C instead of Kelvin.
|
||||||
* And kg instead of g.
|
* And kg instead of g.
|
||||||
*/
|
*/
|
||||||
#define SI_UNITS \
|
#define SI_UNITS \
|
||||||
{ \
|
{ \
|
||||||
.length = METERS, .volume = LITER, .pressure = BAR, .temperature = CELSIUS, .weight = KG, .vertical_speed_time = MINUTES \
|
.length = METERS, .volume = LITER, .pressure = BAR, .temperature = CELSIUS, .weight = KG, \
|
||||||
}
|
.vertical_speed_time = MINUTES, .duration_units = MIXED \
|
||||||
|
}
|
||||||
|
|
||||||
#define IMPERIAL_UNITS \
|
#define IMPERIAL_UNITS \
|
||||||
{ \
|
{ \
|
||||||
.length = FEET, .volume = CUFT, .pressure = PSI, .temperature = FAHRENHEIT, .weight = LBS, .vertical_speed_time = MINUTES \
|
.length = FEET, .volume = CUFT, .pressure = PSI, .temperature = FAHRENHEIT, .weight = LBS, \
|
||||||
}
|
.vertical_speed_time = MINUTES, .duration_units = MIXED \
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ void PreferencesUnits::refreshSettings()
|
||||||
|
|
||||||
ui->vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
|
ui->vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
|
||||||
ui->vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
|
ui->vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
|
||||||
|
ui->duration_mixed->setChecked(prefs.units.duration_units == units::MIXED);
|
||||||
|
ui->duration_no_hours->setChecked(prefs.units.duration_units == units::MINUTES_ONLY);
|
||||||
|
ui->duration_show_hours->setChecked(prefs.units.duration_units == units::ALWAYS_HOURS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesUnits::syncSettings()
|
void PreferencesUnits::syncSettings()
|
||||||
|
@ -56,4 +59,5 @@ void PreferencesUnits::syncSettings()
|
||||||
units->setWeight(ui->lbs->isChecked() ? units::LBS : units::KG);
|
units->setWeight(ui->lbs->isChecked() ? units::LBS : units::KG);
|
||||||
units->setVerticalSpeedTime(ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS);
|
units->setVerticalSpeedTime(ui->vertical_speed_minutes->isChecked() ? units::MINUTES : units::SECONDS);
|
||||||
units->setCoordinatesTraditional(ui->gpsTraditional->isChecked());
|
units->setCoordinatesTraditional(ui->gpsTraditional->isChecked());
|
||||||
|
units->setDurationUnits(ui->duration_mixed->isChecked() ? units::MIXED : (ui->duration_no_hours->isChecked() ? units::MINUTES_ONLY : units::ALWAYS_HOURS));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue