Support tg://settings(/folders)? link.

This commit is contained in:
John Preston 2020-03-27 17:14:27 +04:00
parent cdff0ea9c7
commit eb120e2f5d
1 changed files with 30 additions and 0 deletions

View File

@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/share_box.h"
#include "boxes/connection_box.h"
#include "boxes/sticker_set_box.h"
#include "boxes/sessions_box.h"
#include "passport/passport_form_controller.h"
#include "window/window_session_controller.h"
#include "data/data_session.h"
@ -27,6 +28,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_cloud_themes.h"
#include "data/data_channel.h"
#include "media/player/media_player_instance.h"
#include "window/window_session_controller.h"
#include "settings/settings_common.h"
#include "mainwindow.h"
#include "mainwidget.h"
#include "main/main_session.h"
@ -333,6 +336,29 @@ bool ResolvePrivatePost(
return true;
}
bool ResolveSettings(
Main::Session *session,
const Match &match,
const QVariant &context) {
const auto section = match->captured(1).mid(1).toLower();
if (!session) {
if (section.isEmpty()) {
App::wnd()->showSettings();
return true;
}
return false;
}
if (section == qstr("devices")) {
Ui::show(Box<SessionsBox>(session));
return true;
}
const auto type = (section == qstr("folders"))
? ::Settings::Type::Folders
: ::Settings::Type::Main;
App::wnd()->sessionController()->showSettings(type);
return true;
}
bool HandleUnknown(
Main::Session *session,
const Match &match,
@ -454,6 +480,10 @@ const std::vector<LocalUrlHandler> &LocalUrlHandlers() {
qsl("^privatepost/?\\?(.+)(#|$)"),
ResolvePrivatePost
},
{
qsl("^settings(/folders|/devices)?$"),
ResolveSettings
},
{
qsl("^([^\\?]+)(\\?|#|$)"),
HandleUnknown