Try to reduce memory usage by reusing avatar pixmaps
This commit is contained in:
parent
89015b9f18
commit
52056a79fa
27 changed files with 149 additions and 208 deletions
|
|
@ -350,12 +350,12 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
keyRequestsToggle_->hide();
|
||||
}
|
||||
|
||||
avatar_ = new Avatar(this);
|
||||
avatar_->setSize(128);
|
||||
avatar_ = new Avatar(this, 128);
|
||||
if (avatarImg_.isNull())
|
||||
avatar_->setLetter(utils::firstChar(QString::fromStdString(info_.name)));
|
||||
else
|
||||
avatar_->setImage(avatarImg_);
|
||||
avatar_->setImage(room_id_,
|
||||
QString::fromStdString(http::client()->user_id().to_string()));
|
||||
|
||||
if (canChangeAvatar(room_id_.toStdString(), utils::localUser().toStdString())) {
|
||||
auto filter = new ClickableFilter(this);
|
||||
|
|
@ -487,7 +487,7 @@ RoomSettings::retrieveRoomInfo()
|
|||
try {
|
||||
usesEncryption_ = cache::client()->isRoomEncrypted(room_id_.toStdString());
|
||||
info_ = cache::client()->singleRoomInfo(room_id_.toStdString());
|
||||
setAvatar(QImage::fromData(cache::client()->image(info_.avatar_url)));
|
||||
setAvatar();
|
||||
} catch (const lmdb::error &e) {
|
||||
nhlog::db()->warn("failed to retrieve room info from cache: {}",
|
||||
room_id_.toStdString());
|
||||
|
|
@ -633,14 +633,13 @@ RoomSettings::displayErrorMessage(const QString &msg)
|
|||
}
|
||||
|
||||
void
|
||||
RoomSettings::setAvatar(const QImage &img)
|
||||
RoomSettings::setAvatar()
|
||||
{
|
||||
stopLoadingSpinner();
|
||||
|
||||
avatarImg_ = img;
|
||||
|
||||
if (avatar_)
|
||||
avatar_->setImage(img);
|
||||
avatar_->setImage(room_id_,
|
||||
QString::fromStdString(http::client()->user_id().to_string()));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -733,7 +732,7 @@ RoomSettings::updateAvatar()
|
|||
return;
|
||||
}
|
||||
|
||||
emit proxy->avatarChanged(QImage::fromData(content));
|
||||
emit proxy->avatarChanged();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue