[keyboard] Move responsibility for retranslation to Config

- only widgets get language change events, so we need to
  hook that up to the ViewSteps and inform the Config
  object so that it can (re)load translations for the
  keyboard data.
This commit is contained in:
Adriaan de Groot 2020-10-31 20:02:21 +01:00
parent 89a180ee58
commit 4387b8061e
5 changed files with 26 additions and 5 deletions

View File

@ -560,3 +560,8 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
m_writeEtcDefaultKeyboard = true;
}
}
void
Config::retranslate()
{
}

View File

@ -58,6 +58,17 @@ public:
*/
KeyboardVariantsModel* keyboardVariants() const;
/** @brief Call this to change application language
*
* The models (for keyboard model, layouts and variants) provide
* translations of strings in the xkb table, so need to be
* notified of language changes as well.
*
* Only widgets get LanguageChange events, so one of them will
* need to call this.
*/
void retranslate();
signals:
void prettyStatusChanged();

View File

@ -123,10 +123,6 @@ KeyboardModelsModel::KeyboardModelsModel( QObject* parent )
}
cDebug() << "Loaded" << m_list.count() << "keyboard models";
CALAMARES_RETRANSLATE( if ( !s_kbtranslator ) { s_kbtranslator = new QTranslator; } cqDeleter<QTranslator> d { s_kbtranslator };
d.preserve
= CalamaresUtils::loadTranslator( QLocale(), QStringLiteral( "kb_" ), s_kbtranslator ); )
}

View File

@ -95,10 +95,17 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
connect( config->keyboardVariants(), &KeyboardVariantsModel::currentIndexChanged, [this]( int index ) {
ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) );
} );
CALAMARES_RETRANSLATE( ui->retranslateUi( this ); )
CALAMARES_RETRANSLATE_SLOT( &KeyboardPage::retranslate )
}
KeyboardPage::~KeyboardPage()
{
delete ui;
}
void
KeyboardPage::retranslate()
{
ui->retranslateUi( this );
m_config->retranslate();
}

View File

@ -37,6 +37,8 @@ public:
explicit KeyboardPage( Config* config, QWidget* parent = nullptr );
~KeyboardPage() override;
void retranslate();
private:
Ui::Page_Keyboard* ui;
KeyBoardPreview* m_keyboardPreview;