From 235938256ee8da9119f6e7e6753552ef4cc13f4f Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Tue, 14 Jul 2020 04:37:20 +0300 Subject: [PATCH] Fix forward messages by keyboard with opening chat on click option --- Telegram/SourceFiles/boxes/share_box.cpp | 42 +++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 67b3d5082..475368d6a 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -68,6 +68,8 @@ public: void activateSkipPage(int pageHeight, int direction); void updateFilter(QString filter = QString()); void selectActive(); + void tryGoToChat(); + void selectionMade(); rpl::producer scrollToRequests() const; rpl::producer<> searchRequests() const; @@ -249,11 +251,16 @@ void ShareBox::prepare() { }); _select->setResizedCallback([=] { updateScrollSkips(); }); _select->setSubmittedCallback([=](Qt::KeyboardModifiers modifiers) { - if (modifiers.testFlag(Qt::ControlModifier) + if ((modifiers.testFlag(Qt::ControlModifier) && !cForwardChatOnClick()) || modifiers.testFlag(Qt::MetaModifier)) { submit({}); } else { _inner->selectActive(); + if (!modifiers.testFlag(Qt::ControlModifier) || cForwardChatOnClick()) { + _inner->tryGoToChat(); + } else { + _inner->selectionMade(); + } } }); _comment->heightValue( @@ -940,17 +947,10 @@ void ShareBox::Inner::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { updateUpon(e->pos()); changeCheckState(getChatAtIndex(_upon)); - if (!_hadSelection - && !(e->modifiers() & Qt::ControlModifier) - && _selected.size() == 1) { - if (_submitRequest && _selected.front()->isSelf()) { - _submitRequest(); - } else if (_goToChatRequest && cForwardChatOnClick()) { - _goToChatRequest(); - } - _hadSelection = true; - } else if (!_hadSelection) { - _hadSelection = true; + if (!e->modifiers().testFlag(Qt::ControlModifier)) { + tryGoToChat(); + } else { + selectionMade(); } } } @@ -959,6 +959,24 @@ void ShareBox::Inner::selectActive() { changeCheckState(getChatAtIndex(_active > 0 ? _active : 0)); } +void ShareBox::Inner::tryGoToChat() { + if (!_hadSelection + && _selected.size() == 1) { + if (_submitRequest && _selected.front()->isSelf()) { + _submitRequest(); + } else if (_goToChatRequest && cForwardChatOnClick()) { + _goToChatRequest(); + } + _hadSelection = true; + } +} + +void ShareBox::Inner::selectionMade() { + if (!_hadSelection) { + _hadSelection = true; + } +} + void ShareBox::Inner::resizeEvent(QResizeEvent *e) { _columnSkip = (width() - _columnCount * st::sharePhotoCheckbox.imageRadius * 2) / float64(_columnCount + 1); _rowWidthReal = st::sharePhotoCheckbox.imageRadius * 2 + _columnSkip;