]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
Merge branch 'master' of git.lyx.org:lyx
[lyx.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         void mousePressEvent(QMouseEvent * e);
50
51 private:
52         ///
53         GuiToolbar * bar_;
54         ///
55         ToolbarItem const & tbitem_;
56         ///
57         bool initialized_;
58
59 private Q_SLOTS:
60         ///
61         void actionTriggered(QAction * action);
62         ///
63         void updateTriggered();
64 };
65
66
67
68 class GuiToolbar : public QToolBar
69 {
70         Q_OBJECT
71 public:
72         ///
73         GuiToolbar(ToolbarInfo const &, GuiView &);
74
75         ///
76         void setVisibility(int visibility);
77
78         /// Add a button to the bar.
79         void add(ToolbarItem const & item);
80
81         /// Session key.
82         /**
83          * This key must be used for any session setting.
84          **/
85         QString sessionKey() const;
86         /// Save session settings.
87         void saveSession() const;
88         /// Restore session settings.
89         void restoreSession();
90
91         /// Refresh the contents of the bar.
92         void update(bool in_math, bool in_table, bool review,
93                 bool in_mathmacrotemplate);
94
95         ///
96         void toggle();
97
98         ///
99         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
100
101         ///
102         Action * addItem(ToolbarItem const & item);
103
104 Q_SIGNALS:
105         ///
106         void updated();
107
108 private:
109         // load flags with saved values
110         void initFlags();
111         ///
112         void fill();
113         ///
114         void showEvent(QShowEvent *);
115
116         ///
117         QList<Action *> actions_;
118         /// initial visibility flags
119         int visibility_;
120         ///
121         GuiView & owner_;
122         ///
123         GuiCommandBuffer * command_buffer_;
124         ///
125         ToolbarInfo const & tbinfo_;
126         ///
127         bool filled_;
128 };
129
130 } // namespace frontend
131 } // namespace lyx
132
133 #endif // GUITOOLBAR_H