diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 825144f63..dc7257717 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -11,18 +11,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "history/history_location_manager.h" #include "history/view/history_view_element.h" -#include "history/media/history_media_photo.h" -#include "history/media/history_media_sticker.h" -#include "history/media/history_media_gif.h" -#include "history/media/history_media_video.h" -#include "history/media/history_media_document.h" -#include "history/media/history_media_contact.h" -#include "history/media/history_media_location.h" -#include "history/media/history_media_game.h" -#include "history/media/history_media_invoice.h" -#include "history/media/history_media_call.h" -#include "history/media/history_media_web_page.h" -#include "history/media/history_media_poll.h" +#include "history/view/media/history_view_photo.h" +#include "history/view/media/history_view_sticker.h" +#include "history/view/media/history_view_gif.h" +#include "history/view/media/history_view_video.h" +#include "history/view/media/history_view_document.h" +#include "history/view/media/history_view_contact.h" +#include "history/view/media/history_view_location.h" +#include "history/view/media/history_view_game.h" +#include "history/view/media/history_view_invoice.h" +#include "history/view/media/history_view_call.h" +#include "history/view/media/history_view_web_page.h" +#include "history/view/media/history_view_poll.h" #include "ui/image/image.h" #include "ui/image/image_source.h" #include "ui/text_options.h" @@ -237,7 +237,7 @@ TextWithEntities Media::consumedMessageText() const { return {}; } -std::unique_ptr Media::createView( +std::unique_ptr Media::createView( not_null message) { return createView(message, message->data()); } @@ -471,17 +471,17 @@ bool MediaPhoto::updateSentMedia(const MTPMessageMedia &media) { return true; } -std::unique_ptr MediaPhoto::createView( +std::unique_ptr MediaPhoto::createView( not_null message, not_null realParent) { if (_chat) { - return std::make_unique( + return std::make_unique( message, _chat, _photo, st::msgServicePhotoWidth); } - return std::make_unique( + return std::make_unique( message, realParent, _photo); @@ -611,7 +611,10 @@ QString MediaFile::notificationText() const { QString MediaFile::pinnedTextSubstring() const { if (const auto sticker = _document->sticker()) { if (!_emoji.isEmpty()) { - return tr::lng_action_pinned_media_emoji_sticker(tr::now, lt_emoji, _emoji); + return tr::lng_action_pinned_media_emoji_sticker( + tr::now, + lt_emoji, + _emoji); } return tr::lng_action_pinned_media_sticker(tr::now); } else if (_document->isAnimation()) { @@ -637,7 +640,10 @@ TextForMimeData MediaFile::clipboardText() const { : QString(); if (const auto sticker = _document->sticker()) { if (!_emoji.isEmpty()) { - return tr::lng_in_dlg_sticker_emoji(tr::now, lt_emoji, _emoji); + return tr::lng_in_dlg_sticker_emoji( + tr::now, + lt_emoji, + _emoji); } return tr::lng_in_dlg_sticker(tr::now); } else if (_document->isAnimation()) { @@ -759,20 +765,20 @@ bool MediaFile::updateSentMedia(const MTPMessageMedia &media) { return true; } -std::unique_ptr MediaFile::createView( +std::unique_ptr MediaFile::createView( not_null message, not_null realParent) { if (_document->sticker()) { - return std::make_unique(message, _document); + return std::make_unique(message, _document); } else if (_document->isAnimation()) { - return std::make_unique(message, _document); + return std::make_unique(message, _document); } else if (_document->isVideoFile()) { - return std::make_unique( + return std::make_unique( message, realParent, _document); } - return std::make_unique(message, _document); + return std::make_unique(message, _document); } MediaContact::MediaContact( @@ -818,7 +824,9 @@ QString MediaContact::pinnedTextSubstring() const { } TextForMimeData MediaContact::clipboardText() const { - const auto text = qsl("[ ") + tr::lng_in_dlg_contact(tr::now) + qsl(" ]\n") + const auto text = qsl("[ ") + + tr::lng_in_dlg_contact(tr::now) + + qsl(" ]\n") + tr::lng_full_name( tr::now, lt_first_name, @@ -850,10 +858,10 @@ bool MediaContact::updateSentMedia(const MTPMessageMedia &media) { return true; } -std::unique_ptr MediaContact::createView( +std::unique_ptr MediaContact::createView( not_null message, not_null realParent) { - return std::make_unique( + return std::make_unique( message, _contact.userId, _contact.firstName, @@ -929,10 +937,10 @@ bool MediaLocation::updateSentMedia(const MTPMessageMedia &media) { return false; } -std::unique_ptr MediaLocation::createView( +std::unique_ptr MediaLocation::createView( not_null message, not_null realParent) { - return std::make_unique( + return std::make_unique( message, _location, _title, @@ -988,10 +996,10 @@ bool MediaCall::updateSentMedia(const MTPMessageMedia &media) { return false; } -std::unique_ptr MediaCall::createView( +std::unique_ptr MediaCall::createView( not_null message, not_null realParent) { - return std::make_unique(message, &_call); + return std::make_unique(message, &_call); } QString MediaCall::Text( @@ -1083,10 +1091,10 @@ bool MediaWebPage::updateSentMedia(const MTPMessageMedia &media) { return false; } -std::unique_ptr MediaWebPage::createView( +std::unique_ptr MediaWebPage::createView( not_null message, not_null realParent) { - return std::make_unique(message, _page); + return std::make_unique(message, _page); } MediaGame::MediaGame( @@ -1174,10 +1182,13 @@ bool MediaGame::updateSentMedia(const MTPMessageMedia &media) { return true; } -std::unique_ptr MediaGame::createView( +std::unique_ptr MediaGame::createView( not_null message, not_null realParent) { - return std::make_unique(message, _game, _consumedText); + return std::make_unique( + message, + _game, + _consumedText); } MediaInvoice::MediaInvoice( @@ -1236,10 +1247,10 @@ bool MediaInvoice::updateSentMedia(const MTPMessageMedia &media) { return true; } -std::unique_ptr MediaInvoice::createView( +std::unique_ptr MediaInvoice::createView( not_null message, not_null realParent) { - return std::make_unique(message, &_invoice); + return std::make_unique(message, &_invoice); } MediaPoll::MediaPoll( @@ -1299,10 +1310,10 @@ bool MediaPoll::updateSentMedia(const MTPMessageMedia &media) { return false; } -std::unique_ptr MediaPoll::createView( +std::unique_ptr MediaPoll::createView( not_null message, not_null realParent) { - return std::make_unique(message, _poll); + return std::make_unique(message, _poll); } } // namespace Data diff --git a/Telegram/SourceFiles/data/data_media_types.h b/Telegram/SourceFiles/data/data_media_types.h index 04a314623..7803e503d 100644 --- a/Telegram/SourceFiles/data/data_media_types.h +++ b/Telegram/SourceFiles/data/data_media_types.h @@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once class HistoryItem; -class HistoryMedia; namespace base { template @@ -23,6 +22,7 @@ using SharedMediaTypesMask = base::enum_mask; namespace HistoryView { enum class Context : char; class Element; +class Media; } // namespace HistoryView namespace Data { @@ -107,10 +107,10 @@ public: // the media (all media that was generated on client side, for example). virtual bool updateInlineResultMedia(const MTPMessageMedia &media) = 0; virtual bool updateSentMedia(const MTPMessageMedia &media) = 0; - virtual std::unique_ptr createView( + virtual std::unique_ptr createView( not_null message, not_null realParent) = 0; - std::unique_ptr createView( + std::unique_ptr createView( not_null message); private: @@ -148,7 +148,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -185,7 +185,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -214,7 +214,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -244,7 +244,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -271,7 +271,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -307,7 +307,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -338,7 +338,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -369,7 +369,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; @@ -396,7 +396,7 @@ public: bool updateInlineResultMedia(const MTPMessageMedia &media) override; bool updateSentMedia(const MTPMessageMedia &media) override; - std::unique_ptr createView( + std::unique_ptr createView( not_null message, not_null realParent) override; diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 103190eff..e1a560e65 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -20,7 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/notifications_manager.h" #include "history/history.h" #include "history/history_item_components.h" -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" #include "history/view/history_view_element.h" #include "inline_bots/inline_bot_layout_item.h" #include "storage/localstorage.h" diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index aa63c5f3c..62a5d47aa 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -22,7 +22,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace App { // Hackish.. QString formatPhone(QString phone); } // namespace App +namespace HistoryView { QString FillAmountAndCurrency(uint64 amount, const QString ¤cy); +} // namespace HistoryView QString formatSizeText(qint64 size); QString formatDurationText(qint64 duration); @@ -1725,7 +1727,7 @@ Utf8String FormatDateTime( } Utf8String FormatMoneyAmount(uint64 amount, const Utf8String ¤cy) { - return FillAmountAndCurrency( + return HistoryView::FillAmountAndCurrency( amount, QString::fromUtf8(currency)).toUtf8(); } diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index fb667dd24..42ea69cdb 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -28,7 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/observer.h" #include "history/history.h" #include "history/history_item.h" -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" #include "styles/style_history.h" #include "data/data_session.h" 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 0be9a5414..a5fc9f776 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -9,8 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_history.h" #include "history/history.h" -#include "history/media/history_media.h" -#include "history/media/history_media_web_page.h" +#include "history/view/media/history_view_media.h" +#include "history/view/media/history_view_web_page.h" #include "history/history_message.h" #include "history/history_item_components.h" #include "history/history_item_text.h" @@ -1627,7 +1627,7 @@ void InnerWidget::performDrag() { // return; //} else { // auto forwardMimeType = QString(); - // auto pressedMedia = static_cast(nullptr); + // auto pressedMedia = static_cast(nullptr); // if (auto pressedItem = App::pressedItem()) { // pressedMedia = pressedItem->media(); // if (_mouseCursorState == CursorState::Date diff --git a/Telegram/SourceFiles/history/history.h b/Telegram/SourceFiles/history/history.h index ef2edc549..efc6e54dc 100644 --- a/Telegram/SourceFiles/history/history.h +++ b/Telegram/SourceFiles/history/history.h @@ -22,7 +22,6 @@ class HistoryBlock; class HistoryItem; class HistoryMessage; class HistoryService; -class HistoryMedia; namespace Main { class Session; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 7dec8df67..260987b1a 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -13,9 +13,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/crash_reports.h" #include "history/history.h" #include "history/history_message.h" -#include "history/media/history_media.h" -#include "history/media/history_media_sticker.h" -#include "history/media/history_media_web_page.h" +#include "history/view/media/history_view_media.h" +#include "history/view/media/history_view_sticker.h" +#include "history/view/media/history_view_web_page.h" #include "history/history_item_components.h" #include "history/history_item_text.h" #include "history/view/history_view_message.h" @@ -1087,7 +1087,7 @@ void HistoryInner::mouseActionStart(const QPoint &screenPos, Qt::MouseButton but if (uponSelected) { _mouseAction = MouseAction::PrepareDrag; // start text drag } else if (!_pressWasInactive) { - if (dynamic_cast(App::pressedItem()->media()) + if (dynamic_cast(App::pressedItem()->media()) || _mouseCursorState == CursorState::Date) { _mouseAction = MouseAction::PrepareDrag; // start sticker drag or by-date drag } else { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 5ddf5c05a..417d896bf 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_element.h" #include "history/view/history_view_service_message.h" #include "history/history_item_components.h" -#include "history/media/history_media_grouped.h" +#include "history/view/media/history_view_media_grouped.h" #include "history/history_service.h" #include "history/history_message.h" #include "history/history.h" diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 8a4ab4f93..7b6dbe5e1 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -16,7 +16,6 @@ enum class UnreadMentionType; struct HistoryMessageReplyMarkup; class ReplyKeyboard; class HistoryMessage; -class HistoryMedia; namespace base { template diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 512c2b84d..26ffcf0e5 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_message.h" #include "history/view/history_view_service_message.h" -#include "history/media/history_media_document.h" +#include "history/view/media/history_view_document.h" #include "mainwindow.h" #include "media/audio/media_audio.h" #include "media/player/media_player_instance.h" @@ -922,16 +922,16 @@ HistoryDocumentCaptioned::HistoryDocumentCaptioned() } HistoryDocumentVoicePlayback::HistoryDocumentVoicePlayback( - const HistoryDocument *that) + const HistoryView::Document *that) : progress(0., 0.) , progressAnimation([=](crl::time now) { - const auto nonconst = const_cast(that); + const auto nonconst = const_cast(that); return nonconst->voiceProgressAnimationCallback(now); }) { } void HistoryDocumentVoice::ensurePlayback( - const HistoryDocument *that) const { + const HistoryView::Document *that) const { if (!_playback) { _playback = std::make_unique(that); } diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index a230b78a5..3cbcbb8fc 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -11,11 +11,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/empty_userpic.h" #include "ui/effects/animations.h" -class HistoryDocument; struct WebPageData; namespace HistoryView { class Element; +class Document; } // namespace HistoryView struct HistoryMessageVia : public RuntimeComponent { @@ -375,7 +375,7 @@ struct HistoryMessageLogEntryOriginal }; class FileClickHandler; -struct HistoryDocumentThumbed : public RuntimeComponent { +struct HistoryDocumentThumbed : public RuntimeComponent { std::shared_ptr _linksavel; std::shared_ptr _linkopenwithl; std::shared_ptr _linkcancell; @@ -385,31 +385,31 @@ struct HistoryDocumentThumbed : public RuntimeComponent { +struct HistoryDocumentCaptioned : public RuntimeComponent { HistoryDocumentCaptioned(); Ui::Text::String _caption; }; -struct HistoryDocumentNamed : public RuntimeComponent { +struct HistoryDocumentNamed : public RuntimeComponent { QString _name; int _namew = 0; }; struct HistoryDocumentVoicePlayback { - HistoryDocumentVoicePlayback(const HistoryDocument *that); + HistoryDocumentVoicePlayback(const HistoryView::Document *that); int32 position = 0; anim::value progress; Ui::Animations::Basic progressAnimation; }; -class HistoryDocumentVoice : public RuntimeComponent { +class HistoryDocumentVoice : public RuntimeComponent { // We don't use float64 because components should align to pointer even on 32bit systems. static constexpr float64 kFloatToIntMultiplier = 65536.; public: - void ensurePlayback(const HistoryDocument *interfaces) const; + void ensurePlayback(const HistoryView::Document *interfaces) const; void checkPlaybackFinished() const; mutable std::unique_ptr _playback; diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 8a68e82e5..109b49ae9 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "layout.h" #include "history/history.h" -#include "history/media/history_media_invoice.h" +#include "history/view/media/history_view_invoice.h" #include "history/history_message.h" #include "history/history_item_components.h" #include "history/view/history_view_service_message.h" @@ -669,7 +669,7 @@ void HistoryService::createFromMtp(const MTPDmessageService &message) { UpdateComponents(HistoryServicePayment::Bit()); auto amount = message.vaction().c_messageActionPaymentSent().vtotal_amount().v; auto currency = qs(message.vaction().c_messageActionPaymentSent().vcurrency()); - Get()->amount = FillAmountAndCurrency(amount, currency); + Get()->amount = HistoryView::FillAmountAndCurrency(amount, currency); } if (const auto replyToMsgId = message.vreply_to_msg_id()) { if (message.vaction().type() == mtpc_messageActionPinMessage) { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index c5d317c53..bf17260f1 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -39,7 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_item.h" #include "history/history_message.h" -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" #include "history/history_drag_area.h" #include "history/history_inner_widget.h" #include "history/history_item_components.h" diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 4c9c2a8c0..619660870 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -13,8 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "history/history_message.h" #include "history/history_item_text.h" -#include "history/media/history_media.h" -#include "history/media/history_media_web_page.h" +#include "history/view/media/history_view_media.h" +#include "history/view/media/history_view_web_page.h" #include "ui/widgets/popup_menu.h" #include "ui/image/image.h" #include "ui/toast/toast.h" diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index e2cb084c1..693b17774 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -11,9 +11,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_message.h" #include "history/history_item_components.h" #include "history/history_item.h" -#include "history/media/history_media.h" -#include "history/media/history_media_grouped.h" -#include "history/media/history_media_sticker.h" +#include "history/view/media/history_view_media.h" +#include "history/view/media/history_view_media_grouped.h" +#include "history/view/media/history_view_sticker.h" #include "history/history.h" #include "main/main_session.h" #include "chat_helpers/stickers_emoji_pack.h" @@ -224,7 +224,7 @@ QDateTime Element::dateTime() const { return _dateTime; } -HistoryMedia *Element::media() const { +Media *Element::media() const { return _media.get(); } @@ -331,7 +331,7 @@ void Element::refreshMedia() { _media = nullptr; _flags |= Flag::HiddenByGroup; } else { - _media = std::make_unique( + _media = std::make_unique( this, group->items); if (!pendingResize()) { @@ -345,7 +345,7 @@ void Element::refreshMedia() { if (_data->media()) { _media = _data->media()->createView(this); } else if (const auto document = emojiStickers->stickerForEmoji(_data)) { - _media = std::make_unique(this, document); + _media = std::make_unique(this, document); } else { _media = nullptr; } diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index a69471c13..39c10ee9d 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -15,8 +15,6 @@ class HistoryBlock; class HistoryItem; class HistoryMessage; class HistoryService; -class HistoryMedia; -class HistoryWebPage; namespace HistoryView { @@ -24,6 +22,7 @@ enum class PointState : char; enum class InfoDisplayType : char; struct StateRequest; struct TextState; +class Media; enum class Context : char { History, @@ -147,7 +146,7 @@ public: not_null delegate() const; not_null data() const; not_null history() const; - HistoryMedia *media() const; + Media *media() const; Context context() const; void refreshDataId(); @@ -303,7 +302,7 @@ private: const not_null _delegate; const not_null _data; - std::unique_ptr _media; + std::unique_ptr _media; const QDateTime _dateTime; int _y = 0; diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index ae5f6e218..d01c95e28 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -10,8 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_message.h" #include "history/history_item_components.h" #include "history/history_item_text.h" -#include "history/media/history_media.h" -#include "history/media/history_media_sticker.h" +#include "history/view/media/history_view_media.h" +#include "history/view/media/history_view_sticker.h" #include "history/view/history_view_context_menu.h" #include "history/view/history_view_element.h" #include "history/view/history_view_message.h" @@ -888,7 +888,7 @@ bool ListWidget::requiredToStartDragging( not_null view) const { if (_mouseCursorState == CursorState::Date) { return true; - } else if (dynamic_cast(view->media()) != nullptr) { + } else if (dynamic_cast(view->media()) != nullptr) { return true; } return false; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index b736d8b26..db2e80803 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -10,8 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_cursor_state.h" #include "history/history_item_components.h" #include "history/history_message.h" -#include "history/media/history_media.h" -#include "history/media/history_media_web_page.h" +#include "history/view/media/history_view_media.h" +#include "history/view/media/history_view_web_page.h" #include "history/history.h" #include "ui/toast/toast.h" #include "data/data_session.h" @@ -1301,11 +1301,11 @@ void Message::initLogEntryOriginal() { if (const auto log = message()->Get()) { AddComponents(LogEntryOriginal::Bit()); const auto entry = Get(); - entry->page = std::make_unique(this, log->page); + entry->page = std::make_unique(this, log->page); } } -HistoryWebPage *Message::logEntryOriginal() const { +WebPage *Message::logEntryOriginal() const { if (const auto entry = Get()) { return entry->page.get(); } diff --git a/Telegram/SourceFiles/history/view/history_view_message.h b/Telegram/SourceFiles/history/view/history_view_message.h index 821459bfd..a7290ab7d 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.h +++ b/Telegram/SourceFiles/history/view/history_view_message.h @@ -14,6 +14,8 @@ struct HistoryMessageEdited; namespace HistoryView { +class WebPage; + // Special type of Component for the channel actions log. struct LogEntryOriginal : public RuntimeComponent { @@ -22,7 +24,7 @@ struct LogEntryOriginal LogEntryOriginal &operator=(LogEntryOriginal &&other); ~LogEntryOriginal(); - std::unique_ptr page; + std::unique_ptr page; }; @@ -147,7 +149,7 @@ private: int timeLeft() const; int plainMaxWidth() const; - HistoryWebPage *logEntryOriginal() const; + WebPage *logEntryOriginal() const; mutable ClickHandlerPtr _rightActionLink; mutable ClickHandlerPtr _fastReplyLink; diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index de729b8b4..43de83692 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_service.h" -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" #include "history/history_item_components.h" #include "history/view/history_view_cursor_state.h" #include "data/data_abstract_structure.h" diff --git a/Telegram/SourceFiles/history/media/history_media_call.cpp b/Telegram/SourceFiles/history/view/media/history_view_call.cpp similarity index 90% rename from Telegram/SourceFiles/history/media/history_media_call.cpp rename to Telegram/SourceFiles/history/view/media/history_view_call.cpp index ad7c68f82..5578d6fa8 100644 --- a/Telegram/SourceFiles/history/media/history_media_call.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_call.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media_call.h" +#include "history/view/media/history_view_call.h" #include "lang/lang_keys.h" #include "layout.h" @@ -17,16 +17,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_media_types.h" #include "styles/style_history.h" -namespace { +namespace HistoryView { -using TextState = HistoryView::TextState; - -} // namespace - -HistoryCall::HistoryCall( +Call::Call( not_null parent, not_null call) -: HistoryMedia(parent) { +: Media(parent) { _duration = call->duration; _reason = call->finishReason; @@ -48,7 +44,7 @@ HistoryCall::HistoryCall( } } -QSize HistoryCall::countOptimalSize() { +QSize Call::countOptimalSize() { const auto user = _parent->data()->history()->peer->asUser(); _link = std::make_shared([=] { if (user) { @@ -64,7 +60,7 @@ QSize HistoryCall::countOptimalSize() { return { maxWidth, minHeight }; } -void HistoryCall::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { +void Call::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintx = 0, painty = 0, paintw = width(), painth = height(); @@ -102,7 +98,7 @@ void HistoryCall::draw(Painter &p, const QRect &r, TextSelection selection, crl: icon.paint(p, paintw - st::historyCallIconPosition.x() - icon.width(), st::historyCallIconPosition.y() - topMinus, paintw); } -TextState HistoryCall::textState(QPoint point, StateRequest request) const { +TextState Call::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); if (QRect(0, 0, width(), height()).contains(point)) { result.link = _link; @@ -110,3 +106,5 @@ TextState HistoryCall::textState(QPoint point, StateRequest request) const { } return result; } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_call.h b/Telegram/SourceFiles/history/view/media/history_view_call.h similarity index 88% rename from Telegram/SourceFiles/history/media/history_media_call.h rename to Telegram/SourceFiles/history/view/media/history_view_call.h index 5991e8dd0..c7600e133 100644 --- a/Telegram/SourceFiles/history/media/history_media_call.h +++ b/Telegram/SourceFiles/history/view/media/history_view_call.h @@ -7,16 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" namespace Data { enum class CallFinishReason : char; struct Call; } // namespace Data -class HistoryCall : public HistoryMedia { +namespace HistoryView { + +class Call : public Media { public: - HistoryCall( + Call( not_null parent, not_null call); @@ -53,3 +55,5 @@ private: ClickHandlerPtr _link; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_contact.cpp b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp similarity index 93% rename from Telegram/SourceFiles/history/media/history_media_contact.cpp rename to Telegram/SourceFiles/history/view/media/history_view_contact.cpp index eb742f394..dfdbd4665 100644 --- a/Telegram/SourceFiles/history/media/history_media_contact.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_contact.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media_contact.h" +#include "history/view/media/history_view_contact.h" #include "lang/lang_keys.h" #include "layout.h" @@ -25,12 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "styles/style_history.h" -namespace { - -using TextState = HistoryView::TextState; - -} // namespace - +namespace HistoryView { namespace { ClickHandlerPtr sendMessageClickHandler(PeerData *peer) { @@ -61,13 +56,13 @@ ClickHandlerPtr addContactClickHandler(not_null item) { } // namespace -HistoryContact::HistoryContact( +Contact::Contact( not_null parent, UserId userId, const QString &first, const QString &last, const QString &phone) -: HistoryMedia(parent) +: Media(parent) , _userId(userId) , _fname(first) , _lname(last) @@ -81,11 +76,11 @@ HistoryContact::HistoryContact( _phonew = st::normalFont->width(_phone); } -HistoryContact::~HistoryContact() { +Contact::~Contact() { history()->owner().unregisterContactView(_userId, _parent); } -void HistoryContact::updateSharedContactUserId(UserId userId) { +void Contact::updateSharedContactUserId(UserId userId) { if (_userId != userId) { history()->owner().unregisterContactView(_userId, _parent); _userId = userId; @@ -93,7 +88,7 @@ void HistoryContact::updateSharedContactUserId(UserId userId) { } } -QSize HistoryContact::countOptimalSize() { +QSize Contact::countOptimalSize() { const auto item = _parent->data(); auto maxWidth = st::msgFileMinWidth; @@ -149,7 +144,7 @@ QSize HistoryContact::countOptimalSize() { return { maxWidth, minHeight }; } -void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { +void Contact::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintx = 0, painty = 0, paintw = width(), painth = height(); @@ -204,7 +199,7 @@ void HistoryContact::draw(Painter &p, const QRect &r, TextSelection selection, c p.drawTextLeft(nameleft, statustop, paintw, _phone); } -TextState HistoryContact::textState(QPoint point, StateRequest request) const { +TextState Contact::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); auto nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0; @@ -223,3 +218,5 @@ TextState HistoryContact::textState(QPoint point, StateRequest request) const { } return result; } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_contact.h b/Telegram/SourceFiles/history/view/media/history_view_contact.h similarity index 90% rename from Telegram/SourceFiles/history/media/history_media_contact.h rename to Telegram/SourceFiles/history/view/media/history_view_contact.h index ea52deef6..58c96aaac 100644 --- a/Telegram/SourceFiles/history/media/history_media_contact.h +++ b/Telegram/SourceFiles/history/view/media/history_view_contact.h @@ -7,21 +7,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" namespace Ui { class EmptyUserpic; } // namespace Ui -class HistoryContact : public HistoryMedia { +namespace HistoryView { + +class Contact : public Media { public: - HistoryContact( + Contact( not_null parent, UserId userId, const QString &first, const QString &last, const QString &phone); - ~HistoryContact(); + ~Contact(); void draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const override; TextState textState(QPoint point, StateRequest request) const override; @@ -69,3 +71,5 @@ private: QString _link; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp similarity index 90% rename from Telegram/SourceFiles/history/media/history_media_document.cpp rename to Telegram/SourceFiles/history/view/media/history_view_document.cpp index 579b312ea..fe53bc1b2 100644 --- a/Telegram/SourceFiles/history/media/history_media_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media_document.h" +#include "history/view/media/history_view_document.h" #include "lang/lang_keys.h" #include "layout.h" @@ -16,25 +16,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/view/history_view_element.h" #include "history/view/history_view_cursor_state.h" -#include "history/media/history_media_common.h" +#include "history/view/media/history_view_media_common.h" #include "ui/image/image.h" #include "data/data_session.h" #include "data/data_document.h" #include "data/data_media_types.h" #include "styles/style_history.h" +namespace HistoryView { namespace { constexpr auto kAudioVoiceMsgUpdateView = crl::time(100); -using TextState = HistoryView::TextState; - } // namespace -HistoryDocument::HistoryDocument( +Document::Document( not_null parent, not_null document) -: HistoryFileMedia(parent, parent->data()) +: File(parent, parent->data()) , _data(document) { const auto item = parent->data(); auto caption = createCaption(item); @@ -53,19 +52,19 @@ HistoryDocument::HistoryDocument( } } -float64 HistoryDocument::dataProgress() const { +float64 Document::dataProgress() const { return _data->progress(); } -bool HistoryDocument::dataFinished() const { +bool Document::dataFinished() const { return !_data->loading() && !_data->uploading(); } -bool HistoryDocument::dataLoaded() const { +bool Document::dataLoaded() const { return _data->loaded(); } -void HistoryDocument::createComponents(bool caption) { +void Document::createComponents(bool caption) { uint64 mask = 0; if (_data->isVoiceMessage()) { mask |= HistoryDocumentVoice::Bit(); @@ -102,12 +101,12 @@ void HistoryDocument::createComponents(bool caption) { } } -void HistoryDocument::fillNamedFromData(HistoryDocumentNamed *named) { +void Document::fillNamedFromData(HistoryDocumentNamed *named) { const auto nameString = named->_name = _data->composeNameString(); named->_namew = st::semiboldFont->width(nameString); } -QSize HistoryDocument::countOptimalSize() { +QSize Document::countOptimalSize() { const auto item = _parent->data(); auto captioned = Get(); @@ -180,10 +179,10 @@ QSize HistoryDocument::countOptimalSize() { return { maxWidth, minHeight }; } -QSize HistoryDocument::countCurrentSize(int newWidth) { +QSize Document::countCurrentSize(int newWidth) { auto captioned = Get(); if (!captioned) { - return HistoryFileMedia::countCurrentSize(newWidth); + return File::countCurrentSize(newWidth); } accumulate_min(newWidth, maxWidth()); @@ -205,7 +204,7 @@ QSize HistoryDocument::countCurrentSize(int newWidth) { return { newWidth, newHeight }; } -void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { +void Document::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; const auto cornerDownload = downloadInCorner(); @@ -380,7 +379,7 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, // rescale waveform by going in waveform.size * bar_count 1D grid auto active = outbg ? (selected ? st::msgWaveformOutActiveSelected : st::msgWaveformOutActive) : (selected ? st::msgWaveformInActiveSelected : st::msgWaveformInActive); auto inactive = outbg ? (selected ? st::msgWaveformOutInactiveSelected : st::msgWaveformOutInactive) : (selected ? st::msgWaveformInInactiveSelected : st::msgWaveformInInactive); - auto wf_size = wf ? wf->size() : Media::Player::kWaveformSamplesCount; + auto wf_size = wf ? wf->size() : ::Media::Player::kWaveformSamplesCount; auto availw = namewidth + st::msgWaveformSkip; auto activew = qRound(availw * progress); if (!outbg @@ -458,14 +457,14 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, } } -bool HistoryDocument::downloadInCorner() const { +bool Document::downloadInCorner() const { return _data->isAudioFile() && _data->canBeStreamed() && !_data->inappPlaybackFailed() && IsServerMsgId(_parent->data()->id); } -void HistoryDocument::drawCornerDownload(Painter &p, bool selected) const { +void Document::drawCornerDownload(Painter &p, bool selected) const { if (_data->loaded() || !downloadInCorner()) { return; } @@ -502,7 +501,7 @@ void HistoryDocument::drawCornerDownload(Painter &p, bool selected) const { } } -TextState HistoryDocument::cornerDownloadTextState( +TextState Document::cornerDownloadTextState( QPoint point, StateRequest request) const { auto result = TextState(_parent); @@ -520,7 +519,7 @@ TextState HistoryDocument::cornerDownloadTextState( } -TextState HistoryDocument::textState(QPoint point, StateRequest request) const { +TextState Document::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) { @@ -576,9 +575,9 @@ TextState HistoryDocument::textState(QPoint point, StateRequest request) const { auto namewidth = width() - nameleft - nameright; auto waveformbottom = st::msgFilePadding.top() - topMinus + st::msgWaveformMax + st::msgWaveformMin; if (QRect(nameleft, nametop, namewidth, waveformbottom - nametop).contains(point)) { - const auto state = Media::Player::instance()->getState(AudioMsgId::Type::Voice); + const auto state = ::Media::Player::instance()->getState(AudioMsgId::Type::Voice); if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()) - && !Media::Player::IsStoppedOrStopping(state.state)) { + && !::Media::Player::IsStoppedOrStopping(state.state)) { if (!voice->seeking()) { voice->setSeekingStart((point.x() - nameleft) / float64(namewidth)); } @@ -617,7 +616,7 @@ TextState HistoryDocument::textState(QPoint point, StateRequest request) const { return result; } -void HistoryDocument::updatePressed(QPoint point) { +void Document::updatePressed(QPoint point) { if (auto voice = Get()) { if (voice->seeking()) { auto nameleft = 0, nameright = 0; @@ -634,7 +633,7 @@ void HistoryDocument::updatePressed(QPoint point) { } } -TextSelection HistoryDocument::adjustSelection( +TextSelection Document::adjustSelection( TextSelection selection, TextSelectType type) const { if (const auto captioned = Get()) { @@ -643,18 +642,18 @@ TextSelection HistoryDocument::adjustSelection( return selection; } -uint16 HistoryDocument::fullSelectionLength() const { +uint16 Document::fullSelectionLength() const { if (const auto captioned = Get()) { return captioned->_caption.length(); } return 0; } -bool HistoryDocument::hasTextForCopy() const { +bool Document::hasTextForCopy() const { return Has(); } -TextForMimeData HistoryDocument::selectedText(TextSelection selection) const { +TextForMimeData Document::selectedText(TextSelection selection) const { if (const auto captioned = Get()) { const auto &caption = captioned->_caption; return captioned->_caption.toTextForMimeData(selection); @@ -662,17 +661,17 @@ TextForMimeData HistoryDocument::selectedText(TextSelection selection) const { return TextForMimeData(); } -bool HistoryDocument::uploading() const { +bool Document::uploading() const { return _data->uploading(); } -void HistoryDocument::setStatusSize(int newSize, qint64 realDuration) const { +void Document::setStatusSize(int newSize, qint64 realDuration) const { auto duration = _data->isSong() ? _data->song()->duration : (_data->isVoiceMessage() ? _data->voice()->duration : -1); - HistoryFileMedia::setStatusSize(newSize, _data->size, duration, realDuration); + File::setStatusSize(newSize, _data->size, duration, realDuration); if (auto thumbed = Get()) { if (_statusSize == FileStatusSizeReady) { thumbed->_link = tr::lng_media_download(tr::now).toUpper(); @@ -689,7 +688,7 @@ void HistoryDocument::setStatusSize(int newSize, qint64 realDuration) const { } } -bool HistoryDocument::updateStatusText() const { +bool Document::updateStatusText() const { auto showPause = false; auto statusSize = 0; auto realDuration = 0; @@ -706,9 +705,9 @@ bool HistoryDocument::updateStatusText() const { } if (_data->isVoiceMessage()) { - const auto state = Media::Player::instance()->getState(AudioMsgId::Type::Voice); + const auto state = ::Media::Player::instance()->getState(AudioMsgId::Type::Voice); if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()) - && !Media::Player::IsStoppedOrStopping(state.state)) { + && !::Media::Player::IsStoppedOrStopping(state.state)) { if (auto voice = Get()) { bool was = (voice->_playback != nullptr); voice->ensurePlayback(this); @@ -727,26 +726,26 @@ bool HistoryDocument::updateStatusText() const { statusSize = -1 - (state.position / state.frequency); realDuration = (state.length / state.frequency); - showPause = Media::Player::ShowPauseIcon(state.state); + showPause = ::Media::Player::ShowPauseIcon(state.state); } else { if (auto voice = Get()) { voice->checkPlaybackFinished(); } } if (!showPause && (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()))) { - showPause = Media::Player::instance()->isSeeking(AudioMsgId::Type::Voice); + showPause = ::Media::Player::instance()->isSeeking(AudioMsgId::Type::Voice); } } else if (_data->isAudioFile()) { - const auto state = Media::Player::instance()->getState(AudioMsgId::Type::Song); + const auto state = ::Media::Player::instance()->getState(AudioMsgId::Type::Song); if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()) - && !Media::Player::IsStoppedOrStopping(state.state)) { + && !::Media::Player::IsStoppedOrStopping(state.state)) { statusSize = -1 - (state.position / state.frequency); realDuration = (state.length / state.frequency); - showPause = Media::Player::ShowPauseIcon(state.state); + showPause = ::Media::Player::ShowPauseIcon(state.state); } else { } if (!showPause && (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()))) { - showPause = Media::Player::instance()->isSeeking(AudioMsgId::Type::Song); + showPause = ::Media::Player::instance()->isSeeking(AudioMsgId::Type::Song); } } @@ -756,15 +755,15 @@ bool HistoryDocument::updateStatusText() const { return showPause; } -QMargins HistoryDocument::bubbleMargins() const { +QMargins Document::bubbleMargins() const { return Get() ? QMargins(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbPadding.left(), st::msgFileThumbPadding.bottom()) : st::msgPadding; } -bool HistoryDocument::hideForwardedFrom() const { +bool Document::hideForwardedFrom() const { return _data->isSong(); } -bool HistoryDocument::voiceProgressAnimationCallback(crl::time now) { +bool Document::voiceProgressAnimationCallback(crl::time now) { if (anim::Disabled()) { now += (2 * kAudioVoiceMsgUpdateView); } @@ -785,16 +784,16 @@ bool HistoryDocument::voiceProgressAnimationCallback(crl::time now) { return false; } -void HistoryDocument::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { +void Document::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { if (auto voice = Get()) { if (pressed && p == voice->_seekl && !voice->seeking()) { voice->startSeeking(); } else if (!pressed && voice->seeking()) { const auto type = AudioMsgId::Type::Voice; - const auto state = Media::Player::instance()->getState(type); + const auto state = ::Media::Player::instance()->getState(type); if (state.id == AudioMsgId(_data, _parent->data()->fullId(), state.id.externalPlayId()) && state.length) { const auto currentProgress = voice->seekingCurrent(); - Media::Player::instance()->finishSeeking( + ::Media::Player::instance()->finishSeeking( AudioMsgId::Type::Voice, currentProgress); @@ -805,11 +804,11 @@ void HistoryDocument::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool voice->stopSeeking(); } } - HistoryFileMedia::clickHandlerPressedChanged(p, pressed); + File::clickHandlerPressedChanged(p, pressed); } -void HistoryDocument::refreshParentId(not_null realParent) { - HistoryFileMedia::refreshParentId(realParent); +void Document::refreshParentId(not_null realParent) { + File::refreshParentId(realParent); const auto fullId = realParent->fullId(); if (auto thumbed = Get()) { @@ -825,7 +824,7 @@ void HistoryDocument::refreshParentId(not_null realParent) { } } -void HistoryDocument::parentTextUpdated() { +void Document::parentTextUpdated() { auto caption = (_parent->media() == this) ? createCaption(_parent->data()) : Ui::Text::String(); @@ -839,9 +838,11 @@ void HistoryDocument::parentTextUpdated() { history()->owner().requestViewResize(_parent); } -TextWithEntities HistoryDocument::getCaption() const { +TextWithEntities Document::getCaption() const { if (const auto captioned = Get()) { return captioned->_caption.toTextWithEntities(); } return TextWithEntities(); } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_document.h b/Telegram/SourceFiles/history/view/media/history_view_document.h similarity index 92% rename from Telegram/SourceFiles/history/media/history_media_document.h rename to Telegram/SourceFiles/history/view/media/history_view_document.h index ad13f20d8..f9aeb5433 100644 --- a/Telegram/SourceFiles/history/media/history_media_document.h +++ b/Telegram/SourceFiles/history/view/media/history_view_document.h @@ -7,16 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media_file.h" +#include "history/view/media/history_view_file.h" #include "base/runtime_composer.h" struct HistoryDocumentNamed; -class HistoryDocument - : public HistoryFileMedia - , public RuntimeComposer { +namespace HistoryView { + +class Document + : public File + , public RuntimeComposer { public: - HistoryDocument( + Document( not_null parent, not_null document); @@ -85,3 +87,5 @@ private: not_null _data; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_file.cpp b/Telegram/SourceFiles/history/view/media/history_view_file.cpp similarity index 80% rename from Telegram/SourceFiles/history/media/history_media_file.cpp rename to Telegram/SourceFiles/history/view/media/history_view_file.cpp index 1739e8b20..500415e44 100644 --- a/Telegram/SourceFiles/history/media/history_media_file.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_file.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media_file.h" +#include "history/view/media/history_view_file.h" #include "lang/lang_keys.h" #include "layout.h" @@ -15,7 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "styles/style_history.h" -void HistoryFileMedia::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { +namespace HistoryView { + +void File::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { if (p == _savel || p == _cancell) { if (active && !dataLoaded()) { ensureAnimation(); @@ -26,17 +28,17 @@ void HistoryFileMedia::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool } } -void HistoryFileMedia::thumbAnimationCallback() { +void File::thumbAnimationCallback() { history()->owner().requestViewRepaint(_parent); } -void HistoryFileMedia::clickHandlerPressedChanged( +void File::clickHandlerPressedChanged( const ClickHandlerPtr &handler, bool pressed) { history()->owner().requestViewRepaint(_parent); } -void HistoryFileMedia::setLinks( +void File::setLinks( FileClickHandlerPtr &&openl, FileClickHandlerPtr &&savel, FileClickHandlerPtr &&cancell) { @@ -45,14 +47,14 @@ void HistoryFileMedia::setLinks( _cancell = std::move(cancell); } -void HistoryFileMedia::refreshParentId(not_null realParent) { +void File::refreshParentId(not_null realParent) { const auto contextId = realParent->fullId(); _openl->setMessageId(contextId); _savel->setMessageId(contextId); _cancell->setMessageId(contextId); } -void HistoryFileMedia::setStatusSize(int newSize, int fullSize, int duration, qint64 realDuration) const { +void File::setStatusSize(int newSize, int fullSize, int duration, qint64 realDuration) const { _statusSize = newSize; if (_statusSize == FileStatusSizeReady) { _statusText = (duration >= 0) ? formatDurationAndSizeText(duration, fullSize) : (duration < -1 ? formatGifAndSizeText(fullSize) : formatSizeText(fullSize)); @@ -67,7 +69,7 @@ void HistoryFileMedia::setStatusSize(int newSize, int fullSize, int duration, qi } } -void HistoryFileMedia::radialAnimationCallback(crl::time now) const { +void File::radialAnimationCallback(crl::time now) const { const auto updated = [&] { return _animation->radial.update( dataProgress(), @@ -82,7 +84,7 @@ void HistoryFileMedia::radialAnimationCallback(crl::time now) const { } } -void HistoryFileMedia::ensureAnimation() const { +void File::ensureAnimation() const { if (!_animation) { _animation = std::make_unique([=](crl::time now) { radialAnimationCallback(now); @@ -90,14 +92,14 @@ void HistoryFileMedia::ensureAnimation() const { } } -void HistoryFileMedia::checkAnimationFinished() const { +void File::checkAnimationFinished() const { if (_animation && !_animation->a_thumbOver.animating() && !_animation->radial.animating()) { if (dataLoaded()) { _animation.reset(); } } } -void HistoryFileMedia::setDocumentLinks( +void File::setDocumentLinks( not_null document, not_null realParent) { const auto context = realParent->fullId(); @@ -107,4 +109,6 @@ void HistoryFileMedia::setDocumentLinks( std::make_shared(document, context)); } -HistoryFileMedia::~HistoryFileMedia() = default; +File::~File() = default; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_file.h b/Telegram/SourceFiles/history/view/media/history_view_file.h similarity index 94% rename from Telegram/SourceFiles/history/media/history_media_file.h rename to Telegram/SourceFiles/history/view/media/history_view_file.h index c9c418c7f..0e6574f1a 100644 --- a/Telegram/SourceFiles/history/media/history_media_file.h +++ b/Telegram/SourceFiles/history/view/media/history_view_file.h @@ -7,16 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" #include "ui/effects/animations.h" #include "ui/effects/radial_animation.h" -class HistoryFileMedia : public HistoryMedia { +namespace HistoryView { + +class File : public Media { public: - HistoryFileMedia( + File( not_null parent, not_null realParent) - : HistoryMedia(parent) + : Media(parent) , _realParent(realParent) { } @@ -36,7 +38,7 @@ public: return true; } - ~HistoryFileMedia(); + ~File(); protected: using FileClickHandlerPtr = std::shared_ptr; @@ -104,3 +106,5 @@ protected: mutable std::unique_ptr _animation; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_game.cpp b/Telegram/SourceFiles/history/view/media/history_view_game.cpp similarity index 90% rename from Telegram/SourceFiles/history/media/history_media_game.cpp rename to Telegram/SourceFiles/history/view/media/history_view_game.cpp index 70a601da3..ef4453351 100644 --- a/Telegram/SourceFiles/history/media/history_media_game.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_game.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media_game.h" +#include "history/view/media/history_view_game.h" #include "lang/lang_keys.h" #include "layout.h" @@ -13,24 +13,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/view/history_view_element.h" #include "history/view/history_view_cursor_state.h" -#include "history/media/history_media_common.h" +#include "history/view/media/history_view_media_common.h" #include "ui/text_options.h" #include "data/data_session.h" #include "data/data_game.h" #include "data/data_media_types.h" #include "styles/style_history.h" -namespace { +namespace HistoryView { -using TextState = HistoryView::TextState; - -} // namespace - -HistoryGame::HistoryGame( +Game::Game( not_null parent, not_null data, const TextWithEntities &consumed) -: HistoryMedia(parent) +: Media(parent) , _data(data) , _title(st::msgMinWidth - st::webPageLeft) , _description(st::msgMinWidth - st::webPageLeft) { @@ -43,7 +39,7 @@ HistoryGame::HistoryGame( history()->owner().registerGameView(_data, _parent); } -QSize HistoryGame::countOptimalSize() { +QSize Game::countOptimalSize() { auto lineHeight = unitedLineHeight(); const auto item = _parent->data(); @@ -128,7 +124,7 @@ QSize HistoryGame::countOptimalSize() { return { maxWidth, minHeight }; } -void HistoryGame::refreshParentId(not_null realParent) { +void Game::refreshParentId(not_null realParent) { if (_openl) { _openl->setMessageId(realParent->fullId()); } @@ -137,7 +133,7 @@ void HistoryGame::refreshParentId(not_null realParent) { } } -QSize HistoryGame::countCurrentSize(int newWidth) { +QSize Game::countCurrentSize(int newWidth) { accumulate_min(newWidth, maxWidth()); auto innerWidth = newWidth - st::msgPadding.left() - st::webPageLeft - st::msgPadding.right(); @@ -186,17 +182,17 @@ QSize HistoryGame::countCurrentSize(int newWidth) { return { newWidth, newHeight }; } -TextSelection HistoryGame::toDescriptionSelection( +TextSelection Game::toDescriptionSelection( TextSelection selection) const { - return HistoryView::UnshiftItemSelection(selection, _title); + return UnshiftItemSelection(selection, _title); } -TextSelection HistoryGame::fromDescriptionSelection( +TextSelection Game::fromDescriptionSelection( TextSelection selection) const { - return HistoryView::ShiftItemSelection(selection, _title); + return ShiftItemSelection(selection, _title); } -void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { +void Game::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintw = width(), painth = height(); @@ -268,7 +264,7 @@ void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, crl: } } -TextState HistoryGame::textState(QPoint point, StateRequest request) const { +TextState Game::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) { @@ -343,7 +339,7 @@ TextState HistoryGame::textState(QPoint point, StateRequest request) const { return result; } -TextSelection HistoryGame::adjustSelection(TextSelection selection, TextSelectType type) const { +TextSelection Game::adjustSelection(TextSelection selection, TextSelectType type) const { if (!_descriptionLines || selection.to <= _title.length()) { return _title.adjustSelection(selection, type); } @@ -355,19 +351,19 @@ TextSelection HistoryGame::adjustSelection(TextSelection selection, TextSelectTy return { titleSelection.from, fromDescriptionSelection(descriptionSelection).to }; } -void HistoryGame::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { +void Game::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { if (_attach) { _attach->clickHandlerActiveChanged(p, active); } } -void HistoryGame::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { +void Game::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { if (_attach) { _attach->clickHandlerPressedChanged(p, pressed); } } -TextForMimeData HistoryGame::selectedText(TextSelection selection) const { +TextForMimeData Game::selectedText(TextSelection selection) const { auto titleResult = _title.toTextForMimeData(selection); auto descriptionResult = _description.toTextForMimeData( toDescriptionSelection(selection)); @@ -379,7 +375,7 @@ TextForMimeData HistoryGame::selectedText(TextSelection selection) const { return titleResult.append('\n').append(std::move(descriptionResult)); } -void HistoryGame::playAnimation(bool autoplay) { +void Game::playAnimation(bool autoplay) { if (_attach) { if (autoplay) { _attach->autoplayAnimation(); @@ -389,7 +385,7 @@ void HistoryGame::playAnimation(bool autoplay) { } } -QMargins HistoryGame::inBubblePadding() const { +QMargins Game::inBubblePadding() const { auto lshift = st::msgPadding.left() + st::webPageLeft; auto rshift = st::msgPadding.right(); auto bshift = isBubbleBottom() ? st::msgPadding.left() : st::mediaInBubbleSkip; @@ -397,7 +393,7 @@ QMargins HistoryGame::inBubblePadding() const { return QMargins(lshift, tshift, rshift, bshift); } -int HistoryGame::bottomInfoPadding() const { +int Game::bottomInfoPadding() const { if (!isBubbleBottom()) return 0; auto result = st::msgDateFont->height; @@ -411,7 +407,7 @@ int HistoryGame::bottomInfoPadding() const { return result; } -void HistoryGame::parentTextUpdated() { +void Game::parentTextUpdated() { if (const auto media = _parent->data()->media()) { const auto consumed = media->consumedMessageText(); if (!consumed.text.isEmpty()) { @@ -426,6 +422,8 @@ void HistoryGame::parentTextUpdated() { } } -HistoryGame::~HistoryGame() { +Game::~Game() { history()->owner().unregisterGameView(_data, _parent); } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_game.h b/Telegram/SourceFiles/history/view/media/history_view_game.h similarity index 92% rename from Telegram/SourceFiles/history/media/history_media_game.h rename to Telegram/SourceFiles/history/view/media/history_view_game.h index 708f1e543..4df20b73d 100644 --- a/Telegram/SourceFiles/history/media/history_media_game.h +++ b/Telegram/SourceFiles/history/view/media/history_view_game.h @@ -7,13 +7,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" class ReplyMarkupClickHandler; -class HistoryGame : public HistoryMedia { +namespace HistoryView { + +class Game : public Media { public: - HistoryGame( + Game( not_null parent, not_null data, const TextWithEntities &consumed); @@ -69,13 +71,13 @@ public: return true; } - HistoryMedia *attach() const { + Media *attach() const { return _attach.get(); } void parentTextUpdated() override; - ~HistoryGame(); + ~Game(); private: void playAnimation(bool autoplay) override; @@ -89,7 +91,7 @@ private: not_null _data; std::shared_ptr _openl; - std::unique_ptr _attach; + std::unique_ptr _attach; int _titleLines, _descriptionLines; @@ -98,3 +100,5 @@ private: int _gameTagWidth = 0; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp similarity index 92% rename from Telegram/SourceFiles/history/media/history_media_gif.cpp rename to Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 73116332a..0adece316 100644 --- a/Telegram/SourceFiles/history/media/history_media_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media_gif.h" +#include "history/view/media/history_view_gif.h" #include "lang/lang_keys.h" #include "layout.h" @@ -29,12 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document.h" #include "styles/style_history.h" -namespace { - -using TextState = HistoryView::TextState; - -} // namespace - +namespace HistoryView { namespace { constexpr auto kMaxGifForwardedBarLines = 4; @@ -47,10 +42,10 @@ int gifMaxStatusWidth(DocumentData *document) { } // namespace -HistoryGif::HistoryGif( +Gif::Gif( not_null parent, not_null document) -: HistoryFileMedia(parent, parent->data()) +: File(parent, parent->data()) , _data(document) , _caption(st::minPhotoSize - st::msgPadding.left() - st::msgPadding.right()) { const auto item = parent->data(); @@ -62,7 +57,7 @@ HistoryGif::HistoryGif( _data->loadThumbnail(item->fullId()); } -QSize HistoryGif::countOptimalSize() { +QSize Gif::countOptimalSize() { if (_parent->media() != this) { _caption = Ui::Text::String(); } else if (_caption.hasSkipBlock()) { @@ -70,11 +65,11 @@ QSize HistoryGif::countOptimalSize() { _parent->skipBlockWidth(), _parent->skipBlockHeight()); } - if (_gif && _gif->state() == Media::Clip::State::Error) { + if (_gif && _gif->state() == ::Media::Clip::State::Error) { if (!_gif->autoplay()) { Ui::show(Box(tr::lng_gif_error(tr::now))); } - setClipReader(Media::Clip::ReaderPointer::Bad()); + setClipReader(::Media::Clip::ReaderPointer::Bad()); } const auto maxSize = _data->isVideoMessage() @@ -123,7 +118,7 @@ QSize HistoryGif::countOptimalSize() { return { maxWidth, minHeight }; } -QSize HistoryGif::countCurrentSize(int newWidth) { +QSize Gif::countCurrentSize(int newWidth) { auto availableWidth = newWidth; const auto maxSize = _data->isVideoMessage() @@ -156,7 +151,7 @@ QSize HistoryGif::countCurrentSize(int newWidth) { accumulate_max(newWidth, _parent->infoWidth() + 2 * st::msgDateImgDelta + st::msgDateImgPadding.x()); const auto reader = activeRoundPlayer() ? nullptr : currentReader(); if (reader) { - const auto own = (reader->mode() == Media::Clip::Reader::Mode::Gif); + const auto own = (reader->mode() == ::Media::Clip::Reader::Mode::Gif); if (own && !reader->started()) { auto isRound = _data->isVideoMessage(); auto inWebPage = (_parent->media() != this); @@ -215,7 +210,7 @@ QSize HistoryGif::countCurrentSize(int newWidth) { return { newWidth, newHeight }; } -QSize HistoryGif::videoSize() const { +QSize Gif::videoSize() const { if (const auto player = activeRoundPlayer()) { return player->videoSize(); } else if (const auto reader = currentReader()) { @@ -229,11 +224,11 @@ QSize HistoryGif::videoSize() const { } } -bool HistoryGif::autoplayEnabled() const { +bool Gif::autoplayEnabled() const { return history()->session().settings().autoplayGifs(); } -void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { +void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; const auto item = _parent->data(); @@ -311,7 +306,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, crl:: } } if (player) { - auto request = Media::Streaming::FrameRequest(); + auto request = ::Media::Streaming::FrameRequest(); request.outer = QSize(usew, painth) * cIntRetinaFactor(); request.resize = QSize(_thumbw, _thumbh) * cIntRetinaFactor(); request.corners = roundCorners; @@ -537,7 +532,7 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, crl:: } } -TextState HistoryGif::textState(QPoint point, StateRequest request) const { +TextState Gif::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) { @@ -685,15 +680,15 @@ TextState HistoryGif::textState(QPoint point, StateRequest request) const { return result; } -TextForMimeData HistoryGif::selectedText(TextSelection selection) const { +TextForMimeData Gif::selectedText(TextSelection selection) const { return _caption.toTextForMimeData(selection); } -bool HistoryGif::uploading() const { +bool Gif::uploading() const { return _data->uploading(); } -bool HistoryGif::needsBubble() const { +bool Gif::needsBubble() const { if (_data->isVideoMessage()) { return false; } @@ -708,7 +703,7 @@ bool HistoryGif::needsBubble() const { return false; } -int HistoryGif::additionalWidth() const { +int Gif::additionalWidth() const { const auto item = _parent->data(); return additionalWidth( item->Get(), @@ -716,19 +711,19 @@ int HistoryGif::additionalWidth() const { item->Get()); } -QString HistoryGif::mediaTypeString() const { +QString Gif::mediaTypeString() const { return _data->isVideoMessage() ? tr::lng_in_dlg_video_message(tr::now) : qsl("GIF"); } -bool HistoryGif::isSeparateRoundVideo() const { +bool Gif::isSeparateRoundVideo() const { return _data->isVideoMessage() && (_parent->media() == this) && !_parent->hasBubble(); } -void HistoryGif::setStatusSize(int newSize) const { +void Gif::setStatusSize(int newSize) const { if (_data->isVideoMessage()) { _statusSize = newSize; if (newSize < 0) { @@ -737,11 +732,11 @@ void HistoryGif::setStatusSize(int newSize) const { _statusText = formatDurationText(_data->getDuration()); } } else { - HistoryFileMedia::setStatusSize(newSize, _data->size, -2, 0); + File::setStatusSize(newSize, _data->size, -2, 0); } } -void HistoryGif::updateStatusText() const { +void Gif::updateStatusText() const { auto showPause = false; auto statusSize = 0; auto realDuration = 0; @@ -757,9 +752,9 @@ void HistoryGif::updateStatusText() const { const auto state = video->prepareLegacyState(); if (state.length) { auto position = int64(0); - if (Media::Player::IsStoppedAtEnd(state.state)) { + if (::Media::Player::IsStoppedAtEnd(state.state)) { position = state.length; - } else if (!Media::Player::IsStoppedOrStopping(state.state)) { + } else if (!::Media::Player::IsStoppedOrStopping(state.state)) { position = state.position; } statusSize = -1 - int((state.length - position) / state.frequency + 1); @@ -775,7 +770,7 @@ void HistoryGif::updateStatusText() const { } } -QString HistoryGif::additionalInfoString() const { +QString Gif::additionalInfoString() const { if (_data->isVideoMessage()) { updateStatusText(); return _statusText; @@ -783,18 +778,18 @@ QString HistoryGif::additionalInfoString() const { return QString(); } -bool HistoryGif::isReadyForOpen() const { +bool Gif::isReadyForOpen() const { return _data->loaded(); } -void HistoryGif::parentTextUpdated() { +void Gif::parentTextUpdated() { _caption = (_parent->media() == this) ? createCaption(_parent->data()) : Ui::Text::String(); history()->owner().requestViewResize(_parent); } -int HistoryGif::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply, const HistoryMessageForwarded *forwarded) const { +int Gif::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply, const HistoryMessageForwarded *forwarded) const { int result = 0; if (forwarded) { accumulate_max(result, st::msgReplyPadding.left() + st::msgReplyPadding.left() + forwarded->text.maxWidth() + st::msgReplyPadding.right()); @@ -807,20 +802,20 @@ int HistoryGif::additionalWidth(const HistoryMessageVia *via, const HistoryMessa return result; } -Media::Streaming::Player *HistoryGif::activeRoundPlayer() const { - return Media::Player::instance()->roundVideoPlayer(_parent->data()); +::Media::Streaming::Player *Gif::activeRoundPlayer() const { + return ::Media::Player::instance()->roundVideoPlayer(_parent->data()); } -Media::Clip::Reader *HistoryGif::currentReader() const { +::Media::Clip::Reader *Gif::currentReader() const { return (_gif && _gif->ready()) ? _gif.get() : nullptr; } -Media::View::PlaybackProgress *HistoryGif::videoPlayback() const { - return Media::Player::instance()->roundVideoPlayback(_parent->data()); +::Media::View::PlaybackProgress *Gif::videoPlayback() const { + return ::Media::Player::instance()->roundVideoPlayback(_parent->data()); } -void HistoryGif::clipCallback(Media::Clip::Notification notification) { - using namespace Media::Clip; +void Gif::clipCallback(::Media::Clip::Notification notification) { + using namespace ::Media::Clip; const auto reader = _gif.get(); if (!reader) { @@ -852,7 +847,7 @@ void HistoryGif::clipCallback(Media::Clip::Notification notification) { } } -void HistoryGif::playAnimation(bool autoplay) { +void Gif::playAnimation(bool autoplay) { if (_data->isVideoMessage() && !autoplay) { return; } else if (_gif && autoplay) { @@ -861,14 +856,14 @@ void HistoryGif::playAnimation(bool autoplay) { Core::App().showDocument(_data, _parent->data()); return; } - using Mode = Media::Clip::Reader::Mode; + using Mode = ::Media::Clip::Reader::Mode; if (_gif) { stopAnimation(); } else if (_data->loaded(DocumentData::FilePathResolve::Checked)) { if (!autoplayEnabled()) { history()->owner().stopAutoplayAnimations(); } - setClipReader(Media::Clip::MakeReader( + setClipReader(::Media::Clip::MakeReader( _data, _parent->data()->fullId(), [=](auto notification) { clipCallback(notification); }, @@ -879,7 +874,7 @@ void HistoryGif::playAnimation(bool autoplay) { } } -void HistoryGif::stopAnimation() { +void Gif::stopAnimation() { if (_gif) { clearClipReader(); history()->owner().requestViewResize(_parent); @@ -887,7 +882,7 @@ void HistoryGif::stopAnimation() { } } -void HistoryGif::setClipReader(Media::Clip::ReaderPointer gif) { +void Gif::setClipReader(::Media::Clip::ReaderPointer gif) { if (_gif) { history()->owner().unregisterAutoplayAnimation(_gif.get()); } @@ -897,26 +892,28 @@ void HistoryGif::setClipReader(Media::Clip::ReaderPointer gif) { } } -HistoryGif::~HistoryGif() { +Gif::~Gif() { clearClipReader(); } -float64 HistoryGif::dataProgress() const { +float64 Gif::dataProgress() const { return (_data->uploading() || _parent->data()->id > 0) ? _data->progress() : 0; } -bool HistoryGif::dataFinished() const { +bool Gif::dataFinished() const { return (_parent->data()->id > 0) ? (!_data->loading() && !_data->uploading()) : false; } -bool HistoryGif::dataLoaded() const { +bool Gif::dataLoaded() const { return (_parent->data()->id > 0) ? _data->loaded() : false; } -bool HistoryGif::needInfoDisplay() const { +bool Gif::needInfoDisplay() const { return (_parent->data()->id < 0 || _parent->isUnderCursor()); } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_gif.h b/Telegram/SourceFiles/history/view/media/history_view_gif.h similarity index 83% rename from Telegram/SourceFiles/history/media/history_media_gif.h rename to Telegram/SourceFiles/history/view/media/history_view_gif.h index 4359bbc0b..29480d792 100644 --- a/Telegram/SourceFiles/history/media/history_media_gif.h +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.h @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media_file.h" +#include "history/view/media/history_view_file.h" struct HistoryMessageVia; struct HistoryMessageReply; @@ -25,9 +25,11 @@ class Player; } // namespace Streaming } // namespace Media -class HistoryGif : public HistoryFileMedia { +namespace HistoryView { + +class Gif : public File { public: - HistoryGif( + Gif( not_null parent, not_null document); @@ -72,16 +74,16 @@ public: void parentTextUpdated() override; - ~HistoryGif(); + ~Gif(); protected: float64 dataProgress() const override; bool dataFinished() const override; bool dataLoaded() const override; - void setClipReader(Media::Clip::ReaderPointer gif); + void setClipReader(::Media::Clip::ReaderPointer gif); void clearClipReader() { - setClipReader(Media::Clip::ReaderPointer()); + setClipReader(::Media::Clip::ReaderPointer()); } private: @@ -90,10 +92,10 @@ private: QSize countOptimalSize() override; QSize countCurrentSize(int newWidth) override; QSize videoSize() const; - Media::Streaming::Player *activeRoundPlayer() const; - Media::Clip::Reader *currentReader() const; - Media::View::PlaybackProgress *videoPlayback() const; - void clipCallback(Media::Clip::Notification notification); + ::Media::Streaming::Player *activeRoundPlayer() const; + ::Media::Clip::Reader *currentReader() const; + ::Media::View::PlaybackProgress *videoPlayback() const; + void clipCallback(::Media::Clip::Notification notification); bool needInfoDisplay() const; int additionalWidth( @@ -108,9 +110,11 @@ private: int _thumbw = 1; int _thumbh = 1; Ui::Text::String _caption; - Media::Clip::ReaderPointer _gif; + ::Media::Clip::ReaderPointer _gif; void setStatusSize(int newSize) const; void updateStatusText() const; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_invoice.cpp b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp similarity index 90% rename from Telegram/SourceFiles/history/media/history_media_invoice.cpp rename to Telegram/SourceFiles/history/view/media/history_view_invoice.cpp index f334215ac..abf012ec9 100644 --- a/Telegram/SourceFiles/history/media/history_media_invoice.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp @@ -5,37 +5,33 @@ 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 "history/media/history_media_invoice.h" +#include "history/view/media/history_view_invoice.h" #include "lang/lang_keys.h" #include "layout.h" #include "history/view/history_view_element.h" #include "history/view/history_view_cursor_state.h" -#include "history/media/history_media_photo.h" -#include "history/media/history_media_common.h" +#include "history/view/media/history_view_photo.h" +#include "history/view/media/history_view_media_common.h" #include "ui/text_options.h" #include "data/data_media_types.h" #include "styles/style_history.h" -namespace { +namespace HistoryView { -using TextState = HistoryView::TextState; - -} // namespace - -HistoryInvoice::HistoryInvoice( +Invoice::Invoice( not_null parent, not_null invoice) -: HistoryMedia(parent) +: Media(parent) , _title(st::msgMinWidth) , _description(st::msgMinWidth) , _status(st::msgMinWidth) { fillFromData(invoice); } -void HistoryInvoice::fillFromData(not_null invoice) { +void Invoice::fillFromData(not_null invoice) { if (invoice->photo) { - _attach = std::make_unique( + _attach = std::make_unique( _parent, _parent->data(), invoice->photo); @@ -87,7 +83,7 @@ void HistoryInvoice::fillFromData(not_null invoice) { } } -QSize HistoryInvoice::countOptimalSize() { +QSize Invoice::countOptimalSize() { auto lineHeight = unitedLineHeight(); if (_attach) { @@ -141,7 +137,7 @@ QSize HistoryInvoice::countOptimalSize() { return { maxWidth, minHeight }; } -QSize HistoryInvoice::countCurrentSize(int newWidth) { +QSize Invoice::countCurrentSize(int newWidth) { accumulate_min(newWidth, maxWidth()); auto innerWidth = newWidth - st::msgPadding.left() - st::msgPadding.right(); @@ -186,23 +182,23 @@ QSize HistoryInvoice::countCurrentSize(int newWidth) { return { newWidth, newHeight }; } -TextSelection HistoryInvoice::toDescriptionSelection( +TextSelection Invoice::toDescriptionSelection( TextSelection selection) const { - return HistoryView::UnshiftItemSelection(selection, _title); + return UnshiftItemSelection(selection, _title); } -TextSelection HistoryInvoice::fromDescriptionSelection( +TextSelection Invoice::fromDescriptionSelection( TextSelection selection) const { - return HistoryView::ShiftItemSelection(selection, _title); + return ShiftItemSelection(selection, _title); } -void HistoryInvoice::refreshParentId(not_null realParent) { +void Invoice::refreshParentId(not_null realParent) { if (_attach) { _attach->refreshParentId(realParent); } } -void HistoryInvoice::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { +void Invoice::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintw = width(), painth = height(); @@ -275,7 +271,7 @@ void HistoryInvoice::draw(Painter &p, const QRect &r, TextSelection selection, c } } -TextState HistoryInvoice::textState(QPoint point, StateRequest request) const { +TextState Invoice::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) { @@ -337,7 +333,7 @@ TextState HistoryInvoice::textState(QPoint point, StateRequest request) const { return result; } -TextSelection HistoryInvoice::adjustSelection(TextSelection selection, TextSelectType type) const { +TextSelection Invoice::adjustSelection(TextSelection selection, TextSelectType type) const { if (!_descriptionHeight || selection.to <= _title.length()) { return _title.adjustSelection(selection, type); } @@ -349,19 +345,19 @@ TextSelection HistoryInvoice::adjustSelection(TextSelection selection, TextSelec return { titleSelection.from, fromDescriptionSelection(descriptionSelection).to }; } -void HistoryInvoice::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { +void Invoice::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { if (_attach) { _attach->clickHandlerActiveChanged(p, active); } } -void HistoryInvoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { +void Invoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { if (_attach) { _attach->clickHandlerPressedChanged(p, pressed); } } -TextForMimeData HistoryInvoice::selectedText(TextSelection selection) const { +TextForMimeData Invoice::selectedText(TextSelection selection) const { auto titleResult = _title.toTextForMimeData(selection); auto descriptionResult = _description.toTextForMimeData( toDescriptionSelection(selection)); @@ -373,7 +369,7 @@ TextForMimeData HistoryInvoice::selectedText(TextSelection selection) const { return titleResult.append('\n').append(std::move(descriptionResult)); } -QMargins HistoryInvoice::inBubblePadding() const { +QMargins Invoice::inBubblePadding() const { auto lshift = st::msgPadding.left(); auto rshift = st::msgPadding.right(); auto bshift = isBubbleBottom() ? st::msgPadding.top() : st::mediaInBubbleSkip; @@ -381,7 +377,7 @@ QMargins HistoryInvoice::inBubblePadding() const { return QMargins(lshift, tshift, rshift, bshift); } -int HistoryInvoice::bottomInfoPadding() const { +int Invoice::bottomInfoPadding() const { if (!isBubbleBottom()) return 0; auto result = st::msgDateFont->height; @@ -442,3 +438,5 @@ QString FillAmountAndCurrency(uint64 amount, const QString ¤cy) { //auto amountText = qsl("%1,%2").arg(amountBucks).arg(amountCents, 2, 10, QChar('0')); //return currencyText + amountText; } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_invoice.h b/Telegram/SourceFiles/history/view/media/history_view_invoice.h similarity index 92% rename from Telegram/SourceFiles/history/media/history_media_invoice.h rename to Telegram/SourceFiles/history/view/media/history_view_invoice.h index e6b6c34cc..6961f891e 100644 --- a/Telegram/SourceFiles/history/media/history_media_invoice.h +++ b/Telegram/SourceFiles/history/view/media/history_view_invoice.h @@ -7,15 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" namespace Data { struct Invoice; } // namespace Data -class HistoryInvoice : public HistoryMedia { +namespace HistoryView { + +class Invoice : public Media { public: - HistoryInvoice( + Invoice( not_null parent, not_null invoice); @@ -64,7 +66,7 @@ public: return false; } - HistoryMedia *attach() const { + Media *attach() const { return _attach.get(); } @@ -79,7 +81,7 @@ private: QMargins inBubblePadding() const; int bottomInfoPadding() const; - std::unique_ptr _attach; + std::unique_ptr _attach; int _titleHeight = 0; int _descriptionHeight = 0; @@ -92,3 +94,5 @@ private: }; QString FillAmountAndCurrency(uint64 amount, const QString ¤cy); + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_location.cpp b/Telegram/SourceFiles/history/view/media/history_view_location.cpp similarity index 90% rename from Telegram/SourceFiles/history/media/history_media_location.cpp rename to Telegram/SourceFiles/history/view/media/history_view_location.cpp index 94cd73d80..4ab2c7cc4 100644 --- a/Telegram/SourceFiles/history/media/history_media_location.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_location.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media_location.h" +#include "history/view/media/history_view_location.h" #include "layout.h" #include "history/history_item_components.h" @@ -19,18 +19,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_location.h" #include "styles/style_history.h" -namespace { +namespace HistoryView { -using TextState = HistoryView::TextState; - -} // namespace - -HistoryLocation::HistoryLocation( +Location::Location( not_null parent, not_null location, const QString &title, const QString &description) -: HistoryMedia(parent) +: Media(parent) , _data(location) , _title(st::msgMinWidth) , _description(st::msgMinWidth) @@ -51,7 +47,7 @@ HistoryLocation::HistoryLocation( } } -QSize HistoryLocation::countOptimalSize() { +QSize Location::countOptimalSize() { auto tw = fullWidth(); auto th = fullHeight(); if (tw > st::maxMediaSize) { @@ -79,7 +75,7 @@ QSize HistoryLocation::countOptimalSize() { return { maxWidth, minHeight }; } -QSize HistoryLocation::countCurrentSize(int newWidth) { +QSize Location::countCurrentSize(int newWidth) { accumulate_min(newWidth, maxWidth()); auto tw = fullWidth(); @@ -114,17 +110,17 @@ QSize HistoryLocation::countCurrentSize(int newWidth) { return { newWidth, newHeight }; } -TextSelection HistoryLocation::toDescriptionSelection( +TextSelection Location::toDescriptionSelection( TextSelection selection) const { - return HistoryView::UnshiftItemSelection(selection, _title); + return UnshiftItemSelection(selection, _title); } -TextSelection HistoryLocation::fromDescriptionSelection( +TextSelection Location::fromDescriptionSelection( TextSelection selection) const { - return HistoryView::ShiftItemSelection(selection, _title); + return ShiftItemSelection(selection, _title); } -void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { +void Location::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const { if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return; auto paintx = 0, painty = 0, paintw = width(), painth = height(); bool bubble = _parent->hasBubble(); @@ -195,7 +191,7 @@ void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection, } } -TextState HistoryLocation::textState(QPoint point, StateRequest request) const { +TextState Location::textState(QPoint point, StateRequest request) const { auto result = TextState(_parent); auto symbolAdd = 0; @@ -267,7 +263,7 @@ TextState HistoryLocation::textState(QPoint point, StateRequest request) const { return result; } -TextSelection HistoryLocation::adjustSelection(TextSelection selection, TextSelectType type) const { +TextSelection Location::adjustSelection(TextSelection selection, TextSelectType type) const { if (_description.isEmpty() || selection.to <= _title.length()) { return _title.adjustSelection(selection, type); } @@ -279,7 +275,7 @@ TextSelection HistoryLocation::adjustSelection(TextSelection selection, TextSele return { titleSelection.from, fromDescriptionSelection(descriptionSelection).to }; } -TextForMimeData HistoryLocation::selectedText(TextSelection selection) const { +TextForMimeData Location::selectedText(TextSelection selection) const { auto titleResult = _title.toTextForMimeData(selection); auto descriptionResult = _description.toTextForMimeData( toDescriptionSelection(selection)); @@ -291,7 +287,7 @@ TextForMimeData HistoryLocation::selectedText(TextSelection selection) const { return titleResult.append('\n').append(std::move(descriptionResult)); } -bool HistoryLocation::needsBubble() const { +bool Location::needsBubble() const { if (!_title.isEmpty() || !_description.isEmpty()) { return true; } @@ -303,10 +299,12 @@ bool HistoryLocation::needsBubble() const { return false; } -int HistoryLocation::fullWidth() const { +int Location::fullWidth() const { return st::locationSize.width(); } -int HistoryLocation::fullHeight() const { +int Location::fullHeight() const { return st::locationSize.height(); } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_location.h b/Telegram/SourceFiles/history/view/media/history_view_location.h similarity index 92% rename from Telegram/SourceFiles/history/media/history_media_location.h rename to Telegram/SourceFiles/history/view/media/history_view_location.h index b511e83a5..89e66b17a 100644 --- a/Telegram/SourceFiles/history/media/history_media_location.h +++ b/Telegram/SourceFiles/history/view/media/history_view_location.h @@ -7,15 +7,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "history/media/history_media.h" +#include "history/view/media/history_view_media.h" namespace Data { struct LocationThumbnail; } // namespace Data -class HistoryLocation : public HistoryMedia { +namespace HistoryView { + +class Location : public Media { public: - HistoryLocation( + Location( not_null parent, not_null location, const QString &title = QString(), @@ -67,3 +69,5 @@ private: int fullHeight() const; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media.cpp b/Telegram/SourceFiles/history/view/media/history_view_media.cpp similarity index 59% rename from Telegram/SourceFiles/history/media/history_media.cpp rename to Telegram/SourceFiles/history/view/media/history_view_media.cpp index ae976bdd5..5d2a9cc41 100644 --- a/Telegram/SourceFiles/history/media/history_media.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media.cpp @@ -5,7 +5,7 @@ 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 "history/media/history_media.h" +#include "history/view/media/history_view_media.h" #include "history/history_item.h" #include "history/view/history_view_element.h" @@ -14,30 +14,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text_options.h" #include "styles/style_history.h" -namespace { +namespace HistoryView { -using PointState = HistoryView::PointState; -using TextState = HistoryView::TextState; - -} // namespace - -Storage::SharedMediaTypesMask HistoryMedia::sharedMediaTypes() const { +Storage::SharedMediaTypesMask Media::sharedMediaTypes() const { return {}; } -not_null HistoryMedia::history() const { +not_null Media::history() const { return _parent->history(); } -bool HistoryMedia::isDisplayed() const { +bool Media::isDisplayed() const { return true; } -QSize HistoryMedia::countCurrentSize(int newWidth) { +QSize Media::countCurrentSize(int newWidth) { return QSize(qMin(newWidth, maxWidth()), minHeight()); } -Ui::Text::String HistoryMedia::createCaption(not_null item) const { +Ui::Text::String Media::createCaption(not_null item) const { if (item->emptyText()) { return {}; } @@ -55,27 +50,25 @@ Ui::Text::String HistoryMedia::createCaption(not_null item) const return result; } -TextSelection HistoryMedia::skipSelection(TextSelection selection) const { - return HistoryView::UnshiftItemSelection( - selection, - fullSelectionLength()); +TextSelection Media::skipSelection(TextSelection selection) const { + return UnshiftItemSelection(selection, fullSelectionLength()); } -TextSelection HistoryMedia::unskipSelection(TextSelection selection) const { - return HistoryView::ShiftItemSelection( - selection, - fullSelectionLength()); +TextSelection Media::unskipSelection(TextSelection selection) const { + return ShiftItemSelection(selection, fullSelectionLength()); } -PointState HistoryMedia::pointState(QPoint point) const { +PointState Media::pointState(QPoint point) const { return QRect(0, 0, width(), height()).contains(point) ? PointState::Inside : PointState::Outside; } -TextState HistoryMedia::getStateGrouped( +TextState Media::getStateGrouped( const QRect &geometry, QPoint point, StateRequest request) const { Unexpected("Grouping method call."); } + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media.h b/Telegram/SourceFiles/history/view/media/history_view_media.h similarity index 93% rename from Telegram/SourceFiles/history/media/history_media.h rename to Telegram/SourceFiles/history/view/media/history_view_media.h index 4198d57a5..b564d6bbf 100644 --- a/Telegram/SourceFiles/history/media/history_media.h +++ b/Telegram/SourceFiles/history/view/media/history_view_media.h @@ -23,12 +23,12 @@ using SharedMediaTypesMask = base::enum_mask; } // namespace Storage namespace HistoryView { + enum class PointState : char; enum class CursorState : char; enum class InfoDisplayType : char; struct TextState; struct StateRequest; -} // namespace HistoryView enum class MediaInBubbleState { None, @@ -37,14 +37,9 @@ enum class MediaInBubbleState { Bottom, }; -class HistoryMedia : public HistoryView::Object { +class Media : public Object { public: - using Element = HistoryView::Element; - using PointState = HistoryView::PointState; - using TextState = HistoryView::TextState; - using StateRequest = HistoryView::StateRequest; - - HistoryMedia(not_null parent) : _parent(parent) { + Media(not_null parent) : _parent(parent) { } [[nodiscard]] not_null history() const; @@ -231,12 +226,9 @@ public: virtual void parentTextUpdated() { } - virtual ~HistoryMedia() = default; + virtual ~Media() = default; protected: - using CursorState = HistoryView::CursorState; - using InfoDisplayType = HistoryView::InfoDisplayType; - QSize countCurrentSize(int newWidth) override; Ui::Text::String createCaption(not_null item) const; @@ -247,3 +239,5 @@ protected: MediaInBubbleState _inBubbleState = MediaInBubbleState::None; }; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/media/history_media_common.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_common.cpp similarity index 73% rename from Telegram/SourceFiles/history/media/history_media_common.cpp rename to Telegram/SourceFiles/history/view/media/history_view_media_common.cpp index 67d1562eb..3fb03eb64 100644 --- a/Telegram/SourceFiles/history/media/history_media_common.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_common.cpp @@ -5,20 +5,22 @@ 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 "history/media/history_media_common.h" +#include "history/view/media/history_view_media_common.h" #include "layout.h" #include "data/data_document.h" #include "history/view/history_view_element.h" -#include "history/media/history_media_grouped.h" -#include "history/media/history_media_photo.h" -#include "history/media/history_media_gif.h" -#include "history/media/history_media_document.h" -#include "history/media/history_media_sticker.h" -#include "history/media/history_media_video.h" -#include "history/media/history_media_wall_paper.h" +#include "history/view/media/history_view_media_grouped.h" +#include "history/view/media/history_view_photo.h" +#include "history/view/media/history_view_gif.h" +#include "history/view/media/history_view_document.h" +#include "history/view/media/history_view_sticker.h" +#include "history/view/media/history_view_video.h" +#include "history/view/media/history_view_wall_paper.h" #include "styles/style_history.h" +namespace HistoryView { + int documentMaxStatusWidth(DocumentData *document) { auto result = st::normalFont->width(formatDownloadText(document->size, document->size)); const auto duration = document->getDuration(); @@ -58,33 +60,33 @@ void PaintInterpolatedIcon( p.restore(); } -std::unique_ptr CreateAttach( - not_null parent, +std::unique_ptr CreateAttach( + not_null parent, DocumentData *document, PhotoData *photo, const std::vector> &collage, const QString &webpageUrl) { if (!collage.empty()) { - return std::make_unique(parent, collage); + return std::make_unique(parent, collage); } else if (document) { if (document->sticker()) { - return std::make_unique(parent, document); + return std::make_unique(parent, document); } else if (document->isAnimation()) { - return std::make_unique(parent, document); + return std::make_unique(parent, document); } else if (document->isVideoFile()) { - return std::make_unique( + return std::make_unique