mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Improve download bar finished state.
This commit is contained in:
parent
7e617b7f39
commit
b90524357e
3 changed files with 38 additions and 5 deletions
|
@ -264,6 +264,7 @@ void DownloadManager::addLoaded(
|
||||||
.ready = _loadingProgress.current().ready + readyChange,
|
.ready = _loadingProgress.current().ready + readyChange,
|
||||||
.total = _loadingProgress.current().total + totalChange,
|
.total = _loadingProgress.current().total + totalChange,
|
||||||
};
|
};
|
||||||
|
_loadingListChanges.fire({});
|
||||||
if (_loading.empty()) {
|
if (_loading.empty()) {
|
||||||
_clearLoadingTimer.callOnce(kClearLoadingTimeout);
|
_clearLoadingTimer.callOnce(kClearLoadingTimeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,15 @@ void DownloadBar::show(DownloadBarContent &&content) {
|
||||||
_radial.start(computeProgress());
|
_radial.start(computeProgress());
|
||||||
}
|
}
|
||||||
_content = content;
|
_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(
|
_title.setMarkedText(
|
||||||
st::defaultTextStyle,
|
st::defaultTextStyle,
|
||||||
(content.count > 1
|
(content.count > 1
|
||||||
|
@ -136,6 +145,7 @@ void DownloadBar::paint(Painter &p, QRect clip) {
|
||||||
p.fillRect(clip, st::windowBg);
|
p.fillRect(clip, st::windowBg);
|
||||||
button->paintRipple(p, 0, 0);
|
button->paintRipple(p, 0, 0);
|
||||||
|
|
||||||
|
const auto finished = _finishedAnimation.value(_finished ? 1. : 0.);
|
||||||
const auto size = st::downloadLoadingSize;
|
const auto size = st::downloadLoadingSize;
|
||||||
const auto added = 3 * st::downloadLoadingLine;
|
const auto added = 3 * st::downloadLoadingLine;
|
||||||
const auto skipx = st::downloadLoadingLeft;
|
const auto skipx = st::downloadLoadingLeft;
|
||||||
|
@ -151,7 +161,10 @@ void DownloadBar::paint(Painter &p, QRect clip) {
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(st::windowBgActive);
|
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) {
|
if (loading.shown > 0) {
|
||||||
p.setOpacity(loading.shown);
|
p.setOpacity(loading.shown);
|
||||||
|
@ -169,10 +182,27 @@ void DownloadBar::paint(Painter &p, QRect clip) {
|
||||||
p.setOpacity(1.);
|
p.setOpacity(1.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const auto sizeLoading = st::downloadIconSize;
|
||||||
|
if (finished == 0. || finished == 1.) {
|
||||||
|
const auto size = (finished == 1.)
|
||||||
|
? st::downloadIconSizeDone
|
||||||
|
: sizeLoading;
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
full.x() + (full.width() - st::downloadIconSize) / 2,
|
full.x() + (full.width() - size) / 2,
|
||||||
full.y() + (full.height() - st::downloadIconSize) / 2,
|
full.y() + (full.height() - size) / 2,
|
||||||
_documentIcon);
|
(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(
|
const auto minleft = std::min(
|
||||||
|
|
|
@ -58,6 +58,8 @@ private:
|
||||||
PlainShadow _shadow;
|
PlainShadow _shadow;
|
||||||
DownloadBarContent _content;
|
DownloadBarContent _content;
|
||||||
rpl::variable<DownloadBarProgress> _progress;
|
rpl::variable<DownloadBarProgress> _progress;
|
||||||
|
Ui::Animations::Simple _finishedAnimation;
|
||||||
|
bool _finished = false;
|
||||||
QImage _documentIconOriginal;
|
QImage _documentIconOriginal;
|
||||||
QImage _documentIcon;
|
QImage _documentIcon;
|
||||||
QImage _documentIconDone;
|
QImage _documentIconDone;
|
||||||
|
|
Loading…
Add table
Reference in a new issue