diff --git a/Telegram/SourceFiles/boxes/url_auth_box_content.cpp b/Telegram/SourceFiles/boxes/url_auth_box_content.cpp index 92bb13987e..27b9958fe4 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box_content.cpp +++ b/Telegram/SourceFiles/boxes/url_auth_box_content.cpp @@ -26,48 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace UrlAuthBox { namespace { -class TextWithTooltip final - : public Ui::FlatLabel - , public Ui::AbstractTooltipShower { -public: - using Ui::FlatLabel::FlatLabel; - - void setTooltip(QString text) { - _tooltip = std::move(text); - } - - QString tooltipText() const override { - return _tooltip; - } - - QPoint tooltipPos() const override { - return QCursor::pos(); - } - - bool tooltipWindowActive() const override { - return Ui::AppInFocus() - && Ui::InFocusChain(window()) - && textMaxWidth() > width(); - } - -private: - void mouseMoveEvent(QMouseEvent *e) override { - Ui::Tooltip::Show(1000, this); - Ui::FlatLabel::mouseMoveEvent(e); - } - void enterEventHook(QEnterEvent *e) override { - Ui::Tooltip::Show(1000, this); - Ui::FlatLabel::enterEventHook(e); - } - void leaveEventHook(QEvent *e) override { - Ui::Tooltip::Hide(); - Ui::FlatLabel::leaveEventHook(e); - } - - QString _tooltip; - -}; - } // namespace SwitchableUserpicButton::SwitchableUserpicButton( @@ -144,18 +102,26 @@ void AddAuthInfoRow( object_ptr(container), st::boxRowPadding); - const auto topLabel = Ui::CreateChild( + const auto topLabel = Ui::CreateChild( row, topText, st::urlAuthBoxRowTopLabel); topLabel->setSelectable(true); - topLabel->setTooltip(topText); - const auto bottomLabel = Ui::CreateChild( + Ui::InstallTooltip(topLabel, [=] { + return (topLabel->textMaxWidth() > topLabel->width()) + ? topText + : QString(); + }); + const auto bottomLabel = Ui::CreateChild( row, bottomText, st::urlAuthBoxRowBottomLabel); bottomLabel->setSelectable(true); - bottomLabel->setTooltip(bottomText); + Ui::InstallTooltip(bottomLabel, [=] { + return (bottomLabel->textMaxWidth() > bottomLabel->width()) + ? bottomText + : QString(); + }); const auto leftLabel = Ui::CreateChild( row, leftText, diff --git a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp index dec2126b2c..fc211c2f64 100644 --- a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp +++ b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp @@ -37,50 +37,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_window.h" namespace Window { -namespace { - -class VersionLabel final - : public Ui::FlatLabel - , public Ui::AbstractTooltipShower { -public: - using Ui::FlatLabel::FlatLabel; - - void clickHandlerActiveChanged( - const ClickHandlerPtr &action, - bool active) override { - update(); - if (active && action && !action->dragText().isEmpty()) { - Ui::Tooltip::Show(1000, this); - } else { - Ui::Tooltip::Hide(); - } - } - - QString tooltipText() const override { - return u"Build date: %1."_q.arg(__DATE__); - } - - QPoint tooltipPos() const override { - return QCursor::pos(); - } - - bool tooltipWindowActive() const override { - return Ui::AppInFocus() && Ui::InFocusChain(window()); - } - -}; - -} // namespace [[nodiscard]] not_null AddVersionLabel( not_null parent) { - return (Platform::IsMacStoreBuild() || Platform::IsWindowsStoreBuild()) - ? Ui::CreateChild( - parent.get(), - st::mainMenuVersionLabel) - : Ui::CreateChild( - parent.get(), - st::mainMenuVersionLabel); + const auto label = Ui::CreateChild( + parent.get(), + st::mainMenuVersionLabel); + if constexpr (Platform::IsMacStoreBuild() + || Platform::IsWindowsStoreBuild()) { + Ui::InstallTooltip(label, [] { + return u"Build date: %1."_q.arg(__DATE__); + }); + } + return label; } not_null AddMyChannelsBox( diff --git a/Telegram/lib_ui b/Telegram/lib_ui index bd3cd347ab..c397faa283 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit bd3cd347abec5188f5fac591e9b0567b5cb305c4 +Subproject commit c397faa283756a3c8e0e8f46840f654f526ade6a