Index: app/CMakeLists.txt =================================================================== --- app/CMakeLists.txt +++ app/CMakeLists.txt @@ -29,6 +29,24 @@ KF5::KIOFileWidgets KF5::Parts) +# we provide our own Info.plist containing a simple "we open anything" instruction. +if(APPLE) + # own plist template + set_target_properties (ark PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in) + + # the MacOSX bundle display name property (CFBundleDisplayName) is not currently supported by cmake, + # so has to be set for all targets in this cmake file + set(MACOSX_BUNDLE_DISPLAY_NAME Ark) + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Ark") + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Ark") + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_DISPLAY_NAME "Ark") + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_INFO_STRING "Ark - KDE Archiving Tool") + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_LONG_VERSION_STRING "Ark ${KDE_APPLICATIONS_VERSION}") + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING "${KDE_APPLICATIONS_VERSION}") + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_BUNDLE_VERSION "${KDE_APPLICATIONS_VERSION}") + set_target_properties(ark PROPERTIES MACOSX_BUNDLE_COPYRIGHT "1997-2017, The Ark Developers") +endif() + # Remove duplicate mimetypes from list of supported formats. list(REMOVE_DUPLICATES SUPPORTED_ARK_MIMETYPES) Index: app/MacOSXBundleInfo.plist.in =================================================================== --- /dev/null +++ app/MacOSXBundleInfo.plist.in @@ -0,0 +1,55 @@ + + + + + NSPrincipalClass + NSApplication + NSHighResolutionCapable + True + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + LSRequiresCarbon + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + LSMultipleInstancesProhibited + + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + * + + CFBundleTypeName + NSStringPboardType + CFBundleTypeRole + Editor + + + + Index: app/main.cpp =================================================================== --- app/main.cpp +++ app/main.cpp @@ -31,6 +31,9 @@ #include #include #include +#ifdef Q_OS_MACOS +#include +#endif #include #include @@ -40,6 +43,35 @@ using Kerfuffle::AddToArchive; +class OpenFileEventHandler : public QObject +{ + Q_OBJECT +public: + OpenFileEventHandler(QApplication *parent, MainWindow *w) + : QObject(parent) + , m_window(w) + { +#ifdef Q_OS_MACOS + parent->installEventFilter(this); +#endif + } + + bool eventFilter(QObject *obj, QEvent *event) override + { +#ifdef Q_OS_MACOS + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent *openEvent = static_cast(event); + qCDebug(ARK) << "File open event:" << openEvent->url() << "for window" << m_window; + m_window->openUrl(openEvent->url()); + return true; + } +#endif + return QObject::eventFilter(obj, event); + } +private: + MainWindow *m_window; +}; + int main(int argc, char **argv) { QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); // Required for the webengine part. @@ -127,7 +159,7 @@ QStringLiteral("http://littlesvr.ca/misc/contactandrew.php")); KAboutData::setApplicationData(aboutData); - application.setWindowIcon(QIcon::fromTheme(QStringLiteral("ark"))); + application.setWindowIcon(QIcon::fromTheme(QStringLiteral("ark"), application.windowIcon())); QCommandLineParser parser; parser.addHelpOption(); @@ -293,10 +325,20 @@ } window->openUrl(QUrl::fromUserInput(urls.at(0), QString(), QUrl::AssumeLocalFile)); } +#ifdef Q_OS_MACOS + volatile const OpenFileEventHandler *openFileEventHandler = new OpenFileEventHandler(&application, window); + Q_UNUSED(openFileEventHandler); + // we don't provide a fullscreen mode + window->setWindowFlags(window->windowFlags() & ~Qt::WindowFullscreenButtonHint); +#endif window->show(); } } qCDebug(ARK) << "Entering application loop"; return application.exec(); } + +#ifdef Q_OS_MACOS +#include "main.moc" +#endif Index: kerfuffle/pluginmanager.cpp =================================================================== --- kerfuffle/pluginmanager.cpp +++ kerfuffle/pluginmanager.cpp @@ -271,17 +271,27 @@ // Step 2: ldd the libarchive plugin to figure out the absolute libarchive path. QProcess ldd; +#ifdef Q_OS_MACOS + QRegularExpression regex(QStringLiteral("/.*/libarchive.*.dylib")); + ldd.start(QStringLiteral("otool"), {QStringLiteral("-L"), pluginPath}); +#else + QRegularExpression regex(QStringLiteral("/.*/libarchive.so")); ldd.start(QStringLiteral("ldd"), {pluginPath}); +#endif ldd.waitForFinished(); const QString output = QString::fromUtf8(ldd.readAllStandardOutput()); - QRegularExpression regex(QStringLiteral("/.*/libarchive.so")); if (!regex.match(output).hasMatch()) { return false; } // Step 3: check whether libarchive links against liblzo. const QString libarchivePath = regex.match(output).captured(0); +#ifdef Q_OS_MACOS + qCDebug(ARK) << Q_FUNC_INFO << "libarchivePath=" << libarchivePath; + ldd.start(QStringLiteral("otool"), {QStringLiteral("-L"), libarchivePath}); +#else ldd.start(QStringLiteral("ldd"), {libarchivePath}); +#endif ldd.waitForFinished(); return ldd.readAllStandardOutput().contains(QByteArrayLiteral("lzo")); }