diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index b47563311f..270785fcba 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -135,13 +135,6 @@ const auto CommandNames = base::flat_map{ { Command::FolderNext , u"next_folder"_q }, { Command::ShowAllChats , u"all_chats"_q }, - { Command::ShowAccount1 , u"account1"_q }, - { Command::ShowAccount2 , u"account2"_q }, - { Command::ShowAccount3 , u"account3"_q }, - { Command::ShowAccount4 , u"account4"_q }, - { Command::ShowAccount5 , u"account5"_q }, - { Command::ShowAccount6 , u"account6"_q }, - { Command::ShowFolder1 , u"folder1"_q }, { Command::ShowFolder2 , u"folder2"_q }, { Command::ShowFolder3 , u"folder3"_q }, @@ -156,6 +149,15 @@ const auto CommandNames = base::flat_map{ { Command::ReadChat , u"read_chat"_q }, }; +[[maybe_unused]] constexpr auto kNoValue = { + Command::JustSendMessage, + Command::SendSilentMessage, + Command::ScheduleMessage, + Command::MediaViewerFullscreen, + Command::ShowScheduled, + Command::ArchiveChat, +}; + class Manager { public: void fill(); @@ -408,14 +410,6 @@ 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); @@ -461,13 +455,14 @@ void Manager::writeDefaultFile() { } // Commands without a default value. - for (const auto command : kShowAccount) { - const auto j = CommandNames.find(command); - if (j != CommandNames.end()) { - QJsonObject entry; - entry.insert(u"keys"_q, QJsonValue()); - entry.insert(u"command"_q, j->second); - shortcuts.append(entry); + for (const auto c : ranges::views::concat(kShowAccount, kNoValue)) { + for (const auto &[name, command] : CommandByName) { + if (c == command) { + auto entry = QJsonObject(); + entry.insert(u"keys"_q, QJsonValue()); + entry.insert(u"command"_q, name); + shortcuts.append(entry); + } } }