mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced DocumentOpenClickHandler.
This commit is contained in:
parent
8591d58798
commit
1f816c249b
12 changed files with 31 additions and 35 deletions
|
@ -437,9 +437,7 @@ bool OpenMediaTimestamp(
|
||||||
documentId,
|
documentId,
|
||||||
time * crl::time(1000));
|
time * crl::time(1000));
|
||||||
if (document->isVideoFile()) {
|
if (document->isVideoFile()) {
|
||||||
Core::App().showDocument(
|
controller->openDocument(document, itemId, true);
|
||||||
document,
|
|
||||||
session->data().message(itemId));
|
|
||||||
} else if (document->isSong() || document->isVoiceMessage()) {
|
} else if (document->isSong() || document->isVoiceMessage()) {
|
||||||
Media::Player::instance()->play({ document, itemId });
|
Media::Player::instance()->play({ document, itemId });
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(
|
void DocumentSaveClickHandler::Save(
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
not_null<DocumentData*> data,
|
not_null<DocumentData*> data,
|
||||||
|
|
|
@ -365,10 +365,6 @@ public:
|
||||||
DocumentOpenClickHandler(
|
DocumentOpenClickHandler(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
Fn<void()> &&callback);
|
Fn<void()> &&callback);
|
||||||
static void Open(
|
|
||||||
Data::FileOrigin origin,
|
|
||||||
not_null<DocumentData*> document,
|
|
||||||
HistoryItem *context);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onClickImpl() const override;
|
void onClickImpl() const override;
|
||||||
|
|
|
@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
#include "platform/platform_file_utilities.h"
|
#include "platform/platform_file_utilities.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "window/window_controller.h"
|
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
|
||||||
#include <QtCore/QBuffer>
|
#include <QtCore/QBuffer>
|
||||||
|
@ -209,12 +208,13 @@ base::binary_guard ReadImageAsync(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResolveDocument(
|
void ResolveDocument(
|
||||||
// not_null<Window::Controller*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
HistoryItem *item) {
|
HistoryItem *item) {
|
||||||
if (!document->date) {
|
if (!document->date) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const auto msgId = item ? item->fullId() : FullMsgId();
|
||||||
|
|
||||||
const auto media = document->createMediaView();
|
const auto media = document->createMediaView();
|
||||||
const auto openImageInApp = [&] {
|
const auto openImageInApp = [&] {
|
||||||
|
@ -229,7 +229,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()) {
|
||||||
Core::App().showDocument(document, item);
|
controller->openDocument(document, msgId, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (document->mimeString().startsWith("image/")
|
} else if (document->mimeString().startsWith("image/")
|
||||||
|
@ -237,7 +237,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()) {
|
||||||
Core::App().showDocument(document, item);
|
controller->openDocument(document, msgId, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,20 +245,19 @@ 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)) {
|
||||||
Core::App().showDocument(document, item);
|
controller->openDocument(document, msgId, true);
|
||||||
location.accessDisable();
|
location.accessDisable();
|
||||||
} else if (media->canBePlayed()) {
|
} else if (media->canBePlayed()) {
|
||||||
if (document->isAudioFile()
|
if (document->isAudioFile()
|
||||||
|| document->isVoiceMessage()
|
|| document->isVoiceMessage()
|
||||||
|| document->isVideoMessage()) {
|
|| document->isVideoMessage()) {
|
||||||
const auto msgId = item ? item->fullId() : FullMsgId();
|
|
||||||
::Media::Player::instance()->playPause({ document, msgId });
|
::Media::Player::instance()->playPause({ document, msgId });
|
||||||
} else if (item
|
} else if (item
|
||||||
&& document->isAnimation()
|
&& document->isAnimation()
|
||||||
&& HistoryView::Gif::CanPlayInline(document)) {
|
&& HistoryView::Gif::CanPlayInline(document)) {
|
||||||
document->owner().requestAnimationPlayInline(item);
|
document->owner().requestAnimationPlayInline(item);
|
||||||
} else {
|
} else {
|
||||||
Core::App().showDocument(document, item);
|
controller->openDocument(document, msgId, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
document->saveFromDataSilent();
|
document->saveFromDataSilent();
|
||||||
|
|
|
@ -13,7 +13,7 @@ class DocumentData;
|
||||||
class HistoryItem;
|
class HistoryItem;
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class Controller;
|
class SessionController;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
@ -30,7 +30,7 @@ base::binary_guard ReadImageAsync(
|
||||||
FnMut<void(QImage&&)> done);
|
FnMut<void(QImage&&)> done);
|
||||||
|
|
||||||
void ResolveDocument(
|
void ResolveDocument(
|
||||||
// not_null<Window::Controller*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
HistoryItem *item);
|
HistoryItem *item);
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,6 @@ class PhotoSaveClickHandler;
|
||||||
class PhotoCancelClickHandler;
|
class PhotoCancelClickHandler;
|
||||||
class DocumentClickHandler;
|
class DocumentClickHandler;
|
||||||
class DocumentSaveClickHandler;
|
class DocumentSaveClickHandler;
|
||||||
class DocumentOpenClickHandler;
|
|
||||||
class DocumentCancelClickHandler;
|
class DocumentCancelClickHandler;
|
||||||
class DocumentWrappedClickHandler;
|
class DocumentWrappedClickHandler;
|
||||||
class VoiceSeekClickHandler;
|
class VoiceSeekClickHandler;
|
||||||
|
|
|
@ -1293,7 +1293,7 @@ void InnerWidget::openContextGif(FullMsgId itemId) {
|
||||||
if (const auto item = session().data().message(itemId)) {
|
if (const auto item = session().data().message(itemId)) {
|
||||||
if (const auto media = item->media()) {
|
if (const auto media = item->media()) {
|
||||||
if (const auto document = media->document()) {
|
if (const auto document = media->document()) {
|
||||||
Core::App().showDocument(document, item);
|
_controller->openDocument(document, itemId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1957,7 +1957,7 @@ void HistoryInner::openContextGif(FullMsgId itemId) {
|
||||||
if (const auto item = session().data().message(itemId)) {
|
if (const auto item = session().data().message(itemId)) {
|
||||||
if (const auto media = item->media()) {
|
if (const auto media = item->media()) {
|
||||||
if (const auto document = media->document()) {
|
if (const auto document = media->document()) {
|
||||||
Core::App().showDocument(document, item);
|
_controller->openDocument(document, itemId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,11 +157,13 @@ void AddPhotoActions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGif(not_null<Main::Session*> session, FullMsgId itemId) {
|
void OpenGif(
|
||||||
if (const auto item = session->data().message(itemId)) {
|
not_null<Window::SessionController*> controller,
|
||||||
|
FullMsgId itemId) {
|
||||||
|
if (const auto item = controller->session().data().message(itemId)) {
|
||||||
if (const auto media = item->media()) {
|
if (const auto media = item->media()) {
|
||||||
if (const auto document = media->document()) {
|
if (const auto document = media->document()) {
|
||||||
Core::App().showDocument(document, item);
|
controller->openDocument(document, itemId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,7 +225,7 @@ void AddDocumentActions(
|
||||||
}();
|
}();
|
||||||
if (notAutoplayedGif) {
|
if (notAutoplayedGif) {
|
||||||
menu->addAction(tr::lng_context_open_gif(tr::now), [=] {
|
menu->addAction(tr::lng_context_open_gif(tr::now), [=] {
|
||||||
OpenGif(session, contextId);
|
OpenGif(list->controller(), contextId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1387,7 +1387,10 @@ void Gif::playAnimation(bool autoplay) {
|
||||||
return;
|
return;
|
||||||
} else if ((_streamed && autoplayEnabled())
|
} else if ((_streamed && autoplayEnabled())
|
||||||
|| (!autoplay && _data->isVideoFile())) {
|
|| (!autoplay && _data->isVideoFile())) {
|
||||||
Core::App().showDocument(_data, _parent->data());
|
_parent->delegate()->elementOpenDocument(
|
||||||
|
_data,
|
||||||
|
_parent->data()->fullId(),
|
||||||
|
true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_streamed) {
|
if (_streamed) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_media_rotation.h"
|
#include "data/data_media_rotation.h"
|
||||||
#include "data/data_photo_media.h"
|
#include "data/data_photo_media.h"
|
||||||
#include "data/data_document_media.h"
|
#include "data/data_document_media.h"
|
||||||
|
#include "data/data_document_resolver.h"
|
||||||
#include "window/themes/window_theme_preview.h"
|
#include "window/themes/window_theme_preview.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -1554,8 +1555,11 @@ void OverlayWidget::handleDocumentClick() {
|
||||||
if (_document->loading()) {
|
if (_document->loading()) {
|
||||||
saveCancel();
|
saveCancel();
|
||||||
} else {
|
} else {
|
||||||
DocumentOpenClickHandler::Open(
|
if (!_controller) {
|
||||||
fileOrigin(),
|
return;
|
||||||
|
}
|
||||||
|
Data::ResolveDocument(
|
||||||
|
_controller,
|
||||||
_document,
|
_document,
|
||||||
_document->owner().message(_msgid));
|
_document->owner().message(_msgid));
|
||||||
if (_document->loading() && !_radial.animating()) {
|
if (_document->loading() && !_radial.animating()) {
|
||||||
|
|
|
@ -1238,7 +1238,6 @@ void SessionController::openDocument(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
FullMsgId contextId,
|
FullMsgId contextId,
|
||||||
bool showInMediaView) {
|
bool showInMediaView) {
|
||||||
// TEMP.
|
|
||||||
if (showInMediaView) {
|
if (showInMediaView) {
|
||||||
_window->openInMediaView(Media::View::OpenRequest(
|
_window->openInMediaView(Media::View::OpenRequest(
|
||||||
this,
|
this,
|
||||||
|
@ -1246,7 +1245,10 @@ void SessionController::openDocument(
|
||||||
session().data().message(contextId)));
|
session().data().message(contextId)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Data::ResolveDocument(document, session().data().message(contextId));
|
Data::ResolveDocument(
|
||||||
|
this,
|
||||||
|
document,
|
||||||
|
session().data().message(contextId));
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionController::~SessionController() = default;
|
SessionController::~SessionController() = default;
|
||||||
|
|
Loading…
Add table
Reference in a new issue