2022-02-22 13:58:55 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/wrap/slide_wrap.h"
|
|
|
|
#include "ui/effects/radial_animation.h"
|
|
|
|
#include "ui/widgets/shadow.h"
|
|
|
|
#include "ui/text/text.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
class RippleButton;
|
|
|
|
|
|
|
|
struct DownloadBarProgress {
|
|
|
|
int64 ready = 0;
|
|
|
|
int64 total = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DownloadBarContent {
|
2022-02-27 14:34:22 +00:00
|
|
|
TextWithEntities singleName;
|
2022-02-22 13:58:55 +00:00
|
|
|
QImage singleThumbnail;
|
|
|
|
int count = 0;
|
|
|
|
int done = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DownloadBar final {
|
|
|
|
public:
|
|
|
|
DownloadBar(
|
|
|
|
not_null<QWidget*> parent,
|
|
|
|
rpl::producer<DownloadBarProgress> progress);
|
|
|
|
~DownloadBar();
|
|
|
|
|
|
|
|
void show(DownloadBarContent &&content);
|
|
|
|
|
|
|
|
[[nodiscard]] bool isHidden() const;
|
|
|
|
[[nodiscard]] int height() const;
|
|
|
|
[[nodiscard]] rpl::producer<int> heightValue() const;
|
|
|
|
[[nodiscard]] rpl::producer<bool> shownValue() const;
|
|
|
|
void setGeometry(int left, int top, int width, int height);
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<> clicks() const;
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::lifetime &lifetime();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void paint(Painter &p, QRect clip);
|
2022-02-27 17:19:16 +00:00
|
|
|
void refreshIcon();
|
2022-03-07 14:10:01 +00:00
|
|
|
void refreshThumbnail();
|
2022-02-22 13:58:55 +00:00
|
|
|
void refreshInfo(const DownloadBarProgress &progress);
|
|
|
|
void radialAnimationCallback(crl::time now);
|
|
|
|
[[nodiscard]] float64 computeProgress() const;
|
|
|
|
|
|
|
|
SlideWrap<RippleButton> _button;
|
|
|
|
PlainShadow _shadow;
|
|
|
|
DownloadBarContent _content;
|
|
|
|
rpl::variable<DownloadBarProgress> _progress;
|
2022-03-07 09:33:29 +00:00
|
|
|
Ui::Animations::Simple _finishedAnimation;
|
|
|
|
bool _finished = false;
|
2022-03-07 14:10:01 +00:00
|
|
|
QImage _documentIconLarge;
|
2022-02-27 17:19:16 +00:00
|
|
|
QImage _documentIcon;
|
|
|
|
QImage _documentIconDone;
|
2022-03-07 14:10:01 +00:00
|
|
|
qint64 _thumbnailCacheKey = 0;
|
|
|
|
QImage _thumbnailLarge;
|
|
|
|
QImage _thumbnail;
|
|
|
|
QImage _thumbnailDone;
|
2022-02-22 13:58:55 +00:00
|
|
|
Text::String _title;
|
|
|
|
Text::String _info;
|
|
|
|
RadialAnimation _radial;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Ui
|