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,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,31 @@ using Kerfuffle::AddToArchive; +class OpenFileEventHandler : public QObject +{ + Q_OBJECT +public: + OpenFileEventHandler(QApplication *parent, MainWindow *w) + : QObject(parent) + , m_window(w) + { + parent->installEventFilter(this); + } + + bool eventFilter(QObject *obj, QEvent *event) override + { + 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; + } + 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 +153,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 +319,15 @@ } window->openUrl(QUrl::fromUserInput(urls.at(0), QString(), QUrl::AssumeLocalFile)); } + new OpenFileEventHandler(&application, window); + // Ark doesn't provide a fullscreen mode; remove the corresponding window button + window->setWindowFlags(window->windowFlags() & ~Qt::WindowFullscreenButtonHint); window->show(); } } qCDebug(ARK) << "Entering application loop"; return application.exec(); } + +#include "main.moc"