mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Custom "Copy ID" for peer ID context menu.
This commit is contained in:
parent
1038baf467
commit
3cb33f0825
2 changed files with 23 additions and 2 deletions
|
@ -1162,7 +1162,14 @@ bool Application::openCustomUrl(
|
||||||
|| passcodeLocked()) {
|
|| passcodeLocked()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto command = base::StringViewMid(urlTrimmed, protocol.size(), 8192);
|
static const auto kTagExp = QRegularExpression(
|
||||||
|
u"\\~[a-zA-Z0-9_\\-]+\\~:"_q);
|
||||||
|
auto skip = protocol.size();
|
||||||
|
const auto match = kTagExp.match(urlTrimmed, skip);
|
||||||
|
if (match.hasMatch()) {
|
||||||
|
skip += match.capturedLength();
|
||||||
|
}
|
||||||
|
const auto command = base::StringViewMid(urlTrimmed, skip, 8192);
|
||||||
const auto my = context.value<ClickHandlerContext>();
|
const auto my = context.value<ClickHandlerContext>();
|
||||||
const auto controller = my.sessionWindow.get()
|
const auto controller = my.sessionWindow.get()
|
||||||
? my.sessionWindow.get()
|
? my.sessionWindow.get()
|
||||||
|
|
|
@ -185,7 +185,7 @@ base::options::toggle ShowPeerIdBelowAbout({
|
||||||
const auto raw = peer->id.value & PeerId::kChatTypeMask;
|
const auto raw = peer->id.value & PeerId::kChatTypeMask;
|
||||||
value.append(Link(
|
value.append(Link(
|
||||||
Italic(Lang::FormatCountDecimal(raw)),
|
Italic(Lang::FormatCountDecimal(raw)),
|
||||||
"internal:copy:" + QString::number(raw)));
|
"internal:~peer_id~:copy:" + QString::number(raw)));
|
||||||
return std::move(value);
|
return std::move(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -979,6 +979,20 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
state->labelText = std::move(text);
|
state->labelText = std::move(text);
|
||||||
label->setContextMenuHook([=](
|
label->setContextMenuHook([=](
|
||||||
Ui::FlatLabel::ContextMenuRequest request) {
|
Ui::FlatLabel::ContextMenuRequest request) {
|
||||||
|
if (request.link) {
|
||||||
|
const auto &url = request.link->url();
|
||||||
|
if (url.startsWith(u"internal:~peer_id~:"_q)) {
|
||||||
|
const auto weak = base::make_weak(controller);
|
||||||
|
request.menu->addAction(u"Copy ID"_q, [=] {
|
||||||
|
Core::App().openInternalUrl(
|
||||||
|
url,
|
||||||
|
QVariant::fromValue(ClickHandlerContext{
|
||||||
|
.sessionWindow = weak,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
label->fillContextMenu(request);
|
label->fillContextMenu(request);
|
||||||
if (Ui::SkipTranslate(state->labelText.current())) {
|
if (Ui::SkipTranslate(state->labelText.current())) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue