mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Added ability to show content from Controller for Shared Media.
This commit is contained in:
parent
9290cd3a16
commit
8591d58798
9 changed files with 47 additions and 33 deletions
|
@ -329,9 +329,6 @@ void DocumentOpenClickHandler::onClickImpl() const {
|
|||
}
|
||||
}
|
||||
|
||||
void DocumentOpenClickHandlerOld::onClickImpl() const {
|
||||
}
|
||||
|
||||
void DocumentOpenClickHandler::Open(
|
||||
Data::FileOrigin origin,
|
||||
not_null<DocumentData*> data,
|
||||
|
|
|
@ -378,15 +378,6 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class DocumentOpenClickHandlerOld : public DocumentClickHandler {
|
||||
public:
|
||||
using DocumentClickHandler::DocumentClickHandler;
|
||||
|
||||
protected:
|
||||
void onClickImpl() const override;
|
||||
|
||||
};
|
||||
|
||||
class DocumentCancelClickHandler : public DocumentClickHandler {
|
||||
public:
|
||||
using DocumentClickHandler::DocumentClickHandler;
|
||||
|
|
|
@ -491,9 +491,6 @@ void PhotoOpenClickHandler::onClickImpl() const {
|
|||
}
|
||||
}
|
||||
|
||||
void PhotoOpenClickHandlerOld::onClickImpl() const {
|
||||
}
|
||||
|
||||
void PhotoSaveClickHandler::onClickImpl() const {
|
||||
const auto data = photo();
|
||||
if (!data->date) {
|
||||
|
|
|
@ -208,15 +208,6 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class PhotoOpenClickHandlerOld : public PhotoClickHandler {
|
||||
public:
|
||||
using PhotoClickHandler::PhotoClickHandler;
|
||||
|
||||
protected:
|
||||
void onClickImpl() const override;
|
||||
|
||||
};
|
||||
|
||||
class PhotoSaveClickHandler : public PhotoClickHandler {
|
||||
public:
|
||||
using PhotoClickHandler::PhotoClickHandler;
|
||||
|
|
|
@ -887,6 +887,16 @@ void ListWidget::unregisterHeavyItem(not_null<const BaseLayout*> item) {
|
|||
}
|
||||
}
|
||||
|
||||
void ListWidget::openPhoto(not_null<PhotoData*> photo, FullMsgId id) {
|
||||
_controller->parentController()->openPhoto(photo, id);
|
||||
}
|
||||
|
||||
void ListWidget::openDocument(
|
||||
not_null<DocumentData*> document,
|
||||
FullMsgId id) {
|
||||
_controller->parentController()->openDocument(document, id);
|
||||
}
|
||||
|
||||
SparseIdsMergedSlice::Key ListWidget::sliceKey(
|
||||
UniversalMsgId universalId) const {
|
||||
using Key = SparseIdsMergedSlice::Key;
|
||||
|
|
|
@ -79,6 +79,11 @@ public:
|
|||
void registerHeavyItem(not_null<const BaseLayout*> item) override;
|
||||
void unregisterHeavyItem(not_null<const BaseLayout*> item) override;
|
||||
|
||||
void openPhoto(not_null<PhotoData*> photo, FullMsgId id) override;
|
||||
void openDocument(
|
||||
not_null<DocumentData*> document,
|
||||
FullMsgId id) override;
|
||||
|
||||
private:
|
||||
struct Context;
|
||||
class Section;
|
||||
|
|
|
@ -185,7 +185,11 @@ void RadialProgressItem::setDocumentLinks(
|
|||
not_null<DocumentData*> document) {
|
||||
const auto context = parent()->fullId();
|
||||
setLinks(
|
||||
std::make_shared<DocumentOpenClickHandlerOld>(document, context),
|
||||
std::make_shared<DocumentOpenClickHandler>(
|
||||
document,
|
||||
crl::guard(this, [=] {
|
||||
delegate()->openDocument(document, context);
|
||||
})),
|
||||
std::make_shared<DocumentSaveClickHandler>(document, context),
|
||||
std::make_shared<DocumentCancelClickHandler>(document, context));
|
||||
}
|
||||
|
@ -272,7 +276,9 @@ Photo::Photo(
|
|||
not_null<PhotoData*> photo)
|
||||
: ItemBase(delegate, parent)
|
||||
, _data(photo)
|
||||
, _link(std::make_shared<PhotoOpenClickHandlerOld>(photo, parent->fullId())) {
|
||||
, _link(std::make_shared<PhotoOpenClickHandler>(photo, crl::guard(this, [=] {
|
||||
delegate->openPhoto(photo, parent->fullId());
|
||||
}))) {
|
||||
if (_data->inlineThumbnailBytes().isEmpty()
|
||||
&& (_data->hasExact(Data::PhotoSize::Small)
|
||||
|| _data->hasExact(Data::PhotoSize::Thumbnail))) {
|
||||
|
@ -593,7 +599,11 @@ Voice::Voice(
|
|||
const style::OverviewFileLayout &st)
|
||||
: RadialProgressItem(delegate, parent)
|
||||
, _data(voice)
|
||||
, _namel(std::make_shared<DocumentOpenClickHandlerOld>(_data, parent->fullId()))
|
||||
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
||||
_data,
|
||||
crl::guard(this, [=] {
|
||||
delegate->openDocument(_data, parent->fullId());
|
||||
})))
|
||||
, _st(st) {
|
||||
AddComponents(Info::Bit());
|
||||
|
||||
|
@ -900,7 +910,11 @@ Document::Document(
|
|||
: RadialProgressItem(delegate, parent)
|
||||
, _data(document)
|
||||
, _msgl(goToMessageClickHandler(parent))
|
||||
, _namel(std::make_shared<DocumentOpenClickHandlerOld>(_data, parent->fullId()))
|
||||
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
||||
_data,
|
||||
crl::guard(this, [=] {
|
||||
delegate->openDocument(_data, parent->fullId());
|
||||
})))
|
||||
, _st(st)
|
||||
, _date(langDateTime(base::unixtime::parse(_data->date)))
|
||||
, _datew(st::normalFont->width(_date))
|
||||
|
@ -1452,18 +1466,22 @@ Link::Link(
|
|||
if (_page) {
|
||||
mainUrl = _page->url;
|
||||
if (_page->document) {
|
||||
_photol = std::make_shared<DocumentOpenClickHandlerOld>(
|
||||
_photol = std::make_shared<DocumentOpenClickHandler>(
|
||||
_page->document,
|
||||
parent->fullId());
|
||||
crl::guard(this, [=] {
|
||||
delegate->openDocument(_page->document, parent->fullId());
|
||||
}));
|
||||
} else if (_page->photo) {
|
||||
if (_page->type == WebPageType::Profile || _page->type == WebPageType::Video) {
|
||||
_photol = createHandler(_page->url);
|
||||
} else if (_page->type == WebPageType::Photo
|
||||
|| _page->siteName == qstr("Twitter")
|
||||
|| _page->siteName == qstr("Facebook")) {
|
||||
_photol = std::make_shared<PhotoOpenClickHandlerOld>(
|
||||
_photol = std::make_shared<PhotoOpenClickHandler>(
|
||||
_page->photo,
|
||||
parent->fullId());
|
||||
crl::guard(this, [=] {
|
||||
delegate->openPhoto(_page->photo, parent->fullId());
|
||||
}));
|
||||
} else {
|
||||
_photol = createHandler(_page->url);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class ItemBase : public LayoutItemBase {
|
||||
class ItemBase : public LayoutItemBase, public base::has_weak_ptr {
|
||||
public:
|
||||
ItemBase(not_null<Delegate*> delegate, not_null<HistoryItem*> parent);
|
||||
~ItemBase();
|
||||
|
|
|
@ -17,6 +17,11 @@ public:
|
|||
virtual void registerHeavyItem(not_null<const ItemBase*> item) = 0;
|
||||
virtual void unregisterHeavyItem(not_null<const ItemBase*> item) = 0;
|
||||
|
||||
virtual void openPhoto(not_null<PhotoData*> photo, FullMsgId id) = 0;
|
||||
virtual void openDocument(
|
||||
not_null<DocumentData*> document,
|
||||
FullMsgId id) = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Layout
|
||||
|
|
Loading…
Add table
Reference in a new issue