From b4bff939b1aba00b4a546b32df2a11270275b8cb Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 15 Jun 2021 22:41:56 +0300 Subject: [PATCH] Removed showDocument and showPhoto from Application. --- Telegram/SourceFiles/core/application.cpp | 35 ------------------- Telegram/SourceFiles/core/application.h | 4 --- .../data/data_document_resolver.cpp | 18 +++++++--- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 840b3b978..a8d99756e 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -390,41 +390,6 @@ bool Application::hideMediaView() { return false; } -void Application::showPhoto(not_null link) { - const auto photo = link->photo(); - const auto peer = link->peer(); - const auto item = photo->owner().message(link->context()); - return (!item && peer) - ? showPhoto(photo, peer) - : showPhoto(photo, item); -} - -void Application::showPhoto(not_null photo, HistoryItem *item) { - Expects(_mediaView != nullptr); - - _mediaView->showPhoto(photo, item); -} - -void Application::showPhoto( - not_null photo, - not_null peer) { - Expects(_mediaView != nullptr); - - _mediaView->showPhoto(photo, peer); -} - -void Application::showDocument(not_null document, HistoryItem *item) { - Expects(_mediaView != nullptr); - - if (cUseExternalVideoPlayer() - && document->isVideoFile() - && !document->filepath().isEmpty()) { - File::Launch(document->location(false).fname); - } else { - _mediaView->showDocument(document, item); - } -} - void Application::showTheme( not_null document, const Data::CloudTheme &cloud) { diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 8ca5e6165..b78ff2242 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -143,10 +143,6 @@ public: // Media view interface. void checkMediaViewActivation(); bool hideMediaView(); - void showPhoto(not_null link); - void showPhoto(not_null photo, HistoryItem *item); - void showPhoto(not_null photo, not_null item); - void showDocument(not_null document, HistoryItem *item); void showTheme( not_null document, const Data::CloudTheme &cloud); diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index 22f06be46..32d9049bd 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -216,6 +216,16 @@ void ResolveDocument( } const auto msgId = item ? item->fullId() : FullMsgId(); + const auto showDocument = [&] { + if (cUseExternalVideoPlayer() + && document->isVideoFile() + && !document->filepath().isEmpty()) { + File::Launch(document->location(false).fname); + } else { + controller->openDocument(document, msgId, true); + } + }; + const auto media = document->createMediaView(); const auto openImageInApp = [&] { if (document->size >= App::kImageSizeLimit) { @@ -229,7 +239,7 @@ void ResolveDocument( const auto path = location.name(); if (Core::MimeTypeForFile(path).name().startsWith("image/") && QImageReader(path).canRead()) { - controller->openDocument(document, msgId, true); + showDocument(); return true; } } else if (document->mimeString().startsWith("image/") @@ -237,7 +247,7 @@ void ResolveDocument( auto bytes = media->bytes(); auto buffer = QBuffer(&bytes); if (QImageReader(&buffer).canRead()) { - controller->openDocument(document, msgId, true); + showDocument(); return true; } } @@ -245,7 +255,7 @@ void ResolveDocument( }; const auto &location = document->location(true); if (document->isTheme() && media->loaded(true)) { - controller->openDocument(document, msgId, true); + showDocument(); location.accessDisable(); } else if (media->canBePlayed()) { if (document->isAudioFile() @@ -257,7 +267,7 @@ void ResolveDocument( && HistoryView::Gif::CanPlayInline(document)) { document->owner().requestAnimationPlayInline(item); } else { - controller->openDocument(document, msgId, true); + showDocument(); } } else { document->saveFromDataSilent();