2 * \file GuiApplication.h
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * \author Abdelrazak Younes
10 * Full author contact details are available in file CREDITS.
13 #ifndef GUIAPPLICATION_H
14 #define GUIAPPLICATION_H
16 #include "frontends/Application.h"
18 #include <QApplication>
21 class QAbstractItemModel;
24 class QSessionManager;
25 class QSortFilterProxyModel;
42 /// The Qt main application class
44 There should be only one instance of this class. No Qt object
45 initialisation should be done before the instanciation of this class.
47 class GuiApplication : public QApplication, public Application
52 GuiApplication(int & argc, char ** argv);
55 /// Clear all session information.
58 /// Method inherited from \c Application class
60 LyXView * currentWindow();
61 bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
62 bool dispatch(FuncRequest const &);
63 void dispatchDelayed(FuncRequest const &);
65 void restoreGuiSession();
66 Clipboard & clipboard();
67 Selection & selection();
68 FontLoader & fontLoader();
70 void exit(int status);
71 bool event(QEvent * e);
72 bool getRgbColor(ColorCode col, RGBColor & rgbcol);
73 std::string const hexName(ColorCode col);
74 void registerSocketCallback(int fd, SocketCallback func);
75 void unregisterSocketCallback(int fd);
76 bool searchMenu(FuncRequest const & func, docstring_list & names) const;
77 docstring iconName(FuncRequest const & f, bool unknown);
78 void hideDialogs(std::string const & name, Inset * inset) const;
79 Buffer const * updateInset(Inset const * inset) const;
82 Toolbars const & toolbars() const;
83 Toolbars & toolbars();
84 Menus const & menus() const;
86 /// Methods inherited from \c QApplication class
88 bool notify(QObject * receiver, QEvent * event);
89 void commitData(QSessionManager & sm);
91 bool x11EventFilter(XEvent * ev);
95 /// Create the main window with given geometry settings.
96 /// \param geometry_arg: only for Windows platform.
97 /// \param optional id identifier.
98 void createView(QString const & geometry_arg = QString(),
99 bool autoShow = true, int id = 0);
100 /// FIXME: this method and the one above are quite ugly.
101 void createView(int id);
103 GuiView const * currentView() const { return current_view_; }
105 GuiView * currentView() { return current_view_; }
107 void setCurrentView(GuiView * view) { current_view_ = view; }
109 QList<int> viewIds() const;
112 ColorCache & colorCache();
114 QAbstractItemModel * languageModel();
116 /// return a suitable serif font name.
117 QString const romanFontName();
119 /// return a suitable sans serif font name.
120 QString const sansFontName();
122 /// return a suitable monospaced font name.
123 QString const typewriterFontName();
125 void unregisterView(GuiView * gv);
127 GuiView & view(int id) const;
131 void execBatchCommands();
133 void socketDataReceived(int fd);
134 /// events to be triggered by general_timer_ should go here
135 void handleRegularEvents();
137 void onLastWindowClosed();
140 void processFuncRequestQueue();
144 bool closeAllViews();
145 /// read the given ui (menu/toolbar) file
146 bool readUIFile(QString const & name, bool include = false);
148 void setGuiLanguage();
150 /// This LyXView is the one receiving Clipboard and Selection
152 GuiView * current_view_;
158 extern GuiApplication * guiApp;
160 /// \return the icon file name for the given action.
161 QString iconName(FuncRequest const & f, bool unknown);
164 /// \return the pixmap for the given path, name and extension.
165 QPixmap getPixmap(QString const & path, QString const & name, QString const & ext);
167 /// \return an icon for the given action.
168 QIcon getIcon(FuncRequest const & f, bool unknown);
170 GuiApplication * theGuiApp();
172 } // namespace frontend
175 #endif // GUIAPPLICATION_H