MantisBT - ParaView
View Issue Details
0010015ParaViewFeaturepublic2009-12-09 01:162016-08-12 09:57
Michael Wild 
Berk Geveci 
normalfeatureN/A
closedmoved 
Development 
 
0010015: Enable ParaView to handle OpenDocuments/OpenFiles events on Mac OS X
It would be nice if users of Mac OS X where able to double-click files to open them in ParaView. The patch maintained in

http://github.com/themiwi/ParaView/tree/patches/MacOpenFiles [^]

implements the following:

- A function to handle the Carbon OpenDocuments event.

- A method that is injected into QCocoaApplicationDelegate to replace the application:openFiles: method to handle the Cocoa-event.

- The pqOpenFilesEvent event class which holds a QStringList with the names of all files the application should open which gets sent to the QApplication object by above two functions.

Further, for the ParaView application, an extended Info.plist file is added, associating many (I hope I got them all) file types with ParaView. For VTK and OpenFOAM files I also added icons in Common/DocumentIcons.
On Mac OS X, if a user opens a file from the Finder (or uses the "open" command), the system sends an OpenDocuments event to the application (kAEOpenDocuments in Carbon) which gets translated into a call to the openFiles method of the application delegate if using Cocoa.

Qt has its own event type for this (QFileOpenEvent), but unfortunately translates a single Apple-event with multiple files (i.e. the user opened multiple files at once) into multiple QFileOpenEvent's with a single file each. This makes it look like the user opened many files sequentially, making it impossible for the user to open e.g. a time-series of .vtk files.

For this reason it is necessary to change the default-behavior of Qt for this event. In the Carbon case, this is rather easily achieved by registering a different function for the kAEOpenDocuments event. If using Cocoa, however, there is only a single application-delegate object. When an event occurs, Cocoa calls a corresponding method of this object, allowing it to handle this event. Since this delegate-class is internal to Qt, one can't simply subclass it to override the application:openFiles: method. Either one has to re-implement the whole delegate class, or use the Objective-C runtime to inject a customized implementation into the class, replacing the original. For simplicity I chose the latter.

No tags attached.
Issue History
2009-12-09 01:16Michael WildNew Issue
2009-12-09 10:39Utkarsh AyachitStatusbacklog => tabled
2009-12-09 10:39Utkarsh AyachitAssigned To => Berk Geveci
2011-06-16 13:10Zack GalbreathCategoryFeature Request => Feature
2016-08-12 09:57Kitware RobotNote Added: 0037756
2016-08-12 09:57Kitware RobotStatusexpired => closed
2016-08-12 09:57Kitware RobotResolutionopen => moved

Notes
(0037756)
Kitware Robot   
2016-08-12 09:57   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current ParaView Issues page linked in the banner at the top of this page.