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 /// Clear all session information.
58 /// \name Methods inherited from Application class
60 void dispatch(FuncRequest const &);
61 void dispatch(FuncRequest const &, DispatchResult & dr);
62 FuncStatus getStatus(FuncRequest const & cmd) const;
63 void dispatchDelayed(FuncRequest const &);
64 void restoreGuiSession();
65 Clipboard & clipboard();
66 Selection & selection();
67 FontLoader & fontLoader();
69 void exit(int status);
70 bool event(QEvent * e);
71 bool getRgbColor(ColorCode col, RGBColor & rgbcol);
72 std::string const hexName(ColorCode col);
73 void registerSocketCallback(int fd, SocketCallback func);
74 void unregisterSocketCallback(int fd);
75 bool searchMenu(FuncRequest const & func, docstring_list & names) const;
76 docstring iconName(FuncRequest const & f, bool unknown);
77 Buffer const * updateInset(Inset const * inset) const;
78 void handleKeyFunc(FuncCode action);
81 bool getStatus(FuncRequest const & cmd, FuncStatus & status) const;
83 void hideDialogs(std::string const & name, Inset * inset) const;
87 Toolbars const & toolbars() const;
88 Toolbars & toolbars();
89 Menus const & menus() const;
92 /// \name Methods inherited from QApplication class
94 bool notify(QObject * receiver, QEvent * event);
95 void commitData(QSessionManager & sm);
97 bool x11EventFilter(XEvent * ev);
101 /// Create the main window with given geometry settings.
102 /// \param geometry_arg: only for Windows platform.
103 /// \param optional id identifier.
104 void createView(QString const & geometry_arg = QString(),
105 bool autoShow = true, int id = 0);
106 /// FIXME: this method and the one above are quite ugly.
107 void createView(int id);
109 GuiView const * currentView() const { return current_view_; }
111 GuiView * currentView() { return current_view_; }
113 void setCurrentView(GuiView * view) { current_view_ = view; }
115 QList<int> viewIds() const;
118 ColorCache & colorCache();
120 QAbstractItemModel * languageModel();
122 /// return a suitable serif font name.
123 QString const romanFontName();
125 /// return a suitable sans serif font name.
126 QString const sansFontName();
128 /// return a suitable monospaced font name.
129 QString const typewriterFontName();
131 void unregisterView(GuiView * gv);
133 GuiView & view(int id) const;
135 void processKeySym(KeySymbol const & key, KeyModifier state);
136 /// return the status bar state string
137 docstring viewStatusMessage();
140 /// openFile: whether or not open a file if the file is not opened
141 /// switchToBuffer: whether or not switch to buffer if the buffer is
142 /// not the current buffer
143 void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
147 void execBatchCommands();
149 void socketDataReceived(int fd);
150 /// events to be triggered by general_timer_ should go here
151 void handleRegularEvents();
153 void onLastWindowClosed();
156 void processFuncRequestQueue();
160 bool closeAllViews();
161 /// read the given ui (menu/toolbar) file
162 bool readUIFile(QString const & name, bool include = false);
164 void setGuiLanguage();
166 void reconfigure(std::string const & option);
168 /// This GuiView is the one receiving Clipboard and Selection
170 GuiView * current_view_;
177 extern GuiApplication * guiApp;
179 /// \return the icon file name for the given action.
180 QString iconName(FuncRequest const & f, bool unknown);
183 /// \return the pixmap for the given path, name and extension.
184 QPixmap getPixmap(QString const & path, QString const & name, QString const & ext);
186 /// \return an icon for the given action.
187 QIcon getIcon(FuncRequest const & f, bool unknown);
189 GuiApplication * theGuiApp();
191 } // namespace frontend
194 #endif // GUIAPPLICATION_H