mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved some app config values to separated file.
This commit is contained in:
parent
30a7893afe
commit
ca2a0d41c9
4 changed files with 63 additions and 21 deletions
|
@ -924,6 +924,8 @@ PRIVATE
|
||||||
main/main_account.h
|
main/main_account.h
|
||||||
main/main_app_config.cpp
|
main/main_app_config.cpp
|
||||||
main/main_app_config.h
|
main/main_app_config.h
|
||||||
|
main/main_app_config_values.cpp
|
||||||
|
main/main_app_config_values.h
|
||||||
main/main_domain.cpp
|
main/main_domain.cpp
|
||||||
main/main_domain.h
|
main/main_domain.h
|
||||||
main/main_session.cpp
|
main/main_session.cpp
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
|
#include "main/main_app_config_values.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
@ -127,28 +128,19 @@ void AddPhoneMenu(not_null<Ui::PopupMenu*> menu, not_null<UserData*> user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto domains = user->session().account().appConfig().get<Strings>(
|
if (const auto url = AppConfig::FragmentLink(&user->session())) {
|
||||||
u"whitelisted_domains"_q,
|
menu->addSeparator(&st::expandedMenuSeparator);
|
||||||
std::vector<QString>());
|
const auto link = Ui::Text::Link(
|
||||||
const auto proj = [&, domain = u"fragment"_q](const QString &p) {
|
tr::lng_info_mobile_context_menu_fragment_about_link(tr::now),
|
||||||
return p.contains(domain);
|
*url);
|
||||||
};
|
menu->addAction(base::make_unique_q<TextItem>(
|
||||||
const auto it = ranges::find_if(domains, proj);
|
menu->menu(),
|
||||||
if (it == end(domains)) {
|
st::reactionMenu.menu,
|
||||||
return;
|
tr::lng_info_mobile_context_menu_fragment_about(
|
||||||
|
lt_link,
|
||||||
|
rpl::single(link),
|
||||||
|
Ui::Text::RichLangValue)));
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->addSeparator(&st::expandedMenuSeparator);
|
|
||||||
const auto link = Ui::Text::Link(
|
|
||||||
tr::lng_info_mobile_context_menu_fragment_about_link(tr::now),
|
|
||||||
*it);
|
|
||||||
menu->addAction(base::make_unique_q<TextItem>(
|
|
||||||
menu->menu(),
|
|
||||||
st::reactionMenu.menu,
|
|
||||||
tr::lng_info_mobile_context_menu_fragment_about(
|
|
||||||
lt_link,
|
|
||||||
rpl::single(link),
|
|
||||||
Ui::Text::RichLangValue)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Profile
|
} // namespace Profile
|
||||||
|
|
30
Telegram/SourceFiles/main/main_app_config_values.cpp
Normal file
30
Telegram/SourceFiles/main/main_app_config_values.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "main/main_app_config_values.h"
|
||||||
|
|
||||||
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_app_config.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
|
||||||
|
namespace AppConfig {
|
||||||
|
|
||||||
|
std::optional<QString> FragmentLink(not_null<Main::Session*> session) {
|
||||||
|
using Strings = std::vector<QString>;
|
||||||
|
const auto domains = session->account().appConfig().get<Strings>(
|
||||||
|
u"whitelisted_domains"_q,
|
||||||
|
std::vector<QString>());
|
||||||
|
const auto proj = [&, domain = u"fragment"_q](const QString &p) {
|
||||||
|
return p.contains(domain);
|
||||||
|
};
|
||||||
|
const auto it = ranges::find_if(domains, proj);
|
||||||
|
return (it == end(domains))
|
||||||
|
? std::nullopt
|
||||||
|
: std::make_optional<QString>(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AppConfig
|
18
Telegram/SourceFiles/main/main_app_config_values.h
Normal file
18
Telegram/SourceFiles/main/main_app_config_values.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Session;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
|
namespace AppConfig {
|
||||||
|
|
||||||
|
[[nodiscard]] std::optional<QString> FragmentLink(not_null<Main::Session*>);
|
||||||
|
|
||||||
|
} // namespace AppConfig
|
Loading…
Add table
Reference in a new issue