]> git.lyx.org Git - features.git/blob - src/frontends/qt4/GuiToolbar.h
394b9d8a34416077cd50523a53ab74aa322d89d0
[features.git] / src / frontends / qt4 / GuiToolbar.h
1 // -*- C++ -*-
2 /**
3  * \file GuiToolbar.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 Bjønnes
8  * \author John Levon
9  * \author Jean-Marc Lasgouttes
10  * \author Angus Leeming
11  * \author Abdelrazak Younes
12  *
13  * Full author contact details are available in file CREDITS.
14  */
15
16 #ifndef GUITOOLBAR_H
17 #define GUITOOLBAR_H
18
19 #include "Session.h"
20
21 #include <QList>
22 #include <QToolBar>
23 #include <QToolButton>
24
25 namespace lyx {
26
27 class DocumentClass;
28 class Inset;
29
30 namespace frontend {
31
32 class Action;
33 class GuiCommandBuffer;
34 class GuiLayoutFilterModel;
35 class GuiToolbar;
36 class GuiView;
37 class LayoutBox;
38 class ToolbarInfo;
39 class ToolbarItem;
40
41 class MenuButton : public QToolButton
42 {
43         Q_OBJECT
44 public:
45         ///
46         MenuButton(GuiToolbar * bar, ToolbarItem const & item,
47                 bool const sticky = false);
48
49 private:
50         ///
51         void initialize();
52         ///
53         GuiToolbar * bar_;
54         ///
55         ToolbarItem const & tbitem_;
56
57 private Q_SLOTS:
58         ///
59         void actionTriggered(QAction * action);
60         ///
61         void updateTriggered();
62 };
63
64
65
66 class GuiToolbar : public QToolBar
67 {
68         Q_OBJECT
69 public:
70         ///
71         GuiToolbar(ToolbarInfo const &, GuiView &);
72         
73         /// Reimplemented from QToolbar to detect whether the 
74         /// toolbar is restored with MainWindow::restoreState().
75         void setVisible(bool visible);
76
77         ///
78         void setVisibility(int visibility);
79
80         /// Add a button to the bar.
81         void add(ToolbarItem const & item);
82
83         /// Session key.
84         /**
85          * This key must be used for any session setting.
86          **/
87         QString sessionKey() const;
88         /// Save session settings.
89         void saveSession() const;
90         /// Restore session settings.
91         void restoreSession();
92
93         ///
94         bool isRestored() const;
95
96         /// Refresh the contents of the bar.
97         void update(bool in_math, bool in_table, bool review,
98                 bool in_mathmacrotemplate, bool in_ipa);
99
100         ///
101         void toggle();
102
103         ///
104         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
105
106         ///
107         Action * addItem(ToolbarItem const & item);
108
109 Q_SIGNALS:
110         ///
111         void updated();
112
113 private:
114         // load flags with saved values
115         void initFlags();
116         ///
117         void fill();
118         ///
119         void showEvent(QShowEvent *);
120
121         ///
122         QList<Action *> actions_;
123         /// initial visibility flags
124         int visibility_;
125         ///
126         GuiView & owner_;
127         ///
128         GuiCommandBuffer * command_buffer_;
129         ///
130         ToolbarInfo const & tbinfo_;
131         ///
132         bool filled_;
133         ///
134         bool restored_;
135 };
136
137 } // namespace frontend
138 } // namespace lyx
139
140 #endif // GUITOOLBAR_H