mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
feat: add dev badges
Co-authored-by: c0re100 <corehusky@gmail.com>
This commit is contained in:
parent
b2ce1d2d15
commit
8e7b12a23a
12 changed files with 121 additions and 10 deletions
BIN
Telegram/Resources/icons/ayu/exterabadge.png
Normal file
BIN
Telegram/Resources/icons/ayu/exterabadge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 312 B |
BIN
Telegram/Resources/icons/ayu/exterabadge@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/exterabadge@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 517 B |
BIN
Telegram/Resources/icons/ayu/exterabadge@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/exterabadge@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 754 B |
|
@ -15,3 +15,5 @@ ayuMenuIcon: icon {{ "ayu/ayu_menu", menuIconColor }};
|
||||||
ayuLReadMenuIcon: icon {{ "ayu/lread", menuIconColor }};
|
ayuLReadMenuIcon: icon {{ "ayu/lread", menuIconColor }};
|
||||||
ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }};
|
ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }};
|
||||||
ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }};
|
ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }};
|
||||||
|
|
||||||
|
infoExteraBadge: icon {{ "ayu/exterabadge", profileVerifiedCheckBg }};
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
#include "ayu_profile_values.h"
|
#include "ayu_profile_values.h"
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "ayu/utils/telegram_helpers.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
|
||||||
|
@ -14,13 +15,7 @@ constexpr auto kMaxChannelId = -1000000000000;
|
||||||
|
|
||||||
QString IDString(not_null<PeerData *> peer)
|
QString IDString(not_null<PeerData *> peer)
|
||||||
{
|
{
|
||||||
auto resultId = QString::number(peerIsUser(peer->id)
|
auto resultId = QString::number(getBareID(peer));
|
||||||
? peerToUser(peer->id).bare
|
|
||||||
: peerIsChat(peer->id)
|
|
||||||
? peerToChat(peer->id).bare
|
|
||||||
: peerIsChannel(peer->id)
|
|
||||||
? peerToChannel(peer->id).bare
|
|
||||||
: peer->id.value);
|
|
||||||
|
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
if (settings->showPeerId == 2) {
|
if (settings->showPeerId == 2) {
|
||||||
|
|
|
@ -24,6 +24,49 @@
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/history_unread_things.h"
|
#include "history/history_unread_things.h"
|
||||||
|
|
||||||
|
// https://github.com/AyuGram/AyuGram4AX/blob/rewrite/TMessagesProj/src/main/java/com/radolyn/ayugram/AyuConstants.java
|
||||||
|
std::unordered_set<ID> ayugram_channels = {
|
||||||
|
1905581924, // @ayugramchat
|
||||||
|
1794457129, // @ayugram1338
|
||||||
|
1434550607, // @radolyn
|
||||||
|
1947958814, // @ayugramfun
|
||||||
|
1815864846, // @ayugramfcm
|
||||||
|
};
|
||||||
|
std::unordered_set<ID> ayugram_devs = {
|
||||||
|
139303278, // @alexeyzavar
|
||||||
|
778327202, // @sharapagorg
|
||||||
|
238292700, // @MaxPlays
|
||||||
|
1795176335, // @radolyn_services
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://github.com/AyuGram/AyuGram4AX/blob/rewrite/TMessagesProj/src/main/java/com/exteragram/messenger/ExteraConfig.java
|
||||||
|
std::unordered_set<ID> extera_channels = {
|
||||||
|
1233768168,
|
||||||
|
1524581881,
|
||||||
|
1571726392,
|
||||||
|
1632728092,
|
||||||
|
1172503281,
|
||||||
|
1877362358,
|
||||||
|
// custom
|
||||||
|
1812843581, // @moeGramX
|
||||||
|
1634905346, // @moex_log
|
||||||
|
1516526055, // @moexci
|
||||||
|
1622008530, // @moe_chat
|
||||||
|
};
|
||||||
|
std::unordered_set<ID> extera_devs = {
|
||||||
|
963080346,
|
||||||
|
1282540315,
|
||||||
|
1374434073,
|
||||||
|
388099852,
|
||||||
|
1972014627,
|
||||||
|
168769611,
|
||||||
|
480000401,
|
||||||
|
639891381,
|
||||||
|
1773117711,
|
||||||
|
5330087923,
|
||||||
|
666154369,
|
||||||
|
139303278
|
||||||
|
};
|
||||||
|
|
||||||
Main::Session *getSession(ID userId)
|
Main::Session *getSession(ID userId)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +153,26 @@ std::pair<std::string, std::string> serializeTextWithEntities(not_null<HistoryIt
|
||||||
return std::make_pair(text, std::string(reinterpret_cast<char *>(buff.data()), buff.size()));
|
return std::make_pair(text, std::string(reinterpret_cast<char *>(buff.data()), buff.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ID getBareID(not_null<PeerData *> peer) {
|
||||||
|
return peerIsUser(peer->id)
|
||||||
|
? peerToUser(peer->id).bare
|
||||||
|
: peerIsChat(peer->id)
|
||||||
|
? peerToChat(peer->id).bare
|
||||||
|
: peerIsChannel(peer->id)
|
||||||
|
? peerToChannel(peer->id).bare
|
||||||
|
: peer->id.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAyuGramRelated(ID peerId)
|
||||||
|
{
|
||||||
|
return ayugram_devs.contains(peerId) || ayugram_channels.contains(peerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isExteraRelated(ID peerId)
|
||||||
|
{
|
||||||
|
return extera_devs.contains(peerId) || extera_channels.contains(peerId);
|
||||||
|
}
|
||||||
|
|
||||||
void MarkAsReadChatList(not_null<Dialogs::MainList *> list)
|
void MarkAsReadChatList(not_null<Dialogs::MainList *> list)
|
||||||
{
|
{
|
||||||
auto mark = std::vector<not_null<History *>>();
|
auto mark = std::vector<not_null<History *>>();
|
||||||
|
|
|
@ -21,6 +21,11 @@ not_null<History *> getHistoryFromDialogId(ID dialogId, Main::Session *session);
|
||||||
ID getDialogIdFromPeer(not_null<PeerData *> peer);
|
ID getDialogIdFromPeer(not_null<PeerData *> peer);
|
||||||
std::pair<std::string, std::string> serializeTextWithEntities(not_null<HistoryItem *> item);
|
std::pair<std::string, std::string> serializeTextWithEntities(not_null<HistoryItem *> item);
|
||||||
|
|
||||||
|
ID getBareID(not_null<PeerData *> peer);
|
||||||
|
|
||||||
|
bool isAyuGramRelated(ID peerId);
|
||||||
|
bool isExteraRelated(ID peerId);
|
||||||
|
|
||||||
void MarkAsReadChatList(not_null<Dialogs::MainList *> list);
|
void MarkAsReadChatList(not_null<Dialogs::MainList *> list);
|
||||||
void MarkAsReadThread(not_null<Data::Thread *> thread);
|
void MarkAsReadThread(not_null<Data::Thread *> thread);
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
// AyuGram includes
|
// AyuGram includes
|
||||||
#include <ayu/ayu_settings.h>
|
#include "ayu/ayu_settings.h"
|
||||||
#include <ui/boxes/confirm_box.h>
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
|
||||||
|
|
||||||
namespace ChatHelpers {
|
namespace ChatHelpers {
|
||||||
|
|
|
@ -19,6 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "styles/style_ayu_icons.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Info::Profile {
|
namespace Info::Profile {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -167,6 +171,16 @@ void Badge::setContent(Content content) {
|
||||||
st::attentionButtonFg);
|
st::attentionButtonFg);
|
||||||
}, _view->lifetime());
|
}, _view->lifetime());
|
||||||
} break;
|
} break;
|
||||||
|
case BadgeType::AyuGram:
|
||||||
|
case BadgeType::Extera: {
|
||||||
|
const auto icon = &st::infoExteraBadge;
|
||||||
|
_view->resize(icon->size());
|
||||||
|
_view->paintRequest(
|
||||||
|
) | rpl::start_with_next([=, check = _view.data()]{
|
||||||
|
Painter p(check);
|
||||||
|
icon->paint(p, 0, 0, check->width());
|
||||||
|
}, _view->lifetime());
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_content.badge != BadgeType::Premium || !_premiumClickCallback) {
|
if (_content.badge != BadgeType::Premium || !_premiumClickCallback) {
|
||||||
|
|
|
@ -41,6 +41,8 @@ enum class BadgeType {
|
||||||
Premium = 0x02,
|
Premium = 0x02,
|
||||||
Scam = 0x04,
|
Scam = 0x04,
|
||||||
Fake = 0x08,
|
Fake = 0x08,
|
||||||
|
AyuGram = 0x10,
|
||||||
|
Extera = 0x20,
|
||||||
};
|
};
|
||||||
inline constexpr bool is_flag_type(BadgeType) { return true; }
|
inline constexpr bool is_flag_type(BadgeType) { return true; }
|
||||||
|
|
||||||
|
@ -83,9 +85,9 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] Data::CustomEmojiSizeTag sizeTag() const;
|
[[nodiscard]] Data::CustomEmojiSizeTag sizeTag() const;
|
||||||
|
|
||||||
private:
|
|
||||||
void setContent(Content content);
|
void setContent(Content content);
|
||||||
|
|
||||||
|
private:
|
||||||
const not_null<QWidget*> _parent;
|
const not_null<QWidget*> _parent;
|
||||||
const style::InfoPeerBadge &_st;
|
const style::InfoPeerBadge &_st;
|
||||||
const not_null<Main::Session*> _session;
|
const not_null<Main::Session*> _session;
|
||||||
|
|
|
@ -39,6 +39,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
|
|
||||||
|
// AyuGram includes
|
||||||
|
#include "ayu/utils/telegram_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Info::Profile {
|
namespace Info::Profile {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -302,6 +306,16 @@ Cover::Cover(
|
||||||
return controller->isGifPausedAtLeastFor(
|
return controller->isGifPausedAtLeastFor(
|
||||||
Window::GifPauseReason::Layer);
|
Window::GifPauseReason::Layer);
|
||||||
}))
|
}))
|
||||||
|
, _devBadge(
|
||||||
|
std::make_unique<Badge>(
|
||||||
|
this,
|
||||||
|
st::infoPeerBadge,
|
||||||
|
peer,
|
||||||
|
_emojiStatusPanel.get(),
|
||||||
|
[=] {
|
||||||
|
return controller->isGifPausedAtLeastFor(
|
||||||
|
Window::GifPauseReason::Layer);
|
||||||
|
}))
|
||||||
, _userpic(topic
|
, _userpic(topic
|
||||||
? nullptr
|
? nullptr
|
||||||
: object_ptr<Ui::UserpicButton>(
|
: object_ptr<Ui::UserpicButton>(
|
||||||
|
@ -344,6 +358,16 @@ Cover::Cover(
|
||||||
refreshNameGeometry(width());
|
refreshNameGeometry(width());
|
||||||
}, _name->lifetime());
|
}, _name->lifetime());
|
||||||
|
|
||||||
|
if (isAyuGramRelated(getBareID(_peer))) {
|
||||||
|
_devBadge->setContent(Info::Profile::Badge::Content{BadgeType::AyuGram});
|
||||||
|
}
|
||||||
|
else if (isExteraRelated(getBareID(_peer))) {
|
||||||
|
_devBadge->setContent(Info::Profile::Badge::Content{BadgeType::Extera});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_devBadge->setContent(Info::Profile::Badge::Content{BadgeType::None});
|
||||||
|
}
|
||||||
|
|
||||||
initViewers(std::move(title));
|
initViewers(std::move(title));
|
||||||
setupChildGeometry();
|
setupChildGeometry();
|
||||||
|
|
||||||
|
@ -571,6 +595,11 @@ void Cover::refreshNameGeometry(int newWidth) {
|
||||||
const auto badgeTop = _st.nameTop;
|
const auto badgeTop = _st.nameTop;
|
||||||
const auto badgeBottom = _st.nameTop + _name->height();
|
const auto badgeBottom = _st.nameTop + _name->height();
|
||||||
_badge->move(badgeLeft, badgeTop, badgeBottom);
|
_badge->move(badgeLeft, badgeTop, badgeBottom);
|
||||||
|
|
||||||
|
const auto devBadgeLeft = badgeLeft + (_badge->widget() ? (_badge->widget()->width() + 2) : 0) + 4;
|
||||||
|
const auto devBadgeTop = _st.nameTop;
|
||||||
|
const auto devBadgeBottom = _st.nameTop + _name->height();
|
||||||
|
_devBadge->move(devBadgeLeft, devBadgeTop, devBadgeBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cover::refreshStatusGeometry(int newWidth) {
|
void Cover::refreshStatusGeometry(int newWidth) {
|
||||||
|
|
|
@ -141,6 +141,7 @@ private:
|
||||||
const not_null<PeerData*> _peer;
|
const not_null<PeerData*> _peer;
|
||||||
const std::unique_ptr<EmojiStatusPanel> _emojiStatusPanel;
|
const std::unique_ptr<EmojiStatusPanel> _emojiStatusPanel;
|
||||||
const std::unique_ptr<Badge> _badge;
|
const std::unique_ptr<Badge> _badge;
|
||||||
|
const std::unique_ptr<Badge> _devBadge;
|
||||||
rpl::variable<int> _onlineCount;
|
rpl::variable<int> _onlineCount;
|
||||||
|
|
||||||
object_ptr<Ui::UserpicButton> _userpic;
|
object_ptr<Ui::UserpicButton> _userpic;
|
||||||
|
|
Loading…
Add table
Reference in a new issue