mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-26 07:22:12 +00:00
Simplified installing of tooltip to some labels.
This commit is contained in:
@@ -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<Ui::RpWidget>(container),
|
||||
st::boxRowPadding);
|
||||
|
||||
const auto topLabel = Ui::CreateChild<TextWithTooltip>(
|
||||
const auto topLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||
row,
|
||||
topText,
|
||||
st::urlAuthBoxRowTopLabel);
|
||||
topLabel->setSelectable(true);
|
||||
topLabel->setTooltip(topText);
|
||||
const auto bottomLabel = Ui::CreateChild<TextWithTooltip>(
|
||||
Ui::InstallTooltip(topLabel, [=] {
|
||||
return (topLabel->textMaxWidth() > topLabel->width())
|
||||
? topText
|
||||
: QString();
|
||||
});
|
||||
const auto bottomLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||
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<Ui::FlatLabel>(
|
||||
row,
|
||||
leftText,
|
||||
|
||||
@@ -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<Ui::FlatLabel*> AddVersionLabel(
|
||||
not_null<Ui::RpWidget*> parent) {
|
||||
return (Platform::IsMacStoreBuild() || Platform::IsWindowsStoreBuild())
|
||||
? Ui::CreateChild<Ui::FlatLabel>(
|
||||
parent.get(),
|
||||
st::mainMenuVersionLabel)
|
||||
: Ui::CreateChild<VersionLabel>(
|
||||
parent.get(),
|
||||
st::mainMenuVersionLabel);
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
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<Ui::SettingsButton*> AddMyChannelsBox(
|
||||
|
||||
+1
-1
Submodule Telegram/lib_ui updated: bd3cd347ab...c397faa283
Reference in New Issue
Block a user