2 * \file GuiApplication.h
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 #ifndef GUIAPPLICATION_H
14 #define GUIAPPLICATION_H
16 #include "ColorCache.h"
17 #include "GuiFontLoader.h"
18 #include "GuiClipboard.h"
19 #include "GuiImplementation.h"
20 #include "GuiSelection.h"
22 #include "frontends/Application.h"
24 #include <QApplication>
25 #include <QTranslator>
27 class QSessionManager;
38 /// The Qt main application class
40 There should be only one instance of this class. No Qt object
41 initialisation should be done before the instanciation of this class.
43 \todo The work areas handling could be moved to a base virtual class
44 comon to all frontends.
46 class GuiApplication : public QApplication, public Application
51 GuiApplication(int & argc, char ** argv);
53 virtual ~GuiApplication();
55 /// Method inherited from \c Application class
57 virtual Clipboard & clipboard();
58 virtual Selection & selection();
59 virtual FontLoader & fontLoader() { return font_loader_; }
61 virtual Gui & gui() { return gui_; }
62 virtual void exit(int status);
63 virtual bool event(QEvent * e);
65 virtual std::string const romanFontName();
66 virtual std::string const sansFontName();
67 virtual std::string const typewriterFontName();
68 virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
69 virtual std::string const hexName(ColorCode col);
70 virtual void updateColor(ColorCode col);
71 virtual void registerSocketCallback(int fd, SocketCallback func);
72 void unregisterSocketCallback(int fd);
73 /// Create the main window with given geometry settings.
74 LyXView & createView(unsigned int width, unsigned int height,
75 int posx, int posy, int maximized,
76 unsigned int iconSizeXY, const std::string & geometryArg);
79 /// Methods inherited from \c QApplication class
81 bool notify(QObject * receiver, QEvent * event);
82 void commitData(QSessionManager & sm);
86 ColorCache & colorCache() { return color_cache_; }
89 GuiFontLoader & guiFontLoader() { return font_loader_; }
93 void execBatchCommands();
95 void socketDataReceived(int fd);
99 GuiImplementation gui_;
101 GuiClipboard clipboard_;
103 GuiSelection selection_;
105 GuiFontLoader font_loader_;
107 ColorCache color_cache_;
109 QTranslator qt_trans_;
111 std::map<int, SocketNotifier *> socket_notifiers_;
115 bool x11EventFilter(XEvent * ev);
117 /// A translator suitable for the entries in the LyX menu.
118 /// Only needed with Qt/Mac.
119 void addMenuTranslator();
122 extern GuiApplication * guiApp;
124 } // namespace frontend
127 #endif // GUIAPPLICATION_H