[vlmc-devel] Use the QML Timeline
Yikai Lu
git at videolan.org
Sun Jul 10 18:03:29 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sat Jul 9 19:41:31 2016 +0900| [d11d4df8713aacfdb115f6f5b1d06ccc5c576783] | committer: Yikai Lu
Use the QML Timeline
> https://code.videolan.org/videolan/vlmc/commit/d11d4df8713aacfdb115f6f5b1d06ccc5c576783
---
src/CMakeLists.txt | 9 ++++++---
src/Gui/MainWindow.cpp | 7 +++----
src/Gui/timeline/Timeline.cpp | 25 +++++++++++++++----------
src/Gui/timeline/Timeline.h | 21 ++++++++++-----------
4 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 556d085..a85cf0a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,7 +17,7 @@ find_package(Qt5Core QUIET)
if (Qt5Core_FOUND)
# go on with other packages
if(WITH_GUI)
- find_package(Qt5 COMPONENTS Widgets Gui Network)
+ find_package(Qt5 COMPONENTS Widgets Gui Network Qml Quick)
else()
find_package(Qt5 COMPONENTS Network)
endif()
@@ -109,7 +109,10 @@ ELSE (WIN32)
LIST( APPEND VLMC_SRCS Main/vlmc.cpp )
ENDIF(WIN32)
-SET(VLMC_RCC ../resources.qrc)
+SET(VLMC_RCC
+ ../resources.qrc
+ ../src/Gui/timeline/resources-timeline.qrc
+ )
IF (WIN32)
LIST( APPEND VLMC_RCC ../resources/styles.qrc )
@@ -275,7 +278,7 @@ ELSE(NOT WITH_GUI)
ADD_EXECUTABLE( vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_UIS_H} ${VLMC_RCC_SRCS} )
TARGET_LINK_LIBRARIES( vlmc ${VLMC_LIBS} )
if (NOT Qt4_FOUND)
- qt5_use_modules(vlmc Core Gui Widgets Network)
+ qt5_use_modules(vlmc Core Gui Widgets Network Qml Quick)
else()
# We need to know the target for this one, which is not the case when doing most of the QT4/5 specific stuff.
# We could hide this command in qt_use_modules macro, but this would be some kind of black magic uglyness
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 28b5ec9..5adff21 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -33,6 +33,7 @@
#include <QUrl>
#include <QNetworkProxy>
#include <QSysInfo>
+#include <QScrollArea>
#include "Main/Core.h"
#include "Project/Project.h"
#include "Library/Library.h"
@@ -415,10 +416,8 @@ MainWindow::createStatusBar()
void
MainWindow::initializeDockWidgets()
{
- m_timeline = new Timeline;
- m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
- m_timeline->show();
- setCentralWidget( m_timeline );
+ m_timeline = new Timeline( this );
+ setCentralWidget( m_timeline->container() );
m_importController = new ImportController();
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index e6f310b..e7efcab 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -22,23 +22,28 @@
#include "Timeline.h"
-#include "Project/Project.h"
-#include "Main/Core.h"
-#include "Media/Clip.h"
-#include "Workflow/MainWorkflow.h"
-#include "Tools/VlmcDebug.h"
-#include "Renderer/AbstractRenderer.h"
-
-#include <QHBoxLayout>
-#include <QScrollBar>
+#include <QtQuick/QQuickView>
+#include <QUrl>
Timeline* Timeline::m_instance = nullptr;
Timeline::Timeline( QWidget *parent )
- : QWidget( parent )
+ : QObject( parent )
+ , m_view( new QQuickView )
+ , m_container( QWidget::createWindowContainer( m_view, parent ) )
{
+ m_container->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
+ m_container->setFocusPolicy( Qt::TabFocus );
+ m_view->setSource( QUrl( QStringLiteral( "qrc:/QML/main.qml" ) ) );
}
Timeline::~Timeline()
{
+ delete m_view;
+}
+
+QWidget*
+Timeline::container()
+{
+ return m_container;
}
diff --git a/src/Gui/timeline/Timeline.h b/src/Gui/timeline/Timeline.h
index abbe0ef..0b7e56f 100644
--- a/src/Gui/timeline/Timeline.h
+++ b/src/Gui/timeline/Timeline.h
@@ -28,17 +28,12 @@
#include "ui_Timeline.h"
#include "Workflow/Types.h"
-class MainWorkflow;
-class Project;
-class TracksScene;
-class TracksView;
-class TracksControls;
-class TracksRuler;
+class QQuickView;
/**
* \brief Entry point of the timeline widget.
*/
-class Timeline : public QWidget
+class Timeline : public QObject
{
Q_OBJECT
Q_DISABLE_COPY( Timeline )
@@ -46,6 +41,8 @@ public:
explicit Timeline( QWidget *parent = 0 );
virtual ~Timeline();
+ QWidget* container();
+
public slots:
/**
* \brief Asks the workflow to clear itself.
@@ -55,22 +52,24 @@ public slots:
* \brief Change the zoom level for all widgets of the timeline.
* \param factor The zoom factor.
*/
- void changeZoom( int factor ) {}
+ void changeZoom( int factor ) { Q_UNUSED( factor ) }
/**
* \brief Change the duration of the project.
* \param duration Duration in frames.
*/
- void setDuration( int duration ) {}
+ void setDuration( int duration ) { Q_UNUSED( duration ) }
/**
* \brief Change the currently selected tool.
*/
- void setTool( ToolButtons button ) {}
+ void setTool( ToolButtons button ) { Q_UNUSED( button ) }
protected:
- virtual void changeEvent( QEvent *e ) {}
+ virtual void changeEvent( QEvent *e ) { Q_UNUSED( e ) }
private:
static Timeline* m_instance;
+ QQuickView* m_view;
+ QWidget* m_container;
};
#endif // TIMELINE_H
More information about the Vlmc-devel
mailing list