]> git.lyx.org Git - lyx.git/commitdiff
* qt4/GuiApplication.C: remove ad-hoc Mac OSX Carbon code to handle
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 29 Nov 2006 09:06:37 +0000 (09:06 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 29 Nov 2006 09:06:37 +0000 (09:06 +0000)
kAEOpenDocuments ApleEvent.
(event): new method to do the same thing using qt4 built-in support.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16099 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.C
src/frontends/qt4/GuiApplication.h

index fb5a1b043282a6aeeac04742f157a1f72eaef53e..ffd1624cc9eca967016ed3ac01c3b4f81c764449 100644 (file)
@@ -37,6 +37,7 @@
 #include <QApplication>
 #include <QClipboard>
 #include <QEventLoop>
+#include <QFileOpenEvent>
 #include <QLocale>
 #include <QLibraryInfo>
 #include <QTextCodec>
@@ -102,12 +103,6 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
        QApplication::setDoubleClickInterval(300);
 #endif
 
-#ifdef Q_WS_MACX
-       AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
-                             NewAEEventHandlerUPP(handleOpenDocuments),
-                             0, false);
-#endif
-
        // install translation file for Qt built-in dialogs
        QTranslator qt_trans;
        QString language_name = QString("qt_") + QLocale::system().name();
@@ -220,6 +215,22 @@ string const GuiApplication::typewriterFontName()
 }
 
 
+bool GuiApplication::event(QEvent * e)
+{
+       switch(e->type()) {
+       case QEvent::FileOpen: {
+               // Open a file; this happens only on Mac OS X for now
+               QFileOpenEvent * foe = static_cast<QFileOpenEvent *>(e);
+               lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
+                                         fromqstr(foe->file())));
+               return true;
+       }
+       default:
+               return false;
+       }
+}
+
+
 void GuiApplication::syncEvents()
 {
        // This is the ONLY place where processEvents may be called.
@@ -299,91 +310,6 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
 #endif
 
 
-////////////////////////////////////////////////////////////////////////
-// Mac OSX specific stuff goes here...
-
-#ifdef Q_WS_MACX
-namespace{
-
-OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent)
- {
-       DescType returnedType;
-       Size actualSize;
-       OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr,
-                                     typeWildCard, &returnedType, nil, 0,
-                                     &actualSize);
-       switch (err) {
-       case errAEDescNotFound:
-               return noErr;
-       case noErr:
-               return errAEEventNotHandled;
-       default:
-               return err;
-       }
- }
-
-} // namespace
-
-OSErr GuiApplication::handleOpenDocuments(const AppleEvent* inEvent,
-                                      AppleEvent* /*reply*/, long /*refCon*/)
-{
-       QString s_arg;
-       AEDescList documentList;
-       OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList,
-                                  &documentList);
-       if (err != noErr)
-               return err;
-
-       err = checkAppleEventForMissingParams(*inEvent);
-       if (err == noErr) {
-               long documentCount;
-               err = AECountItems(&documentList, &documentCount);
-               for (long documentIndex = 1;
-                    err == noErr && documentIndex <= documentCount;
-                    documentIndex++) {
-                       DescType returnedType;
-                       Size actualSize;
-                       AEKeyword keyword;
-                       FSRef ref;
-                       char qstr_buf[1024];
-                       err = AESizeOfNthItem(&documentList, documentIndex,
-                                             &returnedType, &actualSize);
-                       if (err == noErr) {
-                               err = AEGetNthPtr(&documentList, documentIndex,
-                                                 typeFSRef, &keyword,
-                                                 &returnedType, (Ptr)&ref,
-                                                 sizeof(FSRef), &actualSize);
-                               if (err == noErr) {
-                                       FSRefMakePath(&ref, (UInt8*)qstr_buf,
-                                                     1024);
-                                       s_arg=QString::fromUtf8(qstr_buf);
-//                                     bv->workAreaDispatch(
-//                                             FuncRequest(LFUN_FILE_OPEN,
-//                                                         fromqstr(s_arg)));
-                                       break;
-                               }
-                       }
-               } // for ...
-       }
-       AEDisposeDesc(&documentList);
-
-       return err;
-}
-
-bool GuiApplication::macEventFilter(EventRef event)
-{
-       if (GetEventClass(event) == kEventClassAppleEvent) {
-               EventRecord eventrec;
-               ConvertEventRefToEventRecord(event, &eventrec);
-               AEProcessAppleEvent(&eventrec);
-
-               return false;
-       }
-       return false;
-}
-
-#endif  // Q_WS_MACX
-
 } // namespace frontend
 } // namespace lyx
 
index 656d87300324270dd5b2d83ae58a3db3064bd58f..1f609467c73544ab684c47bd0206628d8c1538c9 100644 (file)
@@ -65,6 +65,7 @@ public:
        virtual int const exec();
        virtual Gui & gui() { return gui_; }
        virtual void exit(int status);
+       virtual bool event(QEvent * e);
        void syncEvents();
        virtual std::string const romanFontName();
        virtual std::string const sansFontName();
@@ -106,14 +107,6 @@ public:
        bool x11EventFilter (XEvent * ev);
 #endif
 
-#ifdef Q_WS_MACX
-public:
-       bool macEventFilter(EventRef event);
-private:
-//     static OSStatus handleOpenDocuments(
-       static pascal OSErr     handleOpenDocuments(
-               const AppleEvent* inEvent, AppleEvent*, long);
-#endif
 }; // GuiApplication
 
 extern GuiApplication * guiApp;