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 {
|
PrintJobContextMenuItem
|
||||||
onClicked: {
|
{
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
deleteConfirmationDialog.visible = true;
|
deleteConfirmationDialog.visible = true;
|
||||||
popUp.close();
|
popUp.close();
|
||||||
}
|
}
|
||||||
text: catalog.i18nc("@label", "Delete");
|
text: catalog.i18nc("@label", "Delete");
|
||||||
visible: {
|
visible:
|
||||||
if (!printJob) {
|
{
|
||||||
|
if(!printJob)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(printJob.isMine)
|
||||||
|
{
|
||||||
|
if(!OutputDevice.canWriteOwnPrintJobs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!OutputDevice.canWriteOthersPrintJobs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
var states = ["queued", "error", "sent_to_printer"];
|
var states = ["queued", "error", "sent_to_printer"];
|
||||||
return states.indexOf(printJob.state) !== -1;
|
return states.indexOf(printJob.state) !== -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintJobContextMenuItem {
|
PrintJobContextMenuItem
|
||||||
|
{
|
||||||
enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming");
|
enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming");
|
||||||
onClicked: {
|
onClicked:
|
||||||
if (printJob.state == "paused") {
|
{
|
||||||
|
if (printJob.state == "paused")
|
||||||
|
{
|
||||||
printJob.setState("resume");
|
printJob.setState("resume");
|
||||||
popUp.close();
|
popUp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (printJob.state == "printing") {
|
if (printJob.state == "printing")
|
||||||
|
{
|
||||||
printJob.setState("pause");
|
printJob.setState("pause");
|
||||||
popUp.close();
|
popUp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text: {
|
text:
|
||||||
if (!printJob) {
|
{
|
||||||
|
if(!printJob)
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
switch(printJob.state) {
|
switch(printJob.state)
|
||||||
|
{
|
||||||
case "paused":
|
case "paused":
|
||||||
return catalog.i18nc("@label", "Resume");
|
return catalog.i18nc("@label", "Resume");
|
||||||
case "pausing":
|
case "pausing":
|
||||||
|
@ -106,26 +131,60 @@ Item
|
||||||
catalog.i18nc("@label", "Pause");
|
catalog.i18nc("@label", "Pause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visible: {
|
visible:
|
||||||
if (!printJob) {
|
{
|
||||||
|
if(!printJob)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(printJob.isMine)
|
||||||
|
{
|
||||||
|
if(!OutputDevice.canWriteOwnPrintJobs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!OutputDevice.canWriteOthersPrintJobs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
var states = ["printing", "pausing", "paused", "resuming"];
|
var states = ["printing", "pausing", "paused", "resuming"];
|
||||||
return states.indexOf(printJob.state) !== -1;
|
return states.indexOf(printJob.state) !== -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintJobContextMenuItem {
|
PrintJobContextMenuItem
|
||||||
|
{
|
||||||
enabled: visible && printJob.state !== "aborting";
|
enabled: visible && printJob.state !== "aborting";
|
||||||
onClicked: {
|
onClicked:
|
||||||
|
{
|
||||||
abortConfirmationDialog.visible = true;
|
abortConfirmationDialog.visible = true;
|
||||||
popUp.close();
|
popUp.close();
|
||||||
}
|
}
|
||||||
text: printJob && printJob.state == "aborting" ? catalog.i18nc("@label", "Aborting...") : catalog.i18nc("@label", "Abort");
|
text: printJob && printJob.state == "aborting" ? catalog.i18nc("@label", "Aborting...") : catalog.i18nc("@label", "Abort");
|
||||||
visible: {
|
visible:
|
||||||
if (!printJob) {
|
{
|
||||||
|
if (!printJob)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(printJob.isMine)
|
||||||
|
{
|
||||||
|
if(!OutputDevice.canWriteOwnPrintJobs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!OutputDevice.canWriteOthersPrintJobs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
var states = ["pre_print", "printing", "pausing", "paused", "resuming"];
|
var states = ["pre_print", "printing", "pausing", "paused", "resuming"];
|
||||||
return states.indexOf(printJob.state) !== -1;
|
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
|
Whether this user can change things about print jobs made by other
|
||||||
people.
|
people.
|
||||||
"""
|
"""
|
||||||
return False
|
return True
|
||||||
|
|
||||||
@pyqtProperty(bool, constant = True)
|
@pyqtProperty(bool, constant = True)
|
||||||
def canWriteOwnPrintJobs(self) -> bool:
|
def canWriteOwnPrintJobs(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Whether this user can change things about print jobs made by themself.
|
Whether this user can change things about print jobs made by themself.
|
||||||
"""
|
"""
|
||||||
return False
|
return True
|
||||||
|
|
||||||
@pyqtSlot(name="openPrintJobControlPanel")
|
@pyqtSlot(name="openPrintJobControlPanel")
|
||||||
def openPrintJobControlPanel(self) -> None:
|
def openPrintJobControlPanel(self) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue