diff options
author | Black Hat <bhat@encom.eu.org> | 2018-09-16 18:54:12 +0800 |
---|---|---|
committer | Black Hat <bhat@encom.eu.org> | 2018-09-16 18:54:12 +0800 |
commit | e3908964948892633f09cec0df8c5b4d149c9ac7 (patch) | |
tree | 527375f781d90d9b7f4535f05fb1c7d3b812ef43 | |
parent | 52931841d816e2fd128579ef7e51eec1cbd0bb09 (diff) | |
download | libquotient-e3908964948892633f09cec0df8c5b4d149c9ac7.tar.gz libquotient-e3908964948892633f09cec0df8c5b4d149c9ac7.zip |
Remove default avatar.
-rw-r--r-- | lib/avatar.cpp | 24 | ||||
-rw-r--r-- | lib/avatar.h | 4 | ||||
-rw-r--r-- | lib/user.cpp | 4 |
3 files changed, 10 insertions, 22 deletions
diff --git a/lib/avatar.cpp b/lib/avatar.cpp index be9b6a78..438268b6 100644 --- a/lib/avatar.cpp +++ b/lib/avatar.cpp @@ -33,16 +33,14 @@ using std::move; class Avatar::Private { public: - explicit Private(QIcon di, QUrl url = {}) - : _defaultIcon(move(di)), _url(move(url)) - { } + explicit Private(QUrl url = {}) : _url(move(url)) { } + QImage get(Connection* connection, QSize size, get_callback_t callback) const; bool upload(UploadContentJob* job, upload_callback_t callback); bool checkUrl(QUrl url) const; - const QIcon _defaultIcon; QUrl _url; // The below are related to image caching, hence mutable @@ -56,12 +54,12 @@ class Avatar::Private mutable std::vector<get_callback_t> callbacks; }; -Avatar::Avatar(QIcon defaultIcon) - : d(std::make_unique<Private>(std::move(defaultIcon))) +Avatar::Avatar() + : d(std::make_unique<Private>()) { } -Avatar::Avatar(QUrl url, QIcon defaultIcon) - : d(std::make_unique<Private>(std::move(defaultIcon), std::move(url))) +Avatar::Avatar(QUrl url) + : d(std::make_unique<Private>(std::move(url))) { } Avatar::Avatar(Avatar&&) = default; @@ -126,14 +124,6 @@ QImage Avatar::Private::get(Connection* connection, QSize size, if (callback) callbacks.emplace_back(move(callback)); _thumbnailRequest = connection->getThumbnail(_url, size); - if (_originalImage.isNull() && !_defaultIcon.isNull()) - { - _originalImage = QImage(_defaultIcon.actualSize(size), - QImage::Format_ARGB32_Premultiplied); - _originalImage.fill(Qt::transparent); - QPainter p { &_originalImage }; - _defaultIcon.paint(&p, { QPoint(), _defaultIcon.actualSize(size) }); - } QObject::connect( _thumbnailRequest, &MediaThumbnailJob::success, _thumbnailRequest, [this] { _fetched = true; @@ -149,7 +139,7 @@ QImage Avatar::Private::get(Connection* connection, QSize size, for (const auto& p: _scaledImages) if (p.first == size) return p.second; - auto result = _originalImage.scaled(size, + auto result = _originalImage.isNull() ? QImage() : _originalImage.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); _scaledImages.emplace_back(size, result); return result; diff --git a/lib/avatar.h b/lib/avatar.h index 0166ae9e..c86345e3 100644 --- a/lib/avatar.h +++ b/lib/avatar.h @@ -31,8 +31,8 @@ namespace QMatrixClient class Avatar { public: - explicit Avatar(QIcon defaultIcon = {}); - explicit Avatar(QUrl url, QIcon defaultIcon = {}); + explicit Avatar(); + explicit Avatar(QUrl url); Avatar(Avatar&&); ~Avatar(); Avatar& operator=(Avatar&&); diff --git a/lib/user.cpp b/lib/user.cpp index b9f493c5..eec08ad9 100644 --- a/lib/user.cpp +++ b/lib/user.cpp @@ -44,9 +44,7 @@ class User::Private public: static Avatar makeAvatar(QUrl url) { - static const QIcon icon - { QIcon::fromTheme(QStringLiteral("user-available")) }; - return Avatar(move(url), icon); + return Avatar(move(url)); } Private(QString userId, Connection* connection) |