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 /// \name Methods inherited from 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;
89 /// \name Methods inherited from QApplication class
91 bool notify(QObject * receiver, QEvent * event);
92 void commitData(QSessionManager & sm);
94 bool x11EventFilter(XEvent * ev);
98 /// Create the main window with given geometry settings.
99 /// \param geometry_arg: only for Windows platform.
100 /// \param optional id identifier.
101 void createView(QString const & geometry_arg = QString(),
102 bool autoShow = true, int id = 0);
103 /// FIXME: this method and the one above are quite ugly.
104 void createView(int id);
106 GuiView const * currentView() const { return current_view_; }
108 GuiView * currentView() { return current_view_; }
110 void setCurrentView(GuiView * view) { current_view_ = view; }
112 QList<int> viewIds() const;
115 ColorCache & colorCache();
117 QAbstractItemModel * languageModel();
119 /// return a suitable serif font name.
120 QString const romanFontName();
122 /// return a suitable sans serif font name.
123 QString const sansFontName();
125 /// return a suitable monospaced font name.
126 QString const typewriterFontName();
128 void unregisterView(GuiView * gv);
130 GuiView & view(int id) const;
132 void processKeySym(KeySymbol const & key, KeyModifier state);
133 /// return the status bar state string
134 docstring viewStatusMessage();
138 void execBatchCommands();
140 void socketDataReceived(int fd);
141 /// events to be triggered by general_timer_ should go here
142 void handleRegularEvents();
144 void onLastWindowClosed();
147 void processFuncRequestQueue();
151 bool closeAllViews();
152 /// read the given ui (menu/toolbar) file
153 bool readUIFile(QString const & name, bool include = false);
155 void setGuiLanguage();
157 /// This LyXView is the one receiving Clipboard and Selection
159 GuiView * current_view_;
165 extern GuiApplication * guiApp;
167 /// \return the icon file name for the given action.
168 QString iconName(FuncRequest const & f, bool unknown);
171 /// \return the pixmap for the given path, name and extension.
172 QPixmap getPixmap(QString const & path, QString const & name, QString const & ext);
174 /// \return an icon for the given action.
175 QIcon getIcon(FuncRequest const & f, bool unknown);
177 GuiApplication * theGuiApp();
179 } // namespace frontend
182 #endif // GUIAPPLICATION_H