Fixed triggering of pressed buttons in album preview.

This commit is contained in:
23rd 2021-04-26 13:01:53 +03:00
parent 948302cf02
commit 6975b04e6b
2 changed files with 12 additions and 1 deletions

View file

@ -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<int> AlbumPreview::thumbModified() const {

View file

@ -89,6 +89,8 @@ private:
AlbumThumbnail *_paintedAbove = nullptr;
QPoint _draggedStartPosition;
AttachButtonType _pressedButtonType = AttachButtonType::None;
rpl::event_stream<int> _thumbDeleted;
rpl::event_stream<int> _thumbChanged;
rpl::event_stream<int> _thumbModified;