From 6cae088d1f28925b3e354470b203db338697fe93 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 12 Oct 2023 04:14:05 +0300 Subject: [PATCH] Added ability to customize shortcut for full screen in media viewer. --- Telegram/SourceFiles/core/shortcuts.cpp | 7 ++++--- Telegram/SourceFiles/core/shortcuts.h | 2 ++ .../media/view/media_view_overlay_widget.cpp | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index ef566e64a..82d93ec28 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -94,9 +94,10 @@ const auto CommandByName = base::flat_map{ { u"read_chat"_q , Command::ReadChat }, // Shortcuts that have no default values. - { u"message"_q , Command::JustSendMessage }, - { u"message_silently"_q , Command::SendSilentMessage }, - { u"message_scheduled"_q , Command::ScheduleMessage }, + { u"message"_q , Command::JustSendMessage }, + { u"message_silently"_q , Command::SendSilentMessage }, + { u"message_scheduled"_q , Command::ScheduleMessage }, + { u"mevia_viewer_video_fullscreen"_q , Command::MediaViewerFullscreen }, // }; diff --git a/Telegram/SourceFiles/core/shortcuts.h b/Telegram/SourceFiles/core/shortcuts.h index 6e1904c68..d7b3dc3c5 100644 --- a/Telegram/SourceFiles/core/shortcuts.h +++ b/Telegram/SourceFiles/core/shortcuts.h @@ -59,6 +59,8 @@ enum class Command { ReadChat, + MediaViewerFullscreen, + SupportReloadTemplates, SupportToggleMuted, SupportScrollToCurrent, diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 779fe16d7..61c17837e 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/ui_integration.h" #include "core/crash_reports.h" #include "core/sandbox.h" +#include "core/shortcuts.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/buttons.h" #include "ui/image/image.h" @@ -458,6 +459,19 @@ OverlayWidget::OverlayWidget() QImage::Format_ARGB32_Premultiplied); _docRectImage.setDevicePixelRatio(cIntRetinaFactor()); + Shortcuts::Requests( + ) | rpl::start_with_next([=](not_null request) { + request->check( + Shortcuts::Command::MediaViewerFullscreen + ) && request->handle([=] { + if (_streamed) { + playbackToggleFullScreen(); + return true; + } + return false; + }); + }, lifetime()); + setupWindow(); const auto mousePosition = [](not_null e) {