mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
feat: show badges in dialogs list
This commit is contained in:
parent
5d96eab7b4
commit
51122ab3ba
13 changed files with 115 additions and 2 deletions
BIN
Telegram/Resources/icons/ayu/dialogs_extera_official.png
Normal file
BIN
Telegram/Resources/icons/ayu/dialogs_extera_official.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 401 B |
BIN
Telegram/Resources/icons/ayu/dialogs_extera_official@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/dialogs_extera_official@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 712 B |
BIN
Telegram/Resources/icons/ayu/dialogs_extera_official@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/dialogs_extera_official@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 957 B |
BIN
Telegram/Resources/icons/ayu/dialogs_extera_supporter.png
Normal file
BIN
Telegram/Resources/icons/ayu/dialogs_extera_supporter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 282 B |
BIN
Telegram/Resources/icons/ayu/dialogs_extera_supporter@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/dialogs_extera_supporter@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 415 B |
BIN
Telegram/Resources/icons/ayu/dialogs_extera_supporter@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/dialogs_extera_supporter@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 568 B |
|
@ -9,6 +9,7 @@
|
|||
|
||||
using "ui/colors.palette";
|
||||
using "ui/widgets/widgets.style";
|
||||
using "dialogs/dialogs.style";
|
||||
|
||||
ayuGhostIcon: icon {{ "ayu/ghost", menuIconColor }};
|
||||
ayuMenuIcon: icon {{ "ayu/ayu_menu", menuIconColor }};
|
||||
|
@ -40,3 +41,14 @@ editedIconPadding: margins(0px, 0px, 0px, 0px);
|
|||
|
||||
deletedIcon: icon {{ "ayu/trash_bin", windowFg }};
|
||||
deletedIconPadding: margins(0px, 0px, 0px, 0px);
|
||||
|
||||
dialogsExteraOfficialIcon: ThreeStateIcon {
|
||||
icon: icon {{ "ayu/dialogs_extera_official", dialogsVerifiedIconBg }};
|
||||
over: icon {{ "ayu/dialogs_extera_official", dialogsVerifiedIconBgOver }};
|
||||
active: icon {{ "ayu/dialogs_extera_official", dialogsVerifiedIconBgActive }};
|
||||
}
|
||||
dialogsExteraSupporterIcon: ThreeStateIcon {
|
||||
icon: icon {{ "ayu/dialogs_extera_supporter", dialogsVerifiedIconBg }};
|
||||
over: icon {{ "ayu/dialogs_extera_supporter", dialogsVerifiedIconBgOver }};
|
||||
active: icon {{ "ayu/dialogs_extera_supporter", dialogsVerifiedIconBgActive }};
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <xxhash.h> // XXH64.
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
// AyuGram includes
|
||||
#include "styles/style_ayu_icons.h"
|
||||
|
||||
|
||||
[[nodiscard]] PeerListRowId UniqueRowIdFromString(const QString &d) {
|
||||
return XXH64(d.data(), d.size() * sizeof(ushort), 0);
|
||||
}
|
||||
|
@ -800,6 +804,12 @@ int PeerListRow::paintNameIconGetWidth(
|
|||
.verified = &(selected
|
||||
? st::dialogsVerifiedIconOver
|
||||
: st::dialogsVerifiedIcon),
|
||||
.exteraOfficial = &(selected
|
||||
? st::dialogsExteraOfficialIcon.over
|
||||
: st::dialogsExteraOfficialIcon.icon),
|
||||
.exteraSupporter = &(selected
|
||||
? st::dialogsExteraSupporterIcon.over
|
||||
: st::dialogsExteraSupporterIcon.icon),
|
||||
.premium = &(selected
|
||||
? st::dialogsPremiumIcon.over
|
||||
: st::dialogsPremiumIcon.icon),
|
||||
|
|
|
@ -84,6 +84,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
// AyuGram includes
|
||||
#include "styles/style_ayu_icons.h"
|
||||
|
||||
|
||||
namespace Dialogs {
|
||||
namespace {
|
||||
|
||||
|
@ -1458,6 +1462,14 @@ void InnerWidget::paintPeerSearchResult(
|
|||
: context.selected
|
||||
? &st::dialogsVerifiedIconOver
|
||||
: &st::dialogsVerifiedIcon),
|
||||
.exteraOfficial = &ThreeStateIcon(
|
||||
st::dialogsExteraOfficialIcon,
|
||||
context.active,
|
||||
context.selected),
|
||||
.exteraSupporter = &ThreeStateIcon(
|
||||
st::dialogsExteraSupporterIcon,
|
||||
context.active,
|
||||
context.selected),
|
||||
.premium = &ThreeStateIcon(
|
||||
st::dialogsPremiumIcon,
|
||||
context.active,
|
||||
|
|
|
@ -44,6 +44,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_widgets.h"
|
||||
#include "styles/style_window.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "styles/style_ayu_icons.h"
|
||||
|
||||
|
||||
namespace Dialogs::Ui {
|
||||
namespace {
|
||||
|
||||
|
@ -716,6 +720,14 @@ void PaintRow(
|
|||
: context.selected
|
||||
? &st::dialogsVerifiedIconOver
|
||||
: &st::dialogsVerifiedIcon),
|
||||
.exteraOfficial = &ThreeStateIcon(
|
||||
st::dialogsExteraOfficialIcon,
|
||||
context.active,
|
||||
context.selected),
|
||||
.exteraSupporter = &ThreeStateIcon(
|
||||
st::dialogsExteraSupporterIcon,
|
||||
context.active,
|
||||
context.selected),
|
||||
.premium = &ThreeStateIcon(
|
||||
st::dialogsPremiumIcon,
|
||||
context.active,
|
||||
|
|
|
@ -74,6 +74,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_chat_filters.h"
|
||||
#include "history/admin_log/history_admin_log_section.h"
|
||||
#include "styles/style_ayu_styles.h"
|
||||
#include "styles/style_ayu_icons.h"
|
||||
|
||||
|
||||
namespace HistoryView {
|
||||
|
@ -616,6 +617,8 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
|||
.nameWidth = _title.maxWidth(),
|
||||
.outerWidth = width(),
|
||||
.verified = &st::dialogsVerifiedIcon,
|
||||
.exteraOfficial = &st::dialogsExteraOfficialIcon.icon,
|
||||
.exteraSupporter = &st::dialogsExteraSupporterIcon.icon,
|
||||
.premium = &st::dialogsPremiumIcon.icon,
|
||||
.scam = &st::attentionButtonFg,
|
||||
.premiumFg = &st::dialogsVerifiedIconBg,
|
||||
|
|
|
@ -19,6 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/unread_badge_paint.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/utils/telegram_helpers.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
namespace {
|
||||
|
||||
|
@ -154,6 +158,16 @@ int PeerBadge::drawGetWidth(Painter &p, Descriptor &&descriptor) {
|
|||
&& (!paintVerify || descriptor.bothVerifyAndStatus);
|
||||
const auto paintStar = premiumStar && !paintVerify;
|
||||
|
||||
const auto paintExteraDev =
|
||||
isExteraPeer(getBareID(peer)) && (!paintEmoji || descriptor.bothVerifyAndStatus);
|
||||
const auto paintExteraSupporter = !paintExteraDev &&
|
||||
isSupporterPeer(getBareID(peer)) && (!paintEmoji || descriptor.bothVerifyAndStatus);
|
||||
const auto exteraWidth = paintExteraDev
|
||||
? descriptor.exteraOfficial->width()
|
||||
: paintExteraSupporter
|
||||
? descriptor.exteraSupporter->width()
|
||||
: 0;
|
||||
|
||||
auto result = 0;
|
||||
if (paintEmoji) {
|
||||
auto &rectForName = descriptor.rectForName;
|
||||
|
@ -161,13 +175,34 @@ int PeerBadge::drawGetWidth(Painter &p, Descriptor &&descriptor) {
|
|||
if (paintVerify) {
|
||||
rectForName.setWidth(rectForName.width() - verifyWidth);
|
||||
}
|
||||
if (paintExteraDev || paintExteraSupporter) {
|
||||
rectForName.setWidth(rectForName.width() - exteraWidth);
|
||||
}
|
||||
result += drawPremiumEmojiStatus(p, descriptor);
|
||||
if (!paintVerify) {
|
||||
if (!paintVerify && !paintExteraDev) {
|
||||
return result;
|
||||
}
|
||||
rectForName.setWidth(rectForName.width() + verifyWidth);
|
||||
if (paintVerify) {
|
||||
rectForName.setWidth(rectForName.width() + verifyWidth);
|
||||
}
|
||||
if (paintExteraDev || paintExteraSupporter) {
|
||||
rectForName.setWidth(rectForName.width() + exteraWidth);
|
||||
}
|
||||
descriptor.nameWidth += result;
|
||||
}
|
||||
|
||||
if (paintExteraDev || paintExteraSupporter) {
|
||||
if (paintStar) {
|
||||
auto &rectForName = descriptor.rectForName;
|
||||
rectForName.setWidth(rectForName.width() - exteraWidth);
|
||||
result += drawPremiumStar(p, descriptor);
|
||||
rectForName.setWidth(rectForName.width() + exteraWidth);
|
||||
descriptor.nameWidth += result;
|
||||
}
|
||||
result += paintExteraDev ? drawExteraOfficial(p, descriptor) : drawExteraSupporter(p, descriptor);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (paintVerify) {
|
||||
result += drawVerifyCheck(p, descriptor);
|
||||
return result;
|
||||
|
@ -267,6 +302,30 @@ int PeerBadge::drawPremiumStar(Painter &p, const Descriptor &descriptor) {
|
|||
return iconw;
|
||||
}
|
||||
|
||||
int PeerBadge::drawExteraOfficial(Painter &p, const Descriptor &descriptor) {
|
||||
const auto iconw = descriptor.exteraOfficial->width();
|
||||
const auto rectForName = descriptor.rectForName;
|
||||
const auto nameWidth = descriptor.nameWidth;
|
||||
descriptor.exteraOfficial->paint(
|
||||
p,
|
||||
rectForName.x() + qMin(nameWidth, rectForName.width() - iconw),
|
||||
rectForName.y(),
|
||||
descriptor.outerWidth);
|
||||
return iconw;
|
||||
}
|
||||
|
||||
int PeerBadge::drawExteraSupporter(Painter &p, const Descriptor &descriptor) {
|
||||
const auto iconw = descriptor.exteraSupporter->width();
|
||||
const auto rectForName = descriptor.rectForName;
|
||||
const auto nameWidth = descriptor.nameWidth;
|
||||
descriptor.exteraSupporter->paint(
|
||||
p,
|
||||
rectForName.x() + qMin(nameWidth, rectForName.width() - iconw),
|
||||
rectForName.y(),
|
||||
descriptor.outerWidth);
|
||||
return iconw;
|
||||
}
|
||||
|
||||
void PeerBadge::unload() {
|
||||
_emojiStatus = nullptr;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
int nameWidth = 0;
|
||||
int outerWidth = 0;
|
||||
const style::icon *verified = nullptr;
|
||||
const style::icon *exteraOfficial = nullptr;
|
||||
const style::icon *exteraSupporter = nullptr;
|
||||
const style::icon *premium = nullptr;
|
||||
const style::color *scam = nullptr;
|
||||
const style::color *premiumFg = nullptr;
|
||||
|
@ -89,6 +91,9 @@ private:
|
|||
int drawPremiumEmojiStatus(Painter &p, const Descriptor &descriptor);
|
||||
int drawPremiumStar(Painter &p, const Descriptor &descriptor);
|
||||
|
||||
int drawExteraOfficial(Painter &p, const Descriptor &descriptor);
|
||||
int drawExteraSupporter(Painter &p, const Descriptor &descriptor);
|
||||
|
||||
std::unique_ptr<EmojiStatus> _emojiStatus;
|
||||
mutable std::unique_ptr<BotVerifiedData> _botVerifiedData;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue