MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / GenerateCodes

Function GenerateCodes

Telegram/SourceFiles/settings/settings_codes.cpp:77–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77auto GenerateCodes() {
78 auto codes = std::map<QString, Fn<void(SessionController*)>>();
79 codes.emplace(u"debugmode"_q, [](SessionController *window) {
80 QString text = Logs::DebugEnabled()
81 ? u"Do you want to disable DEBUG logs?"_q
82 : u"Do you want to enable DEBUG logs?\n\nAll network events will be logged."_q;
83 Ui::show(Ui::MakeConfirmBox({ text, [] {
84 Core::App().switchDebugMode();
85 } }));
86 });
87 codes.emplace(u"viewlogs"_q, [](SessionController *window) {
88 File::ShowInFolder(cWorkingDir() + "log.txt");
89 });
90 if (!Core::UpdaterDisabled()) {
91 codes.emplace(u"testupdate"_q, [](SessionController *window) {
92 Core::UpdateChecker().test();
93 });
94 }
95 codes.emplace(u"loadlang"_q, [](SessionController *window) {
96 Lang::CurrentCloudManager().switchToLanguage({ u"#custom"_q });
97 });
98 codes.emplace(u"crashplease"_q, [](SessionController *window) {
99 Unexpected("Crashed in Settings!");
100 });
101 codes.emplace(u"moderate"_q, [](SessionController *window) {
102 auto text = Core::App().settings().moderateModeEnabled() ? u"Disable moderate mode?"_q : u"Enable moderate mode?"_q;
103 Ui::show(Ui::MakeConfirmBox({ text, [=] {
104 Core::App().settings().setModerateModeEnabled(!Core::App().settings().moderateModeEnabled());
105 Core::App().saveSettingsDelayed();
106 Ui::hideLayer();
107 } }));
108 });
109 codes.emplace(u"getdifference"_q, [](SessionController *window) {
110 if (window) {
111 window->session().updates().getDifference();
112 }
113 });
114 codes.emplace(u"loadcolors"_q, [](SessionController *window) {
115 FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open palette file", "Palette (*.tdesktop-palette)", [](const FileDialog::OpenResult &result) {
116 if (!result.paths.isEmpty()) {
117 Window::Theme::Apply(result.paths.front());
118 }
119 });
120 });
121 codes.emplace(u"endpoints"_q, [](SessionController *window) {
122 if (!Core::App().domain().started()) {
123 return;
124 }
125 const auto weak = window
126 ? base::make_weak(&window->session().account())
127 : nullptr;
128 FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Open DC endpoints", "DC Endpoints (*.tdesktop-endpoints)", [weak](const FileDialog::OpenResult &result) {
129 if (!result.paths.isEmpty()) {
130 const auto loadFor = [&](not_null<Main::Account*> account) {
131 if (!account->mtp().dcOptions().loadFromFile(result.paths.front())) {
132 Ui::show(Ui::MakeInformBox("Could not load endpoints"
133 " :( Errors in 'log.txt'."));
134 }

Callers 1

CodesFeedStringFunction · 0.85

Calls 15

DebugEnabledFunction · 0.85
showFunction · 0.85
AppClass · 0.85
UpdaterDisabledFunction · 0.85
hideLayerFunction · 0.85
GetOpenPathFunction · 0.85
MakeInformBoxFunction · 0.85
FoldersIdFunction · 0.85
AllFilesFilterFunction · 0.85
UnpackRawGzipFunction · 0.85
GetWritePathFunction · 0.85
emplaceMethod · 0.80

Tested by

no test coverage detected