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