]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
Remove superfluous class definitions.
[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 <QApplication>
19 #include <QList>
20
21 class QAbstractItemModel;
22
23 namespace lyx {
24
25 class BufferView;
26 class ColorCache;
27 class KeySymbol;
28
29 namespace support {
30 class FileName;
31 }
32
33 namespace frontend {
34
35 class GuiView;
36 class GuiWorkArea;
37 class Menus;
38 class SocketNotifier;
39 class Toolbars;
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 instantiation 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         /// \name Methods inherited from Application class
55         //@{
56         void dispatch(FuncRequest const &);
57         void dispatch(FuncRequest const &, DispatchResult & dr);
58         FuncStatus getStatus(FuncRequest const & cmd) const;
59         void restoreGuiSession();
60         Buffer const * updateInset(Inset const * inset) const;
61         int exec();
62         void exit(int status);
63         bool event(QEvent * e);
64         bool getRgbColor(ColorCode col, RGBColor & rgbcol);
65         std::string const hexName(ColorCode col);
66         void registerSocketCallback(int fd, SocketCallback func);
67         void unregisterSocketCallback(int fd);
68         bool searchMenu(FuncRequest const & func, docstring_list & names) const;
69         void handleKeyFunc(FuncCode action);
70         //@}
71
72         ///
73         bool getStatus(FuncRequest const & cmd, FuncStatus & status) const;
74         ///
75         void hideDialogs(std::string const & name, Inset * inset) const;
76         ///
77         void resetGui();
78
79         ///
80         Clipboard & clipboard();
81         ///
82         Selection & selection();
83         ///
84         FontLoader & fontLoader();
85
86         ///
87         Toolbars const & toolbars() const;
88         ///
89         Toolbars & toolbars();
90         ///
91         Menus const & menus() const;
92         ///
93         Menus & menus();
94
95         /// \name Methods inherited from QApplication class
96         //@{
97         bool notify(QObject * receiver, QEvent * event);
98         void commitData(QSessionManager & sm);
99 #ifdef Q_WS_X11
100         bool x11EventFilter(XEvent * ev);
101 #endif
102         //@}
103
104         /// Create the main window with given geometry settings.
105         /// \param geometry_arg: only for Windows platform.
106         /// \param optional id identifier.
107         void createView(QString const & geometry_arg = QString(),
108                 bool autoShow = true, int id = 0);
109         /// FIXME: this method and the one above are quite ugly.
110         void createView(int id);
111         ///
112         GuiView const * currentView() const { return current_view_; }
113         ///
114         GuiView * currentView() { return current_view_; }
115         ///
116         void setCurrentView(GuiView * view) { current_view_ = view; }
117         ///
118         QList<int> viewIds() const;
119
120         /// Clear all session information.
121         void clearSession();
122
123         ///
124         ColorCache & colorCache();
125         ///
126         QAbstractItemModel * languageModel();
127
128         /// return a suitable serif font name.
129         QString const romanFontName();
130
131         /// return a suitable sans serif font name.
132         QString const sansFontName();
133
134         /// return a suitable monospaced font name.
135         QString const typewriterFontName();
136         ///
137         void unregisterView(GuiView * gv);
138         ///
139         GuiView & view(int id) const;
140         ///
141         void processKeySym(KeySymbol const & key, KeyModifier state);
142         /// return the status bar state string
143         docstring viewStatusMessage();
144
145         /// \name Methods to process FuncRequests
146         //@{
147         /// process the func request
148         void processFuncRequest(FuncRequest const &);
149         /// add a func request to the queue and process it asynchronously
150         /// \note As a side-effect this will also process the
151         /// func requests that were added to the queue before.
152         void processFuncRequestAsync(FuncRequest const &);
153         /// process the func requests in the queue
154         void processFuncRequestQueue();
155         /// process the func requests in the queue asynchronously
156         void processFuncRequestQueueAsync();
157         /// add a func request to the queue for later processing
158         void addToFuncRequestQueue(FuncRequest const &);
159         //@}
160
161         /// goto a bookmark
162         /// openFile: whether or not open a file if the file is not opened
163         /// switchToBuffer: whether or not switch to buffer if the buffer is
164         ///             not the current buffer
165         void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
166
167         /// Start a long operation with some cancel possibility (button or ESC)
168         void startLongOperation();
169         /// This needs to be periodically called to avoid freezing the GUI
170         bool longOperationCancelled();
171         /// Stop the long operation mode (i.e., release the GUI)
172         void stopLongOperation();
173         /// A started long operation is still in progress ?
174         bool longOperationStarted();
175 private Q_SLOTS:
176         ///
177         void execBatchCommands();
178         ///
179         void socketDataReceived(int fd);
180         /// events to be triggered by Private::general_timer_ should go here
181         void handleRegularEvents();
182         ///
183         void onLastWindowClosed();
184         ///
185         void slotProcessFuncRequestQueue() { processFuncRequestQueue(); }
186
187 private:
188         ///
189         void validateCurrentView();
190         ///
191         void updateCurrentView(FuncRequest const & cmd, DispatchResult & dr);
192         ///
193         bool closeAllViews();
194         /// read the given ui (menu/toolbar) file
195         bool readUIFile(QString const & name, bool include = false);
196         ///
197         enum ReturnValues {
198                 ReadOK,
199                 ReadError,
200                 FormatMismatch
201         };
202         ///
203         ReturnValues readUIFile(support::FileName);
204         ///
205         void setGuiLanguage();
206         ///
207         void reconfigure(std::string const & option);
208
209         /// This GuiView is the one receiving Clipboard and Selection
210         /// events
211         GuiView * current_view_;
212
213         ///
214         struct Private;
215         Private * const d;
216 }; // GuiApplication
217
218 extern GuiApplication * guiApp;
219
220 /// \return the icon file name for the given action.
221 QString iconName(FuncRequest const & f, bool unknown);
222
223 /// \return the pixmap for the given path, name and extension.
224 QPixmap getPixmap(QString const & path, QString const & name, QString const & ext);
225
226 /// \return an icon for the given action.
227 QIcon getIcon(FuncRequest const & f, bool unknown);
228
229 ///
230 GuiApplication * theGuiApp();
231
232 } // namespace frontend
233 } // namespace lyx
234
235 #endif // GUIAPPLICATION_H