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