right click menu in node view for adding nodes
This commit is contained in:
+5
-105
@@ -49,6 +49,7 @@
|
||||
#include "ui/icons.h"
|
||||
#include "global/clipboard.h"
|
||||
#include "global/config.h"
|
||||
#include "global/global.h"
|
||||
#include "ui/timelineheader.h"
|
||||
#include "ui/keyframeview.h"
|
||||
#include "ui/resizablescrollbar.h"
|
||||
@@ -90,36 +91,6 @@ void EffectControls::set_zoom(bool in) {
|
||||
}
|
||||
}
|
||||
|
||||
void EffectControls::menu_select(QAction* q) {
|
||||
ComboAction* ca = new ComboAction();
|
||||
for (int i=0;i<selected_clips_.size();i++) {
|
||||
Clip* c = selected_clips_.at(i);
|
||||
if (c->type() == effect_menu_subtype) {
|
||||
NodeType node_type = static_cast<NodeType>(q->data().toInt());
|
||||
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
|
||||
if (c->opening_transition == nullptr) {
|
||||
ca->append(new AddTransitionCommand(c,
|
||||
nullptr,
|
||||
nullptr,
|
||||
node_type,
|
||||
olive::config.default_transition_length));
|
||||
}
|
||||
if (c->closing_transition == nullptr) {
|
||||
ca->append(new AddTransitionCommand(nullptr,
|
||||
c,
|
||||
nullptr,
|
||||
node_type,
|
||||
olive::config.default_transition_length));
|
||||
}
|
||||
} else {
|
||||
ca->append(new AddEffectCommand(c, nullptr, node_type));
|
||||
}
|
||||
}
|
||||
}
|
||||
olive::undo_stack.push(ca);
|
||||
update_ui(true);
|
||||
}
|
||||
|
||||
void EffectControls::update_keyframes() {
|
||||
for (int i=0;i<open_effects_.size();i++) {
|
||||
EffectUI* ui = open_effects_.at(i);
|
||||
@@ -138,77 +109,6 @@ void EffectControls::scroll_to_frame(long frame) {
|
||||
scroll_to_frame_internal(horizontalScrollBar, frame - keyframeView->visible_in, zoom, keyframeView->width());
|
||||
}
|
||||
|
||||
void EffectControls::show_effect_menu(EffectType type, olive::TrackType subtype) {
|
||||
effect_menu_type = type;
|
||||
effect_menu_subtype = subtype;
|
||||
|
||||
olive::effects_loaded.lock();
|
||||
|
||||
Menu effects_menu(this);
|
||||
effects_menu.setToolTipsVisible(true);
|
||||
|
||||
for (int i=0;i<olive::node_library.size();i++) {
|
||||
|
||||
NodePtr node = olive::node_library.at(i);
|
||||
|
||||
if (node != nullptr && node->type() == type && node->subtype() == subtype) {
|
||||
QAction* action = new QAction(&effects_menu);
|
||||
action->setText(node->name());
|
||||
action->setData(i);
|
||||
if (!node->description().isEmpty()) {
|
||||
action->setToolTip(node->description());
|
||||
}
|
||||
|
||||
QMenu* parent = &effects_menu;
|
||||
if (!node->category().isEmpty()) {
|
||||
bool found = false;
|
||||
for (int j=0;j<effects_menu.actions().size();j++) {
|
||||
QAction* action = effects_menu.actions().at(j);
|
||||
if (action->menu() != nullptr) {
|
||||
if (action->menu()->title() == node->category()) {
|
||||
parent = action->menu();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
parent = new Menu(&effects_menu);
|
||||
parent->setToolTipsVisible(true);
|
||||
parent->setTitle(node->category());
|
||||
|
||||
bool found = false;
|
||||
for (int i=0;i<effects_menu.actions().size();i++) {
|
||||
QAction* comp_action = effects_menu.actions().at(i);
|
||||
if (comp_action->text() > node->category()) {
|
||||
effects_menu.insertMenu(comp_action, parent);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) effects_menu.addMenu(parent);
|
||||
}
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (int i=0;i<parent->actions().size();i++) {
|
||||
QAction* comp_action = parent->actions().at(i);
|
||||
if (comp_action->text() > action->text()) {
|
||||
parent->insertAction(comp_action, action);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) parent->addAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
olive::effects_loaded.unlock();
|
||||
|
||||
connect(&effects_menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_select(QAction*)));
|
||||
effects_menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void EffectControls::UpdateTitle() {
|
||||
if (selected_clips_.isEmpty()) {
|
||||
setWindowTitle(panel_name + tr("(none)"));
|
||||
@@ -445,19 +345,19 @@ bool EffectControls::focused()
|
||||
}
|
||||
|
||||
void EffectControls::video_effect_click() {
|
||||
show_effect_menu(EFFECT_TYPE_EFFECT, olive::kTypeVideo);
|
||||
olive::Global->ShowEffectMenu(EFFECT_TYPE_EFFECT, olive::kTypeVideo, selected_clips_);
|
||||
}
|
||||
|
||||
void EffectControls::audio_effect_click() {
|
||||
show_effect_menu(EFFECT_TYPE_EFFECT, olive::kTypeAudio);
|
||||
olive::Global->ShowEffectMenu(EFFECT_TYPE_EFFECT, olive::kTypeAudio, selected_clips_);
|
||||
}
|
||||
|
||||
void EffectControls::video_transition_click() {
|
||||
show_effect_menu(EFFECT_TYPE_TRANSITION, olive::kTypeVideo);
|
||||
olive::Global->ShowEffectMenu(EFFECT_TYPE_TRANSITION, olive::kTypeVideo, selected_clips_);
|
||||
}
|
||||
|
||||
void EffectControls::audio_transition_click() {
|
||||
show_effect_menu(EFFECT_TYPE_TRANSITION, olive::kTypeAudio);
|
||||
olive::Global->ShowEffectMenu(EFFECT_TYPE_TRANSITION, olive::kTypeAudio, selected_clips_);
|
||||
}
|
||||
|
||||
void EffectControls::resizeEvent(QResizeEvent*) {
|
||||
|
||||
@@ -76,8 +76,6 @@ public:
|
||||
public slots:
|
||||
void update_keyframes();
|
||||
private slots:
|
||||
void menu_select(QAction* q);
|
||||
|
||||
void video_effect_click();
|
||||
void audio_effect_click();
|
||||
void video_transition_click();
|
||||
@@ -94,14 +92,11 @@ protected:
|
||||
virtual void ClearEvent() override;
|
||||
virtual void LoadEvent() override;
|
||||
private:
|
||||
void show_effect_menu(EffectType type, olive::TrackType subtype);
|
||||
void load_keyframes();
|
||||
void UpdateTitle();
|
||||
|
||||
void setup_ui();
|
||||
|
||||
int effect_menu_type;
|
||||
olive::TrackType effect_menu_subtype;
|
||||
QString panel_name;
|
||||
|
||||
QWidget* video_effect_area;
|
||||
|
||||
@@ -16,6 +16,8 @@ EffectsPanel::~EffectsPanel()
|
||||
}
|
||||
|
||||
void EffectsPanel::Clear(bool clear_cache) {
|
||||
AboutToClearEvent();
|
||||
|
||||
// clear existing clips
|
||||
deselect_all_effects(nullptr);
|
||||
|
||||
@@ -205,6 +207,10 @@ void EffectsPanel::copy(bool del) {
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsPanel::AboutToClearEvent()
|
||||
{
|
||||
}
|
||||
|
||||
void EffectsPanel::DeleteEffect(ComboAction* ca, Node* effect_ref) {
|
||||
if (effect_ref->type() == EFFECT_TYPE_EFFECT) {
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public slots:
|
||||
void cut();
|
||||
void copy(bool del = false);
|
||||
protected:
|
||||
virtual void AboutToClearEvent();
|
||||
virtual void ClearEvent();
|
||||
virtual void LoadEvent();
|
||||
|
||||
|
||||
+19
-4
@@ -6,6 +6,8 @@
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QDebug>
|
||||
|
||||
#include "global/global.h"
|
||||
|
||||
NodeEditor::NodeEditor(QWidget *parent) :
|
||||
EffectsPanel(parent),
|
||||
view_(&scene_)
|
||||
@@ -26,6 +28,12 @@ NodeEditor::NodeEditor(QWidget *parent) :
|
||||
view_.setDragMode(QGraphicsView::RubberBandDrag);
|
||||
|
||||
connect(&scene_, SIGNAL(changed(const QList<QRectF>&)), this, SLOT(ItemsChanged()));
|
||||
connect(&view_, SIGNAL(RequestContextMenu()), this, SLOT(ContextMenu()));
|
||||
}
|
||||
|
||||
NodeEditor::~NodeEditor()
|
||||
{
|
||||
Clear(true);
|
||||
}
|
||||
|
||||
void NodeEditor::Retranslate()
|
||||
@@ -60,10 +68,10 @@ void NodeEditor::LoadEvent()
|
||||
LoadEdges();
|
||||
}
|
||||
|
||||
void NodeEditor::ClearEvent()
|
||||
void NodeEditor::AboutToClearEvent()
|
||||
{
|
||||
foreach (NodeUI* node, nodes_) {
|
||||
scene_.removeItem(node);
|
||||
delete node;
|
||||
}
|
||||
|
||||
nodes_.clear();
|
||||
@@ -75,6 +83,7 @@ void NodeEditor::ClearEdges()
|
||||
{
|
||||
foreach (NodeEdgeUI* edge, edges_) {
|
||||
scene_.removeItem(edge);
|
||||
delete edge;
|
||||
}
|
||||
|
||||
edges_.clear();
|
||||
@@ -150,8 +159,14 @@ void NodeEditor::ItemsChanged()
|
||||
|
||||
void NodeEditor::ReloadEdges()
|
||||
{
|
||||
qDebug() << "reload edges called";
|
||||
|
||||
ClearEdges();
|
||||
LoadEdges();
|
||||
}
|
||||
|
||||
void NodeEditor::ContextMenu()
|
||||
{
|
||||
if (!open_effects_.isEmpty()) {
|
||||
Clip* c = open_effects_.first()->GetEffect()->parent_clip;
|
||||
olive::Global->ShowEffectMenu(EFFECT_TYPE_EFFECT, c->type(), {c});
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -12,12 +12,13 @@ class NodeEditor : public EffectsPanel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
NodeEditor(QWidget* parent = nullptr);
|
||||
virtual ~NodeEditor() override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
protected:
|
||||
virtual void LoadEvent() override;
|
||||
virtual void ClearEvent() override;
|
||||
virtual void AboutToClearEvent() override;
|
||||
|
||||
private:
|
||||
QGraphicsScene scene_;
|
||||
@@ -35,6 +36,7 @@ private:
|
||||
private slots:
|
||||
void ItemsChanged();
|
||||
void ReloadEdges();
|
||||
void ContextMenu();
|
||||
|
||||
};
|
||||
|
||||
|
||||
+6
-11
@@ -873,22 +873,24 @@ void Timeline::transition_tool_click() {
|
||||
|
||||
Menu transition_menu(this);
|
||||
|
||||
transition_menu.addAction(tr("Video Transitions"))->setEnabled(false);
|
||||
|
||||
for (int i=0;i<olive::node_library.size();i++) {
|
||||
NodePtr node = olive::node_library.at(i);
|
||||
if (node->type() == EFFECT_TYPE_TRANSITION && node->subtype() == olive::kTypeVideo) {
|
||||
if (node != nullptr && node->type() == EFFECT_TYPE_TRANSITION && node->subtype() == olive::kTypeVideo) {
|
||||
QAction* a = transition_menu.addAction(node->name());
|
||||
a->setObjectName("v");
|
||||
a->setData(i);
|
||||
}
|
||||
}
|
||||
|
||||
transition_menu.addSeparator();
|
||||
|
||||
transition_menu.addAction(tr("Audio Transitions"))->setEnabled(false);
|
||||
|
||||
for (int i=0;i<olive::node_library.size();i++) {
|
||||
NodePtr node = olive::node_library.at(i);
|
||||
if (node->type() == EFFECT_TYPE_TRANSITION && node->subtype() == olive::kTypeVideo) {
|
||||
if (node != nullptr && node->type() == EFFECT_TYPE_TRANSITION && node->subtype() == olive::kTypeAudio) {
|
||||
QAction* a = transition_menu.addAction(node->name());
|
||||
a->setObjectName("a");
|
||||
a->setData(i);
|
||||
}
|
||||
}
|
||||
@@ -902,13 +904,6 @@ void Timeline::transition_tool_click() {
|
||||
|
||||
void Timeline::transition_menu_select(QAction* a) {
|
||||
transition_tool_meta = static_cast<NodeType>(a->data().toInt());
|
||||
|
||||
if (a->objectName() == "v") {
|
||||
transition_tool_side = olive::kTypeVideo;
|
||||
} else {
|
||||
transition_tool_side = olive::kTypeAudio;
|
||||
}
|
||||
|
||||
timeline_area->setCursor(Qt::CrossCursor);
|
||||
olive::timeline::current_tool = olive::timeline::TIMELINE_TOOL_TRANSITION;
|
||||
toolTransitionButton->setChecked(true);
|
||||
|
||||
@@ -115,7 +115,6 @@ public:
|
||||
Clip* transition_tool_open_clip;
|
||||
Clip* transition_tool_close_clip;
|
||||
NodeType transition_tool_meta;
|
||||
olive::TrackType transition_tool_side;
|
||||
|
||||
// hand tool variables
|
||||
bool hand_moving;
|
||||
|
||||
Reference in New Issue
Block a user