]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
Compil fix.
[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 <QObject>
20 #include <QList>
21
22 class QSessionManager;
23 class QAbstractItemModel;
24 class QSortFilterProxyModel;
25
26 namespace lyx {
27
28 class BufferView;
29 class ColorCache;
30
31 namespace frontend {
32
33 class GuiView;
34 class LyXView;
35 class GlobalMenuBar;
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 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 registerSocketCallback(int fd, SocketCallback func);
69         void unregisterSocketCallback(int fd);
70         bool searchMenu(FuncRequest const & func, docstring_list & names) const;
71         void hideDialogs(std::string const & name, Inset * inset) const;
72         Buffer const * updateInset(Inset const * inset) const;
73         //@}
74
75         Toolbars const & toolbars() const;
76         Toolbars & toolbars();
77         Menus const & menus() const;
78         Menus & menus();
79         /// Methods inherited from \c QApplication class
80         //@{
81         bool notify(QObject * receiver, QEvent * event);
82         void commitData(QSessionManager & sm);
83 #ifdef Q_WS_X11
84         bool x11EventFilter(XEvent * ev);
85 #endif
86         //@}
87
88         /// Create the main window with given geometry settings.
89         /// \param geometry_arg: only for Windows platform.
90         void createView(QString const & geometry_arg = QString(),
91                 bool autoShow = true);
92         ///
93         GuiView const * currentView() const { return current_view_; }
94         ///
95         GuiView * currentView() { return current_view_; }
96         ///
97         void setCurrentView(GuiView * view) { current_view_ = view; }
98         ///
99         QList<int> viewIds() const;
100
101         ///
102         ColorCache & colorCache();
103
104         QAbstractItemModel * languageModel();
105
106         /// return a suitable serif font name.
107         QString const romanFontName();
108
109         /// return a suitable sans serif font name.
110         QString const sansFontName();
111
112         /// return a suitable monospaced font name.
113         QString const typewriterFontName();
114         ///
115         void unregisterView(GuiView * gv);
116         ///
117         GuiView & view(int id) const;
118
119 private Q_SLOTS:
120         ///
121         void execBatchCommands();
122         ///
123         void socketDataReceived(int fd);
124         /// events to be triggered by general_timer_ should go here
125         void handleRegularEvents();
126         ///
127         void onLastWindowClosed();
128         
129 private:
130         ///
131         bool closeAllViews();
132         /// read the given ui (menu/toolbar) file
133         bool readUIFile(QString const & name, bool include = false);
134
135         /// This LyXView is the one receiving Clipboard and Selection
136         /// events
137         GuiView * current_view_;
138         ///
139         struct Private;
140         Private * const d;
141 }; // GuiApplication
142
143 extern GuiApplication * guiApp;
144
145 } // namespace frontend
146 } // namespace lyx
147
148 #endif // GUIAPPLICATION_H