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.
17 // FIXME: move this stuff out again
19 #include "funcrequest.h"
22 #include "LyXAction.h"
27 #include "support/lstrings.h"
31 #include "qt_helpers.h"
32 #include "socket_callback.h"
33 #include "GuiApplication.h"
35 #include <QApplication>
37 #include <QTranslator>
40 #include <QLibraryInfo>
42 #include <boost/bind.hpp>
43 #include <boost/shared_ptr.hpp>
46 using lyx::support::ltrim;
48 using lyx::frontend::GuiImplementation;
49 using lyx::frontend::GuiView;
50 using lyx::frontend::GuiApplication;
52 using boost::shared_ptr;
58 lyx::frontend::GuiApplication * guiApp;
62 map<int, shared_ptr<socket_callback> > socket_callbacks;
68 int exec(int & argc, char * argv[])
71 FIXME : Abdel 29/05/2006 (younes.a@free.fr)
72 reorganize this code. In particular make sure that this
73 advice from Qt documentation is respected:
75 Since the QApplication object does so much initialization, it
76 must be created before any other objects related to the user
77 interface are created.
79 Right now this is not the case, I suspect that a number of global variables
80 contains Qt object that are initialized before the passage through
81 parse_init(). This might also explain the message displayed by Qt
82 that caused the hanging:
84 QObject::killTimer: timers cannot be stopped from another thread
86 I hope that the problem will disappear automagically when we get rid of
87 lyx_gui entirely, thus using theApp directly throughout the code for LyXFunc,
88 Clipboard and Selection access.
91 #if defined(Q_WS_WIN) && !defined(Q_CYGWIN_WIN)
92 static GuiApplication app(argc, argv);
94 GuiApplication app(argc, argv);
100 return LyX::ref().exec2(argc, argv);
106 // This is the ONLY place where processEvents may be called.
107 // During screen update/ redraw, this method is disabled to
108 // prevent keyboard events being handed to the LyX core, where
109 // they could cause re-entrant calls to screen update.
110 guiApp->processEvents(QEventLoop::ExcludeUserInputEvents);
114 bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
116 QColor const & qcol = guiApp->colorCache().get(col);
117 if (!qcol.isValid()) {
123 rgbcol.r = qcol.red();
124 rgbcol.g = qcol.green();
125 rgbcol.b = qcol.blue();
130 string const hexname(LColor_color col)
132 return ltrim(fromqstr(guiApp->colorCache().get(col).name()), "#");
136 void update_color(LColor_color)
138 // FIXME: Bleh, can't we just clear them all at once ?
139 guiApp->colorCache().clear();
143 void register_socket_callback(int fd, boost::function<void()> func)
145 socket_callbacks[fd] = shared_ptr<socket_callback>(new socket_callback(fd, func));
149 void unregister_socket_callback(int fd)
151 socket_callbacks.erase(fd);
154 }; // namespace lyx_gui