]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiApplication.h
Fix whitespaces so the diff between branches is not so huge.
[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 class QIcon;
23 class QObject;
24 class QSessionManager;
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 class Toolbars;
41
42 /// The Qt main application class
43 /**
44 There should be only one instance of this class. No Qt object
45 initialisation should be done before the instanciation of this class.
46 */
47 class GuiApplication : public QApplication, public Application
48 {
49         Q_OBJECT
50
51 public:
52         GuiApplication(int & argc, char ** argv);
53         ~GuiApplication();
54
55         /// Clear all session information.
56         void clearSession();
57
58         /// Method inherited from \c Application class
59         //@{
60         bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
61         bool dispatch(FuncRequest const &);
62         void resetGui();
63         void restoreGuiSession();
64         Clipboard & clipboard();
65         Selection & selection();
66         FontLoader & fontLoader();
67         int exec();
68         void exit(int status);
69         bool event(QEvent * e);
70         bool getRgbColor(ColorCode col, RGBColor & rgbcol);
71         std::string const hexName(ColorCode col);
72         void registerSocketCallback(int fd, SocketCallback func);
73         void unregisterSocketCallback(int fd);
74         bool searchMenu(FuncRequest const & func, docstring_list & names) const;
75         docstring iconName(FuncRequest const & f, bool unknown);
76         void hideDialogs(std::string const & name, Inset * inset) const;
77         Buffer const * updateInset(Inset const * inset) const;
78         //@}
79
80         Toolbars const & toolbars() const;
81         Toolbars & toolbars();
82         Menus const & menus() const;
83         Menus & menus();
84         /// Methods inherited from \c QApplication class
85         //@{
86         bool notify(QObject * receiver, QEvent * event);
87         void commitData(QSessionManager & sm);
88 #ifdef Q_WS_X11
89         bool x11EventFilter(XEvent * ev);
90 #endif
91         //@}
92
93         /// Create the main window with given geometry settings.
94         /// \param geometry_arg: only for Windows platform.
95         /// \param optional id identifier.
96         void createView(QString const & geometry_arg = QString(),
97                 bool autoShow = true, int id = 0);
98         /// FIXME: this method and the one above are quite ugly.
99         void createView(int id);
100         ///
101         GuiView const * currentView() const { return current_view_; }
102         ///
103         GuiView * currentView() { return current_view_; }
104         ///
105         void setCurrentView(GuiView * view) { current_view_ = view; }
106         ///
107         QList<int> viewIds() const;
108
109         ///
110         ColorCache & colorCache();
111
112         QAbstractItemModel * languageModel();
113
114         /// return a suitable serif font name.
115         QString const romanFontName();
116
117         /// return a suitable sans serif font name.
118         QString const sansFontName();
119
120         /// return a suitable monospaced font name.
121         QString const typewriterFontName();
122         ///
123         void unregisterView(GuiView * gv);
124         ///
125         GuiView & view(int id) const;
126
127 private Q_SLOTS:
128         ///
129         void execBatchCommands();
130         ///
131         void socketDataReceived(int fd);
132         /// events to be triggered by general_timer_ should go here
133         void handleRegularEvents();
134         ///
135         void onLastWindowClosed();
136
137 private:
138         ///
139         bool closeAllViews();
140         /// read the given ui (menu/toolbar) file
141         bool readUIFile(QString const & name, bool include = false);
142         ///
143         void setGuiLanguage();
144
145         /// This LyXView is the one receiving Clipboard and Selection
146         /// events
147         GuiView * current_view_;
148         ///
149         struct Private;
150         Private * const d;
151 }; // GuiApplication
152
153 extern GuiApplication * guiApp;
154
155 /// \return the icon file name for the given action.
156 QString iconName(FuncRequest const & f, bool unknown);
157
158 /// \return an icon for the given action.
159 QIcon getIcon(FuncRequest const & f, bool unknown);
160
161 } // namespace frontend
162 } // namespace lyx
163
164 #endif // GUIAPPLICATION_H