From ae8de84828093eb10b07f867267f2cd5644906bc Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Tue, 7 Apr 2026 21:44:18 +0300 Subject: [PATCH] chore: redirect from experimental to settings --- Telegram/SourceFiles/ayu/ayu_settings.cpp | 10 +- Telegram/SourceFiles/ayu/ayu_settings.h | 10 +- .../ayu/ui/settings/settings_chats.cpp | 6 +- .../chat_helpers/stickers_list_widget.cpp | 1 - .../SourceFiles/chat_helpers/tabbed_panel.cpp | 5 +- .../SourceFiles/history/history_widget.cpp | 2 +- .../history_view_compose_controls.cpp | 2 +- .../info/profile/info_profile_actions.cpp | 18 +-- .../settings/settings_experimental.cpp | 124 ++++++++++++++---- .../SourceFiles/ui/chat/chat_style_radius.cpp | 1 - .../ui/controls/compose_ai_button_factory.cpp | 4 +- 11 files changed, 121 insertions(+), 62 deletions(-) diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index ade559d45a..8bdb28f86e 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -777,9 +777,9 @@ void AyuSettings::setShowAutoDeleteButtonInMessageField(bool val) { save(); } -void AyuSettings::setShowCocoonAiButtonInMessageField(bool val) { - if (_showCocoonAiButtonInMessageField.current() == val) return; - _showCocoonAiButtonInMessageField = val; +void AyuSettings::setShowAiEditorButtonInMessageField(bool val) { + if (_showAiEditorButtonInMessageField.current() == val) return; + _showAiEditorButtonInMessageField = val; save(); } @@ -1063,7 +1063,7 @@ void to_json(nlohmann::json &j, const AyuSettings &s) { {"showEmojiButtonInMessageField", s._showEmojiButtonInMessageField.current()}, {"showMicrophoneButtonInMessageField", s._showMicrophoneButtonInMessageField.current()}, {"showAutoDeleteButtonInMessageField", s._showAutoDeleteButtonInMessageField.current()}, - {"showCocoonAiButtonInMessageField", s._showCocoonAiButtonInMessageField.current()}, + {"showAiEditorButtonInMessageField", s._showAiEditorButtonInMessageField.current()}, {"showAttachPopup", s._showAttachPopup.current()}, {"showEmojiPopup", s._showEmojiPopup.current()}, {"showMyProfileInDrawer", s._showMyProfileInDrawer.current()}, @@ -1162,7 +1162,7 @@ void from_json(const nlohmann::json &j, AyuSettings &s) { s._showEmojiButtonInMessageField = j.value("showEmojiButtonInMessageField", defaults._showEmojiButtonInMessageField.current()); s._showMicrophoneButtonInMessageField = j.value("showMicrophoneButtonInMessageField", defaults._showMicrophoneButtonInMessageField.current()); s._showAutoDeleteButtonInMessageField = j.value("showAutoDeleteButtonInMessageField", defaults._showAutoDeleteButtonInMessageField.current()); - s._showCocoonAiButtonInMessageField = j.value("showCocoonAiButtonInMessageField", defaults._showCocoonAiButtonInMessageField.current()); + s._showAiEditorButtonInMessageField = j.value("showAiEditorButtonInMessageField", defaults._showAiEditorButtonInMessageField.current()); s._showAttachPopup = j.value("showAttachPopup", defaults._showAttachPopup.current()); s._showEmojiPopup = j.value("showEmojiPopup", defaults._showEmojiPopup.current()); s._showMyProfileInDrawer = j.value("showMyProfileInDrawer", defaults._showMyProfileInDrawer.current()); diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index 1e404cb8a5..e88e6faa4c 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -292,7 +292,7 @@ public: [[nodiscard]] bool showEmojiButtonInMessageField() const { return _showEmojiButtonInMessageField.current(); } [[nodiscard]] bool showMicrophoneButtonInMessageField() const { return _showMicrophoneButtonInMessageField.current(); } [[nodiscard]] bool showAutoDeleteButtonInMessageField() const { return _showAutoDeleteButtonInMessageField.current(); } - [[nodiscard]] bool showCocoonAiButtonInMessageField() const { return _showCocoonAiButtonInMessageField.current(); } + [[nodiscard]] bool showAiEditorButtonInMessageField() const { return _showAiEditorButtonInMessageField.current(); } [[nodiscard]] bool showAttachPopup() const { return _showAttachPopup.current(); } [[nodiscard]] bool showEmojiPopup() const { return _showEmojiPopup.current(); } [[nodiscard]] bool showMyProfileInDrawer() const { return _showMyProfileInDrawer.current(); } @@ -375,7 +375,7 @@ public: void setShowEmojiButtonInMessageField(bool val); void setShowMicrophoneButtonInMessageField(bool val); void setShowAutoDeleteButtonInMessageField(bool val); - void setShowCocoonAiButtonInMessageField(bool val); + void setShowAiEditorButtonInMessageField(bool val); void setShowAttachPopup(bool val); void setShowEmojiPopup(bool val); void setShowMyProfileInDrawer(bool val); @@ -506,8 +506,8 @@ public: [[nodiscard]] rpl::producer showMicrophoneButtonInMessageFieldChanges() const { return _showMicrophoneButtonInMessageField.changes(); } [[nodiscard]] rpl::producer showAutoDeleteButtonInMessageFieldValue() const { return _showAutoDeleteButtonInMessageField.value(); } [[nodiscard]] rpl::producer showAutoDeleteButtonInMessageFieldChanges() const { return _showAutoDeleteButtonInMessageField.changes(); } - [[nodiscard]] rpl::producer showCocoonAiButtonInMessageFieldValue() const { return _showCocoonAiButtonInMessageField.value(); } - [[nodiscard]] rpl::producer showCocoonAiButtonInMessageFieldChanges() const { return _showCocoonAiButtonInMessageField.changes(); } + [[nodiscard]] rpl::producer showAiEditorButtonInMessageFieldValue() const { return _showAiEditorButtonInMessageField.value(); } + [[nodiscard]] rpl::producer showAiEditorButtonInMessageFieldChanges() const { return _showAiEditorButtonInMessageField.changes(); } [[nodiscard]] rpl::producer showAttachPopupValue() const { return _showAttachPopup.value(); } [[nodiscard]] rpl::producer showAttachPopupChanges() const { return _showAttachPopup.changes(); } [[nodiscard]] rpl::producer showEmojiPopupValue() const { return _showEmojiPopup.value(); } @@ -633,7 +633,7 @@ private: rpl::variable _showEmojiButtonInMessageField = true; rpl::variable _showMicrophoneButtonInMessageField = true; rpl::variable _showAutoDeleteButtonInMessageField = true; - rpl::variable _showCocoonAiButtonInMessageField = true; + rpl::variable _showAiEditorButtonInMessageField = true; rpl::variable _showAttachPopup = true; rpl::variable _showEmojiPopup = true; rpl::variable _showMyProfileInDrawer = true; diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp index aa3f029134..fe8cc147f3 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp @@ -414,10 +414,10 @@ void BuildMessageFieldElements(SectionBuilder &builder, AyuSectionBuilder &ayu) .icon = { &st::messageFieldVoiceIcon }, }); ayu.addSettingToggle({ - .id = u"ayu/showCocoonAiButtonInMessageField"_q, + .id = u"ayu/showAiEditorButtonInMessageField"_q, .title = tr::lng_ai_compose_title(), - .getter = &AyuSettings::showCocoonAiButtonInMessageField, - .setter = &AyuSettings::setShowCocoonAiButtonInMessageField, + .getter = &AyuSettings::showAiEditorButtonInMessageField, + .setter = &AyuSettings::setShowAiEditorButtonInMessageField, .icon = { &st::messageFieldCocoonAiIcon }, }); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index e70bf3ec7e..6a9e2b7ff3 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -81,7 +81,6 @@ base::options::toggle OptionUnlimitedRecentStickers({ .id = kOptionUnlimitedRecentStickers, .name = "Unlimited recent stickers", .description = "Display as much recent stickers as the server provides", - .scope = static_cast(0) }); [[nodiscard]] bool SetInMyList(Data::StickersSetFlags flags) { diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp index 890a93dce9..8f9cc10a20 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp @@ -30,7 +30,6 @@ base::options::toggle TabbedPanelShowOnClick({ .id = kOptionTabbedPanelShowOnClick, .name = "Show tabbed panel by click", .description = "Show Emoji / Stickers / GIFs panel only after a click.", - .scope = static_cast(0), }); } // namespace @@ -38,7 +37,7 @@ base::options::toggle TabbedPanelShowOnClick({ const char kOptionTabbedPanelShowOnClick[] = "tabbed-panel-show-on-click"; bool ShowPanelOnClick() { - return TabbedPanelShowOnClick.value(); + return !AyuSettings::getInstance().showEmojiPopup(); } TabbedPanel::TabbedPanel( @@ -487,7 +486,7 @@ void TabbedPanel::showStarted() { bool TabbedPanel::eventFilter(QObject *obj, QEvent *e) { const auto &settings = AyuSettings::getInstance(); - if (TabbedPanelShowOnClick.value() || !settings.showEmojiPopup()) { + if (!settings.showEmojiPopup()) { return false; } else if (e->type() == QEvent::Enter) { otherEnter(); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 27188a8a4e..959853f423 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -833,7 +833,7 @@ HistoryWidget::HistoryWidget( AyuSettings::getInstance().showEmojiButtonInMessageFieldChanges() | rpl::to_empty, AyuSettings::getInstance().showMicrophoneButtonInMessageFieldChanges() | rpl::to_empty, AyuSettings::getInstance().showAutoDeleteButtonInMessageFieldChanges() | rpl::to_empty, - AyuSettings::getInstance().showCocoonAiButtonInMessageFieldChanges() | rpl::to_empty, + AyuSettings::getInstance().showAiEditorButtonInMessageFieldChanges() | rpl::to_empty, AyuSettings::getInstance().showAttachPopupChanges() | rpl::to_empty, AyuSettings::getInstance().showEmojiPopupChanges() | rpl::to_empty, AyuSettings::getInstance().channelBottomButtonChanges() | rpl::to_empty, diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 0ac4b8701f..c480ed7cf5 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -2239,7 +2239,7 @@ void ComposeControls::init() { AyuSettings::getInstance().showEmojiButtonInMessageFieldChanges() | rpl::to_empty, AyuSettings::getInstance().showMicrophoneButtonInMessageFieldChanges() | rpl::to_empty, AyuSettings::getInstance().showAutoDeleteButtonInMessageFieldChanges() | rpl::to_empty, - AyuSettings::getInstance().showCocoonAiButtonInMessageFieldChanges() | rpl::to_empty, + AyuSettings::getInstance().showAiEditorButtonInMessageFieldChanges() | rpl::to_empty, AyuSettings::getInstance().showAttachPopupChanges() | rpl::to_empty, AyuSettings::getInstance().showEmojiPopupChanges() | rpl::to_empty, AyuSettings::getInstance().channelBottomButtonChanges() | rpl::to_empty, diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 6b8d362a4f..b837db2b3a 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -127,7 +127,6 @@ base::options::toggle ShowPeerIdBelowAbout({ .name = "Show Peer IDs in Profile", .description = "Show peer IDs from API below their Bio / Description." " Add contact IDs to exported data.", - .scope = static_cast(0), }); base::options::toggle ShowChannelJoinedBelowAbout({ @@ -222,26 +221,11 @@ base::options::toggle ShowChannelJoinedBelowAbout({ return AboutValue( peer ) | rpl::map([=](TextWithEntities &&value) { - if (ShowPeerIdBelowAbout.value()) { - using namespace Ui::Text; - if (!value.empty()) { - value.append("\n\n"); - } - value.append(Italic(u"id: "_q)); - const auto raw = peer->id.value & PeerId::kChatTypeMask; - value.append(Link( - Italic(Lang::FormatCountDecimal(raw)), - "internal:~peer_id~:copy:" + QString::number(raw))); - } if (ShowChannelJoinedBelowAbout.value()) { if (const auto channel = peer->asChannel()) { if (!channel->amCreator() && channel->inviteDate) { if (!value.empty()) { - if (ShowPeerIdBelowAbout.value()) { - value.append("\n"); - } else { - value.append("\n\n"); - } + value.append("\n\n"); } using namespace Ui::Text; value.append((channel->isMegagroup() diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index 3429d19c2c..ba82218237 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -50,6 +50,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +// AyuGram includes +#include "ayu/ui/settings/settings_main.h" +#include "settings/settings_builder.h" + + namespace Settings { namespace { @@ -60,6 +65,11 @@ struct DecodeOptionsResult { QString json; }; +struct ResolvedReferrer { + QString controlId; + Type section = AyuMain::Id(); +}; + [[nodiscard]] QString EncodeOptionsToText(const QString &json) { const auto flags = QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals; @@ -96,8 +106,52 @@ struct DecodeOptionsResult { return result; } +[[nodiscard]] ResolvedReferrer ResolveReferrer( + const QString &controlId, + not_null session) { + const auto ®istry = Builder::SearchRegistry::Instance(); + const auto entries = registry.collectAll(session); + for (const auto &entry : entries) { + if (!entry.section) { + continue; + } + if (entry.id == controlId) { + return { + .controlId = entry.id, + .section = entry.section, + }; + } + if (entry.altIds.contains(controlId)) { + return { + .controlId = entry.id, + .section = entry.section, + }; + } + } + return { + .controlId = controlId, + }; +} + +[[nodiscard]] QString OptionReferrer(const base::options::option &option) { + const auto &id = option.id(); + if (id == u"tabbed-panel-show-on-click"_q) { + return u"ayu/showEmojiPopup"_q; + } else if (id == u"show-peer-id-below-about"_q) { + return u"ayu/showPeerId"_q; + } else if (id == u"use-small-msg-bubble-radius"_q) { + return u"ayu/messageBubbleRadius"_q; + } else if (id == u"unlimited-recent-stickers"_q) { + return u"ayu/recentStickersCount"_q; + } else if (id == u"hide-ai-button"_q) { + return u"ayu/showAiEditorButtonInMessageField"_q; + } + return QString(); +} + void AddOption( not_null window, + not_null controller, not_null container, base::options::option &option, rpl::producer<> resetClicks, @@ -114,15 +168,34 @@ void AddOption( toggles->fire_copy(option.value()); }, lifetime); - const auto button = container->add(object_ptr