Commit 084cd165 authored by Eike Ziller's avatar Eike Ziller

Fix OS X file drops from Finder

This is a workaround for QTBUG-40449.

Change-Id: I24a3bfb78d49e94dcafb99ee6d6b36ef4c4299c5
Task-number: QTBUG-40449
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent ecd9c4c8
......@@ -57,6 +57,15 @@ QDebug operator<<(QDebug dbg, const Utils::FileName &c)
QT_END_NAMESPACE
#ifdef Q_OS_OSX
// for file drops from Finder, working around QTBUG-40449
namespace Utils {
namespace Internal {
extern QUrl filePathUrl(const QUrl &url);
} // Internal
} // Utils
#endif
namespace Utils {
/*! \class Utils::FileUtils
......@@ -743,7 +752,12 @@ static bool isFileDrop(const QMimeData *d, QList<FileDropSupport::FileSpec> *fil
bool hasFiles = false;
const QList<QUrl>::const_iterator cend = urls.constEnd();
for (QList<QUrl>::const_iterator it = urls.constBegin(); it != cend; ++it) {
const QString fileName = it->toLocalFile();
QUrl url = *it;
#ifdef Q_OS_OSX
// for file drops from Finder, working around QTBUG-40449
url = Internal::filePathUrl(url);
#endif
const QString fileName = url.toLocalFile();
if (!fileName.isEmpty()) {
hasFiles = true;
if (files)
......
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://www.qt.io/licensing. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include <QUrl>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSURL.h>
namespace Utils {
namespace Internal {
QUrl filePathUrl(const QUrl &url)
{
QUrl ret = url;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL *nsurl = url.toNSURL();
if ([nsurl isFileReferenceURL])
ret = QUrl::fromNSURL([nsurl filePathURL]);
[pool release];
return ret;
}
} // Internal
} // Utils
......@@ -200,3 +200,9 @@ FORMS += $$PWD/filewizardpage.ui \
$$PWD/proxycredentialsdialog.ui
RESOURCES += $$PWD/utils.qrc
osx {
OBJECTIVE_SOURCES += \
$$PWD/fileutils_mac.mm
LIBS += -framework Foundation
}
......@@ -18,6 +18,10 @@ QtcLibrary {
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("osx")
cpp.dynamicLibraries: ["X11"]
}
Properties {
condition: qbs.targetOS.contains("osx")
cpp.frameworks: ["Foundation"]
}
Depends { name: "Qt"; submodules: ["widgets", "network", "script", "concurrent"] }
Depends { name: "app_version_header" }
......@@ -244,6 +248,14 @@ QtcLibrary {
]
}
Group {
name: "FileUtils_osx"
condition: qbs.targetOS.contains("osx")
files: [
"fileutils_mac.mm",
]
}
Export {
Depends { name: "Qt"; submodules: ["concurrent", "widgets" ] }
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment