mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Added SessionController pointer to Media::View::OverlayWidget.
This commit is contained in:
@@ -333,9 +333,9 @@ bool Result::onChoose(Layout::ItemBase *layout) {
|
||||
|
||||
Media::View::OpenRequest Result::openRequest() {
|
||||
if (_document) {
|
||||
return Media::View::OpenRequest(_document, nullptr);
|
||||
return Media::View::OpenRequest(nullptr, _document, nullptr);
|
||||
} else if (_photo) {
|
||||
return Media::View::OpenRequest(_photo, nullptr);
|
||||
return Media::View::OpenRequest(nullptr, _photo, nullptr);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@@ -14,6 +14,10 @@ class PeerData;
|
||||
class PhotoData;
|
||||
class HistoryItem;
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Media::View {
|
||||
|
||||
struct OpenRequest {
|
||||
@@ -21,23 +25,37 @@ public:
|
||||
OpenRequest() {
|
||||
}
|
||||
|
||||
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)
|
||||
OpenRequest(
|
||||
Window::SessionController *controller,
|
||||
not_null<PhotoData*> photo,
|
||||
HistoryItem *item)
|
||||
: _controller(controller)
|
||||
, _photo(photo)
|
||||
, _item(item) {
|
||||
}
|
||||
OpenRequest(
|
||||
Window::SessionController *controller,
|
||||
not_null<PhotoData*> photo,
|
||||
not_null<PeerData*> peer)
|
||||
: _controller(controller)
|
||||
, _photo(photo)
|
||||
, _peer(peer) {
|
||||
}
|
||||
|
||||
OpenRequest(
|
||||
Window::SessionController *controller,
|
||||
not_null<DocumentData*> document,
|
||||
HistoryItem *item)
|
||||
: _controller(controller)
|
||||
, _document(document)
|
||||
, _item(item) {
|
||||
}
|
||||
OpenRequest(
|
||||
Window::SessionController *controller,
|
||||
not_null<DocumentData*> document,
|
||||
const Data::CloudTheme &cloudTheme)
|
||||
: _document(document)
|
||||
: _controller(controller)
|
||||
, _document(document)
|
||||
, _cloudTheme(cloudTheme) {
|
||||
}
|
||||
|
||||
@@ -61,7 +79,12 @@ public:
|
||||
return _cloudTheme;
|
||||
}
|
||||
|
||||
Window::SessionController *controller() const {
|
||||
return _controller;
|
||||
}
|
||||
|
||||
private:
|
||||
Window::SessionController *_controller = nullptr;
|
||||
DocumentData *_document = nullptr;
|
||||
PhotoData *_photo = nullptr;
|
||||
PeerData *_peer = nullptr;
|
||||
|
@@ -2316,6 +2316,10 @@ void OverlayWidget::showDocument(
|
||||
}
|
||||
|
||||
void OverlayWidget::show(OpenRequest request) {
|
||||
if (!request.controller()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto document = request.document();
|
||||
const auto photo = request.photo();
|
||||
const auto contextItem = request.item();
|
||||
@@ -2325,6 +2329,8 @@ void OverlayWidget::show(OpenRequest request) {
|
||||
return;
|
||||
}
|
||||
setSession(&photo->session());
|
||||
_controller = request.controller();
|
||||
Assert(_session == (&_controller->session()));
|
||||
|
||||
if (contextPeer) {
|
||||
setContext(contextPeer);
|
||||
@@ -2345,6 +2351,8 @@ void OverlayWidget::show(OpenRequest request) {
|
||||
activateControls();
|
||||
} else if (document) {
|
||||
setSession(&document->session());
|
||||
_controller = request.controller();
|
||||
Assert(_session == (&_controller->session()));
|
||||
|
||||
if (contextItem) {
|
||||
setContext(contextItem);
|
||||
|
@@ -429,6 +429,7 @@ private:
|
||||
const std::unique_ptr<Ui::RpWidgetWrap> _surface;
|
||||
const not_null<QWidget*> _widget;
|
||||
|
||||
Window::SessionController *_controller = nullptr;
|
||||
Main::Session *_session = nullptr;
|
||||
rpl::lifetime _sessionLifetime;
|
||||
PhotoData *_photo = nullptr;
|
||||
|
@@ -1223,6 +1223,7 @@ void SessionController::openPhoto(
|
||||
not_null<PhotoData*> photo,
|
||||
FullMsgId contextId) {
|
||||
_window->openInMediaView(Media::View::OpenRequest(
|
||||
this,
|
||||
photo,
|
||||
session().data().message(contextId)));
|
||||
}
|
||||
@@ -1230,7 +1231,7 @@ void SessionController::openPhoto(
|
||||
void SessionController::openPhoto(
|
||||
not_null<PhotoData*> photo,
|
||||
not_null<PeerData*> peer) {
|
||||
_window->openInMediaView(Media::View::OpenRequest(photo, peer));
|
||||
_window->openInMediaView(Media::View::OpenRequest(this, photo, peer));
|
||||
}
|
||||
|
||||
void SessionController::openDocument(
|
||||
@@ -1240,6 +1241,7 @@ void SessionController::openDocument(
|
||||
// TEMP.
|
||||
if (showInMediaView) {
|
||||
_window->openInMediaView(Media::View::OpenRequest(
|
||||
this,
|
||||
document,
|
||||
session().data().message(contextId)));
|
||||
return;
|
||||
|
Reference in New Issue
Block a user