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