2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Move inline thumbnail image to DocumentMedia.

This commit is contained in:
John Preston
2020-04-08 19:09:29 +04:00
parent 6ca43153bb
commit bdd3c51ab8
32 changed files with 432 additions and 283 deletions

View File

@@ -437,7 +437,7 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const
ensureDataMediaCreated();
const auto selected = (selection == FullSelection);
const auto blurred = _data->thumbnailInline();
const auto blurred = _dataMedia->thumbnailInline();
const auto thumbLoaded = _data->hasThumbnail()
&& _data->thumbnail()->loaded();
const auto goodLoaded = _dataMedia->goodThumbnail()
@@ -672,10 +672,15 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const
_st.songThumbSize,
_width);
if (clip.intersects(inner)) {
if (_data->hasThumbnail()) {
ensureDataMediaCreated();
}
p.setPen(Qt::NoPen);
const auto thumbLoaded = _data->hasThumbnail()
&& _data->thumbnail()->loaded();
const auto blurred = _data->thumbnailInline();
const auto blurred = _dataMedia
? _dataMedia->thumbnailInline()
: nullptr;
if (thumbLoaded || blurred) {
const auto thumb = thumbLoaded
? _data->thumbnail()->pixCircled(
@@ -826,6 +831,13 @@ TextState Voice::getState(
return result;
}
void Voice::ensureDataMediaCreated() const {
if (_dataMedia) {
return;
}
_dataMedia = _data->createMediaView();
}
float64 Voice::dataProgress() const {
return _data->progress();
}
@@ -1023,8 +1035,9 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
QRect rthumb(style::rtlrect(0, st::linksBorder + _st.filePadding.top(), _st.fileThumbSize, _st.fileThumbSize, _width));
if (clip.intersects(rthumb)) {
if (wthumb) {
ensureDataMediaCreated();
const auto thumbLoaded = _data->thumbnail()->loaded();
const auto blurred = _data->thumbnailInline();
const auto blurred = _dataMedia->thumbnailInline();
if (thumbLoaded || blurred) {
if (_thumb.isNull() || (thumbLoaded && !_thumbLoaded)) {
_thumbLoaded = thumbLoaded;
@@ -1279,6 +1292,13 @@ const style::RoundCheckbox &Document::checkboxStyle() const {
return st::overviewSmallCheck;
}
void Document::ensureDataMediaCreated() const {
if (_dataMedia) {
return;
}
_dataMedia = _data->createMediaView();
}
float64 Document::dataProgress() const {
return _data->progress();
}