diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp
index 8893d387a..cdd4e767f 100644
--- a/src/modules/locale/Config.cpp
+++ b/src/modules/locale/Config.cpp
@@ -192,6 +192,7 @@ Config::setCurrentLocation( const CalamaresUtils::Locale::TZZone* location )
if ( !m_selectedLocaleConfiguration.explicit_lang )
{
m_selectedLocaleConfiguration.setLanguage( newLocale.language() );
+ emit currentLanguageStatusChanged( currentLanguageStatus() );
}
if ( !m_selectedLocaleConfiguration.explicit_lc )
{
@@ -204,6 +205,8 @@ Config::setCurrentLocation( const CalamaresUtils::Locale::TZZone* location )
m_selectedLocaleConfiguration.lc_telephone = newLocale.lc_telephone;
m_selectedLocaleConfiguration.lc_measurement = newLocale.lc_measurement;
m_selectedLocaleConfiguration.lc_identification = newLocale.lc_identification;
+
+ emit currentLCStatusChanged( currentLCStatus() );
}
emit currentLocationChanged( m_currentLocation );
}
@@ -228,6 +231,8 @@ Config::setLanguageExplicitly( const QString& language )
{
m_selectedLocaleConfiguration.setLanguage( language );
m_selectedLocaleConfiguration.explicit_lang = true;
+
+ emit currentLanguageStatusChanged( currentLanguageStatus() );
}
void
@@ -244,33 +249,37 @@ Config::setLCLocaleExplicitly( const QString& locale )
m_selectedLocaleConfiguration.lc_measurement = locale;
m_selectedLocaleConfiguration.lc_identification = locale;
m_selectedLocaleConfiguration.explicit_lc = true;
-}
-std::pair< QString, QString >
-Config::prettyLocaleStatus() const
-{
- using CalamaresUtils::Locale::Label;
-
- Label lang( m_selectedLocaleConfiguration.language(), Label::LabelFormat::AlwaysWithCountry );
- Label num( m_selectedLocaleConfiguration.lc_numeric, Label::LabelFormat::AlwaysWithCountry );
-
- return std::make_pair< QString, QString >(
- tr( "The system language will be set to %1." ).arg( lang.label() ),
- tr( "The numbers and dates locale will be set to %1." ).arg( num.label() ) );
+ emit currentLCStatusChanged( currentLCStatus() );
}
QString
-Config::prettyStatus() const
+Config::currentLocationStatus() const
{
- QString br( QStringLiteral("
"));
- QString status;
- status += tr( "Set timezone to %1/%2." ).arg( m_currentLocation->region(), m_currentLocation->zone() ) + br;
+ return tr( "Set timezone to %1/%2." ).arg( m_currentLocation->region(), m_currentLocation->zone() );
+}
- auto labels = prettyLocaleStatus();
- status += labels.first + br;
- status += labels.second + br;
+static inline QString
+localeLabel( const QString& s )
+{
+ using CalamaresUtils::Locale::Label;
- return status;
+ Label lang( s, Label::LabelFormat::AlwaysWithCountry );
+ return lang.label();
+}
+
+QString
+Config::currentLanguageStatus() const
+{
+ return tr( "The system language will be set to %1." )
+ .arg( localeLabel( m_selectedLocaleConfiguration.language() ) );
+}
+
+QString
+Config::currentLCStatus() const
+{
+ return tr( "The numbers and dates locale will be set to %1." )
+ .arg( localeLabel( m_selectedLocaleConfiguration.lc_numeric ) );
}
diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h
index 91ed8f1be..c4a512100 100644
--- a/src/modules/locale/Config.h
+++ b/src/modules/locale/Config.h
@@ -36,10 +36,14 @@ class Config : public QObject
Q_PROPERTY( const QStringList& supportedLocales READ supportedLocales CONSTANT FINAL )
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* zonesModel READ zonesModel CONSTANT FINAL )
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* regionModel READ regionModel CONSTANT FINAL )
- Q_PROPERTY( const CalamaresUtils::Locale::CStringPairList& timezoneData READ timezoneData CONSTANT FINAL )
+
Q_PROPERTY( const CalamaresUtils::Locale::TZZone* currentLocation READ currentLocation WRITE setCurrentLocation
NOTIFY currentLocationChanged )
+ Q_PROPERTY( QString currentLocationStatus READ currentLocationStatus NOTIFY currentLanguageStatusChanged )
+ Q_PROPERTY( QString currentLanguageStatus READ currentLanguageStatus NOTIFY currentLanguageStatusChanged )
+ Q_PROPERTY( QString currentLCStatus READ currentLCStatus NOTIFY currentLCStatusChanged )
+
public:
Config( QObject* parent = nullptr );
~Config();
@@ -47,25 +51,37 @@ public:
void setConfigurationMap( const QVariantMap& );
Calamares::JobList createJobs();
- /** @brief Human-readable status for language and LC
- *
- * For the current locale config, return two strings describing
- * the settings for language and numbers.
- */
- std::pair< QString, QString > prettyLocaleStatus() const;
- /** @brief Human-readable zone, language and LC status
- *
- * Concatenates all three strings with
- */
- QString prettyStatus() const;
+ // Underlying data for the models
+ const CalamaresUtils::Locale::CStringPairList& timezoneData() const;
+ /** @brief The currently selected location (timezone)
+ *
+ * The location is a pointer into the date that timezoneData() returns.
+ * It is possible to return nullptr, if no location has been picked yet.
+ */
+ const CalamaresUtils::Locale::TZZone* currentLocation() const { return m_currentLocation; }
+
+ /// locale configuration (LC_* and LANG) based solely on the current location.
+ LocaleConfiguration automaticLocaleConfiguration() const;
+ /// locale configuration that takes explicit settings into account
+ LocaleConfiguration localeConfiguration() const;
+
+ /// The human-readable description of what timezone is used
+ QString currentLocationStatus() const;
+ /// The human-readable description of what language is used
+ QString currentLanguageStatus() const;
+ /// The human-readable description of what locale (LC_*) is used
+ QString currentLCStatus() const;
-public Q_SLOTS:
const QStringList& supportedLocales() const { return m_localeGenLines; }
CalamaresUtils::Locale::CStringListModel* regionModel() const { return m_regionModel.get(); }
CalamaresUtils::Locale::CStringListModel* zonesModel() const { return m_zonesModel.get(); }
- // Underlying data for the models
- const CalamaresUtils::Locale::CStringPairList& timezoneData() const;
+
+public Q_SLOTS:
+ /// Set a language by user-choice, overriding future location changes
+ void setLanguageExplicitly( const QString& language );
+ /// Set LC (formats) by user-choice, overriding future location changes
+ void setLCLocaleExplicitly( const QString& locale );
/** @brief Sets a location by name
*
@@ -82,25 +98,11 @@ public Q_SLOTS:
*/
void setCurrentLocation( const CalamaresUtils::Locale::TZZone* location );
- /** @brief The currently selected location (timezone)
- *
- * The location is a pointer into the date that timezoneData() returns.
- * It is possible to return nullptr, if no location has been picked yet.
- */
- const CalamaresUtils::Locale::TZZone* currentLocation() const { return m_currentLocation; }
-
- /// locale configuration (LC_* and LANG) based solely on the current location.
- LocaleConfiguration automaticLocaleConfiguration() const;
- /// locale configuration that takes explicit settings into account
- LocaleConfiguration localeConfiguration() const;
-
- /// Set a language by user-choice, overriding future location changes
- void setLanguageExplicitly( const QString& language );
- /// Set LC (formats) by user-choice, overriding future location changes
- void setLCLocaleExplicitly( const QString& locale );
-
signals:
- void currentLocationChanged( const CalamaresUtils::Locale::TZZone* location );
+ void currentLocationChanged( const CalamaresUtils::Locale::TZZone* location ) const;
+ void currentLocationStatusChanged( const QString& ) const;
+ void currentLanguageStatusChanged( const QString& ) const;
+ void currentLCStatusChanged( const QString& ) const;
private:
/// A list of supported locale identifiers (e.g. "en_US.UTF-8")
diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp
index fb3433d23..c312f39f6 100644
--- a/src/modules/locale/LocalePage.cpp
+++ b/src/modules/locale/LocalePage.cpp
@@ -106,6 +106,8 @@ LocalePage::LocalePage( Config* config, QWidget* parent )
setMinimumWidth( m_tzWidget->width() );
setLayout( mainLayout );
+ connect( config, &Config::currentLCStatusChanged, m_formatsLabel, &QLabel::setText );
+ connect( config, &Config::currentLanguageStatusChanged, m_localeLabel, &QLabel::setText );
connect( config, &Config::currentLocationChanged, m_tzWidget, &TimeZoneWidget::setCurrentLocation );
connect( config, &Config::currentLocationChanged, this, &LocalePage::locationChanged );
connect( m_tzWidget,
@@ -137,14 +139,11 @@ LocalePage::updateLocaleLabels()
m_zoneLabel->setText( tr( "Zone:" ) );
m_localeChangeButton->setText( tr( "&Change..." ) );
m_formatsChangeButton->setText( tr( "&Change..." ) );
-
- auto labels = m_config->prettyLocaleStatus();
- m_localeLabel->setText( labels.first );
- m_formatsLabel->setText( labels.second );
+ m_localeLabel->setText( m_config->currentLanguageStatus() );
+ m_formatsLabel->setText( m_config->currentLCStatus() );
}
-
void
LocalePage::onActivate()
{
diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp
index 00752ebb6..31f8eb8bd 100644
--- a/src/modules/locale/LocaleViewStep.cpp
+++ b/src/modules/locale/LocaleViewStep.cpp
@@ -104,7 +104,8 @@ LocaleViewStep::prettyName() const
QString
LocaleViewStep::prettyStatus() const
{
- return m_prettyStatus;
+ QStringList l { m_config->currentLocationStatus(), m_config->currentLanguageStatus(), m_config->currentLCStatus() };
+ return l.join( QStringLiteral( "
" ) );
}
@@ -167,7 +168,6 @@ LocaleViewStep::onLeave()
if ( m_actualWidget )
{
m_jobs = m_config->createJobs();
- m_prettyStatus = m_config->prettyStatus();
auto map = m_config->localeConfiguration().toMap();
QVariantMap vm;
diff --git a/src/modules/locale/LocaleViewStep.h b/src/modules/locale/LocaleViewStep.h
index 24764b172..cb1902f2e 100644
--- a/src/modules/locale/LocaleViewStep.h
+++ b/src/modules/locale/LocaleViewStep.h
@@ -70,7 +70,6 @@ private:
LocalePage* m_actualWidget;
bool m_nextEnabled;
- QString m_prettyStatus;
Calamares::JobList m_jobs;