Added ability to switch between folders with shortcuts.

This commit is contained in:
23rd 2020-03-29 02:04:20 +03:00
parent 7b583596ec
commit df290605f4
3 changed files with 35 additions and 0 deletions

View file

@ -346,6 +346,9 @@ void Manager::fillDefaults() {
set(qsl("%1+shift+%2").arg(ctrl).arg(index > 9 ? 0 : index), command);
}
set(qsl("%1+shift+down").arg(ctrl), Command::FolderNext);
set(qsl("%1+shift+up").arg(ctrl), Command::FolderPrevious);
set(qsl("ctrl+0"), Command::ChatSelf);
set(qsl("ctrl+9"), Command::ShowArchive);

View file

@ -46,6 +46,9 @@ enum class Command {
ShowFolder9,
ShowFolder10,
FolderNext,
FolderPrevious,
ShowArchive,
JustSendMessage,

View file

@ -3053,6 +3053,35 @@ void InnerWidget::setupShortcuts() {
});
}
const auto nearFolder = [=](bool isNext) {
const auto id = _controller->activeChatsFilterCurrent();
const auto list = &session().data().chatsFilters().list();
const auto it = (id == 0)
? begin(*list) - 1
: ranges::find(*list, id, &Data::ChatFilter::id);
if (it == end(*list) && id != 0) {
return false;
}
const auto i = isNext ? 1 : -1;
const auto index = it - begin(*list) + i;
if (index >= (int)list->size() || index < -1) {
return false;
}
const auto filterId = (index == -1)
? 0
: list->at(index).id();
_controller->setActiveChatsFilter(filterId);
return true;
};
request->check(Command::FolderNext) && request->handle([=] {
return nearFolder(true);
});
request->check(Command::FolderPrevious) && request->handle([=] {
return nearFolder(false);
});
if (session().supportMode() && row.key.history()) {
request->check(
Command::SupportScrollToCurrent