From d1f4463c2a5dbe00eefc79d0bd611aa05afe2684 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 14 Jan 2024 17:53:34 +0300 Subject: [PATCH] Added simple tooltip to ttl button from voice record bar. --- Telegram/Resources/langs/lang.strings | 1 + .../chat_helpers/chat_helpers.style | 6 +++ .../history_view_voice_record_bar.cpp | 45 +++++++++++++++++++ Telegram/lib_ui | 2 +- 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 8c1560cd1..1bbb82bd5 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2492,6 +2492,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_record_listen_cancel_sure" = "Are you sure you want to discard your recorded voice message?"; "lng_record_lock_discard" = "Discard"; "lng_record_hold_tip" = "Please hold the mouse button pressed to record a voice message."; +"lng_record_once_active_tooltip" = "The recipients will be able to listen to it only once."; "lng_will_be_notified" = "Members will be notified when you post"; "lng_wont_be_notified" = "Members will not be notified when you post"; "lng_willbe_history" = "Please select a chat to start messaging"; diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index 2ad067367..99f6f9900 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -1130,6 +1130,12 @@ historyRecordLockPosition: point(1px, 22px); historyRecordCancelButtonWidth: 100px; historyRecordCancelButtonFg: lightButtonFg; +historyRecordTooltip: ImportantTooltip(defaultImportantTooltip) { + padding: margins(4px, 4px, 4px, 4px); + radius: 11px; + arrow: 6px; +} + historySilentToggle: IconButton(historyBotKeyboardShow) { icon: icon {{ "chat/input_silent", historyComposeIconFg }}; iconOver: icon {{ "chat/input_silent", historyComposeIconFgOver }}; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index 093e26bd9..bc80a899a 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -31,7 +31,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/animation_value.h" #include "ui/effects/ripple_animation.h" #include "ui/text/format_values.h" +#include "ui/text/text_utilities.h" #include "ui/painter.h" +#include "ui/widgets/tooltip.h" #include "ui/rect.h" #include "styles/style_chat.h" #include "styles/style_chat_helpers.h" @@ -304,6 +306,49 @@ TTLButton::TTLButton( st::historyRecordVoiceShowDuration); }); + { + const auto tooltip = Ui::CreateChild( + parent.get(), + object_ptr>( + parent.get(), + Ui::MakeNiceTooltipLabel( + parent, + tr::lng_record_once_active_tooltip( + Ui::Text::RichLangValue), + st::historyMessagesTTLLabel.minWidth, + st::ttlMediaImportantTooltipLabel), + st::defaultImportantTooltip.padding), + st::historyRecordTooltip); + geometryValue( + ) | rpl::start_with_next([=](const QRect &r) { + if (r.isEmpty()) { + return; + } + tooltip->pointAt(r, RectPart::Right, [=](QSize size) { + return QPoint( + r.left() + - size.width() + - st::defaultImportantTooltip.padding.left(), + r.top() + + r.height() + - size.height() + + st::historyRecordTooltip.padding.top()); + }); + }, tooltip->lifetime()); + tooltip->show(); + + clicks( + ) | rpl::start_with_next([=] { + const auto toggled = !Ui::AbstractButton::isDisabled(); + tooltip->toggleAnimated(toggled); + + if (toggled) { + constexpr auto kTimeout = crl::time(3000); + tooltip->hideAfter(kTimeout); + } + }, tooltip->lifetime()); + } + paintRequest( ) | rpl::start_with_next([=](const QRect &clip) { auto p = QPainter(this); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index aa39793a9..08a19be80 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit aa39793a91f1186879c15c214a2671d78eab5085 +Subproject commit 08a19be802cef8ee801121906c5f0ce9d2fa65b0