Make ConnectionType Enum type accessible to QML

CURA-6011
This commit is contained in:
Lipu Fei 2018-12-14 11:28:18 +01:00
parent a1ad7851d9
commit 4252b95603
3 changed files with 18 additions and 2 deletions

View file

@ -4,7 +4,7 @@
from UM.Decorators import deprecated
from UM.i18n import i18nCatalog
from UM.OutputDevice.OutputDevice import OutputDevice
from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject, QTimer, QUrl
from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject, QTimer, QUrl, Q_ENUMS
from PyQt5.QtWidgets import QMessageBox
from UM.Logger import Logger
@ -54,6 +54,12 @@ class ConnectionType(IntEnum):
# For all other uses it should be used in the same way as a "regular" OutputDevice.
@signalemitter
class PrinterOutputDevice(QObject, OutputDevice):
# Put ConnectionType here with Q_ENUMS() so it can be registered as a QML type and accessible via QML, and there is
# no need to remember what those Enum integer values mean.
ConnectionType = ConnectionType
Q_ENUMS(ConnectionType)
printersChanged = pyqtSignal()
connectionStateChanged = pyqtSignal(str)
acceptsCommandsChanged = pyqtSignal()