mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[locale] Move status strings from Page to Config
- the config knows the status and how to describe it, fetch the strings from there.
This commit is contained in:
parent
855b21a7db
commit
ef08ff6ac0
5 changed files with 43 additions and 34 deletions
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include "SetTimezoneJob.h"
|
#include "SetTimezoneJob.h"
|
||||||
|
|
||||||
|
#include "locale/Label.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
|
@ -245,6 +246,33 @@ Config::setLCLocaleExplicitly( const QString& locale )
|
||||||
m_selectedLocaleConfiguration.explicit_lc = true;
|
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() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
Config::prettyStatus() const
|
||||||
|
{
|
||||||
|
QString br( QStringLiteral("<br/>"));
|
||||||
|
QString status;
|
||||||
|
status += tr( "Set timezone to %1/%2." ).arg( m_currentLocation->region(), m_currentLocation->zone() ) + br;
|
||||||
|
|
||||||
|
auto labels = prettyLocaleStatus();
|
||||||
|
status += labels.first + br;
|
||||||
|
status += labels.second + br;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
|
|
|
@ -47,6 +47,19 @@ public:
|
||||||
void setConfigurationMap( const QVariantMap& );
|
void setConfigurationMap( const QVariantMap& );
|
||||||
Calamares::JobList createJobs();
|
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 <br/>
|
||||||
|
*/
|
||||||
|
QString prettyStatus() const;
|
||||||
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
const QStringList& supportedLocales() const { return m_localeGenLines; }
|
const QStringList& supportedLocales() const { return m_localeGenLines; }
|
||||||
CalamaresUtils::Locale::CStringListModel* regionModel() const { return m_regionModel.get(); }
|
CalamaresUtils::Locale::CStringListModel* regionModel() const { return m_regionModel.get(); }
|
||||||
|
|
|
@ -138,38 +138,12 @@ LocalePage::updateLocaleLabels()
|
||||||
m_localeChangeButton->setText( tr( "&Change..." ) );
|
m_localeChangeButton->setText( tr( "&Change..." ) );
|
||||||
m_formatsChangeButton->setText( tr( "&Change..." ) );
|
m_formatsChangeButton->setText( tr( "&Change..." ) );
|
||||||
|
|
||||||
LocaleConfiguration lc = m_config->localeConfiguration();
|
auto labels = m_config->prettyLocaleStatus();
|
||||||
auto labels = prettyLocaleStatus( lc );
|
|
||||||
m_localeLabel->setText( labels.first );
|
m_localeLabel->setText( labels.first );
|
||||||
m_formatsLabel->setText( labels.second );
|
m_formatsLabel->setText( labels.second );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair< QString, QString >
|
|
||||||
LocalePage::prettyLocaleStatus( const LocaleConfiguration& lc ) const
|
|
||||||
{
|
|
||||||
using CalamaresUtils::Locale::Label;
|
|
||||||
|
|
||||||
Label lang( lc.language(), Label::LabelFormat::AlwaysWithCountry );
|
|
||||||
Label num( lc.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() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
QString
|
|
||||||
LocalePage::prettyStatus() const
|
|
||||||
{
|
|
||||||
QString status;
|
|
||||||
status += tr( "Set timezone to %1/%2.<br/>" ).arg( m_regionCombo->currentText() ).arg( m_zoneCombo->currentText() );
|
|
||||||
|
|
||||||
LocaleConfiguration lc = m_config->localeConfiguration();
|
|
||||||
auto labels = prettyLocaleStatus( lc );
|
|
||||||
status += labels.first + "<br/>";
|
|
||||||
status += labels.second + "<br/>";
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalePage::onActivate()
|
LocalePage::onActivate()
|
||||||
|
|
|
@ -43,18 +43,12 @@ public:
|
||||||
explicit LocalePage( class Config* config, QWidget* parent = nullptr );
|
explicit LocalePage( class Config* config, QWidget* parent = nullptr );
|
||||||
virtual ~LocalePage();
|
virtual ~LocalePage();
|
||||||
|
|
||||||
QString prettyStatus() const;
|
|
||||||
|
|
||||||
void onActivate();
|
void onActivate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief Non-owning pointer to the ViewStep's config
|
/// @brief Non-owning pointer to the ViewStep's config
|
||||||
Config* m_config;
|
Config* m_config;
|
||||||
|
|
||||||
// For the given locale config, return two strings describing
|
|
||||||
// the settings for language and numbers.
|
|
||||||
std::pair< QString, QString > prettyLocaleStatus( const LocaleConfiguration& ) const;
|
|
||||||
|
|
||||||
/** @brief Update the GS *locale* key with the selected system language.
|
/** @brief Update the GS *locale* key with the selected system language.
|
||||||
*
|
*
|
||||||
* This uses whatever is set in m_selectedLocaleConfiguration as the language,
|
* This uses whatever is set in m_selectedLocaleConfiguration as the language,
|
||||||
|
|
|
@ -167,7 +167,7 @@ LocaleViewStep::onLeave()
|
||||||
if ( m_actualWidget )
|
if ( m_actualWidget )
|
||||||
{
|
{
|
||||||
m_jobs = m_config->createJobs();
|
m_jobs = m_config->createJobs();
|
||||||
m_prettyStatus = m_actualWidget->prettyStatus();
|
m_prettyStatus = m_config->prettyStatus();
|
||||||
|
|
||||||
auto map = m_config->localeConfiguration().toMap();
|
auto map = m_config->localeConfiguration().toMap();
|
||||||
QVariantMap vm;
|
QVariantMap vm;
|
||||||
|
|
Loading…
Add table
Reference in a new issue