]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiView.h
Use QSettings for session management of windows geometry. This commit also removes...
[lyx.git] / src / frontends / qt4 / GuiView.h
1 // -*- C++ -*-
2 /**
3  * \file GuiView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjornes
8  * \author John Levon
9  * \author Abdelrazak Younes
10  * \author Peter Kümmel
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef GUI_VIEW_H
16 #define GUI_VIEW_H
17
18 #include "frontends/LyXView.h"
19
20 #include <QMainWindow>
21 #include <QTimer>
22
23 class QCloseEvent;
24 class QDragEnterEvent;
25 class QDropEvent;
26 class QMenu;
27 class QShowEvent;
28
29
30 namespace lyx {
31
32 class Timeout;
33 class ToolbarInfo;
34
35 namespace frontend {
36
37 class GuiToolbar;
38 class GuiWorkArea;
39
40 QWidget * mainWindow();
41
42 /**
43  * GuiView - Qt4 implementation of LyXView
44  *
45  * qt4-private implementation of the main LyX window.
46  *
47  * Note: a QObject emits a destroyed(QObject *) Qt signal when it
48  * is deleted. This might be useful for closing other dialogs
49  * depending on a given GuiView.
50  */
51 class GuiView : public QMainWindow, public LyXView
52 {
53         Q_OBJECT
54 public:
55         /// create a main window of the given dimensions
56         GuiView(int id);
57
58         ~GuiView();
59
60         virtual void init();
61         virtual void close();
62         virtual void setFocus();
63         virtual void setBusy(bool);
64
65         /// add toolbar, if newline==true, add a toolbar break before the toolbar
66         GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
67         virtual void updateStatusBar();
68         virtual void message(docstring const & str);
69         virtual bool hasFocus() const;
70         void updateLayoutChoice(bool force);
71         bool isToolbarVisible(std::string const & id);
72         void updateToolbars();
73         ///
74         QMenu * createPopupMenu();
75
76         /// dispatch to current BufferView
77         void dispatch(FuncRequest const & cmd);
78
79         /// \return the buffer currently shown in this window
80         Buffer * buffer();
81         Buffer const * buffer() const;
82         /// set a buffer to the current workarea.
83         void setBuffer(Buffer * b); ///< \c Buffer to set.
84
85         /// GuiBufferDelegate.
86         ///@{
87         void resetAutosaveTimers();
88         void errors(std::string const &);
89         void structureChanged() { updateToc(); }
90         ///@}
91
92         ////
93         void showDialog(std::string const & name);
94         void showDialogWithData(std::string const & name,
95                 std::string const & data);
96         void showInsetDialog(std::string const & name,
97                 std::string const & data, Inset * inset);
98         void updateDialog(std::string const & name,
99                 std::string const & data);
100         
101         /// called on timeout
102         void autoSave();
103         ///
104         void updateEmbeddedFiles();
105
106         /// \return the current buffer view.
107         BufferView * view();
108
109         /// get access to the dialogs
110         Dialogs & getDialogs() { return *dialogs_; }
111         ///
112         Dialogs const & getDialogs() const { return *dialogs_; }
113
114         /// load a buffer into the current workarea.
115         Buffer * loadLyXFile(support::FileName const &  name, ///< File to load.
116                 bool tolastfiles = true);  ///< append to the "Open recent" menu?
117
118         /** redraw \c inset in all the BufferViews in which it is currently
119          *  visible. If successful return a pointer to the owning Buffer.
120          */
121         Buffer const * updateInset(Inset const *);
122         ///
123         void restartCursor();
124
125         /// \return the \c Workarea associated to \p  Buffer
126         /// \retval 0 if no \c WorkArea is found.
127         GuiWorkArea * workArea(Buffer & buffer);
128
129         /// Add a \c WorkArea 
130         /// \return the \c Workarea associated to \p  Buffer
131         /// \retval 0 if no \c WorkArea is found.
132         GuiWorkArea * addWorkArea(Buffer & buffer);
133         ///
134         void setCurrentWorkArea(GuiWorkArea * work_area);
135         ///
136         void removeWorkArea(GuiWorkArea * work_area);
137         /// return the current WorkArea (the one that has the focus).
138         GuiWorkArea const * currentWorkArea() const;
139
140 Q_SIGNALS:
141         void closing(int);
142
143 public Q_SLOTS:
144         /// idle timeout.
145         /// clear any temporary message and replace with current status.
146         void clearMessage();
147
148 private Q_SLOTS:
149         ///
150         void updateWindowTitle(GuiWorkArea * wa);
151
152         ///
153         void on_currentWorkAreaChanged(GuiWorkArea *);
154
155         /// slots to change the icon size
156         void smallSizedIcons();
157         void normalSizedIcons();
158         void bigSizedIcons();
159
160 private:
161         ///
162         void addTabWorkArea();
163
164         /// connect to signals in the given BufferView
165         void connectBufferView(BufferView & bv);
166         /// disconnect from signals in the given BufferView
167         void disconnectBufferView();
168         /// connect to signals in the given buffer
169         void connectBuffer(Buffer & buf);
170         /// disconnect from signals in the given buffer
171         void disconnectBuffer();
172         ///
173         void updateToc();
174         ///
175         void dragEnterEvent(QDragEnterEvent * ev);
176         ///
177         void dropEvent(QDropEvent * ev);
178         /// make sure we quit cleanly
179         void closeEvent(QCloseEvent * e);
180         ///
181         void showEvent(QShowEvent *);
182
183         /// in order to catch Tab key press.
184         bool event(QEvent * e);
185         bool focusNextPrevChild(bool);
186
187         ///
188         struct GuiViewPrivate;
189         GuiViewPrivate & d;
190
191         ///
192         QTimer statusbar_timer_;
193
194         /// are we quitting by the menu?
195         bool quitting_by_menu_;
196
197         struct ToolbarSize {
198                 int top_width;
199                 int bottom_width;
200                 int left_height;
201                 int right_height;
202         };
203
204         ToolbarSize toolbarSize_;
205
206         /// auto-saving of buffers
207         Timeout * const autosave_timeout_;
208         /// dialogs for this view
209         Dialogs * dialogs_;
210 };
211
212
213 } // namespace frontend
214 } // namespace lyx
215
216 #endif // GUIVIEW_H