Merge pull request #5762 from Ultimaker/CL-1259_hide_useless_override_button

CL-1259 hide useless override button
This commit is contained in:
Ian Paschal 2019-05-20 15:47:26 +02:00 committed by GitHub
commit 0dc49a66f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View file

@ -32,18 +32,23 @@ UM.Dialog
}
visible:
{
// Don't show the button if we're missing a printer or print job
if (!printer || !printer.activePrintJob)
{
return true
return false
}
var canOverride = false
// Check each required change...
for (var i = 0; i < printer.activePrintJob.configurationChanges.length; i++)
{
var change = printer.activePrintJob.configurationChanges[i]
canOverride = canOverride || change.typeOfChange === "material_change";
// If that type of change is in the list of blocking changes, hide the button
if (!change.canOverride)
{
return false
}
return canOverride
}
return true
}
},
Button

View file

@ -3,11 +3,16 @@
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot
BLOCKING_CHANGE_TYPES = [
"material_insert", "buildplate_change"
]
class ConfigurationChangeModel(QObject):
def __init__(self, type_of_change: str, index: int, target_name: str, origin_name: str) -> None:
super().__init__()
self._type_of_change = type_of_change
# enum = ["material", "print_core_change"]
self._can_override = self._type_of_change not in BLOCKING_CHANGE_TYPES
self._index = index
self._target_name = target_name
self._origin_name = origin_name
@ -27,3 +32,7 @@ class ConfigurationChangeModel(QObject):
@pyqtProperty(str, constant = True)
def originName(self) -> str:
return self._origin_name
@pyqtProperty(bool, constant = True)
def canOverride(self) -> bool:
return self._can_override