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