From 9abffee92c32bda2041c824aeb4b317a80d15b79 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 16 Mar 2020 01:18:14 +0100 Subject: [PATCH] Persist language choice in the preferences So now there's just no field for it in the preferences article. Later, maybe. It's easy enough to switch anyway. --- CuraSettingsGuide.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CuraSettingsGuide.py b/CuraSettingsGuide.py index 09e2b8ec3..db9987f48 100644 --- a/CuraSettingsGuide.py +++ b/CuraSettingsGuide.py @@ -65,7 +65,6 @@ 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", @@ -73,6 +72,7 @@ def __init__(self, parent=None) -> None: "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() @@ -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]: @@ -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() \ No newline at end of file