Files
tdesktop/Telegram/SourceFiles/ui/controls/download_bar.h
allhaileris afb81b8278
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
init
2026-02-16 15:50:16 +03:00

78 lines
1.8 KiB
C++

/*
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 {
TextWithEntities singleName;
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);
void refreshIcon();
void refreshThumbnail();
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;
Ui::Animations::Simple _finishedAnimation;
bool _finished = false;
QImage _documentIconLarge;
QImage _documentIcon;
QImage _documentIconDone;
qint64 _thumbnailCacheKey = 0;
QImage _thumbnailLarge;
QImage _thumbnail;
QImage _thumbnailDone;
Text::String _title;
Text::String _info;
RadialAnimation _radial;
};
} // namespace Ui