summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenĂ© J.V. Bertin <[email protected]>2016-06-02 13:25:16 +0200
committerRenĂ© J.V. Bertin <[email protected]>2016-06-02 13:25:16 +0200
commitfe4563d9fd922bea3890e7ad5f470f2363a8b43d (patch)
treed92190a1e94a85be95f6f9b1c26c67283dad8969
parent3c04125352d534cc20c91277ddcd647954ce3cf6 (diff)
[OS X] Support for opening documents from the Finder (= through LaunchServices) and preserve the app icon
REVIEW: 127932 Committed from host : Portia.local
-rw-r--r--app/CMakeLists.txt16
-rw-r--r--app/main.cpp2
-rw-r--r--app/mainwindow.cpp21
-rw-r--r--app/mainwindow.h1
4 files changed, 39 insertions, 1 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index dcf486f..6e31d59 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -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})
diff --git a/app/main.cpp b/app/main.cpp
index 6aadaf4..a28ca82 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -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);
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index 7b30c4e..aa846cc 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -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);
diff --git a/app/mainwindow.h b/app/mainwindow.h
index 6d252f9..0605aa1 100644
--- a/app/mainwindow.h
+++ b/app/mainwindow.h
@@ -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);