Fixed opening of shared media in corresponding window from media viewer.

This commit is contained in:
23rd 2022-06-08 14:36:40 +03:00
parent fe2455dea6
commit 37f96534ec
6 changed files with 13 additions and 34 deletions

View file

@ -278,8 +278,6 @@ private:
QString _undoText; QString _undoText;
int _undoWidth = 0; int _undoWidth = 0;
int _buttonHeight = 0;
QPoint _mouse; QPoint _mouse;
bool _inDragArea = false; bool _inDragArea = false;
SelectedRow _selected; SelectedRow _selected;

View file

@ -9,23 +9,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <rpl/combine.h> #include <rpl/combine.h>
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_domain.h"
#include "core/application.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "storage/storage_facade.h" #include "storage/storage_facade.h"
#include "storage/storage_shared_media.h"
#include "history/history.h" #include "history/history.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "data/data_document.h" #include "data/data_document.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_photo.h" #include "data/data_photo.h"
#include "data/data_scheduled_messages.h" #include "data/data_scheduled_messages.h"
#include "data/data_sparse_ids.h"
#include "data/data_session.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" #include "core/crash_reports.h"
namespace { namespace {
@ -92,23 +84,6 @@ std::optional<Storage::SharedMediaType> SharedMediaOverviewType(
return std::nullopt; return std::nullopt;
} }
void SharedMediaShowOverview(
Storage::SharedMediaType type,
not_null<History*> 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<Info::Memento>(
history->peer,
Info::Section(type)));
}
}
bool SharedMediaAllowSearch(Storage::SharedMediaType type) { bool SharedMediaAllowSearch(Storage::SharedMediaType type) {
switch (type) { switch (type) {
case Type::MusicFile: case Type::MusicFile:

View file

@ -11,17 +11,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/weak_ptr.h" #include "base/weak_ptr.h"
#include "data/data_sparse_ids.h" #include "data/data_sparse_ids.h"
class History;
namespace Main { namespace Main {
class Session; class Session;
} // namespace Main } // namespace Main
std::optional<Storage::SharedMediaType> SharedMediaOverviewType( [[nodiscard]] std::optional<Storage::SharedMediaType> SharedMediaOverviewType(
Storage::SharedMediaType type); Storage::SharedMediaType type);
void SharedMediaShowOverview(
Storage::SharedMediaType type,
not_null<History*> history);
bool SharedMediaAllowSearch(Storage::SharedMediaType type); bool SharedMediaAllowSearch(Storage::SharedMediaType type);
rpl::producer<SparseIdsSlice> SharedMediaViewer( rpl::producer<SparseIdsSlice> SharedMediaViewer(

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class AudioMsgId; class AudioMsgId;
class DocumentData; class DocumentData;
class History;
namespace Media { namespace Media {
namespace Audio { namespace Audio {

View file

@ -31,6 +31,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/cached_round_corners.h" #include "ui/cached_round_corners.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/boxes/confirm_box.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/delete_messages_box.h"
#include "boxes/report_messages_box.h" #include "boxes/report_messages_box.h"
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
@ -1897,7 +1899,13 @@ void OverlayWidget::showMediaOverview() {
update(); update();
if (const auto overviewType = computeOverviewType()) { if (const auto overviewType = computeOverviewType()) {
close(); close();
SharedMediaShowOverview(*overviewType, _history); if (SharedMediaOverviewType(*overviewType)) {
if (const auto window = findWindow()) {
window->showSection(std::make_shared<Info::Memento>(
_history->peer,
Info::Section(*overviewType)));
}
}
} }
} }

View file

@ -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_playback_controls.h"
#include "media/view/media_view_open_common.h" #include "media/view/media_view_open_common.h"
class History;
namespace Data { namespace Data {
class PhotoMedia; class PhotoMedia;
class DocumentMedia; class DocumentMedia;