mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Check permissions before showing abort/pause/delete context buttons
The user needs permissions to do these things, so don't show them if the user can't use them. Contributes to issue CURA-9220.
This commit is contained in:
parent
8871fd6224
commit
5eb340e3f0
2 changed files with 78 additions and 19 deletions
|
@ -62,40 +62,65 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
PrintJobContextMenuItem {
|
||||
onClicked: {
|
||||
PrintJobContextMenuItem
|
||||
{
|
||||
onClicked:
|
||||
{
|
||||
deleteConfirmationDialog.visible = true;
|
||||
popUp.close();
|
||||
}
|
||||
text: catalog.i18nc("@label", "Delete");
|
||||
visible: {
|
||||
if (!printJob) {
|
||||
visible:
|
||||
{
|
||||
if(!printJob)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(printJob.isMine)
|
||||
{
|
||||
if(!OutputDevice.canWriteOwnPrintJobs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!OutputDevice.canWriteOthersPrintJobs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var states = ["queued", "error", "sent_to_printer"];
|
||||
return states.indexOf(printJob.state) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
PrintJobContextMenuItem {
|
||||
PrintJobContextMenuItem
|
||||
{
|
||||
enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming");
|
||||
onClicked: {
|
||||
if (printJob.state == "paused") {
|
||||
onClicked:
|
||||
{
|
||||
if (printJob.state == "paused")
|
||||
{
|
||||
printJob.setState("resume");
|
||||
popUp.close();
|
||||
return;
|
||||
}
|
||||
if (printJob.state == "printing") {
|
||||
if (printJob.state == "printing")
|
||||
{
|
||||
printJob.setState("pause");
|
||||
popUp.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
text: {
|
||||
if (!printJob) {
|
||||
text:
|
||||
{
|
||||
if(!printJob)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
switch(printJob.state) {
|
||||
switch(printJob.state)
|
||||
{
|
||||
case "paused":
|
||||
return catalog.i18nc("@label", "Resume");
|
||||
case "pausing":
|
||||
|
@ -106,26 +131,60 @@ Item
|
|||
catalog.i18nc("@label", "Pause");
|
||||
}
|
||||
}
|
||||
visible: {
|
||||
if (!printJob) {
|
||||
visible:
|
||||
{
|
||||
if(!printJob)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(printJob.isMine)
|
||||
{
|
||||
if(!OutputDevice.canWriteOwnPrintJobs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!OutputDevice.canWriteOthersPrintJobs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var states = ["printing", "pausing", "paused", "resuming"];
|
||||
return states.indexOf(printJob.state) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
PrintJobContextMenuItem {
|
||||
PrintJobContextMenuItem
|
||||
{
|
||||
enabled: visible && printJob.state !== "aborting";
|
||||
onClicked: {
|
||||
onClicked:
|
||||
{
|
||||
abortConfirmationDialog.visible = true;
|
||||
popUp.close();
|
||||
}
|
||||
text: printJob && printJob.state == "aborting" ? catalog.i18nc("@label", "Aborting...") : catalog.i18nc("@label", "Abort");
|
||||
visible: {
|
||||
if (!printJob) {
|
||||
visible:
|
||||
{
|
||||
if (!printJob)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(printJob.isMine)
|
||||
{
|
||||
if(!OutputDevice.canWriteOwnPrintJobs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!OutputDevice.canWriteOthersPrintJobs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var states = ["pre_print", "printing", "pausing", "paused", "resuming"];
|
||||
return states.indexOf(printJob.state) !== -1;
|
||||
}
|
||||
|
|
|
@ -204,14 +204,14 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
|||
Whether this user can change things about print jobs made by other
|
||||
people.
|
||||
"""
|
||||
return False
|
||||
return True
|
||||
|
||||
@pyqtProperty(bool, constant = True)
|
||||
def canWriteOwnPrintJobs(self) -> bool:
|
||||
"""
|
||||
Whether this user can change things about print jobs made by themself.
|
||||
"""
|
||||
return False
|
||||
return True
|
||||
|
||||
@pyqtSlot(name="openPrintJobControlPanel")
|
||||
def openPrintJobControlPanel(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue