4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * \author Jean-Marc Lasgouttes
10 * \author Angus Leeming
11 * \author Abdelrazak Younes
13 * Full author contact details are available in file CREDITS.
21 #include <QToolButton>
23 #include "support/strfwd.h"
35 class GuiCommandBuffer;
36 class GuiLayoutFilterModel;
43 class MenuButtonBase : public QToolButton
48 MenuButtonBase(GuiToolbar * bar, ToolbarItem const & item);
52 virtual void initialize() = 0;
56 ToolbarItem const & tbitem_;
60 void actionTriggered(QAction * action);
62 virtual void updateTriggered() = 0;
66 class StaticMenuButton : public MenuButtonBase
71 StaticMenuButton(GuiToolbar * bar, ToolbarItem const & item,
72 bool const sticky = false);
80 void updateTriggered();
84 /// A menu which can be populated on the fly.
85 /// The 'type' of menu must be given in the toolbar file
86 /// (stdtoolbars.inc, usually) and must be one of:
87 /// dynamic-custom-insets
88 /// dynamic-char-styles
91 /// To add a new one of these, you must add a routine, like
92 /// loadFlexInsets, that will populate the menu, and call it from
93 /// updateTriggered. Make sure to add the new type to isMenuType().
94 class DynamicMenuButton : public MenuButtonBase
99 DynamicMenuButton(GuiToolbar * bar, ToolbarItem const & item);
101 ~DynamicMenuButton();
103 static bool isMenuType(std::string const & s);
108 void loadFlexInsets();
109 /// pimpl so we don't have to include big files
114 void updateTriggered();
118 class GuiToolbar : public QToolBar
123 GuiToolbar(ToolbarInfo const &, GuiView &);
125 /// Reimplemented from QToolbar to detect whether the
126 /// toolbar is restored with MainWindow::restoreState().
127 void setVisible(bool visible);
130 void setVisibility(int visibility);
132 /// Add a button to the bar.
133 void add(ToolbarItem const & item);
137 * This key must be used for any session setting.
139 QString sessionKey() const;
140 /// Save session settings.
141 void saveSession(QSettings & settings) const;
142 /// Restore session settings.
143 void restoreSession();
146 bool isRestored() const;
148 /// Refresh the contents of the bar.
149 void update(int context = 0);
154 /// toggles movability
155 void movable(bool silent = false);
158 GuiCommandBuffer * commandBuffer() { return command_buffer_; }
161 Action * addItem(ToolbarItem const & item);
163 GuiView const & owner() { return owner_; }
170 // load flags with saved values
175 void showEvent(QShowEvent *);
178 QList<Action *> actions_;
179 /// initial visibility flags
184 GuiCommandBuffer * command_buffer_;
186 ToolbarInfo const & tbinfo_;
193 } // namespace frontend
196 #endif // GUITOOLBAR_H