Added initial ability to show content in OverlayWidget from Controller.

This commit is contained in:
23rd 2021-06-14 09:33:54 +03:00 committed by John Preston
parent b422ec025e
commit 0e89c93993
9 changed files with 138 additions and 0 deletions

View file

@ -805,6 +805,7 @@ PRIVATE
media/view/media_view_playback_controls.h media/view/media_view_playback_controls.h
media/view/media_view_playback_progress.cpp media/view/media_view_playback_progress.cpp
media/view/media_view_playback_progress.h media/view/media_view_playback_progress.h
media/view/media_view_open_common.h
mtproto/config_loader.cpp mtproto/config_loader.cpp
mtproto/config_loader.h mtproto/config_loader.h
mtproto/connection_abstract.cpp mtproto/connection_abstract.cpp

View file

@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_domain.h" #include "main/main_domain.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "media/view/media_view_overlay_widget.h" #include "media/view/media_view_overlay_widget.h"
#include "media/view/media_view_open_common.h"
#include "mtproto/mtproto_dc_options.h" #include "mtproto/mtproto_dc_options.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "mtproto/mtp_instance.h" #include "mtproto/mtp_instance.h"
@ -284,6 +285,13 @@ void Application::run() {
&& Ui::Integration::Instance().openglLastCheckFailed()) { && Ui::Integration::Instance().openglLastCheckFailed()) {
showOpenGLCrashNotification(); showOpenGLCrashNotification();
} }
_window->openInMediaViewRequests(
) | rpl::start_with_next([=](Media::View::OpenRequest &&request) {
if (_mediaView) {
_mediaView->show(std::move(request));
}
}, _window->lifetime());
} }
void Application::showOpenGLCrashNotification() { void Application::showOpenGLCrashNotification() {

View file

@ -0,0 +1,70 @@
/*
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
*/
#pragma once
#include "data/data_cloud_themes.h"
class DocumentData;
class PeerData;
class PhotoData;
class HistoryItem;
namespace Media::View {
struct OpenRequest {
public:
OpenRequest(not_null<PhotoData*> photo, HistoryItem *item)
: _photo(photo)
, _item(item) {
}
OpenRequest(not_null<PhotoData*> photo, not_null<PeerData*> peer)
: _photo(photo)
, _peer(peer) {
}
OpenRequest(not_null<DocumentData*> document, HistoryItem *item)
: _document(document)
, _item(item) {
}
OpenRequest(
not_null<DocumentData*> document,
const Data::CloudTheme &cloudTheme)
: _document(document)
, _cloudTheme(cloudTheme) {
}
PeerData *peer() const {
return _peer;
}
PhotoData *photo() const {
return _photo;
}
HistoryItem *item() const {
return _item;
}
DocumentData *document() const {
return _document;
}
std::optional<Data::CloudTheme> cloudTheme() const {
return _cloudTheme;
}
private:
DocumentData *_document = nullptr;
PhotoData *_photo = nullptr;
PeerData *_peer = nullptr;
HistoryItem *_item = nullptr;
std::optional<Data::CloudTheme> _cloudTheme = std::nullopt;
};
} // namespace Media::View

View file

@ -2315,6 +2315,9 @@ void OverlayWidget::showDocument(
} }
} }
void OverlayWidget::show(OpenRequest request) {
}
void OverlayWidget::displayPhoto(not_null<PhotoData*> photo, HistoryItem *item) { void OverlayWidget::displayPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
if (photo->isNull()) { if (photo->isNull()) {
displayDocument(nullptr, item); displayDocument(nullptr, item);

View file

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_web_page.h" #include "data/data_web_page.h"
#include "data/data_cloud_themes.h" // Data::CloudTheme. #include "data/data_cloud_themes.h" // Data::CloudTheme.
#include "media/view/media_view_playback_controls.h" #include "media/view/media_view_playback_controls.h"
#include "media/view/media_view_open_common.h"
namespace Data { namespace Data {
class PhotoMedia; class PhotoMedia;
@ -86,6 +87,8 @@ public:
not_null<DocumentData*> document, not_null<DocumentData*> document,
const Data::CloudTheme &cloud); const Data::CloudTheme &cloud);
void show(OpenRequest request);
//void leaveToChildEvent(QEvent *e, QWidget *child) override { //void leaveToChildEvent(QEvent *e, QWidget *child) override {
// // e -- from enterEvent() of child TWidget // // e -- from enterEvent() of child TWidget
// updateOverState(OverNone); // updateOverState(OverNone);

View file

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "main/main_app_config.h" #include "main/main_app_config.h"
#include "media/view/media_view_open_common.h"
#include "intro/intro_widget.h" #include "intro/intro_widget.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "ui/layers/box_content.h" #include "ui/layers/box_content.h"
@ -373,4 +374,17 @@ Window::Adaptive &Controller::adaptive() const {
return *_adaptive; return *_adaptive;
} }
void Controller::openInMediaView(Media::View::OpenRequest &&request) {
_openInMediaViewRequests.fire(std::move(request));
}
auto Controller::openInMediaViewRequests() const
-> rpl::producer<Media::View::OpenRequest> {
return _openInMediaViewRequests.events();
}
rpl::lifetime &Controller::lifetime() {
return _lifetime;
}
} // namespace Window } // namespace Window

View file

@ -15,6 +15,10 @@ namespace Main {
class Account; class Account;
} // namespace Main } // namespace Main
namespace Media::View {
struct OpenRequest;
} // namespace Media::View
namespace Window { namespace Window {
class Controller final { class Controller final {
@ -79,8 +83,14 @@ public:
void preventOrInvoke(Fn<void()> &&callback); void preventOrInvoke(Fn<void()> &&callback);
void openInMediaView(Media::View::OpenRequest &&request);
[[nodiscard]] auto openInMediaViewRequests() const
-> rpl::producer<Media::View::OpenRequest>;
QPoint getPointForCallPanelCenter() const; QPoint getPointForCallPanelCenter() const;
rpl::lifetime &lifetime();
private: private:
void showBox( void showBox(
object_ptr<Ui::BoxContent> content, object_ptr<Ui::BoxContent> content,
@ -98,6 +108,8 @@ private:
base::Timer _isActiveTimer; base::Timer _isActiveTimer;
QPointer<Ui::BoxContent> _termsBox; QPointer<Ui::BoxContent> _termsBox;
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
rpl::lifetime _accountLifetime; rpl::lifetime _accountLifetime;
rpl::lifetime _lifetime; rpl::lifetime _lifetime;

View file

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "history/view/history_view_replies_section.h" #include "history/view/history_view_replies_section.h"
#include "media/player/media_player_instance.h" #include "media/player/media_player_instance.h"
#include "media/view/media_view_open_common.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_folder.h" #include "data/data_folder.h"
@ -1217,6 +1218,28 @@ QPointer<Ui::BoxContent> SessionController::show(
return _window->show(std::move(content), options, animated); return _window->show(std::move(content), options, animated);
} }
void SessionController::openPhoto(
not_null<PhotoData*> photo,
FullMsgId contextId) {
_window->openInMediaView(Media::View::OpenRequest(
photo,
session().data().message(contextId)));
}
void SessionController::openPhoto(
not_null<PhotoData*> photo,
not_null<PeerData*> peer) {
_window->openInMediaView(Media::View::OpenRequest(photo, peer));
}
void SessionController::openDocument(
not_null<DocumentData*> document,
FullMsgId contextId) {
_window->openInMediaView(Media::View::OpenRequest(
document,
session().data().message(contextId)));
}
SessionController::~SessionController() = default; SessionController::~SessionController() = default;
} // namespace Window } // namespace Window

View file

@ -347,6 +347,10 @@ public:
void showPassportForm(const Passport::FormRequest &request); void showPassportForm(const Passport::FormRequest &request);
void clearPassportForm(); void clearPassportForm();
void openPhoto(not_null<PhotoData*> photo, FullMsgId contextId);
void openPhoto(not_null<PhotoData*> photo, not_null<PeerData*> peer);
void openDocument(not_null<DocumentData*> document, FullMsgId contextId);
void showChooseReportMessages( void showChooseReportMessages(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Ui::ReportReason reason, Ui::ReportReason reason,