mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Show all entries as files in Downloads.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user