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
90 /// To add a new one of these, you must add a routine, like
91 /// loadFlexInsets, that will populate the menu, and call it from
92 /// updateTriggered. Make sure to add the new type to isMenuType().
93 class DynamicMenuButton : public MenuButtonBase
98 DynamicMenuButton(GuiToolbar * bar, ToolbarItem const & item);
100 ~DynamicMenuButton();
102 static bool isMenuType(std::string const & s);
107 void loadFlexInsets();
108 /// pimpl so we don't have to include big files
113 void updateTriggered();
117 class GuiToolbar : public QToolBar
122 GuiToolbar(ToolbarInfo const &, GuiView &);
124 /// Reimplemented from QToolbar to detect whether the
125 /// toolbar is restored with MainWindow::restoreState().
126 void setVisible(bool visible);
129 void setVisibility(int visibility);
131 /// Add a button to the bar.
132 void add(ToolbarItem const & item);
136 * This key must be used for any session setting.
138 QString sessionKey() const;
139 /// Save session settings.
140 void saveSession(QSettings & settings) const;
141 /// Restore session settings.
142 void restoreSession();
145 bool isRestored() const;
147 /// Refresh the contents of the bar.
148 void update(int context = 0);
153 /// toggles movability
154 void movable(bool silent = false);
157 GuiCommandBuffer * commandBuffer() { return command_buffer_; }
160 Action * addItem(ToolbarItem const & item);
162 GuiView const & owner() { return owner_; }
169 // load flags with saved values
174 void showEvent(QShowEvent *);
177 QList<Action *> actions_;
178 /// initial visibility flags
183 GuiCommandBuffer * command_buffer_;
185 ToolbarInfo const & tbinfo_;
192 } // namespace frontend
195 #endif // GUITOOLBAR_H