Improve download bar finished state.
This commit is contained in:
parent
7e617b7f39
commit
b90524357e
|
@ -264,6 +264,7 @@ void DownloadManager::addLoaded(
|
|||
.ready = _loadingProgress.current().ready + readyChange,
|
||||
.total = _loadingProgress.current().total + totalChange,
|
||||
};
|
||||
_loadingListChanges.fire({});
|
||||
if (_loading.empty()) {
|
||||
_clearLoadingTimer.callOnce(kClearLoadingTimeout);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,15 @@ void DownloadBar::show(DownloadBarContent &&content) {
|
|||
_radial.start(computeProgress());
|
||||
}
|
||||
_content = content;
|
||||
const auto finished = (_content.done == _content.count);
|
||||
if (_finished != finished) {
|
||||
_finished = finished;
|
||||
_finishedAnimation.start(
|
||||
[=] { _button.update(); },
|
||||
_finished ? 0. : 1.,
|
||||
_finished ? 1. : 0.,
|
||||
st::widgetFadeDuration);
|
||||
}
|
||||
_title.setMarkedText(
|
||||
st::defaultTextStyle,
|
||||
(content.count > 1
|
||||
|
@ -136,6 +145,7 @@ void DownloadBar::paint(Painter &p, QRect clip) {
|
|||
p.fillRect(clip, st::windowBg);
|
||||
button->paintRipple(p, 0, 0);
|
||||
|
||||
const auto finished = _finishedAnimation.value(_finished ? 1. : 0.);
|
||||
const auto size = st::downloadLoadingSize;
|
||||
const auto added = 3 * st::downloadLoadingLine;
|
||||
const auto skipx = st::downloadLoadingLeft;
|
||||
|
@ -151,7 +161,10 @@ void DownloadBar::paint(Painter &p, QRect clip) {
|
|||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::windowBgActive);
|
||||
p.drawEllipse(full.marginsRemoved({ added, added, added, added }));
|
||||
const auto shift = st::downloadLoadingLine
|
||||
+ (1. - finished) * (added - st::downloadLoadingLine);
|
||||
p.drawEllipse(QRectF(full).marginsRemoved(
|
||||
{ shift, shift, shift, shift }));
|
||||
|
||||
if (loading.shown > 0) {
|
||||
p.setOpacity(loading.shown);
|
||||
|
@ -169,10 +182,27 @@ void DownloadBar::paint(Painter &p, QRect clip) {
|
|||
p.setOpacity(1.);
|
||||
}
|
||||
}
|
||||
p.drawImage(
|
||||
full.x() + (full.width() - st::downloadIconSize) / 2,
|
||||
full.y() + (full.height() - st::downloadIconSize) / 2,
|
||||
_documentIcon);
|
||||
const auto sizeLoading = st::downloadIconSize;
|
||||
if (finished == 0. || finished == 1.) {
|
||||
const auto size = (finished == 1.)
|
||||
? st::downloadIconSizeDone
|
||||
: sizeLoading;
|
||||
p.drawImage(
|
||||
full.x() + (full.width() - size) / 2,
|
||||
full.y() + (full.height() - size) / 2,
|
||||
(finished == 1.) ? _documentIconDone : _documentIcon);
|
||||
} else {
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
const auto size = sizeLoading
|
||||
+ (st::downloadIconSizeDone - sizeLoading) * finished;
|
||||
p.drawImage(
|
||||
QRectF(
|
||||
full.x() + (full.width() - size) / 2.,
|
||||
full.y() + (full.height() - size) / 2.,
|
||||
size,
|
||||
size),
|
||||
_documentIconOriginal);
|
||||
}
|
||||
}
|
||||
|
||||
const auto minleft = std::min(
|
||||
|
|
|
@ -58,6 +58,8 @@ private:
|
|||
PlainShadow _shadow;
|
||||
DownloadBarContent _content;
|
||||
rpl::variable<DownloadBarProgress> _progress;
|
||||
Ui::Animations::Simple _finishedAnimation;
|
||||
bool _finished = false;
|
||||
QImage _documentIconOriginal;
|
||||
QImage _documentIcon;
|
||||
QImage _documentIconDone;
|
||||
|
|
Loading…
Reference in New Issue