various: fix broken transition creation

It's now possible to create transitions! But they're still broken in
a multitude of other ways so plenty more work to do hahahahahahahahaha
This commit is contained in:
itsmattkc
2020-07-14 22:31:11 +10:00
parent 11afdf32fe
commit ae62750d9d
21 changed files with 415 additions and 33 deletions
@@ -20,6 +20,7 @@
#include "widget/timelinewidget/timelinewidget.h"
#include "node/block/transition/crossdissolve/crossdissolvetransition.h"
#include "node/block/transition/transition.h"
#include "node/factory.h"
#include "widget/nodeview/nodeviewundo.h"
@@ -111,7 +112,14 @@ void TimelineWidget::TransitionTool::MouseRelease(TimelineViewMouseEvent *event)
if (ghost_) {
if (!ghost_->AdjustedLength().isNull()) {
TransitionBlock* transition = static_cast<TransitionBlock*>(NodeFactory::CreateFromID("org.olivevideoeditor.Olive.crossdissolve"));
TransitionBlock* transition;
if (Core::instance()->GetSelectedTransition().isEmpty()) {
// Fallback if the user hasn't selected one yet
transition = new CrossDissolveTransition();
} else {
transition = static_cast<TransitionBlock*>(NodeFactory::CreateFromID(Core::instance()->GetSelectedTransition()));
}
QUndoCommand* command = new QUndoCommand();
+21 -1
View File
@@ -25,8 +25,9 @@
#include <QButtonGroup>
#include <QEvent>
#include "widget/menu/menu.h"
#include "node/factory.h"
#include "ui/icons/icons.h"
#include "widget/menu/menu.h"
OLIVE_NAMESPACE_ENTER
@@ -54,6 +55,9 @@ Toolbar::Toolbar(QWidget *parent) :
btn_snapping_toggle_ = CreateNonToolButton();
connect(btn_snapping_toggle_, &QPushButton::clicked, this, &Toolbar::SnappingButtonClicked);
// Connect transition button to menu signal
connect(btn_transition_tool_, &QPushButton::clicked, this, &Toolbar::TransitionButtonClicked);
// Connect add button to menu signal
connect(btn_add_, &QPushButton::clicked, this, &Toolbar::AddButtonClicked);
@@ -181,9 +185,25 @@ void Toolbar::AddButtonClicked()
m.exec(QCursor::pos());
}
void Toolbar::TransitionButtonClicked()
{
Menu* m = NodeFactory::CreateMenu(this, false, Node::kCategoryTransition);
connect(m, &QMenu::triggered, this, &Toolbar::TransitionMenuItemTriggered);
m->exec(QCursor::pos());
delete m;
}
void Toolbar::AddMenuItemTriggered(QAction* a)
{
emit AddableObjectChanged(static_cast<Tool::AddableObject>(a->data().toInt()));
}
void Toolbar::TransitionMenuItemTriggered(QAction *a)
{
emit SelectedTransitionChanged(NodeFactory::GetIDFromMenuAction(a));
}
OLIVE_NAMESPACE_EXIT
+17
View File
@@ -113,6 +113,11 @@ signals:
*/
void AddableObjectChanged(const Tool::AddableObject& obj);
/**
* @brief Emitted when the selected transition is changed from the transition tool menu
*/
void SelectedTransitionChanged(const QString& id);
private:
/**
* @brief Reset all strings based on the currently selected language
@@ -210,11 +215,23 @@ private slots:
*/
void AddButtonClicked();
/**
* @brief Receiver for the transition button
*
* The transition button pops up a list for which transition to create.
*/
void TransitionButtonClicked();
/**
* @brief Receiver for the menu created by AddButtonClicked()
*/
void AddMenuItemTriggered(QAction* a);
/**
* @brief Receiver for the menu created by TransitionButtonClicked()
*/
void TransitionMenuItemTriggered(QAction* a);
};
OLIVE_NAMESPACE_EXIT