2006-06-26 17:18:28 +00:00
|
|
|
/**
|
2007-08-31 22:16:11 +00:00
|
|
|
* \file GuiApplication.h
|
2006-06-26 17:18:28 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author unknown
|
|
|
|
* \author John Levon
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#ifndef GUIAPPLICATION_H
|
|
|
|
#define GUIAPPLICATION_H
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2006-09-26 09:57:47 +00:00
|
|
|
#include "ColorCache.h"
|
2008-03-20 00:00:53 +00:00
|
|
|
#include "FontLoader.h"
|
2006-09-22 15:02:41 +00:00
|
|
|
#include "GuiClipboard.h"
|
|
|
|
#include "GuiSelection.h"
|
2007-12-26 10:55:43 +00:00
|
|
|
#include "Menus.h"
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2006-09-22 09:47:39 +00:00
|
|
|
#include "frontends/Application.h"
|
|
|
|
|
2007-11-17 20:47:50 +00:00
|
|
|
#include <QObject>
|
2006-06-26 17:18:28 +00:00
|
|
|
#include <QApplication>
|
2008-02-05 13:10:42 +00:00
|
|
|
#include <QTimer>
|
2007-01-04 11:05:57 +00:00
|
|
|
#include <QTranslator>
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2007-11-17 20:47:50 +00:00
|
|
|
#include <map>
|
2007-11-17 22:25:42 +00:00
|
|
|
#include <vector>
|
2007-11-17 20:47:50 +00:00
|
|
|
|
2007-08-27 06:35:24 +00:00
|
|
|
class QSessionManager;
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2006-06-26 17:18:28 +00:00
|
|
|
class BufferView;
|
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-17 20:47:50 +00:00
|
|
|
class GuiView;
|
|
|
|
class LyXView;
|
2008-03-14 23:25:11 +00:00
|
|
|
class GlobalMenuBar;
|
2006-06-26 17:18:28 +00:00
|
|
|
class GuiWorkArea;
|
2007-09-15 20:31:50 +00:00
|
|
|
class SocketNotifier;
|
2006-06-26 17:18:28 +00:00
|
|
|
|
|
|
|
/// The Qt main application class
|
|
|
|
/**
|
|
|
|
There should be only one instance of this class. No Qt object
|
|
|
|
initialisation should be done before the instanciation of this class.
|
|
|
|
*/
|
2006-09-22 09:47:39 +00:00
|
|
|
class GuiApplication : public QApplication, public Application
|
2006-06-26 17:18:28 +00:00
|
|
|
{
|
2006-10-23 16:29:24 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2006-06-26 17:18:28 +00:00
|
|
|
public:
|
2006-09-22 09:47:39 +00:00
|
|
|
GuiApplication(int & argc, char ** argv);
|
2006-10-03 10:34:10 +00:00
|
|
|
///
|
2006-10-13 16:48:12 +00:00
|
|
|
virtual ~GuiApplication();
|
2006-09-22 09:47:39 +00:00
|
|
|
|
|
|
|
/// Method inherited from \c Application class
|
|
|
|
//@{
|
2007-11-24 07:58:12 +00:00
|
|
|
virtual FuncStatus getStatus(FuncRequest const &);
|
2007-11-26 14:36:50 +00:00
|
|
|
virtual bool dispatch(FuncRequest const &);
|
2007-11-21 15:12:47 +00:00
|
|
|
virtual void resetGui();
|
2008-02-06 23:02:57 +00:00
|
|
|
void restoreGuiSession();
|
2007-08-31 22:16:11 +00:00
|
|
|
virtual Clipboard & clipboard();
|
|
|
|
virtual Selection & selection();
|
2006-10-03 16:17:32 +00:00
|
|
|
virtual FontLoader & fontLoader() { return font_loader_; }
|
2007-09-15 17:47:35 +00:00
|
|
|
virtual int exec();
|
2006-09-22 09:47:39 +00:00
|
|
|
virtual void exit(int status);
|
2006-11-29 09:06:37 +00:00
|
|
|
virtual bool event(QEvent * e);
|
2007-10-25 12:41:02 +00:00
|
|
|
virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol);
|
|
|
|
virtual std::string const hexName(ColorCode col);
|
|
|
|
virtual void updateColor(ColorCode col);
|
2008-03-06 21:50:27 +00:00
|
|
|
virtual void readMenus(Lexer & lex);
|
2008-03-14 23:25:11 +00:00
|
|
|
virtual void initGlobalMenu();
|
2007-09-15 20:31:50 +00:00
|
|
|
virtual void registerSocketCallback(int fd, SocketCallback func);
|
2006-12-02 17:39:31 +00:00
|
|
|
void unregisterSocketCallback(int fd);
|
2008-03-06 21:50:27 +00:00
|
|
|
bool searchMenu(FuncRequest const & func, std::vector<docstring> & names) const;
|
2006-09-22 09:47:39 +00:00
|
|
|
//@}
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2007-12-26 10:55:43 +00:00
|
|
|
Menus const & menus() const { return menus_; }
|
|
|
|
Menus & menus() { return menus_; }
|
2007-08-27 06:35:24 +00:00
|
|
|
/// Methods inherited from \c QApplication class
|
2007-04-01 16:06:43 +00:00
|
|
|
//@{
|
2007-08-27 06:35:24 +00:00
|
|
|
bool notify(QObject * receiver, QEvent * event);
|
|
|
|
void commitData(QSessionManager & sm);
|
2007-04-01 16:06:43 +00:00
|
|
|
//@}
|
|
|
|
|
2007-11-24 08:51:11 +00:00
|
|
|
/// Create the main window with given geometry settings.
|
|
|
|
/// \param geometry_arg: only for Windows platform.
|
2008-03-14 23:33:05 +00:00
|
|
|
void createView(QString const & geometry_arg = QString(),
|
|
|
|
bool autoShow = true);
|
2007-11-18 20:36:52 +00:00
|
|
|
///
|
|
|
|
GuiView const * currentView() const { return current_view_; }
|
|
|
|
///
|
|
|
|
GuiView * currentView() { return current_view_; }
|
|
|
|
///
|
2008-03-15 02:42:59 +00:00
|
|
|
void setCurrentView(GuiView * view) { current_view_ = view; }
|
2007-11-18 20:36:52 +00:00
|
|
|
///
|
2007-11-17 22:25:42 +00:00
|
|
|
virtual size_t viewCount() const { return view_ids_.size(); }
|
2007-11-18 20:36:52 +00:00
|
|
|
///
|
2007-11-17 22:25:42 +00:00
|
|
|
std::vector<int> const & viewIds() { return view_ids_; }
|
|
|
|
|
2006-09-26 09:57:47 +00:00
|
|
|
///
|
|
|
|
ColorCache & colorCache() { return color_cache_; }
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2007-11-18 20:36:52 +00:00
|
|
|
/// return a suitable serif font name.
|
|
|
|
virtual QString const romanFontName();
|
2007-11-17 20:47:50 +00:00
|
|
|
|
2007-11-18 20:36:52 +00:00
|
|
|
/// return a suitable sans serif font name.
|
|
|
|
virtual QString const sansFontName();
|
|
|
|
|
|
|
|
/// return a suitable monospaced font name.
|
|
|
|
virtual QString const typewriterFontName();
|
|
|
|
///
|
2007-11-17 20:47:50 +00:00
|
|
|
virtual bool unregisterView(int id);
|
2007-11-18 20:36:52 +00:00
|
|
|
///
|
2007-11-19 20:56:05 +00:00
|
|
|
virtual GuiView & view(int id) const;
|
2007-11-17 20:47:50 +00:00
|
|
|
///
|
|
|
|
virtual void hideDialogs(std::string const & name, Inset * inset) const;
|
|
|
|
///
|
|
|
|
virtual Buffer const * updateInset(Inset const * inset) const;
|
|
|
|
|
2006-11-26 02:18:32 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
///
|
|
|
|
void execBatchCommands();
|
2007-09-15 20:31:50 +00:00
|
|
|
///
|
|
|
|
void socketDataReceived(int fd);
|
2008-02-05 13:10:42 +00:00
|
|
|
/// events to be triggered by general_timer_ should go here
|
|
|
|
void handleRegularEvents();
|
2008-03-14 23:25:11 +00:00
|
|
|
///
|
|
|
|
void onLastWindowClosed();
|
|
|
|
|
2006-09-22 09:47:39 +00:00
|
|
|
private:
|
2007-11-25 18:18:23 +00:00
|
|
|
///
|
|
|
|
bool closeAllViews();
|
2006-09-22 15:02:41 +00:00
|
|
|
///
|
|
|
|
GuiClipboard clipboard_;
|
|
|
|
///
|
|
|
|
GuiSelection selection_;
|
2006-06-26 17:18:28 +00:00
|
|
|
///
|
2008-03-20 00:00:53 +00:00
|
|
|
FontLoader font_loader_;
|
2006-09-26 09:57:47 +00:00
|
|
|
///
|
|
|
|
ColorCache color_cache_;
|
2006-10-12 14:10:13 +00:00
|
|
|
///
|
2007-01-04 11:05:57 +00:00
|
|
|
QTranslator qt_trans_;
|
|
|
|
///
|
2007-09-15 20:31:50 +00:00
|
|
|
std::map<int, SocketNotifier *> socket_notifiers_;
|
2007-12-25 22:27:32 +00:00
|
|
|
///
|
2007-12-26 10:55:43 +00:00
|
|
|
Menus menus_;
|
2008-02-05 13:10:42 +00:00
|
|
|
/// this timer is used for any regular events one wants to
|
|
|
|
/// perform. at present it is used to check if forked processes
|
|
|
|
/// are done.
|
|
|
|
QTimer general_timer_;
|
2006-06-26 17:18:28 +00:00
|
|
|
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
public:
|
2007-09-15 17:47:35 +00:00
|
|
|
bool x11EventFilter(XEvent * ev);
|
2006-06-26 17:18:28 +00:00
|
|
|
#endif
|
2007-08-07 21:23:40 +00:00
|
|
|
/// A translator suitable for the entries in the LyX menu.
|
|
|
|
/// Only needed with Qt/Mac.
|
|
|
|
void addMenuTranslator();
|
2007-11-17 20:47:50 +00:00
|
|
|
|
|
|
|
/// Multiple views container.
|
|
|
|
/**
|
|
|
|
* Warning: This must not be a smart pointer as the destruction of the
|
|
|
|
* object is handled by Qt when the view is closed
|
|
|
|
* \sa Qt::WA_DeleteOnClose attribute.
|
|
|
|
*/
|
|
|
|
std::map<int, GuiView *> views_;
|
2007-11-17 22:25:42 +00:00
|
|
|
///
|
|
|
|
std::vector<int> view_ids_;
|
2007-11-18 20:36:52 +00:00
|
|
|
/// This LyXView is the one receiving Clipboard and Selection
|
|
|
|
/// events
|
|
|
|
GuiView * current_view_;
|
2008-03-14 23:25:11 +00:00
|
|
|
/// only used on mac
|
|
|
|
GlobalMenuBar * global_menubar_;
|
2006-09-22 09:47:39 +00:00
|
|
|
}; // GuiApplication
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
extern GuiApplication * guiApp;
|
|
|
|
|
2006-06-26 17:18:28 +00:00
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#endif // GUIAPPLICATION_H
|