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
89 /// To add a new one of these, you must add a routine, like
90 /// loadFlexInsets, that will populate the menu, and call it from
91 /// updateTriggered. Make sure to add the new type to isMenuType().
92 class DynamicMenuButton : public MenuButtonBase
97 DynamicMenuButton(GuiToolbar * bar, ToolbarItem const & item);
101 static bool isMenuType(std::string const & s);
106 void loadFlexInsets();
107 /// pimpl so we don't have to include big files
112 void updateTriggered();
116 class GuiToolbar : public QToolBar
121 GuiToolbar(ToolbarInfo const &, GuiView &);
123 /// Reimplemented from QToolbar to detect whether the
124 /// toolbar is restored with MainWindow::restoreState().
125 void setVisible(bool visible);
128 void setVisibility(int visibility);
130 /// Add a button to the bar.
131 void add(ToolbarItem const & item);
135 * This key must be used for any session setting.
137 QString sessionKey() const;
138 /// Save session settings.
139 void saveSession(QSettings & settings) const;
140 /// Restore session settings.
141 void restoreSession();
144 bool isRestored() const;
146 /// Refresh the contents of the bar.
147 void update(int context = 0);
152 /// toggles movability
153 void movable(bool silent = false);
156 GuiCommandBuffer * commandBuffer() { return command_buffer_; }
159 Action * addItem(ToolbarItem const & item);
161 GuiView const & owner() { return owner_; }
168 // load flags with saved values
173 void showEvent(QShowEvent *);
176 QList<Action *> actions_;
177 /// initial visibility flags
182 GuiCommandBuffer * command_buffer_;
184 ToolbarInfo const & tbinfo_;
191 } // namespace frontend
194 #endif // GUITOOLBAR_H