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-22 09:47:39 +00:00
|
|
|
#include "frontends/Application.h"
|
|
|
|
|
2006-06-26 17:18:28 +00:00
|
|
|
#include <QApplication>
|
2008-05-23 18:09:40 +00:00
|
|
|
#include <QList>
|
2007-11-17 20:47:50 +00:00
|
|
|
|
2008-05-14 10:34:19 +00:00
|
|
|
class QAbstractItemModel;
|
2008-06-05 08:31:22 +00:00
|
|
|
class QIcon;
|
|
|
|
class QObject;
|
|
|
|
class QSessionManager;
|
2008-05-14 11:01:27 +00:00
|
|
|
class QSortFilterProxyModel;
|
2007-08-27 06:35:24 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2006-06-26 17:18:28 +00:00
|
|
|
class BufferView;
|
2008-05-23 08:43:07 +00:00
|
|
|
class ColorCache;
|
2006-06-26 17:18:28 +00:00
|
|
|
|
|
|
|
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;
|
2008-05-23 08:43:07 +00:00
|
|
|
class Menus;
|
2007-09-15 20:31:50 +00:00
|
|
|
class SocketNotifier;
|
2008-05-25 08:30:06 +00:00
|
|
|
class Toolbars;
|
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);
|
2008-05-23 07:52:39 +00:00
|
|
|
~GuiApplication();
|
2006-09-22 09:47:39 +00:00
|
|
|
|
2008-09-21 21:28:37 +00:00
|
|
|
/// Clear all session information.
|
|
|
|
void clearSession();
|
|
|
|
|
2006-09-22 09:47:39 +00:00
|
|
|
/// Method inherited from \c Application class
|
|
|
|
//@{
|
2008-05-23 09:53:27 +00:00
|
|
|
bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
|
2008-05-23 08:43:07 +00:00
|
|
|
bool dispatch(FuncRequest const &);
|
2008-11-15 16:29:58 +00:00
|
|
|
void dispatchDelayed(FuncRequest const &);
|
2008-05-23 08:43:07 +00:00
|
|
|
void resetGui();
|
2008-02-06 23:02:57 +00:00
|
|
|
void restoreGuiSession();
|
2008-05-23 08:43:07 +00:00
|
|
|
Clipboard & clipboard();
|
|
|
|
Selection & selection();
|
|
|
|
FontLoader & fontLoader();
|
|
|
|
int exec();
|
|
|
|
void exit(int status);
|
|
|
|
bool event(QEvent * e);
|
|
|
|
bool getRgbColor(ColorCode col, RGBColor & rgbcol);
|
|
|
|
std::string const hexName(ColorCode col);
|
|
|
|
void registerSocketCallback(int fd, SocketCallback func);
|
2006-12-02 17:39:31 +00:00
|
|
|
void unregisterSocketCallback(int fd);
|
2008-05-24 10:15:52 +00:00
|
|
|
bool searchMenu(FuncRequest const & func, docstring_list & names) const;
|
2008-06-05 08:31:22 +00:00
|
|
|
docstring iconName(FuncRequest const & f, bool unknown);
|
2008-05-23 08:43:07 +00:00
|
|
|
void hideDialogs(std::string const & name, Inset * inset) const;
|
|
|
|
Buffer const * updateInset(Inset const * inset) const;
|
2006-09-22 09:47:39 +00:00
|
|
|
//@}
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
Toolbars const & toolbars() const;
|
|
|
|
Toolbars & toolbars();
|
2008-05-23 08:43:07 +00:00
|
|
|
Menus const & menus() const;
|
|
|
|
Menus & 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);
|
2008-05-23 07:52:39 +00:00
|
|
|
#ifdef Q_WS_X11
|
|
|
|
bool x11EventFilter(XEvent * ev);
|
|
|
|
#endif
|
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-06-19 11:28:11 +00:00
|
|
|
/// \param optional id identifier.
|
2008-03-14 23:33:05 +00:00
|
|
|
void createView(QString const & geometry_arg = QString(),
|
2008-06-19 11:28:11 +00:00
|
|
|
bool autoShow = true, int id = 0);
|
|
|
|
/// FIXME: this method and the one above are quite ugly.
|
|
|
|
void createView(int id);
|
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
|
|
|
///
|
2008-05-23 18:09:40 +00:00
|
|
|
QList<int> viewIds() const;
|
2007-11-17 22:25:42 +00:00
|
|
|
|
2006-09-26 09:57:47 +00:00
|
|
|
///
|
2008-05-23 08:43:07 +00:00
|
|
|
ColorCache & colorCache();
|
2006-06-26 17:18:28 +00:00
|
|
|
|
2008-05-14 10:34:19 +00:00
|
|
|
QAbstractItemModel * languageModel();
|
2008-05-08 09:03:38 +00:00
|
|
|
|
2007-11-18 20:36:52 +00:00
|
|
|
/// return a suitable serif font name.
|
2008-05-23 08:43:07 +00:00
|
|
|
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.
|
2008-05-23 08:43:07 +00:00
|
|
|
QString const sansFontName();
|
2007-11-18 20:36:52 +00:00
|
|
|
|
|
|
|
/// return a suitable monospaced font name.
|
2008-05-23 08:43:07 +00:00
|
|
|
QString const typewriterFontName();
|
2007-11-17 20:47:50 +00:00
|
|
|
///
|
2008-05-23 10:54:34 +00:00
|
|
|
void unregisterView(GuiView * gv);
|
2007-11-17 20:47:50 +00:00
|
|
|
///
|
2008-05-23 08:43:07 +00:00
|
|
|
GuiView & view(int id) const;
|
2007-11-17 20:47:50 +00:00
|
|
|
|
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();
|
2008-10-13 11:25:37 +00:00
|
|
|
|
2008-11-15 16:29:58 +00:00
|
|
|
///
|
|
|
|
void processFuncRequestQueue();
|
|
|
|
|
2006-09-22 09:47:39 +00:00
|
|
|
private:
|
2007-11-25 18:18:23 +00:00
|
|
|
///
|
|
|
|
bool closeAllViews();
|
2008-05-24 09:28:05 +00:00
|
|
|
/// read the given ui (menu/toolbar) file
|
2008-05-24 09:51:17 +00:00
|
|
|
bool readUIFile(QString const & name, bool include = false);
|
2008-07-28 11:26:46 +00:00
|
|
|
///
|
|
|
|
void setGuiLanguage();
|
2008-05-24 09:28:05 +00:00
|
|
|
|
2007-11-18 20:36:52 +00:00
|
|
|
/// This LyXView is the one receiving Clipboard and Selection
|
|
|
|
/// events
|
|
|
|
GuiView * current_view_;
|
2008-05-23 07:52:39 +00:00
|
|
|
///
|
|
|
|
struct Private;
|
|
|
|
Private * const d;
|
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;
|
|
|
|
|
2008-06-05 08:31:22 +00:00
|
|
|
/// \return the icon file name for the given action.
|
|
|
|
QString iconName(FuncRequest const & f, bool unknown);
|
|
|
|
|
|
|
|
/// \return an icon for the given action.
|
|
|
|
QIcon getIcon(FuncRequest const & f, bool unknown);
|
|
|
|
|
2008-11-16 12:22:54 +00:00
|
|
|
GuiApplication * theGuiApp();
|
2008-11-16 01:20:34 +00:00
|
|
|
|
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
|