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