Removed three dots button from invite link label when menu is disabled.

This commit is contained in:
23rd 2023-10-16 20:45:34 +03:00 committed by John Preston
parent 1bbac5784b
commit 0aa1cd0b52
2 changed files with 39 additions and 25 deletions

View File

@ -758,7 +758,8 @@ topBarConnectingAnimation: InfiniteRadialAnimation(defaultInfiniteRadialAnimatio
size: size(8px, 8px); size: size(8px, 8px);
} }
inviteLinkFieldHeight: 44px; inviteLinkFieldRadius: 5px;
inviteLinkFieldHeight: 42px;
inviteLinkFieldMargin: margins(14px, 12px, 36px, 9px); inviteLinkFieldMargin: margins(14px, 12px, 36px, 9px);
inviteLinkThreeDotsIcon: icon {{ "info/edit/dotsmini", dialogsMenuIconFg }}; inviteLinkThreeDotsIcon: icon {{ "info/edit/dotsmini", dialogsMenuIconFg }};
inviteLinkThreeDotsIconOver: icon {{ "info/edit/dotsmini", dialogsMenuIconFgOver }}; inviteLinkThreeDotsIconOver: icon {{ "info/edit/dotsmini", dialogsMenuIconFgOver }};
@ -773,10 +774,14 @@ inviteLinkThreeDots: IconButton(defaultIconButton) {
rippleAreaSize: 0px; rippleAreaSize: 0px;
} }
inviteLinkFieldPadding: margins(22px, 7px, 22px, 14px); inviteLinkFieldPadding: margins(22px, 7px, 22px, 14px);
inviteLinkFieldLabel: FlatLabel(defaultFlatLabel) {
align: align(center);
}
inviteLinkButton: RoundButton(defaultActiveButton) { inviteLinkButton: RoundButton(defaultActiveButton) {
height: 36px; height: 36px;
textTop: 9px; textTop: 9px;
radius: 6px;
} }
inviteLinkButtonsPadding: margins(22px, 0px, 22px, 0px); inviteLinkButtonsPadding: margins(22px, 0px, 22px, 0px);
inviteLinkButtonsSkip: 10px; inviteLinkButtonsSkip: 10px;

View File

@ -25,19 +25,26 @@ InviteLinkLabel::InviteLinkLabel(
const auto label = CreateChild<FlatLabel>( const auto label = CreateChild<FlatLabel>(
_outer.get(), _outer.get(),
std::move(text), std::move(text),
st::defaultFlatLabel); createMenu ? st::defaultFlatLabel : st::inviteLinkFieldLabel);
label->setAttribute(Qt::WA_TransparentForMouseEvents); label->setAttribute(Qt::WA_TransparentForMouseEvents);
const auto button = CreateChild<IconButton>( const auto button = createMenu
_outer.get(), ? CreateChild<IconButton>(_outer.get(), st::inviteLinkThreeDots)
st::inviteLinkThreeDots); : (IconButton*)(nullptr);
_outer->widthValue( _outer->widthValue(
) | rpl::start_with_next([=](int width) { ) | rpl::start_with_next([=](int width) {
const auto margin = st::inviteLinkFieldMargin; const auto margin = st::inviteLinkFieldMargin;
label->resizeToWidth(width - margin.left() - margin.right()); const auto labelWidth = width - margin.left() - margin.right();
label->moveToLeft(margin.left(), margin.top()); label->resizeToWidth(labelWidth);
button->moveToRight(0, 0); label->moveToLeft(
createMenu
? margin.left()
: (width - labelWidth) / 2,
margin.top());
if (button) {
button->moveToRight(0, 0);
}
}, _outer->lifetime()); }, _outer->lifetime());
_outer->paintRequest( _outer->paintRequest(
@ -49,28 +56,30 @@ InviteLinkLabel::InviteLinkLabel(
PainterHighQualityEnabler hq(p); PainterHighQualityEnabler hq(p);
p.drawRoundedRect( p.drawRoundedRect(
_outer->rect(), _outer->rect(),
st::roundRadiusSmall, st::inviteLinkFieldRadius,
st::roundRadiusSmall); st::inviteLinkFieldRadius);
} }
}, _outer->lifetime()); }, _outer->lifetime());
_outer->setCursor(style::cur_pointer); _outer->setCursor(style::cur_pointer);
rpl::merge( if (createMenu) {
button->clicks() | rpl::to_empty, rpl::merge(
_outer->events( button->clicks() | rpl::to_empty,
) | rpl::filter([=](not_null<QEvent*> event) { _outer->events(
return (event->type() == QEvent::MouseButtonPress) ) | rpl::filter([=](not_null<QEvent*> event) {
&& (static_cast<QMouseEvent*>(event.get())->button() return (event->type() == QEvent::MouseButtonPress)
== Qt::RightButton); && (static_cast<QMouseEvent*>(event.get())->button()
}) | rpl::to_empty == Qt::RightButton);
) | rpl::start_with_next([=] { }) | rpl::to_empty
if (_menu) { ) | rpl::start_with_next([=] {
_menu = nullptr; if (_menu) {
} else if ((_menu = createMenu())) { _menu = nullptr;
_menu->popup(QCursor::pos()); } else if ((_menu = createMenu())) {
} _menu->popup(QCursor::pos());
}, _outer->lifetime()); }
}, _outer->lifetime());
}
} }
object_ptr<RpWidget> InviteLinkLabel::take() { object_ptr<RpWidget> InviteLinkLabel::take() {