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.
15 #include "GuiWorkArea.h"
16 #include "Application.h"
18 #include "qt_helpers.h"
19 #include "BufferView.h"
21 #include "support/lstrings.h"
23 #include <QApplication>
25 #include <QTranslator>
33 using lyx::support::subst;
38 ///////////////////////////////////////////////////////////////
39 // You can find other X11 and MACX specific stuff
40 // at the end of this file...
41 ///////////////////////////////////////////////////////////////
46 Application::Application(int & argc, char ** argv)
47 : QApplication(argc, argv), buffer_view_(0)
50 // doubleClickInterval() is 400 ms on X11 witch is just too long.
51 // On Windows and Mac OS X, the operating system's value is used.
52 // On Microsoft Windows, calling this function sets the double
53 // click interval for all applications. So we don't!
54 QApplication::setDoubleClickInterval(300);
58 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
59 NewAEEventHandlerUPP(handleOpenDocuments),
65 void Application::setBufferView(BufferView * buffer_view)
67 buffer_view_ = buffer_view;
71 ////////////////////////////////////////////////////////////////////////
72 // X11 specific stuff goes here...
74 bool Application::x11EventFilter(XEvent * xev)
77 case SelectionRequest:
78 lyxerr[Debug::GUI] << "X requested selection." << endl;
80 buffer_view_->selectionRequested();
83 lyxerr[Debug::GUI] << "Lost selection." << endl;
85 buffer_view_->selectionLost();
93 ////////////////////////////////////////////////////////////////////////
94 // Mac OSX specific stuff goes here...
98 OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent)
100 DescType returnedType;
102 OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr,
103 typeWildCard, &returnedType, nil, 0,
106 case errAEDescNotFound:
109 return errAEEventNotHandled;
116 OSErr Application::handleOpenDocuments(const AppleEvent* inEvent,
117 AppleEvent* /*reply*/, long /*refCon*/)
120 AEDescList documentList;
121 OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList,
126 err = checkAppleEventForMissingParams(*inEvent);
129 err = AECountItems(&documentList, &documentCount);
130 for (long documentIndex = 1;
131 err == noErr && documentIndex <= documentCount;
133 DescType returnedType;
138 err = AESizeOfNthItem(&documentList, documentIndex,
139 &returnedType, &actualSize);
141 err = AEGetNthPtr(&documentList, documentIndex,
143 &returnedType, (Ptr)&ref,
144 sizeof(FSRef), &actualSize);
146 FSRefMakePath(&ref, (UInt8*)qstr_buf,
148 s_arg=QString::fromUtf8(qstr_buf);
149 // buffer_view_->workAreaDispatch(
150 // FuncRequest(LFUN_FILE_OPEN,
151 // fromqstr(s_arg)));
157 AEDisposeDesc(&documentList);
162 bool Application::macEventFilter(EventRef event)
164 if (GetEventClass(event) == kEventClassAppleEvent) {
165 EventRecord eventrec;
166 ConvertEventRefToEventRecord(event, &eventrec);
167 AEProcessAppleEvent(&eventrec);
176 } // namespace frontend