[welcome] Lookup GeoIP language and pass to language widget

- FIXES #934
 - Whether this is really wanted depends on the distro, and I'm not
   100% convinced the likely tags from Unicode are correct (or it'd
   take a lot more data). In any case, starting Calamares in "NL"
   gets me "nl_NL" as translation; presumably starting it in "BE"
   will get me that as well (what about Les Wallons?)
 - This also shows off that it's a real hack to have so much program
   logic in the *widget* parts of each ViewStep. Longer-term,
   a lot of functionality should go to the ViewStep itself, which
   will then control the UI.
This commit is contained in:
Adriaan de Groot 2019-05-10 15:02:12 -04:00
parent 03f88b3ed6
commit f18f9dcd14
3 changed files with 18 additions and 2 deletions

View File

@ -257,11 +257,19 @@ WelcomePage::focusInEvent( QFocusEvent* e )
e->accept();
}
bool WelcomePage::verdict() const
bool
WelcomePage::verdict() const
{
return m_checkingWidget->verdict();
}
void
WelcomePage::externallySelectedLanguage( int row )
{
if ( ( row >= 0 ) && ( row < ui->languageWidget->count() ) )
ui->languageWidget->setCurrentIndex( row );
}
void
LocaleTwoColumnDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const

View File

@ -46,6 +46,8 @@ public:
/// @brief Results of requirements checking
bool verdict() const;
/// @brief Change the language from an external source.
void externallySelectedLanguage( int row );
protected:
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus

View File

@ -161,5 +161,11 @@ WelcomeViewStep::setCountry( const QString& countryCode )
return;
}
else
cDebug() << "Would like to select" << c_l;
{
int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode );
if ( r < 0 )
cDebug() << "Unusable country code" << countryCode << "(no suitable translation)";
if ( ( r >= 0 ) && m_widget )
m_widget->externallySelectedLanguage( r );
}
}