Open link without warning

Allow Open Link Without Warning By Default
This commit is contained in:
People-11 2025-07-08 01:28:14 +09:30
parent 12879207ef
commit 95d2dfa7e1
5 changed files with 33 additions and 1 deletions

View file

@ -6647,6 +6647,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_KeepAliveService" = "AyuGram Push Service"; "ayu_KeepAliveService" = "AyuGram Push Service";
"ayu_DisableAds" = "Disable Ads"; "ayu_DisableAds" = "Disable Ads";
"ayu_DisableStories" = "Disable Stories"; "ayu_DisableStories" = "Disable Stories";
"ayu_DisableOpenLinkWarning" = "Disable Open Link Warning";
"ayu_DisableCustomBackgrounds" = "Disable Custom Backgrounds"; "ayu_DisableCustomBackgrounds" = "Disable Custom Backgrounds";
"ayu_DisableNotificationsDelay" = "Disable Notify Delay"; "ayu_DisableNotificationsDelay" = "Disable Notify Delay";
"ayu_LocalPremium" = "Local Telegram Premium"; "ayu_LocalPremium" = "Local Telegram Premium";

View file

@ -222,6 +222,7 @@ AyuGramSettings::AyuGramSettings() {
showOnlyAddedEmojisAndStickers = false; showOnlyAddedEmojisAndStickers = false;
collapseSimilarChannels = true; collapseSimilarChannels = true;
hideSimilarChannels = false; hideSimilarChannels = false;
disableOpenLinkWarning = false;
wideMultiplier = 1.0; wideMultiplier = 1.0;
@ -395,6 +396,10 @@ void set_hideSimilarChannels(bool val) {
settings->hideSimilarChannels = val; settings->hideSimilarChannels = val;
} }
void set_disableOpenLinkWarning(bool val) {
settings->disableOpenLinkWarning = val;
}
void set_wideMultiplier(double val) { void set_wideMultiplier(double val) {
settings->wideMultiplier = val; settings->wideMultiplier = val;
} }

View file

@ -67,6 +67,7 @@ public:
bool showOnlyAddedEmojisAndStickers; bool showOnlyAddedEmojisAndStickers;
bool collapseSimilarChannels; bool collapseSimilarChannels;
bool hideSimilarChannels; bool hideSimilarChannels;
bool disableOpenLinkWarning;
double wideMultiplier; double wideMultiplier;
@ -151,6 +152,7 @@ void set_disableCustomBackgrounds(bool val);
void set_showOnlyAddedEmojisAndStickers(bool val); void set_showOnlyAddedEmojisAndStickers(bool val);
void set_collapseSimilarChannels(bool val); void set_collapseSimilarChannels(bool val);
void set_hideSimilarChannels(bool val); void set_hideSimilarChannels(bool val);
void set_disableOpenLinkWarning(bool val);
void set_wideMultiplier(double val); void set_wideMultiplier(double val);
@ -228,6 +230,7 @@ inline void to_json(nlohmann::json &nlohmann_json_j, const AyuGramSettings &nloh
NLOHMANN_JSON_TO(showOnlyAddedEmojisAndStickers) NLOHMANN_JSON_TO(showOnlyAddedEmojisAndStickers)
NLOHMANN_JSON_TO(collapseSimilarChannels) NLOHMANN_JSON_TO(collapseSimilarChannels)
NLOHMANN_JSON_TO(hideSimilarChannels) NLOHMANN_JSON_TO(hideSimilarChannels)
NLOHMANN_JSON_TO(disableOpenLinkWarning)
NLOHMANN_JSON_TO(wideMultiplier) NLOHMANN_JSON_TO(wideMultiplier)
NLOHMANN_JSON_TO(spoofWebviewAsAndroid) NLOHMANN_JSON_TO(spoofWebviewAsAndroid)
NLOHMANN_JSON_TO(increaseWebviewHeight) NLOHMANN_JSON_TO(increaseWebviewHeight)
@ -293,6 +296,7 @@ inline void from_json(const nlohmann::json &nlohmann_json_j, AyuGramSettings &nl
NLOHMANN_JSON_FROM_WITH_DEFAULT(showOnlyAddedEmojisAndStickers) NLOHMANN_JSON_FROM_WITH_DEFAULT(showOnlyAddedEmojisAndStickers)
NLOHMANN_JSON_FROM_WITH_DEFAULT(collapseSimilarChannels) NLOHMANN_JSON_FROM_WITH_DEFAULT(collapseSimilarChannels)
NLOHMANN_JSON_FROM_WITH_DEFAULT(hideSimilarChannels) NLOHMANN_JSON_FROM_WITH_DEFAULT(hideSimilarChannels)
NLOHMANN_JSON_FROM_WITH_DEFAULT(disableOpenLinkWarning)
NLOHMANN_JSON_FROM_WITH_DEFAULT(wideMultiplier) NLOHMANN_JSON_FROM_WITH_DEFAULT(wideMultiplier)
NLOHMANN_JSON_FROM_WITH_DEFAULT(spoofWebviewAsAndroid) NLOHMANN_JSON_FROM_WITH_DEFAULT(spoofWebviewAsAndroid)
NLOHMANN_JSON_FROM_WITH_DEFAULT(increaseWebviewHeight) NLOHMANN_JSON_FROM_WITH_DEFAULT(increaseWebviewHeight)

View file

@ -785,6 +785,25 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
AddCollapsibleToggle(container, tr::ayu_DisableSimilarChannels(), checkboxes, true); AddCollapsibleToggle(container, tr::ayu_DisableSimilarChannels(), checkboxes, true);
AddButtonWithIcon(
container,
tr::ayu_DisableOpenLinkWarning(),
st::settingsButtonNoIcon
)->toggleOn(
rpl::single(settings->disableOpenLinkWarning)
)->toggledValue(
) | rpl::filter(
[=](bool enabled)
{
return (enabled != settings->disableOpenLinkWarning);
}) | start_with_next(
[=](bool enabled)
{
AyuSettings::set_disableOpenLinkWarning(enabled);
AyuSettings::save();
},
container->lifetime());
AddSkip(container); AddSkip(container);
AddDivider(container); AddDivider(container);
AddSkip(container); AddSkip(container);

View file

@ -31,6 +31,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_calls.h" // groupCallBoxLabel #include "styles/style_calls.h" // groupCallBoxLabel
#include "styles/style_layers.h" #include "styles/style_layers.h"
// AyuGram includes
#include "ayu/ayu_settings.h"
namespace { namespace {
// Possible context owners: media viewer, profile, history widget. // Possible context owners: media viewer, profile, history widget.
@ -126,7 +129,7 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) {
const auto parsedUrl = url.startsWith(u"tonsite://"_q) const auto parsedUrl = url.startsWith(u"tonsite://"_q)
? QUrl(url) ? QUrl(url)
: QUrl::fromUserInput(url); : QUrl::fromUserInput(url);
if (UrlRequiresConfirmation(parsedUrl) && !base::IsCtrlPressed()) { if (!AyuSettings::getInstance().disableOpenLinkWarning && UrlRequiresConfirmation(parsedUrl) && !base::IsCtrlPressed()) {
const auto my = context.value<ClickHandlerContext>(); const auto my = context.value<ClickHandlerContext>();
if (!my.show) { if (!my.show) {
Core::App().hideMediaView(); Core::App().hideMediaView();