fix translations kcm to be usable on new users/installations
ClosedPublic

Authored by hein on Aug 28 2018, 9:18 AM.

Details

Summary

this broke somewhat recently. the new availabletranslationsmodel's
rowcount is always 0 on a completely fresh system with no language
preference set. this is because the actual available languages list is
only compiled in its ::setSelectedLanguages function. this function was
however never called. this resulted in the kcm thinking there are no
available languages and thus making it impossible to actually add one by
disabling the button and having an empty view even if the button wasn't
disabled.

previously this was a single model, from what I can see, and that was
incorrectly ported. where previously the setSelectedLanguages was only
called on one model we now need to call it on all models to properly
propagate the language information.

(the reason it works this way is because available languages kinda need to
include already selected languages for consistency; even when the kcm
technically didn't find them available)

Test Plan
  • make new user
  • start kcm
  • kcm DOES NOT show infobox 'no languages installed' and the add languages button is enabled
  • clicking the button gives a list of languages
  • adding one works as well

Diff Detail

Repository
R119 Plasma Desktop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sitter created this revision.Aug 28 2018, 9:18 AM
Restricted Application added a project: Plasma. · View Herald TranscriptAug 28 2018, 9:18 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
sitter requested review of this revision.Aug 28 2018, 9:18 AM
hein added a comment.EditedSep 13 2018, 5:01 PM

This makes sense. In theory this is done by this code:

connect(m_selectedTranslationsModel, &SelectedTranslationsModel::selectedLanguagesChanged,
    m_availableTranslationsModel, &AvailableTranslationsModel::setSelectedLanguages);

However SelectedTranslationsModel only emits the signal when the list has changed, and an initial call to setSelectedLanguages with both the member and the parameter being empty doesn't cause an emit.

This means your patch can be simplified though. Only the Translations::load() needs to call AvailableTranslationsModel::setSelectedLanguages to seed things, save and defaults are covered by the signal-slot connection keeping the models in sync.

hein commandeered this revision.Sep 13 2018, 5:02 PM
hein edited reviewers, added: sitter; removed: hein.

I'll commandeer this rev to fix up the patch. Sorry @sitter, but then we can get this into beta still.

hein updated this revision to Diff 41560.Sep 13 2018, 5:04 PM

Simplify patch to only what's actually needed.

davidedmundson accepted this revision.Sep 13 2018, 5:06 PM
This revision is now accepted and ready to land.Sep 13 2018, 5:06 PM
This revision was automatically updated to reflect the committed changes.