Fixed duration after changing of winners count in create giveaway box.

This commit is contained in:
23rd 2023-11-22 03:44:12 +03:00 committed by John Preston
parent 36a8c49213
commit 32008161a0

View file

@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/padding_wrap.h" #include "ui/wrap/padding_wrap.h"
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "ui/rect.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_premium.h" #include "styles/style_premium.h"
@ -69,8 +70,8 @@ GradientRadioView::GradientRadioView(
, _st(&st) { , _st(&st) {
} }
void GradientRadioView::paint(QPainter &p, int left, int top, int outerWidth) { void GradientRadioView::paint(QPainter &p, int left, int top, int outerW) {
PainterHighQualityEnabler hq(p); auto hq = PainterHighQualityEnabler(p);
const auto toggled = currentAnimationValue(); const auto toggled = currentAnimationValue();
const auto toggledFg = _brushOverride const auto toggledFg = _brushOverride
@ -80,17 +81,17 @@ void GradientRadioView::paint(QPainter &p, int left, int top, int outerWidth) {
{ {
const auto skip = (_st->outerSkip / 10.) + (_st->thickness / 2); const auto skip = (_st->outerSkip / 10.) + (_st->thickness / 2);
const auto rect = QRectF(left, top, _st->diameter, _st->diameter) const auto rect = QRectF(left, top, _st->diameter, _st->diameter)
- QMarginsF(skip, skip, skip, skip); - Margins(skip);
p.setBrush(_st->bg); p.setBrush(_st->bg);
if (toggled < 1) { if (toggled < 1) {
p.setPen(QPen(_st->untoggledFg, _st->thickness)); p.setPen(QPen(_st->untoggledFg, _st->thickness));
p.drawEllipse(style::rtlrect(rect, outerWidth)); p.drawEllipse(style::rtlrect(rect, outerW));
} }
if (toggled > 0) { if (toggled > 0) {
p.setOpacity(toggled); p.setOpacity(toggled);
p.setPen(QPen(toggledFg, _st->thickness)); p.setPen(QPen(toggledFg, _st->thickness));
p.drawEllipse(style::rtlrect(rect, outerWidth)); p.drawEllipse(style::rtlrect(rect, outerW));
} }
} }
@ -102,8 +103,8 @@ void GradientRadioView::paint(QPainter &p, int left, int top, int outerWidth) {
const auto skip1 = _st->skip / 10.; const auto skip1 = _st->skip / 10.;
const auto checkSkip = skip0 * (1. - toggled) + skip1 * toggled; const auto checkSkip = skip0 * (1. - toggled) + skip1 * toggled;
const auto rect = QRectF(left, top, _st->diameter, _st->diameter) const auto rect = QRectF(left, top, _st->diameter, _st->diameter)
- QMarginsF(checkSkip, checkSkip, checkSkip, checkSkip); - Margins(checkSkip);
p.drawEllipse(style::rtlrect(rect, outerWidth)); p.drawEllipse(style::rtlrect(rect, outerW));
} }
} }
@ -343,7 +344,7 @@ void Bubble::paintBubble(QPainter &p, const QRect &r, const QBrush &brush) {
pathBubble.setFillRule(Qt::WindingFill); pathBubble.setFillRule(Qt::WindingFill);
pathBubble.addRoundedRect(bubbleRect, radius, radius); pathBubble.addRoundedRect(bubbleRect, radius, radius);
PainterHighQualityEnabler hq(p); auto hq = PainterHighQualityEnabler(p);
p.setPen(QPen( p.setPen(QPen(
brush, brush,
penWidth, penWidth,
@ -875,7 +876,7 @@ void Line::recache(const QSize &s) {
{ {
auto leftPixmap = pixmap(width); auto leftPixmap = pixmap(width);
auto p = Painter(&leftPixmap); auto p = Painter(&leftPixmap);
PainterHighQualityEnabler hq(p); auto hq = PainterHighQualityEnabler(p);
fill(p, pathRound(width), _st.gradientFromLeft); fill(p, pathRound(width), _st.gradientFromLeft);
if (_dynamic) { if (_dynamic) {
p.setFont(st::normalFont); p.setFont(st::normalFont);
@ -888,7 +889,7 @@ void Line::recache(const QSize &s) {
{ {
auto rightPixmap = pixmap(width); auto rightPixmap = pixmap(width);
auto p = Painter(&rightPixmap); auto p = Painter(&rightPixmap);
PainterHighQualityEnabler hq(p); auto hq = PainterHighQualityEnabler(p);
fill(p, pathRound(width), !_st.gradientFromLeft); fill(p, pathRound(width), !_st.gradientFromLeft);
if (_dynamic) { if (_dynamic) {
p.setFont(st::normalFont); p.setFont(st::normalFont);
@ -1027,7 +1028,7 @@ void AddAccountsRow(
badge.fill(Qt::transparent); badge.fill(Qt::transparent);
auto p = QPainter(&badge); auto p = QPainter(&badge);
PainterHighQualityEnabler hq(p); auto hq = PainterHighQualityEnabler(p);
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
const auto rectOut = QRect(QPoint(), size); const auto rectOut = QRect(QPoint(), size);
@ -1302,7 +1303,9 @@ void AddGiftOptions(
int nowIndex = 0; int nowIndex = 0;
Ui::Animations::Simple animation; Ui::Animations::Simple animation;
}; };
const auto wasGroupValue = group->value();
const auto animation = parent->lifetime().make_state<Animation>(); const auto animation = parent->lifetime().make_state<Animation>();
animation->nowIndex = wasGroupValue;
const auto stops = GiftGradientStops(); const auto stops = GiftGradientStops();
@ -1334,6 +1337,7 @@ void AddGiftOptions(
radio->show(); radio->show();
{ // Paint the last frame instantly for the layer animation. { // Paint the last frame instantly for the layer animation.
group->setValue(0); group->setValue(0);
group->setValue(wasGroupValue);
radio->finishAnimating(); radio->finishAnimating();
} }
@ -1369,7 +1373,7 @@ void AddGiftOptions(
row->paintRequest( row->paintRequest(
) | rpl::start_with_next([=](const QRect &r) { ) | rpl::start_with_next([=](const QRect &r) {
auto p = QPainter(row); auto p = QPainter(row);
PainterHighQualityEnabler hq(p); auto hq = PainterHighQualityEnabler(p);
p.fillRect(r, Qt::transparent); p.fillRect(r, Qt::transparent);
@ -1437,11 +1441,7 @@ void AddGiftOptions(
p.setPen(pen); p.setPen(pen);
p.setBrush(Qt::NoBrush); p.setBrush(Qt::NoBrush);
const auto borderRect = row->rect() const auto borderRect = row->rect()
- QMargins( - Margins(pen.width() / 2);
pen.width() / 2,
pen.width() / 2,
pen.width() / 2,
pen.width() / 2);
const auto round = st.borderRadius; const auto round = st.borderRadius;
p.drawRoundedRect(borderRect, round, round); p.drawRoundedRect(borderRect, round, round);
} }