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 bool getStatus(FuncRequest const & cmd, FuncStatus & flag) 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 readMenus(Lexer & lex);
69 void registerSocketCallback(int fd, SocketCallback func);
70 void unregisterSocketCallback(int fd);
71 bool searchMenu(FuncRequest const & func, std::vector<docstring> & names) const;
72 void hideDialogs(std::string const & name, Inset * inset) const;
73 Buffer const * updateInset(Inset const * inset) const;
76 Menus const & menus() const;
78 /// Methods inherited from \c QApplication class
80 bool notify(QObject * receiver, QEvent * event);
81 void commitData(QSessionManager & sm);
83 bool x11EventFilter(XEvent * ev);
87 /// Create the main window with given geometry settings.
88 /// \param geometry_arg: only for Windows platform.
89 void createView(QString const & geometry_arg = QString(),
90 bool autoShow = true);
92 GuiView const * currentView() const { return current_view_; }
94 GuiView * currentView() { return current_view_; }
96 void setCurrentView(GuiView * view) { current_view_ = view; }
98 size_t viewCount() const;
100 std::vector<int> const & viewIds();
103 ColorCache & colorCache();
105 QAbstractItemModel * languageModel();
107 /// return a suitable serif font name.
108 QString const romanFontName();
110 /// return a suitable sans serif font name.
111 QString const sansFontName();
113 /// return a suitable monospaced font name.
114 QString const typewriterFontName();
116 bool unregisterView(int id);
118 GuiView & view(int id) const;
122 void execBatchCommands();
124 void socketDataReceived(int fd);
125 /// events to be triggered by general_timer_ should go here
126 void handleRegularEvents();
128 void onLastWindowClosed();
132 bool closeAllViews();
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