mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-10 08:51:12 +00:00
Make login QR follow the color theme.
This commit is contained in:
parent
339a80e192
commit
7dbba75776
@ -75,6 +75,7 @@ introHeight: 406px;
|
||||
introStepTopMin: 76px;
|
||||
introStepWidth: 380px;
|
||||
introNextTop: 266px;
|
||||
introNextSlide: 200px;
|
||||
introStepHeight: 384px;
|
||||
introContentTopAdd: 30px;
|
||||
introStepHeightFull: 590px;
|
||||
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/image/image_prepare.h"
|
||||
#include "main/main_account.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "core/application.h"
|
||||
@ -50,9 +51,10 @@ namespace {
|
||||
}
|
||||
|
||||
[[nodiscard]] QImage TelegramQrExact(const Qr::Data &data, int pixel) {
|
||||
return Qr::ReplaceCenter(
|
||||
Qr::Generate(data, pixel),
|
||||
TelegramLogoImage(Qr::ReplaceSize(data, 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) {
|
||||
@ -64,21 +66,20 @@ namespace {
|
||||
return TelegramQrExact(data, pixel * style::DevicePixelRatio());
|
||||
}
|
||||
|
||||
[[nodiscard]] QImage TelegramQr(const QString &text, int pixel, int max) {
|
||||
return TelegramQr(
|
||||
Qr::Encode(text, Qr::Redundancy::Quartile),
|
||||
pixel,
|
||||
max);
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<Ui::RpWidget*> PrepareQrWidget(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<QByteArray> codes) {
|
||||
auto result = Ui::CreateChild<Ui::RpWidget>(parent.get());
|
||||
auto current = result->lifetime().make_state<QImage>();
|
||||
std::move(
|
||||
auto qrs = std::move(
|
||||
codes
|
||||
) | rpl::map([](const QByteArray &code) {
|
||||
return Qr::Encode(code, Qr::Redundancy::Quartile);
|
||||
});
|
||||
auto result = Ui::CreateChild<Ui::RpWidget>(parent.get());
|
||||
auto current = result->lifetime().make_state<QImage>();
|
||||
rpl::combine(
|
||||
std::move(qrs),
|
||||
rpl::single(rpl::empty_value()) | rpl::then(style::PaletteChanged())
|
||||
) | 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());
|
||||
@ -102,7 +103,7 @@ QrWidget::QrWidget(
|
||||
QWidget *parent,
|
||||
not_null<Main::Account*> account,
|
||||
not_null<Data*> data)
|
||||
: Step(parent, account, data)
|
||||
: Step(parent, account, data)
|
||||
, _refreshTimer([=] { refreshCode(); }) {
|
||||
setTitleText(rpl::single(QString()));
|
||||
setDescriptionText(rpl::single(QString()));
|
||||
|
@ -48,7 +48,12 @@ Widget::Widget(QWidget *parent, not_null<Main::Account*> account)
|
||||
this,
|
||||
tr::lng_menu_settings(),
|
||||
st::defaultBoxButton))
|
||||
, _next(this, nullptr, st::introNextButton) {
|
||||
, _next(
|
||||
this,
|
||||
object_ptr<Ui::RoundButton>(
|
||||
this,
|
||||
nullptr,
|
||||
st::introNextButton)) {
|
||||
getData()->country = Platform::SystemCountry();
|
||||
|
||||
_back->entity()->setClickedCallback([=] {
|
||||
@ -56,7 +61,7 @@ Widget::Widget(QWidget *parent, not_null<Main::Account*> account)
|
||||
});
|
||||
_back->hide(anim::type::instant);
|
||||
|
||||
_next->setClickedCallback([this] { getStep()->submit(); });
|
||||
_next->entity()->setClickedCallback([this] { getStep()->submit(); });
|
||||
|
||||
_settings->entity()->setClickedCallback([] { App::wnd()->showSettings(); });
|
||||
|
||||
@ -475,8 +480,8 @@ void Widget::showTerms(Fn<void()> callback) {
|
||||
|
||||
void Widget::showControls() {
|
||||
getStep()->show();
|
||||
_next->show();
|
||||
setupNextButton();
|
||||
_next->show(anim::type::instant);
|
||||
_nextShownAnimation.stop();
|
||||
_connecting->setForceHidden(false);
|
||||
auto hasCover = getStep()->hasCover();
|
||||
@ -496,7 +501,7 @@ void Widget::showControls() {
|
||||
}
|
||||
|
||||
void Widget::setupNextButton() {
|
||||
_next->setText(getStep()->nextButtonText(
|
||||
_next->entity()->setText(getStep()->nextButtonText(
|
||||
) | rpl::filter([](const QString &text) {
|
||||
return !text.isEmpty();
|
||||
}));
|
||||
@ -507,6 +512,7 @@ void Widget::setupNextButton() {
|
||||
std::move(
|
||||
visible
|
||||
) | rpl::start_with_next([=](bool visible) {
|
||||
_next->toggle(visible, anim::type::normal);
|
||||
_nextShown = visible;
|
||||
_nextShownAnimation.start(
|
||||
[=] { updateControlsGeometry(); },
|
||||
@ -518,7 +524,7 @@ void Widget::setupNextButton() {
|
||||
|
||||
void Widget::hideControls() {
|
||||
getStep()->hide();
|
||||
_next->hide();
|
||||
_next->hide(anim::type::instant);
|
||||
_connecting->setForceHidden(true);
|
||||
_settings->hide(anim::type::instant);
|
||||
if (_update) _update->hide(anim::type::instant);
|
||||
@ -605,7 +611,10 @@ void Widget::updateControlsGeometry() {
|
||||
auto nextTopTo = getStep()->contentTop() + st::introNextTop;
|
||||
auto nextTop = anim::interpolate(_nextTopFrom, nextTopTo, shown);
|
||||
const auto shownAmount = _nextShownAnimation.value(_nextShown ? 1. : 0.);
|
||||
const auto realNextTop = anim::interpolate(height(), nextTop, shownAmount);
|
||||
const auto realNextTop = anim::interpolate(
|
||||
nextTop + st::introNextSlide,
|
||||
nextTop,
|
||||
shownAmount);
|
||||
_next->moveToLeft((width() - _next->width()) / 2, realNextTop);
|
||||
if (_changeLanguage) {
|
||||
_changeLanguage->moveToLeft((width() - _changeLanguage->width()) / 2, _next->y() + _next->height() + _changeLanguage->height());
|
||||
|
@ -145,7 +145,7 @@ private:
|
||||
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _update = { nullptr };
|
||||
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _settings;
|
||||
|
||||
object_ptr<Ui::RoundButton> _next;
|
||||
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _next;
|
||||
object_ptr<Ui::FadeWrap<Ui::LinkButton>> _changeLanguage = { nullptr };
|
||||
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _resetAccount = { nullptr };
|
||||
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _terms = { nullptr };
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 4b0a1d5fb546af4671048aeeec9c355a67a12a01
|
||||
Subproject commit 1efe65125ddca2a4a663c004380f31befd22ea76
|
Loading…
Reference in New Issue
Block a user