Commit fe4563d9 authored by René J.V. Bertin's avatar René J.V. Bertin

[OS X] Support for opening documents from the Finder (= through...

[OS X] Support for opening documents from the Finder (= through LaunchServices) and preserve the app icon

REVIEW: 127932
Committed from host : Portia.local
parent 3c041253
......@@ -84,6 +84,22 @@ if (KF5Kipi_FOUND)
target_link_libraries(gwenview KF5::Kipi)
endif()
if (APPLE)
# own plist template
set_target_properties (gwenview 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 Gwenview5)
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.gwenview")
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Gwenview5")
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_DISPLAY_NAME "Gwenview5")
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_INFO_STRING "Gwenview, KDE Image Viewer")
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_LONG_VERSION_STRING "Gwenview ${KDE_APPLICATIONS_VERSION}")
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}")
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_BUNDLE_VERSION "${KDE_APPLICATIONS_VERSION}")
set_target_properties(gwenview PROPERTIES MACOSX_BUNDLE_COPYRIGHT "2002-2016 The Gwenview Authors")
endif (APPLE)
install(TARGETS gwenview
${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
......
......@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
app.setApplicationName(aboutData.data()->componentName());
app.setApplicationDisplayName(aboutData.data()->displayName());
app.setOrganizationDomain(aboutData.data()->organizationDomain());
QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("gwenview")));
QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("gwenview"), app.windowIcon()));
QCommandLineParser parser;
aboutData.data()->setupCommandLine(&parser);
......
......@@ -32,6 +32,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QVBoxLayout>
#include <QMenuBar>
#include <QUrl>
#ifdef Q_OS_OSX
#include <QFileOpenEvent>
#endif
// KDE
#include <KIO/NetAccess>
......@@ -794,6 +797,9 @@ MainWindow::MainWindow()
d->mKIPIExportAction->setKIPIInterface(d->mKIPIInterface);
#endif
setAutoSaveSettings();
#ifdef Q_OS_OSX
qApp->installEventFilter(this);
#endif
}
MainWindow::~MainWindow()
......@@ -1542,6 +1548,21 @@ void MainWindow::resizeEvent(QResizeEvent* event)
}
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
#ifdef Q_OS_OSX
/**
* handle Mac OS X file open events (only exist on OS X)
*/
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *fileOpenEvent = static_cast<QFileOpenEvent*>(event);
openUrl(fileOpenEvent->url());
return true;
}
#endif
return false;
}
void MainWindow::setDistractionFreeMode(bool value)
{
d->mFullScreenContent->setDistractionFreeMode(value);
......
......@@ -78,6 +78,7 @@ protected:
virtual void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
virtual void saveProperties(KConfigGroup&) Q_DECL_OVERRIDE;
virtual void readProperties(const KConfigGroup&) Q_DECL_OVERRIDE;
bool eventFilter(QObject *, QEvent *);
private Q_SLOTS:
void setActiveViewModeAction(QAction* action);
......
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