mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Show GIF in Mediaview on click.
This way you can watch GIF on full screen and switch between them.
This commit is contained in:
parent
2377873c45
commit
efb59e8c3a
9 changed files with 61 additions and 29 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -16,6 +16,7 @@
|
||||||
/Telegram/Resources/art/grid_200x.png
|
/Telegram/Resources/art/grid_200x.png
|
||||||
/Telegram/Resources/art/sprite_125x.png
|
/Telegram/Resources/art/sprite_125x.png
|
||||||
/Telegram/Resources/art/sprite_150x.png
|
/Telegram/Resources/art/sprite_150x.png
|
||||||
|
/Telegram/Debug/
|
||||||
/Telegram/*.user
|
/Telegram/*.user
|
||||||
*.vcxproj*
|
*.vcxproj*
|
||||||
*.sln
|
*.sln
|
||||||
|
|
|
@ -958,6 +958,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
"lng_context_delete_file" = "Delete File";
|
"lng_context_delete_file" = "Delete File";
|
||||||
"lng_context_close_file" = "Close File";
|
"lng_context_close_file" = "Close File";
|
||||||
"lng_context_copy_text" = "Copy Text";
|
"lng_context_copy_text" = "Copy Text";
|
||||||
|
"lng_context_open_gif" = "Open GIF";
|
||||||
"lng_context_save_gif" = "Save GIF";
|
"lng_context_save_gif" = "Save GIF";
|
||||||
"lng_context_to_msg" = "Go To Message";
|
"lng_context_to_msg" = "Go To Message";
|
||||||
"lng_context_reply_msg" = "Reply";
|
"lng_context_reply_msg" = "Reply";
|
||||||
|
|
|
@ -138,22 +138,6 @@ enum MediaOverviewType {
|
||||||
OverviewCount
|
OverviewCount
|
||||||
};
|
};
|
||||||
|
|
||||||
inline MTPMessagesFilter typeToMediaFilter(MediaOverviewType &type) {
|
|
||||||
switch (type) {
|
|
||||||
case OverviewPhotos: return MTP_inputMessagesFilterPhotos();
|
|
||||||
case OverviewVideos: return MTP_inputMessagesFilterVideo();
|
|
||||||
case OverviewMusicFiles: return MTP_inputMessagesFilterMusic();
|
|
||||||
case OverviewFiles: return MTP_inputMessagesFilterDocument();
|
|
||||||
case OverviewVoiceFiles: return MTP_inputMessagesFilterVoice();
|
|
||||||
case OverviewRoundVoiceFiles: return MTP_inputMessagesFilterRoundVoice();
|
|
||||||
case OverviewLinks: return MTP_inputMessagesFilterUrl();
|
|
||||||
case OverviewChatPhotos: return MTP_inputMessagesFilterChatPhotos();
|
|
||||||
case OverviewCount: break;
|
|
||||||
default: type = OverviewCount; break;
|
|
||||||
}
|
|
||||||
return MTPMessagesFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TextWithTags {
|
struct TextWithTags {
|
||||||
struct Tag {
|
struct Tag {
|
||||||
int offset, length;
|
int offset, length;
|
||||||
|
|
|
@ -1291,6 +1291,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
_menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true);
|
_menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
if (document->loaded() && document->isGifv()) {
|
if (document->loaded() && document->isGifv()) {
|
||||||
|
if (!cAutoPlayGif()) {
|
||||||
|
_menu->addAction(lang(lng_context_open_gif), this, SLOT(openContextGif()))->setEnabled(true);
|
||||||
|
}
|
||||||
_menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true);
|
_menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true);
|
||||||
}
|
}
|
||||||
if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
||||||
|
@ -1384,6 +1387,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
_menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true);
|
_menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
if (document->isGifv()) {
|
if (document->isGifv()) {
|
||||||
|
if (!cAutoPlayGif()) {
|
||||||
|
_menu->addAction(lang(lng_context_open_gif), this, SLOT(openContextGif()))->setEnabled(true);
|
||||||
|
}
|
||||||
_menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true);
|
_menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true);
|
||||||
}
|
}
|
||||||
if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
||||||
|
@ -1522,6 +1528,16 @@ void HistoryInner::saveDocumentToFile(DocumentData *document) {
|
||||||
DocumentSaveClickHandler::doSave(document, true);
|
DocumentSaveClickHandler::doSave(document, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryInner::openContextGif() {
|
||||||
|
if (auto item = App::contextItem()) {
|
||||||
|
if (auto media = item->getMedia()) {
|
||||||
|
if (auto document = media->getDocument()) {
|
||||||
|
App::wnd()->showDocument(document, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryInner::saveContextGif() {
|
void HistoryInner::saveContextGif() {
|
||||||
if (auto item = App::contextItem()) {
|
if (auto item = App::contextItem()) {
|
||||||
if (auto media = item->getMedia()) {
|
if (auto media = item->getMedia()) {
|
||||||
|
|
|
@ -118,6 +118,7 @@ public slots:
|
||||||
void cancelContextDownload();
|
void cancelContextDownload();
|
||||||
void showContextInFolder();
|
void showContextInFolder();
|
||||||
void saveContextGif();
|
void saveContextGif();
|
||||||
|
void openContextGif();
|
||||||
void copyContextText();
|
void copyContextText();
|
||||||
void copySelectedText();
|
void copySelectedText();
|
||||||
|
|
||||||
|
|
|
@ -1707,6 +1707,7 @@ HistoryGif::HistoryGif(HistoryItem *parent, DocumentData *document, const QStrin
|
||||||
, _data(document)
|
, _data(document)
|
||||||
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
|
, _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) {
|
||||||
setDocumentLinks(_data, true);
|
setDocumentLinks(_data, true);
|
||||||
|
_openInMediaviewLink = MakeShared<DocumentOpenClickHandler>(_data);
|
||||||
|
|
||||||
setStatusSize(FileStatusSizeReady);
|
setStatusSize(FileStatusSizeReady);
|
||||||
|
|
||||||
|
@ -2217,6 +2218,8 @@ HistoryTextState HistoryGif::getState(int x, int y, HistoryStateRequest request)
|
||||||
result.link = _cancell;
|
result.link = _cancell;
|
||||||
} else if (!_gif || !cAutoPlayGif() || _data->isRoundVideo()) {
|
} else if (!_gif || !cAutoPlayGif() || _data->isRoundVideo()) {
|
||||||
result.link = _data->loaded() ? _openl : (_data->loading() ? _cancell : _savel);
|
result.link = _data->loaded() ? _openl : (_data->loading() ? _cancell : _savel);
|
||||||
|
} else {
|
||||||
|
result.link = _openInMediaviewLink;
|
||||||
}
|
}
|
||||||
if (!isChildMedia) {
|
if (!isChildMedia) {
|
||||||
int32 fullRight = usex + skipx + usew, fullBottom = skipy + height;
|
int32 fullRight = usex + skipx + usew, fullBottom = skipy + height;
|
||||||
|
|
|
@ -580,6 +580,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
gsl::not_null<DocumentData*> _data;
|
gsl::not_null<DocumentData*> _data;
|
||||||
|
ClickHandlerPtr _openInMediaviewLink;
|
||||||
int32 _thumbw = 1;
|
int32 _thumbw = 1;
|
||||||
int32 _thumbh = 1;
|
int32 _thumbh = 1;
|
||||||
Text _caption;
|
Text _caption;
|
||||||
|
|
|
@ -71,6 +71,25 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "calls/calls_top_bar.h"
|
#include "calls/calls_top_bar.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
MTPMessagesFilter typeToMediaFilter(MediaOverviewType &type) {
|
||||||
|
switch (type) {
|
||||||
|
case OverviewPhotos: return MTP_inputMessagesFilterPhotos();
|
||||||
|
case OverviewVideos: return MTP_inputMessagesFilterVideo();
|
||||||
|
case OverviewMusicFiles: return MTP_inputMessagesFilterMusic();
|
||||||
|
case OverviewFiles: return MTP_inputMessagesFilterDocument();
|
||||||
|
case OverviewVoiceFiles: return MTP_inputMessagesFilterVoice();
|
||||||
|
case OverviewRoundVoiceFiles: return MTP_inputMessagesFilterRoundVoice();
|
||||||
|
case OverviewGIFs: return MTP_inputMessagesFilterGif();
|
||||||
|
case OverviewLinks: return MTP_inputMessagesFilterUrl();
|
||||||
|
case OverviewChatPhotos: return MTP_inputMessagesFilterChatPhotos();
|
||||||
|
default: return MTP_inputMessagesFilterEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
StackItemSection::StackItemSection(std::unique_ptr<Window::SectionMemento> &&memento) : StackItem(nullptr)
|
StackItemSection::StackItemSection(std::unique_ptr<Window::SectionMemento> &&memento) : StackItem(nullptr)
|
||||||
, _memento(std::move(memento)) {
|
, _memento(std::move(memento)) {
|
||||||
}
|
}
|
||||||
|
@ -1335,11 +1354,13 @@ void MainWidget::searchMessages(const QString &query, PeerData *inPeer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::preloadOverview(PeerData *peer, MediaOverviewType type) {
|
bool MainWidget::preloadOverview(PeerData *peer, MediaOverviewType type) {
|
||||||
MTPMessagesFilter filter = typeToMediaFilter(type);
|
auto filter = typeToMediaFilter(type);
|
||||||
if (type == OverviewCount) return false;
|
if (filter.type() == mtpc_inputMessagesFilterEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
History *h = App::history(peer->id);
|
auto history = App::history(peer->id);
|
||||||
if (h->overviewCountLoaded(type) || _overviewPreload[type].contains(peer)) {
|
if (history->overviewCountLoaded(type) || _overviewPreload[type].contains(peer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1399,13 +1420,17 @@ bool MainWidget::overviewFailed(PeerData *peer, const RPCError &error, mtpReques
|
||||||
void MainWidget::loadMediaBack(PeerData *peer, MediaOverviewType type, bool many) {
|
void MainWidget::loadMediaBack(PeerData *peer, MediaOverviewType type, bool many) {
|
||||||
if (_overviewLoad[type].constFind(peer) != _overviewLoad[type].cend()) return;
|
if (_overviewLoad[type].constFind(peer) != _overviewLoad[type].cend()) return;
|
||||||
|
|
||||||
History *history = App::history(peer->id);
|
auto history = App::history(peer->id);
|
||||||
if (history->overviewLoaded(type)) return;
|
if (history->overviewLoaded(type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MsgId minId = history->overviewMinId(type);
|
auto minId = history->overviewMinId(type);
|
||||||
int32 limit = (many || history->overview[type].size() > MediaOverviewStartPerPage) ? SearchPerPage : MediaOverviewStartPerPage;
|
auto limit = (many || history->overview[type].size() > MediaOverviewStartPerPage) ? SearchPerPage : MediaOverviewStartPerPage;
|
||||||
MTPMessagesFilter filter = typeToMediaFilter(type);
|
auto filter = typeToMediaFilter(type);
|
||||||
if (type == OverviewCount) return;
|
if (filter.type() == mtpc_inputMessagesFilterEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_overviewLoad[type].insert(peer, MTP::send(MTPmessages_Search(MTP_flags(0), peer->input, MTPstring(), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(minId), MTP_int(limit)), rpcDone(&MainWidget::overviewLoaded, history)));
|
_overviewLoad[type].insert(peer, MTP::send(MTPmessages_Search(MTP_flags(0), peer->input, MTPstring(), filter, MTP_int(0), MTP_int(0), MTP_int(0), MTP_int(minId), MTP_int(limit)), rpcDone(&MainWidget::overviewLoaded, history)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,7 +368,7 @@ void MediaView::updateControls() {
|
||||||
_dateNav = myrtlrect(st::mediaviewTextLeft, height() - st::mediaviewTextTop, st::mediaviewFont->width(_dateText), st::mediaviewFont->height);
|
_dateNav = myrtlrect(st::mediaviewTextLeft, height() - st::mediaviewTextTop, st::mediaviewFont->width(_dateText), st::mediaviewFont->height);
|
||||||
}
|
}
|
||||||
updateHeader();
|
updateHeader();
|
||||||
if (_photo || (_history && (_overview == OverviewPhotos || _overview == OverviewChatPhotos || _overview == OverviewFiles || _overview == OverviewVideos))) {
|
if (_photo || (_history && _overview != OverviewCount)) {
|
||||||
_leftNavVisible = (_index > 0) || (_index == 0 && (
|
_leftNavVisible = (_index > 0) || (_index == 0 && (
|
||||||
(!_msgmigrated && _history && _history->overview[_overview].size() < _history->overviewCount(_overview)) ||
|
(!_msgmigrated && _history && _history->overview[_overview].size() < _history->overviewCount(_overview)) ||
|
||||||
(_msgmigrated && _migrated && _migrated->overview[_overview].size() < _migrated->overviewCount(_overview)) ||
|
(_msgmigrated && _migrated && _migrated->overview[_overview].size() < _migrated->overviewCount(_overview)) ||
|
||||||
|
@ -1152,7 +1152,7 @@ void MediaView::showDocument(DocumentData *doc, HistoryItem *context) {
|
||||||
_canForward = _msgid > 0;
|
_canForward = _msgid > 0;
|
||||||
_canDelete = context ? context->canDelete() : false;
|
_canDelete = context ? context->canDelete() : false;
|
||||||
if (_history) {
|
if (_history) {
|
||||||
_overview = doc->isVideo() ? OverviewVideos : OverviewFiles;
|
_overview = doc->isGifv() ? OverviewGIFs : doc->isVideo() ? OverviewVideos : OverviewFiles;
|
||||||
findCurrent();
|
findCurrent();
|
||||||
}
|
}
|
||||||
if (doc->isVideo() || doc->isRoundVideo()) {
|
if (doc->isVideo() || doc->isRoundVideo()) {
|
||||||
|
@ -2153,7 +2153,7 @@ bool MediaView::moveToNext(int32 delta) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((_history && _overview != OverviewPhotos && _overview != OverviewChatPhotos && _overview != OverviewFiles && _overview != OverviewVideos) || (_overview == OverviewCount && !_user)) {
|
if (_overview == OverviewCount && (_history || !_user)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_msgmigrated && !_history->overviewLoaded(_overview)) {
|
if (_msgmigrated && !_history->overviewLoaded(_overview)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue