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"
19 #include <QApplication>
23 class QSessionManager;
24 class QAbstractItemModel;
25 class QSortFilterProxyModel;
41 /// The Qt main application class
43 There should be only one instance of this class. No Qt object
44 initialisation should be done before the instanciation of this class.
46 class GuiApplication : public QApplication, public Application
51 GuiApplication(int & argc, char ** argv);
54 /// Method inherited from \c Application class
56 FuncStatus getStatus(FuncRequest const &);
57 bool dispatch(FuncRequest const &);
59 void restoreGuiSession();
60 Clipboard & clipboard();
61 Selection & selection();
62 FontLoader & fontLoader();
64 void exit(int status);
65 bool event(QEvent * e);
66 bool getRgbColor(ColorCode col, RGBColor & rgbcol);
67 std::string const hexName(ColorCode col);
68 void updateColor(ColorCode col);
69 void readMenus(Lexer & lex);
70 void initGlobalMenu();
71 void registerSocketCallback(int fd, SocketCallback func);
72 void unregisterSocketCallback(int fd);
73 bool searchMenu(FuncRequest const & func, std::vector<docstring> & names) const;
74 void hideDialogs(std::string const & name, Inset * inset) const;
75 Buffer const * updateInset(Inset const * inset) const;
78 Menus const & menus() const;
80 /// Methods inherited from \c QApplication class
82 bool notify(QObject * receiver, QEvent * event);
83 void commitData(QSessionManager & sm);
85 bool x11EventFilter(XEvent * ev);
89 /// Create the main window with given geometry settings.
90 /// \param geometry_arg: only for Windows platform.
91 void createView(QString const & geometry_arg = QString(),
92 bool autoShow = true);
94 GuiView const * currentView() const { return current_view_; }
96 GuiView * currentView() { return current_view_; }
98 void setCurrentView(GuiView * view) { current_view_ = view; }
100 size_t viewCount() const;
102 std::vector<int> const & viewIds();
105 ColorCache & colorCache();
107 QAbstractItemModel * languageModel();
109 /// return a suitable serif font name.
110 QString const romanFontName();
112 /// return a suitable sans serif font name.
113 QString const sansFontName();
115 /// return a suitable monospaced font name.
116 QString const typewriterFontName();
118 bool unregisterView(int id);
120 GuiView & view(int id) const;
124 void execBatchCommands();
126 void socketDataReceived(int fd);
127 /// events to be triggered by general_timer_ should go here
128 void handleRegularEvents();
130 void onLastWindowClosed();
134 bool closeAllViews();
135 /// This LyXView is the one receiving Clipboard and Selection
137 GuiView * current_view_;
143 extern GuiApplication * guiApp;
145 } // namespace frontend
148 #endif // GUIAPPLICATION_H