[Improvement] Shortcut and settings code to reload language
This commit is contained in:
		
							parent
							
								
									473de051a3
								
							
						
					
					
						commit
						8f2b7fabd3
					
				
					 5 changed files with 19 additions and 0 deletions
				
			
		| 
						 | 
					@ -207,6 +207,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_notifications_mute_seconds": {
 | 
						"ktg_notifications_mute_seconds": {
 | 
				
			||||||
		"zero": "seconds",
 | 
							"zero": "seconds",
 | 
				
			||||||
		"one": "second",
 | 
							"one": "second",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,6 +69,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/cached_round_corners.h"
 | 
					#include "ui/cached_round_corners.h"
 | 
				
			||||||
| 
						 | 
					@ -1275,6 +1276,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);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,6 +100,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>{
 | 
				
			||||||
| 
						 | 
					@ -142,6 +143,7 @@ const auto CommandNames = base::flat_map<Command, QString>{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ Command::SaveDraft      , qsl("save_draft") },
 | 
						{ Command::SaveDraft      , qsl("save_draft") },
 | 
				
			||||||
	{ Command::JumpToDate     , qsl("jump_to_date") },
 | 
						{ Command::JumpToDate     , qsl("jump_to_date") },
 | 
				
			||||||
 | 
						{ Command::ReloadLang     , qsl("reload_lang") },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Manager {
 | 
					class Manager {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,6 +64,7 @@ enum class Command {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SaveDraft,
 | 
						SaveDraft,
 | 
				
			||||||
	JumpToDate,
 | 
						JumpToDate,
 | 
				
			||||||
 | 
						ReloadLang,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[maybe_unused]] constexpr auto kShowFolder = {
 | 
					[[maybe_unused]] constexpr auto kShowFolder = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 "platform/platform_specific.h"
 | 
					#include "platform/platform_specific.h"
 | 
				
			||||||
#include "ui/toast/toast.h"
 | 
					#include "ui/toast/toast.h"
 | 
				
			||||||
#include "mainwidget.h"
 | 
					#include "mainwidget.h"
 | 
				
			||||||
| 
						 | 
					@ -272,6 +273,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(qsl("customicon"), [](SessionController *window) {
 | 
						codes.emplace(qsl("customicon"), [](SessionController *window) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue