mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Removed showDocument and showPhoto from Application.
This commit is contained in:
parent
1f816c249b
commit
b4bff939b1
3 changed files with 14 additions and 43 deletions
|
@ -390,41 +390,6 @@ bool Application::hideMediaView() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::showPhoto(not_null<const PhotoOpenClickHandler*> 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<PhotoData*> photo, HistoryItem *item) {
|
|
||||||
Expects(_mediaView != nullptr);
|
|
||||||
|
|
||||||
_mediaView->showPhoto(photo, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::showPhoto(
|
|
||||||
not_null<PhotoData*> photo,
|
|
||||||
not_null<PeerData*> peer) {
|
|
||||||
Expects(_mediaView != nullptr);
|
|
||||||
|
|
||||||
_mediaView->showPhoto(photo, peer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::showDocument(not_null<DocumentData*> 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(
|
void Application::showTheme(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
const Data::CloudTheme &cloud) {
|
const Data::CloudTheme &cloud) {
|
||||||
|
|
|
@ -143,10 +143,6 @@ public:
|
||||||
// Media view interface.
|
// Media view interface.
|
||||||
void checkMediaViewActivation();
|
void checkMediaViewActivation();
|
||||||
bool hideMediaView();
|
bool hideMediaView();
|
||||||
void showPhoto(not_null<const PhotoOpenClickHandler*> link);
|
|
||||||
void showPhoto(not_null<PhotoData*> photo, HistoryItem *item);
|
|
||||||
void showPhoto(not_null<PhotoData*> photo, not_null<PeerData*> item);
|
|
||||||
void showDocument(not_null<DocumentData*> document, HistoryItem *item);
|
|
||||||
void showTheme(
|
void showTheme(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
const Data::CloudTheme &cloud);
|
const Data::CloudTheme &cloud);
|
||||||
|
|
|
@ -216,6 +216,16 @@ void ResolveDocument(
|
||||||
}
|
}
|
||||||
const auto msgId = item ? item->fullId() : FullMsgId();
|
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 media = document->createMediaView();
|
||||||
const auto openImageInApp = [&] {
|
const auto openImageInApp = [&] {
|
||||||
if (document->size >= App::kImageSizeLimit) {
|
if (document->size >= App::kImageSizeLimit) {
|
||||||
|
@ -229,7 +239,7 @@ void ResolveDocument(
|
||||||
const auto path = location.name();
|
const auto path = location.name();
|
||||||
if (Core::MimeTypeForFile(path).name().startsWith("image/")
|
if (Core::MimeTypeForFile(path).name().startsWith("image/")
|
||||||
&& QImageReader(path).canRead()) {
|
&& QImageReader(path).canRead()) {
|
||||||
controller->openDocument(document, msgId, true);
|
showDocument();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (document->mimeString().startsWith("image/")
|
} else if (document->mimeString().startsWith("image/")
|
||||||
|
@ -237,7 +247,7 @@ void ResolveDocument(
|
||||||
auto bytes = media->bytes();
|
auto bytes = media->bytes();
|
||||||
auto buffer = QBuffer(&bytes);
|
auto buffer = QBuffer(&bytes);
|
||||||
if (QImageReader(&buffer).canRead()) {
|
if (QImageReader(&buffer).canRead()) {
|
||||||
controller->openDocument(document, msgId, true);
|
showDocument();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,7 +255,7 @@ void ResolveDocument(
|
||||||
};
|
};
|
||||||
const auto &location = document->location(true);
|
const auto &location = document->location(true);
|
||||||
if (document->isTheme() && media->loaded(true)) {
|
if (document->isTheme() && media->loaded(true)) {
|
||||||
controller->openDocument(document, msgId, true);
|
showDocument();
|
||||||
location.accessDisable();
|
location.accessDisable();
|
||||||
} else if (media->canBePlayed()) {
|
} else if (media->canBePlayed()) {
|
||||||
if (document->isAudioFile()
|
if (document->isAudioFile()
|
||||||
|
@ -257,7 +267,7 @@ void ResolveDocument(
|
||||||
&& HistoryView::Gif::CanPlayInline(document)) {
|
&& HistoryView::Gif::CanPlayInline(document)) {
|
||||||
document->owner().requestAnimationPlayInline(item);
|
document->owner().requestAnimationPlayInline(item);
|
||||||
} else {
|
} else {
|
||||||
controller->openDocument(document, msgId, true);
|
showDocument();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
document->saveFromDataSilent();
|
document->saveFromDataSilent();
|
||||||
|
|
Loading…
Add table
Reference in a new issue