diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index f673aba28..56158e2b5 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -80,6 +80,13 @@ const auto CommandByName = base::flat_map{ { u"next_folder"_q , Command::FolderNext }, { u"all_chats"_q , Command::ShowAllChats }, + { u"account1"_q , Command::ShowAccount1 }, + { u"account2"_q , Command::ShowAccount2 }, + { u"account3"_q , Command::ShowAccount3 }, + { u"account4"_q , Command::ShowAccount4 }, + { u"account5"_q , Command::ShowAccount5 }, + { u"account6"_q , Command::ShowAccount6 }, + { u"folder1"_q , Command::ShowFolder1 }, { u"folder2"_q , Command::ShowFolder2 }, { u"folder3"_q , Command::ShowFolder3 }, @@ -392,6 +399,14 @@ void Manager::fillDefaults() { set(u"%1+%2"_q.arg(ctrl).arg(index), command); } + auto &&accounts = ranges::views::zip( + kShowAccount, + ranges::views::ints(1, ranges::unreachable)); + + for (const auto [command, index] : accounts) { + set(u"%1+shift+%2"_q.arg(ctrl).arg(index), command); + } + set(u"%1+shift+down"_q.arg(ctrl), Command::FolderNext); set(u"%1+shift+up"_q.arg(ctrl), Command::FolderPrevious); diff --git a/Telegram/SourceFiles/core/shortcuts.h b/Telegram/SourceFiles/core/shortcuts.h index d7b3dc3c5..b562517d5 100644 --- a/Telegram/SourceFiles/core/shortcuts.h +++ b/Telegram/SourceFiles/core/shortcuts.h @@ -38,6 +38,13 @@ enum class Command { ChatPinned7, ChatPinned8, + ShowAccount1, + ShowAccount2, + ShowAccount3, + ShowAccount4, + ShowAccount5, + ShowAccount6, + ShowAllChats, ShowFolder1, ShowFolder2, @@ -79,6 +86,15 @@ enum class Command { Command::ShowFolderLast, }; +[[maybe_unused]] constexpr auto kShowAccount = { + Command::ShowAccount1, + Command::ShowAccount2, + Command::ShowAccount3, + Command::ShowAccount4, + Command::ShowAccount5, + Command::ShowAccount6, +}; + [[nodiscard]] FnMut RequestHandler(Command command); class Request { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 454e525f6..3f78e1850 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1224,19 +1224,48 @@ void SessionController::showGiftPremiumsBox(const QString &ref) { void SessionController::init() { if (session().supportMode()) { - initSupportMode(); + session().supportHelper().registerWindow(this); } + setupShortcuts(); } -void SessionController::initSupportMode() { - session().supportHelper().registerWindow(this); - +void SessionController::setupShortcuts() { Shortcuts::Requests( ) | rpl::filter([=] { - return (Core::App().activeWindow() == &window()); + return (Core::App().activeWindow() == &window()) + && !isLayerShown() + && !window().locked(); }) | rpl::start_with_next([=](not_null request) { using C = Shortcuts::Command; + const auto app = &Core::App(); + const auto accountsCount = int(app->domain().accounts().size()); + auto &&accounts = ranges::views::zip( + Shortcuts::kShowAccount, + ranges::views::ints(0, accountsCount)); + for (const auto [command, index] : accounts) { + request->check(command) && request->handle([=] { + const auto list = app->domain().orderedAccounts(); + if (index >= list.size()) { + return false; + } + const auto account = list[index]; + if (account == &session().account()) { + return false; + } + const auto window = app->separateWindowForAccount(account); + if (window) { + window->activate(); + } else { + app->domain().maybeActivate(account); + } + return true; + }); + } + + if (!session().supportMode()) { + return; + } request->check(C::SupportHistoryBack) && request->handle([=] { return chatEntryHistoryMove(-1); }); diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 03a60fcac..4ef7b1791 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -601,7 +601,7 @@ private: struct CachedTheme; void init(); - void initSupportMode(); + void setupShortcuts(); void refreshFiltersMenu(); void checkOpenedFilter(); void suggestArchiveAndMute();