Ticket #50008: patch-accept-docs-from-finder.diff

File patch-accept-docs-from-finder.diff, 5.5 KB (added by RJVB (René Bertin), 8 years ago)
  • kate/data/MacOSXBundleInfo.plist.in

    From: Christoph Cullmann <cullmann@kde.org>
    Date: Sat, 02 Jan 2016 18:51:33 +0000
    Subject: handle mac like file open for kate, thanks to René J.V. Bertin for the hint with the plist file
    X-Git-Url: http://quickgit.kde.org/?p=kate.git&a=commitdiff&h=cd6ec201725cf627a336015d472c39f5ff73b2a7
    ---
    handle mac like file open for kate, thanks to René J.V. Bertin for the hint with the plist file
    ---
    
    diff --git kate/data/MacOSXBundleInfo.plist.in kate/data/MacOSXBundleInfo.plist.in
     
    66        <string>NSApplication</string>
    77        <key>NSHighResolutionCapable</key>
    88        <string>True</string>
    9         <key>CFBundleDevelopmentRegion</key>
    10         <string>English</string>
    11         <key>CFBundleExecutable</key>
    12         <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
    13         <key>CFBundleGetInfoString</key>
    14         <string>${MACOSX_BUNDLE_INFO_STRING}</string>
    15         <key>CFBundleIconFile</key>
    16         <string>${MACOSX_BUNDLE_ICON_FILE}</string>
    17         <key>CFBundleIdentifier</key>
    18         <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
    19         <key>CFBundleInfoDictionaryVersion</key>
    20         <string>6.0</string>
    21         <key>CFBundleLongVersionString</key>
    22         <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
    23         <key>CFBundleName</key>
    24         <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
    25         <key>CFBundlePackageType</key>
    26         <string>APPL</string>
    27         <key>CFBundleShortVersionString</key>
    28         <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
    29         <key>CFBundleSignature</key>
    30         <string>????</string>
    31         <key>CFBundleVersion</key>
    32         <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
    33         <key>CSResourcesFileMapped</key>
    34         <true/>
    35         <key>LSRequiresCarbon</key>
    36         <true/>
    37         <key>NSHumanReadableCopyright</key>
    38         <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
     9        <key>CFBundleDevelopmentRegion</key>
     10        <string>English</string>
     11        <key>CFBundleExecutable</key>
     12        <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
     13        <key>CFBundleGetInfoString</key>
     14        <string>${MACOSX_BUNDLE_INFO_STRING}</string>
     15        <key>CFBundleIconFile</key>
     16        <string>${MACOSX_BUNDLE_ICON_FILE}</string>
     17        <key>CFBundleIdentifier</key>
     18        <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
     19        <key>CFBundleInfoDictionaryVersion</key>
     20        <string>6.0</string>
     21        <key>CFBundleLongVersionString</key>
     22        <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
     23        <key>CFBundleName</key>
     24        <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
     25        <key>CFBundlePackageType</key>
     26        <string>APPL</string>
     27        <key>CFBundleShortVersionString</key>
     28        <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
     29        <key>CFBundleSignature</key>
     30        <string>????</string>
     31        <key>CFBundleVersion</key>
     32        <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
     33        <key>CSResourcesFileMapped</key>
     34        <true/>
     35        <key>LSRequiresCarbon</key>
     36        <true/>
     37        <key>NSHumanReadableCopyright</key>
     38        <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
     39        <key>LSMultipleInstancesProhibited</key>
     40        <true/>
     41        <key>CFBundleDocumentTypes</key>
     42        <array>
     43            <dict>
     44                <key>CFBundleTypeExtensions</key>
     45                <array>
     46                        <string>*</string>
     47                </array>
     48                <key>CFBundleTypeName</key>
     49                <string>NSStringPboardType</string>
     50                <key>CFBundleTypeRole</key>
     51                <string>Editor</string>
     52            </dict>
     53        </array>
    3954</dict>
    4055</plist>
    4156
  • kate/kateapp.h

    diff --git kate/kateapp.h kate/kateapp.h
     
    310310        shutdownKate(activeKateMainWindow());
    311311        return true;
    312312    }
     313   
     314protected:
     315    /**
     316     * Event filter for QApplication to handle mac os like file open
     317     */
     318    bool eventFilter(QObject *obj, QEvent *event);
    313319
    314320private:
    315321    /**
  • kateapp.cpp

    diff --git kate/orig.kateapp.cpp kate/kateapp.cpp
    old new  
    3434#include <QFileInfo>
    3535#include <QTextCodec>
    3636#include <QApplication>
     37#include <QFileOpenEvent>
    3738
    3839#include "../../urlinfo.h"
    3940
     
    6061    connect(&m_docManager, &KateDocManager::documentDeleted, &m_wrapper, &KTextEditor::Application::documentDeleted);
    6162    connect(&m_docManager, &KateDocManager::aboutToCreateDocuments, &m_wrapper, &KTextEditor::Application::aboutToCreateDocuments);
    6263    connect(&m_docManager, &KateDocManager::documentsCreated, &m_wrapper, &KTextEditor::Application::documentsCreated);
     64   
     65    /**
     66     * handle mac os x like file open request via event filter
     67     */
     68    qApp->installEventFilter(this);
    6369}
    6470
    6571KateApp::~KateApp()
     
    386392    return m_pluginManager.plugin(name);
    387393}
    388394
     395bool KateApp::eventFilter(QObject *obj, QEvent *event)
     396{
     397    /**
     398     * handle mac os like file open
     399     */
     400    if (event->type() == QEvent::FileOpen) {
     401        /**
     402         * try to open and activate the new document, like we would do for stuff
     403         * opened via dbus
     404         */
     405        QFileOpenEvent *foe = static_cast<QFileOpenEvent*>(event);
     406        KTextEditor::Document *doc = openDocUrl(foe->url(), QString(), false);
     407        if (doc && activeKateMainWindow()) {
     408            activeKateMainWindow()->viewManager()->activateView(doc);
     409        }
     410        return true;
     411    }
     412
     413    /**
     414     * else: pass over to default implementation
     415     */
     416    return QObject::eventFilter(obj, event);
     417}