]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
[the "translation" patch series] Part 4: translating the LyX menu on the mac
[lyx.git] / src / frontends / qt4 / GuiApplication.h
1 /**
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.
5  *
6  * \author unknown
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef QT4_APPLICATION_H
14 #define QT4_APPLICATION_H
15
16 #include "ColorCache.h"
17 #include "GuiFontLoader.h"
18 #include "GuiClipboard.h"
19 #include "GuiImplementation.h"
20 #include "GuiSelection.h"
21
22 #include "frontends/Application.h"
23
24 #include <boost/scoped_ptr.hpp>
25
26 #include <QApplication>
27 #include <QTranslator>
28
29 namespace lyx {
30
31 class BufferView;
32 class socket_callback;
33
34 namespace frontend {
35
36 class GuiWorkArea;
37 class MenuTranslator;
38
39 /// The Qt main application class
40 /**
41 There should be only one instance of this class. No Qt object
42 initialisation should be done before the instanciation of this class.
43
44 \todo The work areas handling could be moved to a base virtual class
45 comon to all frontends.
46 */
47 class GuiApplication : public QApplication, public Application
48 {
49         Q_OBJECT
50
51 public:
52         GuiApplication(int & argc, char ** argv);
53         ///
54         virtual ~GuiApplication();
55
56         /// Method inherited from \c Application class
57         //@{
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);
65         void syncEvents();
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);
75         //@}
76
77         /// Methods inherited from \c Application class
78         //@{
79         virtual bool notify(QObject * receiver, QEvent * event);
80         //@}
81
82         ///
83         ColorCache & colorCache() { return color_cache_; }
84         ///
85         ///
86         GuiFontLoader & guiFontLoader() { return font_loader_; }
87
88 private Q_SLOTS:
89         ///
90         void execBatchCommands();
91
92 private:
93         ///
94         GuiImplementation gui_;
95         ///
96         GuiClipboard clipboard_;
97         ///
98         GuiSelection selection_;
99         ///
100         GuiFontLoader font_loader_;
101         ///
102         ColorCache color_cache_;
103         ///
104         QTranslator qt_trans_;
105         ///
106         std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
107
108 #ifdef Q_WS_X11
109 public:
110         bool x11EventFilter (XEvent * ev);
111 #endif
112
113         /// A translator suitable for the entries in the LyX menu.
114         /// Only needed with Qt/Mac.
115         void addMenuTranslator();
116         ///
117         boost::scoped_ptr<MenuTranslator> menu_trans_;
118 }; // GuiApplication
119
120 extern GuiApplication * guiApp;
121
122 } // namespace frontend
123
124 } // namespace lyx
125
126
127 #endif // QT4_APPLICATION_H