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