2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

some template send improvements

This commit is contained in:
John Preston
2014-10-17 22:32:34 +04:00
parent 21a7e0243c
commit b35b3bcb87
6 changed files with 45 additions and 35 deletions

View File

@@ -2282,25 +2282,28 @@ 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));
shareContact(peer, contact->phone, contact->firstName, contact->lastName, int32(contact->id & 0xFFFFFFFF));
}
void HistoryWidget::shareContact(const QString &phone, const QString &fname, const QString &lname, int32 userId) {
App::main()->readServerHistory(hist, false);
void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const QString &fname, const QString &lname, int32 userId) {
History *h = App::history(peer);
App::main()->readServerHistory(h, false);
uint64 randomId = MTP::nonce<uint64>();
MsgId newId = clientMsgId();
hist->loadAround(0);
h->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(phone), MTP_string(fname), MTP_string(lname), MTP_int(userId))));
h->addToBack(MTP_message(MTP_int(newId), MTP_int(MTP::authedId()), App::peerToMTP(peer), 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(phone), MTP_string(fname), MTP_string(lname)), MTP_long(randomId)), App::main()->rpcDone(&MainWidget::sentFullDataReceived, randomId));
MTP::send(MTPmessages_SendMedia(App::peer(peer)->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);
if (hist && histPeer && peer == histPeer->id) {
App::main()->historyToDown(hist);
}
App::main()->dialogsToUp();
peerMessagesUpdated();
peerMessagesUpdated(peer);
}
void HistoryWidget::onSendPaths(const PeerId &peer) {
@@ -2735,11 +2738,15 @@ void HistoryWidget::shareContactConfirmation(const QString &phone, const QString
App::wnd()->showLayer(new PhotoSendBox(phone, fname, lname));
}
void HistoryWidget::uploadConfirmImageUncompressed() {
void HistoryWidget::uploadConfirmImageUncompressed(bool ctrlShiftEnter) {
if (!hist || !confirmImageId || confirmImage.isNull()) return;
App::wnd()->activateWindow();
imageLoader.append(confirmImage, histPeer->id, ToPrepareDocument);
PeerId peerId = histPeer->id;
if (confirmWithText) {
onSend(ctrlShiftEnter);
}
imageLoader.append(confirmImage, peerId, ToPrepareDocument);
confirmImageId = 0;
confirmWithText = false;
confirmImage = QImage();
@@ -2767,7 +2774,7 @@ void HistoryWidget::onPhotoReady() {
if (i->id == confirmImageId) {
App::wnd()->showLayer(new PhotoSendBox(*i));
} else {
confirmSendImage(*i);
confirmSendImage(false, *i);
}
}
list.clear();
@@ -2776,22 +2783,25 @@ void HistoryWidget::onPhotoReady() {
void HistoryWidget::onPhotoFailed(quint64 id) {
}
void HistoryWidget::confirmShareContact(const QString &phone, const QString &fname, const QString &lname) {
void HistoryWidget::confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname) {
if (!histPeer) return;
PeerId peerId = histPeer->id;
if (0xFFFFFFFFFFFFFFFFL == confirmImageId) {
if (confirmWithText) {
onSend();
onSend(ctrlShiftEnter);
}
confirmImageId = 0;
confirmWithText = false;
confirmImage = QImage();
}
shareContact(phone, fname, lname);
shareContact(peerId, phone, fname, lname);
}
void HistoryWidget::confirmSendImage(const ReadyLocalMedia &img) {
void HistoryWidget::confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img) {
if (img.id == confirmImageId) {
if (confirmWithText) {
onSend();
onSend(ctrlShiftEnter);
}
confirmImageId = 0;
confirmWithText = false;