Commit bf83c582 authored by Halla Rempt's avatar Halla Rempt
Browse files

Make it possible to add tool buttons to the toolbar

Create an action for the tool in the toolfactory's createActions
method, so it's already present when the factory is created, not
only when the tool is created.

(cherry picked from commit 55a24002)
parent 1dde6b83
......@@ -58,16 +58,19 @@ KoToolFactoryBase::~KoToolFactoryBase()
QList<QAction *> KoToolFactoryBase::createActions(KActionCollection *actionCollection)
{
// qDebug() << "creating actions for" << id();
QList<QAction *> toolActions;
Q_FOREACH(QAction *action, createActionsImpl()) {
KisActionRegistry *actionRegistry = KisActionRegistry::instance();
QList<QAction*> actions = createActionsImpl();
actions << actionRegistry->makeQAction(id());
Q_FOREACH(QAction *action, actions) {
if (action->objectName().isEmpty()) {
qWarning() << "Tool" << id() << "tries to add an action without a name";
continue;
}
QAction *existingAction = actionCollection->action(action->objectName());
if (existingAction) {
// qDebug() << "\tFound existing action" << action->objectName() << existingAction->property("tool_action");
delete action;
action = existingAction;
}
......@@ -79,7 +82,6 @@ QList<QAction *> KoToolFactoryBase::createActions(KActionCollection *actionColle
tools << id();
action->setProperty("tool_action", tools);
if (!existingAction) {
// qDebug() << "\tAdding new action" << action->objectName() << "Associated with" << tools;
actionCollection->addAction(action->objectName(), action);
}
toolActions << action;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment