2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Add monoforum sender bar divider.

This commit is contained in:
John Preston
2025-05-12 12:41:00 +04:00
parent c6d43a802c
commit 43b4499125
27 changed files with 388 additions and 90 deletions

View File

@@ -427,10 +427,12 @@ QImage *PeerData::userpicCloudImage(Ui::PeerUserpicView &view) const {
void PeerData::paintUserpic(
Painter &p,
Ui::PeerUserpicView &view,
int x,
int y,
int size,
bool forceCircle) const {
const PaintUserpicContext &context) const {
if (const auto broadcast = monoforumBroadcast()) {
broadcast->paintUserpic(p, view, context);
return;
}
const auto size = context.size;
const auto cloud = userpicCloudImage(view);
const auto ratio = style::DevicePixelRatio();
Ui::ValidateUserpicCache(
@@ -438,8 +440,8 @@ void PeerData::paintUserpic(
cloud,
cloud ? nullptr : ensureEmptyUserpic().get(),
size * ratio,
!forceCircle && (isForum() || isMonoforum()));
p.drawImage(QRect(x, y, size, size), view.cached);
context.forumLayout);
p.drawImage(QRect(context.position, QSize(size, size)), view.cached);
}
void PeerData::loadUserpic() {
@@ -1118,6 +1120,16 @@ const ChannelData *PeerData::asChannelOrMigrated() const {
return migrateTo();
}
ChannelData *PeerData::asMonoforum() {
const auto channel = asMegagroup();
return (channel && channel->isMonoforum()) ? channel : nullptr;
}
const ChannelData *PeerData::asMonoforum() const {
const auto channel = asMegagroup();
return (channel && channel->isMonoforum()) ? channel : nullptr;
}
ChatData *PeerData::migrateFrom() const {
if (const auto megagroup = asMegagroup()) {
return megagroup->amIn()
@@ -1150,6 +1162,16 @@ not_null<const PeerData*> PeerData::migrateToOrMe() const {
return this;
}
ChannelData *PeerData::monoforumBroadcast() const {
const auto monoforum = asMonoforum();
return monoforum ? monoforum->monoforumLink() : nullptr;
}
ChannelData *PeerData::broadcastMonoforum() const {
const auto broadcast = asBroadcast();
return broadcast ? broadcast->monoforumLink() : nullptr;
}
const QString &PeerData::topBarNameText() const {
if (const auto to = migrateTo()) {
return to->topBarNameText();
@@ -1572,12 +1594,21 @@ bool PeerData::canManageGroupCall() const {
return chat->amCreator()
|| (chat->adminRights() & ChatAdminRight::ManageCall);
} else if (const auto group = asChannel()) {
if (group->isMonoforum()) {
return false;
}
return group->amCreator()
|| (group->adminRights() & ChatAdminRight::ManageCall);
}
return false;
}
bool PeerData::amMonoforumAdmin() const {
const auto broadcast = monoforumBroadcast();
return broadcast
&& (broadcast->amCreator() || broadcast->hasAdminRights());
}
int PeerData::starsPerMessage() const {
if (const auto user = asUser()) {
return user->starsPerMessage();