[locale] Get starting TZ in Config
- read the *region* and *zone* settings; this duplicates what the ViewStep does and is currently unused, but .. - add new support for using the system's TZ (rather than the fixed values from *region* and *zone*). This complements GeoIP lookup. This is the actual feature that started the long rewrite of the Config object (so that all the business logic would be in one place, usable for both widgets and QML). FIXES #1381
This commit is contained in:
parent
781d76c9e5
commit
b607cf3f98
@ -31,6 +31,7 @@
|
||||
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QTimeZone>
|
||||
|
||||
/** @brief Load supported locale keys
|
||||
*
|
||||
@ -342,17 +343,38 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
#ifdef DEBUG_TIMEZONES
|
||||
if ( m_adjustLiveTimezone )
|
||||
{
|
||||
cDebug() << "Turning off live-timezone adjustments because debugging is on.";
|
||||
cWarning() << "Turning off live-timezone adjustments because debugging is on.";
|
||||
m_adjustLiveTimezone = false;
|
||||
}
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
if ( m_adjustLiveTimezone )
|
||||
{
|
||||
cDebug() << "Turning off live-timezone adjustments on FreeBSD.";
|
||||
cWarning() << "Turning off live-timezone adjustments on FreeBSD.";
|
||||
m_adjustLiveTimezone = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString region = CalamaresUtils::getString( configurationMap, "region" );
|
||||
QString zone = CalamaresUtils::getString( configurationMap, "zone" );
|
||||
if ( !region.isEmpty() && !zone.isEmpty() )
|
||||
{
|
||||
m_startingTimezone = CalamaresUtils::GeoIP::RegionZonePair( region, zone );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_startingTimezone
|
||||
= CalamaresUtils::GeoIP::RegionZonePair( QStringLiteral( "America" ), QStringLiteral( "New_York" ) );
|
||||
}
|
||||
|
||||
if ( CalamaresUtils::getBool( configurationMap, "useSystemTimezone", false ) )
|
||||
{
|
||||
auto systemtz = CalamaresUtils::GeoIP::splitTZString( QTimeZone::systemTimeZoneId() );
|
||||
if ( systemtz.isValid() )
|
||||
{
|
||||
m_startingTimezone = systemtz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Calamares::JobList
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "LocaleConfiguration.h"
|
||||
|
||||
#include "Job.h"
|
||||
#include "geoip/Interface.h"
|
||||
#include "locale/TimeZone.h"
|
||||
|
||||
#include <QObject>
|
||||
@ -133,6 +134,10 @@ private:
|
||||
* timezone, and the live system can be made to follow that.
|
||||
*/
|
||||
bool m_adjustLiveTimezone;
|
||||
|
||||
/** @brief The initial timezone (region, zone) specified in the config.
|
||||
*/
|
||||
CalamaresUtils::GeoIP::RegionZonePair m_startingTimezone;
|
||||
};
|
||||
|
||||
|
||||
|
@ -11,9 +11,21 @@
|
||||
# the locale page can be set through keys *region* and *zone*.
|
||||
# If either is not set, defaults to America/New_York.
|
||||
#
|
||||
# Note that useSystemTimezone and GeoIP settings can change the
|
||||
# starting time zone.
|
||||
#
|
||||
region: "America"
|
||||
zone: "New_York"
|
||||
|
||||
# Instead of using *region* and *zone* specified above,
|
||||
# you can use the system's notion of the timezone, instead.
|
||||
# This can help if your system is automatically configured with
|
||||
# a sensible TZ rather than chasing a fixed default.
|
||||
#
|
||||
# The default is false.
|
||||
#
|
||||
# useSystemTimezone: true
|
||||
|
||||
# Should changing the system location (e.g. clicking around on the timezone
|
||||
# map) immediately reflect the changed timezone in the live system?
|
||||
# By default, installers (with a target system) do, and setup (e.g. OEM
|
||||
|
@ -19,6 +19,7 @@ properties:
|
||||
]
|
||||
}
|
||||
zone: { type: string }
|
||||
useSystemTimezone: { type: boolean, default: false }
|
||||
|
||||
adjustLiveTimezone: { type: boolean, default: true }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user