2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "lang.h"
|
|
|
|
|
|
|
|
#include "layerwidget.h"
|
|
|
|
#include "application.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "mainwidget.h"
|
2016-04-07 18:05:28 +00:00
|
|
|
#include "ui/filedialog.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
BackgroundWidget::BackgroundWidget(QWidget *parent, LayeredWidget *w) : TWidget(parent)
|
|
|
|
, w(w)
|
2015-12-08 12:33:37 +00:00
|
|
|
, a_bg(0)
|
|
|
|
, _a_background(animation(this, &BackgroundWidget::step_background))
|
2015-12-07 13:05:00 +00:00
|
|
|
, hiding(false)
|
|
|
|
, shadow(st::boxShadow) {
|
2014-05-30 08:53:19 +00:00
|
|
|
w->setParent(this);
|
2015-10-15 11:51:10 +00:00
|
|
|
if (App::app()) App::app()->mtpPause();
|
2014-05-30 08:53:19 +00:00
|
|
|
setGeometry(0, 0, App::wnd()->width(), App::wnd()->height());
|
2015-12-08 12:33:37 +00:00
|
|
|
a_bg.start(1);
|
|
|
|
_a_background.start();
|
2014-05-30 08:53:19 +00:00
|
|
|
show();
|
|
|
|
connect(w, SIGNAL(closed()), this, SLOT(onInnerClose()));
|
|
|
|
connect(w, SIGNAL(resized()), this, SLOT(update()));
|
2014-12-12 16:27:03 +00:00
|
|
|
connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(boxDestroyed(QObject*)));
|
2014-05-30 08:53:19 +00:00
|
|
|
w->setFocus();
|
|
|
|
}
|
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
void BackgroundWidget::showFast() {
|
2015-12-08 12:33:37 +00:00
|
|
|
_a_background.step(getms() + st::layerSlideDuration + 1);
|
2014-12-12 16:27:03 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void BackgroundWidget::paintEvent(QPaintEvent *e) {
|
2014-12-12 16:27:03 +00:00
|
|
|
if (!w) return;
|
2014-05-30 08:53:19 +00:00
|
|
|
bool trivial = (rect() == e->rect());
|
|
|
|
|
|
|
|
QPainter p(this);
|
|
|
|
if (!trivial) {
|
|
|
|
p.setClipRect(e->rect());
|
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
p.setOpacity(st::layerAlpha * a_bg.current());
|
2015-10-11 08:37:24 +00:00
|
|
|
p.fillRect(rect(), st::layerBg->b);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
p.setOpacity(a_bg.current());
|
2015-10-01 14:05:05 +00:00
|
|
|
shadow.paint(p, w->geometry(), st::boxShadowShift);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BackgroundWidget::keyPressEvent(QKeyEvent *e) {
|
|
|
|
if (e->key() == Qt::Key_Escape) {
|
2015-10-15 11:51:10 +00:00
|
|
|
onClose();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BackgroundWidget::mousePressEvent(QMouseEvent *e) {
|
2014-10-10 12:46:20 +00:00
|
|
|
onClose();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BackgroundWidget::onClose() {
|
|
|
|
startHide();
|
|
|
|
}
|
|
|
|
|
2014-11-25 12:15:29 +00:00
|
|
|
bool BackgroundWidget::onInnerClose() {
|
2015-09-16 13:04:08 +00:00
|
|
|
if (_hidden.isEmpty()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
onClose();
|
2014-11-25 12:15:29 +00:00
|
|
|
return true;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-11-24 11:23:14 +00:00
|
|
|
w->hide();
|
2014-11-25 12:15:29 +00:00
|
|
|
w->deleteLater();
|
2015-09-16 13:04:08 +00:00
|
|
|
w = _hidden.back();
|
|
|
|
_hidden.pop_back();
|
2014-11-25 12:15:29 +00:00
|
|
|
w->show();
|
|
|
|
resizeEvent(0);
|
2015-12-08 12:33:37 +00:00
|
|
|
w->showStep(1);
|
2014-11-25 12:15:29 +00:00
|
|
|
update();
|
|
|
|
return false;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BackgroundWidget::startHide() {
|
2015-09-16 13:04:08 +00:00
|
|
|
if (hiding) return;
|
2015-10-15 11:51:10 +00:00
|
|
|
if (App::app()) App::app()->mtpPause();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
hiding = true;
|
2015-09-16 13:04:08 +00:00
|
|
|
if (App::wnd()) App::wnd()->setInnerFocus();
|
2015-12-08 12:33:37 +00:00
|
|
|
a_bg.start(0);
|
|
|
|
_a_background.start();
|
2014-05-30 08:53:19 +00:00
|
|
|
w->startHide();
|
|
|
|
}
|
|
|
|
|
2015-09-16 13:04:08 +00:00
|
|
|
bool BackgroundWidget::canSetFocus() const {
|
|
|
|
return w && !hiding;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BackgroundWidget::setInnerFocus() {
|
|
|
|
if (w) {
|
|
|
|
w->setInnerFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-01 14:05:05 +00:00
|
|
|
bool BackgroundWidget::contentOverlapped(const QRect &globalRect) {
|
|
|
|
if (isHidden()) return false;
|
|
|
|
return w && w->overlaps(globalRect);
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void BackgroundWidget::resizeEvent(QResizeEvent *e) {
|
|
|
|
w->parentResized();
|
|
|
|
}
|
|
|
|
|
2016-02-08 14:54:55 +00:00
|
|
|
void BackgroundWidget::updateAdaptiveLayout() {
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void BackgroundWidget::replaceInner(LayeredWidget *n) {
|
2015-09-16 13:04:08 +00:00
|
|
|
_hidden.push_back(w);
|
|
|
|
w->hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
w = n;
|
|
|
|
w->setParent(this);
|
|
|
|
connect(w, SIGNAL(closed()), this, SLOT(onInnerClose()));
|
|
|
|
connect(w, SIGNAL(resized()), this, SLOT(update()));
|
2014-12-12 16:27:03 +00:00
|
|
|
connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(boxDestroyed(QObject*)));
|
2014-05-30 08:53:19 +00:00
|
|
|
w->show();
|
|
|
|
resizeEvent(0);
|
2015-12-08 12:33:37 +00:00
|
|
|
w->showStep(1);
|
2014-05-30 08:53:19 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-10-27 02:39:02 +00:00
|
|
|
void BackgroundWidget::showLayerLast(LayeredWidget *n) {
|
|
|
|
_hidden.push_front(n);
|
|
|
|
n->setParent(this);
|
|
|
|
connect(n, SIGNAL(closed()), this, SLOT(onInnerClose()));
|
|
|
|
connect(n, SIGNAL(resized()), this, SLOT(update()));
|
|
|
|
connect(n, SIGNAL(destroyed(QObject*)), this, SLOT(boxDestroyed(QObject*)));
|
|
|
|
n->parentResized();
|
2015-12-08 12:33:37 +00:00
|
|
|
n->showStep(1);
|
2015-10-27 02:39:02 +00:00
|
|
|
n->hide();
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void BackgroundWidget::step_background(float64 ms, bool timer) {
|
2014-05-30 08:53:19 +00:00
|
|
|
float64 dt = ms / (hiding ? st::layerHideDuration : st::layerSlideDuration);
|
2015-12-08 12:33:37 +00:00
|
|
|
w->showStep(dt);
|
2014-05-30 08:53:19 +00:00
|
|
|
if (dt >= 1) {
|
2015-12-08 12:33:37 +00:00
|
|
|
a_bg.finish();
|
2014-05-30 08:53:19 +00:00
|
|
|
if (hiding) {
|
2014-12-12 16:27:03 +00:00
|
|
|
App::wnd()->layerFinishedHide(this);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
_a_background.stop();
|
2015-10-15 11:51:10 +00:00
|
|
|
if (App::app()) App::app()->mtpUnpause();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2015-12-08 12:33:37 +00:00
|
|
|
a_bg.update(dt, anim::easeOutCirc);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
if (timer) update();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
void BackgroundWidget::boxDestroyed(QObject *obj) {
|
|
|
|
if (obj == w) {
|
|
|
|
if (App::wnd()) App::wnd()->layerFinishedHide(this);
|
|
|
|
w = 0;
|
2015-09-16 13:04:08 +00:00
|
|
|
} else {
|
|
|
|
int32 index = _hidden.indexOf(static_cast<LayeredWidget*>(obj));
|
|
|
|
if (index >= 0) {
|
|
|
|
_hidden.removeAt(index);
|
|
|
|
}
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
BackgroundWidget::~BackgroundWidget() {
|
|
|
|
if (App::wnd()) App::wnd()->noBox(this);
|
|
|
|
w->deleteLater();
|
2015-09-16 13:04:08 +00:00
|
|
|
for (HiddenLayers::const_iterator i = _hidden.cbegin(), e = _hidden.cend(); i != e; ++i) {
|
|
|
|
(*i)->deleteLater();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
MediaPreviewWidget::MediaPreviewWidget(QWidget *parent) : TWidget(parent)
|
2015-12-07 13:05:00 +00:00
|
|
|
, a_shown(0, 0)
|
2016-04-10 18:18:26 +00:00
|
|
|
, _a_shown(animation(this, &MediaPreviewWidget::step_shown)) {
|
2015-12-07 13:05:00 +00:00
|
|
|
setAttribute(Qt::WA_TransparentForMouseEvents);
|
2016-03-03 18:37:15 +00:00
|
|
|
connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update()));
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
void MediaPreviewWidget::paintEvent(QPaintEvent *e) {
|
2015-12-07 13:05:00 +00:00
|
|
|
Painter p(this);
|
|
|
|
QRect r(e->rect());
|
|
|
|
|
|
|
|
const QPixmap &draw(currentImage());
|
|
|
|
uint32 w = draw.width() / cIntRetinaFactor(), h = draw.height() / cIntRetinaFactor();
|
|
|
|
if (_a_shown.animating()) {
|
|
|
|
float64 shown = a_shown.current();
|
|
|
|
p.setOpacity(shown);
|
|
|
|
// w = qMax(qRound(w * (st::stickerPreviewMin + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2 + int(w % 2), 1);
|
|
|
|
// h = qMax(qRound(h * (st::stickerPreviewMin + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2 + int(h % 2), 1);
|
|
|
|
}
|
|
|
|
p.fillRect(r, st::stickerPreviewBg);
|
|
|
|
p.drawPixmap((width() - w) / 2, (height() - h) / 2, draw);
|
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
void MediaPreviewWidget::resizeEvent(QResizeEvent *e) {
|
2015-12-07 13:05:00 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
void MediaPreviewWidget::step_shown(float64 ms, bool timer) {
|
2015-12-07 13:05:00 +00:00
|
|
|
float64 dt = ms / st::stickerPreviewDuration;
|
|
|
|
if (dt >= 1) {
|
|
|
|
_a_shown.stop();
|
2015-12-08 12:33:37 +00:00
|
|
|
a_shown.finish();
|
2015-12-07 13:05:00 +00:00
|
|
|
if (a_shown.current() < 0.5) hide();
|
|
|
|
} else {
|
|
|
|
a_shown.update(dt, anim::linear);
|
|
|
|
}
|
2015-12-08 12:33:37 +00:00
|
|
|
if (timer) update();
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
void MediaPreviewWidget::showPreview(DocumentData *document) {
|
|
|
|
if (!document || (!document->isAnimation() && !document->sticker())) {
|
|
|
|
hidePreview();
|
2015-12-07 13:05:00 +00:00
|
|
|
return;
|
2016-04-10 18:18:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
startShow();
|
|
|
|
_photo = nullptr;
|
|
|
|
_document = document;
|
|
|
|
resetGifAndCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MediaPreviewWidget::showPreview(PhotoData *photo) {
|
|
|
|
if (!photo || photo->full->isNull()) {
|
|
|
|
hidePreview();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
startShow();
|
|
|
|
_photo = photo;
|
|
|
|
_document = nullptr;
|
|
|
|
resetGifAndCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MediaPreviewWidget::startShow() {
|
|
|
|
_cache = QPixmap();
|
|
|
|
if (isHidden() || _a_shown.animating()) {
|
|
|
|
if (isHidden()) show();
|
|
|
|
a_shown.start(1);
|
2015-12-07 13:05:00 +00:00
|
|
|
_a_shown.start();
|
2016-04-10 18:18:26 +00:00
|
|
|
} else {
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MediaPreviewWidget::hidePreview() {
|
|
|
|
if (isHidden()) {
|
|
|
|
return;
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
if (_gif) _cache = currentImage();
|
|
|
|
a_shown.start(0);
|
|
|
|
_a_shown.start();
|
|
|
|
_photo = nullptr;
|
|
|
|
_document = nullptr;
|
|
|
|
resetGifAndCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MediaPreviewWidget::resetGifAndCache() {
|
2015-12-27 21:37:48 +00:00
|
|
|
if (_gif) {
|
|
|
|
if (gif()) {
|
|
|
|
delete _gif;
|
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
_gif = nullptr;
|
2015-12-27 21:37:48 +00:00
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
_cacheStatus = CacheNotLoaded;
|
2016-04-10 18:18:26 +00:00
|
|
|
_cachedSize = QSize();
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
QSize MediaPreviewWidget::currentDimensions() const {
|
|
|
|
if (!_cachedSize.isEmpty()) {
|
|
|
|
return _cachedSize;
|
|
|
|
}
|
|
|
|
if (!_document && !_photo) {
|
|
|
|
_cachedSize = QSize(_cache.width() / cIntRetinaFactor(), _cache.height() / cIntRetinaFactor());
|
|
|
|
return _cachedSize;
|
|
|
|
}
|
2015-12-07 13:05:00 +00:00
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
QSize result, box;
|
|
|
|
if (_photo) {
|
|
|
|
result = QSize(_photo->full->width(), _photo->full->height());
|
|
|
|
box = QSize(width() - 2 * st::boxVerticalMargin, height() - 2 * st::boxVerticalMargin);
|
|
|
|
} else {
|
|
|
|
result = _document->dimensions;
|
|
|
|
if (gif() && _gif->ready()) {
|
|
|
|
result = QSize(_gif->width(), _gif->height());
|
|
|
|
}
|
|
|
|
if (_document->sticker()) {
|
|
|
|
box = QSize(st::maxStickerSize, st::maxStickerSize);
|
|
|
|
} else {
|
|
|
|
box = QSize(2 * st::maxStickerSize, 2 * st::maxStickerSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = QSize(qMax(convertScale(result.width()), 1), qMax(convertScale(result.height()), 1));
|
|
|
|
if (result.width() > box.width()) {
|
|
|
|
result.setHeight(qMax((box.width() * result.height()) / result.width(), 1));
|
|
|
|
result.setWidth(box.width());
|
2015-12-27 21:37:48 +00:00
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
if (result.height() > box.height()) {
|
|
|
|
result.setWidth(qMax((box.height() * result.width()) / result.height(), 1));
|
|
|
|
result.setHeight(box.height());
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
if (_photo) {
|
|
|
|
_cachedSize = result;
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
QPixmap MediaPreviewWidget::currentImage() const {
|
|
|
|
if (_document) {
|
|
|
|
if (_document->sticker()) {
|
2015-12-27 21:37:48 +00:00
|
|
|
if (_cacheStatus != CacheLoaded) {
|
2016-04-10 18:18:26 +00:00
|
|
|
_document->checkSticker();
|
|
|
|
if (_document->sticker()->img->isNull()) {
|
|
|
|
if (_cacheStatus != CacheThumbLoaded && _document->thumb->loaded()) {
|
2015-12-27 21:37:48 +00:00
|
|
|
QSize s = currentDimensions();
|
2016-04-10 18:18:26 +00:00
|
|
|
_cache = _document->thumb->pixBlurred(s.width(), s.height());
|
2015-12-27 21:37:48 +00:00
|
|
|
_cacheStatus = CacheThumbLoaded;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
QSize s = currentDimensions();
|
2016-04-10 18:18:26 +00:00
|
|
|
_cache = _document->sticker()->img->pix(s.width(), s.height());
|
2015-12-27 21:37:48 +00:00
|
|
|
_cacheStatus = CacheLoaded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2016-04-10 18:18:26 +00:00
|
|
|
_document->automaticLoad(nullptr);
|
|
|
|
if (_document->loaded()) {
|
2015-12-27 21:37:48 +00:00
|
|
|
if (!_gif && _gif != BadClipReader) {
|
2016-04-10 18:18:26 +00:00
|
|
|
MediaPreviewWidget *that = const_cast<MediaPreviewWidget*>(this);
|
|
|
|
that->_gif = new ClipReader(_document->location(), _document->data(), func(that, &MediaPreviewWidget::clipCallback));
|
2015-12-27 21:37:48 +00:00
|
|
|
if (gif()) _gif->setAutoplay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gif() && _gif->started()) {
|
|
|
|
QSize s = currentDimensions();
|
|
|
|
return _gif->current(s.width(), s.height(), s.width(), s.height(), getms());
|
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
if (_cacheStatus != CacheThumbLoaded && _document->thumb->loaded()) {
|
2015-12-07 13:05:00 +00:00
|
|
|
QSize s = currentDimensions();
|
2016-04-10 18:18:26 +00:00
|
|
|
_cache = _document->thumb->pixBlurred(s.width(), s.height());
|
2015-12-07 13:05:00 +00:00
|
|
|
_cacheStatus = CacheThumbLoaded;
|
|
|
|
}
|
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
} else if (_photo) {
|
|
|
|
if (_cacheStatus != CacheLoaded) {
|
|
|
|
if (_photo->full->loaded()) {
|
|
|
|
QSize s = currentDimensions();
|
|
|
|
LOG(("DIMENSIONS: %1 %2").arg(s.width()).arg(s.height()));
|
|
|
|
_cache = _photo->full->pix(s.width(), s.height());
|
|
|
|
_cacheStatus = CacheLoaded;
|
|
|
|
} else {
|
|
|
|
if (_cacheStatus != CacheThumbLoaded && _photo->thumb->loaded()) {
|
|
|
|
QSize s = currentDimensions();
|
|
|
|
LOG(("DIMENSIONS: %1 %2").arg(s.width()).arg(s.height()));
|
|
|
|
_cache = _photo->thumb->pixBlurred(s.width(), s.height());
|
|
|
|
_cacheStatus = CacheThumbLoaded;
|
|
|
|
}
|
|
|
|
_photo->thumb->load();
|
|
|
|
_photo->full->load();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|
|
|
|
return _cache;
|
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
void MediaPreviewWidget::clipCallback(ClipReaderNotification notification) {
|
2015-12-27 21:37:48 +00:00
|
|
|
switch (notification) {
|
|
|
|
case ClipReaderReinit: {
|
|
|
|
if (gif() && _gif->state() == ClipError) {
|
|
|
|
delete _gif;
|
|
|
|
_gif = BadClipReader;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gif() && _gif->ready() && !_gif->started()) {
|
|
|
|
QSize s = currentDimensions();
|
|
|
|
_gif->start(s.width(), s.height(), s.width(), s.height(), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
update();
|
|
|
|
} break;
|
|
|
|
|
2015-12-28 21:20:04 +00:00
|
|
|
case ClipReaderRepaint: {
|
|
|
|
if (gif() && !_gif->currentDisplayed()) {
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
} break;
|
2015-12-27 21:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
MediaPreviewWidget::~MediaPreviewWidget() {
|
2015-12-07 13:05:00 +00:00
|
|
|
}
|