Merge pull request #2613 from Ultimaker/CURA-4333_Notification_icon_for_recommended_mode

Cura 4333 notification icon for recommended mode
This commit is contained in:
ChrisTerBeke 2017-10-17 13:05:45 +02:00 committed by GitHub
commit 276232dae5
4 changed files with 96 additions and 161 deletions

View File

@ -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
@ -402,7 +404,7 @@ class CuraApplication(QtApplication):
# ALWAYS ask whether to keep or discard the profile
self.showDiscardOrKeepProfileChanges.emit()
sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal()
#sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal()
@pyqtSlot(str)
def discardOrKeepProfileChangesClosed(self, option):
@ -413,10 +415,6 @@ class CuraApplication(QtApplication):
global_stack.getTop().clear()
#event handler for SidebarSimple, which will update sliders view visibility (like:sliders..)
if Preferences.getInstance().getValue("cura/active_mode") == 0:
self.sidebarSimpleDiscardOrKeepProfileChanges.emit()
@pyqtSlot(int)
def messageBoxClosed(self, button):
if self._message_box_callback:
@ -674,7 +672,9 @@ class CuraApplication(QtApplication):
qmlRegisterSingletonType(MachineManager, "Cura", 1, 0, "MachineManager", self.getMachineManager)
qmlRegisterSingletonType(MaterialManager, "Cura", 1, 0, "MaterialManager", self.getMaterialManager)
qmlRegisterSingletonType(SettingInheritanceManager, "Cura", 1, 0, "SettingInheritanceManager",
self.getSettingInheritanceManager)
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"))
@ -714,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:

View File

@ -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,42 +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
@pyqtSlot("QVariantList", result = bool)
def hasUserCustomSettings(self, skip_keys = []) -> bool:
user_setting_keys = []
try:
if not self._global_container_stack:
return False
allContainers = self._global_container_stack.getContainers()
for container in allContainers:
meta = container.getMetaData()
if meta and meta["type"] and 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 = container.getMetaData()
if meta and meta["type"] and 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)
except:
Logger.log("e", "While checking user custom settings occured error. skip_keys: %s", skip_keys )
return False
return len(user_setting_keys) > 0
@pyqtProperty(int, notify = activeStackValueChanged)
def numUserSettings(self) -> int:
if not self._global_container_stack:

View File

@ -0,0 +1,56 @@
# 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()
# These are the settings included in the Simple ("Recommended") Mode, so only when the other settings have been
# changed, we consider it as a user customized profile in the Simple ("Recommended") Mode.
__ignored_custom_setting_keys = ["support_enable",
"infill_sparse_density",
"gradual_infill_steps",
"adhesion_type",
"support_extruder_nr"]

View File

