4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjornes
9 * \author Abdelrazak Younes
10 * \author Peter Kümmel
12 * Full author contact details are available in file CREDITS.
18 #include "frontends/LyXView.h"
23 #include <QMainWindow>
27 class QDragEnterEvent;
44 QWidget * mainWindow();
47 * GuiView - Qt4 implementation of LyXView
49 * qt4-private implementation of the main LyX window.
51 * Note: a QObject emits a destroyed(QObject *) Qt signal when it
52 * is deleted. This might be useful for closing other dialogs
53 * depending on a given GuiView.
55 class GuiView : public QMainWindow, public LyXView
59 /// create a main window of the given dimensions
65 * This is called after the concrete view has been created.
66 * We have to have the toolbar and the other stuff created
67 * before we can populate it with this call.
72 virtual void setFocus();
73 virtual void setBusy(bool);
75 /// add toolbar, if newline==true, add a toolbar break before the toolbar
76 GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
77 virtual void updateStatusBar();
78 virtual void message(docstring const & str);
79 virtual bool hasFocus() const;
80 void updateLayoutChoice(bool force);
81 bool isToolbarVisible(std::string const & id);
82 void updateToolbars();
84 QMenu * createPopupMenu();
86 /// dispatch to current BufferView
87 void dispatch(FuncRequest const & cmd);
89 /// \return the buffer currently shown in this window
91 Buffer const * buffer() const;
92 /// set a buffer to the current workarea.
93 void setBuffer(Buffer * b); ///< \c Buffer to set.
95 /// GuiBufferDelegate.
97 void resetAutosaveTimers();
98 void errors(std::string const &);
99 void structureChanged() { updateToc(); }
103 /// called on timeout
106 void updateEmbeddedFiles();
108 /// \return the current buffer view.
111 /// load a buffer into the current workarea.
112 Buffer * loadLyXFile(support::FileName const & name, ///< File to load.
113 bool tolastfiles = true); ///< append to the "Open recent" menu?
115 /** redraw \c inset in all the BufferViews in which it is currently
116 * visible. If successful return a pointer to the owning Buffer.
118 Buffer const * updateInset(Inset const *);
120 void restartCursor();
122 /// \return the \c Workarea associated to \p Buffer
123 /// \retval 0 if no \c WorkArea is found.
124 GuiWorkArea * workArea(Buffer & buffer);
126 /// Add a \c WorkArea
127 /// \return the \c Workarea associated to \p Buffer
128 /// \retval 0 if no \c WorkArea is found.
129 GuiWorkArea * addWorkArea(Buffer & buffer);
131 void setCurrentWorkArea(GuiWorkArea * work_area);
133 void removeWorkArea(GuiWorkArea * work_area);
134 /// return the current WorkArea (the one that has the focus).
135 GuiWorkArea const * currentWorkArea() const;
142 /// clear any temporary message and replace with current status.
147 void updateWindowTitle(GuiWorkArea * wa);
150 void on_currentWorkAreaChanged(GuiWorkArea *);
152 /// slots to change the icon size
153 void smallSizedIcons();
154 void normalSizedIcons();
155 void bigSizedIcons();
159 void addTabWorkArea();
161 /// connect to signals in the given BufferView
162 void connectBufferView(BufferView & bv);
163 /// disconnect from signals in the given BufferView
164 void disconnectBufferView();
165 /// connect to signals in the given buffer
166 void connectBuffer(Buffer & buf);
167 /// disconnect from signals in the given buffer
168 void disconnectBuffer();
172 void dragEnterEvent(QDragEnterEvent * ev);
174 void dropEvent(QDropEvent * ev);
175 /// make sure we quit cleanly
176 void closeEvent(QCloseEvent * e);
178 void showEvent(QShowEvent *);
180 /// in order to catch Tab key press.
181 bool event(QEvent * e);
182 bool focusNextPrevChild(bool);
185 struct GuiViewPrivate;
189 QTimer statusbar_timer_;
191 /// are we quitting by the menu?
192 bool quitting_by_menu_;
201 ToolbarSize toolbarSize_;
203 /// auto-saving of buffers
204 Timeout * const autosave_timeout_;
208 /// dialogs for this view
211 /** Check the status of all visible dialogs and disable or reenable
212 * them as appropriate.
214 * Disabling is needed for example when a dialog is open and the
215 * cursor moves to a position where the corresponding inset is not
220 /// Hide all visible dialogs
221 void hideAll() const;
222 /// Hide any dialogs that require a buffer for them to operate
223 void hideBufferDependent() const;
224 /** Update visible, buffer-dependent dialogs
225 If the bool is true then a buffer change has occurred
226 else it is still the same buffer.
228 void updateBufferDependent(bool) const;
230 /** \param name == "bibtex", "citation" etc; an identifier used to
231 launch a particular dialog.
232 \param data is a string representation of the Inset contents.
233 It is often little more than the output from Inset::write.
234 It is passed to, and parsed by, the frontend dialog.
235 Several of these dialogs do not need any data,
236 so it defaults to string().
237 \param inset ownership is _not_ passed to the frontend dialog.
238 It is stored internally and used by the kernel to ascertain
239 what to do with the FuncRequest dispatched from the frontend
240 dialog on 'Apply'; should it be used to create a new inset at
241 the current cursor position or modify an existing, 'open' inset?
243 void showDialog(std::string const & name,
244 std::string const & data, Inset * inset = 0);
246 /** \param name == "citation", "bibtex" etc; an identifier used
247 to update the contents of a particular dialog with \param data.
248 See the comments to 'show', above.
250 void updateDialog(std::string const & name, std::string const & data);
252 /// Is the dialog currently visible?
253 bool isDialogVisible(std::string const & name) const;
255 /** All Dialogs of the given \param name will be closed if they are
256 connected to the given \param inset.
258 void hideDialog(std::string const & name, Inset * inset);
260 void disconnectDialog(std::string const & name);
262 Inset * getOpenInset(std::string const & name) const;
266 void redrawDialog() const;
268 bool isValidName(std::string const & name) const;
270 Dialog * find_or_build(std::string const & name);
272 Dialog * build(std::string const & name);
275 /// flag against a race condition due to multiclicks in Qt frontend,
280 } // namespace frontend