diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 4424995a71..3273af203a 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -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); diff --git a/Telegram/SourceFiles/boxes/photosendbox.cpp b/Telegram/SourceFiles/boxes/photosendbox.cpp index 09305a1ecd..064a717e37 100644 --- a/Telegram/SourceFiles/boxes/photosendbox.cpp +++ b/Telegram/SourceFiles/boxes/photosendbox.cpp @@ -209,7 +209,8 @@ void PhotoSendBox::onSend(bool ctrlShiftEnter) { App::writeUserConfig(); } if (_compressed.isHidden() || _compressed.checked()) { - if (App::main()) App::main()->confirmSendImage(ctrlShiftEnter, *_img); + _img->ctrlShiftEnter = ctrlShiftEnter; + if (App::main()) App::main()->confirmSendImage(*_img); } else { if (App::main()) App::main()->confirmSendImageUncompressed(ctrlShiftEnter); } diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 00bbc977e2..64d30d34ca 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -2746,7 +2746,7 @@ void HistoryWidget::uploadConfirmImageUncompressed(bool ctrlShiftEnter) { if (confirmWithText) { onSend(ctrlShiftEnter); } - imageLoader.append(confirmImage, peerId, ToPrepareDocument); + imageLoader.append(confirmImage, peerId, ToPrepareDocument, ctrlShiftEnter); confirmImageId = 0; confirmWithText = false; confirmImage = QImage(); @@ -2774,7 +2774,7 @@ void HistoryWidget::onPhotoReady() { if (i->id == confirmImageId) { App::wnd()->showLayer(new PhotoSendBox(*i)); } else { - confirmSendImage(false, *i); + confirmSendImage(*i); } } list.clear(); @@ -2798,10 +2798,10 @@ void HistoryWidget::confirmShareContact(bool ctrlShiftEnter, const QString &phon shareContact(peerId, phone, fname, lname); } -void HistoryWidget::confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img) { +void HistoryWidget::confirmSendImage(const ReadyLocalMedia &img) { if (img.id == confirmImageId) { if (confirmWithText) { - onSend(ctrlShiftEnter); + onSend(img.ctrlShiftEnter); } confirmImageId = 0; confirmWithText = false; diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 963bbf1acb..a8bb845033 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -292,7 +292,7 @@ public: void uploadMedias(const QStringList &files, ToPrepareMediaType type); void uploadMedia(const QByteArray &fileContent, ToPrepareMediaType type); void confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname); - void confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img); + void confirmSendImage(const ReadyLocalMedia &img); void cancelSendImage(); void checkUnreadLoaded(bool checkOnlyShow = false); diff --git a/Telegram/SourceFiles/localimageloader.cpp b/Telegram/SourceFiles/localimageloader.cpp index 07c6b73f9d..85a333db5d 100644 --- a/Telegram/SourceFiles/localimageloader.cpp +++ b/Telegram/SourceFiles/localimageloader.cpp @@ -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) { diff --git a/Telegram/SourceFiles/localimageloader.h b/Telegram/SourceFiles/localimageloader.h index ff5449ecd6..7d7957195e 100644 --- a/Telegram/SourceFiles/localimageloader.h +++ b/Telegram/SourceFiles/localimageloader.h @@ -25,11 +25,11 @@ enum ToPrepareMediaType { }; struct ToPrepareMedia { - ToPrepareMedia(const QString &file, const PeerId &peer, ToPrepareMediaType t) : id(MTP::nonce()), file(file), peer(peer), type(t) { + ToPrepareMedia(const QString &file, const PeerId &peer, ToPrepareMediaType t, bool ctrlShiftEnter) : id(MTP::nonce()), file(file), peer(peer), type(t), ctrlShiftEnter(ctrlShiftEnter) { } - ToPrepareMedia(const QImage &img, const PeerId &peer, ToPrepareMediaType t) : id(MTP::nonce()), img(img), peer(peer), type(t) { + ToPrepareMedia(const QImage &img, const PeerId &peer, ToPrepareMediaType t, bool ctrlShiftEnter) : id(MTP::nonce()), img(img), peer(peer), type(t), ctrlShiftEnter(ctrlShiftEnter) { } - ToPrepareMedia(const QByteArray &data, const PeerId &peer, ToPrepareMediaType t) : id(MTP::nonce()), data(data), peer(peer), type(t) { + ToPrepareMedia(const QByteArray &data, const PeerId &peer, ToPrepareMediaType t, bool ctrlShiftEnter) : id(MTP::nonce()), 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 ToPrepareMedias; typedef QMap 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 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(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 615cfa5ee5..5bab3a1dfa 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -985,8 +985,8 @@ void MainWidget::confirmShareContact(bool ctrlShiftEnter, const QString &phone, history.confirmShareContact(ctrlShiftEnter, phone, fname, lname); } -void MainWidget::confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img) { - history.confirmSendImage(ctrlShiftEnter, img); +void MainWidget::confirmSendImage(const ReadyLocalMedia &img) { + history.confirmSendImage(img); } void MainWidget::confirmSendImageUncompressed(bool ctrlShiftEnter) { diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 7bdeedf124..182534ad5b 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -214,7 +214,7 @@ public: QRect historyRect() const; void confirmShareContact(bool ctrlShiftEnter, const QString &phone, const QString &fname, const QString &lname); - void confirmSendImage(bool ctrlShiftEnter, const ReadyLocalMedia &img); + void confirmSendImage(const ReadyLocalMedia &img); void confirmSendImageUncompressed(bool ctrlShiftEnter); void cancelSendImage(); diff --git a/Telegram/SourceFiles/pspecific_mac_p.mm b/Telegram/SourceFiles/pspecific_mac_p.mm index ff16dfe171..9e310fba2e 100644 --- a/Telegram/SourceFiles/pspecific_mac_p.mm +++ b/Telegram/SourceFiles/pspecific_mac_p.mm @@ -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]); }