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 "Application.h"
17 #include "GuiWorkArea.h"
19 #include "qt_helpers.h"
21 #include "BufferView.h"
24 #include "support/lstrings.h"
26 #include <QApplication>
28 #include <QTranslator>
36 using lyx::support::subst;
41 ///////////////////////////////////////////////////////////////
42 // You can find other X11 and MACX specific stuff
43 // at the end of this file...
44 ///////////////////////////////////////////////////////////////
49 Application::Application(int & argc, char ** argv)
50 : QApplication(argc, argv), buffer_view_(0)
53 // doubleClickInterval() is 400 ms on X11 witch is just too long.
54 // On Windows and Mac OS X, the operating system's value is used.
55 // On Microsoft Windows, calling this function sets the double
56 // click interval for all applications. So we don't!
57 QApplication::setDoubleClickInterval(300);
61 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
62 NewAEEventHandlerUPP(handleOpenDocuments),
68 void Application::setBufferView(BufferView * buffer_view)
70 buffer_view_ = buffer_view;
74 ////////////////////////////////////////////////////////////////////////
75 // X11 specific stuff goes here...
77 bool Application::x11EventFilter(XEvent * xev)
80 case SelectionRequest:
81 lyxerr[Debug::GUI] << "X requested selection." << endl;
83 buffer_view_->selectionRequested();
86 lyxerr[Debug::GUI] << "Lost selection." << endl;
88 buffer_view_->selectionLost();
96 ////////////////////////////////////////////////////////////////////////
97 // Mac OSX specific stuff goes here...
101 OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent)
103 DescType returnedType;
105 OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr,
106 typeWildCard, &returnedType, nil, 0,
109 case errAEDescNotFound:
112 return errAEEventNotHandled;
119 OSErr Application::handleOpenDocuments(const AppleEvent* inEvent,
120 AppleEvent* /*reply*/, long /*refCon*/)
123 AEDescList documentList;
124 OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList,
129 err = checkAppleEventForMissingParams(*inEvent);
132 err = AECountItems(&documentList, &documentCount);
133 for (long documentIndex = 1;
134 err == noErr && documentIndex <= documentCount;
136 DescType returnedType;
141 err = AESizeOfNthItem(&documentList, documentIndex,
142 &returnedType, &actualSize);
144 err = AEGetNthPtr(&documentList, documentIndex,
146 &returnedType, (Ptr)&ref,
147 sizeof(FSRef), &actualSize);
149 FSRefMakePath(&ref, (UInt8*)qstr_buf,
151 s_arg=QString::fromUtf8(qstr_buf);
152 // buffer_view_->workAreaDispatch(
153 // FuncRequest(LFUN_FILE_OPEN,
154 // fromqstr(s_arg)));
160 AEDisposeDesc(&documentList);
165 bool Application::macEventFilter(EventRef event)
167 if (GetEventClass(event) == kEventClassAppleEvent) {
168 EventRecord eventrec;
169 ConvertEventRefToEventRecord(event, &eventrec);
170 AEProcessAppleEvent(&eventrec);
179 } // namespace frontend