Ctrl+[1-5] jump to the relevant pinned chat.

This commit is contained in:
John Preston 2018-12-29 17:39:17 +04:00
parent a11ca58f36
commit ea7796dccc
3 changed files with 30 additions and 0 deletions

View File

@ -310,6 +310,12 @@ void Manager::fillDefaults() {
set(qsl("f5"), Command::SupportReloadTemplates);
set(qsl("ctrl+delete"), Command::SupportToggleMuted);
set(qsl("ctrl+insert"), Command::SupportScrollToCurrent);
set(qsl("ctrl+1"), Command::ChatPinned1);
set(qsl("ctrl+2"), Command::ChatPinned2);
set(qsl("ctrl+3"), Command::ChatPinned3);
set(qsl("ctrl+4"), Command::ChatPinned4);
set(qsl("ctrl+5"), Command::ChatPinned5);
}
void Manager::writeDefaultFile() {

View File

@ -28,6 +28,11 @@ enum class Command {
ChatNext,
ChatFirst,
ChatLast,
ChatPinned1,
ChatPinned2,
ChatPinned3,
ChatPinned4,
ChatPinned5,
SupportReloadTemplates,
SupportToggleMuted,

View File

@ -2844,6 +2844,25 @@ void DialogsInner::setupShortcuts() {
request->check(Command::ChatLast) && request->handle([=] {
return jumpToDialogRow(last);
});
static const auto kPinned = {
Command::ChatPinned1,
Command::ChatPinned2,
Command::ChatPinned3,
Command::ChatPinned4,
Command::ChatPinned5,
};
auto &&pinned = ranges::view::zip(kPinned, ranges::view::ints(0));
for (const auto [command, index] : pinned) {
request->check(command) && request->handle([=, index = index] {
const auto count = shownPinnedCount();
if (index >= count) {
return false;
}
const auto row = *(shownDialogs()->cbegin() + index);
return jumpToDialogRow({ row->key(), FullMsgId() });
});
}
if (Auth().supportMode() && row.key.history()) {
request->check(
Command::SupportScrollToCurrent