2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Moved generic document preview info to separated file.

This commit is contained in:
23rd
2021-07-26 08:38:10 +03:00
parent 6e2f8eb9a7
commit c6071d1148
8 changed files with 168 additions and 134 deletions

View File

@@ -933,9 +933,10 @@ Document::Document(
}),
parent->fullId()))
, _st(st)
, _generic(::Layout::DocumentGenericPreview::Create(_data))
, _date(langDateTime(base::unixtime::parse(_data->date)))
, _datew(st::normalFont->width(_date))
, _colorIndex(documentColorIndex(_data, _ext)) {
, _ext(_generic.ext)
, _datew(st::normalFont->width(_date)) {
_name.setMarkedText(
st::defaultTextStyle,
Ui::Text::FormatSongNameFor(_data).textWithEntities(),
@@ -1110,7 +1111,7 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
p.fillRect(rthumb, st::overviewFileThumbBg);
}
} else {
p.fillRect(rthumb, documentColor(_colorIndex));
p.fillRect(rthumb, _generic.color);
if (!radial && loaded && !_ext.isEmpty()) {
p.setFont(st::overviewFileExtFont);
p.setPen(st::overviewFileExtFg);
@@ -1127,10 +1128,15 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
auto radialOpacity = (radial && loaded && !_data->uploading()) ? _radial->opacity() : 1;
p.setPen(Qt::NoPen);
if (selected) {
p.setBrush(wthumb ? st::msgDateImgBgSelected : documentSelectedColor(_colorIndex));
p.setBrush(wthumb
? st::msgDateImgBgSelected
: _generic.selected);
} else {
auto over = ClickHandler::showAsActive(_data->loading() ? _cancell : _savel);
p.setBrush(anim::brush(wthumb ? st::msgDateImgBg : documentDarkColor(_colorIndex), wthumb ? st::msgDateImgBgOver : documentOverColor(_colorIndex), _a_iconOver.value(over ? 1. : 0.)));
p.setBrush(anim::brush(
wthumb ? st::msgDateImgBg : _generic.dark,
wthumb ? st::msgDateImgBgOver : _generic.over,
_a_iconOver.value(over ? 1. : 0.)));
}
p.setOpacity(radialOpacity * p.opacity());