mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added drag text to contact view.
This commit is contained in:
parent
afdd22d154
commit
ea20e41f1d
1 changed files with 46 additions and 14 deletions
|
@ -32,8 +32,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
ClickHandlerPtr SendMessageClickHandler(PeerData *peer) {
|
class ContactClickHandler : public LambdaClickHandler {
|
||||||
return std::make_shared<LambdaClickHandler>([peer](ClickContext context) {
|
public:
|
||||||
|
using LambdaClickHandler::LambdaClickHandler;
|
||||||
|
|
||||||
|
void setDragText(const QString &t) {
|
||||||
|
_dragText = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString dragText() const override {
|
||||||
|
return _dragText;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _dragText;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ClickHandlerPtr SendMessageClickHandler(not_null<PeerData*> peer) {
|
||||||
|
const auto clickHandlerPtr = std::make_shared<ContactClickHandler>([peer](
|
||||||
|
ClickContext context) {
|
||||||
const auto my = context.other.value<ClickHandlerContext>();
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
if (const auto controller = my.sessionWindow.get()) {
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
if (controller->session().uniqueId()
|
if (controller->session().uniqueId()
|
||||||
|
@ -45,30 +63,44 @@ ClickHandlerPtr SendMessageClickHandler(PeerData *peer) {
|
||||||
Window::SectionShow::Way::Forward);
|
Window::SectionShow::Way::Forward);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (const auto user = peer->asUser()) {
|
||||||
|
clickHandlerPtr->setDragText(user->phone().isEmpty()
|
||||||
|
? peer->name()
|
||||||
|
: Ui::FormatPhone(user->phone()));
|
||||||
|
}
|
||||||
|
return clickHandlerPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClickHandlerPtr AddContactClickHandler(not_null<HistoryItem*> item) {
|
ClickHandlerPtr AddContactClickHandler(not_null<HistoryItem*> item) {
|
||||||
const auto session = &item->history()->session();
|
const auto session = &item->history()->session();
|
||||||
const auto fullId = item->fullId();
|
const auto sharedContact = [=, fullId = item->fullId()] {
|
||||||
return std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
if (const auto item = session->data().message(fullId)) {
|
||||||
|
if (const auto media = item->media()) {
|
||||||
|
return media->sharedContact();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (const Data::SharedContact *)nullptr;
|
||||||
|
};
|
||||||
|
const auto clickHandlerPtr = std::make_shared<ContactClickHandler>([=](
|
||||||
|
ClickContext context) {
|
||||||
const auto my = context.other.value<ClickHandlerContext>();
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
if (const auto controller = my.sessionWindow.get()) {
|
if (const auto controller = my.sessionWindow.get()) {
|
||||||
if (controller->session().uniqueId() != session->uniqueId()) {
|
if (controller->session().uniqueId() != session->uniqueId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (const auto item = session->data().message(fullId)) {
|
if (const auto contact = sharedContact()) {
|
||||||
if (const auto media = item->media()) {
|
controller->show(Box<AddContactBox>(
|
||||||
if (const auto contact = media->sharedContact()) {
|
session,
|
||||||
controller->show(Box<AddContactBox>(
|
contact->firstName,
|
||||||
session,
|
contact->lastName,
|
||||||
contact->firstName,
|
contact->phoneNumber));
|
||||||
contact->lastName,
|
|
||||||
contact->phoneNumber));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (const auto contact = sharedContact()) {
|
||||||
|
clickHandlerPtr->setDragText(Ui::FormatPhone(contact->phoneNumber));
|
||||||
|
}
|
||||||
|
return clickHandlerPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Add table
Reference in a new issue