From da5435d1cbe7b64d893f3b597847775f79aaac55 Mon Sep 17 00:00:00 2001
From: 23rd <23rd@vivaldi.net>
Date: Fri, 17 Oct 2025 13:27:21 +0300
Subject: [PATCH] Added leave button to action buttons in profile top bar.
---
Telegram/Resources/icons/profile/leave.svg | 3 +++
Telegram/Resources/langs/lang.strings | 1 +
Telegram/SourceFiles/info/info.style | 1 +
.../info/profile/info_profile_top_bar.cpp | 16 ++++++++++++++++
4 files changed, 21 insertions(+)
create mode 100644 Telegram/Resources/icons/profile/leave.svg
diff --git a/Telegram/Resources/icons/profile/leave.svg b/Telegram/Resources/icons/profile/leave.svg
new file mode 100644
index 0000000000..a91a104440
--- /dev/null
+++ b/Telegram/Resources/icons/profile/leave.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings
index 426066ae33..f98913bf9c 100644
--- a/Telegram/Resources/langs/lang.strings
+++ b/Telegram/Resources/langs/lang.strings
@@ -1678,6 +1678,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_profile_action_short_gift" = "Gift";
"lng_profile_action_short_join" = "Join";
"lng_profile_action_short_report" = "Report";
+"lng_profile_action_short_leave" = "Leave";
"lng_media_type_photos" = "Photos";
"lng_media_type_gifs" = "GIFs";
diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style
index f7159fe1c6..be41fccfa6 100644
--- a/Telegram/SourceFiles/info/info.style
+++ b/Telegram/SourceFiles/info/info.style
@@ -418,6 +418,7 @@ infoProfileTopBarActionCall: icon{{ "profile/call-22x22", premiumButtonFg }};
infoProfileTopBarActionGift: icon{{ "profile/gift-22x22", premiumButtonFg }};
infoProfileTopBarActionJoin: icon{{ "profile/join-22x22", premiumButtonFg }};
infoProfileTopBarActionReport: icon{{ "profile/report-22x22", premiumButtonFg }};
+infoProfileTopBarActionLeave: icon{{ "profile/leave-22x22", premiumButtonFg }};
infoMinimalWidth: 324px;
infoDesiredWidth: 392px;
diff --git a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp
index b268183c06..24e1de49c4 100644
--- a/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp
+++ b/Telegram/SourceFiles/info/profile/info_profile_top_bar.cpp
@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/timer_rpl.h"
#include "base/timer.h"
#include "base/unixtime.h"
+#include "boxes/moderate_messages_box.h"
#include "boxes/report_messages_box.h"
#include "boxes/star_gift_box.h"
#include "calls/calls_instance.h"
@@ -386,6 +387,7 @@ void TopBar::setupActions(not_null controller) {
const auto channel = peer->asChannel();
const auto chat = peer->asChat();
const auto topic = controller->key().topic();
+ const auto sublist = controller->key().sublist();
const auto mapped = [=](std::optional c) {
return !c
? anim::with_alpha(
@@ -567,6 +569,20 @@ void TopBar::setupActions(not_null controller) {
_actions->add(reportButton);
buttons.push_back(reportButton);
}
+ if (!topic && !sublist && channel && channel->amIn()) {
+ const auto navigation = controller->parentController();
+ const auto leaveButton = Ui::CreateChild(
+ this,
+ tr::lng_profile_action_short_leave(tr::now),
+ st::infoProfileTopBarActionLeave);
+ leaveButton->setClickedCallback([=] {
+ if (!navigation->showFrozenError()) {
+ navigation->show(Box(DeleteChatBox, peer));
+ }
+ });
+ _actions->add(leaveButton);
+ buttons.push_back(leaveButton);
+ }
_edgeColor.value() | rpl::map(mapped) | rpl::start_with_next([=](
QColor c) {
for (const auto &button : buttons) {