Added ability to open folders with shortcuts.

This commit is contained in:
23rd 2020-03-27 20:51:09 +03:00
parent 49e286b04c
commit 09bc3eefdb
3 changed files with 58 additions and 9 deletions

View file

@ -295,6 +295,8 @@ bool Manager::readCustomFile() {
}
void Manager::fillDefaults() {
const auto ctrl = Platform::IsMac() ? qsl("meta") : qsl("ctrl");
set(qsl("ctrl+w"), Command::Close);
set(qsl("ctrl+f4"), Command::Close);
set(qsl("ctrl+l"), Command::Lock);
@ -316,15 +318,11 @@ void Manager::fillDefaults() {
set(qsl("alt+down"), Command::ChatNext);
set(qsl("ctrl+pgup"), Command::ChatPrevious);
set(qsl("alt+up"), Command::ChatPrevious);
if (Platform::IsMac()) {
set(qsl("meta+tab"), Command::ChatNext);
set(qsl("meta+shift+tab"), Command::ChatPrevious);
set(qsl("meta+backtab"), Command::ChatPrevious);
} else {
set(qsl("ctrl+tab"), Command::ChatNext);
set(qsl("ctrl+shift+tab"), Command::ChatPrevious);
set(qsl("ctrl+backtab"), Command::ChatPrevious);
}
set(qsl("%1+tab").arg(ctrl), Command::ChatNext);
set(qsl("%1+shift+tab").arg(ctrl), Command::ChatPrevious);
set(qsl("%1+backtab").arg(ctrl), Command::ChatPrevious);
set(qsl("ctrl+alt+home"), Command::ChatFirst);
set(qsl("ctrl+alt+end"), Command::ChatLast);
@ -340,6 +338,14 @@ void Manager::fillDefaults() {
set(qsl("ctrl+4"), Command::ChatPinned4);
set(qsl("ctrl+5"), Command::ChatPinned5);
auto &&folders = ranges::view::zip(
kShowFolder,
ranges::view::ints(1, ranges::unreachable));
for (const auto [command, index] : folders) {
set(qsl("%1+shift+%2").arg(ctrl).arg(index > 9 ? 0 : index), command);
}
set(qsl("ctrl+0"), Command::ChatSelf);
set(qsl("ctrl+9"), Command::ShowArchive);

View file

@ -35,6 +35,17 @@ enum class Command {
ChatPinned4,
ChatPinned5,
ShowFolder1,
ShowFolder2,
ShowFolder3,
ShowFolder4,
ShowFolder5,
ShowFolder6,
ShowFolder7,
ShowFolder8,
ShowFolder9,
ShowFolder10,
ShowArchive,
JustSendMessage,
@ -48,6 +59,19 @@ enum class Command {
SupportHistoryForward,
};
constexpr auto kShowFolder = {
Command::ShowFolder1,
Command::ShowFolder2,
Command::ShowFolder3,
Command::ShowFolder4,
Command::ShowFolder5,
Command::ShowFolder6,
Command::ShowFolder7,
Command::ShowFolder8,
Command::ShowFolder9,
Command::ShowFolder10,
};
[[nodiscard]] FnMut<bool()> RequestHandler(Command command);
class Request {

View file

@ -3034,6 +3034,25 @@ void InnerWidget::setupShortcuts() {
return jumpToDialogRow({ row->key(), FullMsgId() });
});
}
auto &&folders = ranges::view::zip(
Shortcuts::kShowFolder,
ranges::view::ints(0, ranges::unreachable));
for (const auto [command, index] : folders) {
request->check(command) && request->handle([=, index = index] {
const auto list = &session().data().chatsFilters().list();
if (index >= list->size()) {
return false;
}
const auto filterId = list->at(index).id();
_controller->setActiveChatsFilter((filterId == _filterId)
? 0
: filterId);
return true;
});
}
if (session().supportMode() && row.key.history()) {
request->check(
Command::SupportScrollToCurrent