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>
22 class QSessionManager;
23 class QAbstractItemModel;
24 class QSortFilterProxyModel;
40 /// The Qt main application class
42 There should be only one instance of this class. No Qt object
43 initialisation should be done before the instanciation of this class.
45 class GuiApplication : public QApplication, public Application
50 GuiApplication(int & argc, char ** argv);
53 /// Method inherited from \c Application class
55 bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
56 bool dispatch(FuncRequest const &);
58 void restoreGuiSession();
59 Clipboard & clipboard();
60 Selection & selection();
61 FontLoader & fontLoader();
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;
75 Menus const & menus() const;
77 /// Methods inherited from \c QApplication class
79 bool notify(QObject * receiver, QEvent * event);
80 void commitData(QSessionManager & sm);
82 bool x11EventFilter(XEvent * ev);
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);
91 GuiView const * currentView() const { return current_view_; }
93 GuiView * currentView() { return current_view_; }
95 void setCurrentView(GuiView * view) { current_view_ = view; }
97 QList<int> viewIds() const;
100 ColorCache & colorCache();
102 QAbstractItemModel * languageModel();
104 /// return a suitable serif font name.
105 QString const romanFontName();
107 /// return a suitable sans serif font name.
108 QString const sansFontName();
110 /// return a suitable monospaced font name.
111 QString const typewriterFontName();
113 void unregisterView(GuiView * gv);
115 GuiView & view(int id) const;
119 void execBatchCommands();
121 void socketDataReceived(int fd);
122 /// events to be triggered by general_timer_ should go here
123 void handleRegularEvents();
125 void onLastWindowClosed();
129 bool closeAllViews();
130 /// read the given ui (menu/toolbar) file
131 bool readUIFile(std::string const & name, bool include = false);
133 /// This LyXView is the one receiving Clipboard and Selection
135 GuiView * current_view_;
141 extern GuiApplication * guiApp;
143 } // namespace frontend
146 #endif // GUIAPPLICATION_H