footageviewer: allow dragging footage from footage viewer
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "footageviewer.h"
|
||||
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "project/project.h"
|
||||
|
||||
FootageViewerWidget::FootageViewerWidget(QWidget *parent) :
|
||||
@@ -13,6 +16,8 @@ FootageViewerWidget::FootageViewerWidget(QWidget *parent) :
|
||||
NodeParam::ConnectEdge(video_node_->output(), viewer_node_->texture_input());
|
||||
NodeParam::ConnectEdge(audio_node_->output(), viewer_node_->samples_input());
|
||||
NodeParam::ConnectEdge(video_node_->output(), viewer_node_->length_input());
|
||||
|
||||
connect(gl_widget_, &ViewerGLWidget::DragStarted, this, &FootageViewerWidget::StartFootageDrag);
|
||||
}
|
||||
|
||||
Footage *FootageViewerWidget::GetFootage() const
|
||||
@@ -62,3 +67,24 @@ void FootageViewerWidget::SetFootage(Footage *footage)
|
||||
audio_renderer_->InvalidateCache(TimeRange(0, viewer_node_->Length()));
|
||||
}
|
||||
}
|
||||
|
||||
void FootageViewerWidget::StartFootageDrag()
|
||||
{
|
||||
if (!GetFootage()) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Drag start!";
|
||||
QDrag* drag = new QDrag(this);
|
||||
QMimeData* mimedata = new QMimeData();
|
||||
|
||||
QByteArray encoded_data;
|
||||
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
||||
|
||||
stream << -1 << reinterpret_cast<quintptr>(GetFootage());
|
||||
|
||||
mimedata->setData("application/x-oliveprojectitemdata", encoded_data);
|
||||
drag->setMimeData(mimedata);
|
||||
|
||||
drag->exec();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ private:
|
||||
|
||||
ViewerOutput* viewer_node_;
|
||||
|
||||
private slots:
|
||||
void StartFootageDrag();
|
||||
|
||||
};
|
||||
|
||||
#endif // FOOTAGEVIEWERWIDGET_H
|
||||
|
||||
@@ -118,6 +118,8 @@ protected:
|
||||
OpenGLBackend* video_renderer_;
|
||||
AudioBackend* audio_renderer_;
|
||||
|
||||
ViewerGLWidget* gl_widget_;
|
||||
|
||||
private:
|
||||
void UpdateTimeInternal(int64_t i);
|
||||
|
||||
@@ -131,8 +133,6 @@ private:
|
||||
|
||||
ViewerSizer* sizer_;
|
||||
|
||||
ViewerGLWidget* gl_widget_;
|
||||
|
||||
PlaybackControls* controls_;
|
||||
|
||||
qint64 start_msec_;
|
||||
|
||||
@@ -167,6 +167,13 @@ const QString &ViewerGLWidget::ocio_look() const
|
||||
return ocio_look_;
|
||||
}
|
||||
|
||||
void ViewerGLWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QOpenGLWidget::mousePressEvent(event);
|
||||
|
||||
emit DragStarted();
|
||||
}
|
||||
|
||||
void ViewerGLWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look)
|
||||
{
|
||||
ocio_display_ = display;
|
||||
|
||||
@@ -119,7 +119,15 @@ public slots:
|
||||
const QString& ocio_view() const;
|
||||
const QString& ocio_look() const;
|
||||
|
||||
signals:
|
||||
void DragStarted();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Override the mouse press event simply to emit the DragStarted() signal
|
||||
*/
|
||||
virtual void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
/**
|
||||
* @brief Initialize function to set up the OpenGL context upon its construction
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user