From a176f0bf35a3e855f269d6349ebce37252746f94 Mon Sep 17 00:00:00 2001 From: Mayeul Cantan Date: Fri, 21 Aug 2020 21:17:35 +0200 Subject: [PATCH 1/4] Smooth Avatars in timeline This helps on low-dpi screens, getting rid of the jaggies. --- resources/qml/Avatar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Avatar.qml b/resources/qml/Avatar.qml index 34b029a6..4adff572 100644 --- a/resources/qml/Avatar.qml +++ b/resources/qml/Avatar.qml @@ -33,7 +33,7 @@ Rectangle { asynchronous: true fillMode: Image.PreserveAspectCrop mipmap: true - smooth: false + smooth: true sourceSize.width: avatar.width sourceSize.height: avatar.height layer.enabled: true From 2c542c398a79ed0091b8bffae0fde131363df01e Mon Sep 17 00:00:00 2001 From: Mayeul Cantan Date: Fri, 21 Aug 2020 21:46:42 +0200 Subject: [PATCH 2/4] Smooth pictures in timeline --- resources/qml/delegates/ImageMessage.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index 5c3dac95..e8e325f0 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -29,6 +29,8 @@ Item { source: model.data.url.replace("mxc://", "image://MxcImage/") asynchronous: true fillMode: Image.PreserveAspectFit + smooth: true + mipmap: true MouseArea { id: mouseArea From 6219604ff8295dd1383648c953c791f9985db1e6 Mon Sep 17 00:00:00 2001 From: Mayeul Cantan Date: Sun, 1 Nov 2020 02:47:03 +0100 Subject: [PATCH 3/4] Smooth avatars in widgets --- src/ui/Avatar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/Avatar.cpp b/src/ui/Avatar.cpp index 70ebfcf2..0d1bb924 100644 --- a/src/ui/Avatar.cpp +++ b/src/ui/Avatar.cpp @@ -121,7 +121,9 @@ Avatar::paintEvent(QPaintEvent *) bool rounded = QSettings().value("user/avatar_circles", true).toBool(); QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); + + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | + QPainter::TextAntialiasing); QRectF r = rect(); const int hs = size_ / 2; From 5f086cd93d5a84f41b1157109ac0936a8de3bdec Mon Sep 17 00:00:00 2001 From: Mayeul Cantan Date: Sun, 1 Nov 2020 02:47:47 +0100 Subject: [PATCH 4/4] Simplify PainterHighQualityEnabler code There is no need to iterate over a list, flags can be applied and stored simultaneously. --- src/ui/Painter.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/ui/Painter.h b/src/ui/Painter.h index 2bb0981b..c69dca95 100644 --- a/src/ui/Painter.h +++ b/src/ui/Painter.h @@ -139,18 +139,10 @@ public: PainterHighQualityEnabler(Painter &p) : _painter(p) { - static constexpr QPainter::RenderHint Hints[] = {QPainter::Antialiasing, - QPainter::SmoothPixmapTransform, - QPainter::TextAntialiasing}; + hints_ = QPainter::Antialiasing | QPainter::SmoothPixmapTransform | + QPainter::TextAntialiasing; - auto hints = _painter.renderHints(); - for (const auto &hint : Hints) { - if (!(hints & hint)) - hints_ |= hint; - } - - if (hints_) - _painter.setRenderHints(hints_); + _painter.setRenderHints(hints_); } ~PainterHighQualityEnabler()