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>
29 class QSessionManager;
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 \todo The work areas handling could be moved to a base virtual class
48 comon to all frontends.
50 class GuiApplication : public QApplication, public Application
55 GuiApplication(int & argc, char ** argv);
57 virtual ~GuiApplication();
59 /// Method inherited from \c Application class
61 virtual Clipboard & clipboard();
62 virtual Selection & selection();
63 virtual FontLoader & fontLoader() { return font_loader_; }
65 virtual void exit(int status);
66 virtual bool event(QEvent * e);
68 virtual std::string const romanFontName();
69 virtual std::string const sansFontName();
70 virtual std::string const typewriterFontName();
71 virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
72 virtual std::string const hexName(ColorCode col);
73 virtual void updateColor(ColorCode col);
74 virtual void registerSocketCallback(int fd, SocketCallback func);
75 void unregisterSocketCallback(int fd);
76 LyXView & createView(std::string const & geometry_arg);
79 /// Methods inherited from \c QApplication class
81 bool notify(QObject * receiver, QEvent * event);
82 void commitData(QSessionManager & sm);
86 ColorCache & colorCache() { return color_cache_; }
88 GuiFontLoader & guiFontLoader() { return font_loader_; }
91 virtual int createRegisteredView();
92 virtual bool closeAllViews();
93 virtual bool unregisterView(int id);
95 virtual LyXView & view(int id) const;
97 virtual void hideDialogs(std::string const & name, Inset * inset) const;
99 virtual Buffer const * updateInset(Inset const * inset) const;
103 void execBatchCommands();
105 void socketDataReceived(int fd);
109 GuiClipboard clipboard_;
111 GuiSelection selection_;
113 GuiFontLoader font_loader_;
115 ColorCache color_cache_;
117 QTranslator qt_trans_;
119 std::map<int, SocketNotifier *> socket_notifiers_;
123 bool x11EventFilter(XEvent * ev);
125 /// A translator suitable for the entries in the LyX menu.
126 /// Only needed with Qt/Mac.
127 void addMenuTranslator();
129 /// Multiple views container.
131 * Warning: This must not be a smart pointer as the destruction of the
132 * object is handled by Qt when the view is closed
133 * \sa Qt::WA_DeleteOnClose attribute.
135 std::map<int, GuiView *> views_;
138 extern GuiApplication * guiApp;
140 } // namespace frontend
143 #endif // GUIAPPLICATION_H