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), buffer_view_(0)
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),
63 void Application::setBufferView(BufferView * buffer_view)
65 buffer_view_ = buffer_view;
69 ////////////////////////////////////////////////////////////////////////
70 // X11 specific stuff goes here...
72 bool Application::x11EventFilter(XEvent * xev)
75 case SelectionRequest:
76 lyxerr[Debug::GUI] << "X requested selection." << endl;
78 buffer_view_->selectionRequested();
81 lyxerr[Debug::GUI] << "Lost selection." << endl;
83 buffer_view_->selectionLost();
91 ////////////////////////////////////////////////////////////////////////
92 // Mac OSX specific stuff goes here...
96 OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent)
98 DescType returnedType;
100 OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr,
101 typeWildCard, &returnedType, nil, 0,
104 case errAEDescNotFound:
107 return errAEEventNotHandled;
114 OSErr Application::handleOpenDocuments(const AppleEvent* inEvent,
115 AppleEvent* /*reply*/, long /*refCon*/)
118 AEDescList documentList;
119 OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList,
124 err = checkAppleEventForMissingParams(*inEvent);
127 err = AECountItems(&documentList, &documentCount);
128 for (long documentIndex = 1;
129 err == noErr && documentIndex <= documentCount;
131 DescType returnedType;
136 err = AESizeOfNthItem(&documentList, documentIndex,
137 &returnedType, &actualSize);
139 err = AEGetNthPtr(&documentList, documentIndex,
141 &returnedType, (Ptr)&ref,
142 sizeof(FSRef), &actualSize);
144 FSRefMakePath(&ref, (UInt8*)qstr_buf,
146 s_arg=QString::fromUtf8(qstr_buf);
147 // buffer_view_->workAreaDispatch(
148 // FuncRequest(LFUN_FILE_OPEN,
149 // fromqstr(s_arg)));
155 AEDisposeDesc(&documentList);
160 bool Application::macEventFilter(EventRef event)
162 if (GetEventClass(event) == kEventClassAppleEvent) {
163 EventRecord eventrec;
164 ConvertEventRefToEventRecord(event, &eventrec);
165 AEProcessAppleEvent(&eventrec);
174 } // namespace frontend