diff --git a/Telegram/SourceFiles/boxes/photosendbox.cpp b/Telegram/SourceFiles/boxes/photosendbox.cpp index ad45e6584..09305a1ec 100644 --- a/Telegram/SourceFiles/boxes/photosendbox.cpp +++ b/Telegram/SourceFiles/boxes/photosendbox.cpp @@ -119,7 +119,7 @@ a_opacity(0, 1) { void PhotoSendBox::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { - onSend(); + onSend((e->modifiers().testFlag(Qt::ControlModifier) || e->modifiers().testFlag(Qt::MetaModifier)) && e->modifiers().testFlag(Qt::ShiftModifier)); } else if (e->key() == Qt::Key_Escape) { onCancel(); } @@ -200,18 +200,18 @@ void PhotoSendBox::animStep(float64 ms) { update(); } -void PhotoSendBox::onSend() { +void PhotoSendBox::onSend(bool ctrlShiftEnter) { if (!_img) { - if (App::main()) App::main()->confirmShareContact(_phone, _fname, _lname); + if (App::main()) App::main()->confirmShareContact(ctrlShiftEnter, _phone, _fname, _lname); } else { if (!_compressed.isHidden()) { cSetCompressPastedImage(_compressed.checked()); App::writeUserConfig(); } if (_compressed.isHidden() || _compressed.checked()) { - if (App::main()) App::main()->confirmSendImage(*_img); + if (App::main()) App::main()->confirmSendImage(ctrlShiftEnter, *_img); } else { - if (App::main()) App::main()->confirmSendImageUncompressed(); + if (App::main()) App::main()->confirmSendImageUncompressed(ctrlShiftEnter); } } emit closed(); diff --git a/Telegram/SourceFiles/boxes/photosendbox.h b/Telegram/SourceFiles/boxes/photosendbox.h index b350089cf..a219e827a 100644 --- a/Telegram/SourceFiles/boxes/photosendbox.h +++ b/Telegram/SourceFiles/boxes/photosendbox.h @@ -36,7 +36,7 @@ public: public slots: - void onSend(); + void onSend(bool ctrlShiftEnter = false); void onCancel(); private: diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 7ae355028..00bbc977e 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -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(); 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; diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index a5335354a..963bbf1ac 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -288,11 +288,11 @@ public: 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 uploadConfirmImageUncompressed(bool ctrlShiftEnter); 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 confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname); + void confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img); void cancelSendImage(); void checkUnreadLoaded(bool checkOnlyShow = false); @@ -304,7 +304,7 @@ 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); + void shareContact(const PeerId &peer, const QString &phone, const QString &fname, const QString &lname, int32 userId = 0); PeerData *peer() const; PeerData *activePeer() const; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 0b88d5cd4..615cfa5ee 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -981,16 +981,16 @@ 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::confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname) { + history.confirmShareContact(ctrlShiftEnter, phone, fname, lname); } -void MainWidget::confirmSendImage(const ReadyLocalMedia &img) { - history.confirmSendImage(img); +void MainWidget::confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img) { + history.confirmSendImage(ctrlShiftEnter, img); } -void MainWidget::confirmSendImageUncompressed() { - history.uploadConfirmImageUncompressed(); +void MainWidget::confirmSendImageUncompressed(bool ctrlShiftEnter) { + history.uploadConfirmImageUncompressed(ctrlShiftEnter); } void MainWidget::cancelSendImage() { diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 1a147fbf8..7bdeedf12 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -213,9 +213,9 @@ 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 confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname); + void confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img); + void confirmSendImageUncompressed(bool ctrlShiftEnter); void cancelSendImage(); void destroyData();