[KDE/Mac] new year's resolution: opening files "the Mac way" (TM)
Christoph Cullmann
cullmann at absint.com
Sat Jan 2 18:56:28 UTC 2016
Hi,
> Hi,
>
>
> I have gotten a bit further. As I thought it is critical to have a correct
> Info.plist (or else the event is never sent), and it isn't trivial to edit that
> file "in place" and have the system recognise its new content (easiest way is
> to copy the entire app bundle in the Finder).
>
> You also need to set a flag (LSMultipleInstancesProhibited) in the Info.plist to
> avoid launching multiple copies; for some reason the mechanism that is in place
> to prevent that doesn't work when you drop a document on Kate's app icon in the
> Finder (or the Dock). So:
>
> <key>NSPrincipalClass</key>
> <string>NSApplication</string>
> <key>NSSupportsAutomaticGraphicsSwitching</key>
> <true/>
> <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>
>
> (The NSSupportsAutomaticGraphicsSwitching comes from QtCreator; I haven't check
> what it does exactly but it shouldn't harm).
Thanks for the hint with the plist file!
>
> With this, I see the events arrive in kate's main.cpp when I add the following:
>
> #include <QFileOpenEvent>
> class FileOpenHandler : public QObject
> {
> Q_OBJECT
> public:
> FileOpenHandler(QObject *parent=Q_NULLPTR)
> : QObject(parent)
> {}
> bool eventFilter(QObject *obj, QEvent *event)
> {
> if (event->type() == QEvent::FileOpen) {
> QFileOpenEvent *foe = static_cast<QFileOpenEvent*>(event);
> qDebug() << Q_FUNC_INFO << "FileOpen event" << foe;
> // call KateApp::openUrl(foe->url() ...) from here
> return true;
> } else {
> return QObject::eventFilter(obj, event);
> }
> }
> };
>
> and then just before starting the main loop:
>
> #ifdef Q_OS_OSX
> FileOpenHandler *fileOpenHandler = new FileOpenHandler(qApp);
> qApp->installEventFilter(fileOpenHandler);
> #endif
I have added this now just to KateApp.
https://quickgit.kde.org/?p=kate.git&a=commit&h=cd6ec201725cf627a336015d472c39f5ff73b2a7
>
> Question is: what about the encoding parameter?
Can be just set to empty QString like done in my commit above.
>
> Also, for a local/MacPorts KDE4 implementation of this : if I add a signal to
> the KApplication class, do I need to rebuild all dependents to avoid
> ABI-related crashing, or only those that are modified to connect to the new
> signal?
> (IOW, can you add a signal to a class without breaking backwards compatibility?)
Signal adding should be binary compatible, but I doubt that is a good idea.
Why not just add the matching code to the applications you want to have support?
They will anyway need adjustments.
Greetings
Christoph
--
----------------------------- Dr.-Ing. Christoph Cullmann ---------
AbsInt Angewandte Informatik GmbH Email: cullmann at AbsInt.com
Science Park 1 Tel: +49-681-38360-22
66123 Saarbrücken Fax: +49-681-38360-20
GERMANY WWW: http://www.AbsInt.com
--------------------------------------------------------------------
Geschäftsführung: Dr.-Ing. Christian Ferdinand
Eingetragen im Handelsregister des Amtsgerichts Saarbrücken, HRB 11234
More information about the kde-mac
mailing list