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>
32 class socket_callback;
39 /// The Qt main application class
41 There should be only one instance of this class. No Qt object
42 initialisation should be done before the instanciation of this class.
44 \todo The work areas handling could be moved to a base virtual class
45 comon to all frontends.
47 class GuiApplication : public QApplication, public Application
52 GuiApplication(int & argc, char ** argv);
54 virtual ~GuiApplication();
56 /// Method inherited from \c Application class
58 virtual Clipboard& clipboard();
59 virtual Selection& selection();
60 virtual FontLoader & fontLoader() { return font_loader_; }
61 virtual int const exec();
62 virtual Gui & gui() { return gui_; }
63 virtual void exit(int status);
64 virtual bool event(QEvent * e);
66 virtual std::string const romanFontName();
67 virtual std::string const sansFontName();
68 virtual std::string const typewriterFontName();
69 virtual bool getRgbColor(Color_color col, RGBColor & rgbcol);
70 virtual std::string const hexName(Color_color col);
71 virtual void updateColor(Color_color col);
72 virtual void registerSocketCallback(
73 int fd, boost::function<void()> func);
74 void unregisterSocketCallback(int fd);
77 /// Methods inherited from \c Application class
79 virtual bool notify(QObject * receiver, QEvent * event);
83 ColorCache & colorCache() { return color_cache_; }
86 GuiFontLoader & guiFontLoader() { return font_loader_; }
90 void execBatchCommands();
94 GuiImplementation gui_;
96 GuiClipboard clipboard_;
98 GuiSelection selection_;
100 GuiFontLoader font_loader_;
102 ColorCache color_cache_;
104 QTranslator qt_trans_;
106 std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
110 bool x11EventFilter (XEvent * ev);
113 /// A translator suitable for the entries in the LyX menu.
114 /// Only needed with Qt/Mac.
115 void addMenuTranslator();
117 boost::scoped_ptr<MenuTranslator> menu_trans_;
120 extern GuiApplication * guiApp;
122 } // namespace frontend
127 #endif // QT4_APPLICATION_H