From ba7762305eef955d9738d82ef45658d99c9345c5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 26 Nov 2019 15:56:07 +0300 Subject: [PATCH] Use special plane icon for login QR. --- Telegram/Resources/icons/intro_qr_plane.png | Bin 0 -> 635 bytes .../Resources/icons/intro_qr_plane@2x.png | Bin 0 -> 1264 bytes .../Resources/icons/intro_qr_plane@3x.png | Bin 0 -> 1921 bytes Telegram/SourceFiles/intro/intro.style | 6 +- Telegram/SourceFiles/intro/intro_qr.cpp | 76 +++++++++++------- 5 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 Telegram/Resources/icons/intro_qr_plane.png create mode 100644 Telegram/Resources/icons/intro_qr_plane@2x.png create mode 100644 Telegram/Resources/icons/intro_qr_plane@3x.png diff --git a/Telegram/Resources/icons/intro_qr_plane.png b/Telegram/Resources/icons/intro_qr_plane.png new file mode 100644 index 0000000000000000000000000000000000000000..cdc309f9d8c90c02b84e6824b3026a2958d65aca GIT binary patch literal 635 zcmV->0)+jEP)50006)NklPwSIPrP#wb zolYQ0k`dr-UD+re68qoI(IOI zLgD|zpx=!U9}S1Y;Ra)|SeSe8O2mbfO6BGHIh{^XwOVD&@cj!xr7sMXJ_iON^aFNp VN|`&_^qBwv002ovPDHLkV1m%4COH5A literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/intro_qr_plane@2x.png b/Telegram/Resources/icons/intro_qr_plane@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..3d0c2e9afb737e266037a3b962541e9a53a912c6 GIT binary patch literal 1264 zcmVWyo=fwvhgc0KdznBuo zFfjy}7y?WT0Vak36GMQBA;82CU}6X`F$9dK)EdmbJhyjzS^D#ewRm3VG$?n@c=JU>5srHZo!iHc`1p9-*4BnEFE0g+9nO-K zmG!d+-;9h5tkdc6>+3784w}toyu7^Z@^uLb2|rH^)E?E<)p%`fP0+6nm94FV>+9=I zUk5b|%y2(OOl)i{Zf$MF7Z(?TguwOX<>i0dEh#B+Y5LyT+2PvI&C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 zZ_A9tTfUXc8$4WF97r4>jl(pGo00*WURq0;#@U2*ti0vcTBKc0YY~nabTU%vhloML z);-TlOF1*;_n{5@mu9P@+$a5|+8bWv-MsXP9UM77RPG=> F_CGPKs=WXJ literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/intro/intro.style b/Telegram/SourceFiles/intro/intro.style index 8491d5b14..c9d4be939 100644 --- a/Telegram/SourceFiles/intro/intro.style +++ b/Telegram/SourceFiles/intro/intro.style @@ -162,9 +162,9 @@ introBackButton: IconButton(defaultIconButton) { } } -introQrTop: 0px; +introQrTop: -6px; introQrPixel: 50px; // large enough -introQrMaxSize: 170px; +introQrMaxSize: 180px; introQrLabelsWidth: 292px; introQrTitle: FlatLabel(defaultFlatLabel) { textFg: introTitleFg; @@ -179,3 +179,5 @@ introQrStep: defaultFlatLabel; introQrStepsTop: 232px; introQrStepMargins: margins(0px, 8px, 0px, 0px); introQrSkipTop: 360px; +introQrCenterSize: 44px; +introQrPlane: icon {{ "intro_qr_plane", activeButtonFg }}; diff --git a/Telegram/SourceFiles/intro/intro_qr.cpp b/Telegram/SourceFiles/intro/intro_qr.cpp index fe6971903..3ee26130e 100644 --- a/Telegram/SourceFiles/intro/intro_qr.cpp +++ b/Telegram/SourceFiles/intro/intro_qr.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/vertical_layout.h" #include "ui/text/text_utilities.h" #include "ui/image/image_prepare.h" +#include "ui/painter.h" #include "main/main_account.h" #include "boxes/confirm_box.h" #include "core/application.h" @@ -26,35 +27,26 @@ namespace Intro { namespace details { namespace { -[[nodiscard]] QImage TelegramLogoImage(int size) { - constexpr auto kScale = 0.8; - const auto used = int(size * kScale); - const auto adjusted = used + ((used % 2) + (size % 2)) % 2; - const auto image = Core::App().logo().scaled( - adjusted, - adjusted, - Qt::KeepAspectRatio, - Qt::SmoothTransformation); - auto result = QImage(size, size, QImage::Format_ARGB32_Premultiplied); +[[nodiscard]] QImage TelegramLogoImage() { + const auto size = QSize(st::introQrCenterSize, st::introQrCenterSize); + auto result = QImage( + size * style::DevicePixelRatio(), + QImage::Format_ARGB32_Premultiplied); result.fill(Qt::transparent); + result.setDevicePixelRatio(style::DevicePixelRatio()); { - QPainter p(&result); - p.drawImage( - QRect( - (size - adjusted) / 2, - (size - adjusted) / 2, - adjusted, - adjusted), - image); + auto p = QPainter(&result); + auto hq = PainterHighQualityEnabler(p); + p.setBrush(st::activeButtonBg); + p.setPen(Qt::NoPen); + p.drawEllipse(QRect(QPoint(), size)); + st::introQrPlane.paintInCenter(p, QRect(QPoint(), size)); } return result; } [[nodiscard]] QImage TelegramQrExact(const Qr::Data &data, int pixel) { return Qr::Generate(data, pixel, st::windowFg->c); - //Qr::ReplaceCenter( - // Qr::Generate(data, pixel), - // TelegramLogoImage(Qr::ReplaceSize(data, pixel))); } [[nodiscard]] QImage TelegramQr(const Qr::Data &data, int pixel, int max = 0) { @@ -74,25 +66,53 @@ namespace { ) | rpl::map([](const QByteArray &code) { return Qr::Encode(code, Qr::Redundancy::Quartile); }); + auto palettes = rpl::single( + rpl::empty_value() + ) | rpl::then( + style::PaletteChanged() + ); auto result = Ui::CreateChild(parent.get()); - auto current = result->lifetime().make_state(); + const auto current = result->lifetime().make_state(); + const auto center = result->lifetime().make_state(); + result->resize(st::introQrMaxSize, st::introQrMaxSize); rpl::combine( std::move(qrs), - rpl::single(rpl::empty_value()) | rpl::then(style::PaletteChanged()) + rpl::duplicate(palettes) ) | rpl::map([](const Qr::Data &code, const auto &) { return TelegramQr(code, st::introQrPixel, st::introQrMaxSize); }) | rpl::start_with_next([=](QImage &&image) { - result->resize(image.size() / cIntRetinaFactor()); *current = std::move(image); result->update(); }, result->lifetime()); + std::move( + palettes + ) | rpl::map([] { + return TelegramLogoImage(); + }) | rpl::start_with_next([=](QImage &&image) { + *center = std::move(image); + }, result->lifetime()); result->paintRequest( ) | rpl::filter([=] { - return !current->isNull(); + return !center->isNull(); }) | rpl::start_with_next([=](QRect clip) { - QPainter(result).drawImage( - QRect(QPoint(), current->size() / cIntRetinaFactor()), - *current); + auto p = QPainter(result); + p.drawImage( + QRect( + (result->width() - st::introQrCenterSize) / 2, + (result->height() - st::introQrCenterSize) / 2, + st::introQrCenterSize, + st::introQrCenterSize), + *center); + if (current) { + const auto size = current->size() / cIntRetinaFactor(); + p.drawImage( + QRect( + (result->width() - size.width()) / 2, + (result->height() - size.height()) / 2, + size.width(), + size.height()), + *current); + } }, result->lifetime()); return result; }