nodeparamview: implemented add button

This commit is contained in:
itsmattkc
2022-04-26 14:23:19 -07:00
parent 45b18f6df2
commit d1bb931854
19 changed files with 114 additions and 6 deletions
@@ -23,6 +23,8 @@
#include <QMessageBox>
#include "node/block/clip/clip.h"
#include "node/factory.h"
#include "widget/nodeview/nodeviewundo.h"
namespace olive {
@@ -130,7 +132,45 @@ void NodeParamViewContext::Retranslate()
void NodeParamViewContext::AddEffectButtonClicked()
{
QMessageBox::information(this, tr("STUB"), tr("This feature is coming soon. Thanks for testing development builds of Olive :)"));
Menu *m = NodeFactory::CreateMenu(this, false, Node::kCategoryUnknown, Node::kVideoEffect);
connect(m, &Menu::triggered, this, &NodeParamViewContext::AddEffectMenuItemTriggered);
m->exec(QCursor::pos());
delete m;
}
void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a)
{
Node *n = NodeFactory::CreateFromMenuAction(a);
if (n) {
NodeInput new_node_input = n->GetEffectInput();
MultiUndoCommand *command = new MultiUndoCommand();
QVector<NodeGraph*> graphs_added_to;
foreach (Node *ctx, contexts_) {
NodeInput ctx_input = ctx->GetEffectInput();
if (!graphs_added_to.contains(ctx->parent())) {
command->add_child(new NodeAddCommand(ctx->parent(), n));
graphs_added_to.append(ctx->parent());
}
command->add_child(new NodeSetPositionCommand(n, ctx, ctx->GetNodePositionInContext(ctx)));
command->add_child(new NodeSetPositionCommand(ctx, ctx, ctx->GetNodePositionInContext(ctx) + QPointF(1, 0)));
if (ctx_input.IsConnected()) {
Node *prev_output = ctx_input.GetConnectedOutput();
command->add_child(new NodeEdgeRemoveCommand(prev_output, ctx_input));
command->add_child(new NodeEdgeAddCommand(prev_output, new_node_input));
}
command->add_child(new NodeEdgeAddCommand(n, ctx_input));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
}
}
}
@@ -91,6 +91,8 @@ private:
private slots:
void AddEffectButtonClicked();
void AddEffectMenuItemTriggered(QAction *a);
};
}