mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-19 06:26:55 +00:00
Always use black-over-white login QR code.
Some android devices don't read light-on-dark QRs. Fixes #10077. Fixes #16152.
This commit is contained in:
parent
25470cde3c
commit
d93d47f2cf
@ -163,9 +163,11 @@ introBackButton: IconButton(defaultIconButton) {
|
||||
}
|
||||
}
|
||||
|
||||
introQrTop: -6px;
|
||||
introQrTop: -18px;
|
||||
introQrPixel: 50px; // large enough
|
||||
introQrMaxSize: 180px;
|
||||
introQrBackgroundSkip: 12px;
|
||||
introQrBackgroundRadius: 8px;
|
||||
introQrLabelsWidth: 292px;
|
||||
introQrTitleWidth: 320px;
|
||||
introQrTitle: FlatLabel(defaultFlatLabel) {
|
||||
|
@ -33,7 +33,7 @@ namespace details {
|
||||
namespace {
|
||||
|
||||
[[nodiscard]] QImage TelegramQrExact(const Qr::Data &data, int pixel) {
|
||||
return Qr::Generate(data, pixel, st::windowFg->c);
|
||||
return Qr::Generate(data, pixel, Qt::black);
|
||||
}
|
||||
|
||||
[[nodiscard]] QImage TelegramQr(const Qr::Data &data, int pixel, int max = 0) {
|
||||
@ -44,7 +44,7 @@ namespace {
|
||||
}
|
||||
const auto qr = TelegramQrExact(data, pixel * style::DevicePixelRatio());
|
||||
auto result = QImage(qr.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
result.fill(st::windowBg->c);
|
||||
result.fill(Qt::white);
|
||||
{
|
||||
auto p = QPainter(&result);
|
||||
p.drawImage(QRect(QPoint(), qr.size()), qr);
|
||||
@ -52,6 +52,10 @@ namespace {
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] QColor QrActiveColor() {
|
||||
return QColor(0x40, 0xA7, 0xE3); // Default windowBgActive.
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<Ui::RpWidget*> PrepareQrWidget(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<QByteArray> codes) {
|
||||
@ -80,7 +84,8 @@ namespace {
|
||||
const auto state = result->lifetime().make_state<State>(
|
||||
[=] { result->update(); });
|
||||
state->waiting.start();
|
||||
result->resize(st::introQrMaxSize, st::introQrMaxSize);
|
||||
const auto size = st::introQrMaxSize + 2 * st::introQrBackgroundSkip;
|
||||
result->resize(size, size);
|
||||
rpl::combine(
|
||||
std::move(qrs),
|
||||
rpl::duplicate(palettes)
|
||||
@ -107,14 +112,30 @@ namespace {
|
||||
result->paintRequest(
|
||||
) | rpl::start_with_next([=](QRect clip) {
|
||||
auto p = QPainter(result);
|
||||
const auto shown = state->qr.isNull() ? 0. : state->shown.value(1.);
|
||||
const auto has = !state->qr.isNull();
|
||||
const auto shown = has ? state->shown.value(1.) : 0.;
|
||||
const auto usualSize = 41;
|
||||
const auto pixel = std::clamp(
|
||||
st::introQrMaxSize / usualSize,
|
||||
1,
|
||||
st::introQrPixel);
|
||||
const auto size = has
|
||||
? (state->qr.size() / cIntRetinaFactor())
|
||||
: QSize(usualSize * pixel, usualSize * pixel);
|
||||
const auto qr = QRect(
|
||||
(result->width() - size.width()) / 2,
|
||||
(result->height() - size.height()) / 2,
|
||||
size.width(),
|
||||
size.height());
|
||||
const auto radius = st::introQrBackgroundRadius;
|
||||
const auto skip = st::introQrBackgroundSkip;
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(Qt::white);
|
||||
p.drawRoundedRect(
|
||||
qr.marginsAdded({ skip, skip, skip, skip }),
|
||||
radius,
|
||||
radius);
|
||||
if (!state->qr.isNull()) {
|
||||
const auto size = state->qr.size() / cIntRetinaFactor();
|
||||
const auto qr = QRect(
|
||||
(result->width() - size.width()) / 2,
|
||||
(result->height() - size.height()) / 2,
|
||||
size.width(),
|
||||
size.height());
|
||||
if (shown == 1.) {
|
||||
state->previous = QImage();
|
||||
} else if (!state->previous.isNull()) {
|
||||
@ -134,7 +155,7 @@ namespace {
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
const auto line = st::radialLine;
|
||||
const auto radial = state->waiting.computeState();
|
||||
auto pen = st::activeButtonBg->p;
|
||||
auto pen = QPen(QrActiveColor());
|
||||
pen.setWidth(line);
|
||||
pen.setCapStyle(Qt::RoundCap);
|
||||
p.setOpacity(radial.shown * (1. - shown));
|
||||
@ -422,7 +443,7 @@ QImage TelegramLogoImage() {
|
||||
{
|
||||
auto p = QPainter(&result);
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.setBrush(st::activeButtonBg);
|
||||
p.setBrush(QrActiveColor());
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(QRect(QPoint(), size));
|
||||
st::introQrPlane.paintInCenter(p, QRect(QPoint(), size));
|
||||
|
Loading…
Reference in New Issue
Block a user