2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Replaced DocumentOpenClickHandler.

This commit is contained in:
23rd
2021-06-17 00:33:51 +03:00
committed by John Preston
parent 8591d58798
commit 1f816c249b
12 changed files with 31 additions and 35 deletions

View File

@@ -329,13 +329,6 @@ void DocumentOpenClickHandler::onClickImpl() const {
}
}
void DocumentOpenClickHandler::Open(
Data::FileOrigin origin,
not_null<DocumentData*> data,
HistoryItem *context) {
Data::ResolveDocument(data, context);
}
void DocumentSaveClickHandler::Save(
Data::FileOrigin origin,
not_null<DocumentData*> data,

View File

@@ -365,10 +365,6 @@ public:
DocumentOpenClickHandler(
not_null<DocumentData*> document,
Fn<void()> &&callback);
static void Open(
Data::FileOrigin origin,
not_null<DocumentData*> document,
HistoryItem *context);
protected:
void onClickImpl() const override;

View File

@@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/player/media_player_instance.h"
#include "platform/platform_file_utilities.h"
#include "ui/text/text_utilities.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
#include <QtCore/QBuffer>
@@ -209,12 +208,13 @@ base::binary_guard ReadImageAsync(
}
void ResolveDocument(
// not_null<Window::Controller*> controller,
not_null<Window::SessionController*> controller,
not_null<DocumentData*> document,
HistoryItem *item) {
if (!document->date) {
return;
}
const auto msgId = item ? item->fullId() : FullMsgId();
const auto media = document->createMediaView();
const auto openImageInApp = [&] {
@@ -229,7 +229,7 @@ void ResolveDocument(
const auto path = location.name();
if (Core::MimeTypeForFile(path).name().startsWith("image/")
&& QImageReader(path).canRead()) {
Core::App().showDocument(document, item);
controller->openDocument(document, msgId, true);
return true;
}
} else if (document->mimeString().startsWith("image/")
@@ -237,7 +237,7 @@ void ResolveDocument(
auto bytes = media->bytes();
auto buffer = QBuffer(&bytes);
if (QImageReader(&buffer).canRead()) {
Core::App().showDocument(document, item);
controller->openDocument(document, msgId, true);
return true;
}
}
@@ -245,20 +245,19 @@ void ResolveDocument(
};
const auto &location = document->location(true);
if (document->isTheme() && media->loaded(true)) {
Core::App().showDocument(document, item);
controller->openDocument(document, msgId, true);
location.accessDisable();
} else if (media->canBePlayed()) {
if (document->isAudioFile()
|| document->isVoiceMessage()
|| document->isVideoMessage()) {
const auto msgId = item ? item->fullId() : FullMsgId();
::Media::Player::instance()->playPause({ document, msgId });
} else if (item
&& document->isAnimation()
&& HistoryView::Gif::CanPlayInline(document)) {
document->owner().requestAnimationPlayInline(item);
} else {
Core::App().showDocument(document, item);
controller->openDocument(document, msgId, true);
}
} else {
document->saveFromDataSilent();

View File

@@ -13,7 +13,7 @@ class DocumentData;
class HistoryItem;
namespace Window {
class Controller;
class SessionController;
} // namespace Window
namespace Data {
@@ -30,7 +30,7 @@ base::binary_guard ReadImageAsync(
FnMut<void(QImage&&)> done);
void ResolveDocument(
// not_null<Window::Controller*> controller,
not_null<Window::SessionController*> controller,
not_null<DocumentData*> document,
HistoryItem *item);

View File

@@ -199,7 +199,6 @@ class PhotoSaveClickHandler;
class PhotoCancelClickHandler;
class DocumentClickHandler;
class DocumentSaveClickHandler;
class DocumentOpenClickHandler;
class DocumentCancelClickHandler;
class DocumentWrappedClickHandler;
class VoiceSeekClickHandler;