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 class GuiApplication : public QApplication, public Application
52 GuiApplication(int & argc, char ** argv);
54 virtual ~GuiApplication();
56 /// Method inherited from \c Application class
58 virtual Clipboard & clipboard();
59 virtual Selection & selection();
60 virtual FontLoader & fontLoader() { return font_loader_; }
62 virtual void exit(int status);
63 virtual bool event(QEvent * e);
65 virtual std::string const romanFontName();
66 virtual std::string const sansFontName();
67 virtual std::string const typewriterFontName();
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 LyXView & createView(std::string const & geometry_arg);
76 /// Methods inherited from \c QApplication class
78 bool notify(QObject * receiver, QEvent * event);
79 void commitData(QSessionManager & sm);
83 ColorCache & colorCache() { return color_cache_; }
85 GuiFontLoader & guiFontLoader() { return font_loader_; }
88 virtual int createRegisteredView();
89 virtual bool closeAllViews();
90 virtual bool unregisterView(int id);
92 virtual LyXView & view(int id) const;
94 virtual void hideDialogs(std::string const & name, Inset * inset) const;
96 virtual Buffer const * updateInset(Inset const * inset) const;
100 void execBatchCommands();
102 void socketDataReceived(int fd);
106 GuiClipboard clipboard_;
108 GuiSelection selection_;
110 GuiFontLoader font_loader_;
112 ColorCache color_cache_;
114 QTranslator qt_trans_;
116 std::map<int, SocketNotifier *> socket_notifiers_;
120 bool x11EventFilter(XEvent * ev);
122 /// A translator suitable for the entries in the LyX menu.
123 /// Only needed with Qt/Mac.
124 void addMenuTranslator();
126 /// Multiple views container.
128 * Warning: This must not be a smart pointer as the destruction of the
129 * object is handled by Qt when the view is closed
130 * \sa Qt::WA_DeleteOnClose attribute.
132 std::map<int, GuiView *> views_;
135 extern GuiApplication * guiApp;
137 } // namespace frontend
140 #endif // GUIAPPLICATION_H