From 787ed443f481820aefda514b6b4aaf7e55318360 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 5 Sep 2023 13:34:41 +0300 Subject: [PATCH] Increased clickable area to change forward options in sections. --- Telegram/SourceFiles/history/history_widget.cpp | 17 +++++++++++------ .../controls/history_view_compose_controls.cpp | 9 ++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index d3795d4e9..6a0f06df8 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4329,12 +4329,14 @@ void HistoryWidget::mouseMoveEvent(QMouseEvent *e) { } void HistoryWidget::updateOverStates(QPoint pos) { + const auto isReadyToForward = readyToForward(); + const auto skip = isReadyToForward ? 0 : st::historyReplySkip; const auto replyEditForwardInfoRect = QRect( - st::historyReplySkip, + skip, _field->y() - st::historySendPadding - st::historyReplyHeight, - width() - st::historyReplySkip - _fieldBarCancel->width(), + width() - skip - _fieldBarCancel->width(), st::historyReplyHeight); - auto inReplyEditForward = (_editMsgId || replyToId() || readyToForward()) + auto inReplyEditForward = (_editMsgId || replyToId() || isReadyToForward) && replyEditForwardInfoRect.contains(pos); auto inPhotoEdit = inReplyEditForward && _photoEditMedia @@ -6170,16 +6172,19 @@ bool HistoryWidget::cornerButtonsHas(HistoryView::CornerButtonType type) { } void HistoryWidget::mousePressEvent(QMouseEvent *e) { + const auto isReadyToForward = readyToForward(); const auto hasSecondLayer = (_editMsgId || _replyToId - || readyToForward() + || isReadyToForward || _kbReplyTo); _replyForwardPressed = hasSecondLayer && QRect( 0, _field->y() - st::historySendPadding - st::historyReplyHeight, st::historyReplySkip, st::historyReplyHeight).contains(e->pos()); - if (_replyForwardPressed && !_fieldBarCancel->isHidden()) { + if (_replyForwardPressed + && !_fieldBarCancel->isHidden() + && !isReadyToForward) { updateField(); } else if (_inPhotoEdit && _photoEditMedia) { EditCaptionBox::StartPhotoEdit( @@ -6189,7 +6194,7 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) { _field->getTextWithTags(), crl::guard(_list, [=] { cancelEdit(); })); } else if (_inReplyEditForward) { - if (readyToForward()) { + if (isReadyToForward) { _forwardPanel->editOptions(controller()->uiShow()); } else { controller()->showPeerHistory( diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 22bccf2b6..cb1affa57 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -612,7 +612,7 @@ void FieldHeader::init() { const auto isLeftIcon = (pos.x() < st::historyReplySkip); const auto isLeftButton = (e->button() == Qt::LeftButton); if (type == QEvent::MouseButtonPress) { - if (isLeftButton && isLeftIcon) { + if (isLeftButton && isLeftIcon && !inPreviewRect) { *leftIconPressed = true; update(); } else if (isLeftButton && inPhotoEdit) { @@ -966,11 +966,13 @@ MsgId FieldHeader::getDraftMessageId() const { } void FieldHeader::updateControlsGeometry(QSize size) { + const auto isReadyToForward = readyToForward(); + const auto skip = isReadyToForward ? 0 : st::historyReplySkip; _cancel->moveToRight(0, 0); _clickableRect = QRect( - st::historyReplySkip, + skip, 0, - width() - st::historyReplySkip - _cancel->width(), + width() - skip - _cancel->width(), height()); _shownMessagePreviewRect = QRect( st::historyReplySkip, @@ -1000,6 +1002,7 @@ void FieldHeader::updateForwarding( if (readyToForward()) { replyToMessage({}); } + updateControlsGeometry(size()); } rpl::producer FieldHeader::editMsgIdValue() const {