Browse Source

Add property of the print job being made by the current user

According to the Account API, is this print job made by the same user?
This property is a bit inaccurate, in that this matches by the user name. The user name might be duplicate in some systems.

Contributes to issue CURA-9220.
Ghostkeeper 2 years ago
parent
commit
8871fd6224
1 changed files with 10 additions and 1 deletions
  1. 10 1
      cura/PrinterOutput/Models/PrintJobOutputModel.py

+ 10 - 1
cura/PrinterOutput/Models/PrintJobOutputModel.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2022 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from typing import Optional, TYPE_CHECKING, List
@@ -6,6 +6,8 @@ from typing import Optional, TYPE_CHECKING, List
 from PyQt6.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot, QUrl
 from PyQt6.QtGui import QImage
 
+from cura.CuraApplication import CuraApplication
+
 if TYPE_CHECKING:
     from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
     from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel
@@ -86,6 +88,13 @@ class PrintJobOutputModel(QObject):
             self._owner = owner
             self.ownerChanged.emit()
 
+    @pyqtProperty(bool, notify = ownerChanged)
+    def isMine(self) -> bool:
+        """
+        Returns whether this print job was sent by the currently logged in user.
+        """
+        return self._owner == CuraApplication.getInstance().getCuraAPI().account.userName
+
     @pyqtProperty(QObject, notify=assignedPrinterChanged)
     def assignedPrinter(self):
         return self._assigned_printer