Fix inline result previews.

This commit is contained in:
John Preston 2019-10-07 12:19:04 +03:00
parent de230332b9
commit 60b39c8f7e
5 changed files with 24 additions and 25 deletions

View File

@ -625,7 +625,7 @@ void Photo::prepareThumbnail(QSize size, QSize frame) const {
} }
Video::Video(not_null<Context*> context, Result *result) : FileBase(context, result) Video::Video(not_null<Context*> context, Result *result) : FileBase(context, result)
, _link(getResultContentUrlHandler()) , _link(getResultPreviewHandler())
, _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) , _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip)
, _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) { , _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) {
if (int duration = content_duration()) { if (int duration = content_duration()) {
@ -1057,7 +1057,7 @@ void Contact::prepareThumbnail(int width, int height) const {
Article::Article(not_null<Context*> context, Result *result, bool withThumb) : ItemBase(context, result) Article::Article(not_null<Context*> context, Result *result, bool withThumb) : ItemBase(context, result)
, _url(getResultUrlHandler()) , _url(getResultUrlHandler())
, _link(getResultContentUrlHandler()) , _link(getResultPreviewHandler())
, _withThumb(withThumb) , _withThumb(withThumb)
, _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) , _title(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip)
, _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) { , _description(st::emojiPanWidth - st::emojiScroll.width - st::inlineResultsLeft - st::inlineThumbSize - st::inlineThumbSkip) {

View File

@ -187,11 +187,16 @@ ClickHandlerPtr ItemBase::getResultUrlHandler() const {
return ClickHandlerPtr(); return ClickHandlerPtr();
} }
ClickHandlerPtr ItemBase::getResultContentUrlHandler() const { ClickHandlerPtr ItemBase::getResultPreviewHandler() const {
if (!_result->_content_url.isEmpty()) { if (!_result->_content_url.isEmpty()) {
return std::make_shared<UrlClickHandler>( return std::make_shared<UrlClickHandler>(
_result->_content_url, _result->_content_url,
false); false);
} else if (_result->_document && _result->_document->canBePlayed()) {
return std::make_shared<DocumentOpenClickHandler>(
_result->_document);
} else if (_result->_photo) {
return std::make_shared<PhotoOpenClickHandler>(_result->_photo);
} }
return ClickHandlerPtr(); return ClickHandlerPtr();
} }

View File

@ -103,7 +103,7 @@ protected:
int getResultDuration() const; int getResultDuration() const;
QString getResultUrl() const; QString getResultUrl() const;
ClickHandlerPtr getResultUrlHandler() const; ClickHandlerPtr getResultUrlHandler() const;
ClickHandlerPtr getResultContentUrlHandler() const; ClickHandlerPtr getResultPreviewHandler() const;
QString getResultThumbLetter() const; QString getResultThumbLetter() const;
not_null<Context*> context() const { not_null<Context*> context() const {

View File

@ -272,9 +272,9 @@ bool Result::onChoose(Layout::ItemBase *layout) {
} else if (_document->loading()) { } else if (_document->loading()) {
_document->cancel(); _document->cancel();
} else { } else {
_document->save( DocumentSaveClickHandler::Save(
Data::FileOriginSavedGifs(), Data::FileOriginSavedGifs(),
QString()); _document);
} }
return false; return false;
} }

View File

@ -2358,25 +2358,19 @@ void OverlayWidget::playbackPauseResume() {
Expects(_streamed != nullptr); Expects(_streamed != nullptr);
_streamed->resumeOnCallEnd = false; _streamed->resumeOnCallEnd = false;
if (const auto item = Auth().data().message(_msgid)) { if (_streamed->player.failed()) {
if (_streamed->player.failed()) {
clearStreaming();
initStreaming();
} else if (_streamed->player.finished()) {
_streamingStartPaused = false;
restartAtSeekPosition(0);
} else if (_streamed->player.paused()) {
_streamed->player.resume();
updatePlaybackState();
playbackPauseMusic();
} else {
_streamed->player.pause();
updatePlaybackState();
}
} else {
clearStreaming(); clearStreaming();
updateControls(); initStreaming();
update(); } else if (_streamed->player.finished()) {
_streamingStartPaused = false;
restartAtSeekPosition(0);
} else if (_streamed->player.paused()) {
_streamed->player.resume();
updatePlaybackState();
playbackPauseMusic();
} else {
_streamed->player.pause();
updatePlaybackState();
} }
} }
@ -3324,7 +3318,7 @@ void OverlayWidget::mousePressEvent(QMouseEvent *e) {
void OverlayWidget::mouseDoubleClickEvent(QMouseEvent *e) { void OverlayWidget::mouseDoubleClickEvent(QMouseEvent *e) {
updateOver(e->pos()); updateOver(e->pos());
if (_over == OverVideo) { if (_over == OverVideo && _streamed) {
playbackToggleFullScreen(); playbackToggleFullScreen();
playbackPauseResume(); playbackPauseResume();
} else { } else {