]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiToolbar.h
On Linux show in crash message box the backtrace
[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(bool in_math, bool in_table, bool review,
96                 bool in_mathmacrotemplate, bool in_ipa);
97
98         ///
99         void toggle();
100
101         ///
102         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
103
104         ///
105         Action * addItem(ToolbarItem const & item);
106
107 Q_SIGNALS:
108         ///
109         void updated();
110
111 private:
112         // load flags with saved values
113         void initFlags();
114         ///
115         void fill();
116         ///
117         void showEvent(QShowEvent *);
118
119         ///
120         QList<Action *> actions_;
121         /// initial visibility flags
122         int visibility_;
123         ///
124         GuiView & owner_;
125         ///
126         GuiCommandBuffer * command_buffer_;
127         ///
128         ToolbarInfo const & tbinfo_;
129         ///
130         bool filled_;
131         ///
132         bool restored_;
133 };
134
135 } // namespace frontend
136 } // namespace lyx
137
138 #endif // GUITOOLBAR_H