mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
enabled contact share from templates, copy phone number from context menu in profiles
This commit is contained in:
parent
38e8e51ec5
commit
90a9c92d38
11 changed files with 199 additions and 65 deletions
|
@ -251,6 +251,7 @@ lng_profile_audio: "{count} voice message »";
|
|||
lng_profile_audios: "{count} voice messages »";
|
||||
lng_profile_audios_header: "Voice messages overview";
|
||||
lng_profile_show_all_types: "Show all types";
|
||||
lng_profile_copy_phone: "Copy phone number";
|
||||
|
||||
lng_participant_filter: "Search";
|
||||
lng_participant_invite: "Invite";
|
||||
|
@ -364,6 +365,7 @@ lng_context_delete_selected: "Delete Selected";
|
|||
lng_context_clear_selection: "Clear Selection";
|
||||
lng_really_send_image: "Do you want to send this image?";
|
||||
lng_really_send_file: "Do you want to send this file?";
|
||||
lng_really_share_contact: "Do you want to share this contact?";
|
||||
lng_send_image_compressed: "Send compressed image";
|
||||
|
||||
lng_forward_choose: "Choose recipient...";
|
||||
|
|
|
@ -23,7 +23,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
|
|||
#include "mainwidget.h"
|
||||
#include "photosendbox.h"
|
||||
|
||||
PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(img),
|
||||
PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(new ReadyLocalMedia(img)),
|
||||
_thumbx(0), _thumby(0), _thumbw(0), _thumbh(0), _namew(0), _textw(0),
|
||||
_compressed(this, lang(lng_send_image_compressed), true),
|
||||
_sendButton(this, lang(lng_send_button), st::btnSelectDone),
|
||||
|
@ -33,9 +33,9 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(img),
|
|||
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
|
||||
|
||||
_width = st::confirmWidth;
|
||||
if (img.type == ToPreparePhoto) {
|
||||
if (_img->type == ToPreparePhoto) {
|
||||
int32 maxW = 0, maxH = 0;
|
||||
for (PreparedPhotoThumbs::const_iterator i = img.photoThumbs.cbegin(), e = img.photoThumbs.cend(); i != e; ++i) {
|
||||
for (PreparedPhotoThumbs::const_iterator i = _img->photoThumbs.cbegin(), e = _img->photoThumbs.cend(); i != e; ++i) {
|
||||
if (i->width() >= maxW && i->height() >= maxH) {
|
||||
_thumb = *i;
|
||||
maxW = _thumb.width();
|
||||
|
@ -64,8 +64,8 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(img),
|
|||
_thumb = QPixmap::fromImage(_thumb.toImage().scaled(_thumbw, _thumbh, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
} else {
|
||||
_compressed.hide();
|
||||
if (!img.photoThumbs.isEmpty()) {
|
||||
_thumb = img.photoThumbs.cbegin().value();
|
||||
if (!_img->photoThumbs.isEmpty()) {
|
||||
_thumb = _img->photoThumbs.cbegin().value();
|
||||
int32 tw = _thumb.width(), th = _thumb.height();
|
||||
if (_thumb.isNull() || !tw || !th) {
|
||||
_thumbw = _thumbx = _thumby = 0;
|
||||
|
@ -85,15 +85,38 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(img),
|
|||
}
|
||||
_height = st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height();
|
||||
|
||||
_name = img.filename;
|
||||
_name = _img->filename;
|
||||
_namew = st::mediaFont->m.width(_name);
|
||||
_size = formatSizeText(img.filesize);
|
||||
_size = formatSizeText(_img->filesize);
|
||||
_textw = qMax(_namew, st::mediaFont->m.width(_size));
|
||||
}
|
||||
|
||||
resize(_width, _height);
|
||||
}
|
||||
|
||||
PhotoSendBox::PhotoSendBox(const QString &phone, const QString &fname, const QString &lname) : _img(0),
|
||||
_thumbx(0), _thumby(0), _thumbw(0), _thumbh(0), _namew(0), _textw(0),
|
||||
_compressed(this, lang(lng_send_image_compressed), true),
|
||||
_sendButton(this, lang(lng_send_button), st::btnSelectDone),
|
||||
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
|
||||
_phone(phone), _fname(fname), _lname(lname),
|
||||
a_opacity(0, 1) {
|
||||
connect(&_sendButton, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
|
||||
|
||||
_width = st::confirmWidth;
|
||||
_compressed.hide();
|
||||
_height = st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height();
|
||||
|
||||
_name = _fname + QChar(' ') + _lname;
|
||||
_namew = st::mediaFont->m.width(_name);
|
||||
_size = _phone;
|
||||
_textw = qMax(_namew, st::mediaFont->m.width(_size));
|
||||
|
||||
resize(_width, _height);
|
||||
}
|
||||
|
||||
|
||||
void PhotoSendBox::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
||||
onSend();
|
||||
|
@ -126,11 +149,11 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) {
|
|||
|
||||
p.setFont(st::boxFont->f);
|
||||
p.setPen(st::boxGrayTitle->p);
|
||||
if (_img.type == ToPreparePhoto) {
|
||||
if (_img && _img->type == ToPreparePhoto) {
|
||||
p.drawText(QRect(st::boxPadding.left(), st::boxPadding.top(), _width - st::boxPadding.left() - st::boxPadding.right(), st::boxFont->height), lang(lng_really_send_image), style::al_center);
|
||||
p.drawPixmap((_width - _thumbw) / 2, st::boxPadding.top() * 2 + st::boxFont->height, _thumb);
|
||||
} else {
|
||||
p.drawText(QRect(st::boxPadding.left(), st::boxPadding.top(), _width - st::boxPadding.left() - st::boxPadding.right(), st::boxFont->height), lang(lng_really_send_file), style::al_center);
|
||||
p.drawText(QRect(st::boxPadding.left(), st::boxPadding.top(), _width - st::boxPadding.left() - st::boxPadding.right(), st::boxFont->height), lang(_img ? lng_really_send_file : lng_really_share_contact), style::al_center);
|
||||
|
||||
int32 w = _width - st::boxPadding.left() - st::boxPadding.right(), h = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
|
||||
int32 tleft = st::mediaPadding.left() + st::mediaThumbSize + st::mediaPadding.right();
|
||||
|
@ -146,8 +169,10 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) {
|
|||
if (_thumbw) {
|
||||
int32 rf(cIntRetinaFactor());
|
||||
p.drawPixmap(QPoint(x + st::mediaPadding.left(), y + st::mediaPadding.top()), _thumb, QRect(_thumbx * rf, _thumby * rf, st::mediaThumbSize * rf, st::mediaThumbSize * rf));
|
||||
} else {
|
||||
} else if (_img) {
|
||||
p.drawPixmap(QPoint(x + st::mediaPadding.left(), y + st::mediaPadding.top()), App::sprite(), st::mediaDocOutImg);
|
||||
} else {
|
||||
p.drawPixmap(x + st::mediaPadding.left(), y + st::mediaPadding.top(), userDefPhoto(1)->pix(st::mediaThumbSize));
|
||||
}
|
||||
|
||||
p.setFont(st::mediaFont->f);
|
||||
|
@ -176,8 +201,10 @@ void PhotoSendBox::animStep(float64 ms) {
|
|||
}
|
||||
|
||||
void PhotoSendBox::onSend() {
|
||||
if (_compressed.isHidden() || _compressed.checked()) {
|
||||
if (App::main()) App::main()->confirmSendImage(_img);
|
||||
if (!_img) {
|
||||
if (App::main()) App::main()->confirmShareContact(_phone, _fname, _lname);
|
||||
} else if (_compressed.isHidden() || _compressed.checked()) {
|
||||
if (App::main()) App::main()->confirmSendImage(*_img);
|
||||
} else {
|
||||
if (App::main()) App::main()->confirmSendImageUncompressed();
|
||||
}
|
||||
|
@ -195,5 +222,6 @@ void PhotoSendBox::startHide() {
|
|||
}
|
||||
|
||||
PhotoSendBox::~PhotoSendBox() {
|
||||
delete _img;
|
||||
if (App::main()) App::main()->cancelSendImage();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ class PhotoSendBox : public LayeredWidget {
|
|||
public:
|
||||
|
||||
PhotoSendBox(const ReadyLocalMedia &img);
|
||||
PhotoSendBox(const QString &phone, const QString &fname, const QString &lname);
|
||||
void parentResized();
|
||||
void animStep(float64 ms);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
|
@ -40,7 +41,7 @@ public slots:
|
|||
|
||||
private:
|
||||
|
||||
ReadyLocalMedia _img;
|
||||
ReadyLocalMedia *_img;
|
||||
int32 _width, _height, _thumbx, _thumby, _thumbw, _thumbh;
|
||||
QString _name, _size;
|
||||
int32 _namew, _textw;
|
||||
|
@ -48,6 +49,8 @@ private:
|
|||
FlatButton _sendButton, _cancelButton;
|
||||
QPixmap _thumb;
|
||||
|
||||
QString _phone, _fname, _lname;
|
||||
|
||||
anim::fvalue a_opacity;
|
||||
|
||||
bool _hiding;
|
||||
|
|
|
@ -39,46 +39,45 @@ TextParseOptions _textDlgOptions = {
|
|||
Qt::LayoutDirectionAuto, // lang-dependent
|
||||
};
|
||||
|
||||
style::color peerColor(int32 index) {
|
||||
static const style::color peerColors[8] = {
|
||||
style::color(st::color1),
|
||||
style::color(st::color2),
|
||||
style::color(st::color3),
|
||||
style::color(st::color4),
|
||||
style::color(st::color5),
|
||||
style::color(st::color6),
|
||||
style::color(st::color7),
|
||||
style::color(st::color8)
|
||||
};
|
||||
return peerColors[index];
|
||||
}
|
||||
|
||||
ImagePtr userDefPhoto(int32 index) {
|
||||
static const ImagePtr userDefPhotos[8] = {
|
||||
ImagePtr(":/ava/art/usercolor1.png"),
|
||||
ImagePtr(":/ava/art/usercolor2.png"),
|
||||
ImagePtr(":/ava/art/usercolor3.png"),
|
||||
ImagePtr(":/ava/art/usercolor4.png"),
|
||||
ImagePtr(":/ava/art/usercolor5.png"),
|
||||
ImagePtr(":/ava/art/usercolor6.png"),
|
||||
ImagePtr(":/ava/art/usercolor7.png"),
|
||||
ImagePtr(":/ava/art/usercolor8.png")
|
||||
};
|
||||
return userDefPhotos[index];
|
||||
}
|
||||
|
||||
ImagePtr chatDefPhoto(int32 index) {
|
||||
static const ImagePtr chatDefPhotos[4] = {
|
||||
ImagePtr(":/ava/art/chatcolor1.png"),
|
||||
ImagePtr(":/ava/art/chatcolor2.png"),
|
||||
ImagePtr(":/ava/art/chatcolor3.png"),
|
||||
ImagePtr(":/ava/art/chatcolor4.png")
|
||||
};
|
||||
return chatDefPhotos[index];
|
||||
}
|
||||
|
||||
namespace {
|
||||
style::color peerColor(int32 index) {
|
||||
static const style::color peerColors[8] = {
|
||||
style::color(st::color1),
|
||||
style::color(st::color2),
|
||||
style::color(st::color3),
|
||||
style::color(st::color4),
|
||||
style::color(st::color5),
|
||||
style::color(st::color6),
|
||||
style::color(st::color7),
|
||||
style::color(st::color8)
|
||||
};
|
||||
return peerColors[index];
|
||||
}
|
||||
|
||||
ImagePtr userDefPhoto(int32 index) {
|
||||
static const ImagePtr userDefPhotos[8] = {
|
||||
ImagePtr(":/ava/art/usercolor1.png"),
|
||||
ImagePtr(":/ava/art/usercolor2.png"),
|
||||
ImagePtr(":/ava/art/usercolor3.png"),
|
||||
ImagePtr(":/ava/art/usercolor4.png"),
|
||||
ImagePtr(":/ava/art/usercolor5.png"),
|
||||
ImagePtr(":/ava/art/usercolor6.png"),
|
||||
ImagePtr(":/ava/art/usercolor7.png"),
|
||||
ImagePtr(":/ava/art/usercolor8.png")
|
||||
};
|
||||
return userDefPhotos[index];
|
||||
}
|
||||
|
||||
ImagePtr chatDefPhoto(int32 index) {
|
||||
static const ImagePtr chatDefPhotos[4] = {
|
||||
ImagePtr(":/ava/art/chatcolor1.png"),
|
||||
ImagePtr(":/ava/art/chatcolor2.png"),
|
||||
ImagePtr(":/ava/art/chatcolor3.png"),
|
||||
ImagePtr(":/ava/art/chatcolor4.png")
|
||||
};
|
||||
return chatDefPhotos[index];
|
||||
}
|
||||
|
||||
int32 peerColorIndex(const PeerId &peer) {
|
||||
int32 myId(MTP::authedId()), peerId(peer & 0xFFFFFFFFL);
|
||||
bool chat = (peer & 0x100000000L);
|
||||
|
@ -2696,6 +2695,22 @@ void HistoryContact::draw(QPainter &p, const HistoryItem *parent, bool selected,
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryContact::updateFrom(const MTPMessageMedia &media) {
|
||||
if (media.type() == mtpc_messageMediaContact) {
|
||||
userId = media.c_messageMediaContact().vuser_id.v;
|
||||
contact = App::userLoaded(userId);
|
||||
if (contact) {
|
||||
if (contact->phone.isEmpty()) {
|
||||
contact->setPhone(phone);
|
||||
}
|
||||
if (contact->contact < 0) {
|
||||
contact->contact = 0;
|
||||
}
|
||||
contact->photo->load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HistoryMessage::HistoryMessage(History *history, HistoryBlock *block, const MTPDmessage &msg) :
|
||||
HistoryItem(history, block, msg.vid.v, msg.vout.v, msg.vunread.v, ::date(msg.vdate), msg.vfrom_id.v)
|
||||
, _text(st::msgMinWidth)
|
||||
|
|
|
@ -55,6 +55,10 @@ inline bool isNotifyMuted(NotifySettingsPtr settings) {
|
|||
return (settings->mute > unixtime());
|
||||
}
|
||||
|
||||
style::color peerColor(int32 index);
|
||||
ImagePtr userDefPhoto(int32 index);
|
||||
ImagePtr chatDefPhoto(int32 index);
|
||||
|
||||
struct ChatData;
|
||||
struct UserData;
|
||||
struct PeerData {
|
||||
|
@ -1403,6 +1407,8 @@ public:
|
|||
TextLinkPtr getLink(int32 x, int32 y, const HistoryItem *parent, int32 width) const;
|
||||
HistoryMedia *clone() const;
|
||||
|
||||
void updateFrom(const MTPMessageMedia &media);
|
||||
|
||||
private:
|
||||
int32 userId;
|
||||
int32 w, phonew;
|
||||
|
|
|
@ -2258,14 +2258,18 @@ void HistoryWidget::onShareContact(const PeerId &peer, UserData *contact) {
|
|||
App::main()->showPeer(peer, 0, false, true);
|
||||
if (!hist) return;
|
||||
|
||||
shareContact(contact->phone, contact->firstName, contact->lastName, int32(contact->id & 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
void HistoryWidget::shareContact(const QString &phone, const QString &fname, const QString &lname, int32 userId) {
|
||||
uint64 randomId = MTP::nonce<uint64>();
|
||||
MsgId newId = clientMsgId();
|
||||
|
||||
hist->loadAround(0);
|
||||
|
||||
hist->addToBack(MTP_message(MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(histPeer->id), MTP_bool(true), MTP_bool(true), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaContact(MTP_string(contact->phone), MTP_string(contact->firstName), MTP_string(contact->lastName), MTP_int(int32(contact->id & 0xFFFFFFFF)))));
|
||||
hist->addToBack(MTP_message(MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(histPeer->id), MTP_bool(true), MTP_bool(true), MTP_int(unixtime()), MTP_string(""), MTP_messageMediaContact(MTP_string(phone), MTP_string(fname), MTP_string(lname), MTP_int(userId))));
|
||||
|
||||
MTP::send(MTPmessages_SendMedia(histPeer->input, MTP_inputMediaContact(MTP_string(contact->phone), MTP_string(contact->firstName), MTP_string(contact->lastName)), MTP_long(randomId)), App::main()->rpcDone(&MainWidget::sentFullDataReceived, randomId));
|
||||
MTP::send(MTPmessages_SendMedia(histPeer->input, MTP_inputMediaContact(MTP_string(phone), MTP_string(fname), MTP_string(lname)), MTP_long(randomId)), App::main()->rpcDone(&MainWidget::sentFullDataReceived, randomId));
|
||||
|
||||
App::historyRegRandom(randomId, newId);
|
||||
App::main()->historyToDown(hist);
|
||||
|
@ -2687,6 +2691,15 @@ void HistoryWidget::uploadFile(const QString &file, bool withText) {
|
|||
confirmImageId = imageLoader.append(file, histPeer->id, ToPrepareDocument);
|
||||
}
|
||||
|
||||
void HistoryWidget::shareContactConfirmation(const QString &phone, const QString &fname, const QString &lname, bool withText) {
|
||||
if (!hist || confirmImageId) return;
|
||||
|
||||
App::wnd()->activateWindow();
|
||||
confirmWithText = withText;
|
||||
confirmImageId = -1;
|
||||
App::wnd()->showLayer(new PhotoSendBox(phone, fname, lname));
|
||||
}
|
||||
|
||||
void HistoryWidget::uploadConfirmImageUncompressed() {
|
||||
if (!hist || !confirmImageId || confirmImage.isNull()) return;
|
||||
|
||||
|
@ -2728,6 +2741,18 @@ void HistoryWidget::onPhotoReady() {
|
|||
void HistoryWidget::onPhotoFailed(quint64 id) {
|
||||
}
|
||||
|
||||
void HistoryWidget::confirmShareContact(const QString &phone, const QString &fname, const QString &lname) {
|
||||
if (-1 == confirmImageId) {
|
||||
if (confirmWithText) {
|
||||
onSend();
|
||||
}
|
||||
confirmImageId = 0;
|
||||
confirmWithText = false;
|
||||
confirmImage = QImage();
|
||||
}
|
||||
shareContact(phone, fname, lname);
|
||||
}
|
||||
|
||||
void HistoryWidget::confirmSendImage(const ReadyLocalMedia &img) {
|
||||
if (img.id == confirmImageId) {
|
||||
if (confirmWithText) {
|
||||
|
@ -3003,7 +3028,7 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
|
|||
void HistoryWidget::onFieldTabbed() {
|
||||
QString v = _field.getText(), t = supportTemplate(v.trimmed());
|
||||
if (!t.isEmpty()) {
|
||||
bool isImg = t.startsWith(qsl("img:")), isFile = t.startsWith(qsl("file:"));
|
||||
bool isImg = t.startsWith(qsl("img:")), isFile = t.startsWith(qsl("file:")), isContact = t.startsWith(qsl("contact:"));
|
||||
if (isImg || isFile) {
|
||||
QString fname = t.mid(isImg ? 4 : 5).trimmed(), text;
|
||||
int32 lineEnd = fname.indexOf(QChar('\n'));
|
||||
|
@ -3021,6 +3046,20 @@ void HistoryWidget::onFieldTabbed() {
|
|||
_field.setPlainText(text);
|
||||
uploadFile(cWorkingDir() + fname, !text.isEmpty());
|
||||
}
|
||||
} else if (isContact) {
|
||||
QString contact = t.mid(8).trimmed(), text;
|
||||
int32 lineEnd = contact.indexOf(QChar('\n'));
|
||||
if (lineEnd > 0) {
|
||||
text = contact.mid(lineEnd + 1).trimmed();
|
||||
contact = contact.mid(0, lineEnd).trimmed();
|
||||
}
|
||||
QStringList data = contact.split(QChar(' '));
|
||||
if (data.size() > 1) {
|
||||
_field.setPlainText(text);
|
||||
|
||||
QString phone = data.at(0).trimmed(), fname = data.at(1).trimmed(), lname = (data.size() > 2) ? data.at(2).trimmed() : QString();
|
||||
shareContactConfirmation(phone, fname, lname, !text.isEmpty());
|
||||
}
|
||||
} else {
|
||||
_field.setPlainText(t);
|
||||
QTextCursor c = _field.textCursor();
|
||||
|
|
|
@ -290,9 +290,11 @@ public:
|
|||
void destroyData();
|
||||
void uploadImage(const QImage &img, bool withText = false);
|
||||
void uploadFile(const QString &file, bool withText = false); // with confirmation
|
||||
void shareContactConfirmation(const QString &phone, const QString &fname, const QString &lname, bool withText = false);
|
||||
void uploadConfirmImageUncompressed();
|
||||
void uploadMedias(const QStringList &files, ToPrepareMediaType type);
|
||||
void uploadMedia(const QByteArray &fileContent, ToPrepareMediaType type);
|
||||
void confirmShareContact(const QString &phone, const QString &fname, const QString &lname);
|
||||
void confirmSendImage(const ReadyLocalMedia &img);
|
||||
void cancelSendImage();
|
||||
|
||||
|
@ -305,6 +307,8 @@ public:
|
|||
void onShareContact(const PeerId &peer, UserData *contact);
|
||||
void onSendPaths(const PeerId &peer);
|
||||
|
||||
void shareContact(const QString &phone, const QString &fname, const QString &lname, int32 userId = 0);
|
||||
|
||||
PeerData *peer() const;
|
||||
PeerData *activePeer() const;
|
||||
MsgId activeMsgId() const;
|
||||
|
|
|
@ -911,6 +911,10 @@ void MainWidget::updateOnlineDisplay() {
|
|||
if (App::wnd()->settingsWidget()) App::wnd()->settingsWidget()->updateOnlineDisplay();
|
||||
}
|
||||
|
||||
void MainWidget::confirmShareContact(const QString &phone, const QString &fname, const QString &lname) {
|
||||
history.confirmShareContact(phone, fname, lname);
|
||||
}
|
||||
|
||||
void MainWidget::confirmSendImage(const ReadyLocalMedia &img) {
|
||||
history.confirmSendImage(img);
|
||||
}
|
||||
|
@ -1211,14 +1215,14 @@ void MainWidget::sentDataReceived(uint64 randomId, const MTPmessages_SentMessage
|
|||
}
|
||||
|
||||
void MainWidget::sentFullDataReceived(uint64 randomId, const MTPmessages_StatedMessage &result) {
|
||||
const MTPMessage *msg = 0;
|
||||
MsgId msgId = 0;
|
||||
if (randomId) {
|
||||
const MTPMessage *msg = 0;
|
||||
switch (result.type()) {
|
||||
case mtpc_messages_statedMessage: msg = &result.c_messages_statedMessage().vmessage; break;
|
||||
case mtpc_messages_statedMessageLink: msg = &result.c_messages_statedMessageLink().vmessage; break;
|
||||
}
|
||||
if (msg) {
|
||||
MsgId msgId = 0;
|
||||
switch (msg->type()) {
|
||||
case mtpc_message: msgId = msg->c_message().vid.v; break;
|
||||
case mtpc_messageEmpty: msgId = msg->c_messageEmpty().vid.v; break;
|
||||
|
@ -1227,7 +1231,6 @@ void MainWidget::sentFullDataReceived(uint64 randomId, const MTPmessages_StatedM
|
|||
}
|
||||
if (msgId) {
|
||||
feedUpdate(MTP_updateMessageID(MTP_int(msgId), MTP_long(randomId))); // ignore real date
|
||||
App::feedMessageMedia(msgId, *msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1236,12 +1239,14 @@ void MainWidget::sentFullDataReceived(uint64 randomId, const MTPmessages_StatedM
|
|||
case mtpc_messages_statedMessage: {
|
||||
const MTPDmessages_statedMessage &d(result.c_messages_statedMessage());
|
||||
|
||||
App::feedChats(d.vchats);
|
||||
App::feedUsers(d.vusers);
|
||||
if (msg && msgId) {
|
||||
App::feedMessageMedia(msgId, *msg);
|
||||
}
|
||||
if (updInited && d.vseq.v) {
|
||||
if (d.vseq.v <= updSeq || d.vseq.v > updSeq + 1) return getDifference();
|
||||
}
|
||||
|
||||
App::feedChats(d.vchats);
|
||||
App::feedUsers(d.vusers);
|
||||
if (!randomId) {
|
||||
feedUpdate(MTP_updateNewMessage(d.vmessage, d.vpts));
|
||||
}
|
||||
|
@ -1253,12 +1258,14 @@ void MainWidget::sentFullDataReceived(uint64 randomId, const MTPmessages_StatedM
|
|||
case mtpc_messages_statedMessageLink: {
|
||||
const MTPDmessages_statedMessageLink &d(result.c_messages_statedMessageLink());
|
||||
|
||||
App::feedChats(d.vchats);
|
||||
App::feedUsers(d.vusers);
|
||||
if (msg && msgId) {
|
||||
App::feedMessageMedia(msgId, *msg);
|
||||
}
|
||||
if (updInited && d.vseq.v) {
|
||||
if (d.vseq.v <= updSeq || d.vseq.v > updSeq + 1) return getDifference();
|
||||
}
|
||||
|
||||
App::feedChats(d.vchats);
|
||||
App::feedUsers(d.vusers);
|
||||
if (!randomId) {
|
||||
feedUpdate(MTP_updateNewMessage(d.vmessage, d.vpts));
|
||||
}
|
||||
|
|
|
@ -213,6 +213,7 @@ public:
|
|||
void showBackFromStack();
|
||||
QRect historyRect() const;
|
||||
|
||||
void confirmShareContact(const QString &phone, const QString &fname, const QString &lname);
|
||||
void confirmSendImage(const ReadyLocalMedia &img);
|
||||
void confirmSendImageUncompressed();
|
||||
void cancelSendImage();
|
||||
|
|
|
@ -62,7 +62,7 @@ ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const Pee
|
|||
_selectedRow(-1), _lastPreload(0), _contactId(0),
|
||||
_kickOver(0), _kickDown(0), _kickConfirm(0),
|
||||
|
||||
_loadingId(0) {
|
||||
_loadingId(0), _menu(0) {
|
||||
|
||||
if (_peerUser) {
|
||||
_phoneText = _peerUser->phone.isEmpty() ? QString() : App::formatPhone(_peerUser->phone);
|
||||
|
@ -703,6 +703,31 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
|
|||
}
|
||||
|
||||
void ProfileInner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (_menu) {
|
||||
_menu->deleteLater();
|
||||
_menu = 0;
|
||||
}
|
||||
if (!_phoneText.isEmpty()) {
|
||||
QRect info(_left + st::profilePhotoSize + st::profilePhoneLeft, st::profilePadding.top(), _width - st::profilePhotoSize - st::profilePhoneLeft, st::profilePhotoSize);
|
||||
if (info.contains(mapFromGlobal(e->globalPos()))) {
|
||||
_menu = new QMenu(this);
|
||||
_menu->addAction(lang(lng_profile_copy_phone), this, SLOT(onCopyPhone()))->setEnabled(true);
|
||||
_menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroy(QObject*)));
|
||||
_menu->popup(e->globalPos());
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileInner::onMenuDestroy(QObject *obj) {
|
||||
if (_menu == obj) {
|
||||
_menu = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileInner::onCopyPhone() {
|
||||
QApplication::clipboard()->setText(_phoneText);
|
||||
}
|
||||
|
||||
bool ProfileInner::animStep(float64 ms) {
|
||||
|
|
|
@ -89,6 +89,9 @@ public slots:
|
|||
void onMediaDocuments();
|
||||
void onMediaAudios();
|
||||
|
||||
void onMenuDestroy(QObject *obj);
|
||||
void onCopyPhone();
|
||||
|
||||
private:
|
||||
|
||||
void showAll();
|
||||
|
@ -148,7 +151,8 @@ private:
|
|||
|
||||
QPoint _lastPos;
|
||||
|
||||
QString _onlineText;
|
||||
QString _onlineText;
|
||||
QMenu *_menu;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue