mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to scroll to replying message on reply header click.
This commit is contained in:
parent
8c224f7aca
commit
498e82b804
1 changed files with 15 additions and 11 deletions
|
@ -130,6 +130,8 @@ private:
|
||||||
const not_null<Data::Session*> _data;
|
const not_null<Data::Session*> _data;
|
||||||
const not_null<Ui::IconButton*> _cancel;
|
const not_null<Ui::IconButton*> _cancel;
|
||||||
|
|
||||||
|
QRect _clickableRect;
|
||||||
|
|
||||||
rpl::event_stream<bool> _visibleChanged;
|
rpl::event_stream<bool> _visibleChanged;
|
||||||
rpl::event_stream<FullMsgId> _scrollToItemRequests;
|
rpl::event_stream<FullMsgId> _scrollToItemRequests;
|
||||||
|
|
||||||
|
@ -231,22 +233,16 @@ void FieldHeader::init() {
|
||||||
events(
|
events(
|
||||||
) | rpl::filter([=](not_null<QEvent*> event) {
|
) | rpl::filter([=](not_null<QEvent*> event) {
|
||||||
return ranges::contains(kMouseEvents, event->type())
|
return ranges::contains(kMouseEvents, event->type())
|
||||||
&& isEditingMessage();
|
&& (isEditingMessage() || replyingToMessage());
|
||||||
}) | rpl::start_with_next([=](not_null<QEvent*> event) {
|
}) | rpl::start_with_next([=](not_null<QEvent*> event) {
|
||||||
const auto type = event->type();
|
const auto type = event->type();
|
||||||
const auto e = static_cast<QMouseEvent*>(event.get());
|
const auto e = static_cast<QMouseEvent*>(event.get());
|
||||||
const auto pos = e ? e->pos() : mapFromGlobal(QCursor::pos());
|
const auto pos = e ? e->pos() : mapFromGlobal(QCursor::pos());
|
||||||
const auto inPreviewRect = QRect(
|
const auto inPreviewRect = _clickableRect.contains(pos);
|
||||||
st::historyReplySkip,
|
|
||||||
0,
|
|
||||||
width() - st::historyReplySkip - _cancel->width(),
|
|
||||||
height()).contains(pos);
|
|
||||||
|
|
||||||
if (type == QEvent::MouseMove) {
|
if (type == QEvent::MouseMove) {
|
||||||
const auto inEdit = inPreviewRect;
|
if (inPreviewRect != *inClickable) {
|
||||||
|
*inClickable = inPreviewRect;
|
||||||
if (inEdit != *inClickable) {
|
|
||||||
*inClickable = inEdit;
|
|
||||||
setCursor(*inClickable
|
setCursor(*inClickable
|
||||||
? style::cur_pointer
|
? style::cur_pointer
|
||||||
: style::cur_default);
|
: style::cur_default);
|
||||||
|
@ -260,7 +256,10 @@ void FieldHeader::init() {
|
||||||
*leftIconPressed = true;
|
*leftIconPressed = true;
|
||||||
update();
|
update();
|
||||||
} else if (isLeftButton && inPreviewRect) {
|
} else if (isLeftButton && inPreviewRect) {
|
||||||
_scrollToItemRequests.fire(_editMsgId.current());
|
auto id = isEditingMessage()
|
||||||
|
? _editMsgId.current()
|
||||||
|
: replyingToMessage();
|
||||||
|
_scrollToItemRequests.fire(std::move(id));
|
||||||
}
|
}
|
||||||
} else if (type == QEvent::MouseButtonRelease) {
|
} else if (type == QEvent::MouseButtonRelease) {
|
||||||
if (isLeftButton && *leftIconPressed) {
|
if (isLeftButton && *leftIconPressed) {
|
||||||
|
@ -451,6 +450,11 @@ WebPageId FieldHeader::webPageId() const {
|
||||||
|
|
||||||
void FieldHeader::updateControlsGeometry(QSize size) {
|
void FieldHeader::updateControlsGeometry(QSize size) {
|
||||||
_cancel->moveToRight(0, 0);
|
_cancel->moveToRight(0, 0);
|
||||||
|
_clickableRect = QRect(
|
||||||
|
st::historyReplySkip,
|
||||||
|
0,
|
||||||
|
width() - st::historyReplySkip - _cancel->width(),
|
||||||
|
height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldHeader::editMessage(FullMsgId id) {
|
void FieldHeader::editMessage(FullMsgId id) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue