[Improvement] Shortcut and settings code to reload language

This commit is contained in:
Eric Kotato 2022-09-11 03:31:54 +03:00 committed by Eric Kotato
parent 9ada0c04a2
commit 09778ba687
5 changed files with 19 additions and 0 deletions

View file

@ -159,6 +159,7 @@
"ktg_send_silent_preview": "Send preview silent", "ktg_send_silent_preview": "Send preview silent",
"ktg_reminder_preview": "Remind with preview", "ktg_reminder_preview": "Remind with preview",
"ktg_schedule_preview": "Send preview scheduled", "ktg_schedule_preview": "Send preview scheduled",
"ktg_language_reloaded": "Kotatogram-specific language strings were reloaded.",
"ktg_forward_sender_names_and_captions_removed": "Sender names and captions removed", "ktg_forward_sender_names_and_captions_removed": "Sender names and captions removed",
"ktg_forward_remember_mode": "Remember forward mode", "ktg_forward_remember_mode": "Remember forward mode",
"ktg_forward_mode": "Forward mode", "ktg_forward_mode": "Forward mode",

View file

@ -81,6 +81,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/gl/gl_detection.h" #include "ui/gl/gl_detection.h"
#include "ui/image/image.h" #include "ui/image/image.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/toast/toast.h"
#include "ui/emoji_config.h" #include "ui/emoji_config.h"
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
#include "ui/effects/spoiler_mess.h" #include "ui/effects/spoiler_mess.h"
@ -1802,6 +1803,13 @@ void Application::startShortcuts() {
request->check(Command::Close) && request->handle([=] { request->check(Command::Close) && request->handle([=] {
return closeActiveWindow(); return closeActiveWindow();
}); });
request->check(Command::ReloadLang) && request->handle([=] {
Kotato::Lang::Load(
Lang::GetInstance().baseId(),
Lang::GetInstance().id());
Ui::Toast::Show(ktr("ktg_language_reloaded"));
return true;
});
}, _lifetime); }, _lifetime);
} }

View file

@ -111,6 +111,7 @@ const auto CommandByName = base::flat_map<QString, Command>{
{ qsl("save_draft") , Command::SaveDraft }, { qsl("save_draft") , Command::SaveDraft },
{ qsl("jump_to_date") , Command::JumpToDate }, { qsl("jump_to_date") , Command::JumpToDate },
{ qsl("reload_lang") , Command::ReloadLang },
}; };
const auto CommandNames = base::flat_map<Command, QString>{ const auto CommandNames = base::flat_map<Command, QString>{
@ -153,6 +154,7 @@ const auto CommandNames = base::flat_map<Command, QString>{
{ Command::SaveDraft , u"save_draft"_q }, { Command::SaveDraft , u"save_draft"_q },
{ Command::JumpToDate , u"jump_to_date"_q }, { Command::JumpToDate , u"jump_to_date"_q },
{ Command::ReloadLang , u"reload_lang"_q },
}; };
[[maybe_unused]] constexpr auto kNoValue = { [[maybe_unused]] constexpr auto kNoValue = {

View file

@ -79,6 +79,7 @@ enum class Command {
SaveDraft, SaveDraft,
JumpToDate, JumpToDate,
ReloadLang,
}; };
[[maybe_unused]] constexpr auto kShowFolder = { [[maybe_unused]] constexpr auto kShowFolder = {

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "settings/settings_codes.h" #include "settings/settings_codes.h"
#include "kotato/kotato_lang.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
@ -248,6 +249,12 @@ auto GenerateCodes() {
Data::CloudThemes::SetTestingColors(now); Data::CloudThemes::SetTestingColors(now);
Ui::Toast::Show(now ? "Testing chat theme colors!" : "Not testing.."); Ui::Toast::Show(now ? "Testing chat theme colors!" : "Not testing..");
}); });
codes.emplace(qsl("reloadlang"), [](SessionController *window) {
Kotato::Lang::Load(
Lang::GetInstance().baseId(),
Lang::GetInstance().id());
Ui::Toast::Show(ktr("ktg_language_reloaded"));
});
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
codes.emplace(u"customicon"_q, [](SessionController *window) { codes.emplace(u"customicon"_q, [](SessionController *window) {