mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-22 08:16:56 +00:00
Open channel profile from message sender click.
This commit is contained in:
parent
3c0f80719e
commit
16232c0a4a
@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "ui/basic_click_handlers.h"
|
||||
|
||||
constexpr auto kPeerLinkPeerIdProperty = 0x01;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
@ -163,6 +163,7 @@ bool UpdateBotCommands(
|
||||
|
||||
PeerClickHandler::PeerClickHandler(not_null<PeerData*> peer)
|
||||
: _peer(peer) {
|
||||
setProperty(kPeerLinkPeerIdProperty, peer->id.value);
|
||||
}
|
||||
|
||||
void PeerClickHandler::onClick(ClickContext context) const {
|
||||
|
@ -1156,10 +1156,11 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
: App::hoveredLinkItem();
|
||||
auto lnkPhoto = dynamic_cast<PhotoClickHandler*>(link.get());
|
||||
auto lnkDocument = dynamic_cast<DocumentClickHandler*>(link.get());
|
||||
auto lnkPeer = dynamic_cast<PeerClickHandler*>(link.get());
|
||||
auto lnkIsVideo = lnkDocument ? lnkDocument->document()->isVideoFile() : false;
|
||||
auto lnkIsVoice = lnkDocument ? lnkDocument->document()->isVoiceMessage() : false;
|
||||
auto lnkIsAudio = lnkDocument ? lnkDocument->document()->isAudioFile() : false;
|
||||
const auto fromId = PeerId(
|
||||
link->property(kPeerLinkPeerIdProperty).toULongLong());
|
||||
if (lnkPhoto || lnkDocument) {
|
||||
if (isUponSelected > 0) {
|
||||
_menu->addAction(tr::lng_context_copy_selected(tr::now), [=] {
|
||||
@ -1231,9 +1232,11 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (lnkPeer) { // suggest to block
|
||||
if (auto user = lnkPeer->peer()->asUser()) {
|
||||
suggestRestrictUser(user);
|
||||
} else if (fromId) { // suggest to block
|
||||
if (const auto userId = peerToUser(fromId)) {
|
||||
if (const auto user = session().data().user(userId)) {
|
||||
suggestRestrictUser(user);
|
||||
}
|
||||
}
|
||||
} else { // maybe cursor on some text history item?
|
||||
const auto item = view ? view->data().get() : nullptr;
|
||||
|
@ -19,7 +19,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/unixtime.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_domain.h"
|
||||
#include "chat_helpers/stickers_emoji_pack.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "ui/effects/path_shift_gradient.h"
|
||||
@ -572,10 +574,37 @@ bool Element::computeIsAttachToPrevious(not_null<Element*> previous) {
|
||||
}
|
||||
|
||||
ClickHandlerPtr Element::fromLink() const {
|
||||
if (_fromLink) {
|
||||
return _fromLink;
|
||||
}
|
||||
const auto item = data();
|
||||
const auto from = item->displayFrom();
|
||||
if (from) {
|
||||
return from->openLink();
|
||||
if (const auto from = item->displayFrom()) {
|
||||
_fromLink = std::make_shared<LambdaClickHandler>([=](
|
||||
ClickContext context) {
|
||||
if (context.button != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
const auto window = [&]() -> Window::SessionController* {
|
||||
if (const auto controller = my.sessionWindow.get()) {
|
||||
return controller;
|
||||
}
|
||||
const auto session = &from->session();
|
||||
const auto &windows = session->windows();
|
||||
if (windows.empty()) {
|
||||
session->domain().activate(&session->account());
|
||||
if (windows.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return windows.front();
|
||||
}();
|
||||
if (window) {
|
||||
window->showPeerInfo(from);
|
||||
}
|
||||
});
|
||||
_fromLink->setProperty(kPeerLinkPeerIdProperty, from->id.value);
|
||||
return _fromLink;
|
||||
}
|
||||
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||
if (forwarded->imported) {
|
||||
@ -590,7 +619,8 @@ ClickHandlerPtr Element::fromLink() const {
|
||||
static const auto hidden = std::make_shared<LambdaClickHandler>([] {
|
||||
Ui::Toast::Show(tr::lng_forwarded_hidden(tr::now));
|
||||
});
|
||||
return hidden;
|
||||
_fromLink = hidden;
|
||||
return _fromLink;
|
||||
}
|
||||
|
||||
void Element::createUnreadBar(rpl::producer<QString> text) {
|
||||
|
@ -421,6 +421,7 @@ private:
|
||||
const not_null<ElementDelegate*> _delegate;
|
||||
const not_null<HistoryItem*> _data;
|
||||
std::unique_ptr<Media> _media;
|
||||
mutable ClickHandlerPtr _fromLink;
|
||||
bool _isScheduledUntilOnline = false;
|
||||
const QDateTime _dateTime;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 725654654d44554c7ce2ebd86d242f7c46b13591
|
||||
Subproject commit 5cf6981bbbc7098fab90d7a421e4599ec0013115
|
Loading…
Reference in New Issue
Block a user