diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 5253ebde5..1c881e2ed 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1206,6 +1206,8 @@ PRIVATE media/streaming/media_streaming_video_track.h media/view/media_view_group_thumbs.cpp media/view/media_view_group_thumbs.h + media/view/media_view_open_common.cpp + media/view/media_view_open_common.h media/view/media_view_overlay_opengl.cpp media/view/media_view_overlay_opengl.h media/view/media_view_overlay_raster.cpp @@ -1224,7 +1226,6 @@ PRIVATE media/view/media_view_playback_controls.h media/view/media_view_playback_progress.cpp media/view/media_view_playback_progress.h - media/view/media_view_open_common.h media/system_media_controls_manager.h media/system_media_controls_manager.cpp menu/menu_antispam_validator.cpp diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index e654b2d80..dbdf7e126 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "media/streaming/media_streaming_instance.h" #include "media/streaming/media_streaming_player.h" #include "media/streaming/media_streaming_utility.h" +#include "media/view/media_view_open_common.h" #include "media/view/media_view_playback_progress.h" #include "ui/boxes/confirm_box.h" #include "ui/painter.h" @@ -135,18 +136,6 @@ Gif::Streamed::Streamed( && parent->data()->media()->ttlSeconds(); } -[[nodiscard]] TimeId ExtractVideoTimestamp(not_null item) { - const auto media = item->media(); - if (!media) { - return 0; - } else if (const auto timestamp = media->videoTimestamp()) { - return timestamp; - } else if (const auto webpage = media->webpage()) { - return webpage->extractVideoTimestamp(); - } - return 0; -} - Gif::Gif( not_null parent, not_null realParent, @@ -163,7 +152,7 @@ Gif::Gif( ? std::make_unique() : nullptr) , _downloadSize(Ui::FormatSizeText(_data->size)) -, _videoTimestamp(ExtractVideoTimestamp(realParent)) +, _videoTimestamp(::Media::View::ExtractVideoTimestamp(realParent)) , _sensitiveSpoiler(realParent->isMediaSensitive()) , _hasVideoCover(realParent->media() && realParent->media()->videoCover()) { if (_data->isVideoMessage() && _parent->data()->media()->ttlSeconds()) { @@ -889,21 +878,19 @@ void Gif::paintTimestampMark( if (_videoTimestamp <= 0) { return; } - const auto roundingLeft = rounding - ? rounding->bottomLeft - : Ui::BubbleCornerRounding::Small; - const auto roundingRight = rounding - ? rounding->bottomRight - : Ui::BubbleCornerRounding::Small; const auto convert = [](Ui::BubbleCornerRounding rounding) { return (rounding == Ui::BubbleCornerRounding::Small) - ? st::roundRadiusSmall + ? Ui::BubbleRadiusSmall() : (rounding == Ui::BubbleCornerRounding::Large) - ? st::roundRadiusLarge + ? Ui::BubbleRadiusLarge() : 0; }; - const auto radiusl = convert(roundingLeft); - const auto radiusr = convert(roundingRight); + const auto radiusl = rounding + ? convert(rounding->bottomLeft) + : st::roundRadiusSmall; + const auto radiusr = rounding + ? convert(rounding->bottomRight) + : st::roundRadiusSmall; const auto line = st::historyVideoTimestampProgressLine; const auto duration = _data->duration() / 1000; if (rthumb.height() <= line @@ -924,9 +911,9 @@ void Gif::paintTimestampMark( p.setClipRect(rthumb.x(), top, edge, line); p.drawRoundedRect( rthumb.x(), - top - radiusl, + top - 2 * radiusl, edge + radiusl, - line + radiusl, + line + 2 * radiusl, radiusl, radiusl); } @@ -936,10 +923,11 @@ void Gif::paintTimestampMark( p.setClipRect(left, top, width, line); p.drawRoundedRect( left - radiusr, - top - radiusr, + top - 2 * radiusr, width + radiusr, - line + radiusr, - radiusr, radiusr); + line + 2 * radiusr, + radiusr, + radiusr); } p.restore(); } diff --git a/Telegram/SourceFiles/media/view/media_view_open_common.cpp b/Telegram/SourceFiles/media/view/media_view_open_common.cpp new file mode 100644 index 000000000..346a87ef3 --- /dev/null +++ b/Telegram/SourceFiles/media/view/media_view_open_common.cpp @@ -0,0 +1,28 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "media/view/media_view_open_common.h" + +#include "history/history_item.h" +#include "data/data_media_types.h" +#include "data/data_web_page.h" + +namespace Media::View { + +TimeId ExtractVideoTimestamp(not_null item) { + const auto media = item->media(); + if (!media) { + return 0; + } else if (const auto timestamp = media->videoTimestamp()) { + return timestamp; + } else if (const auto webpage = media->webpage()) { + return webpage->extractVideoTimestamp(); + } + return 0; +} + +} // namespace Media::View diff --git a/Telegram/SourceFiles/media/view/media_view_open_common.h b/Telegram/SourceFiles/media/view/media_view_open_common.h index ff56af25d..76cfd7748 100644 --- a/Telegram/SourceFiles/media/view/media_view_open_common.h +++ b/Telegram/SourceFiles/media/view/media_view_open_common.h @@ -135,4 +135,6 @@ private: }; +[[nodiscard]] TimeId ExtractVideoTimestamp(not_null item); + } // namespace Media::View diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 5562388d2..3461db2aa 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat_filters.h" #include "data/data_replies_list.h" #include "data/data_peer_values.h" +#include "data/data_web_page.h" #include "passport/passport_form_controller.h" #include "chat_helpers/tabbed_selector.h" #include "chat_helpers/emoji_interactions.h" @@ -2784,11 +2785,14 @@ void SessionController::openDocument( if (openSharedStory(item) || openFakeItemStory(message.id, stories)) { return; } else if (showInMediaView) { - _window->openInMediaView(Media::View::OpenRequest( + using namespace Media::View; + _window->openInMediaView(OpenRequest( this, document, item, - message.topicRootId)); + message.topicRootId, + false, + (item ? ExtractVideoTimestamp(item) : 0) * crl::time(1000))); return; } Data::ResolveDocument(this, document, item, message.topicRootId);