[locale] Add a 'current timezone' strings to Config

- status is a longer phrase
- name is a short human-readable name
- code is the internal code

Code that writes its own "Timezone set to" messages can use
the name, rather than the status.
This commit is contained in:
Adriaan de Groot 2020-08-06 12:40:24 +02:00
parent eda14ce548
commit 15a8d62986
2 changed files with 34 additions and 0 deletions

View file

@ -192,6 +192,9 @@ Config::Config( QObject* parent )
QProcess::execute( "timedatectl", // depends on systemd
{ "set-timezone", location->region() + '/' + location->zone() } );
}
emit currentTimezoneCodeChanged( currentTimezoneCode() );
emit currentTimezoneNameChanged( currentTimezoneName() );
} );
auto prettyStatusNotify = [&]() { emit prettyStatusChanged( prettyStatus() ); };
@ -265,6 +268,7 @@ Config::setCurrentLocation( const CalamaresUtils::Locale::TimeZoneData* location
emit currentLCStatusChanged( currentLCStatus() );
}
emit currentLocationChanged( m_currentLocation );
// Other signals come from the LocationChanged signal
}
}
@ -323,6 +327,27 @@ Config::currentLocationStatus() const
m_currentLocation ? m_currentLocation->zone() : QString() );
}
QString
Config::currentTimezoneCode() const
{
if ( m_currentLocation )
{
return m_currentLocation->region() + '/' + m_currentLocation->zone();
}
return QString();
}
QString
Config::currentTimezoneName() const
{
if ( m_currentLocation )
{
return m_regionModel->tr( m_currentLocation->region() ) + '/' + m_currentLocation->tr();
}
return QString();
}
static inline QString
localeLabel( const QString& s )
{