From 3fd772ce17944431327b2ba480cffaabb4ef524b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 18 Jun 2021 02:28:09 +0300 Subject: [PATCH] Moved file click handlers to separated file. --- Telegram/CMakeLists.txt | 2 + Telegram/SourceFiles/data/data_document.cpp | 151 ------------- Telegram/SourceFiles/data/data_document.h | 98 -------- .../data/data_document_resolver.cpp | 1 + .../data/data_file_click_handler.cpp | 209 ++++++++++++++++++ .../data/data_file_click_handler.h | 177 +++++++++++++++ Telegram/SourceFiles/data/data_photo.cpp | 49 ---- Telegram/SourceFiles/data/data_photo.h | 50 ----- Telegram/SourceFiles/data/data_types.cpp | 4 - Telegram/SourceFiles/data/data_types.h | 39 ---- .../admin_log/history_admin_log_inner.cpp | 1 + .../history/history_inner_widget.cpp | 1 + .../history/history_item_components.cpp | 1 + .../history/history_item_components.h | 1 + .../view/history_view_context_menu.cpp | 1 + .../history/view/history_view_list_widget.cpp | 1 + .../view/media/history_view_document.cpp | 1 + .../history/view/media/history_view_file.cpp | 8 + .../history/view/media/history_view_file.h | 14 +- .../history/view/media/history_view_gif.cpp | 1 + .../history/view/media/history_view_photo.cpp | 1 + .../view/media/history_view_sticker.cpp | 1 + .../media/history_view_theme_document.cpp | 1 + .../view/media/history_view_web_page.cpp | 1 + .../info/media/info_media_list_widget.cpp | 1 + .../inline_bots/inline_bot_result.cpp | 1 + .../media/player/media_player_instance.cpp | 1 + .../media/view/media_view_overlay_widget.cpp | 1 + .../SourceFiles/overview/overview_layout.cpp | 1 + 29 files changed, 421 insertions(+), 398 deletions(-) create mode 100644 Telegram/SourceFiles/data/data_file_click_handler.cpp create mode 100644 Telegram/SourceFiles/data/data_file_click_handler.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 66b712eb4..0029d6eeb 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -428,6 +428,8 @@ PRIVATE data/data_drafts.h data/data_folder.cpp data/data_folder.h + data/data_file_click_handler.cpp + data/data_file_click_handler.h data/data_file_origin.cpp data/data_file_origin.h data/data_flags.h diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index c5bef87ea..1a1b718a7 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -76,59 +76,6 @@ QString JoinStringList(const QStringList &list, const QString &separator) { return result; } -void LaunchWithWarning( - not_null session, - const QString &name, - HistoryItem *item) { - const auto isExecutable = Data::IsExecutableName(name); - const auto isIpReveal = Data::IsIpRevealingName(name); - auto &app = Core::App(); - const auto warn = [&] { - if (item && item->history()->peer->isVerified()) { - return false; - } - return (isExecutable && app.settings().exeLaunchWarning()) - || (isIpReveal && app.settings().ipRevealWarning()); - }(); - const auto extension = '.' + Data::FileExtension(name); - if (Platform::IsWindows() && extension == u"."_q) { - // If you launch a file without extension, like "test", in case - // there is an executable file with the same name in this folder, - // like "test.bat", the executable file will be launched. - // - // Now we always force an Open With dialog box for such files. - crl::on_main([=] { - Platform::File::UnsafeShowOpenWith(name); - }); - return; - } else if (!warn) { - File::Launch(name); - return; - } - const auto callback = [=, &app](bool checked) { - if (checked) { - if (isExecutable) { - app.settings().setExeLaunchWarning(false); - } else if (isIpReveal) { - app.settings().setIpRevealWarning(false); - } - app.saveSettingsDelayed(); - } - File::Launch(name); - }; - auto text = isExecutable - ? tr::lng_launch_exe_warning( - lt_extension, - rpl::single(Ui::Text::Bold(extension)), - Ui::Text::WithEntities) - : tr::lng_launch_svg_warning(Ui::Text::WithEntities); - Ui::show(Box( - std::move(text), - tr::lng_launch_exe_dont_ask(tr::now), - (isExecutable ? tr::lng_launch_exe_sure : tr::lng_continue)(), - callback)); -} - } // namespace QString FileNameUnsafe( @@ -309,104 +256,6 @@ QString DocumentFileNameForSave( dir); } -DocumentClickHandler::DocumentClickHandler( - not_null document, - FullMsgId context) -: FileClickHandler(&document->session(), context) -, _document(document) { -} - -DocumentOpenClickHandler::DocumentOpenClickHandler( - not_null document, - Fn &&callback) -: DocumentClickHandler(document) -, _handler(std::move(callback)) { -} - -void DocumentOpenClickHandler::onClickImpl() const { - if (_handler) { - _handler(); - } -} - -void DocumentSaveClickHandler::Save( - Data::FileOrigin origin, - not_null data, - Mode mode) { - if (!data->date) { - return; - } - - auto savename = QString(); - if (mode != Mode::ToCacheOrFile || !data->saveToCache()) { - if (mode != Mode::ToNewFile && data->saveFromData()) { - return; - } - const auto filepath = data->filepath(true); - const auto fileinfo = QFileInfo( - ); - const auto filedir = filepath.isEmpty() - ? QDir() - : fileinfo.dir(); - const auto filename = filepath.isEmpty() - ? QString() - : fileinfo.fileName(); - savename = DocumentFileNameForSave( - data, - (mode == Mode::ToNewFile), - filename, - filedir); - if (savename.isEmpty()) { - return; - } - } - data->save(origin, savename); -} - -void DocumentSaveClickHandler::onClickImpl() const { - Save(context(), document()); -} - -void DocumentCancelClickHandler::onClickImpl() const { - const auto data = document(); - if (!data->date) { - return; - } else if (data->uploading()) { - if (const auto item = data->owner().message(context())) { - if (const auto m = App::main()) { // multi good - if (&m->session() == &data->session()) { - m->cancelUploadLayer(item); - } - } - } - } else { - data->cancel(); - } -} - -void DocumentOpenWithClickHandler::Open( - Data::FileOrigin origin, - not_null data) { - if (!data->date) { - return; - } - - data->saveFromDataSilent(); - const auto path = data->filepath(true); - if (!path.isEmpty()) { - File::OpenWith(path, QCursor::pos()); - } else { - DocumentSaveClickHandler::Save( - origin, - data, - DocumentSaveClickHandler::Mode::ToFile); - } -} - -void DocumentOpenWithClickHandler::onClickImpl() const { - Open(context(), document()); -} - Data::FileOrigin StickerData::setOrigin() const { return set.match([&](const MTPDinputStickerSetID &data) { return Data::FileOrigin( diff --git a/Telegram/SourceFiles/data/data_document.h b/Telegram/SourceFiles/data/data_document.h index 510df4c77..706f04743 100644 --- a/Telegram/SourceFiles/data/data_document.h +++ b/Telegram/SourceFiles/data/data_document.h @@ -327,104 +327,6 @@ private: VoiceWaveform documentWaveformDecode(const QByteArray &encoded5bit); QByteArray documentWaveformEncode5bit(const VoiceWaveform &waveform); -class DocumentClickHandler : public FileClickHandler { -public: - DocumentClickHandler( - not_null document, - FullMsgId context = FullMsgId()); - - [[nodiscard]] not_null document() const { - return _document; - } - -private: - const not_null _document; - -}; - -class DocumentSaveClickHandler : public DocumentClickHandler { -public: - enum class Mode { - ToCacheOrFile, - ToFile, - ToNewFile, - }; - using DocumentClickHandler::DocumentClickHandler; - static void Save( - Data::FileOrigin origin, - not_null document, - Mode mode = Mode::ToCacheOrFile); - -protected: - void onClickImpl() const override; - -}; - -class DocumentOpenClickHandler : public DocumentClickHandler { -public: - DocumentOpenClickHandler( - not_null document, - Fn &&callback); - -protected: - void onClickImpl() const override; - -private: - Fn _handler; - -}; - -class DocumentCancelClickHandler : public DocumentClickHandler { -public: - using DocumentClickHandler::DocumentClickHandler; - -protected: - void onClickImpl() const override; - -}; - -class DocumentOpenWithClickHandler : public DocumentClickHandler { -public: - using DocumentClickHandler::DocumentClickHandler; - static void Open( - Data::FileOrigin origin, - not_null document); - -protected: - void onClickImpl() const override; - -}; - -class VoiceSeekClickHandler : public DocumentOpenClickHandler { -public: - using DocumentOpenClickHandler::DocumentOpenClickHandler; - -protected: - void onClickImpl() const override { - } - -}; - -class DocumentWrappedClickHandler : public DocumentClickHandler { -public: - DocumentWrappedClickHandler( - ClickHandlerPtr wrapped, - not_null document, - FullMsgId context = FullMsgId()) - : DocumentClickHandler(document, context) - , _wrapped(wrapped) { - } - -protected: - void onClickImpl() const override { - _wrapped->onClick({ Qt::LeftButton }); - } - -private: - ClickHandlerPtr _wrapped; - -}; - QString FileNameForSave( not_null session, const QString &title, diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index 32d9049bd..df6e4ea67 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/mime_type.h" #include "data/data_document.h" #include "data/data_document_media.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_session.h" #include "history/view/media/history_view_gif.h" diff --git a/Telegram/SourceFiles/data/data_file_click_handler.cpp b/Telegram/SourceFiles/data/data_file_click_handler.cpp new file mode 100644 index 000000000..bae51c79e --- /dev/null +++ b/Telegram/SourceFiles/data/data_file_click_handler.cpp @@ -0,0 +1,209 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "data/data_file_click_handler.h" + +#include "core/file_utilities.h" +#include "data/data_document.h" +#include "data/data_photo.h" +#include "data/data_session.h" +#include "main/main_session.h" +#include "mainwidget.h" // App::main + +FileClickHandler::FileClickHandler( + not_null session, + FullMsgId context) +: _session(session) +, _context(context) { +} + +Main::Session &FileClickHandler::session() const { + return *_session; +} + +void FileClickHandler::setMessageId(FullMsgId context) { + _context = context; +} + +FullMsgId FileClickHandler::context() const { + return _context; +} + +HistoryItem *FileClickHandler::getActionItem() const { + return _session->data().message(context()); +} + +not_null DocumentClickHandler::document() const { + return _document; +} + +DocumentWrappedClickHandler::DocumentWrappedClickHandler( + ClickHandlerPtr wrapped, + not_null document, + FullMsgId context) +: DocumentClickHandler(document, context) +, _wrapped(wrapped) { +} + +void DocumentWrappedClickHandler::onClickImpl() const { + _wrapped->onClick({ Qt::LeftButton }); +} + +DocumentClickHandler::DocumentClickHandler( + not_null document, + FullMsgId context) +: FileClickHandler(&document->session(), context) +, _document(document) { +} + +DocumentOpenClickHandler::DocumentOpenClickHandler( + not_null document, + Fn &&callback) +: DocumentClickHandler(document) +, _handler(std::move(callback)) { +} + +void DocumentOpenClickHandler::onClickImpl() const { + if (_handler) { + _handler(); + } +} + +void DocumentSaveClickHandler::Save( + Data::FileOrigin origin, + not_null data, + Mode mode) { + if (!data->date) { + return; + } + + auto savename = QString(); + if (mode != Mode::ToCacheOrFile || !data->saveToCache()) { + if (mode != Mode::ToNewFile && data->saveFromData()) { + return; + } + const auto filepath = data->filepath(true); + const auto fileinfo = QFileInfo( + ); + const auto filedir = filepath.isEmpty() + ? QDir() + : fileinfo.dir(); + const auto filename = filepath.isEmpty() + ? QString() + : fileinfo.fileName(); + savename = DocumentFileNameForSave( + data, + (mode == Mode::ToNewFile), + filename, + filedir); + if (savename.isEmpty()) { + return; + } + } + data->save(origin, savename); +} + +void DocumentSaveClickHandler::onClickImpl() const { + Save(context(), document()); +} + +void DocumentCancelClickHandler::onClickImpl() const { + const auto data = document(); + if (!data->date) { + return; + } else if (data->uploading()) { + if (const auto item = data->owner().message(context())) { + if (const auto m = App::main()) { // multi good + if (&m->session() == &data->session()) { + m->cancelUploadLayer(item); + } + } + } + } else { + data->cancel(); + } +} + +void DocumentOpenWithClickHandler::Open( + Data::FileOrigin origin, + not_null data) { + if (!data->date) { + return; + } + + data->saveFromDataSilent(); + const auto path = data->filepath(true); + if (!path.isEmpty()) { + File::OpenWith(path, QCursor::pos()); + } else { + DocumentSaveClickHandler::Save( + origin, + data, + DocumentSaveClickHandler::Mode::ToFile); + } +} + +void DocumentOpenWithClickHandler::onClickImpl() const { + Open(context(), document()); +} + +PhotoClickHandler::PhotoClickHandler( + not_null photo, + FullMsgId context, + PeerData *peer) +: FileClickHandler(&photo->session(), context) +, _photo(photo) +, _peer(peer) { +} + +not_null PhotoClickHandler::photo() const { + return _photo; +} + +PeerData *PhotoClickHandler::peer() const { + return _peer; +} + +PhotoOpenClickHandler::PhotoOpenClickHandler( + not_null photo, + Fn &&callback) +: PhotoClickHandler(photo) +, _handler(std::move(callback)) { +} + +void PhotoOpenClickHandler::onClickImpl() const { + if (_handler) { + _handler(); + } +} + +void PhotoSaveClickHandler::onClickImpl() const { + const auto data = photo(); + if (!data->date) { + return; + } else { + data->clearFailed(Data::PhotoSize::Large); + data->load(context()); + } +} + +void PhotoCancelClickHandler::onClickImpl() const { + const auto data = photo(); + if (!data->date) { + return; + } else if (data->uploading()) { + if (const auto item = data->owner().message(context())) { + if (const auto m = App::main()) { // multi good + if (&m->session() == &data->session()) { + m->cancelUploadLayer(item); + } + } + } + } else { + data->cancel(); + } +} diff --git a/Telegram/SourceFiles/data/data_file_click_handler.h b/Telegram/SourceFiles/data/data_file_click_handler.h new file mode 100644 index 000000000..7d1f7ff81 --- /dev/null +++ b/Telegram/SourceFiles/data/data_file_click_handler.h @@ -0,0 +1,177 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +#include "data/data_file_origin.h" +#include "ui/basic_click_handlers.h" + +class DocumentData; +class HistoryItem; +class PhotoData; + +namespace Main { +class Session; +} // namespace Main + +class FileClickHandler : public LeftButtonClickHandler { +public: + FileClickHandler( + not_null session, + FullMsgId context); + + [[nodiscard]] Main::Session &session() const; + + void setMessageId(FullMsgId context); + + [[nodiscard]] FullMsgId context() const; + +protected: + HistoryItem *getActionItem() const; + +private: + const not_null _session; + FullMsgId _context; + +}; + +class DocumentClickHandler : public FileClickHandler { +public: + DocumentClickHandler( + not_null document, + FullMsgId context = FullMsgId()); + + [[nodiscard]] not_null document() const; + +private: + const not_null _document; + +}; + +class DocumentSaveClickHandler : public DocumentClickHandler { +public: + enum class Mode { + ToCacheOrFile, + ToFile, + ToNewFile, + }; + using DocumentClickHandler::DocumentClickHandler; + static void Save( + Data::FileOrigin origin, + not_null document, + Mode mode = Mode::ToCacheOrFile); + +protected: + void onClickImpl() const override; + +}; + +class DocumentOpenClickHandler : public DocumentClickHandler { +public: + DocumentOpenClickHandler( + not_null document, + Fn &&callback); + +protected: + void onClickImpl() const override; + +private: + Fn _handler; + +}; + +class DocumentCancelClickHandler : public DocumentClickHandler { +public: + using DocumentClickHandler::DocumentClickHandler; + +protected: + void onClickImpl() const override; + +}; + +class DocumentOpenWithClickHandler : public DocumentClickHandler { +public: + using DocumentClickHandler::DocumentClickHandler; + static void Open( + Data::FileOrigin origin, + not_null document); + +protected: + void onClickImpl() const override; + +}; + +class VoiceSeekClickHandler : public DocumentOpenClickHandler { +public: + using DocumentOpenClickHandler::DocumentOpenClickHandler; + +protected: + void onClickImpl() const override { + } + +}; + +class DocumentWrappedClickHandler : public DocumentClickHandler { +public: + DocumentWrappedClickHandler( + ClickHandlerPtr wrapped, + not_null document, + FullMsgId context = FullMsgId()); + +protected: + void onClickImpl() const override; + +private: + ClickHandlerPtr _wrapped; + +}; + +class PhotoClickHandler : public FileClickHandler { +public: + PhotoClickHandler( + not_null photo, + FullMsgId context = FullMsgId(), + PeerData *peer = nullptr); + + [[nodiscard]] not_null photo() const; + [[nodiscard]] PeerData *peer() const; + +private: + const not_null _photo; + PeerData * const _peer = nullptr; + +}; + +class PhotoOpenClickHandler : public PhotoClickHandler { +public: + PhotoOpenClickHandler(not_null photo, Fn &&callback); + +protected: + void onClickImpl() const override; + +private: + Fn _handler; + +}; + +class PhotoSaveClickHandler : public PhotoClickHandler { +public: + using PhotoClickHandler::PhotoClickHandler; + +protected: + void onClickImpl() const override; + +}; + +class PhotoCancelClickHandler : public PhotoClickHandler { +public: + using PhotoClickHandler::PhotoClickHandler; + +protected: + void onClickImpl() const override; + +}; diff --git a/Telegram/SourceFiles/data/data_photo.cpp b/Telegram/SourceFiles/data/data_photo.cpp index 90e434f81..f93d6fb67 100644 --- a/Telegram/SourceFiles/data/data_photo.cpp +++ b/Telegram/SourceFiles/data/data_photo.cpp @@ -468,52 +468,3 @@ auto PhotoData::createStreamingLoader( origin) : nullptr; } - -PhotoClickHandler::PhotoClickHandler( - not_null photo, - FullMsgId context, - PeerData *peer) -: FileClickHandler(&photo->session(), context) -, _photo(photo) -, _peer(peer) { -} - -PhotoOpenClickHandler::PhotoOpenClickHandler( - not_null photo, - Fn &&callback) -: PhotoClickHandler(photo) -, _handler(std::move(callback)) { -} - -void PhotoOpenClickHandler::onClickImpl() const { - if (_handler) { - _handler(); - } -} - -void PhotoSaveClickHandler::onClickImpl() const { - const auto data = photo(); - if (!data->date) { - return; - } else { - data->clearFailed(PhotoSize::Large); - data->load(context()); - } -} - -void PhotoCancelClickHandler::onClickImpl() const { - const auto data = photo(); - if (!data->date) { - return; - } else if (data->uploading()) { - if (const auto item = data->owner().message(context())) { - if (const auto m = App::main()) { // multi good - if (&m->session() == &data->session()) { - m->cancelUploadLayer(item); - } - } - } - } else { - data->cancel(); - } -} diff --git a/Telegram/SourceFiles/data/data_photo.h b/Telegram/SourceFiles/data/data_photo.h index db244f952..4922b28d3 100644 --- a/Telegram/SourceFiles/data/data_photo.h +++ b/Telegram/SourceFiles/data/data_photo.h @@ -175,53 +175,3 @@ private: not_null _owner; }; - -class PhotoClickHandler : public FileClickHandler { -public: - PhotoClickHandler( - not_null photo, - FullMsgId context = FullMsgId(), - PeerData *peer = nullptr); - - [[nodiscard]] not_null photo() const { - return _photo; - } - [[nodiscard]] PeerData *peer() const { - return _peer; - } - -private: - const not_null _photo; - PeerData * const _peer = nullptr; - -}; - -class PhotoOpenClickHandler : public PhotoClickHandler { -public: - PhotoOpenClickHandler(not_null photo, Fn &&callback); - -protected: - void onClickImpl() const override; - -private: - Fn _handler; - -}; - -class PhotoSaveClickHandler : public PhotoClickHandler { -public: - using PhotoClickHandler::PhotoClickHandler; - -protected: - void onClickImpl() const override; - -}; - -class PhotoCancelClickHandler : public PhotoClickHandler { -public: - using PhotoClickHandler::PhotoClickHandler; - -protected: - void onClickImpl() const override; - -}; diff --git a/Telegram/SourceFiles/data/data_types.cpp b/Telegram/SourceFiles/data/data_types.cpp index 644caebe6..6f3a86532 100644 --- a/Telegram/SourceFiles/data/data_types.cpp +++ b/Telegram/SourceFiles/data/data_types.cpp @@ -133,10 +133,6 @@ void MessageCursor::applyTo(not_null field) { field->scrollTo(scroll); } -HistoryItem *FileClickHandler::getActionItem() const { - return _session->data().message(context()); -} - PeerId PeerFromMessage(const MTPmessage &message) { return message.match([](const MTPDmessageEmpty &) { return PeerId(0); diff --git a/Telegram/SourceFiles/data/data_types.h b/Telegram/SourceFiles/data/data_types.h index b2ea50194..b3cd44bf2 100644 --- a/Telegram/SourceFiles/data/data_types.h +++ b/Telegram/SourceFiles/data/data_types.h @@ -193,15 +193,6 @@ struct GameData; struct PollData; class AudioMsgId; -class PhotoClickHandler; -class PhotoOpenClickHandler; -class PhotoSaveClickHandler; -class PhotoCancelClickHandler; -class DocumentClickHandler; -class DocumentSaveClickHandler; -class DocumentCancelClickHandler; -class DocumentWrappedClickHandler; -class VoiceSeekClickHandler; using PhotoId = uint64; using VideoId = uint64; @@ -360,33 +351,3 @@ inline bool operator!=( const MessageCursor &b) { return !(a == b); } - -class FileClickHandler : public LeftButtonClickHandler { -public: - FileClickHandler( - not_null session, - FullMsgId context) - : _session(session) - , _context(context) { - } - - [[nodiscard]] Main::Session &session() const { - return *_session; - } - - void setMessageId(FullMsgId context) { - _context = context; - } - - [[nodiscard]] FullMsgId context() const { - return _context; - } - -protected: - HistoryItem *getActionItem() const; - -private: - const not_null _session; - FullMsgId _context; - -}; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index a9b9008fe..d37a2cef8 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo_media.h" #include "data/data_document.h" #include "data/data_media_types.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_cloud_file.h" #include "data/data_channel.h" diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index ba8cf49be..87c675827 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -61,6 +61,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_photo_media.h" #include "data/data_user.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_histories.h" #include "data/data_changes.h" diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 07863eab1..f8502321f 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "data/data_file_origin.h" #include "data/data_document.h" +#include "data/data_file_click_handler.h" #include "main/main_session.h" #include "window/window_session_controller.h" #include "facades.h" diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index 2061c4230..b60a8d051 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/animations.h" struct WebPageData; +class VoiceSeekClickHandler; namespace Data { class Session; diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index f5446a477..1929ae288 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_groups.h" #include "data/data_channel.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_scheduled_messages.h" #include "core/file_utilities.h" diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 3a3d6e524..d38f4817a 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "data/data_chat.h" #include "data/data_channel.h" +#include "data/data_file_click_handler.h" #include "facades.h" #include "styles/style_chat.h" diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index b915e6c28..52b5f2a28 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document_media.h" #include "data/data_document_resolver.h" #include "data/data_media_types.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "styles/style_chat.h" diff --git a/Telegram/SourceFiles/history/view/media/history_view_file.cpp b/Telegram/SourceFiles/history/view/media/history_view_file.cpp index f5c82f92c..4ea0ec3c1 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_file.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_file.cpp @@ -13,11 +13,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/view/history_view_element.h" #include "data/data_document.h" +#include "data/data_file_click_handler.h" #include "data/data_session.h" #include "styles/style_chat.h" namespace HistoryView { +bool File::toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const { + return p == _openl || p == _savel || p == _cancell; +} +bool File::dragItemByHandler(const ClickHandlerPtr &p) const { + return p == _openl || p == _savel || p == _cancell; +} + void File::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { if (p == _savel || p == _cancell) { if (active && !dataLoaded()) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_file.h b/Telegram/SourceFiles/history/view/media/history_view_file.h index 1a1542132..ef097254b 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_file.h +++ b/Telegram/SourceFiles/history/view/media/history_view_file.h @@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/animations.h" #include "ui/effects/radial_animation.h" +class FileClickHandler; + namespace HistoryView { class File : public Media, public base::has_weak_ptr { @@ -22,19 +24,17 @@ public: , _realParent(realParent) { } - bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override { - return p == _openl || p == _savel || p == _cancell; - } - bool dragItemByHandler(const ClickHandlerPtr &p) const override { - return p == _openl || p == _savel || p == _cancell; - } + [[nodiscard]] bool toggleSelectionByHandlerClick( + const ClickHandlerPtr &p) const override; + [[nodiscard]] bool dragItemByHandler( + const ClickHandlerPtr &p) const override; void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override; void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override; void refreshParentId(not_null realParent) override; - bool allowsFastShare() const override { + [[nodiscard]] bool allowsFastShare() const override { return true; } diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 43a80eb82..63a393235 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_streaming.h" #include "data/data_document.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_document_media.h" #include "layout.h" // FullSelection diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index 2095b9419..db755a43f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_streaming.h" #include "data/data_photo.h" #include "data/data_photo_media.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_auto_download.h" #include "core/application.h" diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp index e9f0e3d68..bea40fe9c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp @@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_document.h" #include "data/data_document_media.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "lottie/lottie_single_player.h" #include "chat_helpers/stickers_lottie.h" diff --git a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp index 43938b0c4..2d97754c3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document.h" #include "data/data_session.h" #include "data/data_document_media.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "base/qthelp_url.h" #include "ui/text/format_values.h" diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 87b096b22..7aa183612 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_web_page.h" #include "data/data_photo.h" #include "data/data_photo_media.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "styles/style_chat.h" diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index a2afe49fd..471a0b068 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_document.h" #include "data/data_session.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "history/history_item.h" #include "history/history.h" diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp index 4e4d5f800..110901d8f 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_result.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_document.h" #include "data/data_session.h" +#include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_photo_media.h" #include "data/data_document_media.h" diff --git a/Telegram/SourceFiles/media/player/media_player_instance.cpp b/Telegram/SourceFiles/media/player/media_player_instance.cpp index 71aa09757..46c848749 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.cpp +++ b/Telegram/SourceFiles/media/player/media_player_instance.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document.h" #include "data/data_session.h" #include "data/data_streaming.h" +#include "data/data_file_click_handler.h" #include "media/audio/media_audio.h" #include "media/audio/media_audio_capture.h" #include "media/streaming/media_streaming_instance.h" diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index e18107528..6f2b894d9 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -50,6 +50,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo_media.h" #include "data/data_document_media.h" #include "data/data_document_resolver.h" +#include "data/data_file_click_handler.h" #include "window/themes/window_theme_preview.h" #include "window/window_peer_menu.h" #include "window/window_session_controller.h" diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 9cfaa5c49..5c0961987 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_file_origin.h" #include "data/data_photo_media.h" #include "data/data_document_media.h" +#include "data/data_file_click_handler.h" #include "styles/style_overview.h" #include "styles/style_chat.h" #include "core/file_utilities.h"