2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiToolbar.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2006-03-05 17:24:44 +00:00
|
|
|
* \author John Levon
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#ifndef GUITOOLBAR_H
|
|
|
|
#define GUITOOLBAR_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-28 22:53:00 +00:00
|
|
|
#include <QList>
|
2006-09-10 11:03:21 +00:00
|
|
|
#include <QToolBar>
|
2009-04-18 10:44:44 +00:00
|
|
|
#include <QToolButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2016-06-24 17:47:30 -04:00
|
|
|
#include "support/strfwd.h"
|
|
|
|
|
2017-10-18 13:12:20 +02:00
|
|
|
class QSettings;
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
2007-08-31 05:53:55 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace frontend {
|
|
|
|
|
2008-03-10 13:02:57 +00:00
|
|
|
class Action;
|
2007-10-15 22:43:55 +00:00
|
|
|
class GuiCommandBuffer;
|
2008-05-25 08:30:06 +00:00
|
|
|
class GuiToolbar;
|
2007-11-05 13:52:37 +00:00
|
|
|
class GuiView;
|
2008-05-25 08:30:06 +00:00
|
|
|
class ToolbarInfo;
|
|
|
|
class ToolbarItem;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2016-06-24 17:47:30 -04:00
|
|
|
class MenuButtonBase : public QToolButton
|
2009-04-18 10:44:44 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
///
|
2016-06-24 17:47:30 -04:00
|
|
|
MenuButtonBase(GuiToolbar * bar, ToolbarItem const & item);
|
2009-04-18 10:44:44 +00:00
|
|
|
|
2016-06-24 17:47:30 -04:00
|
|
|
protected:
|
2012-09-22 20:51:49 +02:00
|
|
|
///
|
2016-06-24 17:47:30 -04:00
|
|
|
virtual void initialize() = 0;
|
2009-04-18 10:44:44 +00:00
|
|
|
///
|
|
|
|
GuiToolbar * bar_;
|
|
|
|
///
|
|
|
|
ToolbarItem const & tbitem_;
|
|
|
|
|
2016-06-24 17:47:30 -04:00
|
|
|
protected Q_SLOTS:
|
2009-04-18 10:44:44 +00:00
|
|
|
///
|
|
|
|
void actionTriggered(QAction * action);
|
2016-06-24 17:47:30 -04:00
|
|
|
///
|
|
|
|
virtual void updateTriggered() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class StaticMenuButton : public MenuButtonBase
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
StaticMenuButton(GuiToolbar * bar, ToolbarItem const & item,
|
|
|
|
bool const sticky = false);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
2020-10-04 17:56:53 +03:00
|
|
|
void initialize() override;
|
2016-06-24 17:47:30 -04:00
|
|
|
|
|
|
|
protected Q_SLOTS:
|
2012-03-15 12:55:40 +01:00
|
|
|
///
|
2020-10-04 17:56:53 +03:00
|
|
|
void updateTriggered() override;
|
2009-04-18 10:44:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-06-24 17:47:30 -04:00
|
|
|
/// A menu which can be populated on the fly.
|
|
|
|
/// The 'type' of menu must be given in the toolbar file
|
|
|
|
/// (stdtoolbars.inc, usually) and must be one of:
|
|
|
|
/// dynamic-custom-insets
|
|
|
|
/// dynamic-char-styles
|
2018-12-27 11:18:13 +01:00
|
|
|
/// textstyle-apply
|
2018-12-26 17:11:24 +01:00
|
|
|
/// paste
|
2016-06-24 17:47:30 -04:00
|
|
|
/// To add a new one of these, you must add a routine, like
|
|
|
|
/// loadFlexInsets, that will populate the menu, and call it from
|
|
|
|
/// updateTriggered. Make sure to add the new type to isMenuType().
|
|
|
|
class DynamicMenuButton : public MenuButtonBase
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
DynamicMenuButton(GuiToolbar * bar, ToolbarItem const & item);
|
|
|
|
///
|
|
|
|
~DynamicMenuButton();
|
|
|
|
///
|
|
|
|
static bool isMenuType(std::string const & s);
|
|
|
|
protected:
|
|
|
|
///
|
2020-10-04 17:56:53 +03:00
|
|
|
void initialize() override;
|
2016-06-24 17:47:30 -04:00
|
|
|
///
|
|
|
|
void loadFlexInsets();
|
|
|
|
/// pimpl so we don't have to include big files
|
|
|
|
class Private;
|
|
|
|
Private * d;
|
|
|
|
protected Q_SLOTS:
|
|
|
|
///
|
2020-10-04 17:56:53 +03:00
|
|
|
void updateTriggered() override;
|
2016-06-24 17:47:30 -04:00
|
|
|
};
|
|
|
|
|
2009-04-18 10:44:44 +00:00
|
|
|
|
2007-10-01 20:45:50 +00:00
|
|
|
class GuiToolbar : public QToolBar
|
2007-09-05 20:33:29 +00:00
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2008-05-27 11:15:17 +00:00
|
|
|
///
|
2007-11-05 13:52:37 +00:00
|
|
|
GuiToolbar(ToolbarInfo const &, GuiView &);
|
2017-07-03 13:45:58 -04:00
|
|
|
|
|
|
|
/// Reimplemented from QToolbar to detect whether the
|
2013-05-19 22:04:29 +02:00
|
|
|
/// toolbar is restored with MainWindow::restoreState().
|
2020-10-04 17:56:53 +03:00
|
|
|
void setVisible(bool visible) override;
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
///
|
|
|
|
void setVisibility(int visibility);
|
|
|
|
|
2007-10-01 20:45:50 +00:00
|
|
|
/// Add a button to the bar.
|
2007-04-19 19:43:15 +00:00
|
|
|
void add(ToolbarItem const & item);
|
2008-05-27 11:15:17 +00:00
|
|
|
|
|
|
|
/// Session key.
|
|
|
|
/**
|
|
|
|
* This key must be used for any session setting.
|
|
|
|
**/
|
|
|
|
QString sessionKey() const;
|
|
|
|
/// Save session settings.
|
2017-10-18 13:12:20 +02:00
|
|
|
void saveSession(QSettings & settings) const;
|
2008-05-27 11:15:17 +00:00
|
|
|
/// Restore session settings.
|
|
|
|
void restoreSession();
|
|
|
|
|
2013-05-19 22:04:29 +02:00
|
|
|
///
|
|
|
|
bool isRestored() const;
|
|
|
|
|
2020-08-04 15:23:53 +02:00
|
|
|
///
|
|
|
|
bool isVisibiltyOn() const;
|
|
|
|
int visibility() const { return visibility_; }
|
|
|
|
|
2007-10-01 20:45:50 +00:00
|
|
|
/// Refresh the contents of the bar.
|
2015-06-18 15:30:44 +02:00
|
|
|
void update(int context = 0);
|
2008-05-27 11:15:17 +00:00
|
|
|
|
2020-12-17 10:15:18 +01:00
|
|
|
///
|
|
|
|
void setState(std::string const state);
|
2008-05-27 11:15:17 +00:00
|
|
|
///
|
|
|
|
void toggle();
|
|
|
|
|
2021-03-04 12:35:38 +01:00
|
|
|
///
|
|
|
|
void refill();
|
|
|
|
|
2016-11-24 14:10:03 +02:00
|
|
|
/// toggles movability
|
|
|
|
void movable(bool silent = false);
|
|
|
|
|
2007-10-02 06:59:02 +00:00
|
|
|
///
|
|
|
|
GuiCommandBuffer * commandBuffer() { return command_buffer_; }
|
2006-09-10 11:03:21 +00:00
|
|
|
|
2008-03-14 16:39:34 +00:00
|
|
|
///
|
2008-01-16 18:27:24 +00:00
|
|
|
Action * addItem(ToolbarItem const & item);
|
2020-12-17 10:10:56 +01:00
|
|
|
///
|
|
|
|
GuiView const & owner() { return owner_; }
|
2008-01-16 18:27:24 +00:00
|
|
|
|
2006-06-30 14:37:33 +00:00
|
|
|
Q_SIGNALS:
|
2008-03-14 16:39:34 +00:00
|
|
|
///
|
2006-05-31 12:53:05 +00:00
|
|
|
void updated();
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
private:
|
2008-05-27 11:15:17 +00:00
|
|
|
// load flags with saved values
|
|
|
|
void initFlags();
|
2008-05-28 10:26:03 +00:00
|
|
|
///
|
|
|
|
void fill();
|
|
|
|
///
|
2020-10-03 15:42:14 +03:00
|
|
|
void showEvent(QShowEvent *) override;
|
2008-05-28 10:26:03 +00:00
|
|
|
|
2008-03-14 16:39:34 +00:00
|
|
|
///
|
2007-09-28 22:53:00 +00:00
|
|
|
QList<Action *> actions_;
|
2008-05-27 11:15:17 +00:00
|
|
|
/// initial visibility flags
|
|
|
|
int visibility_;
|
|
|
|
///
|
2007-11-05 13:52:37 +00:00
|
|
|
GuiView & owner_;
|
2008-03-14 16:39:34 +00:00
|
|
|
///
|
2007-09-28 22:53:00 +00:00
|
|
|
GuiCommandBuffer * command_buffer_;
|
2008-05-28 10:26:03 +00:00
|
|
|
///
|
|
|
|
ToolbarInfo const & tbinfo_;
|
2008-05-28 10:30:25 +00:00
|
|
|
///
|
|
|
|
bool filled_;
|
2013-05-19 22:04:29 +02:00
|
|
|
///
|
|
|
|
bool restored_;
|
2006-03-05 17:24:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#endif // GUITOOLBAR_H
|