]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiToolbar.h
Remove unused forward declarations
[lyx.git] / src / frontends / qt / 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 #include "support/strfwd.h"
24
25 class QSettings;
26
27 namespace lyx {
28
29 namespace frontend {
30
31 class Action;
32 class GuiCommandBuffer;
33 class GuiToolbar;
34 class GuiView;
35 class ToolbarInfo;
36 class ToolbarItem;
37
38 class MenuButtonBase : public QToolButton
39 {
40         Q_OBJECT
41 public:
42         ///
43         MenuButtonBase(GuiToolbar * bar, ToolbarItem const & item);
44
45 protected:
46         ///
47         virtual void initialize() = 0;
48         ///
49         GuiToolbar * bar_;
50         ///
51         ToolbarItem const & tbitem_;
52
53 protected Q_SLOTS:
54         ///
55         void actionTriggered(QAction * action);
56         ///
57         virtual void updateTriggered() = 0;
58 };
59
60
61 class StaticMenuButton : public MenuButtonBase
62 {
63         Q_OBJECT
64 public:
65         ///
66         StaticMenuButton(GuiToolbar * bar, ToolbarItem const & item,
67                 bool const sticky = false);
68
69 protected:
70         ///
71         void initialize() override;
72
73 protected Q_SLOTS:
74         ///
75         void updateTriggered() override;
76 };
77
78
79 /// A menu which can be populated on the fly.
80 /// The 'type' of menu must be given in the toolbar file
81 /// (stdtoolbars.inc, usually) and must be one of:
82 ///             dynamic-custom-insets
83 ///             dynamic-char-styles
84 ///             textstyle-apply
85 ///             paste
86 /// To add a new one of these, you must add a routine, like 
87 /// loadFlexInsets, that will populate the menu, and call it from
88 /// updateTriggered. Make sure to add the new type to isMenuType().
89 class DynamicMenuButton : public MenuButtonBase
90 {
91     Q_OBJECT
92 public:
93         ///
94         DynamicMenuButton(GuiToolbar * bar, ToolbarItem const & item);
95         ///
96         ~DynamicMenuButton();
97         ///
98         static bool isMenuType(std::string const & s);
99 protected:
100         ///
101         void initialize() override;
102         ///
103         void loadFlexInsets();
104         /// pimpl so we don't have to include big files
105         class Private;
106         Private * d;
107 protected Q_SLOTS:
108         ///
109         void updateTriggered() override;
110 };
111
112
113 class GuiToolbar : public QToolBar
114 {
115         Q_OBJECT
116 public:
117         ///
118         GuiToolbar(ToolbarInfo const &, GuiView &);
119
120         /// Reimplemented from QToolbar to detect whether the
121         /// toolbar is restored with MainWindow::restoreState().
122         void setVisible(bool visible) override;
123
124         ///
125         void setVisibility(int visibility);
126
127         /// Add a button to the bar.
128         void add(ToolbarItem const & item);
129
130         /// Session key.
131         /**
132          * This key must be used for any session setting.
133          **/
134         QString sessionKey() const;
135         /// Save session settings.
136         void saveSession(QSettings & settings) const;
137         /// Restore session settings.
138         void restoreSession();
139
140         ///
141         bool isRestored() const;
142
143         ///
144         bool isVisibiltyOn() const;
145         int visibility() const { return visibility_; }
146
147         /// Refresh the contents of the bar.
148         void update(int context = 0);
149
150         ///
151         void toggle();
152
153         /// toggles movability
154         void movable(bool silent = false);
155
156         ///
157         GuiCommandBuffer * commandBuffer() { return command_buffer_; }
158
159         ///
160         Action * addItem(ToolbarItem const & item);
161     ///
162     GuiView const & owner() { return owner_; }
163
164 Q_SIGNALS:
165         ///
166         void updated();
167
168 private:
169         // load flags with saved values
170         void initFlags();
171         ///
172         void fill();
173         ///
174         void showEvent(QShowEvent *) override;
175
176         ///
177         QList<Action *> actions_;
178         /// initial visibility flags
179         int visibility_;
180         ///
181         GuiView & owner_;
182         ///
183         GuiCommandBuffer * command_buffer_;
184         ///
185         ToolbarInfo const & tbinfo_;
186         ///
187         bool filled_;
188         ///
189         bool restored_;
190 };
191
192 } // namespace frontend
193 } // namespace lyx
194
195 #endif // GUITOOLBAR_H