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() {
|
void ElementHighlighter::clear() {
|
||||||
_animation.cancel();
|
_animation.cancel();
|
||||||
_highlightedMessageId = FullMsgId();
|
_highlightedMessageId = FullMsgId();
|
||||||
|
_lastHighlightedMessageId = FullMsgId();
|
||||||
_queue.clear();
|
_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() {
|
void ElementHighlighter::AnimationManager::start() {
|
||||||
const auto finish = [=] {
|
const auto finish = [=] {
|
||||||
cancel();
|
cancel();
|
||||||
_parent._highlightedMessageId = FullMsgId();
|
_parent._lastHighlightedMessageId = base::take(
|
||||||
|
_parent._highlightedMessageId);
|
||||||
_parent.checkNextHighlight();
|
_parent.checkNextHighlight();
|
||||||
};
|
};
|
||||||
cancel();
|
cancel();
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
[[nodiscard]] float64 progress(not_null<const HistoryItem*> item) const;
|
[[nodiscard]] float64 progress(not_null<const HistoryItem*> item) const;
|
||||||
|
[[nodiscard]] MsgId latestSingleHighlightedMsgId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkNextHighlight();
|
void checkNextHighlight();
|
||||||
|
@ -47,10 +48,12 @@ private:
|
||||||
[[nodiscard]] float64 progress() const;
|
[[nodiscard]] float64 progress() const;
|
||||||
void start();
|
void start();
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ElementHighlighter &_parent;
|
ElementHighlighter &_parent;
|
||||||
Ui::Animations::Simple _simple;
|
Ui::Animations::Simple _simple;
|
||||||
std::optional<base::Timer> _timer;
|
std::optional<base::Timer> _timer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const not_null<Data::Session*> _data;
|
const not_null<Data::Session*> _data;
|
||||||
|
@ -58,9 +61,11 @@ private:
|
||||||
const RepaintView _repaintView;
|
const RepaintView _repaintView;
|
||||||
|
|
||||||
FullMsgId _highlightedMessageId;
|
FullMsgId _highlightedMessageId;
|
||||||
|
FullMsgId _lastHighlightedMessageId;
|
||||||
std::deque<FullMsgId> _queue;
|
std::deque<FullMsgId> _queue;
|
||||||
|
|
||||||
AnimationManager _animation;
|
AnimationManager _animation;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
|
@ -6212,6 +6212,16 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_scroll->keyPressEvent(e);
|
_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) {
|
} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
|
||||||
if (!_botStart->isHidden()) {
|
if (!_botStart->isHidden()) {
|
||||||
sendBotStartCommand();
|
sendBotStartCommand();
|
||||||
|
@ -6268,20 +6278,28 @@ bool HistoryWidget::replyToPreviousMessage() {
|
||||||
if (!_history || _editMsgId || _history->isForum()) {
|
if (!_history || _editMsgId || _history->isForum()) {
|
||||||
return false;
|
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 item = session().data().message(fullId)) {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
if (const auto previousView = view->previousDisplayedInBlocks()) {
|
if (const auto previousView = view->previousDisplayedInBlocks()) {
|
||||||
const auto previous = previousView->data();
|
const auto previous = previousView->data();
|
||||||
controller()->showMessage(previous);
|
controller()->showMessage(previous);
|
||||||
replyToMessage(previous);
|
if (_field->isVisible()) {
|
||||||
|
replyToMessage(previous);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (const auto previousView = _history->findLastDisplayed()) {
|
} else if (const auto previousView = _history->findLastDisplayed()) {
|
||||||
const auto previous = previousView->data();
|
const auto previous = previousView->data();
|
||||||
controller()->showMessage(previous);
|
controller()->showMessage(previous);
|
||||||
replyToMessage(previous);
|
if (_field->isVisible()) {
|
||||||
|
replyToMessage(previous);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -6291,13 +6309,19 @@ bool HistoryWidget::replyToNextMessage() {
|
||||||
if (!_history || _editMsgId || _history->isForum()) {
|
if (!_history || _editMsgId || _history->isForum()) {
|
||||||
return false;
|
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 item = session().data().message(fullId)) {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
if (const auto nextView = view->nextDisplayedInBlocks()) {
|
if (const auto nextView = view->nextDisplayedInBlocks()) {
|
||||||
const auto next = nextView->data();
|
const auto next = nextView->data();
|
||||||
controller()->showMessage(next);
|
controller()->showMessage(next);
|
||||||
replyToMessage(next);
|
if (_field->isVisible()) {
|
||||||
|
replyToMessage(next);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_highlighter.clear();
|
_highlighter.clear();
|
||||||
cancelReply(false);
|
cancelReply(false);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 70867536a4f499f64c0efea18b870a24043c7ce0
|
Subproject commit 0ea27ae051774047cc00b92778f98c2f243712e8
|
Loading…
Reference in New Issue
Block a user