diff --git a/Telegram/SourceFiles/history/history_view_highlight_manager.cpp b/Telegram/SourceFiles/history/history_view_highlight_manager.cpp index 137cd30e0..939e56980 100644 --- a/Telegram/SourceFiles/history/history_view_highlight_manager.cpp +++ b/Telegram/SourceFiles/history/history_view_highlight_manager.cpp @@ -115,6 +115,7 @@ void ElementHighlighter::updateMessage() { void ElementHighlighter::clear() { _animation.cancel(); _highlightedMessageId = FullMsgId(); + _lastHighlightedMessageId = FullMsgId(); _queue.clear(); } @@ -139,10 +140,17 @@ float64 ElementHighlighter::AnimationManager::progress() const { } } +MsgId ElementHighlighter::latestSingleHighlightedMsgId() const { + return _highlightedMessageId + ? _highlightedMessageId.msg + : _lastHighlightedMessageId.msg; +} + void ElementHighlighter::AnimationManager::start() { const auto finish = [=] { cancel(); - _parent._highlightedMessageId = FullMsgId(); + _parent._lastHighlightedMessageId = base::take( + _parent._highlightedMessageId); _parent.checkNextHighlight(); }; cancel(); diff --git a/Telegram/SourceFiles/history/history_view_highlight_manager.h b/Telegram/SourceFiles/history/history_view_highlight_manager.h index df43f446b..43372a8b9 100644 --- a/Telegram/SourceFiles/history/history_view_highlight_manager.h +++ b/Telegram/SourceFiles/history/history_view_highlight_manager.h @@ -34,6 +34,7 @@ public: void clear(); [[nodiscard]] float64 progress(not_null item) const; + [[nodiscard]] MsgId latestSingleHighlightedMsgId() const; private: void checkNextHighlight(); @@ -47,10 +48,12 @@ private: [[nodiscard]] float64 progress() const; void start(); void cancel(); + private: ElementHighlighter &_parent; Ui::Animations::Simple _simple; std::optional _timer; + }; const not_null _data; @@ -58,9 +61,11 @@ private: const RepaintView _repaintView; FullMsgId _highlightedMessageId; + FullMsgId _lastHighlightedMessageId; std::deque _queue; AnimationManager _animation; + }; } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 6c71cd83a..138a12a31 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6212,6 +6212,16 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) { return; } _scroll->keyPressEvent(e); + } else if (e->key() == Qt::Key_Up + && commonModifiers == Qt::ControlModifier) { + if (!replyToPreviousMessage()) { + e->ignore(); + } + } else if (e->key() == Qt::Key_Down + && commonModifiers == Qt::ControlModifier) { + if (!replyToNextMessage()) { + e->ignore(); + } } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { if (!_botStart->isHidden()) { sendBotStartCommand(); @@ -6268,20 +6278,28 @@ bool HistoryWidget::replyToPreviousMessage() { if (!_history || _editMsgId || _history->isForum()) { return false; } - const auto fullId = FullMsgId(_history->peer->id, _replyToId); + const auto fullId = FullMsgId( + _history->peer->id, + _field->isVisible() + ? _replyToId + : _highlighter.latestSingleHighlightedMsgId()); if (const auto item = session().data().message(fullId)) { if (const auto view = item->mainView()) { if (const auto previousView = view->previousDisplayedInBlocks()) { const auto previous = previousView->data(); controller()->showMessage(previous); - replyToMessage(previous); + if (_field->isVisible()) { + replyToMessage(previous); + } return true; } } } else if (const auto previousView = _history->findLastDisplayed()) { const auto previous = previousView->data(); controller()->showMessage(previous); - replyToMessage(previous); + if (_field->isVisible()) { + replyToMessage(previous); + } return true; } return false; @@ -6291,13 +6309,19 @@ bool HistoryWidget::replyToNextMessage() { if (!_history || _editMsgId || _history->isForum()) { return false; } - const auto fullId = FullMsgId(_history->peer->id, _replyToId); + const auto fullId = FullMsgId( + _history->peer->id, + _field->isVisible() + ? _replyToId + : _highlighter.latestSingleHighlightedMsgId()); if (const auto item = session().data().message(fullId)) { if (const auto view = item->mainView()) { if (const auto nextView = view->nextDisplayedInBlocks()) { const auto next = nextView->data(); controller()->showMessage(next); - replyToMessage(next); + if (_field->isVisible()) { + replyToMessage(next); + } } else { _highlighter.clear(); cancelReply(false); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 70867536a..0ea27ae05 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 70867536a4f499f64c0efea18b870a24043c7ce0 +Subproject commit 0ea27ae051774047cc00b92778f98c2f243712e8