Open link without warning

This commit is contained in:
People-11 2025-06-29 17:17:51 +09:30
parent 2250fe75c4
commit 08a6b77bb1
5 changed files with 33 additions and 1 deletions

View file

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

View file

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

View file

@ -67,6 +67,7 @@ public:
bool showOnlyAddedEmojisAndStickers;
bool collapseSimilarChannels;
bool hideSimilarChannels;
bool disableOpenLinkWarning;
double wideMultiplier;
@ -149,6 +150,7 @@ void set_disableCustomBackgrounds(bool val);
void set_showOnlyAddedEmojisAndStickers(bool val);
void set_collapseSimilarChannels(bool val);
void set_hideSimilarChannels(bool val);
void set_disableOpenLinkWarning(bool val);
void set_wideMultiplier(double val);
@ -224,6 +226,7 @@ inline void to_json(nlohmann::json &nlohmann_json_j, const AyuGramSettings &nloh
NLOHMANN_JSON_TO(showOnlyAddedEmojisAndStickers)
NLOHMANN_JSON_TO(collapseSimilarChannels)
NLOHMANN_JSON_TO(hideSimilarChannels)
NLOHMANN_JSON_TO(disableOpenLinkWarning)
NLOHMANN_JSON_TO(wideMultiplier)
NLOHMANN_JSON_TO(spoofWebviewAsAndroid)
NLOHMANN_JSON_TO(increaseWebviewHeight)
@ -287,6 +290,7 @@ inline void from_json(const nlohmann::json &nlohmann_json_j, AyuGramSettings &nl
NLOHMANN_JSON_FROM_WITH_DEFAULT(showOnlyAddedEmojisAndStickers)
NLOHMANN_JSON_FROM_WITH_DEFAULT(collapseSimilarChannels)
NLOHMANN_JSON_FROM_WITH_DEFAULT(hideSimilarChannels)
NLOHMANN_JSON_FROM_WITH_DEFAULT(disableOpenLinkWarning)
NLOHMANN_JSON_FROM_WITH_DEFAULT(wideMultiplier)
NLOHMANN_JSON_FROM_WITH_DEFAULT(spoofWebviewAsAndroid)
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);
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);
AddDivider(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_layers.h"
// AyuGram includes
#include "ayu/ayu_settings.h"
namespace {
// 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)
? QUrl(url)
: QUrl::fromUserInput(url);
if (UrlRequiresConfirmation(parsedUrl) && !base::IsCtrlPressed()) {
if (!AyuSettings::getInstance().disableOpenLinkWarning && UrlRequiresConfirmation(parsedUrl) && !base::IsCtrlPressed()) {
const auto my = context.value<ClickHandlerContext>();
if (!my.show) {
Core::App().hideMediaView();