mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core/settings: make qPrefUnit accesable from QML
Use string literals to communicate with QML. Instead of passing arounds enum/int value, it seems easier to pass string literals to QML and have that code respond to those Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
573a4a5e2d
commit
fc7aec5402
3 changed files with 151 additions and 49 deletions
|
@ -9,15 +9,15 @@
|
|||
class qPrefUnits : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool coordinates_traditional READ coordinates_traditional WRITE set_coordinates_traditional NOTIFY coordinates_traditionalChanged)
|
||||
Q_PROPERTY(units::DURATION duration_units READ duration_units WRITE set_duration_units NOTIFY duration_unitsChanged)
|
||||
Q_PROPERTY(units::LENGTH length READ length WRITE set_length NOTIFY lengthChanged)
|
||||
Q_PROPERTY(units::PRESSURE pressure READ pressure WRITE set_pressure NOTIFY pressureChanged)
|
||||
Q_PROPERTY(QString duration_units READ duration_units WRITE set_duration_units NOTIFY duration_unitsStringChanged)
|
||||
Q_PROPERTY(QString length READ length WRITE set_length NOTIFY lengthStringChanged)
|
||||
Q_PROPERTY(QString pressure READ pressure WRITE set_pressure NOTIFY pressureStringChanged)
|
||||
Q_PROPERTY(bool show_units_table READ show_units_table WRITE set_show_units_table NOTIFY show_units_tableChanged)
|
||||
Q_PROPERTY(units::TEMPERATURE temperature READ temperature WRITE set_temperature NOTIFY temperatureChanged)
|
||||
Q_PROPERTY(QString temperature READ temperature WRITE set_temperature NOTIFY temperatureStringChanged)
|
||||
Q_PROPERTY(QString unit_system READ unit_system WRITE set_unit_system NOTIFY unit_systemChanged)
|
||||
Q_PROPERTY(units::TIME vertical_speed_time READ vertical_speed_time WRITE set_vertical_speed_time NOTIFY vertical_speed_timeChanged)
|
||||
Q_PROPERTY(units::VOLUME volume READ volume WRITE set_volume NOTIFY volumeChanged)
|
||||
Q_PROPERTY(units::WEIGHT weight READ weight WRITE set_weight NOTIFY weightChanged)
|
||||
Q_PROPERTY(QString vertical_speed_time READ vertical_speed_time WRITE set_vertical_speed_time NOTIFY vertical_speed_timeStringChanged)
|
||||
Q_PROPERTY(QString volume READ volume WRITE set_volume NOTIFY volumeStringChanged)
|
||||
Q_PROPERTY(QString weight READ weight WRITE set_weight NOTIFY weightStringChanged)
|
||||
|
||||
public:
|
||||
static qPrefUnits *instance();
|
||||
|
@ -29,40 +29,61 @@ public:
|
|||
|
||||
public:
|
||||
static bool coordinates_traditional() { return prefs.coordinates_traditional; }
|
||||
static units::DURATION duration_units() { return prefs.units.duration_units; }
|
||||
static units::LENGTH length() { return prefs.units.length; }
|
||||
static units::PRESSURE pressure() { return prefs.units.pressure; }
|
||||
static QString duration_units();
|
||||
static QString length();
|
||||
static QString pressure();
|
||||
static bool show_units_table() { return prefs.units.show_units_table; }
|
||||
static units::TEMPERATURE temperature() { return prefs.units.temperature; }
|
||||
static QString temperature();
|
||||
static QString unit_system();
|
||||
static units::TIME vertical_speed_time() { return prefs.units.vertical_speed_time; }
|
||||
static units::VOLUME volume() { return prefs.units.volume; }
|
||||
static units::WEIGHT weight() { return prefs.units.weight; }
|
||||
static QString vertical_speed_time();
|
||||
static QString volume();
|
||||
static QString weight();
|
||||
|
||||
public slots:
|
||||
static void set_coordinates_traditional(bool value);
|
||||
static void set_duration_units(units::DURATION value);
|
||||
static void set_duration_units(const QString& value);
|
||||
static void set_length(units::LENGTH value);
|
||||
static void set_length(const QString& value);
|
||||
static void set_pressure(units::PRESSURE value);
|
||||
static void set_pressure(const QString& value);
|
||||
static void set_show_units_table(bool value);
|
||||
static void set_temperature(units::TEMPERATURE value);
|
||||
static void set_temperature(const QString& value);
|
||||
static void set_unit_system(const QString& value);
|
||||
static void set_vertical_speed_time(units::TIME value);
|
||||
static void set_vertical_speed_time(const QString& value);
|
||||
static void set_volume(units::VOLUME value);
|
||||
static void set_volume(const QString& value);
|
||||
static void set_weight(units::WEIGHT value);
|
||||
static void set_weight(const QString& value);
|
||||
|
||||
signals:
|
||||
// Normally the same signal name are used with different parameters:
|
||||
// void weightChanged(int value);
|
||||
// void weightChanged(const QString& value);
|
||||
// This works perfect, however connect() cannot automatically determine
|
||||
// which signal to catch, for that purpose SIGNAL() / SLOT() macros are used,
|
||||
// since they include the parameter type.
|
||||
// However there is a design decision, not to use the macros, so
|
||||
// signal must have unique names.
|
||||
void coordinates_traditionalChanged(bool value);
|
||||
void duration_unitsChanged(int value);
|
||||
void duration_unitsStringChanged(const QString& value);
|
||||
void lengthChanged(int value);
|
||||
void lengthStringChanged(const QString& value);
|
||||
void pressureChanged(int value);
|
||||
void pressureStringChanged(const QString& value);
|
||||
void show_units_tableChanged(bool value);
|
||||
void temperatureChanged(int value);
|
||||
void temperatureStringChanged(const QString& value);
|
||||
void unit_systemChanged(const QString& value);
|
||||
void vertical_speed_timeChanged(int value);
|
||||
void vertical_speed_timeStringChanged(const QString& value);
|
||||
void volumeChanged(int value);
|
||||
void volumeStringChanged(const QString& value);
|
||||
void weightChanged(int value);
|
||||
|
||||
void weightStringChanged(const QString& value);
|
||||
private:
|
||||
qPrefUnits() {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue