diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-05-11 16:00:14 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-05-11 16:00:14 +0300 |
commit | 18061f06002b349bdc0e5b439a84d54545b9c87e (patch) | |
tree | c58d47200c244c8005ac05e7f7f73c030943088d /include | |
parent | 05585ff8cf9ef090c7158af47d99df835a22686d (diff) |
Use the correct avatar size for HiDPI displays
Diffstat (limited to 'include')
-rw-r--r-- | include/CommunitiesListItem.h | 8 | ||||
-rw-r--r-- | include/Utils.h | 4 | ||||
-rw-r--r-- | include/dialogs/RoomSettings.hpp | 17 |
3 files changed, 6 insertions, 23 deletions
diff --git a/include/CommunitiesListItem.h b/include/CommunitiesListItem.h index 9309d334..6055d732 100644 --- a/include/CommunitiesListItem.h +++ b/include/CommunitiesListItem.h @@ -84,11 +84,3 @@ private: RippleOverlay *rippleOverlay_; }; - -inline void -CommunitiesListItem::setAvatar(const QImage &img) -{ - communityAvatar_ = QPixmap::fromImage( - img.scaled(IconSize, IconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - update(); -} diff --git a/include/Utils.h b/include/Utils.h index 6fea4962..ad8e2073 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -8,6 +8,7 @@ #include "timeline/widgets/VideoItem.h" #include <QDateTime> +#include <QPixmap> #include <mtx/events/collections.hpp> namespace utils { @@ -168,4 +169,7 @@ message_body(const mtx::events::collections::TimelineEvents &event) //! Calculate the Levenshtein distance between two strings with character skipping. int levenshtein_distance(const std::string &s1, const std::string &s2); + +QPixmap +scaleImageToPixmap(const QImage &img, int size); } diff --git a/include/dialogs/RoomSettings.hpp b/include/dialogs/RoomSettings.hpp index 2acbf4b1..df94fea3 100644 --- a/include/dialogs/RoomSettings.hpp +++ b/include/dialogs/RoomSettings.hpp @@ -22,21 +22,8 @@ class TopSection : public QWidget Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor) public: - TopSection(const RoomInfo &info, const QImage &img, QWidget *parent = nullptr) - : QWidget{parent} - , info_{std::move(info)} - { - textColor_ = palette().color(QPalette::Text); - avatar_ = QPixmap::fromImage(img.scaled( - AvatarSize, AvatarSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - } - - QSize sizeHint() const override - { - QFont font; - font.setPixelSize(18); - return QSize(200, AvatarSize + QFontMetrics(font).ascent() + 6 * Padding); - } + TopSection(const RoomInfo &info, const QImage &img, QWidget *parent = nullptr); + QSize sizeHint() const override; QColor textColor() const { return textColor_; } void setTextColor(QColor &color) { textColor_ = color; } |