mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-27 19:11:09 +00:00
Save frame in GIFs panel.
This commit is contained in:
parent
7d386b164b
commit
c967a72dcb
@ -431,9 +431,14 @@ TabbedSelector::InnerFooter *GifsListWidget::getFooter() const {
|
||||
|
||||
void GifsListWidget::processHideFinished() {
|
||||
clearSelection();
|
||||
clearHeavyData();
|
||||
}
|
||||
|
||||
void GifsListWidget::processPanelHideFinished() {
|
||||
clearHeavyData();
|
||||
}
|
||||
|
||||
void GifsListWidget::clearHeavyData() {
|
||||
const auto itemForget = [](const auto &item) {
|
||||
if (const auto document = item->getDocument()) {
|
||||
document->unload();
|
||||
|
@ -102,6 +102,7 @@ private:
|
||||
InlineResults results;
|
||||
};
|
||||
|
||||
void clearHeavyData();
|
||||
void cancelGifsSearch();
|
||||
void switchToSavedGifs();
|
||||
void refreshSavedGifs();
|
||||
|
@ -163,8 +163,11 @@ void Gif::paint(Painter &p, const QRect &clip, const PaintContext *context) cons
|
||||
|
||||
QRect r(0, 0, _width, height);
|
||||
if (animating) {
|
||||
if (!_thumb.isNull()) _thumb = QPixmap();
|
||||
auto pixmap = _gif->current(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, RectPart::None, context->paused ? 0 : context->ms);
|
||||
const auto pixmap = _gif->current(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, RectPart::None, context->paused ? 0 : context->ms);
|
||||
if (_thumb.isNull()) {
|
||||
_thumb = pixmap;
|
||||
_thumbGood = true;
|
||||
}
|
||||
p.drawPixmap(r.topLeft(), pixmap);
|
||||
} else {
|
||||
prepareThumbnail({ _width, height }, frame);
|
||||
@ -372,15 +375,11 @@ void Gif::radialAnimationCallback(crl::time now) const {
|
||||
}
|
||||
|
||||
void Gif::unloadHeavyPart() {
|
||||
unloadAnimation();
|
||||
_gif.reset();
|
||||
getShownDocument()->unload();
|
||||
_dataMedia = nullptr;
|
||||
}
|
||||
|
||||
void Gif::unloadAnimation() {
|
||||
_gif.reset();
|
||||
}
|
||||
|
||||
void Gif::clipCallback(Media::Clip::Notification notification) {
|
||||
using namespace Media::Clip;
|
||||
switch (notification) {
|
||||
@ -394,14 +393,14 @@ void Gif::clipCallback(Media::Clip::Notification notification) {
|
||||
getShownDocument()->dimensions = QSize(
|
||||
_gif->width(),
|
||||
_gif->height());
|
||||
unloadAnimation();
|
||||
_gif.reset();
|
||||
} else {
|
||||
auto height = st::inlineMediaHeight;
|
||||
auto frame = countFrameSize();
|
||||
_gif->start(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, RectPart::None);
|
||||
}
|
||||
} else if (_gif->autoPausedGif() && !context()->inlineItemVisible(this)) {
|
||||
unloadAnimation();
|
||||
unloadHeavyPart();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1377,9 +1376,12 @@ void Game::paint(Painter &p, const QRect &clip, const PaintContext *context) con
|
||||
radial = isRadialAnimation();
|
||||
|
||||
if (animating) {
|
||||
if (!_thumb.isNull()) _thumb = QPixmap();
|
||||
auto animationThumb = _gif->current(_frameSize.width(), _frameSize.height(), st::inlineThumbSize, st::inlineThumbSize, ImageRoundRadius::None, RectPart::None, context->paused ? 0 : context->ms);
|
||||
p.drawPixmapLeft(rthumb.topLeft(), _width, animationThumb);
|
||||
const auto pixmap = _gif->current(_frameSize.width(), _frameSize.height(), st::inlineThumbSize, st::inlineThumbSize, ImageRoundRadius::None, RectPart::None, context->paused ? 0 : context->ms);
|
||||
if (_thumb.isNull()) {
|
||||
_thumb = pixmap;
|
||||
_thumbGood = true;
|
||||
}
|
||||
p.drawPixmapLeft(rthumb.topLeft(), _width, pixmap);
|
||||
thumbDisplayed = true;
|
||||
}
|
||||
}
|
||||
@ -1518,15 +1520,11 @@ void Game::radialAnimationCallback(crl::time now) const {
|
||||
}
|
||||
|
||||
void Game::unloadHeavyPart() {
|
||||
unloadAnimation();
|
||||
_gif.reset();
|
||||
getResultDocument()->unload();
|
||||
_dataMedia = nullptr;
|
||||
}
|
||||
|
||||
void Game::unloadAnimation() {
|
||||
_gif.reset();
|
||||
}
|
||||
|
||||
void Game::clipCallback(Media::Clip::Notification notification) {
|
||||
using namespace Media::Clip;
|
||||
switch (notification) {
|
||||
@ -1540,7 +1538,7 @@ void Game::clipCallback(Media::Clip::Notification notification) {
|
||||
getResultDocument()->dimensions = QSize(
|
||||
_gif->width(),
|
||||
_gif->height());
|
||||
unloadAnimation();
|
||||
_gif.reset();
|
||||
} else {
|
||||
_gif->start(
|
||||
_frameSize.width(),
|
||||
@ -1551,7 +1549,7 @@ void Game::clipCallback(Media::Clip::Notification notification) {
|
||||
RectPart::None);
|
||||
}
|
||||
} else if (_gif->autoPausedGif() && !context()->inlineItemVisible(this)) {
|
||||
unloadAnimation();
|
||||
unloadHeavyPart();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ private:
|
||||
};
|
||||
|
||||
void ensureDataMediaCreated(not_null<DocumentData*> document) const;
|
||||
void unloadAnimation();
|
||||
QSize countFrameSize() const;
|
||||
|
||||
void validateThumbnail(
|
||||
@ -393,7 +392,6 @@ public:
|
||||
|
||||
private:
|
||||
void ensureDataMediaCreated(not_null<DocumentData*> document) const;
|
||||
void unloadAnimation();
|
||||
void countFrameSize();
|
||||
|
||||
void prepareThumbnail(QSize size) const;
|
||||
|
@ -292,24 +292,26 @@ void Inner::clearSelection() {
|
||||
update();
|
||||
}
|
||||
|
||||
void Inner::hideFinish(bool completely) {
|
||||
if (completely) {
|
||||
const auto unload = [](const auto &item) {
|
||||
if (const auto document = item->getDocument()) {
|
||||
document->unload();
|
||||
}
|
||||
if (const auto photo = item->getPhoto()) {
|
||||
photo->unload();
|
||||
}
|
||||
if (const auto result = item->getResult()) {
|
||||
result->unload();
|
||||
}
|
||||
item->unloadHeavyPart();
|
||||
};
|
||||
clearInlineRows(false);
|
||||
for (const auto &[result, layout] : _inlineLayouts) {
|
||||
unload(layout);
|
||||
void Inner::hideFinished() {
|
||||
clearHeavyData();
|
||||
}
|
||||
|
||||
void Inner::clearHeavyData() {
|
||||
const auto unload = [](const auto &item) {
|
||||
if (const auto document = item->getDocument()) {
|
||||
document->unload();
|
||||
}
|
||||
if (const auto photo = item->getPhoto()) {
|
||||
photo->unload();
|
||||
}
|
||||
if (const auto result = item->getResult()) {
|
||||
result->unload();
|
||||
}
|
||||
item->unloadHeavyPart();
|
||||
};
|
||||
clearInlineRows(false);
|
||||
for (const auto &[result, layout] : _inlineLayouts) {
|
||||
unload(layout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -964,7 +966,7 @@ void Widget::hideFinished() {
|
||||
_controller->disableGifPauseReason(
|
||||
Window::GifPauseReason::InlineResults);
|
||||
|
||||
_inner->hideFinish(true);
|
||||
_inner->hideFinished();
|
||||
_a_show.stop();
|
||||
_showAnimation.reset();
|
||||
_cache = QPixmap();
|
||||
|
@ -61,7 +61,7 @@ class Inner
|
||||
public:
|
||||
Inner(QWidget *parent, not_null<Window::SessionController*> controller);
|
||||
|
||||
void hideFinish(bool completely);
|
||||
void hideFinished();
|
||||
|
||||
void clearSelection();
|
||||
|
||||
@ -121,6 +121,7 @@ private:
|
||||
void updateSelected();
|
||||
void checkRestrictedPeer();
|
||||
bool isRestrictedView();
|
||||
void clearHeavyData();
|
||||
|
||||
void paintInlineItems(Painter &p, const QRect &r);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user