mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Digital Library plugin needs to be backwards compatible.
Message-types are a new parameter to Messages, so they can't be used in SDK/API versions smaller than 7.7.0. CURA-8473
This commit is contained in:
parent
8b2904ee3b
commit
5d7804deae
3 changed files with 41 additions and 24 deletions
15
plugins/DigitalLibrary/src/BackwardsCompatibleMessage.py
Normal file
15
plugins/DigitalLibrary/src/BackwardsCompatibleMessage.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Copyright (c) 2021 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Message import Message
|
||||
from UM.Version import Version
|
||||
|
||||
def getBackwardsCompatibleMessage(text: str, title: str, lifetime: int, message_type_str: str) -> Message:
|
||||
if Application.getInstance().getAPIVersion() < Version("7.7.0"):
|
||||
return Message(text=text, title=title, lifetime=lifetime)
|
||||
else:
|
||||
message_type = Message.MessageType.NEUTRAL
|
||||
if message_type in Message.MessageType:
|
||||
message_type = Message.MessageType[message_type_str]
|
||||
return Message(text=text, title=title, lifetime=lifetime, message_type=message_type)
|
Loading…
Add table
Add a link
Reference in a new issue