mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/preferences] Added UnitFormat preference
The UnitFormat can either be Imperial (for the US) or Metric (for the rest of the world. Change-Id: Ic698e6732f1fa225d88a14e61751b775fe70f1ab
This commit is contained in:
committed by
Émilie Feral
parent
4d6682e211
commit
e2a6edd78f
@@ -133,7 +133,14 @@ void CountryController::viewWillAppear() {
|
||||
|
||||
bool CountryController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->setCountry(CountryAtIndex(selectedRow()));
|
||||
/* FIXME : Changing the unit format should perhaps be done in setCountry.*/
|
||||
I18n::Country country = CountryAtIndex(selectedRow());
|
||||
GlobalPreferences::sharedGlobalPreferences()->setCountry(country);
|
||||
if (country == I18n::Country::US) {
|
||||
Poincare::Preferences::sharedPreferences()->setUnitFormat(Poincare::Preferences::UnitFormat::Imperial);
|
||||
} else {
|
||||
Poincare::Preferences::sharedPreferences()->setUnitFormat(Poincare::Preferences::UnitFormat::Metric);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -36,6 +36,10 @@ public:
|
||||
Radian = 1,
|
||||
Gradian = 2
|
||||
};
|
||||
enum class UnitFormat : uint8_t {
|
||||
Metric = 0,
|
||||
Imperial = 1
|
||||
};
|
||||
Preferences();
|
||||
static Preferences * sharedPreferences();
|
||||
AngleUnit angleUnit() const { return m_angleUnit; }
|
||||
@@ -46,6 +50,8 @@ public:
|
||||
void setEditionMode(EditionMode editionMode) { m_editionMode = editionMode; }
|
||||
ComplexFormat complexFormat() const { return m_complexFormat; }
|
||||
void setComplexFormat(Preferences::ComplexFormat complexFormat) { m_complexFormat = complexFormat; }
|
||||
UnitFormat unitFormat() const { return m_unitFormat; }
|
||||
void setUnitFormat(UnitFormat unitFormat) { m_unitFormat = unitFormat; }
|
||||
uint8_t numberOfSignificantDigits() const { return m_numberOfSignificantDigits; }
|
||||
void setNumberOfSignificantDigits(uint8_t numberOfSignificantDigits) { m_numberOfSignificantDigits = numberOfSignificantDigits; }
|
||||
private:
|
||||
@@ -53,6 +59,7 @@ private:
|
||||
PrintFloatMode m_displayMode;
|
||||
EditionMode m_editionMode;
|
||||
ComplexFormat m_complexFormat;
|
||||
UnitFormat m_unitFormat;
|
||||
uint8_t m_numberOfSignificantDigits;
|
||||
};
|
||||
|
||||
|
||||
@@ -210,21 +210,21 @@ public:
|
||||
static constexpr const Prefix * NoPrefix[] = {
|
||||
&EmptyPrefix
|
||||
};
|
||||
static constexpr const Prefix * NegativeLongScalePrefixes[] = {
|
||||
static constexpr const Prefix * NegativeLongScalePrefixes[] = {
|
||||
&PicoPrefix,
|
||||
&NanoPrefix,
|
||||
&MicroPrefix,
|
||||
&MilliPrefix,
|
||||
&EmptyPrefix,
|
||||
};
|
||||
static constexpr const Prefix * PositiveLongScalePrefixes[] = {
|
||||
static constexpr const Prefix * PositiveLongScalePrefixes[] = {
|
||||
&EmptyPrefix,
|
||||
&KiloPrefix,
|
||||
&MegaPrefix,
|
||||
&GigaPrefix,
|
||||
&TeraPrefix,
|
||||
};
|
||||
static constexpr const Prefix * LongScalePrefixes[] = {
|
||||
static constexpr const Prefix * LongScalePrefixes[] = {
|
||||
&PicoPrefix,
|
||||
&NanoPrefix,
|
||||
&MicroPrefix,
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
&GigaPrefix,
|
||||
&TeraPrefix,
|
||||
};
|
||||
static constexpr const Prefix * NegativePrefixes[] = {
|
||||
static constexpr const Prefix * NegativePrefixes[] = {
|
||||
&PicoPrefix,
|
||||
&NanoPrefix,
|
||||
&MicroPrefix,
|
||||
@@ -244,7 +244,7 @@ public:
|
||||
&DeciPrefix,
|
||||
&EmptyPrefix,
|
||||
};
|
||||
static constexpr const Prefix * AllPrefixes[] = {
|
||||
static constexpr const Prefix * AllPrefixes[] = {
|
||||
&PicoPrefix,
|
||||
&NanoPrefix,
|
||||
&MicroPrefix,
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
#include <poincare/power.h>
|
||||
#include <poincare/rational.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <limits.h>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user