[vlmc-devel] Implement TransitionsListView
Yikai Lu
git at videolan.org
Mon Aug 7 19:18:37 CEST 2017
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Aug 8 01:34:38 2017 +0900| [48205b9ffb6ed6c260e2c1367961b75f3fb63527] | committer: Yikai Lu
Implement TransitionsListView
> https://code.videolan.org/videolan/vlmc/commit/48205b9ffb6ed6c260e2c1367961b75f3fb63527
---
Makefile.am | 3 ++
src/Gui/MainWindow.cpp | 10 +++++
src/Gui/MainWindow.h | 4 ++
src/Gui/transition/TransitionsListView.cpp | 65 ++++++++++++++++++++++++++++++
src/Gui/transition/TransitionsListView.h | 28 +++++++++++++
src/Gui/transition/TransitionsListView.qml | 35 ++++++++++++++++
6 files changed, 145 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 8baea3c3..3ce90db3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -173,6 +173,7 @@ vlmc_SOURCES += \
src/Gui/effectsengine/EffectsListView.cpp \
src/Gui/effectsengine/EffectStack.cpp \
src/Gui/effectsengine/EffectWidget.cpp \
+ src/Gui/transition/TransitionsListView.cpp \
src/Gui/export/RendererSettings.cpp \
src/Gui/export/ShareOnInternet.cpp \
src/Gui/import/TagWidget.cpp \
@@ -319,6 +320,7 @@ nodist_vlmc_SOURCES += \
src/Gui/media/ClipMetadataDisplayer.moc.cpp \
src/Gui/effectsengine/EffectWidget.moc.cpp \
src/Gui/effectsengine/EffectInstanceWidget.moc.cpp \
+ src/Gui/transition/TransitionsListView.moc.cpp \
src/Gui/preview/LCDTimecode.moc.cpp \
src/Gui/effectsengine/EffectStack.moc.cpp \
src/Gui/wizard/firstlaunch/WorkspaceLocation.moc.cpp \
@@ -402,6 +404,7 @@ vlmc_QML = \
src/Gui/library/ui/ClipItem.qml \
src/Gui/effectsengine/Effect.qml \
src/Gui/effectsengine/EffectsListView.qml \
+ src/Gui/transition/TransitionsListView.qml \
$(NULL)
EXTRA_DIST += $(vlmc_QML)
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 128dd069..022d6ed8 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -56,6 +56,7 @@
/* Widgets */
#include "effectsengine/EffectsListView.h"
+#include "transition/TransitionsListView.h"
#include "library/MediaLibraryView.h"
#include "library/ClipLibraryView.h"
#include "preview/PreviewWidget.h"
@@ -178,6 +179,7 @@ MainWindow::retranslateUi()
{
m_dockedUndoView->setWindowTitle( tr( "History" ) );
m_dockedEffectsList->setWindowTitle( tr( "Effects List" ) );
+ m_dockedTransitionsList->setWindowTitle( tr( "Transitions List" ) );
m_dockedMediaLibrary->setWindowTitle( tr( "Media Library" ) );
m_dockedClipLibrary->setWindowTitle( tr( "Clip Library" ) );
m_dockedClipPreview->setWindowTitle( tr( "Clip Preview" ) );
@@ -482,6 +484,7 @@ MainWindow::initializeDockWidgets()
setupLibrary();
setupEffectsList();
+ setupTransitionsList();
setupClipPreview();
setupProjectPreview();
setupUndoRedoWidget();
@@ -509,6 +512,13 @@ MainWindow::setupEffectsList()
}
void
+MainWindow::setupTransitionsList()
+{
+ m_transitionsList = new TransitionsListView( this );
+ m_dockedTransitionsList = dockWidget( m_transitionsList->container(), Qt::TopDockWidgetArea );
+}
+
+void
MainWindow::setupLibrary()
{
m_mediaLibrary = new MediaLibraryView( this );
diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h
index fceb5c1e..69467611 100644
--- a/src/Gui/MainWindow.h
+++ b/src/Gui/MainWindow.h
@@ -37,6 +37,7 @@ class QProgressBar;
#include "ui/MainWindow.h"
class EffectsListView;
+class TransitionsListView;
class ClipLibraryView;
class MediaLibraryView;
class PreviewWidget;
@@ -88,6 +89,7 @@ private:
void setupClipPreview();
void setupProjectPreview();
void setupEffectsList();
+ void setupTransitionsList();
void setupUndoRedoWidget();
void retranslateUi();
#ifdef WITH_CRASHBUTTON
@@ -132,9 +134,11 @@ private:
MediaLibraryView* m_mediaLibrary;
ClipLibraryView* m_clipLibrary;
EffectsListView* m_effectsList;
+ TransitionsListView* m_transitionsList;
QUndoView* m_undoView;
QDockWidget* m_dockedUndoView;
QDockWidget* m_dockedEffectsList;
+ QDockWidget* m_dockedTransitionsList;
QDockWidget* m_dockedClipLibrary;
QDockWidget* m_dockedMediaLibrary;
QDockWidget* m_dockedClipPreview;
diff --git a/src/Gui/transition/TransitionsListView.cpp b/src/Gui/transition/TransitionsListView.cpp
new file mode 100644
index 00000000..0ccb7b12
--- /dev/null
+++ b/src/Gui/transition/TransitionsListView.cpp
@@ -0,0 +1,65 @@
+#include "TransitionsListView.h"
+
+#include "Backend/IBackend.h"
+#include "Backend/IInfo.h"
+#include "Backend/ITransition.h"
+
+#include <QWidget>
+#include <QJsonObject>
+#include <QQuickView>
+#include <QQmlContext>
+#include <QDrag>
+#include <QMimeData>
+
+TransitionsListView::TransitionsListView( QWidget* parent )
+ : QObject( parent )
+{
+ setObjectName( QStringLiteral( "TransitionsListView" ) );
+ auto view = new QQuickView;
+ m_container = QWidget::createWindowContainer( view, parent );
+ m_container->setMinimumSize( 100, 1 );
+ m_container->setObjectName( objectName() );
+ view->rootContext()->setContextProperty( QStringLiteral( "view" ), this );
+ view->setSource( QUrl( QStringLiteral( "qrc:/QML/TransitionsListView.qml" ) ) );
+ view->setResizeMode( QQuickView::SizeRootObjectToView );
+}
+
+TransitionsListView::~TransitionsListView()
+{
+
+}
+
+QWidget*
+TransitionsListView::container()
+{
+ return m_container;
+}
+
+QJsonArray
+TransitionsListView::transitions()
+{
+ QJsonArray array;
+ for ( auto p : Backend::instance()->availableTransitions() )
+ {
+ auto info = p.second;
+ QJsonObject jInfo;
+ jInfo[QStringLiteral( "identifier" )] = QString::fromStdString( info->identifier() );
+ jInfo[QStringLiteral( "name" )] = QString::fromStdString( info->name() );
+ jInfo[QStringLiteral( "description" )] = QString::fromStdString( info->description() );
+ jInfo[QStringLiteral( "author" )] = QString::fromStdString( info->author() );
+ array.append( jInfo );
+ }
+ return array;
+}
+
+void
+TransitionsListView::startDrag( const QString& transitionId )
+{
+ QDrag* drag = new QDrag( this );
+ QMimeData* mimeData = new QMimeData;
+
+ mimeData->setData( QStringLiteral( "vlmc/transition_id" ), transitionId.toUtf8() );
+
+ drag->setMimeData( mimeData );
+ drag->exec();
+}
diff --git a/src/Gui/transition/TransitionsListView.h b/src/Gui/transition/TransitionsListView.h
new file mode 100644
index 00000000..da081be3
--- /dev/null
+++ b/src/Gui/transition/TransitionsListView.h
@@ -0,0 +1,28 @@
+#ifndef TRANSITIONSLISTVIEW_H
+#define TRANSITIONSLISTVIEW_H
+
+#include <QObject>
+#include <QJsonArray>
+
+class TransitionsListView : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY( TransitionsListView )
+
+ public:
+ explicit TransitionsListView( QWidget* parent = 0);
+ virtual ~TransitionsListView();
+
+ QWidget* container();
+
+ Q_INVOKABLE
+ QJsonArray transitions();
+
+ public slots:
+ void startDrag( const QString& transitionId );
+
+ private:
+ QWidget* m_container;
+};
+
+#endif // TRANSITIONSLISTVIEW_H
diff --git a/src/Gui/transition/TransitionsListView.qml b/src/Gui/transition/TransitionsListView.qml
new file mode 100644
index 00000000..47743c7f
--- /dev/null
+++ b/src/Gui/transition/TransitionsListView.qml
@@ -0,0 +1,35 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.4
+
+Rectangle {
+ anchors.fill: parent
+ color: "#999999"
+
+ ListModel {
+ id: transitionsList
+ }
+
+ Component.onCompleted: {
+ var transitionsInfo = view.transitions();
+ for ( var i = 0; i < transitionsInfo.length; ++i ) {
+ transitionsList.append( transitionsInfo[i] );
+ }
+ }
+
+ ScrollView {
+ id: sView
+ height: parent.height
+ width: parent.width
+
+ ListView {
+ width: sView.viewport.width
+ model: transitionsList
+ delegate: Effect {
+ width: sView.viewport.width
+ identifier: model.identifier
+ name: model.name
+ description: model.description
+ }
+ }
+ }
+}
More information about the Vlmc-devel
mailing list