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;
|
2009-10-04 20:58:20 +00:00
|
|
|
class KeySymbol;
|
2006-06-26 17:18:28 +00:00
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-17 20:47:50 +00:00
|
|
|
class GuiView;
|
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();
|
|
|
|
|
2010-01-27 18:10:33 +00:00
|
|
|
/// \name Methods inherited from Application class
|
2006-09-22 09:47:39 +00:00
|
|
|
//@{
|
2010-02-09 16:11:13 +00:00
|
|
|
void dispatch(FuncRequest const &);
|
2009-10-04 20:58:20 +00:00
|
|
|
void dispatch(FuncRequest const &, DispatchResult & dr);
|
2010-02-09 16:11:13 +00:00
|
|
|
FuncStatus getStatus(FuncRequest const & cmd) const;
|
2008-11-15 16:29:58 +00:00
|
|
|
void dispatchDelayed(FuncRequest const &);
|
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
|
|
|
Buffer const * updateInset(Inset const * inset) const;
|
2009-10-04 20:58:20 +00:00
|
|
|
void handleKeyFunc(FuncCode action);
|
2006-09-22 09:47:39 +00:00
|
|
|
//@}
|
2010-02-09 17:25:44 +00:00
|
|
|
///
|
|
|
|
void hideDialogs(std::string const & name, Inset * inset) const;
|
|
|
|
///
|
|
|
|
void resetGui();
|
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();
|
2010-01-27 18:10:33 +00:00
|
|
|
|
|
|
|
/// \name Methods inherited from 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;
|
2009-10-04 20:58:20 +00:00
|
|
|
///
|
|
|
|
void processKeySym(KeySymbol const & key, KeyModifier state);
|
|
|
|
/// return the status bar state string
|
|
|
|
docstring viewStatusMessage();
|
2007-11-17 20:47:50 +00:00
|
|
|
|
2010-02-09 16:11:13 +00:00
|
|
|
/// goto a bookmark
|
|
|
|
/// openFile: whether or not open a file if the file is not opened
|
|
|
|
/// switchToBuffer: whether or not switch to buffer if the buffer is
|
|
|
|
/// not the current buffer
|
|
|
|
void gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer);
|
|
|
|
|
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
|
|
|
|
2010-02-09 17:06:40 +00:00
|
|
|
/// This GuiView is the one receiving Clipboard and Selection
|
2007-11-18 20:36:52 +00:00
|
|
|
/// events
|
|
|
|
GuiView * current_view_;
|
2010-02-09 16:11:13 +00:00
|
|
|
|
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);
|
|
|
|
|
2009-04-03 17:00:09 +00:00
|
|
|
|
|
|
|
/// \return the pixmap for the given path, name and extension.
|
|
|
|
QPixmap getPixmap(QString const & path, QString const & name, QString const & ext);
|
|
|
|
|
2008-06-05 08:31:22 +00:00
|
|
|
/// \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
|