pgLab/pglab/plugin_support/StaticAction.cpp
eelke 601d071d0f Proof of concept for having the context actions statically defined in the module.
Needs work for correctly placing the items in menu and on toolbar.
Old system still needs to be removed left in place to keep app useable.
2019-08-14 09:06:48 +02:00

75 lines
1.2 KiB
C++

#include "StaticAction.h"
BaseAction::BaseAction(const QString &text)
: m_text(text)
{}
const QIcon& BaseAction::icon() const
{
return m_icon;
}
const MenuLocation& BaseAction::menuLocation() const
{
return m_menuLocation;
}
void BaseAction::setIcon(QIcon icon)
{
m_icon = std::move(icon);
}
void BaseAction::setMenuLocation(MenuLocation menu_location)
{
m_menuLocation = std::move(menu_location);
}
void BaseAction::setToolbarLocation(ToolbarLocation toolbar_location)
{
m_toolbarLocation = toolbar_location;
}
void BaseAction::setShortcut(QKeySequence shortcut)
{
m_shortcut = std::move(shortcut);
}
void BaseAction::setText(QString text)
{
m_text = std::move(text);
}
void BaseAction::setToolTip(QString tooltip)
{
m_toolTip = std::move(tooltip);
}
const QKeySequence& BaseAction::shortcut() const
{
return m_shortcut;
}
const QString& BaseAction::text() const
{
return m_text;
}
const QString& BaseAction::toolTip() const
{
return m_toolTip;
}
StaticAction::StaticAction(QString text, Func func)
: BaseAction(std::move(text))
, m_func(std::move(func))
{}
void StaticAction::perform(IPluginContentWidgetContext *context) const
{
if (m_func)
m_func(context);
}
ContextBaseAction::~ContextBaseAction()
{}