Skip to content

Commit

Permalink
Persist language choice in the preferences
Browse files Browse the repository at this point in the history
So now there's just no field for it in the preferences article. Later, maybe. It's easy enough to switch anyway.
  • Loading branch information
Ghostkeeper committed Mar 16, 2020
1 parent 700d32f commit 9abffee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CuraSettingsGuide.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ def __init__(self, parent=None) -> None:

# Add context menu item to the settings list to open the guide for that setting.
application = CuraApplication.getInstance()
self._selected_language = application.getPreferences().getValue("general/language")
application.getCuraAPI().interface.settings.addContextMenuItem({
"name": "Settings Guide",
"icon_name": "help-contents",
"actions": ["sidebarMenuItemOnClickHandler"],
"menu_item": MenuItemHandler.MenuItemHandler(self)
})

application.getPreferences().addPreference("settings_guide/language", "cura_default")
application.getPreferences().addPreference("settings_guide/show+articles+in+setting+tooltips+%28requires+restart%29", False)

self.adjust_theme()
Expand Down Expand Up @@ -395,7 +395,11 @@ def selectedArticle(self) -> List[List[str]]:
items, some of which are text and some of which are image lists.
:return: The the currently selected article.
"""
return self._getArticle(self._selected_article_id, self._selected_language)
preferences = CuraApplication.getInstance().getPreferences()
language = preferences.getValue("settings_guide/language")
if language == "cura_default":
language = preferences.getValue("general/language")
return self._getArticle(self._selected_article_id, language)

@pyqtSlot(str, result="QVariantList")
def language_list(self, article_key: str) -> List[str]:
Expand All @@ -414,5 +418,5 @@ def set_language(self, language_code: str) -> None:
Changes the viewing language.
:param language_code: The new language code.
"""
self._selected_language = language_code
CuraApplication.getInstance().getPreferences().setValue("settings_guide/language", language_code)
self.selectedArticleChanged.emit()

0 comments on commit 9abffee

Please sign in to comment.