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;
43 /// The Qt main application class
45 There should be only one instance of this class. No Qt object
46 initialisation should be done before the instanciation of this class.
48 class GuiApplication : public QApplication, public Application
53 GuiApplication(int & argc, char ** argv);
56 /// Clear all session information.
59 /// Method inherited from \c Application class
61 LyXView * currentWindow();
62 bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
63 void dispatch(FuncRequest const &, DispatchResult & dr);
64 void dispatchDelayed(FuncRequest const &);
66 void restoreGuiSession();
67 Clipboard & clipboard();
68 Selection & selection();
69 FontLoader & fontLoader();
71 void exit(int status);
72 bool event(QEvent * e);
73 bool getRgbColor(ColorCode col, RGBColor & rgbcol);
74 std::string const hexName(ColorCode col);
75 void registerSocketCallback(int fd, SocketCallback func);
76 void unregisterSocketCallback(int fd);
77 bool searchMenu(FuncRequest const & func, docstring_list & names) const;
78 docstring iconName(FuncRequest const & f, bool unknown);
79 void hideDialogs(std::string const & name, Inset * inset) const;
80 Buffer const * updateInset(Inset const * inset) const;
81 void handleKeyFunc(FuncCode action);
84 Toolbars const & toolbars() const;
85 Toolbars & toolbars();
86 Menus const & menus() const;
88 /// Methods inherited from \c QApplication class
90 bool notify(QObject * receiver, QEvent * event);
91 void commitData(QSessionManager & sm);
93 bool x11EventFilter(XEvent * ev);
97 /// Create the main window with given geometry settings.
98 /// \param geometry_arg: only for Windows platform.
99 /// \param optional id identifier.
100 void createView(QString const & geometry_arg = QString(),
101 bool autoShow = true, int id = 0);
102 /// FIXME: this method and the one above are quite ugly.
103 void createView(int id);
105 GuiView const * currentView() const { return current_view_; }
107 GuiView * currentView() { return current_view_; }
109 void setCurrentView(GuiView * view) { current_view_ = view; }
111 QList<int> viewIds() const;
114 ColorCache & colorCache();
116 QAbstractItemModel * languageModel();
118 /// return a suitable serif font name.
119 QString const romanFontName();
121 /// return a suitable sans serif font name.
122 QString const sansFontName();
124 /// return a suitable monospaced font name.
125 QString const typewriterFontName();
127 void unregisterView(GuiView * gv);
129 GuiView & view(int id) const;
131 void processKeySym(KeySymbol const & key, KeyModifier state);
132 /// return the status bar state string
133 docstring viewStatusMessage();
137 void execBatchCommands();
139 void socketDataReceived(int fd);
140 /// events to be triggered by general_timer_ should go here
141 void handleRegularEvents();
143 void onLastWindowClosed();
146 void processFuncRequestQueue();
150 bool closeAllViews();
151 /// read the given ui (menu/toolbar) file
152 bool readUIFile(QString const & name, bool include = false);
154 void setGuiLanguage();
156 /// This LyXView is the one receiving Clipboard and Selection
158 GuiView * current_view_;
164 extern GuiApplication * guiApp;
166 /// \return the icon file name for the given action.
167 QString iconName(FuncRequest const & f, bool unknown);
170 /// \return the pixmap for the given path, name and extension.
171 QPixmap getPixmap(QString const & path, QString const & name, QString const & ext);
173 /// \return an icon for the given action.
174 QIcon getIcon(FuncRequest const & f, bool unknown);
176 GuiApplication * theGuiApp();
178 } // namespace frontend
181 #endif // GUIAPPLICATION_H