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 /// Method inherited from \c Application class
57 bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
58 bool dispatch(FuncRequest const &);
60 void restoreGuiSession();
61 Clipboard & clipboard();
62 Selection & selection();
63 FontLoader & fontLoader();
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;
77 Toolbars const & toolbars() const;
78 Toolbars & toolbars();
79 Menus const & menus() const;
81 /// Methods inherited from \c QApplication class
83 bool notify(QObject * receiver, QEvent * event);
84 void commitData(QSessionManager & sm);
86 bool x11EventFilter(XEvent * ev);
90 /// Create the main window with given geometry settings.
91 /// \param geometry_arg: only for Windows platform.
92 /// \param optional id identifier.
93 void createView(QString const & geometry_arg = QString(),
94 bool autoShow = true, int id = 0);
95 /// FIXME: this method and the one above are quite ugly.
96 void createView(int id);
98 GuiView const * currentView() const { return current_view_; }
100 GuiView * currentView() { return current_view_; }
102 void setCurrentView(GuiView * view) { current_view_ = view; }
104 QList<int> viewIds() const;
107 ColorCache & colorCache();
109 QAbstractItemModel * languageModel();
111 /// return a suitable serif font name.
112 QString const romanFontName();
114 /// return a suitable sans serif font name.
115 QString const sansFontName();
117 /// return a suitable monospaced font name.
118 QString const typewriterFontName();
120 void unregisterView(GuiView * gv);
122 GuiView & view(int id) const;
126 void execBatchCommands();
128 void socketDataReceived(int fd);
129 /// events to be triggered by general_timer_ should go here
130 void handleRegularEvents();
132 void onLastWindowClosed();
136 bool closeAllViews();
137 /// read the given ui (menu/toolbar) file
138 bool readUIFile(QString const & name, bool include = false);
140 /// This LyXView is the one receiving Clipboard and Selection
142 GuiView * current_view_;
148 extern GuiApplication * guiApp;
150 /// \return the icon file name for the given action.
151 QString iconName(FuncRequest const & f, bool unknown);
153 /// \return an icon for the given action.
154 QIcon getIcon(FuncRequest const & f, bool unknown);
156 } // namespace frontend
159 #endif // GUIAPPLICATION_H