mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Fixed display of last frame of voice messages in media viewer with ttl.
This commit is contained in:
parent
2a81a617e1
commit
53e95a7f74
1 changed files with 31 additions and 10 deletions
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_theme.h"
|
#include "ui/chat/chat_theme.h"
|
||||||
#include "ui/effects/path_shift_gradient.h"
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/rect.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
@ -96,6 +97,11 @@ private:
|
||||||
std::unique_ptr<HistoryView::Element> _element;
|
std::unique_ptr<HistoryView::Element> _element;
|
||||||
rpl::lifetime _elementLifetime;
|
rpl::lifetime _elementLifetime;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
QImage frame;
|
||||||
|
bool use = false;
|
||||||
|
} _last;
|
||||||
|
|
||||||
rpl::event_stream<> _closeRequests;
|
rpl::event_stream<> _closeRequests;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -200,7 +206,10 @@ PreviewWrap::PreviewWrap(
|
||||||
|
|
||||||
HistoryView::TTLVoiceStops(
|
HistoryView::TTLVoiceStops(
|
||||||
item->fullId()
|
item->fullId()
|
||||||
) | rpl::start_with_next(closeCallback, lifetime());
|
) | rpl::start_with_next([=] {
|
||||||
|
_last.use = true;
|
||||||
|
closeCallback();
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect PreviewWrap::elementRect() const {
|
QRect PreviewWrap::elementRect() const {
|
||||||
|
@ -225,20 +234,32 @@ void PreviewWrap::paintEvent(QPaintEvent *e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto p = Painter(this);
|
auto p = QPainter(this);
|
||||||
const auto r = rect();
|
const auto r = rect();
|
||||||
|
|
||||||
|
if (!_last.use) {
|
||||||
|
const auto size = _element->currentSize();
|
||||||
|
auto result = QImage(
|
||||||
|
size * style::DevicePixelRatio(),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
result.fill(Qt::transparent);
|
||||||
|
result.setDevicePixelRatio(style::DevicePixelRatio());
|
||||||
|
{
|
||||||
|
auto q = Painter(&result);
|
||||||
auto context = _theme->preparePaintContext(
|
auto context = _theme->preparePaintContext(
|
||||||
_style.get(),
|
_style.get(),
|
||||||
r,
|
Rect(size),
|
||||||
e->rect(),
|
Rect(size),
|
||||||
!window()->isActiveWindow());
|
!window()->isActiveWindow());
|
||||||
context.outbg = _element->hasOutLayout();
|
context.outbg = _element->hasOutLayout();
|
||||||
|
_element->draw(q, context);
|
||||||
|
}
|
||||||
|
_last.frame = std::move(result);
|
||||||
|
}
|
||||||
p.translate(
|
p.translate(
|
||||||
(r.width() - _element->width()) / 2,
|
(r.width() - _element->width()) / 2,
|
||||||
(r.height() - _element->height()) / 2);
|
(r.height() - _element->height()) / 2);
|
||||||
_element->draw(p, context);
|
p.drawImage(0, 0, _last.frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Add table
Reference in a new issue