2 * \file qt4/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 QT4_APPLICATION_H
14 #define QT4_APPLICATION_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 <boost/scoped_ptr.hpp>
26 #include <QApplication>
27 #include <QTranslator>
29 class QSessionManager;
34 class socket_callback;
41 /// The Qt main application class
43 There should be only one instance of this class. No Qt object
44 initialisation should be done before the instanciation of this class.
46 \todo The work areas handling could be moved to a base virtual class
47 comon to all frontends.
49 class GuiApplication : public QApplication, public Application
54 GuiApplication(int & argc, char ** argv);
56 virtual ~GuiApplication();
58 /// Method inherited from \c Application class
60 virtual Clipboard& clipboard();
61 virtual Selection& selection();
62 virtual FontLoader & fontLoader() { return font_loader_; }
63 virtual int const exec();
64 virtual Gui & gui() { return gui_; }
65 virtual void exit(int status);
66 virtual bool event(QEvent * e);
68 virtual std::string const romanFontName();
69 virtual std::string const sansFontName();
70 virtual std::string const typewriterFontName();
71 virtual bool getRgbColor(Color_color col, RGBColor & rgbcol);
72 virtual std::string const hexName(Color_color col);
73 virtual void updateColor(Color_color col);
74 virtual void registerSocketCallback(
75 int fd, boost::function<void()> func);
76 void unregisterSocketCallback(int fd);
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();
97 GuiImplementation gui_;
99 GuiClipboard clipboard_;
101 GuiSelection selection_;
103 GuiFontLoader font_loader_;
105 ColorCache color_cache_;
107 QTranslator qt_trans_;
109 std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
113 bool x11EventFilter (XEvent * ev);
116 /// A translator suitable for the entries in the LyX menu.
117 /// Only needed with Qt/Mac.
118 void addMenuTranslator();
120 boost::scoped_ptr<MenuTranslator> menu_trans_;
123 extern GuiApplication * guiApp;
125 } // namespace frontend
130 #endif // QT4_APPLICATION_H