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