diff options
author | Ilya Grechuhin <i.grechuhin@mapswithme.com> | 2015-07-16 13:49:24 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:56:31 +0300 |
commit | 3c5bb1746c29c54a40a16efaba9c6c2eb5500c74 (patch) | |
tree | ae57f3dfb910e049888931b38d14e5158dc69071 /platform | |
parent | 51e035216bc40b91819c9aaa16eab2205715ec5d (diff) |
[omim] Extracted measurement system setup to platform.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/platform.hpp | 2 | ||||
-rw-r--r-- | platform/platform_android.cpp | 11 | ||||
-rw-r--r-- | platform/platform_ios.mm | 21 | ||||
-rw-r--r-- | platform/platform_qt.cpp | 17 |
4 files changed, 43 insertions, 8 deletions
diff --git a/platform/platform.hpp b/platform/platform.hpp index 95e1eb7587..283614aa61 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -207,6 +207,8 @@ public: static EConnectionType ConnectionStatus(); static bool IsConnected() { return ConnectionStatus() != EConnectionType::CONNECTION_NONE; } + void SetupMeasurementSystem() const; + private: void GetSystemFontNames(FilesList & res) const; }; diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp index 225547015e..dcd83fffe0 100644 --- a/platform/platform_android.cpp +++ b/platform/platform_android.cpp @@ -1,6 +1,7 @@ #include "platform/platform.hpp" #include "platform/platform_unix_impl.hpp" #include "platform/constants.hpp" +#include "platform/settings.hpp" #include "coding/zip_reader.hpp" #include "coding/file_name_utils.hpp" @@ -264,6 +265,16 @@ Platform::EError Platform::MkDir(string const & dirName) const return Platform::ERR_OK; } +void Platform::SetupMeasurementSystem() const +{ + Settings::Units u; + if (Settings::Get("Units", u)) + return; + // @TODO Add correct implementation + u = Settings::Metric; + Settings::Set("Units", u); +} + namespace { class FunctorWrapper : public threads::IRoutine diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm index 2cbc073dbb..9e95dfd48b 100644 --- a/platform/platform_ios.mm +++ b/platform/platform_ios.mm @@ -1,20 +1,21 @@ +#include "platform/constants.hpp" #include "platform/platform_ios.hpp" #include "platform/platform_unix_impl.hpp" -#include "platform/constants.hpp" +#include "platform/settings.hpp" #include "coding/file_reader.hpp" #include <ifaddrs.h> -#import <mach/mach.h> +#include <mach/mach.h> + +#include <net/if_dl.h> +#include <net/if.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> -#include <net/if_dl.h> -#include <net/if.h> - #if !defined(IFT_ETHER) #define IFT_ETHER 0x6 /* Ethernet CSMACD */ #endif @@ -195,6 +196,16 @@ Platform::EConnectionType Platform::ConnectionStatus() return EConnectionType::CONNECTION_WIFI; } +void Platform::SetupMeasurementSystem() const +{ + Settings::Units u; + if (Settings::Get("Units", u)) + return; + BOOL const isMetric = [[[NSLocale autoupdatingCurrentLocale] objectForKey:NSLocaleUsesMetricSystem] boolValue]; + u = isMetric ? Settings::Metric : Settings::Foot; + Settings::Set("Units", u); +} + CustomIOSPlatform::CustomIOSPlatform() { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; diff --git a/platform/platform_qt.cpp b/platform/platform_qt.cpp index 004c273446..31f127b466 100644 --- a/platform/platform_qt.cpp +++ b/platform/platform_qt.cpp @@ -1,17 +1,19 @@ -#include "platform/platform.hpp" + #include "platform/constants.hpp" +#include "platform/platform.hpp" +#include "platform/settings.hpp" #include "coding/file_reader.hpp" #include "base/logging.hpp" #include "base/regexp.hpp" -#include "std/target_os.hpp" #include "std/algorithm.hpp" +#include "std/target_os.hpp" #include <QtCore/QDir> #include <QtCore/QFileInfo> - +#include <QtCore/QLocale> ModelReader * Platform::GetReader(string const & file, string const & searchScope) const { @@ -69,6 +71,15 @@ Platform::EError Platform::MkDir(string const & dirName) const return Platform::ERR_OK; } +void Platform::SetupMeasurementSystem() const +{ + Settings::Units u; + if (Settings::Get("Units", u)) + return; + bool const isMetric = QLocale::system().measurementSystem() == QLocale::MetricSystem; + u = isMetric ? Settings::Metric : Settings::Foot; + Settings::Set("Units", u); +} extern Platform & GetPlatform() { |