Skip to content

Commit

Permalink
Properly update message progress in the model if the message changes
Browse files Browse the repository at this point in the history
Contributes to Asana issue 38547857084327
  • Loading branch information
awhiemstra committed Jun 24, 2015
1 parent 03576ef commit 3660ca0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions UM/Message.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, text = "", lifetime = 10, dismissable = True, progress = None
self._visible = False
self._text = text
self._progress = progress
self._max_progress = 0
self._max_progress = 100
self._lifetime = lifetime
self._lifetime_timer = None
self._dismissable = dismissable # Can the message be closed by user?
Expand Down Expand Up @@ -63,7 +63,7 @@ def getMaxProgress(self):

def setProgress(self, progress):
self._progress = progress
self.progressChanged.emit()
self.progressChanged.emit(self)

progressChanged = Signal()

Expand Down
5 changes: 5 additions & 0 deletions UM/Qt/Bindings/VisibleMessagesModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def addMessage(self, message):
"actions":self.createActionsModel(message.getActions()),
"dismissable": message.isDismissable()
})
message.progressChanged.connect(self._onMessageProgress)

def createActionsModel(self, actions):
model = ListModel()
Expand Down Expand Up @@ -69,3 +70,7 @@ def removeMessage(self, message):
if self.items[index]["id"] == message_id:
self.removeItem(index)
break

def _onMessageProgress(self, message):
index = self.find("id", id(message))
self.setProperty(index, "progress", message.getProgress())

0 comments on commit 3660ca0

Please sign in to comment.