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 void resetGui();
60 virtual Clipboard & clipboard();
61 virtual Selection & selection();
62 virtual FontLoader & fontLoader() { return font_loader_; }
64 virtual void exit(int status);
65 virtual bool event(QEvent * e);
66 virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
67 virtual std::string const hexName(ColorCode col);
68 virtual void updateColor(ColorCode col);
69 virtual void registerSocketCallback(int fd, SocketCallback func);
70 void unregisterSocketCallback(int fd);
71 LyXView & createView(std::string const & geometry_arg);
74 /// Methods inherited from \c QApplication class
76 bool notify(QObject * receiver, QEvent * event);
77 void commitData(QSessionManager & sm);
81 GuiView const * currentView() const { return current_view_; }
83 GuiView * currentView() { return current_view_; }
85 void setCurrentView(GuiView & view) { current_view_ = &view; }
87 virtual size_t viewCount() const { return view_ids_.size(); }
89 std::vector<int> const & viewIds() { return view_ids_; }
92 ColorCache & colorCache() { return color_cache_; }
94 GuiFontLoader & guiFontLoader() { return font_loader_; }
96 /// return a suitable serif font name.
97 virtual QString const romanFontName();
99 /// return a suitable sans serif font name.
100 virtual QString const sansFontName();
102 /// return a suitable monospaced font name.
103 virtual QString const typewriterFontName();
105 virtual bool closeAllViews();
107 virtual bool unregisterView(int id);
109 virtual GuiView & view(int id) const;
111 virtual void hideDialogs(std::string const & name, Inset * inset) const;
113 virtual Buffer const * updateInset(Inset const * inset) const;
117 void execBatchCommands();
119 void socketDataReceived(int fd);
123 GuiClipboard clipboard_;
125 GuiSelection selection_;
127 GuiFontLoader font_loader_;
129 ColorCache color_cache_;
131 QTranslator qt_trans_;
133 std::map<int, SocketNotifier *> socket_notifiers_;
137 bool x11EventFilter(XEvent * ev);
139 /// A translator suitable for the entries in the LyX menu.
140 /// Only needed with Qt/Mac.
141 void addMenuTranslator();
143 /// Multiple views container.
145 * Warning: This must not be a smart pointer as the destruction of the
146 * object is handled by Qt when the view is closed
147 * \sa Qt::WA_DeleteOnClose attribute.
149 std::map<int, GuiView *> views_;
151 std::vector<int> view_ids_;
152 /// This LyXView is the one receiving Clipboard and Selection
154 GuiView * current_view_;
157 extern GuiApplication * guiApp;
159 } // namespace frontend
162 #endif // GUIAPPLICATION_H