]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
shuffle some code around
[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 <QApplication>
25 #include <QTranslator>
26
27 class QSessionManager;
28
29 namespace lyx {
30
31 class BufferView;
32
33 namespace frontend {
34
35 class GuiWorkArea;
36 class SocketNotifier;
37
38 /// The Qt main application class
39 /**
40 There should be only one instance of this class. No Qt object
41 initialisation should be done before the instanciation of this class.
42
43 \todo The work areas handling could be moved to a base virtual class
44 comon to all frontends.
45 */
46 class GuiApplication : public QApplication, public Application
47 {
48         Q_OBJECT
49
50 public:
51         GuiApplication(int & argc, char ** argv);
52         ///
53         virtual ~GuiApplication();
54
55         /// Method inherited from \c Application class
56         //@{
57         virtual Clipboard & clipboard();
58         virtual Selection & selection();
59         virtual FontLoader & fontLoader() { return font_loader_; }
60         virtual int exec();
61         virtual Gui & gui() { return gui_; }
62         virtual Gui const & gui() const { 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(ColorCode col, RGBColor & rgbcol);
70         virtual std::string const hexName(ColorCode col);
71         virtual void updateColor(ColorCode col);
72         virtual void registerSocketCallback(int fd, SocketCallback func);
73         void unregisterSocketCallback(int fd);
74         LyXView & createView(std::string const & geometry_arg);
75         //@}
76
77         /// Methods inherited from \c QApplication class
78         //@{
79         bool notify(QObject * receiver, QEvent * event);
80         void commitData(QSessionManager & sm);
81         //@}
82
83         ///
84         ColorCache & colorCache() { return color_cache_; }
85         ///
86         ///
87         GuiFontLoader & guiFontLoader() { return font_loader_; }
88
89 private Q_SLOTS:
90         ///
91         void execBatchCommands();
92         ///
93         void socketDataReceived(int fd);
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, SocketNotifier *> socket_notifiers_;
110
111 #ifdef Q_WS_X11
112 public:
113         bool x11EventFilter(XEvent * ev);
114 #endif
115         /// A translator suitable for the entries in the LyX menu.
116         /// Only needed with Qt/Mac.
117         void addMenuTranslator();
118 }; // GuiApplication
119
120 extern GuiApplication * guiApp;
121
122 } // namespace frontend
123 } // namespace lyx
124
125 #endif // GUIAPPLICATION_H