mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 04:37:11 +02:00
40 lines
No EOL
1.3 KiB
C++
40 lines
No EOL
1.3 KiB
C++
// This is the source code of AyuGram for Desktop.
|
|
//
|
|
// We do not and cannot prevent the use of our code,
|
|
// but be respectful and credit the original author.
|
|
//
|
|
// Copyright @Radolyn, 2023
|
|
|
|
#include "ui/text/text_utilities.h"
|
|
#include "ayu/ayu_settings.h"
|
|
#include "ayu_profile_values.h"
|
|
#include "data/data_peer.h"
|
|
|
|
|
|
constexpr auto kMaxChannelId = -1000000000000;
|
|
|
|
|
|
QString IDString(not_null<PeerData*> peer) {
|
|
auto resultId = QString::number(peerIsUser(peer->id)
|
|
? peerToUser(peer->id).bare
|
|
: peerIsChat(peer->id)
|
|
? peerToChat(peer->id).bare
|
|
: peerIsChannel(peer->id)
|
|
? peerToChannel(peer->id).bare
|
|
: peer->id.value);
|
|
|
|
auto const settings = &AyuSettings::getInstance();
|
|
if (settings->showPeerId == 2) {
|
|
if (peer->isChannel()) {
|
|
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
|
|
} else if (peer->isChat()) {
|
|
resultId = resultId.prepend("-");
|
|
}
|
|
}
|
|
|
|
return resultId;
|
|
}
|
|
|
|
rpl::producer<TextWithEntities> IDValue(not_null<PeerData*> peer) {
|
|
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
|
|
} |