Commit cd6ec201 authored by Christoph Cullmann's avatar Christoph Cullmann

handle mac like file open for kate, thanks to René J.V. Bertin for the hint with the plist file

parent c5884cdd
......@@ -6,35 +6,50 @@
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>LSMultipleInstancesProhibited</key>
<true/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeName</key>
<string>NSStringPboardType</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
</dict>
</plist>
......@@ -34,6 +34,7 @@
#include <QFileInfo>
#include <QTextCodec>
#include <QApplication>
#include <QFileOpenEvent>
#include "../../urlinfo.h"
......@@ -60,6 +61,11 @@ KateApp::KateApp(const QCommandLineParser &args)
connect(&m_docManager, &KateDocManager::documentDeleted, &m_wrapper, &KTextEditor::Application::documentDeleted);
connect(&m_docManager, &KateDocManager::aboutToCreateDocuments, &m_wrapper, &KTextEditor::Application::aboutToCreateDocuments);
connect(&m_docManager, &KateDocManager::documentsCreated, &m_wrapper, &KTextEditor::Application::documentsCreated);
/**
* handle mac os x like file open request via event filter
*/
qApp->installEventFilter(this);
}
KateApp::~KateApp()
......@@ -386,3 +392,26 @@ KTextEditor::Plugin *KateApp::plugin(const QString &name)
return m_pluginManager.plugin(name);
}
bool KateApp::eventFilter(QObject *obj, QEvent *event)
{
/**
* handle mac os like file open
*/
if (event->type() == QEvent::FileOpen) {
/**
* try to open and activate the new document, like we would do for stuff
* opened via dbus
*/
QFileOpenEvent *foe = static_cast<QFileOpenEvent*>(event);
KTextEditor::Document *doc = openDocUrl(foe->url(), QString(), false);
if (doc && activeKateMainWindow()) {
activeKateMainWindow()->viewManager()->activateView(doc);
}
return true;
}
/**
* else: pass over to default implementation
*/
return QObject::eventFilter(obj, event);
}
......@@ -310,6 +310,12 @@ public Q_SLOTS:
shutdownKate(activeKateMainWindow());
return true;
}
protected:
/**
* Event filter for QApplication to handle mac os like file open
*/
bool eventFilter(QObject *obj, QEvent *event);
private:
/**
......
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