mirror of https://github.com/procxx/kepka.git
webpage attachs redesigned
This commit is contained in:
parent
840ffa6482
commit
11da39b72d
|
@ -2444,8 +2444,8 @@ namespace App {
|
||||||
void stopGifItems() {
|
void stopGifItems() {
|
||||||
if (!::gifItems.isEmpty()) {
|
if (!::gifItems.isEmpty()) {
|
||||||
if (HistoryItem *playing = ::gifItems.begin().value()) {
|
if (HistoryItem *playing = ::gifItems.begin().value()) {
|
||||||
if (playing->getMedia() && playing->getMedia()->type() == MediaTypeGif) {
|
if (playing->getMedia()) {
|
||||||
static_cast<HistoryGif*>(playing->getMedia())->stop(playing);
|
playing->getMedia()->stopInline(playing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,12 +482,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readNextFrame(QImage &to) {
|
bool readNextFrame(QImage &to) {
|
||||||
|
if (_reader) _frameDelay = _reader->nextImageDelay();
|
||||||
if (_framesLeft < 1 && !jumpToStart()) {
|
if (_framesLeft < 1 && !jumpToStart()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_frameDelay = _reader->nextImageDelay();
|
|
||||||
|
|
||||||
QImage frame; // QGifHandler always reads first to internal QImage and returns it
|
QImage frame; // QGifHandler always reads first to internal QImage and returns it
|
||||||
if (!_reader->read(&frame)) {
|
if (!_reader->read(&frame)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -655,20 +654,17 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int64 duration = av_frame_get_pkt_duration(_frame);
|
int64 duration = av_frame_get_pkt_duration(_frame);
|
||||||
|
int64 framePts = (_frame->pkt_pts == AV_NOPTS_VALUE) ? _frame->pkt_dts : _frame->pkt_pts;
|
||||||
|
int64 frameMs = (framePts * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den;
|
||||||
|
_currentFrameDelay = _nextFrameDelay;
|
||||||
|
if (_frameMs + _currentFrameDelay < frameMs) {
|
||||||
|
_currentFrameDelay = int32(frameMs - _frameMs);
|
||||||
|
}
|
||||||
|
_frameMs = frameMs;
|
||||||
if (duration == AV_NOPTS_VALUE) {
|
if (duration == AV_NOPTS_VALUE) {
|
||||||
int64 framePts = (_frame->pkt_pts == AV_NOPTS_VALUE) ? _frame->pkt_dts : _frame->pkt_pts;
|
_nextFrameDelay = 0;
|
||||||
int64 frameMs = (framePts * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den;
|
|
||||||
if (frameMs > _frameMs) {
|
|
||||||
_currentFrameDelay = int32(frameMs - _frameMs);
|
|
||||||
_frameMs = frameMs;
|
|
||||||
} else {
|
|
||||||
_currentFrameDelay = 0;
|
|
||||||
}
|
|
||||||
_nextFrameDelay = _currentFrameDelay;
|
|
||||||
} else {
|
} else {
|
||||||
_currentFrameDelay = _nextFrameDelay;
|
|
||||||
_nextFrameDelay = (duration * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den;
|
_nextFrameDelay = (duration * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den;
|
||||||
_frameMs += _nextFrameDelay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
av_frame_unref(_frame);
|
av_frame_unref(_frame);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1176,6 +1176,16 @@ public:
|
||||||
}
|
}
|
||||||
virtual HistoryMedia *clone() const = 0;
|
virtual HistoryMedia *clone() const = 0;
|
||||||
|
|
||||||
|
virtual DocumentData *getDocument() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool playInline(HistoryItem *item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual void stopInline(HistoryItem *item) {
|
||||||
|
}
|
||||||
|
|
||||||
virtual void regItem(HistoryItem *item) {
|
virtual void regItem(HistoryItem *item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1204,6 +1214,9 @@ public:
|
||||||
}
|
}
|
||||||
virtual bool needsBubble(const HistoryItem *parent) const = 0;
|
virtual bool needsBubble(const HistoryItem *parent) const = 0;
|
||||||
virtual bool customInfoLayout() const = 0;
|
virtual bool customInfoLayout() const = 0;
|
||||||
|
virtual QMargins bubbleMargins() const {
|
||||||
|
return QMargins();
|
||||||
|
}
|
||||||
virtual bool hideFromName() const {
|
virtual bool hideFromName() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1225,6 +1238,7 @@ class HistoryPhoto : public HistoryMedia {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HistoryPhoto(const MTPDphoto &photo, const QString &caption, HistoryItem *parent);
|
HistoryPhoto(const MTPDphoto &photo, const QString &caption, HistoryItem *parent);
|
||||||
|
HistoryPhoto(PhotoData *photo);
|
||||||
HistoryPhoto(PeerData *chat, const MTPDphoto &photo, int32 width = 0);
|
HistoryPhoto(PeerData *chat, const MTPDphoto &photo, int32 width = 0);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
@ -1459,6 +1473,9 @@ public:
|
||||||
bool customInfoLayout() const {
|
bool customInfoLayout() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
QMargins bubbleMargins() const {
|
||||||
|
return st::msgPadding;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -1507,7 +1524,7 @@ public:
|
||||||
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||||
HistoryMedia *clone() const;
|
HistoryMedia *clone() const;
|
||||||
|
|
||||||
DocumentData *document() {
|
DocumentData *getDocument() {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1530,6 +1547,9 @@ public:
|
||||||
bool customInfoLayout() const {
|
bool customInfoLayout() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
QMargins bubbleMargins() const {
|
||||||
|
return withThumb() ? QMargins(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbPadding.left(), st::msgFileThumbPadding.bottom()) : st::msgPadding;
|
||||||
|
}
|
||||||
bool hideForwardedFrom() const {
|
bool hideForwardedFrom() const {
|
||||||
return _data->song();
|
return _data->song();
|
||||||
}
|
}
|
||||||
|
@ -1586,9 +1606,11 @@ public:
|
||||||
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||||
HistoryMedia *clone() const;
|
HistoryMedia *clone() const;
|
||||||
|
|
||||||
DocumentData *document() {
|
DocumentData *getDocument() {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
bool playInline(HistoryItem *item);
|
||||||
|
void stopInline(HistoryItem *item);
|
||||||
|
|
||||||
void regItem(HistoryItem *item);
|
void regItem(HistoryItem *item);
|
||||||
void unregItem(HistoryItem *item);
|
void unregItem(HistoryItem *item);
|
||||||
|
@ -1613,9 +1635,6 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void play(HistoryItem *parent);
|
|
||||||
void stop(HistoryItem *parent);
|
|
||||||
|
|
||||||
~HistoryGif();
|
~HistoryGif();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -1760,11 +1779,15 @@ class HistoryWebPage : public HistoryMedia {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HistoryWebPage(WebPageData *data);
|
HistoryWebPage(WebPageData *data);
|
||||||
|
HistoryWebPage(const HistoryWebPage &other);
|
||||||
void initDimensions(const HistoryItem *parent);
|
void initDimensions(const HistoryItem *parent);
|
||||||
|
|
||||||
|
void linkOver(HistoryItem *parent, const TextLinkPtr &lnk);
|
||||||
|
void linkOut(HistoryItem *parent, const TextLinkPtr &lnk);
|
||||||
|
|
||||||
void draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const;
|
void draw(Painter &p, const HistoryItem *parent, const QRect &r, bool selected, uint64 ms) const;
|
||||||
bool isDisplayed() const {
|
bool isDisplayed() const {
|
||||||
return !data->pendingTill;
|
return !_data->pendingTill;
|
||||||
}
|
}
|
||||||
int32 resize(int32 width, const HistoryItem *parent);
|
int32 resize(int32 width, const HistoryItem *parent);
|
||||||
HistoryMediaType type() const {
|
HistoryMediaType type() const {
|
||||||
|
@ -1776,21 +1799,32 @@ public:
|
||||||
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
void getState(TextLinkPtr &lnk, HistoryCursorState &state, int32 x, int32 y, const HistoryItem *parent, int32 width = -1) const;
|
||||||
HistoryMedia *clone() const;
|
HistoryMedia *clone() const;
|
||||||
|
|
||||||
|
DocumentData *getDocument() {
|
||||||
|
return _attach ? _attach->getDocument() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool playInline(HistoryItem *item) {
|
||||||
|
return _attach ? _attach->playInline(item) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopInline(HistoryItem *item) {
|
||||||
|
if (_attach) _attach->stopInline(item);
|
||||||
|
}
|
||||||
|
|
||||||
void regItem(HistoryItem *item);
|
void regItem(HistoryItem *item);
|
||||||
void unregItem(HistoryItem *item);
|
void unregItem(HistoryItem *item);
|
||||||
|
|
||||||
bool hasReplyPreview() const {
|
bool hasReplyPreview() const {
|
||||||
return (data->photo && !data->photo->thumb->isNull()) || (data->doc && !data->doc->thumb->isNull());
|
return (_data->photo && !_data->photo->thumb->isNull()) || (_data->doc && !_data->doc->thumb->isNull());
|
||||||
}
|
}
|
||||||
ImagePtr replyPreview();
|
ImagePtr replyPreview();
|
||||||
|
|
||||||
virtual bool animating() const {
|
virtual bool animating() const {
|
||||||
if (_asArticle || !data->photo || data->photo->full->loaded()) return false;
|
return _attach ? _attach->animating() : false;
|
||||||
return data->photo->full->loading();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebPageData *webpage() {
|
WebPageData *webpage() {
|
||||||
return data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsBubble(const HistoryItem *parent) const {
|
bool needsBubble(const HistoryItem *parent) const {
|
||||||
|
@ -1801,17 +1835,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WebPageData *data;
|
WebPageData *_data;
|
||||||
TextLinkPtr _openl, _attachl;
|
TextLinkPtr _openl;
|
||||||
|
HistoryMedia *_attach;
|
||||||
|
|
||||||
bool _asArticle;
|
bool _asArticle;
|
||||||
|
int32 _titleLines, _descriptionLines;
|
||||||
|
|
||||||
Text _title, _description;
|
Text _title, _description;
|
||||||
int32 _siteNameWidth;
|
int32 _siteNameWidth;
|
||||||
|
|
||||||
QString _duration, _docName, _docSize;
|
QString _duration;
|
||||||
int32 _durationWidth, _docNameWidth, _docThumbWidth;
|
int32 _durationWidth;
|
||||||
mutable QString _docDownloadTextCache;
|
|
||||||
mutable int32 _docDownloadDone;
|
|
||||||
|
|
||||||
int16 _pixw, _pixh;
|
int16 _pixw, _pixh;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5363,14 +5363,7 @@ void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, const MTPInputFil
|
||||||
if (!MTP::authedId()) return;
|
if (!MTP::authedId()) return;
|
||||||
HistoryMessage *item = dynamic_cast<HistoryMessage*>(App::histItemById(newId));
|
HistoryMessage *item = dynamic_cast<HistoryMessage*>(App::histItemById(newId));
|
||||||
if (item) {
|
if (item) {
|
||||||
DocumentData *document = 0;
|
DocumentData *document = item->getMedia() ? item->getMedia()->getDocument() : 0;
|
||||||
if (HistoryDocument *media = dynamic_cast<HistoryDocument*>(item->getMedia())) {
|
|
||||||
document = media->document();
|
|
||||||
} else if (HistoryGif *media = dynamic_cast<HistoryGif*>(item->getMedia())) {
|
|
||||||
document = media->document();
|
|
||||||
} else if (HistorySticker *media = dynamic_cast<HistorySticker*>(item->getMedia())) {
|
|
||||||
document = media->document();
|
|
||||||
}
|
|
||||||
if (document) {
|
if (document) {
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = MTP::nonce<uint64>();
|
||||||
App::historyRegRandom(randomId, newId);
|
App::historyRegRandom(randomId, newId);
|
||||||
|
@ -5394,14 +5387,7 @@ void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, const MTPInp
|
||||||
if (!MTP::authedId()) return;
|
if (!MTP::authedId()) return;
|
||||||
HistoryMessage *item = dynamic_cast<HistoryMessage*>(App::histItemById(newId));
|
HistoryMessage *item = dynamic_cast<HistoryMessage*>(App::histItemById(newId));
|
||||||
if (item) {
|
if (item) {
|
||||||
DocumentData *document = 0;
|
DocumentData *document = item->getMedia() ? item->getMedia()->getDocument() : 0;
|
||||||
if (HistoryDocument *media = dynamic_cast<HistoryDocument*>(item->getMedia())) {
|
|
||||||
document = media->document();
|
|
||||||
} else if (HistoryGif *media = dynamic_cast<HistoryGif*>(item->getMedia())) {
|
|
||||||
document = media->document();
|
|
||||||
} else if (HistorySticker *media = dynamic_cast<HistorySticker*>(item->getMedia())) {
|
|
||||||
document = media->document();
|
|
||||||
}
|
|
||||||
if (document) {
|
if (document) {
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = MTP::nonce<uint64>();
|
||||||
App::historyRegRandom(randomId, newId);
|
App::historyRegRandom(randomId, newId);
|
||||||
|
@ -5463,17 +5449,7 @@ void HistoryWidget::onDocumentProgress(const FullMsgId &newId) {
|
||||||
if (!MTP::authedId()) return;
|
if (!MTP::authedId()) return;
|
||||||
if (HistoryItem *item = App::histItemById(newId)) {
|
if (HistoryItem *item = App::histItemById(newId)) {
|
||||||
HistoryMedia *media = item->getMedia();
|
HistoryMedia *media = item->getMedia();
|
||||||
DocumentData *doc = 0;
|
DocumentData *doc = media ? media->getDocument() : 0;
|
||||||
if (media) {
|
|
||||||
HistoryMediaType type = media->type();
|
|
||||||
if (type == MediaTypeDocument) {
|
|
||||||
doc = static_cast<HistoryDocument*>(item->getMedia())->document();
|
|
||||||
} else if (type == MediaTypeGif) {
|
|
||||||
doc = static_cast<HistoryGif*>(item->getMedia())->document();
|
|
||||||
} else if (type == MediaTypeSticker) {
|
|
||||||
doc = static_cast<HistorySticker*>(item->getMedia())->document();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!item->fromChannel()) {
|
if (!item->fromChannel()) {
|
||||||
updateSendAction(item->history(), SendActionUploadFile, doc ? doc->uploadOffset : 0);
|
updateSendAction(item->history(), SendActionUploadFile, doc ? doc->uploadOffset : 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1883,9 +1883,7 @@ void MainWidget::documentLoadProgress(mtpFileLoader *loader) {
|
||||||
} else if (document->openOnSave > 0 && document->size < MediaViewImageSizeLimit) {
|
} else if (document->openOnSave > 0 && document->size < MediaViewImageSizeLimit) {
|
||||||
const FileLocation &location(document->location(true));
|
const FileLocation &location(document->location(true));
|
||||||
if (location.accessEnable()) {
|
if (location.accessEnable()) {
|
||||||
if (item && item->getMedia() && item->getMedia()->type() == MediaTypeGif) {
|
if (!item || !item->getMedia() || !item->getMedia()->playInline(item)) {
|
||||||
static_cast<HistoryGif*>(item->getMedia())->play(item);
|
|
||||||
} else {
|
|
||||||
QImageReader reader(location.name());
|
QImageReader reader(location.name());
|
||||||
if (reader.canRead() && item) {
|
if (reader.canRead() && item) {
|
||||||
App::wnd()->showDocument(document, item);
|
App::wnd()->showDocument(document, item);
|
||||||
|
|
|
@ -346,7 +346,7 @@ void MediaView::updateControls() {
|
||||||
_dateText = lng_mediaview_date_time(lt_date, d.date().toString(qsl("dd.MM.yy")), lt_time, d.time().toString(cTimeFormat()));
|
_dateText = lng_mediaview_date_time(lt_date, d.date().toString(qsl("dd.MM.yy")), lt_time, d.time().toString(cTimeFormat()));
|
||||||
}
|
}
|
||||||
if (_from) {
|
if (_from) {
|
||||||
_fromName.setText(st::mvFont, (_from->migrateTo() ? _from->migrateTo() : _from)->name);
|
_fromName.setText(st::mvFont, (_from->migrateTo() ? _from->migrateTo() : _from)->name, _textNameOptions);
|
||||||
_nameNav = myrtlrect(st::mvTextLeft, height() - st::mvTextTop, qMin(_fromName.maxWidth(), width() / 3), st::mvFont->height);
|
_nameNav = myrtlrect(st::mvTextLeft, height() - st::mvTextTop, qMin(_fromName.maxWidth(), width() / 3), st::mvFont->height);
|
||||||
_dateNav = myrtlrect(st::mvTextLeft + _nameNav.width() + st::mvTextSkip, height() - st::mvTextTop, st::mvFont->width(_dateText), st::mvFont->height);
|
_dateNav = myrtlrect(st::mvTextLeft + _nameNav.width() + st::mvTextSkip, height() - st::mvTextTop, st::mvFont->width(_dateText), st::mvFont->height);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1513,8 +1513,8 @@ void MediaView::moveToNext(int32 delta) {
|
||||||
if (item->getMedia()) {
|
if (item->getMedia()) {
|
||||||
switch (item->getMedia()->type()) {
|
switch (item->getMedia()->type()) {
|
||||||
case MediaTypePhoto: displayPhoto(static_cast<HistoryPhoto*>(item->getMedia())->photo(), item); preloadData(delta); break;
|
case MediaTypePhoto: displayPhoto(static_cast<HistoryPhoto*>(item->getMedia())->photo(), item); preloadData(delta); break;
|
||||||
case MediaTypeDocument: displayDocument(static_cast<HistoryDocument*>(item->getMedia())->document(), item); preloadData(delta); break;
|
case MediaTypeDocument: displayDocument(static_cast<HistoryDocument*>(item->getMedia())->getDocument(), item); preloadData(delta); break;
|
||||||
case MediaTypeGif: displayDocument(static_cast<HistoryGif*>(item->getMedia())->document(), item); preloadData(delta); break;
|
case MediaTypeGif: displayDocument(static_cast<HistoryGif*>(item->getMedia())->getDocument(), item); preloadData(delta); break;
|
||||||
case MediaTypeSticker: displayDocument(static_cast<HistorySticker*>(item->getMedia())->document(), item); preloadData(delta); break;
|
case MediaTypeSticker: displayDocument(static_cast<HistorySticker*>(item->getMedia())->document(), item); preloadData(delta); break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1561,8 +1561,8 @@ void MediaView::preloadData(int32 delta) {
|
||||||
if (HistoryMedia *media = item->getMedia()) {
|
if (HistoryMedia *media = item->getMedia()) {
|
||||||
switch (media->type()) {
|
switch (media->type()) {
|
||||||
case MediaTypePhoto: static_cast<HistoryPhoto*>(media)->photo()->full->load(); break;
|
case MediaTypePhoto: static_cast<HistoryPhoto*>(media)->photo()->full->load(); break;
|
||||||
case MediaTypeDocument: static_cast<HistoryDocument*>(media)->document()->thumb->load(); break;
|
case MediaTypeDocument: static_cast<HistoryDocument*>(media)->getDocument()->thumb->load(); break;
|
||||||
case MediaTypeGif: static_cast<HistoryGif*>(media)->document()->thumb->load(); break;
|
case MediaTypeGif: static_cast<HistoryGif*>(media)->getDocument()->thumb->load(); break;
|
||||||
case MediaTypeSticker: static_cast<HistorySticker*>(media)->document()->sticker()->img->load(); break;
|
case MediaTypeSticker: static_cast<HistorySticker*>(media)->document()->sticker()->img->load(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1585,8 +1585,8 @@ void MediaView::preloadData(int32 delta) {
|
||||||
if (HistoryMedia *media = item->getMedia()) {
|
if (HistoryMedia *media = item->getMedia()) {
|
||||||
switch (media->type()) {
|
switch (media->type()) {
|
||||||
case MediaTypePhoto: static_cast<HistoryPhoto*>(media)->photo()->forget(); break;
|
case MediaTypePhoto: static_cast<HistoryPhoto*>(media)->photo()->forget(); break;
|
||||||
case MediaTypeDocument: static_cast<HistoryDocument*>(media)->document()->forget(); break;
|
case MediaTypeDocument: static_cast<HistoryDocument*>(media)->getDocument()->forget(); break;
|
||||||
case MediaTypeGif: static_cast<HistoryGif*>(media)->document()->forget(); break;
|
case MediaTypeGif: static_cast<HistoryGif*>(media)->getDocument()->forget(); break;
|
||||||
case MediaTypeSticker: static_cast<HistorySticker*>(media)->document()->forget(); break;
|
case MediaTypeSticker: static_cast<HistorySticker*>(media)->document()->forget(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,11 +323,12 @@ void PlayerWidget::preloadNext() {
|
||||||
}
|
}
|
||||||
if (next) {
|
if (next) {
|
||||||
if (HistoryDocument *document = static_cast<HistoryDocument*>(next->getMedia())) {
|
if (HistoryDocument *document = static_cast<HistoryDocument*>(next->getMedia())) {
|
||||||
if (document->document()->location(true).isEmpty() && document->document()->data.isEmpty()) {
|
DocumentData *d = document->getDocument();
|
||||||
if (!document->document()->loader) {
|
if (d->location(true).isEmpty() && d->data.isEmpty()) {
|
||||||
DocumentOpenLink::doOpen(document->document());
|
if (!d->loader) {
|
||||||
document->document()->openOnSave = 0;
|
DocumentOpenLink::doOpen(d);
|
||||||
document->document()->openOnSaveMsgId = FullMsgId();
|
d->openOnSave = 0;
|
||||||
|
d->openOnSaveMsgId = FullMsgId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +338,7 @@ void PlayerWidget::preloadNext() {
|
||||||
void PlayerWidget::startPlay(const FullMsgId &msgId) {
|
void PlayerWidget::startPlay(const FullMsgId &msgId) {
|
||||||
if (HistoryItem *item = App::histItemById(msgId)) {
|
if (HistoryItem *item = App::histItemById(msgId)) {
|
||||||
if (HistoryDocument *doc = static_cast<HistoryDocument*>(item->getMedia())) {
|
if (HistoryDocument *doc = static_cast<HistoryDocument*>(item->getMedia())) {
|
||||||
audioPlayer()->play(SongMsgId(doc->document(), item->fullId()));
|
audioPlayer()->play(SongMsgId(doc->getDocument(), item->fullId()));
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -886,9 +886,7 @@ void DocumentOpenLink::doOpen(DocumentData *data) {
|
||||||
if (App::main()) App::main()->documentPlayProgress(song);
|
if (App::main()) App::main()->documentPlayProgress(song);
|
||||||
}
|
}
|
||||||
} else if (data->size < MediaViewImageSizeLimit && location.accessEnable()) {
|
} else if (data->size < MediaViewImageSizeLimit && location.accessEnable()) {
|
||||||
if (App::hoveredLinkItem() && App::hoveredLinkItem()->getMedia() && App::hoveredLinkItem()->getMedia()->type() == MediaTypeGif) {
|
if (!App::hoveredLinkItem() || !App::hoveredLinkItem()->getMedia() || !App::hoveredLinkItem()->getMedia()->playInline(App::hoveredLinkItem())) {
|
||||||
static_cast<HistoryGif*>(App::hoveredLinkItem()->getMedia())->play(App::hoveredLinkItem());
|
|
||||||
} else {
|
|
||||||
QImageReader reader(location.name());
|
QImageReader reader(location.name());
|
||||||
if (reader.canRead() && (App::hoveredLinkItem() || App::contextItem())) {
|
if (reader.canRead() && (App::hoveredLinkItem() || App::contextItem())) {
|
||||||
App::wnd()->showDocument(data, App::hoveredLinkItem() ? App::hoveredLinkItem() : App::contextItem());
|
App::wnd()->showDocument(data, App::hoveredLinkItem() ? App::hoveredLinkItem() : App::contextItem());
|
||||||
|
|
|
@ -1145,6 +1145,9 @@ struct DocumentData {
|
||||||
SongData *song() {
|
SongData *song() {
|
||||||
return (type == SongDocument) ? static_cast<SongData*>(_additional) : 0;
|
return (type == SongDocument) ? static_cast<SongData*>(_additional) : 0;
|
||||||
}
|
}
|
||||||
|
bool isAnimation() {
|
||||||
|
return (type == AnimatedDocument) || !mime.compare(qstr("image/gif"), Qt::CaseInsensitive);
|
||||||
|
}
|
||||||
bool isImage() const {
|
bool isImage() const {
|
||||||
return _isImage;
|
return _isImage;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue