mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Improved quality of profile photo in share QR box.
This commit is contained in:
parent
a32a9aa3fc
commit
9557f0c844
1 changed files with 16 additions and 15 deletions
|
@ -18,6 +18,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "qr/qr_generate.h"
|
#include "qr/qr_generate.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
|
#include "ui/dynamic_image.h"
|
||||||
|
#include "ui/dynamic_thumbnails.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/image/image_prepare.h"
|
#include "ui/image/image_prepare.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
|
@ -425,10 +427,18 @@ void FillPeerQrBox(
|
||||||
: (rpl::single(QString()) | rpl::type_erased());
|
: (rpl::single(QString()) | rpl::type_erased());
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
const auto userpic = Ui::CreateChild<Ui::RpWidget>(box);
|
||||||
box,
|
const auto userpicSize = st::defaultUserpicButton.photoSize;
|
||||||
peer ? peer : controller->session().user().get(),
|
userpic->resize(Size(userpicSize));
|
||||||
st::defaultUserpicButton);
|
const auto userpicMedia = Ui::MakeUserpicThumbnail(peer
|
||||||
|
? peer
|
||||||
|
: controller->session().user().get());
|
||||||
|
userpicMedia->subscribeToUpdates([=] { userpic->update(); });
|
||||||
|
userpic->paintRequest() | rpl::start_with_next([=] {
|
||||||
|
auto p = QPainter(userpic);
|
||||||
|
p.drawImage(0, 0, userpicMedia->image(userpicSize));
|
||||||
|
}, userpic->lifetime());
|
||||||
|
|
||||||
userpic->setVisible(peer != nullptr);
|
userpic->setVisible(peer != nullptr);
|
||||||
PrepareQrWidget(
|
PrepareQrWidget(
|
||||||
box->verticalLayout(),
|
box->verticalLayout(),
|
||||||
|
@ -781,10 +791,7 @@ void FillPeerQrBox(
|
||||||
usernameValue()).current().toUpper();
|
usernameValue()).current().toUpper();
|
||||||
const auto link = rpl::variable<QString>(linkValue());
|
const auto link = rpl::variable<QString>(linkValue());
|
||||||
const auto textWidth = font->width(username);
|
const auto textWidth = font->width(username);
|
||||||
const auto top = Ui::GrabWidget(
|
const auto top = userpicMedia->image(photoSize);
|
||||||
userpic,
|
|
||||||
{},
|
|
||||||
Qt::transparent);
|
|
||||||
const auto weak = Ui::MakeWeak(box);
|
const auto weak = Ui::MakeWeak(box);
|
||||||
|
|
||||||
crl::async([=] {
|
crl::async([=] {
|
||||||
|
@ -837,13 +844,7 @@ void FillPeerQrBox(
|
||||||
photoSize);
|
photoSize);
|
||||||
|
|
||||||
if (userpicToggled) {
|
if (userpicToggled) {
|
||||||
p.drawPixmap(
|
p.drawImage((resultSize.width() - photoSize) / 2, 0, top);
|
||||||
(resultSize.width() - photoSize) / 2,
|
|
||||||
0,
|
|
||||||
top.scaled(
|
|
||||||
Size(photoSize * style::DevicePixelRatio()),
|
|
||||||
Qt::IgnoreAspectRatio,
|
|
||||||
Qt::SmoothTransformation));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
crl::on_main(weak, [=] {
|
crl::on_main(weak, [=] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue