Replaced empty settings button with simple ripple button.

This commit is contained in:
23rd 2024-10-20 05:33:23 +03:00
parent 6787ea883e
commit cd041e8366

View file

@ -165,43 +165,42 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
st->photoSize = st::defaultPeerListItem.photoSize; st->photoSize = st::defaultPeerListItem.photoSize;
st->size = QSize(st->photoSize, st->photoSize); st->size = QSize(st->photoSize, st->photoSize);
class Button final : public Ui::SettingsButton { const auto megagroupMark = u"[s] "_q;
public: const auto add = [&](
using Ui::SettingsButton::SettingsButton; not_null<PeerData*> peer,
not_null<Ui::VerticalLayout*> container) {
void setPeer(not_null<PeerData*> p) { const auto row = container->add(
const auto c = p->asChannel(); object_ptr<Ui::AbstractButton>::fromRaw(
const auto g = p->asChat(); Ui::CreateSimpleSettingsButton(
_text.setText( container,
st::defaultPeerListItem.nameStyle, st::defaultRippleAnimation,
((c && c->isMegagroup()) ? u"[s] "_q : QString()) st::defaultSettingsButton.textBgOver)));
+ p->name()); row->resize(row->width(), st::defaultPeerListItem.height);
const auto count = c ? c->membersCount() : g->count; const auto c = peer->asChannel();
_status.setText( const auto g = peer->asChat();
st::defaultTextStyle, const auto count = c ? c->membersCount() : g->count;
(g && !g->amIn()) const auto text = std::make_shared<Ui::Text::String>(
? tr::lng_chat_status_unaccessible(tr::now) st::defaultPeerListItem.nameStyle,
: !p->username().isEmpty() ((c && c->isMegagroup()) ? megagroupMark : QString())
? ('@' + p->username()) + peer->name());
: (count > 0) const auto status = std::make_shared<Ui::Text::String>(
? ((c && !c->isMegagroup()) st::defaultTextStyle,
? tr::lng_chat_status_subscribers (g && !g->amIn())
: tr::lng_chat_status_members)( ? tr::lng_chat_status_unaccessible(tr::now)
tr::now, : !peer->username().isEmpty()
lt_count, ? ('@' + peer->username())
count) : (count > 0)
: QString()); ? ((c && !c->isMegagroup())
} ? tr::lng_chat_status_subscribers
: tr::lng_chat_status_members)(
int resizeGetHeight(int) override { tr::now,
return st::defaultPeerListItem.height; lt_count,
} count)
: QString());
void paintEvent(QPaintEvent *e) override { row->paintRequest() | rpl::start_with_next([=] {
Ui::SettingsButton::paintEvent(e); auto p = QPainter(row);
auto p = Painter(this);
const auto &st = st::defaultPeerListItem; const auto &st = st::defaultPeerListItem;
const auto availableWidth = width() const auto availableWidth = row->width()
- st::boxRowPadding.right() - st::boxRowPadding.right()
- st.namePosition.x(); - st.namePosition.x();
p.setPen(st.nameFg); p.setPen(st.nameFg);
@ -211,24 +210,11 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
.availableWidth = availableWidth, .availableWidth = availableWidth,
.elisionLines = 1, .elisionLines = 1,
}; };
_text.draw(p, context); text->draw(p, context);
p.setPen(st.statusFg); p.setPen(st.statusFg);
context.position = st.statusPosition; context.position = st.statusPosition;
_status.draw(p, context); status->draw(p, context);
} }, row->lifetime());
private:
Ui::Text::String _text;
Ui::Text::String _status;
};
const auto add = [&](
not_null<PeerData*> peer,
not_null<Ui::VerticalLayout*> container) {
const auto row = container->add(
object_ptr<Button>(container, rpl::single(QString())));
row->setPeer(peer);
row->setClickedCallback([=] { row->setClickedCallback([=] {
controller->showPeerHistory(peer); controller->showPeerHistory(peer);
}); });