Commit 56d5057c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

EffectsEngine: Allowing filter drag and drop to the timeline.

parent 21ee39e1
......@@ -153,6 +153,7 @@ ELSE(NOT WITH_GUI)
Gui/UndoStack.cpp
Gui/WorkflowFileRendererDialog.cpp
Gui/effectsengine/EffectsList.cpp
Gui/effectsengine/EffectsListView.cpp
Gui/export/RendererSettings.cpp
Gui/export/ShareOnYoutube.cpp
Gui/import/ImportController.cpp
......@@ -216,6 +217,7 @@ ELSE(NOT WITH_GUI)
Gui/UndoStack.h
Gui/WorkflowFileRendererDialog.h
Gui/effectsengine/EffectsList.h
Gui/effectsengine/EffectsListView.h
Gui/export/RendererSettings.h
Gui/export/ShareOnYoutube.h
Gui/import/ImportController.h
......
......@@ -425,7 +425,15 @@ MainWindow::createStatusBar()
void
MainWindow::initializeDockWidgets( void )
{
DockWidgetManager *dockManager = DockWidgetManager::getInstance();
//FIXME !!!
EffectsList *effectsList = new EffectsList( this );
dockManager->addDockedWidget( effectsList,
QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ),
Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
EffectsEngine::getInstance()->browseDirectory( "/usr/local/frei0r/lib/" );
m_renderer = new WorkflowRenderer();
......@@ -435,8 +443,6 @@ MainWindow::initializeDockWidgets( void )
m_timeline->show();
setCentralWidget( m_timeline );
DockWidgetManager *dockManager = DockWidgetManager::getInstance();
m_clipPreview = new PreviewWidget( this );
m_clipPreview->setRenderer( new ClipRenderer );
dockManager->addDockedWidget( m_clipPreview,
......@@ -457,12 +463,6 @@ MainWindow::initializeDockWidgets( void )
KeyboardShortcutHelper* renderShortcut = new KeyboardShortcutHelper( "keyboard/renderpreview", this );
connect( renderShortcut, SIGNAL( activated() ), m_projectPreview, SLOT( on_pushButtonPlay_clicked() ) );
EffectsList *effectsList = new EffectsList( this );
dockManager->addDockedWidget( effectsList,
QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ),
Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
QDockWidget* dock = dockManager->addDockedWidget( UndoStack::getInstance( this ),
QT_TRANSLATE_NOOP( "DockWidgetManager", "History" ),
Qt::AllDockWidgetAreas,
......
......@@ -24,32 +24,16 @@
#include "EffectsEngine/EffectsEngine.h"
#include "ui_EffectsList.h"
#include <QStandardItemModel>
EffectsList::EffectsList(QWidget *parent) :
QWidget(parent),
m_ui( new Ui::EffectsList )
{
m_ui->setupUi( this );
m_filtersModel = new QStandardItemModel( this );
m_effectsModel = new QStandardItemModel( this );
m_ui->filterList->setModel( m_filtersModel );
m_ui->effectsList->setModel( m_effectsModel );
connect( EffectsEngine::getInstance(), SIGNAL( effectAdded( Effect*, Effect::Type ) ),
this, SLOT( effectAdded(Effect*,Effect::Type) ) );
m_ui->filterList->setType( Effect::Filter );
m_ui->effectsList->setType( Effect::Mixer2 );
}
EffectsList::~EffectsList()
{
delete m_ui;
}
void
EffectsList::effectAdded( Effect *effect, Effect::Type type )
{
if ( type == Effect::Filter )
m_filtersModel->appendRow( new QStandardItem( effect->name() ) );
else
m_effectsModel->appendRow( new QStandardItem( effect->name() ) );
}
......@@ -26,8 +26,6 @@
#include <QWidget>
#include "EffectsEngine/Effect.h"
class QStandardItemModel;
namespace Ui
{
class EffectsList;
......@@ -43,11 +41,6 @@ class EffectsList : public QWidget
private:
Ui::EffectsList *m_ui;
QStandardItemModel *m_filtersModel;
QStandardItemModel *m_effectsModel;
public slots:
void effectAdded( Effect *effect, Effect::Type type );
};
#endif // EFFECTSLIST_H
#include "EffectsListView.h"
#include "EffectsEngine/EffectsEngine.h"
#include <QApplication>
#include <QMouseEvent>
#include <QStandardItem>
#include <QtDebug>
EffectsListView::EffectsListView(QWidget *parent) :
QListView(parent)
{
m_model = new QStandardItemModel( this );
connect( EffectsEngine::getInstance(), SIGNAL( effectAdded( Effect*, Effect::Type ) ),
this, SLOT( effectAdded(Effect*,Effect::Type) ) );
setModel( m_model );
setEditTriggers( QListView::NoEditTriggers );
setDragEnabled( true );
setSelectionMode( QAbstractItemView::MultiSelection );
}
void
EffectsListView::effectAdded( Effect *effect, Effect::Type type )
{
if ( type == m_type )
m_model->appendRow( new QStandardItem( effect->name() ) );
}
void
EffectsListView::setType( Effect::Type type )
{
m_type = type;
}
void
EffectsListView::mousePressEvent( QMouseEvent *event )
{
QListView::mousePressEvent( event );
if ( ( event->buttons() | Qt::LeftButton ) == Qt::LeftButton )
m_dragStartPos = event->pos();
}
void
EffectsListView::mouseMoveEvent( QMouseEvent *event )
{
if ( ( event->buttons() | Qt::LeftButton ) != Qt::LeftButton )
return;
if ( ( event->pos() - m_dragStartPos ).manhattanLength()
< QApplication::startDragDistance() )
return;
QMimeData* mimeData = new QMimeData;
mimeData->setData( "vlmc/effect_name", m_model->data( currentIndex() ).toByteArray() );
QDrag* drag = new QDrag( this );
drag->setMimeData( mimeData );
drag->exec( Qt::CopyAction | Qt::MoveAction, Qt::CopyAction );
}
#ifndef EFFECTLISTVIEW_H
#define EFFECTLISTVIEW_H
#include "EffectsEngine/Effect.h"
#include <QListView>
class QStandardItemModel;
class EffectsListView : public QListView
{
Q_OBJECT
public:
explicit EffectsListView(QWidget *parent = 0);
void setType( Effect::Type type );
protected:
void mousePressEvent( QMouseEvent *event );
void mouseMoveEvent( QMouseEvent *event );
private:
QStandardItemModel *m_model;
Effect::Type m_type;
QPoint m_dragStartPos;
public slots:
void effectAdded( Effect *effect, Effect::Type type );
};
#endif // EFFECTLISTVIEW_H
......@@ -25,13 +25,16 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QListView" name="filterList">
<widget class="EffectsListView" name="filterList">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
</widget>
</item>
</layout>
......@@ -42,7 +45,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QListView" name="effectsList"/>
<widget class="EffectsListView" name="effectsList"/>
</item>
</layout>
</widget>
......@@ -50,6 +53,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>EffectsListView</class>
<extends>QListView</extends>
<header>effectsengine/EffectsListView.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -251,3 +251,22 @@ Timeline::load( const QDomElement &root )
elem = elem.nextSibling().toElement();
}
}
void
Timeline::dragEnterEvent( QDragEnterEvent *event )
{
if ( event->mimeData()->hasFormat("vlmc/effect_name") == true )
event->acceptProposedAction();
else
event->ignore();
}
void
Timeline::dropEvent( QDropEvent *event )
{
Effect* effect = EffectsEngine::getInstance()->effect( event->mimeData()->data( "vlmc/effect_name") );
if ( effect != NULL )
m_renderer->appendEffect( effect );
else
qWarning() << "Can't find effect name" << event->mimeData()->data( "vlmc/effect_name");
}
......@@ -99,6 +99,9 @@ public slots:
*/
void actionRemoveClip( const QUuid& uuid, unsigned int track, MainWorkflow::TrackType trackType );
void dragEnterEvent( QDragEnterEvent *event );
void dropEvent( QDropEvent *event );
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -430,6 +430,7 @@ void
WorkflowRenderer::appendEffect( Effect *effect, qint64 start, qint64 end )
{
effect->setUsed( true );
effect->init( m_width, m_height );
m_effects.push_back( new EffectsEngine::EffectHelper( effect, start, end ) );
}
......
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