mirror of https://github.com/procxx/kepka.git
Add reply shortcut
This commit is contained in:
parent
26e023058c
commit
74b126f309
|
@ -577,6 +577,31 @@ public:
|
|||
setAttachToNext(attachToNext);
|
||||
}
|
||||
|
||||
HistoryItem *previousItem() const {
|
||||
if (_block && _indexInBlock >= 0) {
|
||||
if (_indexInBlock > 0) {
|
||||
return _block->items.at(_indexInBlock - 1);
|
||||
}
|
||||
if (auto previous = _block->previousBlock()) {
|
||||
Assert(!previous->items.empty());
|
||||
return previous->items.back();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
HistoryItem *nextItem() const {
|
||||
if (_block && _indexInBlock >= 0) {
|
||||
if (_indexInBlock + 1 < _block->items.size()) {
|
||||
return _block->items.at(_indexInBlock + 1);
|
||||
}
|
||||
if (auto next = _block->nextBlock()) {
|
||||
Assert(!next->items.empty());
|
||||
return next->items.front();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
~HistoryItem();
|
||||
|
||||
protected:
|
||||
|
@ -608,31 +633,6 @@ protected:
|
|||
int _indexInBlock = -1;
|
||||
MTPDmessage::Flags _flags = 0;
|
||||
|
||||
HistoryItem *previousItem() const {
|
||||
if (_block && _indexInBlock >= 0) {
|
||||
if (_indexInBlock > 0) {
|
||||
return _block->items.at(_indexInBlock - 1);
|
||||
}
|
||||
if (auto previous = _block->previousBlock()) {
|
||||
Assert(!previous->items.empty());
|
||||
return previous->items.back();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
HistoryItem *nextItem() const {
|
||||
if (_block && _indexInBlock >= 0) {
|
||||
if (_indexInBlock + 1 < _block->items.size()) {
|
||||
return _block->items.at(_indexInBlock + 1);
|
||||
}
|
||||
if (auto next = _block->nextBlock()) {
|
||||
Assert(!next->items.empty());
|
||||
return next->items.front();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This should be called only from previousItemChanged()
|
||||
// to add required bits to the Composer mask
|
||||
// after that always use Has<HistoryMessageDate>().
|
||||
|
|
|
@ -5046,6 +5046,19 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
|
|||
} else if (e->key() == Qt::Key_Down) {
|
||||
if (!(e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier))) {
|
||||
_scroll->keyPressEvent(e);
|
||||
} else if ((e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier)) == Qt::ControlModifier) {
|
||||
if (_history && _history->lastMsg && !_editMsgId) {
|
||||
if (_replyToId) {
|
||||
HistoryItem *item = App::histItemById(_history->channelId(), _replyToId)->nextItem();
|
||||
if (item) App::contextItem(item);
|
||||
else { cancelReply(); return; }
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
Ui::showPeerHistory(_peer, App::contextItem()->id);
|
||||
onReplyToMessage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (e->key() == Qt::Key_Up) {
|
||||
if (!(e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier))) {
|
||||
|
@ -5057,6 +5070,20 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
|
|||
}
|
||||
}
|
||||
_scroll->keyPressEvent(e);
|
||||
} else if ((e->modifiers() & (Qt::ShiftModifier | Qt::MetaModifier | Qt::ControlModifier)) == Qt::ControlModifier) {
|
||||
if (_history && _history->lastMsg && !_editMsgId) {
|
||||
if (_replyToId) {
|
||||
HistoryItem *item = App::histItemById(_history->channelId(), _replyToId);
|
||||
App::contextItem(item->previousItem());
|
||||
} else {
|
||||
App::contextItem(_history->lastMsg);
|
||||
}
|
||||
if (App::contextItem()) {
|
||||
Ui::showPeerHistory(_peer, App::contextItem()->id);
|
||||
onReplyToMessage();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
|
||||
onListEnterPressed();
|
||||
|
|
Loading…
Reference in New Issue