Correctly load material favorites from preferences

Contributes to CURA-5378, CURA-5162
This commit is contained in:
Ian Paschal 2018-08-22 12:31:48 +02:00
parent 6d1fd8281c
commit 08b325ee04
2 changed files with 4 additions and 11 deletions

View file

@ -501,7 +501,7 @@ class CuraApplication(QtApplication):
preferences.addPreference("view/filter_current_build_plate", False)
preferences.addPreference("cura/sidebar_collapsed", False)
preferences.addPreference("cura/favorite_materials", [])
preferences.addPreference("cura/favorite_materials", ";".join([]))
self._need_to_show_user_agreement = not preferences.getValue("general/accepted_user_agreement")

View file

@ -199,11 +199,8 @@ class MaterialManager(QObject):
self.materialsUpdated.emit()
favorites = self._application.getPreferences().getValue("cura/favorite_materials")
print(favorites)
for item in favorites:
print(item)
for item in favorites.split(";"):
self._favorites.add(item)
print("LOADED FAVES", self._favorites)
self.favoritesUpdated.emit()
def __addMaterialMetadataIntoLookupTree(self, material_metadata: dict) -> None:
@ -623,24 +620,20 @@ class MaterialManager(QObject):
@pyqtSlot(str)
def addFavorite(self, root_material_id: str):
print(root_material_id)
self._favorites.add(root_material_id)
self.favoritesUpdated.emit()
print(self._favorites)
print(list(self._favorites))
# Ensure all settings are saved.
self._application.getPreferences().setValue("cura/favorite_materials", list(self._favorites))
self._application.getPreferences().setValue("cura/favorite_materials", ";".join(list(self._favorites)))
self._application.saveSettings()
@pyqtSlot(str)
def removeFavorite(self, root_material_id: str):
self._favorites.remove(root_material_id)
self.favoritesUpdated.emit()
print(self._favorites)
# Ensure all settings are saved.
self._application.getPreferences().setValue("cura/favorite_materials", list(self._favorites))
self._application.getPreferences().setValue("cura/favorite_materials", ";".join(list(self._favorites)))
self._application.saveSettings()
@pyqtSlot()