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 "ColorCache.h"
17 #include "GuiFontLoader.h"
18 #include "GuiClipboard.h"
19 #include "GuiSelection.h"
21 #include "frontends/Application.h"
24 #include <QApplication>
25 #include <QTranslator>
30 class QSessionManager;
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);
55 virtual ~GuiApplication();
57 /// Method inherited from \c Application class
59 virtual FuncStatus getStatus(FuncRequest const &);
60 virtual void dispatch(FuncRequest const &);
61 virtual void resetGui();
62 virtual Clipboard & clipboard();
63 virtual Selection & selection();
64 virtual FontLoader & fontLoader() { return font_loader_; }
66 virtual void exit(int status);
67 virtual bool event(QEvent * e);
68 virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
69 virtual std::string const hexName(ColorCode col);
70 virtual void updateColor(ColorCode col);
71 virtual void registerSocketCallback(int fd, SocketCallback func);
72 void unregisterSocketCallback(int fd);
73 void createView(std::string const & geometry_arg = std::string());
76 /// Methods inherited from \c QApplication class
78 bool notify(QObject * receiver, QEvent * event);
79 void commitData(QSessionManager & sm);
83 GuiView const * currentView() const { return current_view_; }
85 GuiView * currentView() { return current_view_; }
87 void setCurrentView(GuiView & view) { current_view_ = &view; }
89 virtual size_t viewCount() const { return view_ids_.size(); }
91 std::vector<int> const & viewIds() { return view_ids_; }
94 ColorCache & colorCache() { return color_cache_; }
96 GuiFontLoader & guiFontLoader() { return font_loader_; }
98 /// return a suitable serif font name.
99 virtual QString const romanFontName();
101 /// return a suitable sans serif font name.
102 virtual QString const sansFontName();
104 /// return a suitable monospaced font name.
105 virtual QString const typewriterFontName();
107 virtual bool closeAllViews();
109 virtual bool unregisterView(int id);
111 virtual GuiView & view(int id) const;
113 virtual void hideDialogs(std::string const & name, Inset * inset) const;
115 virtual Buffer const * updateInset(Inset const * inset) const;
119 void execBatchCommands();
121 void socketDataReceived(int fd);
125 GuiClipboard clipboard_;
127 GuiSelection selection_;
129 GuiFontLoader font_loader_;
131 ColorCache color_cache_;
133 QTranslator qt_trans_;
135 std::map<int, SocketNotifier *> socket_notifiers_;
139 bool x11EventFilter(XEvent * ev);
141 /// A translator suitable for the entries in the LyX menu.
142 /// Only needed with Qt/Mac.
143 void addMenuTranslator();
145 /// Multiple views container.
147 * Warning: This must not be a smart pointer as the destruction of the
148 * object is handled by Qt when the view is closed
149 * \sa Qt::WA_DeleteOnClose attribute.
151 std::map<int, GuiView *> views_;
153 std::vector<int> view_ids_;
154 /// This LyXView is the one receiving Clipboard and Selection
156 GuiView * current_view_;
159 extern GuiApplication * guiApp;
161 } // namespace frontend
164 #endif // GUIAPPLICATION_H