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

Use a Qml view to display the media library

/!\ WIP /!\
parent 1fcdb6a9
......@@ -298,7 +298,6 @@ nodist_vlmc_SOURCES += \
src/Gui/widgets/FramelessButton.moc.cpp \
src/Gui/wizard/OpenPage.moc.cpp \
src/Gui/settings/ColorWidget.moc.cpp \
src/Gui/library/MediaLibraryView.moc.cpp \
src/Gui/wizard/firstlaunch/FirstLaunchPage.moc.cpp \
src/Gui/settings/Panel.moc.cpp \
src/Gui/preview/RenderWidget.moc.cpp \
......@@ -350,7 +349,6 @@ vlmc_UI = \
src/Gui/ui/RendererSettings.ui \
src/Gui/ui/ShareOnInternet.ui \
src/Gui/ui/TagWidget.ui \
src/Gui/ui/MediaLibraryView.ui \
src/Gui/ui/FolderListWidget.ui \
src/Gui/ui/ClipMetadataDisplayer.ui \
src/Gui/ui/PreviewWidget.ui \
......
......@@ -57,4 +57,7 @@
<file>THANKS</file>
<file>TRANSLATORS</file>
</qresource>
<qresource prefix="/qml">
<file alias="MediaLibraryView">src/Gui/library/ui/MediaLibraryView.qml</file>
</qresource>
</RCC>
......@@ -26,40 +26,31 @@
#include "MediaLibraryView.h"
#include "Project/Project.h"
#include "Media/Clip.h"
#include "Library/Library.h"
#include "Library/MediaLibrary.h"
#include "Library/MediaLibraryModel.h"
#include "Main/Core.h"
#include "Media/Media.h"
#include "MediaCellView.h"
#include "ViewController.h"
#include "Tools/VlmcDebug.h"
#include <QBoxLayout>
#include <QListView>
#include <QtQuick/QQuickView>
#include <QQmlContext>
#include <QUrl>
#include <QMimeData>
MediaLibraryView::MediaLibraryView(QWidget *parent) : QWidget(parent),
m_ui( new Ui::MediaLibraryView() )
MediaLibraryView::MediaLibraryView(QWidget *parent)
: QWidget(parent)
{
m_ui->setupUi( this );
}
setObjectName( QStringLiteral( "medialibrary" ) );
auto view = new QQuickView;
auto container = QWidget::createWindowContainer( view, this );
auto layout = new QBoxLayout( QBoxLayout::TopToBottom, this );
layout->addWidget( container );
MediaLibraryView::~MediaLibraryView()
{
delete m_ui;
view->setSource( QUrl( "qrc:/qml/MediaLibraryView" ) );
view->setResizeMode(QQuickView::SizeRootObjectToView);
auto ctx = view->rootContext();
ctx->setContextProperty( "mlModel", Core::instance()->mediaLibrary()->model( MediaLibrary::MediaType::Video ) );
}
void
MediaLibraryView::changeEvent( QEvent *e )
MediaLibraryView::~MediaLibraryView()
{
QWidget::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
}
}
......@@ -25,25 +25,13 @@
#include <QWidget>
#include "ui/MediaLibraryView.h"
class Clip;
class MediaLibraryView : public QWidget
{
Q_OBJECT
Q_DISABLE_COPY( MediaLibraryView )
public:
typedef bool (*Filter)( const Clip*, const QString& filter );
explicit MediaLibraryView( QWidget *parent = 0);
virtual ~MediaLibraryView();
protected:
void changeEvent( QEvent *e );
private:
Ui::MediaLibraryView *m_ui;
};
#endif // MEDIALIBRARYVIEW_H
import QtQuick 2.0
import QtQuick.Controls 1.4
ScrollView {
Component {
id: itemDelegate
Item {
id: mediaItem
width: gridView.cellWidth - gridView.spacing
height: gridView.cellHeight - gridView.spacing
Column {
Image {
id: thumbnail
source: thumbnailPath.length > 0 ? "file://" + thumbnailPath : "qrc:///images/vlmc"
fillMode: Image.PreserveAspectFit
width: mediaItem.width
height: mediaItem.height - 20
}
Row {
width: mediaItem.width
Text {
id: mediaTitle
text: title
fontSizeMode: Text.HorizontalFit
minimumPixelSize: 4
width: mediaItem.width - durationLabel.width
elide: Text.ElideRight
}
Text {
function toDuration( seconds ) {
if ( seconds <= 0 )
return "00:00:00";
var hours = Math.floor(seconds / 3600);
seconds = seconds % 3600;
var minutes = Math.floor( seconds / 60 );
seconds = Math.floor( seconds % 60 );
if (hours < 10) {hours = "0" + hours;}
if (minutes < 10) {minutes = "0" + minutes;}
if (seconds < 10) {seconds = "0" + seconds;}
return hours + ':' + minutes + ':' + seconds;
}
id: durationLabel
text: toDuration( duration / 1000 )
}
}
}
Drag.active: dragArea.drag.active
Drag.dragType: Drag.Automatic
Drag.mimeData: {
"vlmc/uuid":"test",
}
MouseArea {
id: dragArea
drag.target: mediaItem
anchors.fill: parent
anchors.centerIn: parent
onClicked: gridView.currentIndex = index
}
}
}
GridView {
id: gridView
model: mlModel
anchors.fill: parent
property int spacing: 10
cellWidth: 200 + spacing
cellHeight: 180 + spacing
delegate: itemDelegate
highlight: Rectangle {
color: "lightsteelblue"
radius: 5
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MediaLibraryView</class>
<widget class="QWidget" name="MediaLibraryView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>280</width>
<height>219</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>280</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="SearchLineEdit" name="filterInput"/>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="filterType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Name</string>
</property>
</item>
<item>
<property name="text">
<string>Tags</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="mediaListContainer" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SearchLineEdit</class>
<extends>QLineEdit</extends>
<header>Gui/widgets/SearchLineEdit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
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