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);
66 virtual std::string const romanFontName();
67 virtual std::string const sansFontName();
68 virtual std::string const typewriterFontName();
69 virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
70 virtual std::string const hexName(ColorCode col);
71 virtual void updateColor(ColorCode col);
72 virtual void registerSocketCallback(int fd, SocketCallback func);
73 void unregisterSocketCallback(int fd);
74 LyXView & createView(std::string const & geometry_arg);
77 /// Methods inherited from \c QApplication class
79 bool notify(QObject * receiver, QEvent * event);
80 void commitData(QSessionManager & sm);
83 virtual size_t viewCount() const { return view_ids_.size(); }
84 std::vector<int> const & viewIds() { return view_ids_; }
87 ColorCache & colorCache() { return color_cache_; }
89 GuiFontLoader & guiFontLoader() { return font_loader_; }
92 virtual int createRegisteredView();
93 virtual bool closeAllViews();
94 virtual bool unregisterView(int id);
96 virtual LyXView & view(int id) const;
98 virtual void hideDialogs(std::string const & name, Inset * inset) const;
100 virtual Buffer const * updateInset(Inset const * inset) const;
104 void execBatchCommands();
106 void socketDataReceived(int fd);
110 GuiClipboard clipboard_;
112 GuiSelection selection_;
114 GuiFontLoader font_loader_;
116 ColorCache color_cache_;
118 QTranslator qt_trans_;
120 std::map<int, SocketNotifier *> socket_notifiers_;
124 bool x11EventFilter(XEvent * ev);
126 /// A translator suitable for the entries in the LyX menu.
127 /// Only needed with Qt/Mac.
128 void addMenuTranslator();
130 /// Multiple views container.
132 * Warning: This must not be a smart pointer as the destruction of the
133 * object is handled by Qt when the view is closed
134 * \sa Qt::WA_DeleteOnClose attribute.
136 std::map<int, GuiView *> views_;
138 std::vector<int> view_ids_;
141 extern GuiApplication * guiApp;
143 } // namespace frontend
146 #endif // GUIAPPLICATION_H