From 5c4bfceee7798825310d9250745f934d93497e48 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Thu, 16 Jun 2016 00:12:27 +0300 Subject: [PATCH] bug fix - repaint --- src/callbacks.py | 2 +- src/list_items.py | 7 +++++++ src/profile.py | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index a33fd35..b760ed6 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -151,7 +151,7 @@ def friend_read_receipt(tox, friend_number, message_id, user_data): profile = Profile.get_instance() profile.get_friend_by_number(friend_number).dec_receipt() if friend_number == profile.get_active_number(): - invoke_in_main_thread(profile.update) # TODO: improve + invoke_in_main_thread(profile.receipt) # ----------------------------------------------------------------------------------------------------------------- # Callbacks - file transfers diff --git a/src/list_items.py b/src/list_items.py index 7501aaf..041d2d4 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -123,6 +123,7 @@ class MessageItem(QtGui.QWidget): movie = QtGui.QMovie(curr_directory() + '/images/spinner.gif') self.time.setMovie(movie) movie.start() + self.t = time else: self.time.setText(time) @@ -136,6 +137,12 @@ class MessageItem(QtGui.QWidget): self.message.setAlignment(QtCore.Qt.AlignCenter) self.time.setStyleSheet("QLabel { color: #5CB3FF; }") + def mark_as_sent(self): + if hasattr(self, 't'): + self.time.setText(self.t) + return True + return False + class ContactItem(QtGui.QWidget): """ diff --git a/src/profile.py b/src/profile.py index eb0819c..e7398ee 100644 --- a/src/profile.py +++ b/src/profile.py @@ -306,6 +306,11 @@ class Profile(contact.Contact, Singleton): # Private messages # ----------------------------------------------------------------------------------------------------------------- + def receipt(self): + i = 0 + while i < self._messages.count() and not self._messages.itemWidget(self._messages.item(i)).mark_as_sent(): + i += 1 + def send_messages(self, friend_number): """ Send 'offline' messages to friend @@ -976,7 +981,7 @@ class Profile(contact.Contact, Singleton): self.get_friend_by_number(friend_number).update_transfer_data(file_number, FILE_TRANSFER_MESSAGE_STATUS['FINISHED'], inline) - self.update() + self.update() # not load all messages? else: self.get_friend_by_number(friend_number).update_transfer_data(file_number, FILE_TRANSFER_MESSAGE_STATUS['FINISHED'])