mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 20:28:01 -06:00
Merge branch '4.0' into STAR-322_cloud-connection
This commit is contained in:
commit
0edeb11a78
5 changed files with 34 additions and 14 deletions
|
@ -6,6 +6,7 @@ from typing import Optional, List
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
from UM.Preferences import Preferences
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
@ -18,14 +19,20 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
onItemsChanged = pyqtSignal()
|
onItemsChanged = pyqtSignal()
|
||||||
activePresetChanged = pyqtSignal()
|
activePresetChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, preferences, parent = None):
|
def __init__(self, preferences: Preferences, parent = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self._items = [] # type: List[SettingVisibilityPreset]
|
self._items = [] # type: List[SettingVisibilityPreset]
|
||||||
|
self._custom_preset = SettingVisibilityPreset(preset_id = "custom", name = "Custom selection", weight = -100)
|
||||||
|
|
||||||
self._populate()
|
self._populate()
|
||||||
|
|
||||||
basic_item = self.getVisibilityPresetById("basic")
|
basic_item = self.getVisibilityPresetById("basic")
|
||||||
basic_visibile_settings = ";".join(basic_item.settings)
|
if basic_item is not None:
|
||||||
|
basic_visibile_settings = ";".join(basic_item.settings)
|
||||||
|
else:
|
||||||
|
Logger.log("w", "Unable to find the basic visiblity preset.")
|
||||||
|
basic_visibile_settings = ""
|
||||||
|
|
||||||
self._preferences = preferences
|
self._preferences = preferences
|
||||||
|
|
||||||
|
@ -42,7 +49,8 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
visible_settings = self._preferences.getValue("general/visible_settings")
|
visible_settings = self._preferences.getValue("general/visible_settings")
|
||||||
|
|
||||||
if not visible_settings:
|
if not visible_settings:
|
||||||
self._preferences.setValue("general/visible_settings", ";".join(self._active_preset_item.settings))
|
new_visible_settings = self._active_preset_item.settings if self._active_preset_item is not None else []
|
||||||
|
self._preferences.setValue("general/visible_settings", ";".join(new_visible_settings))
|
||||||
else:
|
else:
|
||||||
self._onPreferencesChanged("general/visible_settings")
|
self._onPreferencesChanged("general/visible_settings")
|
||||||
|
|
||||||
|
@ -59,9 +67,7 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
def _populate(self) -> None:
|
def _populate(self) -> None:
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
items = [] # type: List[SettingVisibilityPreset]
|
items = [] # type: List[SettingVisibilityPreset]
|
||||||
|
items.append(self._custom_preset)
|
||||||
custom_preset = SettingVisibilityPreset(preset_id="custom", name ="Custom selection", weight = -100)
|
|
||||||
items.append(custom_preset)
|
|
||||||
for file_path in Resources.getAllResourcesOfType(CuraApplication.ResourceTypes.SettingVisibilityPreset):
|
for file_path in Resources.getAllResourcesOfType(CuraApplication.ResourceTypes.SettingVisibilityPreset):
|
||||||
setting_visibility_preset = SettingVisibilityPreset()
|
setting_visibility_preset = SettingVisibilityPreset()
|
||||||
try:
|
try:
|
||||||
|
@ -77,7 +83,7 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
self.setItems(items)
|
self.setItems(items)
|
||||||
|
|
||||||
@pyqtProperty("QVariantList", notify = onItemsChanged)
|
@pyqtProperty("QVariantList", notify = onItemsChanged)
|
||||||
def items(self):
|
def items(self) -> List[SettingVisibilityPreset]:
|
||||||
return self._items
|
return self._items
|
||||||
|
|
||||||
def setItems(self, items: List[SettingVisibilityPreset]) -> None:
|
def setItems(self, items: List[SettingVisibilityPreset]) -> None:
|
||||||
|
@ -87,7 +93,7 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def setActivePreset(self, preset_id: str) -> None:
|
def setActivePreset(self, preset_id: str) -> None:
|
||||||
if preset_id == self._active_preset_item.presetId:
|
if self._active_preset_item is not None and preset_id == self._active_preset_item.presetId:
|
||||||
Logger.log("d", "Same setting visibility preset [%s] selected, do nothing.", preset_id)
|
Logger.log("d", "Same setting visibility preset [%s] selected, do nothing.", preset_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -96,7 +102,7 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
Logger.log("w", "Tried to set active preset to unknown id [%s]", preset_id)
|
Logger.log("w", "Tried to set active preset to unknown id [%s]", preset_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
need_to_save_to_custom = self._active_preset_item.presetId == "custom" and preset_id != "custom"
|
need_to_save_to_custom = self._active_preset_item is None or (self._active_preset_item.presetId == "custom" and preset_id != "custom")
|
||||||
if need_to_save_to_custom:
|
if need_to_save_to_custom:
|
||||||
# Save the current visibility settings to custom
|
# Save the current visibility settings to custom
|
||||||
current_visibility_string = self._preferences.getValue("general/visible_settings")
|
current_visibility_string = self._preferences.getValue("general/visible_settings")
|
||||||
|
@ -117,7 +123,9 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
|
|
||||||
@pyqtProperty(str, notify = activePresetChanged)
|
@pyqtProperty(str, notify = activePresetChanged)
|
||||||
def activePreset(self) -> str:
|
def activePreset(self) -> str:
|
||||||
return self._active_preset_item.presetId
|
if self._active_preset_item is not None:
|
||||||
|
return self._active_preset_item.presetId
|
||||||
|
return ""
|
||||||
|
|
||||||
def _onPreferencesChanged(self, name: str) -> None:
|
def _onPreferencesChanged(self, name: str) -> None:
|
||||||
if name != "general/visible_settings":
|
if name != "general/visible_settings":
|
||||||
|
@ -149,7 +157,12 @@ class SettingVisibilityPresetsModel(QObject):
|
||||||
else:
|
else:
|
||||||
item_to_set = matching_preset_item
|
item_to_set = matching_preset_item
|
||||||
|
|
||||||
|
# If we didn't find a matching preset, fallback to custom.
|
||||||
|
if item_to_set is None:
|
||||||
|
item_to_set = self._custom_preset
|
||||||
|
|
||||||
if self._active_preset_item is None or self._active_preset_item.presetId != item_to_set.presetId:
|
if self._active_preset_item is None or self._active_preset_item.presetId != item_to_set.presetId:
|
||||||
self._active_preset_item = item_to_set
|
self._active_preset_item = item_to_set
|
||||||
self._preferences.setValue("cura/active_setting_visibility_preset", self._active_preset_item.presetId)
|
if self._active_preset_item is not None:
|
||||||
|
self._preferences.setValue("cura/active_setting_visibility_preset", self._active_preset_item.presetId)
|
||||||
self.activePresetChanged.emit()
|
self.activePresetChanged.emit()
|
||||||
|
|
|
@ -86,9 +86,11 @@ class AuthorizationService:
|
||||||
if not self.getUserProfile():
|
if not self.getUserProfile():
|
||||||
# We check if we can get the user profile.
|
# We check if we can get the user profile.
|
||||||
# If we can't get it, that means the access token (JWT) was invalid or expired.
|
# If we can't get it, that means the access token (JWT) was invalid or expired.
|
||||||
|
Logger.log("w", "Unable to get the user profile.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self._auth_data is None:
|
if self._auth_data is None:
|
||||||
|
Logger.log("d", "No auth data to retrieve the access_token from")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self._auth_data.access_token
|
return self._auth_data.access_token
|
||||||
|
|
|
@ -300,6 +300,7 @@ class MachineManager(QObject):
|
||||||
self.activeMaterialChanged.emit()
|
self.activeMaterialChanged.emit()
|
||||||
|
|
||||||
self.rootMaterialChanged.emit()
|
self.rootMaterialChanged.emit()
|
||||||
|
self.numberExtrudersEnabledChanged.emit()
|
||||||
|
|
||||||
def _onContainersChanged(self, container: ContainerInterface) -> None:
|
def _onContainersChanged(self, container: ContainerInterface) -> None:
|
||||||
self._instance_container_timer.start()
|
self._instance_container_timer.start()
|
||||||
|
|
|
@ -229,6 +229,7 @@ class CuraEngineBackend(QObject, Backend):
|
||||||
if not self._build_plates_to_be_sliced:
|
if not self._build_plates_to_be_sliced:
|
||||||
self.processingProgress.emit(1.0)
|
self.processingProgress.emit(1.0)
|
||||||
Logger.log("w", "Slice unnecessary, nothing has changed that needs reslicing.")
|
Logger.log("w", "Slice unnecessary, nothing has changed that needs reslicing.")
|
||||||
|
self.setState(BackendState.Done)
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._process_layers_job:
|
if self._process_layers_job:
|
||||||
|
|
|
@ -134,10 +134,13 @@ Column
|
||||||
onPreferenceChanged:
|
onPreferenceChanged:
|
||||||
{
|
{
|
||||||
var autoSlice = UM.Preferences.getValue("general/auto_slice")
|
var autoSlice = UM.Preferences.getValue("general/auto_slice")
|
||||||
prepareButtons.autoSlice = autoSlice
|
if(prepareButtons.autoSlice != autoSlice)
|
||||||
if(autoSlice)
|
|
||||||
{
|
{
|
||||||
CuraApplication.backend.forceSlice()
|
prepareButtons.autoSlice = autoSlice
|
||||||
|
if(autoSlice)
|
||||||
|
{
|
||||||
|
CuraApplication.backend.forceSlice()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue