fixed os x 10.10 dragndrop

This commit is contained in:
John Preston 2014-10-17 23:14:42 +04:00
parent b35b3bcb87
commit ebe9b4f80f
9 changed files with 30 additions and 25 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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) {

View File

@ -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();

View File

@ -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) {

View File

@ -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();

View File

@ -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]);
}