mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
fix: show topic ID
This commit is contained in:
parent
0813121f58
commit
7c378bf397
3 changed files with 43 additions and 5 deletions
|
@ -35,6 +35,17 @@ QString IDString(not_null<PeerData *> peer) {
|
||||||
return resultId;
|
return resultId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString IDString(MsgId topic_root_id) {
|
||||||
|
auto resultId = QString::number(topic_root_id.bare);
|
||||||
|
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer) {
|
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer) {
|
||||||
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
|
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<TextWithEntities> IDValue(MsgId topic_root_id) {
|
||||||
|
return rpl::single(IDString(topic_root_id)) | Ui::Text::ToWithEntities();
|
||||||
}
|
}
|
|
@ -9,5 +9,7 @@
|
||||||
|
|
||||||
|
|
||||||
QString IDString(not_null<PeerData *> peer);
|
QString IDString(not_null<PeerData *> peer);
|
||||||
|
QString IDString(MsgId topic_root_id);
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer);
|
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer);
|
||||||
|
rpl::producer<TextWithEntities> IDValue(MsgId topic_root_id);
|
|
@ -482,6 +482,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->showPeerId != 0) {
|
if (settings->showPeerId != 0) {
|
||||||
|
|
||||||
auto idDrawableText = IDValue(
|
auto idDrawableText = IDValue(
|
||||||
user
|
user
|
||||||
) | rpl::map([](TextWithEntities &&text) {
|
) | rpl::map([](TextWithEntities &&text) {
|
||||||
|
@ -565,12 +566,12 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
addTranslateToMenu(about.text, AboutValue(_peer));
|
addTranslateToMenu(about.text, AboutValue(_peer));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->showPeerId != 0) {
|
if (settings->showPeerId != 0 && !_topic) {
|
||||||
auto idDrawableText = IDValue(
|
auto idDrawableText = IDValue(
|
||||||
_peer
|
_peer
|
||||||
) | rpl::map([](TextWithEntities &&text) {
|
) | rpl::map([](TextWithEntities &&text) {
|
||||||
return Ui::Text::Code(text.text);
|
return Ui::Text::Code(text.text);
|
||||||
});
|
});
|
||||||
auto idInfo = addInfoOneLine(
|
auto idInfo = addInfoOneLine(
|
||||||
rpl::single(QString("ID")),
|
rpl::single(QString("ID")),
|
||||||
std::move(idDrawableText),
|
std::move(idDrawableText),
|
||||||
|
@ -587,6 +588,30 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings->showPeerId != 0 && _topic) {
|
||||||
|
const auto topicRootId = _topic->rootId();
|
||||||
|
auto idDrawableText = IDValue(
|
||||||
|
_peer->forumTopicFor(topicRootId)->topicRootId()
|
||||||
|
) | rpl::map([](TextWithEntities &&text) {
|
||||||
|
return Ui::Text::Code(text.text);
|
||||||
|
});
|
||||||
|
auto idInfo = addInfoOneLine(
|
||||||
|
rpl::single(QString("ID")),
|
||||||
|
std::move(idDrawableText),
|
||||||
|
tr::ayu_ContextCopyID(tr::now)
|
||||||
|
);
|
||||||
|
|
||||||
|
idInfo.text->setClickHandlerFilter([=, peer = _peer](auto &&...) {
|
||||||
|
const auto idText = IDString(peer);
|
||||||
|
if (!idText.isEmpty()) {
|
||||||
|
QGuiApplication::clipboard()->setText(idText);
|
||||||
|
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
||||||
|
controller->showToast(msg);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!_peer->isSelf()) {
|
if (!_peer->isSelf()) {
|
||||||
// No notifications toggle for Self => no separator.
|
// No notifications toggle for Self => no separator.
|
||||||
|
|
Loading…
Add table
Reference in a new issue