]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
Merge QController into individual dialogs. Also various cleanup
[lyx.git] / src / frontends / qt4 / GuiApplication.h
1 /**
2  * \file 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 GUIAPPLICATION_H
14 #define GUIAPPLICATION_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 class QSessionManager;
30
31 namespace lyx {
32
33 class BufferView;
34 class socket_callback;
35
36 namespace frontend {
37
38 class GuiWorkArea;
39 class MenuTranslator;
40
41 /// The Qt main application class
42 /**
43 There should be only one instance of this class. No Qt object
44 initialisation should be done before the instanciation of this class.
45
46 \todo The work areas handling could be moved to a base virtual class
47 comon to all frontends.
48 */
49 class GuiApplication : public QApplication, public Application
50 {
51         Q_OBJECT
52
53 public:
54         GuiApplication(int & argc, char ** argv);
55         ///
56         virtual ~GuiApplication();
57
58         /// Method inherited from \c Application class
59         //@{
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);
67         void syncEvents();
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);
77         //@}
78
79         /// Methods inherited from \c QApplication class
80         //@{
81         bool notify(QObject * receiver, QEvent * event);
82         void commitData(QSessionManager & sm);
83         //@}
84
85         ///
86         ColorCache & colorCache() { return color_cache_; }
87         ///
88         ///
89         GuiFontLoader & guiFontLoader() { return font_loader_; }
90
91 private Q_SLOTS:
92         ///
93         void execBatchCommands();
94
95 private:
96         ///
97         GuiImplementation gui_;
98         ///
99         GuiClipboard clipboard_;
100         ///
101         GuiSelection selection_;
102         ///
103         GuiFontLoader font_loader_;
104         ///
105         ColorCache color_cache_;
106         ///
107         QTranslator qt_trans_;
108         ///
109         std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
110
111 #ifdef Q_WS_X11
112 public:
113         bool x11EventFilter (XEvent * ev);
114 #endif
115
116         /// A translator suitable for the entries in the LyX menu.
117         /// Only needed with Qt/Mac.
118         void addMenuTranslator();
119         ///
120         boost::scoped_ptr<MenuTranslator> menu_trans_;
121 }; // GuiApplication
122
123 extern GuiApplication * guiApp;
124
125 } // namespace frontend
126
127 } // namespace lyx
128
129
130 #endif // GUIAPPLICATION_H