aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConfuSomu2024-03-24 20:40:51 -0400
committerConfuSomu2024-03-24 20:43:39 -0400
commit13c3f52f9b5027d5b1ead5f8b828da3bebd50937 (patch)
treee55426a9688cfe1e8e4a572fa67593a62cd2a864
parent9429663fb6b0be845cc4ea45c4dfd3962422f6cf (diff)
downloadActorViewer-13c3f52f9b5027d5b1ead5f8b828da3bebd50937.tar
ActorViewer-13c3f52f9b5027d5b1ead5f8b828da3bebd50937.tar.gz
ActorViewer-13c3f52f9b5027d5b1ead5f8b828da3bebd50937.zip
Scale header image to nicely fill username label
This is similar to what the Mastodon web interface (and other clients, such as SubwayTooter) does with header images, only in an empty zone above the display name label. We could evidently change this with ease in the future.
-rw-r--r--src/widgets/tab_actor_info.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/widgets/tab_actor_info.cpp b/src/widgets/tab_actor_info.cpp
index 7a01980..282d093 100644
--- a/src/widgets/tab_actor_info.cpp
+++ b/src/widgets/tab_actor_info.cpp
@@ -54,12 +54,19 @@ void TabActorInfo::paintEvent(QPaintEvent* event) {
if (actor and actor->header) {
painter.setOpacity(0.75);
- QPixmap pixmap = actor->header->get_pixmap(ui->displayNameText->width());
+
auto &widget = *(ui->displayNameText);
- painter.translate(widget.pos());
+ QPixmap pixmap = actor->header->get_pixmap(widget.width());
+
QPoint centre(widget.width() / 2 - pixmap.width() / 2,
widget.height() / 2 - pixmap.height() / 2);
- painter.drawPixmap(centre, pixmap);
+
+ QRect source(
+ QPoint(0, abs(widget.height() - pixmap.height()) / 2),
+ QPoint(pixmap.width(), abs(widget.height() - pixmap.height()) / 2 + widget.height())
+ );
+
+ painter.drawPixmap(widget.pos(), pixmap, source);
painter.setOpacity(1.0);
}
}