]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
* Application: change the signature of getStatus() to reflect the one of GuiView.
[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 "frontends/Application.h"
17
18 #include <QObject>
19 #include <QApplication>
20
21 #include <vector>
22
23 class QSessionManager;
24 class QAbstractItemModel;
25 class QSortFilterProxyModel;
26
27 namespace lyx {
28
29 class BufferView;
30 class ColorCache;
31
32 namespace frontend {
33
34 class GuiView;
35 class LyXView;
36 class GlobalMenuBar;
37 class GuiWorkArea;
38 class Menus;
39 class SocketNotifier;
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 class GuiApplication : public QApplication, public Application
47 {
48         Q_OBJECT
49
50 public:
51         GuiApplication(int & argc, char ** argv);
52         ~GuiApplication();
53
54         /// Method inherited from \c Application class
55         //@{
56         bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
57         bool dispatch(FuncRequest const &);
58         void resetGui();
59         void restoreGuiSession();
60         Clipboard & clipboard();
61         Selection & selection();
62         FontLoader & fontLoader();
63         int exec();
64         void exit(int status);
65         bool event(QEvent * e);
66         bool getRgbColor(ColorCode col, RGBColor & rgbcol);
67         std::string const hexName(ColorCode col);
68         void readMenus(Lexer & lex);
69         void registerSocketCallback(int fd, SocketCallback func);
70         void unregisterSocketCallback(int fd);
71         bool searchMenu(FuncRequest const & func, std::vector<docstring> & names) const;
72         void hideDialogs(std::string const & name, Inset * inset) const;
73         Buffer const * updateInset(Inset const * inset) const;
74         //@}
75
76         Menus const & menus() const;
77         Menus & menus();
78         /// Methods inherited from \c QApplication class
79         //@{
80         bool notify(QObject * receiver, QEvent * event);
81         void commitData(QSessionManager & sm);
82 #ifdef Q_WS_X11
83         bool x11EventFilter(XEvent * ev);
84 #endif
85         //@}
86
87         /// Create the main window with given geometry settings.
88         /// \param geometry_arg: only for Windows platform.
89         void createView(QString const & geometry_arg = QString(),
90                 bool autoShow = true);
91         ///
92         GuiView const * currentView() const { return current_view_; }
93         ///
94         GuiView * currentView() { return current_view_; }
95         ///
96         void setCurrentView(GuiView * view) { current_view_ = view; }
97         ///
98         size_t viewCount() const;
99         ///
100         std::vector<int> const & viewIds();
101
102         ///
103         ColorCache & colorCache();
104
105         QAbstractItemModel * languageModel();
106
107         /// return a suitable serif font name.
108         QString const romanFontName();
109
110         /// return a suitable sans serif font name.
111         QString const sansFontName();
112
113         /// return a suitable monospaced font name.
114         QString const typewriterFontName();
115         ///
116         bool unregisterView(int id);
117         ///
118         GuiView & view(int id) const;
119
120 private Q_SLOTS:
121         ///
122         void execBatchCommands();
123         ///
124         void socketDataReceived(int fd);
125         /// events to be triggered by general_timer_ should go here
126         void handleRegularEvents();
127         ///
128         void onLastWindowClosed();
129         
130 private:
131         ///
132         bool closeAllViews();
133         /// This LyXView is the one receiving Clipboard and Selection
134         /// events
135         GuiView * current_view_;
136         ///
137         struct Private;
138         Private * const d;
139 }; // GuiApplication
140
141 extern GuiApplication * guiApp;
142
143 } // namespace frontend
144 } // namespace lyx
145
146 #endif // GUIAPPLICATION_H