mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 10:17:52 -06:00
Move simple-mode settings customization check into a separate file
CURA-4333 Simple-mode is a special mode so it makes more sense to put those code in a separate file instead of in the more generic MachineManager.
This commit is contained in:
parent
e1234a09aa
commit
9b8dc9bf55
4 changed files with 68 additions and 46 deletions
|
@ -51,6 +51,7 @@ from cura.Settings.MaterialsModel import MaterialsModel
|
|||
from cura.Settings.QualityAndUserProfilesModel import QualityAndUserProfilesModel
|
||||
from cura.Settings.SettingInheritanceManager import SettingInheritanceManager
|
||||
from cura.Settings.UserProfilesModel import UserProfilesModel
|
||||
from cura.Settings.SimpleModeSettingsManager import SimpleModeSettingsManager
|
||||
|
||||
from . import PlatformPhysics
|
||||
from . import BuildVolume
|
||||
|
@ -201,6 +202,7 @@ class CuraApplication(QtApplication):
|
|||
self._machine_manager = None # This is initialized on demand.
|
||||
self._material_manager = None
|
||||
self._setting_inheritance_manager = None
|
||||
self._simple_mode_settings_manager = None
|
||||
|
||||
self._additional_components = {} # Components to add to certain areas in the interface
|
||||
|
||||
|
@ -671,6 +673,8 @@ class CuraApplication(QtApplication):
|
|||
qmlRegisterSingletonType(MaterialManager, "Cura", 1, 0, "MaterialManager", self.getMaterialManager)
|
||||
qmlRegisterSingletonType(SettingInheritanceManager, "Cura", 1, 0, "SettingInheritanceManager",
|
||||
self.getSettingInheritanceManager)
|
||||
qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 2, "SimpleModeSettingsManager",
|
||||
self.getSimpleModeSettingsManager)
|
||||
|
||||
qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager)
|
||||
self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml"))
|
||||
|
@ -710,6 +714,11 @@ class CuraApplication(QtApplication):
|
|||
def getMachineActionManager(self, *args):
|
||||
return self._machine_action_manager
|
||||
|
||||
def getSimpleModeSettingsManager(self, *args):
|
||||
if self._simple_mode_settings_manager is None:
|
||||
self._simple_mode_settings_manager = SimpleModeSettingsManager()
|
||||
return self._simple_mode_settings_manager
|
||||
|
||||
## Handle Qt events
|
||||
def event(self, event):
|
||||
if event.type() == QEvent.FileOpen:
|
||||
|
|
|
@ -39,8 +39,6 @@ if TYPE_CHECKING:
|
|||
from cura.Settings.CuraContainerStack import CuraContainerStack
|
||||
from cura.Settings.GlobalStack import GlobalStack
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class MachineManager(QObject):
|
||||
def __init__(self, parent = None):
|
||||
|
@ -413,45 +411,6 @@ class MachineManager(QObject):
|
|||
|
||||
return False
|
||||
|
||||
## Check whether user containers have adjusted settings or not
|
||||
# \param skip_keys \type{list} List of setting keys which will be not taken into account ("support_enable" , "infill_sparse_density"...)
|
||||
# \return \type{boole} Return true if user containers have any of adjusted settings
|
||||
def hasUserCustomSettings(self, skip_keys = {}) -> bool:
|
||||
|
||||
user_setting_keys = []
|
||||
|
||||
if not self._global_container_stack:
|
||||
return False
|
||||
|
||||
allContainers = self._global_container_stack.getContainers()
|
||||
|
||||
for container in allContainers:
|
||||
meta_type = container.getMetaDataEntry("type", None)
|
||||
if meta_type == "user":
|
||||
user_setting_keys.extend(container.getAllKeys())
|
||||
|
||||
stacks = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()))
|
||||
for stack in stacks:
|
||||
|
||||
for container in stack.getContainers():
|
||||
meta_type = container.getMetaDataEntry("type", None)
|
||||
if meta_type == "user":
|
||||
user_setting_keys.extend(container.getAllKeys())
|
||||
|
||||
for skip_key in skip_keys:
|
||||
if skip_key in user_setting_keys:
|
||||
user_setting_keys.remove(skip_key)
|
||||
|
||||
return len(user_setting_keys) > 0
|
||||
|
||||
# These setting keys are used in SettingSimple.qml. They used to validate whether show notification(reset) icon or not
|
||||
# If a changed setting is in the ignore list then this setting should be skipped and the notification not shown
|
||||
ignore_list = ["support_enable", "infill_sparse_density", "gradual_infill_steps", "adhesion_type", "support_extruder_nr"]
|
||||
|
||||
@pyqtProperty(bool, notify = activeStackValueChanged)
|
||||
def allActiveUserSettings(self):
|
||||
return self.hasUserCustomSettings(skip_keys = self.ignore_list)
|
||||
|
||||
@pyqtProperty(int, notify = activeStackValueChanged)
|
||||
def numUserSettings(self) -> int:
|
||||
if not self._global_container_stack:
|
||||
|
|
55
cura/Settings/SimpleModeSettingsManager.py
Normal file
55
cura/Settings/SimpleModeSettingsManager.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty
|
||||
|
||||
from UM.Application import Application
|
||||
|
||||
|
||||
class SimpleModeSettingsManager(QObject):
|
||||
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
||||
self._machine_manager = Application.getInstance().getMachineManager()
|
||||
self._is_profile_customized = False
|
||||
|
||||
self._machine_manager.activeStackValueChanged.connect(self._updateIsProfileCustomized)
|
||||
|
||||
isProfileCustomizedChanged = pyqtSignal()
|
||||
|
||||
@pyqtProperty(bool, notify = isProfileCustomizedChanged)
|
||||
def isProfileCustomized(self):
|
||||
return self._is_profile_customized
|
||||
|
||||
def _updateIsProfileCustomized(self):
|
||||
user_setting_keys = set()
|
||||
|
||||
if not self._machine_manager.activeMachine:
|
||||
return False
|
||||
|
||||
global_stack = self._machine_manager.activeMachine
|
||||
|
||||
# check user settings in the global stack
|
||||
user_setting_keys.update(set(global_stack.userChanges.getAllKeys()))
|
||||
# check user settings in the extruder stacks
|
||||
if global_stack.extruders:
|
||||
for extruder_stack in global_stack.extruders.values():
|
||||
user_setting_keys.update(set(extruder_stack.userChanges.getAllKeys()))
|
||||
|
||||
for skip_key in self.__ignored_custom_setting_keys:
|
||||
if skip_key in user_setting_keys:
|
||||
user_setting_keys.remove(skip_key)
|
||||
|
||||
has_customized_user_settings = len(user_setting_keys) > 0
|
||||
|
||||
if has_customized_user_settings != self._is_profile_customized:
|
||||
self._is_profile_customized = has_customized_user_settings
|
||||
self.isProfileCustomizedChanged.emit()
|
||||
|
||||
# A list of settings that will be ignored when check whether there is any custom settings.
|
||||
__ignored_custom_setting_keys = ["support_enable",
|
||||
"infill_sparse_density",
|
||||
"gradual_infill_steps",
|
||||
"adhesion_type",
|
||||
"support_extruder_nr"]
|
|
@ -7,7 +7,7 @@ import QtQuick.Controls.Styles 1.1
|
|||
import QtQuick.Layouts 1.1
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
import Cura 1.2 as Cura
|
||||
|
||||
Item
|
||||
{
|
||||
|
@ -20,7 +20,6 @@ Item
|
|||
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
|
||||
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
|
||||
property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
|
||||
property bool hasUserSettings: Cura.MachineManager.allActiveUserSettings
|
||||
|
||||
Component.onCompleted: PrintInformation.enabled = true
|
||||
Component.onDestruction: PrintInformation.enabled = false
|
||||
|
@ -292,7 +291,7 @@ Item
|
|||
implicitWidth: 10 * screenScaleFactor
|
||||
implicitHeight: implicitWidth
|
||||
radius: implicitWidth / 2
|
||||
visible: !hasUserSettings;
|
||||
visible: !Cura.SimpleModeSettingsManager.isProfileCustomized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +349,7 @@ Item
|
|||
{
|
||||
id: customisedSettings
|
||||
|
||||
visible: hasUserSettings
|
||||
visible: Cura.SimpleModeSettingsManager.isProfileCustomized
|
||||
height: speedSlider.height * 0.8
|
||||
width: speedSlider.height * 0.8
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue