]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
Account for old versions of Pygments
[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 <QList>
20 #include <QToolBar>
21 #include <QToolButton>
22
23 namespace lyx {
24
25 class DocumentClass;
26 class Inset;
27
28 namespace frontend {
29
30 class Action;
31 class GuiCommandBuffer;
32 class GuiLayoutFilterModel;
33 class GuiToolbar;
34 class GuiView;
35 class LayoutBox;
36 class ToolbarInfo;
37 class ToolbarItem;
38
39 class MenuButton : public QToolButton
40 {
41         Q_OBJECT
42 public:
43         ///
44         MenuButton(GuiToolbar * bar, ToolbarItem const & item,
45                 bool const sticky = false);
46
47 private:
48         ///
49         void initialize();
50         ///
51         GuiToolbar * bar_;
52         ///
53         ToolbarItem const & tbitem_;
54
55 private Q_SLOTS:
56         ///
57         void actionTriggered(QAction * action);
58         ///
59         void updateTriggered();
60 };
61
62
63
64 class GuiToolbar : public QToolBar
65 {
66         Q_OBJECT
67 public:
68         ///
69         GuiToolbar(ToolbarInfo const &, GuiView &);
70         
71         /// Reimplemented from QToolbar to detect whether the 
72         /// toolbar is restored with MainWindow::restoreState().
73         void setVisible(bool visible);
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         ///
92         bool isRestored() const;
93
94         /// Refresh the contents of the bar.
95         void update(int context = 0);
96
97         ///
98         void toggle();
99
100         /// toggles movability
101         void movable(bool silent = false);
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