@ -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,40 +20,11 @@ Item
property variant minimumPrintTime: PrintInformation.minimumPrintTime;
property variant maximumPrintTime: PrintInformation.maximumPrintTime;
property bool settingsEnabled: ExtruderManager.activeExtruderStackId || machineExtruderCount.properties.value == 1
property bool hasUserSettings;
Component.onCompleted: PrintInformation.enabled = true
Component.onDestruction: PrintInformation.enabled = false
UM.I18nCatalog { id: catalog; name: "cura" }
onVisibleChanged:
{
if (visible)
{
base.checkUserSettings()
}
}
Connections
{
target: CuraApplication
onSidebarSimpleDiscardOrKeepProfileChanges:
{
base.hasUserSettings = false
}
}
function checkUserSettings(){
var skip_keys = ["support_enable" ,
"infill_sparse_density",
"gradual_infill_steps",
"adhesion_type",
"support_extruder_nr"]
base.hasUserSettings = Cura.MachineManager.hasUserCustomSettings(skip_keys)
}
ScrollView
{
visible: Cura.MachineManager.activeMachineName != "" // If no printers added then the view is invisible
@ -204,7 +175,7 @@ Item
{
anchors.verticalCenter: parent.verticalCenter
anchors.top: parent.top
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height / 2)
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height / 2)
color: (Cura.MachineManager.activeMachine != null && Cura.ProfilesModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
text:
{
@ -223,13 +194,13 @@ Item
// Make sure the text aligns correctly with each tick
if (qualityModel.totalTicks == 0) {
// If there is only one tick, align it centrally
return Math.floor(((base.width * 0.55) - width) / 2)
return parseInt(((base.width * 0.55) - width) / 2)
} else if (index == 0) {
return (base.width * 0.55 / qualityModel.totalTicks) * index
} else if (index == qualityModel.totalTicks) {
return (base.width * 0.55 / qualityModel.totalTicks) * index - width
} else {
return Math.floor((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2))
return parseInt((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2))
}
}
}
@ -289,7 +260,7 @@ Item
id: qualitySlider
height: UM.Theme.getSize("sidebar_margin").height
anchors.bottom: speedSlider.bottom
enabled: qualityModel.availableTotalTicks > 0
enabled: qualityModel.availableTotalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized
visible: qualityModel.totalTicks > 0
updateValueWhileDragging : false
@ -320,7 +291,7 @@ Item
implicitWidth: 10 * screenScaleFactor
implicitHeight: implicitWidth
radius: implicitWidth / 2
visible: !hasUserSettings;
visible: !Cura.SimpleModeSettingsManager.isProfileCustomized;
}
}
}
@ -338,33 +309,6 @@ Item
}
}
}
//If any of settings were changed in custom mode then the Rectangle will
//overlap quality slider area. It is used to catch mouse click
Rectangle {
anchors.verticalCenter: parent.verticalCenter
anchors.right: extrudersModelCheckBox.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
width: qualitySlider.width
height: qualitySlider.height * 1.5
//border.width: UM.Theme.getSize("default_lining").width // dispay overlap zone
//border.color: UM.Theme.getColor("lining")
color: "transparent"
visible: hasUserSettings
enabled: hasUserSettings
MouseArea {
anchors.fill: parent
onClicked: {
discardOrKeepProfileChangesDialog.show()
}
}
}
}
Label
@ -373,13 +317,10 @@ Item
anchors.top: speedSlider.bottom
anchors.left: parent.left
anchors.right: speedSlider.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width
text: catalog.i18nc("@label", "Print Speed")
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
elide: Text.ElideRight
}
Label
@ -408,7 +349,7 @@ Item
{
id: customisedSettings
visible: hasUserSettings
visible: Cura.SimpleModeSettingsManager.isProfileCustomized
height: speedSlider.height * 0.8
width: speedSlider.height * 0.8
@ -445,7 +386,7 @@ Item
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 2
anchors.left: parent.left
width: Math.floor(UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width)
width: parseInt(UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width)
Label
{
@ -455,7 +396,7 @@ Item
color: UM.Theme.getColor("text")
anchors.top: parent.top
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 1.7)
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 1.7)
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
}
@ -466,7 +407,7 @@ Item
id: infillCellRight
height: infillSlider.height + UM.Theme.getSize("sidebar_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("sidebar_margin").height)
width: Math.floor(UM.Theme.getSize("sidebar").width * .55)
width: parseInt(UM.Theme.getSize("sidebar").width * .55)
anchors.left: infillCellLeft.right
anchors.top: infillCellLeft.top
@ -477,10 +418,10 @@ Item
//anchors.top: parent.top
anchors.left: infillSlider.left
anchors.leftMargin: Math.floor((infillSlider.value / infillSlider.stepSize) * (infillSlider.width / (infillSlider.maximumValue / infillSlider.stepSize)) - 10 * screenScaleFactor)
anchors.leftMargin: parseInt((infillSlider.value / infillSlider.stepSize) * (infillSlider.width / (infillSlider.maximumValue / infillSlider.stepSize)) - 10 * screenScaleFactor)
anchors.right: parent.right
text: Math.floor(infillDensity.properties.value) + "%"
text: parseInt(infillDensity.properties.value) + "%"
horizontalAlignment: Text.AlignLeft
color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
@ -490,7 +431,7 @@ Item
Binding {
target: infillSlider
property: "value"
value: Math.floor(infillDensity.properties.value)
value: parseInt(infillDensity.properties.value)
}
Slider
@ -503,7 +444,7 @@ Item
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
height: UM.Theme.getSize("sidebar_margin").height
width: Math.floor(infillCellRight.width - UM.Theme.getSize("sidebar_margin").width - style.handleWidth)
width: parseInt(infillCellRight.width - UM.Theme.getSize("sidebar_margin").width - style.handleWidth)
minimumValue: 0
maximumValue: 100
@ -511,15 +452,15 @@ Item
tickmarksEnabled: true
// disable slider when gradual support is enabled
enabled: Math.floor(infillSteps.properties.value) == 0
enabled: parseInt(infillSteps.properties.value) == 0
// set initial value from stack
value: Math.floor(infillDensity.properties.value)
value: parseInt(infillDensity.properties.value)
onValueChanged: {
// Don't round the value if it's already the same
if (Math.floor(infillDensity.properties.value) == infillSlider.value) {
if (parseInt(infillDensity.properties.value) == infillSlider.value) {
return
}
@ -588,7 +529,7 @@ Item
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height / 2)
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height / 2)
// we loop over all density icons and only show the one that has the current density and steps
Repeater
@ -599,8 +540,8 @@ Item
property int activeIndex: {
for (var i = 0; i < infillModel.count; i++) {
var density = Math.floor(infillDensity.properties.value)
var steps = Math.floor(infillSteps.properties.value)
var density = parseInt(infillDensity.properties.value)
var steps = parseInt(infillSteps.properties.value)
var infillModelItem = infillModel.get(i)
if (density >= infillModelItem.percentageMin
@ -639,13 +580,13 @@ Item
property alias _hovered: enableGradualInfillMouseArea.containsMouse
anchors.top: infillSlider.bottom
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height / 2) // closer to slider since it belongs to the same category
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height / 2) // closer to slider since it belongs to the same category
anchors.left: infillCellRight.left
style: UM.Theme.styles.checkbox
enabled: base.settingsEnabled
visible: infillSteps.properties.enabled == "True"
checked: Math.floor(infillSteps.properties.value) > 0
checked: parseInt(infillSteps.properties.value) > 0
MouseArea {
id: enableGradualInfillMouseArea
@ -654,18 +595,18 @@ Item
hoverEnabled: true
enabled: true
property var previousInfillDensity: Math.floor(infillDensity.properties.value)
property var previousInfillDensity: parseInt(infillDensity.properties.value)
onClicked: {
// Set to 90% only when enabling gradual infill
if (Math.floor(infillSteps.properties.value) == 0) {
previousInfillDensity = Math.floor(infillDensity.properties.value)
if (parseInt(infillSteps.properties.value) == 0) {
previousInfillDensity = parseInt(infillDensity.properties.value)
infillDensity.setPropertyValue("value", String(90))
} else {
infillDensity.setPropertyValue("value", String(previousInfillDensity))
}
infillSteps.setPropertyValue("value", (Math.floor(infillSteps.properties.value) == 0) ? 5 : 0)
infillSteps.setPropertyValue("value", (parseInt(infillSteps.properties.value) == 0) ? 5 : 0)
}
onEntered: {
@ -681,7 +622,7 @@ Item
Label {
id: gradualInfillLabel
anchors.left: enableGradualInfillCheckBox.right
anchors.leftMargin: Math.floor(UM.Theme.getSize("sidebar_margin").width / 2)
anchors.leftMargin: parseInt(UM.Theme.getSize("sidebar_margin").width / 2)
text: catalog.i18nc("@label", "Enable gradual")
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
@ -742,7 +683,7 @@ Item
visible: enableSupportCheckBox.visible
anchors.top: infillCellRight.bottom
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 1.5)
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 1.5)
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
anchors.right: infillCellLeft.right
@ -957,7 +898,7 @@ Item
{
id: tipsCell
anchors.top: adhesionCheckBox.visible ? adhesionCheckBox.bottom : (enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom)
anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 2)
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 2)
anchors.left: parent.left
width: parent.width
height: tipsText.contentHeight * tipsText.lineCount
@ -988,35 +929,6 @@ Item
storeIndex: 0
}
Binding
{
target: infillDensity
property: "containerStackId"
value: {
// not settable per extruder or there only is global, so we must pick global
if (machineExtruderCount.properties.value == 1) {
return Cura.MachineManager.activeStackId
}
// return the ID of the extruder when the infill is limited to an extruder
if (infillInheritStackProvider.properties.limit_to_extruder != null && infillInheritStackProvider.properties.limit_to_extruder >= 0) {
return ExtruderManager.extruderIds[String(infillInheritStackProvider.properties.limit_to_extruder)]
}
// default to the global stack
return Cura.MachineManager.activeStackId
}
}
UM.SettingPropertyProvider
{
id: infillInheritStackProvider
containerStackId: Cura.MachineManager.activeMachineId
key: "infill_sparse_density"
watchedProperties: [ "limit_to_extruder" ]
}
UM.SettingPropertyProvider
{
id: infillDensity