mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
Show avatars in the completion popup
This commit is contained in:
parent
97326243db
commit
72d5d6d286
12 changed files with 102 additions and 87 deletions
|
@ -25,9 +25,12 @@
|
||||||
class MatrixClient;
|
class MatrixClient;
|
||||||
class TimelineItem;
|
class TimelineItem;
|
||||||
|
|
||||||
|
//! Saved cache data per user.
|
||||||
struct AvatarData
|
struct AvatarData
|
||||||
{
|
{
|
||||||
|
//! The avatar image of the user.
|
||||||
QImage img;
|
QImage img;
|
||||||
|
//! The url that was used to download the avatar.
|
||||||
QUrl url;
|
QUrl url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,17 +40,22 @@ class AvatarProvider : public QObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init(QSharedPointer<MatrixClient> client);
|
static void init(QSharedPointer<MatrixClient> client);
|
||||||
static void resolve(const QString &userId, std::function<void(QImage)> callback);
|
//! The callback is called with the downloaded avatar for the given user
|
||||||
|
//! or the avatar is downloaded first and then saved for re-use.
|
||||||
|
static void resolve(const QString &userId,
|
||||||
|
QObject *receiver,
|
||||||
|
std::function<void(QImage)> callback);
|
||||||
|
//! Used to initialize the mapping user -> avatar url.
|
||||||
static void setAvatarUrl(const QString &userId, const QUrl &url);
|
static void setAvatarUrl(const QString &userId, const QUrl &url);
|
||||||
|
//! Remove all saved data.
|
||||||
static void clear();
|
static void clear() { avatars_.clear(); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Update the cache with the downloaded avatar.
|
||||||
static void updateAvatar(const QString &uid, const QImage &img);
|
static void updateAvatar(const QString &uid, const QImage &img);
|
||||||
|
|
||||||
static QSharedPointer<MatrixClient> client_;
|
static QSharedPointer<MatrixClient> client_;
|
||||||
|
|
||||||
using UserID = QString;
|
using UserID = QString;
|
||||||
static std::map<UserID, AvatarData> avatars_;
|
static std::map<UserID, AvatarData> avatars_;
|
||||||
static std::map<UserID, std::vector<std::function<void(QImage)>>> toBeResolved_;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,7 @@ class DownloadMediaProxy : public QObject
|
||||||
signals:
|
signals:
|
||||||
void imageDownloaded(const QPixmap &data);
|
void imageDownloaded(const QPixmap &data);
|
||||||
void fileDownloaded(const QByteArray &data);
|
void fileDownloaded(const QByteArray &data);
|
||||||
|
void avatarDownloaded(const QImage &img);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -59,14 +60,12 @@ public:
|
||||||
void versions() noexcept;
|
void versions() noexcept;
|
||||||
void fetchRoomAvatar(const QString &roomid, const QUrl &avatar_url);
|
void fetchRoomAvatar(const QString &roomid, const QUrl &avatar_url);
|
||||||
//! Download user's avatar.
|
//! Download user's avatar.
|
||||||
void fetchUserAvatar(const QUrl &avatarUrl,
|
QSharedPointer<DownloadMediaProxy> fetchUserAvatar(const QUrl &avatarUrl);
|
||||||
std::function<void(QImage)> onSuccess,
|
|
||||||
std::function<void(QString)> onError);
|
|
||||||
void fetchCommunityAvatar(const QString &communityId, const QUrl &avatarUrl);
|
void fetchCommunityAvatar(const QString &communityId, const QUrl &avatarUrl);
|
||||||
void fetchCommunityProfile(const QString &communityId);
|
void fetchCommunityProfile(const QString &communityId);
|
||||||
void fetchCommunityRooms(const QString &communityId);
|
void fetchCommunityRooms(const QString &communityId);
|
||||||
DownloadMediaProxy *downloadImage(const QUrl &url);
|
QSharedPointer<DownloadMediaProxy> downloadImage(const QUrl &url);
|
||||||
DownloadMediaProxy *downloadFile(const QUrl &url);
|
QSharedPointer<DownloadMediaProxy> downloadFile(const QUrl &url);
|
||||||
void messages(const QString &room_id, const QString &from_token, int limit = 30) noexcept;
|
void messages(const QString &room_id, const QString &from_token, int limit = 30) noexcept;
|
||||||
void uploadImage(const QString &roomid,
|
void uploadImage(const QString &roomid,
|
||||||
const QString &filename,
|
const QString &filename,
|
||||||
|
|
|
@ -182,7 +182,8 @@ TimelineItem::setupLocalWidgetLayout(Widget *widget,
|
||||||
headerLayout_->addLayout(widgetLayout_);
|
headerLayout_->addLayout(widgetLayout_);
|
||||||
messageLayout_->addLayout(headerLayout_, 1);
|
messageLayout_->addLayout(headerLayout_, 1);
|
||||||
|
|
||||||
AvatarProvider::resolve(userid, [this](const QImage &img) { setUserAvatar(img); });
|
AvatarProvider::resolve(
|
||||||
|
userid, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
} else {
|
} else {
|
||||||
setupSimpleLayout();
|
setupSimpleLayout();
|
||||||
|
|
||||||
|
@ -230,7 +231,8 @@ TimelineItem::setupWidgetLayout(Widget *widget,
|
||||||
headerLayout_->addLayout(widgetLayout_);
|
headerLayout_->addLayout(widgetLayout_);
|
||||||
messageLayout_->addLayout(headerLayout_, 1);
|
messageLayout_->addLayout(headerLayout_, 1);
|
||||||
|
|
||||||
AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); });
|
AvatarProvider::resolve(
|
||||||
|
sender, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
} else {
|
} else {
|
||||||
setupSimpleLayout();
|
setupSimpleLayout();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
QSharedPointer<MatrixClient> AvatarProvider::client_;
|
QSharedPointer<MatrixClient> AvatarProvider::client_;
|
||||||
|
|
||||||
std::map<QString, AvatarData> AvatarProvider::avatars_;
|
std::map<QString, AvatarData> AvatarProvider::avatars_;
|
||||||
std::map<QString, std::vector<std::function<void(QImage)>>> AvatarProvider::toBeResolved_;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AvatarProvider::init(QSharedPointer<MatrixClient> client)
|
AvatarProvider::init(QSharedPointer<MatrixClient> client)
|
||||||
|
@ -32,22 +31,14 @@ AvatarProvider::init(QSharedPointer<MatrixClient> client)
|
||||||
void
|
void
|
||||||
AvatarProvider::updateAvatar(const QString &uid, const QImage &img)
|
AvatarProvider::updateAvatar(const QString &uid, const QImage &img)
|
||||||
{
|
{
|
||||||
if (toBeResolved_.find(uid) != toBeResolved_.end()) {
|
|
||||||
auto callbacks = toBeResolved_[uid];
|
|
||||||
|
|
||||||
// Update all the timeline items with the resolved avatar.
|
|
||||||
for (const auto &callback : callbacks)
|
|
||||||
callback(img);
|
|
||||||
|
|
||||||
toBeResolved_.erase(uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto avatarData = &avatars_[uid];
|
auto avatarData = &avatars_[uid];
|
||||||
avatarData->img = img;
|
avatarData->img = img;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AvatarProvider::resolve(const QString &userId, std::function<void(QImage)> callback)
|
AvatarProvider::resolve(const QString &userId,
|
||||||
|
QObject *receiver,
|
||||||
|
std::function<void(QImage)> callback)
|
||||||
{
|
{
|
||||||
if (avatars_.find(userId) == avatars_.end())
|
if (avatars_.find(userId) == avatars_.end())
|
||||||
return;
|
return;
|
||||||
|
@ -59,23 +50,19 @@ AvatarProvider::resolve(const QString &userId, std::function<void(QImage)> callb
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the current timeline item to the waiting list for this avatar.
|
auto proxy = client_->fetchUserAvatar(avatars_[userId].url);
|
||||||
if (toBeResolved_.find(userId) == toBeResolved_.end()) {
|
|
||||||
client_->fetchUserAvatar(avatars_[userId].url,
|
|
||||||
[userId](QImage image) { updateAvatar(userId, image); },
|
|
||||||
[userId](QString error) {
|
|
||||||
qWarning()
|
|
||||||
<< error << ": failed to retrieve user avatar"
|
|
||||||
<< userId;
|
|
||||||
});
|
|
||||||
|
|
||||||
std::vector<std::function<void(QImage)>> items;
|
if (proxy == nullptr)
|
||||||
items.emplace_back(callback);
|
return;
|
||||||
|
|
||||||
toBeResolved_.emplace(userId, items);
|
connect(proxy.data(),
|
||||||
} else {
|
&DownloadMediaProxy::avatarDownloaded,
|
||||||
toBeResolved_[userId].emplace_back(callback);
|
receiver,
|
||||||
}
|
[userId, proxy, callback](const QImage &img) {
|
||||||
|
proxy->deleteLater();
|
||||||
|
updateAvatar(userId, img);
|
||||||
|
callback(img);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -86,10 +73,3 @@ AvatarProvider::setAvatarUrl(const QString &userId, const QUrl &url)
|
||||||
|
|
||||||
avatars_.emplace(userId, data);
|
avatars_.emplace(userId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AvatarProvider::clear()
|
|
||||||
{
|
|
||||||
avatars_.clear();
|
|
||||||
toBeResolved_.clear();
|
|
||||||
}
|
|
||||||
|
|
|
@ -579,11 +579,20 @@ ChatPage::updateOwnProfileInfo(const QUrl &avatar_url, const QString &display_na
|
||||||
user_info_widget_->setUserId(userid);
|
user_info_widget_->setUserId(userid);
|
||||||
user_info_widget_->setDisplayName(display_name);
|
user_info_widget_->setDisplayName(display_name);
|
||||||
|
|
||||||
if (avatar_url.isValid())
|
if (avatar_url.isValid()) {
|
||||||
client_->fetchUserAvatar(
|
auto proxy = client_->fetchUserAvatar(avatar_url);
|
||||||
avatar_url,
|
if (proxy == nullptr)
|
||||||
[this](QImage img) { user_info_widget_->setAvatar(img); },
|
return;
|
||||||
[](QString error) { qWarning() << error << ": failed to fetch own avatar"; });
|
|
||||||
|
proxy->setParent(this);
|
||||||
|
connect(proxy.data(),
|
||||||
|
&DownloadMediaProxy::avatarDownloaded,
|
||||||
|
this,
|
||||||
|
[this, proxy](const QImage &img) {
|
||||||
|
proxy->deleteLater();
|
||||||
|
user_info_widget_->setAvatar(img);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -709,16 +709,14 @@ MatrixClient::fetchCommunityRooms(const QString &communityId)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
QSharedPointer<DownloadMediaProxy>
|
||||||
MatrixClient::fetchUserAvatar(const QUrl &avatarUrl,
|
MatrixClient::fetchUserAvatar(const QUrl &avatarUrl)
|
||||||
std::function<void(QImage)> onSuccess,
|
|
||||||
std::function<void(QString)> onError)
|
|
||||||
{
|
{
|
||||||
QList<QString> url_parts = avatarUrl.toString().split("mxc://");
|
QList<QString> url_parts = avatarUrl.toString().split("mxc://");
|
||||||
|
|
||||||
if (url_parts.size() != 2) {
|
if (url_parts.size() != 2) {
|
||||||
qDebug() << "Invalid format for user avatar " << avatarUrl.toString();
|
qDebug() << "Invalid format for user avatar:" << avatarUrl.toString();
|
||||||
return;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrlQuery query;
|
QUrlQuery query;
|
||||||
|
@ -735,33 +733,42 @@ MatrixClient::fetchUserAvatar(const QUrl &avatarUrl,
|
||||||
QNetworkRequest avatar_request(endpoint);
|
QNetworkRequest avatar_request(endpoint);
|
||||||
|
|
||||||
auto reply = get(avatar_request);
|
auto reply = get(avatar_request);
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, onSuccess, onError]() {
|
auto proxy = QSharedPointer<DownloadMediaProxy>(
|
||||||
|
new DownloadMediaProxy, [this](auto proxy) { proxy->deleteLater(); });
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [reply, proxy, avatarUrl]() {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|
||||||
if (status == 0 || status >= 400)
|
if (status == 0 || status >= 400) {
|
||||||
return onError(reply->errorString());
|
qWarning() << reply->errorString() << avatarUrl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto data = reply->readAll();
|
auto data = reply->readAll();
|
||||||
|
|
||||||
if (data.size() == 0)
|
if (data.size() == 0) {
|
||||||
return onError("received avatar with no data");
|
qWarning() << "received avatar with no data:" << avatarUrl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QImage img;
|
QImage img;
|
||||||
img.loadFromData(data);
|
img.loadFromData(data);
|
||||||
|
|
||||||
onSuccess(std::move(img));
|
emit proxy->avatarDownloaded(img);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadMediaProxy *
|
QSharedPointer<DownloadMediaProxy>
|
||||||
MatrixClient::downloadImage(const QUrl &url)
|
MatrixClient::downloadImage(const QUrl &url)
|
||||||
{
|
{
|
||||||
QNetworkRequest image_request(url);
|
QNetworkRequest image_request(url);
|
||||||
|
|
||||||
auto reply = get(image_request);
|
auto reply = get(image_request);
|
||||||
auto proxy = new DownloadMediaProxy;
|
auto proxy = QSharedPointer<DownloadMediaProxy>(
|
||||||
|
new DownloadMediaProxy, [this](auto proxy) { proxy->deleteLater(); });
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, proxy]() {
|
connect(reply, &QNetworkReply::finished, this, [reply, proxy]() {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
|
@ -786,13 +793,14 @@ MatrixClient::downloadImage(const QUrl &url)
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadMediaProxy *
|
QSharedPointer<DownloadMediaProxy>
|
||||||
MatrixClient::downloadFile(const QUrl &url)
|
MatrixClient::downloadFile(const QUrl &url)
|
||||||
{
|
{
|
||||||
QNetworkRequest fileRequest(url);
|
QNetworkRequest fileRequest(url);
|
||||||
|
|
||||||
auto reply = get(fileRequest);
|
auto reply = get(fileRequest);
|
||||||
auto proxy = new DownloadMediaProxy;
|
auto proxy = QSharedPointer<DownloadMediaProxy>(
|
||||||
|
new DownloadMediaProxy, [this](auto proxy) { proxy->deleteLater(); });
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, proxy]() {
|
connect(reply, &QNetworkReply::finished, this, [reply, proxy]() {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ PopupItem::PopupItem(QWidget *parent, const QString &user_id)
|
||||||
topLayout_->addWidget(avatar_);
|
topLayout_->addWidget(avatar_);
|
||||||
topLayout_->addWidget(userName_, 1);
|
topLayout_->addWidget(userName_, 1);
|
||||||
|
|
||||||
/* AvatarProvider::resolve(user_id, [this](const QImage &img) { avatar_->setImage(img); });
|
AvatarProvider::resolve(
|
||||||
*/
|
user_id, this, [this](const QImage &img) { avatar_->setImage(img); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -51,7 +51,8 @@ ReceiptItem::ReceiptItem(QWidget *parent, const QString &user_id, uint64_t times
|
||||||
topLayout_->addWidget(avatar_);
|
topLayout_->addWidget(avatar_);
|
||||||
topLayout_->addLayout(textLayout_, 1);
|
topLayout_->addLayout(textLayout_, 1);
|
||||||
|
|
||||||
AvatarProvider::resolve(user_id, [this](const QImage &img) { avatar_->setImage(img); });
|
AvatarProvider::resolve(
|
||||||
|
user_id, this, [this](const QImage &img) { avatar_->setImage(img); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
|
|
|
@ -126,7 +126,8 @@ TimelineItem::TimelineItem(mtx::events::MessageType ty,
|
||||||
|
|
||||||
messageLayout_->addLayout(headerLayout_, 1);
|
messageLayout_->addLayout(headerLayout_, 1);
|
||||||
|
|
||||||
AvatarProvider::resolve(userid, [this](const QImage &img) { setUserAvatar(img); });
|
AvatarProvider::resolve(
|
||||||
|
userid, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
} else {
|
} else {
|
||||||
generateBody(body);
|
generateBody(body);
|
||||||
setupSimpleLayout();
|
setupSimpleLayout();
|
||||||
|
@ -259,7 +260,8 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Notice
|
||||||
|
|
||||||
messageLayout_->addLayout(headerLayout_, 1);
|
messageLayout_->addLayout(headerLayout_, 1);
|
||||||
|
|
||||||
AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); });
|
AvatarProvider::resolve(
|
||||||
|
sender, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
} else {
|
} else {
|
||||||
generateBody(body);
|
generateBody(body);
|
||||||
setupSimpleLayout();
|
setupSimpleLayout();
|
||||||
|
@ -303,7 +305,8 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Emote>
|
||||||
|
|
||||||
messageLayout_->addLayout(headerLayout_, 1);
|
messageLayout_->addLayout(headerLayout_, 1);
|
||||||
|
|
||||||
AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); });
|
AvatarProvider::resolve(
|
||||||
|
sender, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
} else {
|
} else {
|
||||||
generateBody(emoteMsg);
|
generateBody(emoteMsg);
|
||||||
setupSimpleLayout();
|
setupSimpleLayout();
|
||||||
|
@ -352,7 +355,8 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Text>
|
||||||
|
|
||||||
messageLayout_->addLayout(headerLayout_, 1);
|
messageLayout_->addLayout(headerLayout_, 1);
|
||||||
|
|
||||||
AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); });
|
AvatarProvider::resolve(
|
||||||
|
sender, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
} else {
|
} else {
|
||||||
generateBody(body);
|
generateBody(body);
|
||||||
setupSimpleLayout();
|
setupSimpleLayout();
|
||||||
|
@ -562,5 +566,5 @@ TimelineItem::addAvatar()
|
||||||
messageLayout_->addWidget(checkmark_);
|
messageLayout_->addWidget(checkmark_);
|
||||||
messageLayout_->addWidget(timestamp_);
|
messageLayout_->addWidget(timestamp_);
|
||||||
|
|
||||||
AvatarProvider::resolve(userid, [this](const QImage &img) { setUserAvatar(img); });
|
AvatarProvider::resolve(userid, this, [this](const QImage &img) { setUserAvatar(img); });
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ AudioItem::mousePressEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto proxy = client_->downloadFile(url_);
|
auto proxy = client_->downloadFile(url_);
|
||||||
connect(proxy,
|
connect(proxy.data(),
|
||||||
&DownloadMediaProxy::fileDownloaded,
|
&DownloadMediaProxy::fileDownloaded,
|
||||||
this,
|
this,
|
||||||
[proxy, this](const QByteArray &data) {
|
[proxy, this](const QByteArray &data) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ FileItem::mousePressEvent(QMouseEvent *event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto proxy = client_->downloadFile(url_);
|
auto proxy = client_->downloadFile(url_);
|
||||||
connect(proxy,
|
connect(proxy.data(),
|
||||||
&DownloadMediaProxy::fileDownloaded,
|
&DownloadMediaProxy::fileDownloaded,
|
||||||
this,
|
this,
|
||||||
[proxy, this](const QByteArray &data) {
|
[proxy, this](const QByteArray &data) {
|
||||||
|
|
|
@ -56,11 +56,13 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
|
||||||
|
|
||||||
auto proxy = client_.data()->downloadImage(url_);
|
auto proxy = client_.data()->downloadImage(url_);
|
||||||
|
|
||||||
connect(
|
connect(proxy.data(),
|
||||||
proxy, &DownloadMediaProxy::imageDownloaded, this, [this, proxy](const QPixmap &img) {
|
&DownloadMediaProxy::imageDownloaded,
|
||||||
proxy->deleteLater();
|
this,
|
||||||
setImage(img);
|
[this, proxy](const QPixmap &img) {
|
||||||
});
|
proxy->deleteLater();
|
||||||
|
setImage(img);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
|
ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
|
||||||
|
@ -92,11 +94,13 @@ ImageItem::ImageItem(QSharedPointer<MatrixClient> client,
|
||||||
|
|
||||||
auto proxy = client_.data()->downloadImage(url_);
|
auto proxy = client_.data()->downloadImage(url_);
|
||||||
|
|
||||||
connect(
|
connect(proxy.data(),
|
||||||
proxy, &DownloadMediaProxy::imageDownloaded, this, [proxy, this](const QPixmap &img) {
|
&DownloadMediaProxy::imageDownloaded,
|
||||||
proxy->deleteLater();
|
this,
|
||||||
setImage(img);
|
[proxy, this](const QPixmap &img) {
|
||||||
});
|
proxy->deleteLater();
|
||||||
|
setImage(img);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -230,7 +234,7 @@ ImageItem::saveAs()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto proxy = client_->downloadFile(url_);
|
auto proxy = client_->downloadFile(url_);
|
||||||
connect(proxy,
|
connect(proxy.data(),
|
||||||
&DownloadMediaProxy::fileDownloaded,
|
&DownloadMediaProxy::fileDownloaded,
|
||||||
this,
|
this,
|
||||||
[proxy, filename](const QByteArray &data) {
|
[proxy, filename](const QByteArray &data) {
|
||||||
|
|
Loading…
Reference in a new issue