mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-25 15:03:03 +02:00
Show "Messages" badge for monoforum.
This commit is contained in:
parent
5943052cd1
commit
d7c964afc5
13 changed files with 85 additions and 33 deletions
|
@ -169,6 +169,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_group_status" = "group";
|
||||
"lng_scam_badge" = "SCAM";
|
||||
"lng_fake_badge" = "FAKE";
|
||||
"lng_direct_badge" = "MESSAGES";
|
||||
|
||||
"lng_remember" = "Remember this choice";
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class ChannelData;
|
|||
|
||||
namespace Info::Profile {
|
||||
class Badge;
|
||||
enum class BadgeType;
|
||||
enum class BadgeType : uchar;
|
||||
} // namespace Info::Profile
|
||||
|
||||
namespace Main {
|
||||
|
|
|
@ -810,6 +810,9 @@ int PeerListRow::paintNameIconGetWidth(
|
|||
? st::dialogsPremiumIcon.over
|
||||
: st::dialogsPremiumIcon.icon),
|
||||
.scam = &(selected ? st::dialogsScamFgOver : st::dialogsScamFg),
|
||||
.direct = &(selected
|
||||
? st::windowSubTextFgOver
|
||||
: st::windowSubTextFg),
|
||||
.premiumFg = &(selected
|
||||
? st::dialogsVerifiedIconBgOver
|
||||
: st::dialogsVerifiedIconBg),
|
||||
|
|
|
@ -1606,6 +1606,11 @@ void InnerWidget::paintPeerSearchResult(
|
|||
: context.selected
|
||||
? &st::dialogsScamFgOver
|
||||
: &st::dialogsScamFg),
|
||||
.direct = (context.active
|
||||
? &st::dialogsDraftFgActive
|
||||
: context.selected
|
||||
? &st::windowSubTextFgOver
|
||||
: &st::windowSubTextFg),
|
||||
.premiumFg = (context.active
|
||||
? &st::dialogsVerifiedIconBgActive
|
||||
: context.selected
|
||||
|
|
|
@ -750,6 +750,11 @@ void PaintRow(
|
|||
: context.selected
|
||||
? &st::dialogsScamFgOver
|
||||
: &st::dialogsScamFg),
|
||||
.direct = (context.active
|
||||
? &st::dialogsDraftFgActive
|
||||
: context.selected
|
||||
? &st::windowSubTextFgOver
|
||||
: &st::windowSubTextFg),
|
||||
.premiumFg = (context.active
|
||||
? &st::dialogsVerifiedIconBgActive
|
||||
: context.selected
|
||||
|
@ -923,7 +928,7 @@ const style::icon *ChatTypeIcon(
|
|||
st::dialogsChannelIcon,
|
||||
context.active,
|
||||
context.selected);
|
||||
} else if (peer->isForum() || peer->amMonoforumAdmin()) {
|
||||
} else if (peer->isForum()) {
|
||||
return &ThreeStateIcon(
|
||||
st::dialogsForumIcon,
|
||||
context.active,
|
||||
|
|
|
@ -2363,6 +2363,9 @@ bool History::chatListMessageKnown() const {
|
|||
}
|
||||
|
||||
const QString &History::chatListName() const {
|
||||
if (const auto broadcast = peer->monoforumBroadcast()) {
|
||||
return broadcast->name();
|
||||
}
|
||||
return peer->name();
|
||||
}
|
||||
|
||||
|
|
|
@ -604,6 +604,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
|||
.verified = &st::dialogsVerifiedIcon,
|
||||
.premium = &st::dialogsPremiumIcon.icon,
|
||||
.scam = &st::attentionButtonFg,
|
||||
.direct = &st::windowSubTextFg,
|
||||
.premiumFg = &st::dialogsVerifiedIconBg,
|
||||
.customEmojiRepaint = [=] { update(); },
|
||||
.now = now,
|
||||
|
|
|
@ -131,9 +131,14 @@ void Badge::setContent(Content content) {
|
|||
}, _view->lifetime());
|
||||
} break;
|
||||
case BadgeType::Scam:
|
||||
case BadgeType::Fake: {
|
||||
const auto fake = (_content.badge == BadgeType::Fake);
|
||||
const auto size = Ui::ScamBadgeSize(fake);
|
||||
case BadgeType::Fake:
|
||||
case BadgeType::Direct: {
|
||||
const auto type = (_content.badge == BadgeType::Direct)
|
||||
? Ui::TextBadgeType::Direct
|
||||
: (_content.badge == BadgeType::Fake)
|
||||
? Ui::TextBadgeType::Fake
|
||||
: Ui::TextBadgeType::Scam;
|
||||
const auto size = Ui::TextBadgeSize(type);
|
||||
const auto skip = st::infoVerifiedCheckPosition.x();
|
||||
_view->resize(
|
||||
size.width() + 2 * skip,
|
||||
|
@ -141,12 +146,14 @@ void Badge::setContent(Content content) {
|
|||
_view->paintRequest(
|
||||
) | rpl::start_with_next([=, badge = _view.data()]{
|
||||
Painter p(badge);
|
||||
Ui::DrawScamBadge(
|
||||
fake,
|
||||
Ui::DrawTextBadge(
|
||||
type,
|
||||
p,
|
||||
badge->rect().marginsRemoved({ skip, skip, skip, skip }),
|
||||
badge->width(),
|
||||
st::attentionButtonFg);
|
||||
(type == Ui::TextBadgeType::Direct
|
||||
? st::windowSubTextFg
|
||||
: st::attentionButtonFg));
|
||||
}, _view->lifetime());
|
||||
} break;
|
||||
}
|
||||
|
|
|
@ -35,13 +35,14 @@ namespace Info::Profile {
|
|||
|
||||
class EmojiStatusPanel;
|
||||
|
||||
enum class BadgeType {
|
||||
enum class BadgeType : uchar {
|
||||
None = 0x00,
|
||||
Verified = 0x01,
|
||||
BotVerified = 0x02,
|
||||
Premium = 0x04,
|
||||
Scam = 0x08,
|
||||
Fake = 0x10,
|
||||
Direct = 0x20,
|
||||
};
|
||||
inline constexpr bool is_flag_type(BadgeType) { return true; }
|
||||
|
||||
|
|
|
@ -93,6 +93,9 @@ void StripExternalLinks(TextWithEntities &text) {
|
|||
} // namespace
|
||||
|
||||
rpl::producer<QString> NameValue(not_null<PeerData*> peer) {
|
||||
if (const auto broadcast = peer->monoforumBroadcast()) {
|
||||
return NameValue(broadcast);
|
||||
}
|
||||
return peer->session().changes().peerFlagsValue(
|
||||
peer,
|
||||
UpdateFlag::Name
|
||||
|
@ -659,6 +662,8 @@ rpl::producer<BadgeType> BadgeValueFromFlags(Peer peer) {
|
|||
? BadgeType::Scam
|
||||
: (value & Flag::Fake)
|
||||
? BadgeType::Fake
|
||||
: peer->isMonoforum()
|
||||
? BadgeType::Direct
|
||||
: (value & Flag::Verified)
|
||||
? BadgeType::Verified
|
||||
: premium
|
||||
|
|
|
@ -130,7 +130,7 @@ struct LinkWithUrl {
|
|||
[[nodiscard]] rpl::producer<bool> CanViewParticipantsValue(
|
||||
not_null<ChannelData*> megagroup);
|
||||
|
||||
enum class BadgeType;
|
||||
enum class BadgeType : uchar;
|
||||
[[nodiscard]] rpl::producer<BadgeType> BadgeValue(not_null<PeerData*> peer);
|
||||
[[nodiscard]] rpl::producer<EmojiStatusId> EmojiStatusIdValue(
|
||||
not_null<PeerData*> peer);
|
||||
|
|
|
@ -71,10 +71,17 @@ void UnreadBadge::paintEvent(QPaintEvent *e) {
|
|||
unreadSt);
|
||||
}
|
||||
|
||||
QSize ScamBadgeSize(bool fake) {
|
||||
const auto phrase = fake
|
||||
? tr::lng_fake_badge(tr::now)
|
||||
: tr::lng_scam_badge(tr::now);
|
||||
QString TextBadgeText(TextBadgeType type) {
|
||||
switch (type) {
|
||||
case TextBadgeType::Fake: return tr::lng_fake_badge(tr::now);
|
||||
case TextBadgeType::Scam: return tr::lng_scam_badge(tr::now);
|
||||
case TextBadgeType::Direct: return tr::lng_direct_badge(tr::now);
|
||||
}
|
||||
Unexpected("Type in TextBadgeText.");
|
||||
}
|
||||
|
||||
QSize TextBadgeSize(TextBadgeType type) {
|
||||
const auto phrase = TextBadgeText(type);
|
||||
const auto phraseWidth = st::dialogsScamFont->width(phrase);
|
||||
const auto width = st::dialogsScamPadding.left()
|
||||
+ phraseWidth
|
||||
|
@ -85,7 +92,7 @@ QSize ScamBadgeSize(bool fake) {
|
|||
return { width, height };
|
||||
}
|
||||
|
||||
void DrawScamFakeBadge(
|
||||
void DrawTextBadge(
|
||||
Painter &p,
|
||||
QRect rect,
|
||||
int outerWidth,
|
||||
|
@ -107,16 +114,14 @@ void DrawScamFakeBadge(
|
|||
phraseWidth);
|
||||
}
|
||||
|
||||
void DrawScamBadge(
|
||||
bool fake,
|
||||
void DrawTextBadge(
|
||||
TextBadgeType type,
|
||||
Painter &p,
|
||||
QRect rect,
|
||||
int outerWidth,
|
||||
const style::color &color) {
|
||||
const auto phrase = fake
|
||||
? tr::lng_fake_badge(tr::now)
|
||||
: tr::lng_scam_badge(tr::now);
|
||||
DrawScamFakeBadge(
|
||||
const auto phrase = TextBadgeText(type);
|
||||
DrawTextBadge(
|
||||
p,
|
||||
rect,
|
||||
outerWidth,
|
||||
|
@ -133,8 +138,9 @@ int PeerBadge::drawGetWidth(Painter &p, Descriptor &&descriptor) {
|
|||
Expects(descriptor.customEmojiRepaint != nullptr);
|
||||
|
||||
const auto peer = descriptor.peer;
|
||||
if (descriptor.scam && (peer->isScam() || peer->isFake())) {
|
||||
return drawScamOrFake(p, descriptor);
|
||||
if ((descriptor.scam && (peer->isScam() || peer->isFake()))
|
||||
|| descriptor.direct && peer->isMonoforum()) {
|
||||
return drawTextBadge(p, descriptor);
|
||||
}
|
||||
const auto verifyCheck = descriptor.verified && peer->isVerified();
|
||||
const auto premiumMark = descriptor.premium
|
||||
|
@ -177,10 +183,16 @@ int PeerBadge::drawGetWidth(Painter &p, Descriptor &&descriptor) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int PeerBadge::drawScamOrFake(Painter &p, const Descriptor &descriptor) {
|
||||
const auto phrase = descriptor.peer->isScam()
|
||||
? tr::lng_scam_badge(tr::now)
|
||||
: tr::lng_fake_badge(tr::now);
|
||||
int PeerBadge::drawTextBadge(Painter &p, const Descriptor &descriptor) {
|
||||
const auto type = [&] {
|
||||
if (descriptor.peer->isScam()) {
|
||||
return TextBadgeType::Scam;
|
||||
} else if (descriptor.peer->isFake()) {
|
||||
return TextBadgeType::Fake;
|
||||
}
|
||||
return TextBadgeType::Direct;
|
||||
}();
|
||||
const auto phrase = TextBadgeText(type);
|
||||
const auto phraseWidth = st::dialogsScamFont->width(phrase);
|
||||
const auto width = st::dialogsScamPadding.left()
|
||||
+ phraseWidth
|
||||
|
@ -197,11 +209,13 @@ int PeerBadge::drawScamOrFake(Painter &p, const Descriptor &descriptor) {
|
|||
rectForName.y() + (rectForName.height() - height) / 2,
|
||||
width,
|
||||
height);
|
||||
DrawScamFakeBadge(
|
||||
DrawTextBadge(
|
||||
p,
|
||||
rect,
|
||||
descriptor.outerWidth,
|
||||
*descriptor.scam,
|
||||
*((type == TextBadgeType::Direct)
|
||||
? descriptor.direct
|
||||
: descriptor.scam),
|
||||
phrase,
|
||||
phraseWidth);
|
||||
return st::dialogsScamSkip + width;
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
const style::icon *verified = nullptr;
|
||||
const style::icon *premium = nullptr;
|
||||
const style::color *scam = nullptr;
|
||||
const style::color *direct = nullptr;
|
||||
const style::color *premiumFg = nullptr;
|
||||
Fn<void()> customEmojiRepaint;
|
||||
crl::time now = 0;
|
||||
|
@ -84,7 +85,7 @@ private:
|
|||
struct EmojiStatus;
|
||||
struct BotVerifiedData;
|
||||
|
||||
int drawScamOrFake(Painter &p, const Descriptor &descriptor);
|
||||
int drawTextBadge(Painter &p, const Descriptor &descriptor);
|
||||
int drawVerifyCheck(Painter &p, const Descriptor &descriptor);
|
||||
int drawPremiumEmojiStatus(Painter &p, const Descriptor &descriptor);
|
||||
int drawPremiumStar(Painter &p, const Descriptor &descriptor);
|
||||
|
@ -94,9 +95,15 @@ private:
|
|||
|
||||
};
|
||||
|
||||
QSize ScamBadgeSize(bool fake);
|
||||
void DrawScamBadge(
|
||||
bool fake,
|
||||
enum class TextBadgeType : uchar {
|
||||
Scam,
|
||||
Fake,
|
||||
Direct,
|
||||
};
|
||||
|
||||
QSize TextBadgeSize(TextBadgeType type);
|
||||
void DrawTextBadge(
|
||||
TextBadgeType,
|
||||
Painter &p,
|
||||
QRect rect,
|
||||
int outerWidth,
|
||||
|
|
Loading…
Add table
Reference in a new issue