From 3a64121d72dc22ef0c6bc3e9b9287980d90f2f7b Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Thu, 4 Aug 2016 18:23:47 +0300 Subject: [PATCH] avatars fix --- toxygen/contact.py | 7 +++---- toxygen/list_items.py | 4 ++-- toxygen/mainscreen.py | 4 ++-- toxygen/profile.py | 8 +++----- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/toxygen/contact.py b/toxygen/contact.py index f4b3f9a..1dbfcdf 100644 --- a/toxygen/contact.py +++ b/toxygen/contact.py @@ -92,10 +92,9 @@ class Contact: avatar_path = 'avatar.png' os.chdir(curr_directory() + '/images/') width = self._widget.avatar_label.width() - pixmap = QtGui.QPixmap(QtCore.QSize(width, width)) - pixmap.load(avatar_path) - self._widget.avatar_label.setScaledContents(False) - self._widget.avatar_label.setPixmap(pixmap.scaled(width, width, QtCore.Qt.KeepAspectRatio)) + pixmap = QtGui.QPixmap(avatar_path) + self._widget.avatar_label.setPixmap(pixmap.scaled(width, width, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation)) self._widget.avatar_label.repaint() def reset_avatar(self): diff --git a/toxygen/list_items.py b/toxygen/list_items.py index 7b7ccd9..49e9c5a 100644 --- a/toxygen/list_items.py +++ b/toxygen/list_items.py @@ -187,7 +187,7 @@ class MessageItem(QtGui.QWidget): self.setFixedHeight(max(self.height(), 36)) self.name.setFixedHeight(self.height()) self.message.setFixedHeight(self.height()) - self.name.setPixmap(pixmap.scaled(30, 30, QtCore.Qt.KeepAspectRatio)) + self.name.setPixmap(pixmap.scaled(30, 30, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)) class ContactItem(QtGui.QWidget): @@ -202,7 +202,7 @@ class ContactItem(QtGui.QWidget): self.avatar_label = QtGui.QLabel(self) size = 32 if mode else 64 self.avatar_label.setGeometry(QtCore.QRect(3, 4, size, size)) - self.avatar_label.setScaledContents(True) + self.avatar_label.setScaledContents(False) self.avatar_label.setAlignment(QtCore.Qt.AlignCenter) self.name = DataLabel(self) self.name.setGeometry(QtCore.QRect(50 if mode else 75, 3 if mode else 10, 150, 15 if mode else 25)) diff --git a/toxygen/mainscreen.py b/toxygen/mainscreen.py index e4d23b0..eb04dff 100644 --- a/toxygen/mainscreen.py +++ b/toxygen/mainscreen.py @@ -177,7 +177,7 @@ class MainWindow(QtGui.QMainWindow, Singleton): Form.setBaseSize(QtCore.QSize(270, 100)) self.avatar_label = Form.avatar_label = QtGui.QLabel(Form) self.avatar_label.setGeometry(QtCore.QRect(5, 30, 64, 64)) - self.avatar_label.setScaledContents(True) + self.avatar_label.setScaledContents(False) self.avatar_label.setAlignment(QtCore.Qt.AlignCenter) self.name = Form.name = DataLabel(Form) Form.name.setGeometry(QtCore.QRect(75, 40, 150, 25)) @@ -205,7 +205,7 @@ class MainWindow(QtGui.QMainWindow, Singleton): Form.resize(650, 100) self.account_avatar = QtGui.QLabel(Form) self.account_avatar.setGeometry(QtCore.QRect(10, 30, 64, 64)) - self.account_avatar.setScaledContents(True) + self.account_avatar.setScaledContents(False) self.account_name = DataLabel(Form) self.account_name.setGeometry(QtCore.QRect(100, 25, 400, 25)) self.account_name.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse) diff --git a/toxygen/profile.py b/toxygen/profile.py index 321fc5e..1b5e5dc 100644 --- a/toxygen/profile.py +++ b/toxygen/profile.py @@ -229,11 +229,9 @@ class Profile(contact.Contact, Singleton): if not os.path.isfile(avatar_path): # load default image avatar_path = curr_directory() + '/images/avatar.png' os.chdir(os.path.dirname(avatar_path)) - pixmap = QtGui.QPixmap(QtCore.QSize(64, 64)) - pixmap.load(avatar_path) - self._screen.account_avatar.setScaledContents(False) - self._screen.account_avatar.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio)) - self._screen.account_avatar.repaint() # comment? + pixmap = QtGui.QPixmap(avatar_path) + self._screen.account_avatar.setPixmap(pixmap.scaled(64, 64, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation)) self.update_filtration() except Exception as ex: # no friend found. ignore log('Friend value: ' + str(value))