mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
CURA-5164 The Preferences is not a singleton class anymore since in some point
several instances need to be created. - In the ThreeMFWorkspaceReader we need to create some temporal instances of Preferences that makes it not singleton anymore. - The current preferences are kept in the Application class and so all the calls to the preferences are changed to get the preferences from Application. - The method getInstance in Preferences is kept as deprecated since some external plugins.
This commit is contained in:
parent
42ecb12614
commit
43657010ba
22 changed files with 102 additions and 119 deletions
|
@ -5,8 +5,7 @@ from PyQt5.QtCore import QUrl
|
|||
from PyQt5.QtGui import QDesktopServices
|
||||
|
||||
from UM.Extension import Extension
|
||||
from UM.Preferences import Preferences
|
||||
from UM.Logger import Logger
|
||||
from UM.Application import Application
|
||||
from UM.i18n import i18nCatalog
|
||||
from cura.Settings.GlobalStack import GlobalStack
|
||||
|
||||
|
@ -27,12 +26,12 @@ class FirmwareUpdateChecker(Extension):
|
|||
|
||||
# Initialize the Preference called `latest_checked_firmware` that stores the last version
|
||||
# checked for the UM3. In the future if we need to check other printers' firmware
|
||||
Preferences.getInstance().addPreference("info/latest_checked_firmware", "")
|
||||
Application.getInstance().getPreferences().addPreference("info/latest_checked_firmware", "")
|
||||
|
||||
# Listen to a Signal that indicates a change in the list of printers, just if the user has enabled the
|
||||
# 'check for updates' option
|
||||
Preferences.getInstance().addPreference("info/automatic_update_check", True)
|
||||
if Preferences.getInstance().getValue("info/automatic_update_check"):
|
||||
Application.getInstance().getPreferences().addPreference("info/automatic_update_check", True)
|
||||
if Application.getInstance().getPreferences().getValue("info/automatic_update_check"):
|
||||
ContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
||||
|
||||
self._download_url = None
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from UM.Preferences import Preferences
|
||||
from UM.Application import Application
|
||||
from UM.Message import Message
|
||||
from UM.Logger import Logger
|
||||
|
@ -51,11 +50,11 @@ class FirmwareUpdateCheckerJob(Job):
|
|||
current_version = reader(current_version_file).readline().rstrip()
|
||||
|
||||
# If it is the first time the version is checked, the checked_version is ''
|
||||
checked_version = Preferences.getInstance().getValue("info/latest_checked_firmware")
|
||||
checked_version = Application.getInstance().getPreferences().getValue("info/latest_checked_firmware")
|
||||
|
||||
# If the checked_version is '', it's because is the first time we check firmware and in this case
|
||||
# we will not show the notification, but we will store it for the next time
|
||||
Preferences.getInstance().setValue("info/latest_checked_firmware", current_version)
|
||||
Application.getInstance().getPreferences().setValue("info/latest_checked_firmware", current_version)
|
||||
Logger.log("i", "Reading firmware version of %s: checked = %s - latest = %s", machine_name, checked_version, current_version)
|
||||
|
||||
# The first time we want to store the current version, the notification will not be shown,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue