From 37f96534eca693539c84831778cf4fa946b4acb1 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 8 Jun 2022 14:36:40 +0300 Subject: [PATCH] Fixed opening of shared media in corresponding window from media viewer. --- Telegram/SourceFiles/boxes/stickers_box.cpp | 2 -- .../SourceFiles/data/data_shared_media.cpp | 25 ------------------- Telegram/SourceFiles/data/data_shared_media.h | 7 +----- .../media/player/media_player_instance.h | 1 + .../media/view/media_view_overlay_widget.cpp | 10 +++++++- .../media/view/media_view_overlay_widget.h | 2 ++ 6 files changed, 13 insertions(+), 34 deletions(-) diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 0665387c5e..ec91c766f4 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -278,8 +278,6 @@ private: QString _undoText; int _undoWidth = 0; - int _buttonHeight = 0; - QPoint _mouse; bool _inDragArea = false; SelectedRow _selected; diff --git a/Telegram/SourceFiles/data/data_shared_media.cpp b/Telegram/SourceFiles/data/data_shared_media.cpp index 53480ceb90..e715250df8 100644 --- a/Telegram/SourceFiles/data/data_shared_media.cpp +++ b/Telegram/SourceFiles/data/data_shared_media.cpp @@ -9,23 +9,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include "main/main_session.h" -#include "main/main_domain.h" -#include "core/application.h" #include "apiwrap.h" #include "storage/storage_facade.h" -#include "storage/storage_shared_media.h" #include "history/history.h" #include "history/history_item.h" #include "data/data_document.h" #include "data/data_media_types.h" #include "data/data_photo.h" #include "data/data_scheduled_messages.h" -#include "data/data_sparse_ids.h" #include "data/data_session.h" -#include "info/info_memento.h" -#include "info/info_controller.h" -#include "window/window_session_controller.h" -#include "mainwindow.h" #include "core/crash_reports.h" namespace { @@ -92,23 +84,6 @@ std::optional SharedMediaOverviewType( return std::nullopt; } -void SharedMediaShowOverview( - Storage::SharedMediaType type, - not_null history) { - if (SharedMediaOverviewType(type)) { - const auto &windows = history->session().windows(); - if (windows.empty()) { - Core::App().domain().activate(&history->session().account()); - if (windows.empty()) { - return; - } - } - windows.front()->showSection(std::make_shared( - history->peer, - Info::Section(type))); - } -} - bool SharedMediaAllowSearch(Storage::SharedMediaType type) { switch (type) { case Type::MusicFile: diff --git a/Telegram/SourceFiles/data/data_shared_media.h b/Telegram/SourceFiles/data/data_shared_media.h index 445dc2e2e7..f24c35693d 100644 --- a/Telegram/SourceFiles/data/data_shared_media.h +++ b/Telegram/SourceFiles/data/data_shared_media.h @@ -11,17 +11,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/weak_ptr.h" #include "data/data_sparse_ids.h" -class History; - namespace Main { class Session; } // namespace Main -std::optional SharedMediaOverviewType( +[[nodiscard]] std::optional SharedMediaOverviewType( Storage::SharedMediaType type); -void SharedMediaShowOverview( - Storage::SharedMediaType type, - not_null history); bool SharedMediaAllowSearch(Storage::SharedMediaType type); rpl::producer SharedMediaViewer( diff --git a/Telegram/SourceFiles/media/player/media_player_instance.h b/Telegram/SourceFiles/media/player/media_player_instance.h index bdc1078c0d..9255c9526b 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.h +++ b/Telegram/SourceFiles/media/player/media_player_instance.h @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL class AudioMsgId; class DocumentData; +class History; namespace Media { namespace Audio { diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index d28ed4e1d2..f492a7669e 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -31,6 +31,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/cached_round_corners.h" #include "ui/gl/gl_surface.h" #include "ui/boxes/confirm_box.h" +#include "info/info_memento.h" +#include "info/info_controller.h" #include "boxes/delete_messages_box.h" #include "boxes/report_messages_box.h" #include "media/audio/media_audio.h" @@ -1897,7 +1899,13 @@ void OverlayWidget::showMediaOverview() { update(); if (const auto overviewType = computeOverviewType()) { close(); - SharedMediaShowOverview(*overviewType, _history); + if (SharedMediaOverviewType(*overviewType)) { + if (const auto window = findWindow()) { + window->showSection(std::make_shared( + _history->peer, + Info::Section(*overviewType))); + } + } } } diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.h b/Telegram/SourceFiles/media/view/media_view_overlay_widget.h index b4fe87b596..47673712b8 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.h +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.h @@ -20,6 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "media/view/media_view_playback_controls.h" #include "media/view/media_view_open_common.h" +class History; + namespace Data { class PhotoMedia; class DocumentMedia;