mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-21 23:57:38 +00:00
Merge branch 'master' of https://github.com/telegramdesktop/tdesktop
This commit is contained in:
commit
3daa74ff27
@ -406,7 +406,7 @@ void Application::uploadProfilePhoto(const QImage &tosend, const PeerId &peerId)
|
||||
int32 filesize = 0;
|
||||
QByteArray data;
|
||||
|
||||
ReadyLocalMedia ready(ToPreparePhoto, file, filename, filesize, data, id, id, peerId, photo, photoThumbs, MTP_documentEmpty(MTP_long(0)), jpeg);
|
||||
ReadyLocalMedia ready(ToPreparePhoto, file, filename, filesize, data, id, id, peerId, photo, photoThumbs, MTP_documentEmpty(MTP_long(0)), jpeg, false);
|
||||
|
||||
connect(App::uploader(), SIGNAL(photoReady(MsgId, const MTPInputFile &)), App::app(), SLOT(photoUpdated(MsgId, const MTPInputFile &)), Qt::UniqueConnection);
|
||||
|
||||
|
@ -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,19 @@ 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()) {
|
||||
_img->ctrlShiftEnter = ctrlShiftEnter;
|
||||
if (App::main()) App::main()->confirmSendImage(*_img);
|
||||
} else {
|
||||
if (App::main()) App::main()->confirmSendImageUncompressed();
|
||||
if (App::main()) App::main()->confirmSendImageUncompressed(ctrlShiftEnter);
|
||||
}
|
||||
}
|
||||
emit closed();
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
public slots:
|
||||
|
||||
void onSend();
|
||||
void onSend(bool ctrlShiftEnter = false);
|
||||
void onCancel();
|
||||
|
||||
private:
|
||||
|
@ -2235,7 +2235,7 @@ mtpRequestId HistoryWidget::onForward(const PeerId &peer, SelectedItemSet toForw
|
||||
|
||||
hist->loadAround(0);
|
||||
if (item->id > 0 && msg) {
|
||||
App::main()->readServerHistory(item->history(), false);
|
||||
App::main()->readServerHistory(hist, false);
|
||||
|
||||
newId = clientMsgId();
|
||||
hist->addToBackForwarded(newId, msg);
|
||||
@ -2244,7 +2244,7 @@ mtpRequestId HistoryWidget::onForward(const PeerId &peer, SelectedItemSet toForw
|
||||
// newId = clientMsgId();
|
||||
// MTP::send(MTPmessages_ForwardMessage(histPeer->input, MTP_int(item->id), MTP_long(randomId)), App::main()->rpcDone(&MainWidget::sentFullDataReceived, randomId));
|
||||
} else if (msg) {
|
||||
App::main()->readServerHistory(item->history(), false);
|
||||
App::main()->readServerHistory(hist, false);
|
||||
|
||||
newId = clientMsgId();
|
||||
|
||||
@ -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, ctrlShiftEnter);
|
||||
confirmImageId = 0;
|
||||
confirmWithText = false;
|
||||
confirmImage = QImage();
|
||||
@ -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) {
|
||||
if (img.id == confirmImageId) {
|
||||
if (confirmWithText) {
|
||||
onSend();
|
||||
onSend(img.ctrlShiftEnter);
|
||||
}
|
||||
confirmImageId = 0;
|
||||
confirmWithText = false;
|
||||
|
@ -288,10 +288,10 @@ 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 confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname);
|
||||
void confirmSendImage(const ReadyLocalMedia &img);
|
||||
void cancelSendImage();
|
||||
|
||||
@ -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;
|
||||
|
@ -38,6 +38,7 @@ void LocalImageLoaderPrivate::prepareImages() {
|
||||
PeerId peer;
|
||||
uint64 id, jpeg_id = 0;
|
||||
ToPrepareMediaType type;
|
||||
bool ctrlShiftEnter = false;
|
||||
{
|
||||
QMutexLocker lock(loader->toPrepareMutex());
|
||||
ToPrepareMedias &list(loader->toPrepareMedias());
|
||||
@ -49,6 +50,7 @@ void LocalImageLoaderPrivate::prepareImages() {
|
||||
peer = list.front().peer;
|
||||
id = list.front().id;
|
||||
type = list.front().type;
|
||||
ctrlShiftEnter = list.front().ctrlShiftEnter;
|
||||
}
|
||||
|
||||
if (img.isNull()) {
|
||||
@ -182,7 +184,7 @@ void LocalImageLoaderPrivate::prepareImages() {
|
||||
|
||||
{
|
||||
QMutexLocker lock(loader->readyMutex());
|
||||
loader->readyList().push_back(ReadyLocalMedia(type, file, filename, filesize, data, id, jpeg_id, peer, photo, photoThumbs, document, jpeg));
|
||||
loader->readyList().push_back(ReadyLocalMedia(type, file, filename, filesize, data, id, jpeg_id, peer, photo, photoThumbs, document, jpeg, ctrlShiftEnter));
|
||||
}
|
||||
|
||||
{
|
||||
@ -208,7 +210,7 @@ void LocalImageLoader::append(const QStringList &files, const PeerId &peer, ToPr
|
||||
{
|
||||
QMutexLocker lock(toPrepareMutex());
|
||||
for (QStringList::const_iterator i = files.cbegin(), e = files.cend(); i != e; ++i) {
|
||||
toPrepare.push_back(ToPrepareMedia(*i, peer, t));
|
||||
toPrepare.push_back(ToPrepareMedia(*i, peer, t, false));
|
||||
}
|
||||
}
|
||||
if (!thread) {
|
||||
@ -223,7 +225,7 @@ PhotoId LocalImageLoader::append(const QByteArray &img, const PeerId &peer, ToPr
|
||||
PhotoId result = 0;
|
||||
{
|
||||
QMutexLocker lock(toPrepareMutex());
|
||||
toPrepare.push_back(ToPrepareMedia(img, peer, t));
|
||||
toPrepare.push_back(ToPrepareMedia(img, peer, t, false));
|
||||
result = toPrepare.back().id;
|
||||
}
|
||||
if (!thread) {
|
||||
@ -235,11 +237,11 @@ PhotoId LocalImageLoader::append(const QByteArray &img, const PeerId &peer, ToPr
|
||||
return result;
|
||||
}
|
||||
|
||||
PhotoId LocalImageLoader::append(const QImage &img, const PeerId &peer, ToPrepareMediaType t) {
|
||||
PhotoId LocalImageLoader::append(const QImage &img, const PeerId &peer, ToPrepareMediaType t, bool ctrlShiftEnter) {
|
||||
PhotoId result = 0;
|
||||
{
|
||||
QMutexLocker lock(toPrepareMutex());
|
||||
toPrepare.push_back(ToPrepareMedia(img, peer, t));
|
||||
toPrepare.push_back(ToPrepareMedia(img, peer, t, ctrlShiftEnter));
|
||||
result = toPrepare.back().id;
|
||||
}
|
||||
if (!thread) {
|
||||
@ -255,7 +257,7 @@ PhotoId LocalImageLoader::append(const QString &file, const PeerId &peer, ToPrep
|
||||
PhotoId result = 0;
|
||||
{
|
||||
QMutexLocker lock(toPrepareMutex());
|
||||
toPrepare.push_back(ToPrepareMedia(file, peer, t));
|
||||
toPrepare.push_back(ToPrepareMedia(file, peer, t, false));
|
||||
result = toPrepare.back().id;
|
||||
}
|
||||
if (!thread) {
|
||||
|
@ -25,11 +25,11 @@ enum ToPrepareMediaType {
|
||||
};
|
||||
|
||||
struct ToPrepareMedia {
|
||||
ToPrepareMedia(const QString &file, const PeerId &peer, ToPrepareMediaType t) : id(MTP::nonce<PhotoId>()), file(file), peer(peer), type(t) {
|
||||
ToPrepareMedia(const QString &file, const PeerId &peer, ToPrepareMediaType t, bool ctrlShiftEnter) : id(MTP::nonce<PhotoId>()), file(file), peer(peer), type(t), ctrlShiftEnter(ctrlShiftEnter) {
|
||||
}
|
||||
ToPrepareMedia(const QImage &img, const PeerId &peer, ToPrepareMediaType t) : id(MTP::nonce<PhotoId>()), img(img), peer(peer), type(t) {
|
||||
ToPrepareMedia(const QImage &img, const PeerId &peer, ToPrepareMediaType t, bool ctrlShiftEnter) : id(MTP::nonce<PhotoId>()), img(img), peer(peer), type(t), ctrlShiftEnter(ctrlShiftEnter) {
|
||||
}
|
||||
ToPrepareMedia(const QByteArray &data, const PeerId &peer, ToPrepareMediaType t) : id(MTP::nonce<PhotoId>()), data(data), peer(peer), type(t) {
|
||||
ToPrepareMedia(const QByteArray &data, const PeerId &peer, ToPrepareMediaType t, bool ctrlShiftEnter) : id(MTP::nonce<PhotoId>()), data(data), peer(peer), type(t), ctrlShiftEnter(ctrlShiftEnter) {
|
||||
}
|
||||
PhotoId id;
|
||||
QString file;
|
||||
@ -37,13 +37,14 @@ struct ToPrepareMedia {
|
||||
QByteArray data;
|
||||
PeerId peer;
|
||||
ToPrepareMediaType type;
|
||||
bool ctrlShiftEnter;
|
||||
};
|
||||
typedef QList<ToPrepareMedia> ToPrepareMedias;
|
||||
|
||||
typedef QMap<int32, QByteArray> LocalFileParts;
|
||||
struct ReadyLocalMedia {
|
||||
ReadyLocalMedia(ToPrepareMediaType type, const QString &file, const QString &filename, int32 filesize, const QByteArray &data, const uint64 &id, const uint64 &jpeg_id, const PeerId &peer, const MTPPhoto &photo, const PreparedPhotoThumbs &photoThumbs, const MTPDocument &document, const QByteArray &jpeg) :
|
||||
type(type), file(file), filename(filename), filesize(filesize), data(data), id(id), jpeg_id(jpeg_id), peer(peer), photo(photo), document(document), photoThumbs(photoThumbs) {
|
||||
ReadyLocalMedia(ToPrepareMediaType type, const QString &file, const QString &filename, int32 filesize, const QByteArray &data, const uint64 &id, const uint64 &jpeg_id, const PeerId &peer, const MTPPhoto &photo, const PreparedPhotoThumbs &photoThumbs, const MTPDocument &document, const QByteArray &jpeg, bool ctrlShiftEnter) :
|
||||
type(type), file(file), filename(filename), filesize(filesize), data(data), id(id), jpeg_id(jpeg_id), peer(peer), photo(photo), document(document), photoThumbs(photoThumbs), ctrlShiftEnter(ctrlShiftEnter) {
|
||||
if (!jpeg.isEmpty()) {
|
||||
int32 size = jpeg.size();
|
||||
for (int32 i = 0, part = 0; i < size; i += UploadPartSize, ++part) {
|
||||
@ -65,6 +66,8 @@ struct ReadyLocalMedia {
|
||||
PreparedPhotoThumbs photoThumbs;
|
||||
LocalFileParts parts;
|
||||
QByteArray jpeg_md5;
|
||||
|
||||
bool ctrlShiftEnter;
|
||||
};
|
||||
typedef QList<ReadyLocalMedia> ReadyLocalMedias;
|
||||
|
||||
@ -101,7 +104,7 @@ public:
|
||||
LocalImageLoader(QObject *parent);
|
||||
void append(const QStringList &files, const PeerId &peer, ToPrepareMediaType t = ToPrepareAuto);
|
||||
PhotoId append(const QByteArray &img, const PeerId &peer, ToPrepareMediaType t = ToPrepareAuto);
|
||||
PhotoId append(const QImage &img, const PeerId &peer, ToPrepareMediaType t = ToPreparePhoto);
|
||||
PhotoId append(const QImage &img, const PeerId &peer, ToPrepareMediaType t = ToPreparePhoto, bool ctrlShiftEnter = false);
|
||||
PhotoId append(const QString &file, const PeerId &peer, ToPrepareMediaType t = ToPrepareAuto);
|
||||
|
||||
QMutex *readyMutex();
|
||||
|
@ -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::confirmSendImageUncompressed() {
|
||||
history.uploadConfirmImageUncompressed();
|
||||
void MainWidget::confirmSendImageUncompressed(bool ctrlShiftEnter) {
|
||||
history.uploadConfirmImageUncompressed(ctrlShiftEnter);
|
||||
}
|
||||
|
||||
void MainWidget::cancelSendImage() {
|
||||
|
@ -213,9 +213,9 @@ public:
|
||||
void showBackFromStack();
|
||||
QRect historyRect() const;
|
||||
|
||||
void confirmShareContact(const QString &phone, const QString &fname, const QString &lname);
|
||||
void confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname);
|
||||
void confirmSendImage(const ReadyLocalMedia &img);
|
||||
void confirmSendImageUncompressed();
|
||||
void confirmSendImageUncompressed(bool ctrlShiftEnter);
|
||||
void cancelSendImage();
|
||||
|
||||
void destroyData();
|
||||
|
@ -709,10 +709,9 @@ QString objc_currentLang() {
|
||||
}
|
||||
|
||||
QString objc_convertFileUrl(const QString &url) {
|
||||
NSString *nsurl = [[[NSURL URLWithString: [NSString stringWithUTF8String: (qsl("file://") + url).toUtf8().constData()]] filePathURL] absoluteString];
|
||||
NSString *nsurl = [[[NSURL URLWithString: [NSString stringWithUTF8String: (qsl("file://") + url).toUtf8().constData()]] filePathURL] path];
|
||||
if (!nsurl) return QString();
|
||||
|
||||
QString result = QString::fromUtf8([nsurl cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
return result.startsWith(qsl("file://")) ? result.mid(7) : result;
|
||||
return QString::fromUtf8([nsurl cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ CONFIG += precompile_header
|
||||
|
||||
PRECOMPILED_HEADER = ./SourceFiles/stdafx.h
|
||||
|
||||
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter -Wno-unused-variable -Wno-switch -Wno-comment -Wno-unused-but-set-variable
|
||||
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-result -Wno-unused-parameter -Wno-unused-variable -Wno-switch -Wno-comment -Wno-unused-but-set-variable
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||
|
Loading…
Reference in New Issue
Block a user