From eb120e2f5d0f73c09ccf4264036436935dc9df02 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 27 Mar 2020 17:14:27 +0400 Subject: [PATCH] Support tg://settings(/folders)? link. --- .../SourceFiles/core/local_url_handlers.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index fdb9a0198..03cb2ee9e 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -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(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 &LocalUrlHandlers() { qsl("^privatepost/?\\?(.+)(#|$)"), ResolvePrivatePost }, + { + qsl("^settings(/folders|/devices)?$"), + ResolveSettings + }, { qsl("^([^\\?]+)(\\?|#|$)"), HandleUnknown