Added ability to jump between channel posts with Ctrl + arrow shortcuts.
This commit is contained in:
parent
2e6abf0bed
commit
29a458c8a0
|
@ -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();
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
void clear();
|
||||
|
||||
[[nodiscard]] float64 progress(not_null<const HistoryItem*> 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<base::Timer> _timer;
|
||||
|
||||
};
|
||||
|
||||
const not_null<Data::Session*> _data;
|
||||
|
@ -58,9 +61,11 @@ private:
|
|||
const RepaintView _repaintView;
|
||||
|
||||
FullMsgId _highlightedMessageId;
|
||||
FullMsgId _lastHighlightedMessageId;
|
||||
std::deque<FullMsgId> _queue;
|
||||
|
||||
AnimationManager _animation;
|
||||
|
||||
};
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 70867536a4f499f64c0efea18b870a24043c7ce0
|
||||
Subproject commit 0ea27ae051774047cc00b92778f98c2f243712e8
|
Loading…
Reference in New Issue