mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
parent
3fd772ce17
commit
6c56fad180
10 changed files with 66 additions and 57 deletions
|
@ -62,15 +62,15 @@ DocumentClickHandler::DocumentClickHandler(
|
||||||
|
|
||||||
DocumentOpenClickHandler::DocumentOpenClickHandler(
|
DocumentOpenClickHandler::DocumentOpenClickHandler(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
Fn<void()> &&callback)
|
Fn<void(FullMsgId)> &&callback,
|
||||||
: DocumentClickHandler(document)
|
FullMsgId context)
|
||||||
|
: DocumentClickHandler(document, context)
|
||||||
, _handler(std::move(callback)) {
|
, _handler(std::move(callback)) {
|
||||||
|
Expects(_handler != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentOpenClickHandler::onClickImpl() const {
|
void DocumentOpenClickHandler::onClickImpl() const {
|
||||||
if (_handler) {
|
_handler(context());
|
||||||
_handler();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentSaveClickHandler::Save(
|
void DocumentSaveClickHandler::Save(
|
||||||
|
@ -170,15 +170,15 @@ PeerData *PhotoClickHandler::peer() const {
|
||||||
|
|
||||||
PhotoOpenClickHandler::PhotoOpenClickHandler(
|
PhotoOpenClickHandler::PhotoOpenClickHandler(
|
||||||
not_null<PhotoData*> photo,
|
not_null<PhotoData*> photo,
|
||||||
Fn<void()> &&callback)
|
Fn<void(FullMsgId)> &&callback,
|
||||||
: PhotoClickHandler(photo)
|
FullMsgId context)
|
||||||
|
: PhotoClickHandler(photo, context)
|
||||||
, _handler(std::move(callback)) {
|
, _handler(std::move(callback)) {
|
||||||
|
Expects(_handler != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoOpenClickHandler::onClickImpl() const {
|
void PhotoOpenClickHandler::onClickImpl() const {
|
||||||
if (_handler) {
|
_handler(context());
|
||||||
_handler();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoSaveClickHandler::onClickImpl() const {
|
void PhotoSaveClickHandler::onClickImpl() const {
|
||||||
|
|
|
@ -74,13 +74,14 @@ class DocumentOpenClickHandler : public DocumentClickHandler {
|
||||||
public:
|
public:
|
||||||
DocumentOpenClickHandler(
|
DocumentOpenClickHandler(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
Fn<void()> &&callback);
|
Fn<void(FullMsgId)> &&callback,
|
||||||
|
FullMsgId context = FullMsgId());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onClickImpl() const override;
|
void onClickImpl() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Fn<void()> _handler;
|
const Fn<void(FullMsgId)> _handler;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,13 +149,16 @@ private:
|
||||||
|
|
||||||
class PhotoOpenClickHandler : public PhotoClickHandler {
|
class PhotoOpenClickHandler : public PhotoClickHandler {
|
||||||
public:
|
public:
|
||||||
PhotoOpenClickHandler(not_null<PhotoData*> photo, Fn<void()> &&callback);
|
PhotoOpenClickHandler(
|
||||||
|
not_null<PhotoData*> photo,
|
||||||
|
Fn<void(FullMsgId)> &&callback,
|
||||||
|
FullMsgId context = FullMsgId());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onClickImpl() const override;
|
void onClickImpl() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Fn<void()> _handler;
|
const Fn<void(FullMsgId)> _handler;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,9 @@ void Document::createComponents(bool caption) {
|
||||||
_realParent->fullId());
|
_realParent->fullId());
|
||||||
}
|
}
|
||||||
if (const auto voice = Get<HistoryDocumentVoice>()) {
|
if (const auto voice = Get<HistoryDocumentVoice>()) {
|
||||||
voice->_seekl = std::make_shared<VoiceSeekClickHandler>(_data, [] {});
|
voice->_seekl = std::make_shared<VoiceSeekClickHandler>(
|
||||||
|
_data,
|
||||||
|
[](FullMsgId) {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ void File::clickHandlerPressedChanged(
|
||||||
}
|
}
|
||||||
|
|
||||||
void File::setLinks(
|
void File::setLinks(
|
||||||
ClickHandlerPtr &&openl,
|
FileClickHandlerPtr &&openl,
|
||||||
FileClickHandlerPtr &&savel,
|
FileClickHandlerPtr &&savel,
|
||||||
FileClickHandlerPtr &&cancell) {
|
FileClickHandlerPtr &&cancell) {
|
||||||
_openl = std::move(openl);
|
_openl = std::move(openl);
|
||||||
|
@ -58,6 +58,7 @@ void File::setLinks(
|
||||||
|
|
||||||
void File::refreshParentId(not_null<HistoryItem*> realParent) {
|
void File::refreshParentId(not_null<HistoryItem*> realParent) {
|
||||||
const auto contextId = realParent->fullId();
|
const auto contextId = realParent->fullId();
|
||||||
|
_openl->setMessageId(contextId);
|
||||||
_savel->setMessageId(contextId);
|
_savel->setMessageId(contextId);
|
||||||
_cancell->setMessageId(contextId);
|
_cancell->setMessageId(contextId);
|
||||||
}
|
}
|
||||||
|
@ -114,9 +115,10 @@ void File::setDocumentLinks(
|
||||||
setLinks(
|
setLinks(
|
||||||
std::make_shared<DocumentOpenClickHandler>(
|
std::make_shared<DocumentOpenClickHandler>(
|
||||||
document,
|
document,
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
_parent->delegate()->elementOpenDocument(document, context);
|
_parent->delegate()->elementOpenDocument(document, id);
|
||||||
})),
|
}),
|
||||||
|
context),
|
||||||
std::make_shared<DocumentSaveClickHandler>(document, context),
|
std::make_shared<DocumentSaveClickHandler>(document, context),
|
||||||
std::make_shared<DocumentCancelClickHandler>(document, context));
|
std::make_shared<DocumentCancelClickHandler>(document, context));
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,10 @@ protected:
|
||||||
using FileClickHandlerPtr = std::shared_ptr<FileClickHandler>;
|
using FileClickHandlerPtr = std::shared_ptr<FileClickHandler>;
|
||||||
|
|
||||||
not_null<HistoryItem*> _realParent;
|
not_null<HistoryItem*> _realParent;
|
||||||
ClickHandlerPtr _openl;
|
FileClickHandlerPtr _openl, _savel, _cancell;
|
||||||
FileClickHandlerPtr _savel, _cancell;
|
|
||||||
|
|
||||||
void setLinks(
|
void setLinks(
|
||||||
ClickHandlerPtr &&openl,
|
FileClickHandlerPtr &&openl,
|
||||||
FileClickHandlerPtr &&savel,
|
FileClickHandlerPtr &&savel,
|
||||||
FileClickHandlerPtr &&cancell);
|
FileClickHandlerPtr &&cancell);
|
||||||
void setDocumentLinks(
|
void setDocumentLinks(
|
||||||
|
|
|
@ -87,9 +87,10 @@ Photo::~Photo() {
|
||||||
|
|
||||||
void Photo::create(FullMsgId contextId, PeerData *chat) {
|
void Photo::create(FullMsgId contextId, PeerData *chat) {
|
||||||
setLinks(
|
setLinks(
|
||||||
std::make_shared<PhotoOpenClickHandler>(_data, crl::guard(this, [=] {
|
std::make_shared<PhotoOpenClickHandler>(
|
||||||
showPhoto();
|
_data,
|
||||||
})),
|
crl::guard(this, [=](FullMsgId id) { showPhoto(id); }),
|
||||||
|
contextId),
|
||||||
std::make_shared<PhotoSaveClickHandler>(_data, contextId, chat),
|
std::make_shared<PhotoSaveClickHandler>(_data, contextId, chat),
|
||||||
std::make_shared<PhotoCancelClickHandler>(_data, contextId, chat));
|
std::make_shared<PhotoCancelClickHandler>(_data, contextId, chat));
|
||||||
if ((_dataMedia = _data->activeMediaView())) {
|
if ((_dataMedia = _data->activeMediaView())) {
|
||||||
|
@ -774,7 +775,7 @@ void Photo::playAnimation(bool autoplay) {
|
||||||
if (_streamed && autoplay) {
|
if (_streamed && autoplay) {
|
||||||
return;
|
return;
|
||||||
} else if (_streamed && videoAutoplayEnabled()) {
|
} else if (_streamed && videoAutoplayEnabled()) {
|
||||||
showPhoto();
|
showPhoto(_parent->data()->fullId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_streamed) {
|
if (_streamed) {
|
||||||
|
@ -847,10 +848,8 @@ void Photo::parentTextUpdated() {
|
||||||
history()->owner().requestViewResize(_parent);
|
history()->owner().requestViewResize(_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Photo::showPhoto() {
|
void Photo::showPhoto(FullMsgId id) {
|
||||||
_parent->delegate()->elementOpenPhoto(
|
_parent->delegate()->elementOpenPhoto(_data, id);
|
||||||
_data,
|
|
||||||
_parent->data()->fullId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -102,7 +102,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
struct Streamed;
|
struct Streamed;
|
||||||
|
|
||||||
void showPhoto();
|
void showPhoto(FullMsgId id);
|
||||||
|
|
||||||
void create(FullMsgId contextId, PeerData *chat = nullptr);
|
void create(FullMsgId contextId, PeerData *chat = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -287,11 +287,10 @@ void Sticker::refreshLink() {
|
||||||
// .webp image and we allow to open it in media viewer.
|
// .webp image and we allow to open it in media viewer.
|
||||||
_link = std::make_shared<DocumentOpenClickHandler>(
|
_link = std::make_shared<DocumentOpenClickHandler>(
|
||||||
_data,
|
_data,
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
_parent->delegate()->elementOpenDocument(
|
_parent->delegate()->elementOpenDocument(_data, id);
|
||||||
_data,
|
}),
|
||||||
_parent->data()->fullId());
|
_parent->data()->fullId());
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2276,9 +2276,7 @@ void OverlayWidget::show(OpenRequest request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
clearControlsState();
|
clearControlsState();
|
||||||
if (contextPeer) {
|
_firstOpenedPeerPhoto = (contextPeer != nullptr);
|
||||||
_firstOpenedPeerPhoto = true;
|
|
||||||
}
|
|
||||||
assignMediaPointer(photo);
|
assignMediaPointer(photo);
|
||||||
|
|
||||||
displayPhoto(photo, contextPeer ? nullptr : contextItem);
|
displayPhoto(photo, contextPeer ? nullptr : contextItem);
|
||||||
|
|
|
@ -188,9 +188,10 @@ void RadialProgressItem::setDocumentLinks(
|
||||||
setLinks(
|
setLinks(
|
||||||
std::make_shared<DocumentOpenClickHandler>(
|
std::make_shared<DocumentOpenClickHandler>(
|
||||||
document,
|
document,
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
delegate()->openDocument(document, context);
|
delegate()->openDocument(document, id);
|
||||||
})),
|
}),
|
||||||
|
context),
|
||||||
std::make_shared<DocumentSaveClickHandler>(document, context),
|
std::make_shared<DocumentSaveClickHandler>(document, context),
|
||||||
std::make_shared<DocumentCancelClickHandler>(document, context));
|
std::make_shared<DocumentCancelClickHandler>(document, context));
|
||||||
}
|
}
|
||||||
|
@ -277,9 +278,10 @@ Photo::Photo(
|
||||||
not_null<PhotoData*> photo)
|
not_null<PhotoData*> photo)
|
||||||
: ItemBase(delegate, parent)
|
: ItemBase(delegate, parent)
|
||||||
, _data(photo)
|
, _data(photo)
|
||||||
, _link(std::make_shared<PhotoOpenClickHandler>(photo, crl::guard(this, [=] {
|
, _link(std::make_shared<PhotoOpenClickHandler>(
|
||||||
delegate->openPhoto(photo, parent->fullId());
|
photo,
|
||||||
}))) {
|
crl::guard(this, [=](FullMsgId id) { delegate->openPhoto(photo, id); }),
|
||||||
|
parent->fullId())) {
|
||||||
if (_data->inlineThumbnailBytes().isEmpty()
|
if (_data->inlineThumbnailBytes().isEmpty()
|
||||||
&& (_data->hasExact(Data::PhotoSize::Small)
|
&& (_data->hasExact(Data::PhotoSize::Small)
|
||||||
|| _data->hasExact(Data::PhotoSize::Thumbnail))) {
|
|| _data->hasExact(Data::PhotoSize::Thumbnail))) {
|
||||||
|
@ -602,9 +604,10 @@ Voice::Voice(
|
||||||
, _data(voice)
|
, _data(voice)
|
||||||
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
||||||
_data,
|
_data,
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
delegate->openDocument(_data, parent->fullId());
|
delegate->openDocument(_data, id);
|
||||||
})))
|
}),
|
||||||
|
parent->fullId()))
|
||||||
, _st(st) {
|
, _st(st) {
|
||||||
AddComponents(Info::Bit());
|
AddComponents(Info::Bit());
|
||||||
|
|
||||||
|
@ -913,9 +916,10 @@ Document::Document(
|
||||||
, _msgl(goToMessageClickHandler(parent))
|
, _msgl(goToMessageClickHandler(parent))
|
||||||
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
, _namel(std::make_shared<DocumentOpenClickHandler>(
|
||||||
_data,
|
_data,
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
delegate->openDocument(_data, parent->fullId());
|
delegate->openDocument(_data, id);
|
||||||
})))
|
}),
|
||||||
|
parent->fullId()))
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _date(langDateTime(base::unixtime::parse(_data->date)))
|
, _date(langDateTime(base::unixtime::parse(_data->date)))
|
||||||
, _datew(st::normalFont->width(_date))
|
, _datew(st::normalFont->width(_date))
|
||||||
|
@ -1469,9 +1473,10 @@ Link::Link(
|
||||||
if (_page->document) {
|
if (_page->document) {
|
||||||
_photol = std::make_shared<DocumentOpenClickHandler>(
|
_photol = std::make_shared<DocumentOpenClickHandler>(
|
||||||
_page->document,
|
_page->document,
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
delegate->openDocument(_page->document, parent->fullId());
|
delegate->openDocument(_page->document, id);
|
||||||
}));
|
}),
|
||||||
|
parent->fullId());
|
||||||
} else if (_page->photo) {
|
} else if (_page->photo) {
|
||||||
if (_page->type == WebPageType::Profile || _page->type == WebPageType::Video) {
|
if (_page->type == WebPageType::Profile || _page->type == WebPageType::Video) {
|
||||||
_photol = createHandler(_page->url);
|
_photol = createHandler(_page->url);
|
||||||
|
@ -1480,9 +1485,10 @@ Link::Link(
|
||||||
|| _page->siteName == qstr("Facebook")) {
|
|| _page->siteName == qstr("Facebook")) {
|
||||||
_photol = std::make_shared<PhotoOpenClickHandler>(
|
_photol = std::make_shared<PhotoOpenClickHandler>(
|
||||||
_page->photo,
|
_page->photo,
|
||||||
crl::guard(this, [=] {
|
crl::guard(this, [=](FullMsgId id) {
|
||||||
delegate->openPhoto(_page->photo, parent->fullId());
|
delegate->openPhoto(_page->photo, id);
|
||||||
}));
|
}),
|
||||||
|
parent->fullId());
|
||||||
} else {
|
} else {
|
||||||
_photol = createHandler(_page->url);
|
_photol = createHandler(_page->url);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue