Added all unused shortcuts to json of default shortcuts.

This commit is contained in:
23rd 2024-03-24 18:01:44 +03:00 committed by John Preston
parent 00a89883fd
commit aad2961646
1 changed files with 17 additions and 22 deletions

View File

@ -135,13 +135,6 @@ const auto CommandNames = base::flat_map<Command, QString>{
{ 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, QString>{
{ 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);
}
}
}