mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Replaced empty settings button with simple ripple button.
This commit is contained in:
parent
6787ea883e
commit
cd041e8366
1 changed files with 38 additions and 52 deletions
|
@ -165,43 +165,42 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
|
|||
st->photoSize = st::defaultPeerListItem.photoSize;
|
||||
st->size = QSize(st->photoSize, st->photoSize);
|
||||
|
||||
class Button final : public Ui::SettingsButton {
|
||||
public:
|
||||
using Ui::SettingsButton::SettingsButton;
|
||||
|
||||
void setPeer(not_null<PeerData*> p) {
|
||||
const auto c = p->asChannel();
|
||||
const auto g = p->asChat();
|
||||
_text.setText(
|
||||
st::defaultPeerListItem.nameStyle,
|
||||
((c && c->isMegagroup()) ? u"[s] "_q : QString())
|
||||
+ p->name());
|
||||
const auto count = c ? c->membersCount() : g->count;
|
||||
_status.setText(
|
||||
st::defaultTextStyle,
|
||||
(g && !g->amIn())
|
||||
? tr::lng_chat_status_unaccessible(tr::now)
|
||||
: !p->username().isEmpty()
|
||||
? ('@' + p->username())
|
||||
: (count > 0)
|
||||
? ((c && !c->isMegagroup())
|
||||
? tr::lng_chat_status_subscribers
|
||||
: tr::lng_chat_status_members)(
|
||||
tr::now,
|
||||
lt_count,
|
||||
count)
|
||||
: QString());
|
||||
}
|
||||
|
||||
int resizeGetHeight(int) override {
|
||||
return st::defaultPeerListItem.height;
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *e) override {
|
||||
Ui::SettingsButton::paintEvent(e);
|
||||
auto p = Painter(this);
|
||||
const auto megagroupMark = u"[s] "_q;
|
||||
const auto add = [&](
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
const auto row = container->add(
|
||||
object_ptr<Ui::AbstractButton>::fromRaw(
|
||||
Ui::CreateSimpleSettingsButton(
|
||||
container,
|
||||
st::defaultRippleAnimation,
|
||||
st::defaultSettingsButton.textBgOver)));
|
||||
row->resize(row->width(), st::defaultPeerListItem.height);
|
||||
const auto c = peer->asChannel();
|
||||
const auto g = peer->asChat();
|
||||
const auto count = c ? c->membersCount() : g->count;
|
||||
const auto text = std::make_shared<Ui::Text::String>(
|
||||
st::defaultPeerListItem.nameStyle,
|
||||
((c && c->isMegagroup()) ? megagroupMark : QString())
|
||||
+ peer->name());
|
||||
const auto status = std::make_shared<Ui::Text::String>(
|
||||
st::defaultTextStyle,
|
||||
(g && !g->amIn())
|
||||
? tr::lng_chat_status_unaccessible(tr::now)
|
||||
: !peer->username().isEmpty()
|
||||
? ('@' + peer->username())
|
||||
: (count > 0)
|
||||
? ((c && !c->isMegagroup())
|
||||
? tr::lng_chat_status_subscribers
|
||||
: tr::lng_chat_status_members)(
|
||||
tr::now,
|
||||
lt_count,
|
||||
count)
|
||||
: QString());
|
||||
row->paintRequest() | rpl::start_with_next([=] {
|
||||
auto p = QPainter(row);
|
||||
const auto &st = st::defaultPeerListItem;
|
||||
const auto availableWidth = width()
|
||||
const auto availableWidth = row->width()
|
||||
- st::boxRowPadding.right()
|
||||
- st.namePosition.x();
|
||||
p.setPen(st.nameFg);
|
||||
|
@ -211,24 +210,11 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
|
|||
.availableWidth = availableWidth,
|
||||
.elisionLines = 1,
|
||||
};
|
||||
_text.draw(p, context);
|
||||
text->draw(p, context);
|
||||
p.setPen(st.statusFg);
|
||||
context.position = st.statusPosition;
|
||||
_status.draw(p, context);
|
||||
}
|
||||
|
||||
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);
|
||||
status->draw(p, context);
|
||||
}, row->lifetime());
|
||||
row->setClickedCallback([=] {
|
||||
controller->showPeerHistory(peer);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue