2 * \file qt4/Application.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
13 #include "GuiWorkArea.h"
14 #include "Application.h"
16 #include "qt_helpers.h"
17 #include "BufferView.h"
19 #include "support/lstrings.h"
21 #include <QApplication>
23 #include <QTranslator>
31 using lyx::support::subst;
36 ///////////////////////////////////////////////////////////////
37 // You can find other X11 and MACX specific stuff
38 // at the end of this file...
39 ///////////////////////////////////////////////////////////////
44 Application::Application(int & argc, char ** argv)
45 : QApplication(argc, argv), work_area_(NULL)
48 // doubleClickInterval() is 400 ms on X11 witch is just too long.
49 // On Windows and Mac OS X, the operating system's value is used.
50 // On Microsoft Windows, calling this function sets the double
51 // click interval for all applications. So we don't!
52 QApplication::setDoubleClickInterval(300);
56 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
57 NewAEEventHandlerUPP(handleOpenDocuments),
62 void Application::connect(GuiWorkArea * work_area)
64 work_area_ = work_area;
68 ////////////////////////////////////////////////////////////////////////
69 // X11 specific stuff goes here...
71 bool Application::x11EventFilter(XEvent * xev)
74 case SelectionRequest:
75 lyxerr[Debug::GUI] << "X requested selection." << endl;
77 work_area_->view().view()->selectionRequested();
80 lyxerr[Debug::GUI] << "Lost selection." << endl;
82 work_area_->view().view()->selectionLost();
90 ////////////////////////////////////////////////////////////////////////
91 // Mac OSX specific stuff goes here...
95 OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent)
97 DescType returnedType;
99 OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr,
100 typeWildCard, &returnedType, nil, 0,
103 case errAEDescNotFound:
106 return errAEEventNotHandled;
113 OSErr Application::handleOpenDocuments(const AppleEvent* inEvent,
114 AppleEvent* /*reply*/, long /*refCon*/)
117 AEDescList documentList;
118 OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList,
123 err = checkAppleEventForMissingParams(*inEvent);
126 err = AECountItems(&documentList, &documentCount);
127 for (long documentIndex = 1;
128 err == noErr && documentIndex <= documentCount;
130 DescType returnedType;
135 err = AESizeOfNthItem(&documentList, documentIndex,
136 &returnedType, &actualSize);
138 err = AEGetNthPtr(&documentList, documentIndex,
140 &returnedType, (Ptr)&ref,
141 sizeof(FSRef), &actualSize);
143 FSRefMakePath(&ref, (UInt8*)qstr_buf,
145 s_arg=QString::fromUtf8(qstr_buf);
146 work_area_->view().view()->workAreaDispatch(
147 FuncRequest(LFUN_FILE_OPEN,
154 AEDisposeDesc(&documentList);
159 bool Application::macEventFilter(EventRef event)
161 if (GetEventClass(event) == kEventClassAppleEvent) {
162 EventRecord eventrec;
163 ConvertEventRefToEventRecord(event, &eventrec);
164 AEProcessAppleEvent(&eventrec);
173 } // namespace frontend