From a1a078f9982ec6a42ad5b5de078cf8cbdf4f7ce5 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 3 Apr 2026 16:24:38 +0300 Subject: [PATCH] Improved style of connection box with table-style. --- Telegram/Resources/langs/lang.strings | 5 + Telegram/SourceFiles/boxes/boxes.style | 36 ++++++++ Telegram/SourceFiles/boxes/connection_box.cpp | 92 +++++++++++++------ 3 files changed, 103 insertions(+), 30 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index a666ccb80a..1f9f61d5f4 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -324,6 +324,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_sure_enable_socks" = "Are you sure you want to enable this proxy?\n\nServer: {server}\nPort: {port}\n\nYou can change your proxy server later in Settings > Advanced > Connection Type."; "lng_sure_enable" = "Enable"; "lng_proxy_box_title" = "Enable proxy"; +"lng_proxy_box_table_title" = "Proxy Server"; +"lng_proxy_box_table_button" = "Connect Proxy"; +"lng_proxy_box_table_checking" = "Checking…"; +"lng_proxy_box_table_available" = "Available (ping: {ping} ms)"; +"lng_proxy_box_table_unavailable" = "Not Available"; "lng_proxy_box_server" = "Server"; "lng_proxy_box_port" = "Port"; "lng_proxy_box_secret" = "Secret"; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 23e34ce706..4fd2e656c8 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -669,6 +669,42 @@ proxyAboutSponsorPadding: margins(22px, 7px, 22px, 0px); proxyApplyBoxLabel : FlatLabel(defaultFlatLabel) { maxHeight: 30px; } +proxyApplyBoxTable: Table(defaultTable) { + labelMinWidth: 91px; +} +proxyApplyBoxTableMargin: margins(24px, 4px, 24px, 4px); +proxyApplyBoxTableLabelMargin: margins(13px, 10px, 13px, 10px); +proxyApplyBoxTableValueMargin: margins(13px, 9px, 13px, 9px); +proxyApplyBoxValueMultiline: FlatLabel(defaultTableValue) { + minWidth: 128px; + maxHeight: 100px; + style: TextStyle(defaultTextStyle) { + font: font(10px); + linkUnderline: kLinkUnderlineNever; + } +} +proxyApplyBoxSponsorLabel: FlatLabel(defaultFlatLabel) { + textFg: windowBoldFg; + minWidth: 100px; + align: align(top); + style: TextStyle(defaultTextStyle) { + font: font(11px); + } +} +proxyApplyBoxSponsorMargin: margins(13px, 8px, 13px, 8px); +proxyApplyBoxButton: RoundButton(defaultActiveButton) { + height: 38px; + textTop: 10px; + radius: 19px; + style: semiboldTextStyle; +} +proxyApplyBox: Box(defaultBox) { + buttonPadding: margins(22px, 11px, 22px, 22px); + buttonHeight: 38px; + buttonWide: true; + button: proxyApplyBoxButton; + shadowIgnoreTopSkip: true; +} markdownLinkFieldPadding: margins(22px, 0px, 22px, 10px); diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index b687c074e7..757586b04c 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -38,7 +38,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/menu/menu_add_action_callback.h" #include "ui/widgets/menu/menu_add_action_callback_factory.h" #include "ui/widgets/popup_menu.h" +#include "ui/controls/table_rows.h" #include "ui/wrap/slide_wrap.h" +#include "ui/wrap/table_layout.h" #include "ui/wrap/vertical_layout.h" #include "ui/vertical_list.h" #include "ui/ui_utility.h" @@ -47,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_chat_helpers.h" +#include "styles/style_giveaway.h" #include "styles/style_info.h" #include "styles/style_menu_icons.h" #include "styles/style_settings.h" @@ -1417,44 +1420,73 @@ void ProxiesBoxController::ShowApplyConfirmation( ).replace(UrlEndRegExp, QString()); const auto box = [=](not_null box) { box->setTitle(tr::lng_proxy_box_title()); - if (type == Type::Mtproto) { - box->addRow(object_ptr( + box->setStyle(st::proxyApplyBox); + box->addTopButton(st::boxTitleClose, [=] { + box->closeBox(); + }); + + const auto table = box->addRow( + object_ptr( box, - tr::lng_proxy_sponsor_warning(), - st::boxDividerLabel)); - Ui::AddSkip(box->verticalLayout()); - Ui::AddSkip(box->verticalLayout()); - } - const auto &stL = st::proxyApplyBoxLabel; - const auto &stSubL = st::boxDividerLabel; - const auto add = [&](const QString &s, tr::phrase<> phrase) { - if (!s.isEmpty()) { - box->addRow(object_ptr(box, s, stL)); - box->addRow(object_ptr(box, phrase(), stSubL)); - Ui::AddSkip(box->verticalLayout()); - Ui::AddSkip(box->verticalLayout()); + st::giveawayGiftCodeTable), + st::giveawayGiftCodeTableMargin); + const auto add = [&]( + const QString &value, + rpl::producer label) { + if (!value.isEmpty()) { + constexpr auto kOneLineCount = 20; + const auto oneLine = value.length() <= kOneLineCount; + auto widget = object_ptr( + table, + rpl::single(Ui::Text::Wrapped( + { value }, + EntityType::Code, + {})), + (oneLine + ? table->st().defaultValue + : st::giveawayGiftCodeValueMultiline), + st::defaultPopupMenu); + Ui::AddTableRow( + table, + std::move(label), + std::move(widget)); } }; if (!displayServer.isEmpty()) { - add(displayServer, tr::lng_proxy_box_server); + add(displayServer, tr::lng_proxy_box_server()); } - add(QString::number(proxy.port), tr::lng_proxy_box_port); + add(QString::number(proxy.port), tr::lng_proxy_box_port()); if (type == Type::Socks5) { - add(proxy.user, tr::lng_proxy_box_username); - add(proxy.password, tr::lng_proxy_box_password); + add(proxy.user, tr::lng_proxy_box_username()); + add(proxy.password, tr::lng_proxy_box_password()); } else if (type == Type::Mtproto) { - add(proxy.password, tr::lng_proxy_box_secret); + add(proxy.password, tr::lng_proxy_box_secret()); } - const auto enableButton = box->addButton(tr::lng_sure_enable(), [=] { - auto &proxies = Core::App().settings().proxy().list(); - if (!ranges::contains(proxies, proxy)) { - proxies.push_back(proxy); - } - Core::App().setCurrentProxy(proxy, ProxyData::Settings::Enabled); - Local::writeSettings(); - box->closeBox(); - }); - box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); + + if (type == Type::Mtproto) { + table->addRow( + object_ptr( + table, + tr::lng_proxy_sponsor_warning(), + st::proxyApplyBoxSponsorLabel), + object_ptr(nullptr), + st::proxyApplyBoxSponsorMargin, + st::proxyApplyBoxSponsorMargin); + } + + const auto enableButton = box->addButton( + tr::lng_sure_enable(), + [=] { + auto &proxies = Core::App().settings().proxy().list(); + if (!ranges::contains(proxies, proxy)) { + proxies.push_back(proxy); + } + Core::App().setCurrentProxy( + proxy, + ProxyData::Settings::Enabled); + Local::writeSettings(); + box->closeBox(); + }); box->events( ) | rpl::on_next([=](not_null e) { if ((e->type() != QEvent::KeyPress) || !enableButton) {