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 Clipboard & clipboard();
60 virtual Selection & selection();
61 virtual FontLoader & fontLoader() { return font_loader_; }
63 virtual void exit(int status);
64 virtual bool event(QEvent * e);
65 virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
66 virtual std::string const hexName(ColorCode col);
67 virtual void updateColor(ColorCode col);
68 virtual void registerSocketCallback(int fd, SocketCallback func);
69 void unregisterSocketCallback(int fd);
70 LyXView & createView(std::string const & geometry_arg);
73 /// Methods inherited from \c QApplication class
75 bool notify(QObject * receiver, QEvent * event);
76 void commitData(QSessionManager & sm);
80 GuiView const * currentView() const { return current_view_; }
82 GuiView * currentView() { return current_view_; }
84 void setCurrentView(GuiView & view) { current_view_ = &view; }
86 virtual size_t viewCount() const { return view_ids_.size(); }
88 std::vector<int> const & viewIds() { return view_ids_; }
91 ColorCache & colorCache() { return color_cache_; }
93 GuiFontLoader & guiFontLoader() { return font_loader_; }
95 /// return a suitable serif font name.
96 virtual QString const romanFontName();
98 /// return a suitable sans serif font name.
99 virtual QString const sansFontName();
101 /// return a suitable monospaced font name.
102 virtual QString const typewriterFontName();
104 virtual bool closeAllViews();
106 virtual bool unregisterView(int id);
108 virtual LyXView & view(int id) const;
110 virtual void hideDialogs(std::string const & name, Inset * inset) const;
112 virtual Buffer const * updateInset(Inset const * inset) const;
116 void execBatchCommands();
118 void socketDataReceived(int fd);
122 GuiClipboard clipboard_;
124 GuiSelection selection_;
126 GuiFontLoader font_loader_;
128 ColorCache color_cache_;
130 QTranslator qt_trans_;
132 std::map<int, SocketNotifier *> socket_notifiers_;
136 bool x11EventFilter(XEvent * ev);
138 /// A translator suitable for the entries in the LyX menu.
139 /// Only needed with Qt/Mac.
140 void addMenuTranslator();
142 /// Multiple views container.
144 * Warning: This must not be a smart pointer as the destruction of the
145 * object is handled by Qt when the view is closed
146 * \sa Qt::WA_DeleteOnClose attribute.
148 std::map<int, GuiView *> views_;
150 std::vector<int> view_ids_;
151 /// This LyXView is the one receiving Clipboard and Selection
153 GuiView * current_view_;
156 extern GuiApplication * guiApp;
158 } // namespace frontend
161 #endif // GUIAPPLICATION_H