mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Show all entries as files in Downloads.
This commit is contained in:
parent
e89c95551f
commit
147d2e1934
6 changed files with 40 additions and 9 deletions
|
@ -242,6 +242,13 @@ void DownloadManager::addLoaded(
|
|||
}
|
||||
}
|
||||
|
||||
void DownloadManager::clearIfFinished() {
|
||||
if (_clearLoadingTimer.isActive()) {
|
||||
_clearLoadingTimer.cancel();
|
||||
clearLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadManager::deleteFiles(const std::vector<GlobalMsgId> &ids) {
|
||||
struct DocumentDescriptor {
|
||||
uint64 sessionUniqueId = 0;
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
const QString &path,
|
||||
DownloadDate started);
|
||||
|
||||
void clearIfFinished();
|
||||
void deleteFiles(const std::vector<GlobalMsgId> &ids);
|
||||
|
||||
[[nodiscard]] auto loadingList() const
|
||||
|
|
|
@ -433,6 +433,9 @@ void Widget::setupDownloadBar() {
|
|||
_downloadBar->clicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto &&list = Core::App().downloadManager().loadingList();
|
||||
const auto guard = gsl::finally([] {
|
||||
Core::App().downloadManager().clearIfFinished();
|
||||
});
|
||||
auto first = (HistoryItem*)nullptr;
|
||||
for (const auto id : list) {
|
||||
if (!first) {
|
||||
|
|
|
@ -329,6 +329,7 @@ std::unique_ptr<BaseLayout> Provider::createLayout(
|
|||
DocumentFields{
|
||||
.document = file,
|
||||
.dateOverride = Data::DateFromDownloadDate(element.started),
|
||||
.forceFileLayout = true,
|
||||
},
|
||||
songSt);
|
||||
}
|
||||
|
|
|
@ -933,6 +933,7 @@ Document::Document(
|
|||
parent->fullId()))
|
||||
, _st(st)
|
||||
, _generic(::Layout::DocumentGenericPreview::Create(_data))
|
||||
, _forceFileLayout(fields.forceFileLayout)
|
||||
, _date(langDateTime(base::unixtime::parse(fields.dateOverride
|
||||
? fields.dateOverride
|
||||
: _data->date)))
|
||||
|
@ -940,14 +941,20 @@ Document::Document(
|
|||
, _datew(st::normalFont->width(_date)) {
|
||||
_name.setMarkedText(
|
||||
st::defaultTextStyle,
|
||||
Ui::Text::FormatSongNameFor(_data).textWithEntities(),
|
||||
(_forceFileLayout
|
||||
? TextWithEntities{ _data->filename() }
|
||||
: Ui::Text::FormatSongNameFor(_data).textWithEntities()),
|
||||
_documentNameOptions);
|
||||
|
||||
AddComponents(Info::Bit());
|
||||
|
||||
setDocumentLinks(_data);
|
||||
|
||||
_status.update(Ui::FileStatusSizeReady, _data->size, _data->isSong() ? _data->song()->duration : -1, 0);
|
||||
_status.update(
|
||||
Ui::FileStatusSizeReady,
|
||||
_data->size,
|
||||
songLayout() ? _data->song()->duration : -1,
|
||||
0);
|
||||
|
||||
if (withThumb()) {
|
||||
_data->loadThumbnail(parent->fullId());
|
||||
|
@ -978,7 +985,7 @@ bool Document::downloadInCorner() const {
|
|||
|
||||
void Document::initDimensions() {
|
||||
_maxw = _st.maxWidth;
|
||||
if (_data->isSong()) {
|
||||
if (songLayout()) {
|
||||
_minh = _st.songPadding.top() + _st.songThumbSize + _st.songPadding.bottom();
|
||||
} else {
|
||||
_minh = _st.filePadding.top() + _st.fileThumbSize + _st.filePadding.bottom() + st::lineWidth;
|
||||
|
@ -1008,7 +1015,7 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
|
|||
int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, datetop = -1;
|
||||
const auto wthumb = withThumb();
|
||||
|
||||
const auto isSong = _data->isSong();
|
||||
const auto isSong = songLayout();
|
||||
if (isSong) {
|
||||
nameleft = _st.songPadding.left() + _st.songThumbSize + _st.songPadding.right();
|
||||
nameright = _st.songPadding.left();
|
||||
|
@ -1268,7 +1275,7 @@ TextState Document::getState(
|
|||
ensureDataMediaCreated();
|
||||
const auto loaded = dataLoaded();
|
||||
|
||||
if (_data->isSong()) {
|
||||
if (songLayout()) {
|
||||
const auto nameleft = _st.songPadding.left() + _st.songThumbSize + _st.songPadding.right();
|
||||
const auto nameright = _st.songPadding.left();
|
||||
const auto namewidth = std::min(
|
||||
|
@ -1368,6 +1375,10 @@ const style::RoundCheckbox &Document::checkboxStyle() const {
|
|||
return st::overviewSmallCheck;
|
||||
}
|
||||
|
||||
bool Document::songLayout() const {
|
||||
return !_forceFileLayout && _data->isSong();
|
||||
}
|
||||
|
||||
void Document::ensureDataMediaCreated() const {
|
||||
if (_dataMedia) {
|
||||
return;
|
||||
|
@ -1396,13 +1407,13 @@ bool Document::dataLoaded() const {
|
|||
}
|
||||
|
||||
bool Document::iconAnimated() const {
|
||||
return _data->isSong()
|
||||
return songLayout()
|
||||
|| !dataLoaded()
|
||||
|| (_radial && _radial->animating());
|
||||
}
|
||||
|
||||
bool Document::withThumb() const {
|
||||
return !_data->isSong()
|
||||
return !songLayout()
|
||||
&& _data->hasThumbnail()
|
||||
&& !Data::IsExecutableName(_data->filename());
|
||||
}
|
||||
|
@ -1423,7 +1434,8 @@ bool Document::updateStatusText() {
|
|||
statusSize = Ui::FileStatusSizeReady;
|
||||
}
|
||||
|
||||
if (_data->isSong()) {
|
||||
const auto isSong = songLayout();
|
||||
if (isSong) {
|
||||
const auto state = Media::Player::instance()->getState(AudioMsgId::Type::Song);
|
||||
if (state.id == AudioMsgId(_data, parent()->fullId(), state.id.externalPlayId()) && !Media::Player::IsStoppedOrStopping(state.state)) {
|
||||
statusSize = -1 - (state.position / state.frequency);
|
||||
|
@ -1436,7 +1448,11 @@ bool Document::updateStatusText() {
|
|||
}
|
||||
|
||||
if (statusSize != _status.size()) {
|
||||
_status.update(statusSize, _data->size, _data->isSong() ? _data->song()->duration : -1, realDuration);
|
||||
_status.update(
|
||||
statusSize,
|
||||
_data->size,
|
||||
isSong ? _data->song()->duration : -1,
|
||||
realDuration);
|
||||
}
|
||||
return showPause;
|
||||
}
|
||||
|
|
|
@ -338,6 +338,7 @@ private:
|
|||
struct DocumentFields {
|
||||
not_null<DocumentData*> document;
|
||||
TimeId dateOverride = 0;
|
||||
bool forceFileLayout = false;
|
||||
};
|
||||
class Document final : public RadialProgressItem {
|
||||
public:
|
||||
|
@ -369,6 +370,7 @@ private:
|
|||
QPoint point,
|
||||
StateRequest request) const;
|
||||
|
||||
[[nodiscard]] bool songLayout() const;
|
||||
void ensureDataMediaCreated() const;
|
||||
|
||||
not_null<DocumentData*> _data;
|
||||
|
@ -380,6 +382,7 @@ private:
|
|||
const ::Layout::DocumentGenericPreview _generic;
|
||||
|
||||
bool _thumbLoaded = false;
|
||||
bool _forceFileLayout = false;
|
||||
QPixmap _thumb;
|
||||
|
||||
Ui::Text::String _name;
|
||||
|
|
Loading…
Add table
Reference in a new issue