From 6975b04e6b7a20178016f935e910f7db52d3c95e Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 26 Apr 2021 13:01:53 +0300 Subject: [PATCH] Fixed triggering of pressed buttons in album preview. --- .../ui/chat/attach/attach_album_preview.cpp | 11 ++++++++++- .../SourceFiles/ui/chat/attach/attach_album_preview.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp index a4caa28d6c..5737d3cd2f 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.cpp @@ -392,7 +392,7 @@ void AlbumPreview::mousePressEvent(QMouseEvent *e) { cancelDrag(); if (const auto thumb = findThumb(position)) { if (thumb->buttonsContainPoint(e->pos())) { - thumbButtonsCallback(thumb, thumb->buttonTypeFromPoint(e->pos())); + _pressedButtonType = thumb->buttonTypeFromPoint(e->pos()); return; } _paintedAbove = _suggestedThumb = _draggedThumb = thumb; @@ -492,7 +492,16 @@ void AlbumPreview::mouseReleaseEvent(QMouseEvent *e) { _draggedThumb = nullptr; _suggestedThumb = nullptr; update(); + } else if (const auto thumb = findThumb(e->pos())) { + if (thumb->buttonsContainPoint(e->pos())) { + const auto was = _pressedButtonType; + const auto now = thumb->buttonTypeFromPoint(e->pos()); + if (was == now) { + thumbButtonsCallback(thumb, now); + } + } } + _pressedButtonType = AttachButtonType::None; } rpl::producer AlbumPreview::thumbModified() const { diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.h b/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.h index 3016db4b74..e9fc6006eb 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_album_preview.h @@ -89,6 +89,8 @@ private: AlbumThumbnail *_paintedAbove = nullptr; QPoint _draggedStartPosition; + AttachButtonType _pressedButtonType = AttachButtonType::None; + rpl::event_stream _thumbDeleted; rpl::event_stream _thumbChanged; rpl::event_stream _thumbModified;