Add two local urls to open language selection box.

tg://setlanguage and tg://settings/language

Fixes #7831.
This commit is contained in:
John Preston 2020-05-08 13:00:12 +04:00
parent d1d1f83881
commit 82a372873f
1 changed files with 17 additions and 4 deletions

View File

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/connection_box.h"
#include "boxes/sticker_set_box.h"
#include "boxes/sessions_box.h"
#include "boxes/language_box.h"
#include "passport/passport_form_controller.h"
#include "window/window_session_controller.h"
#include "data/data_session.h"
@ -101,12 +102,21 @@ bool ShowTheme(
return true;
}
void ShowLanguagesBox() {
static auto Guard = base::binary_guard();
Guard = LanguageBox::Show();
}
bool SetLanguage(
Main::Session *session,
const Match &match,
const QVariant &context) {
const auto languageId = match->captured(1);
Lang::CurrentCloudManager().switchWithWarning(languageId);
if (match->capturedRef(1).isEmpty()) {
ShowLanguagesBox();
} else {
const auto languageId = match->captured(2);
Lang::CurrentCloudManager().switchWithWarning(languageId);
}
return true;
}
@ -351,6 +361,9 @@ bool ResolveSettings(
if (section == qstr("devices")) {
Ui::show(Box<SessionsBox>(session));
return true;
} else if (section == qstr("language")) {
ShowLanguagesBox();
return true;
}
const auto type = (section == qstr("folders"))
? ::Settings::Type::Folders
@ -441,7 +454,7 @@ const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
ShowTheme
},
{
qsl("^setlanguage/?\\?lang=([a-zA-Z0-9\\.\\_\\-]+)(&|$)"),
qsl("^setlanguage/?(\\?lang=([a-zA-Z0-9\\.\\_\\-]+))?(&|$)"),
SetLanguage
},
{
@ -481,7 +494,7 @@ const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
ResolvePrivatePost
},
{
qsl("^settings(/folders|/devices)?$"),
qsl("^settings(/folders|/devices|/language)?$"),
ResolveSettings
},
{