Commit 596d1fb5 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Merge branch 'master' into boubak-effects-engine

Conflicts:
	src/Media/Media.cpp
	src/Media/Media.h
	src/Renderer/ClipRenderer.cpp
	src/Workflow/ClipWorkflow.cpp
	src/Workflow/ClipWorkflow.h
	src/Workflow/MainWorkflow.cpp
	src/Workflow/MainWorkflow.h
	src/Workflow/TrackWorkflow.cpp
	vlmc.pro
parents d7821959 d2458e86
/*****************************************************************************
* SettingsManager.cpp * : Backend settings manager
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <kinder@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QHash>
#include "SettingsManager.h"
int SettingsManager::createNewSettings()
{
this->m_settings.append(new SettingsContainer());
return this->m_settings.size() - 1;
}
SettingsManager::SettingsManager( QObject* parent )
: QObject( parent )
{
}
SettingsManager::~SettingsManager()
{
}
void SettingsManager::saveSettings( QDomDocument& xmlfile, int index )
{
Q_UNUSED( xmlfile )
SettingsContainer* settings = m_settings[index];
settings->lock.lockForRead();
//SAVE SETTINGS TO DomDocument
settings->lock.unlock();
}
/*****************************************************************************
* SettingsManager.h: Backend settings manager
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <kinder@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H
#include <QObject>
#include <QVector>
#include <QHash>
#include <QReadWriteLock>
#include <QString>
#include <QVariant>
#include <QDomDocument>
#include "QSingleton.hpp"
struct SettingsContainer
{
QReadWriteLock lock;
QHash<QString, QVariant> settings;
};
class SettingsManager : public QObject, public QSingleton<SettingsManager>
{
//Q_OBJECT
//
friend class QSingleton<SettingsManager>;
public:
int createNewSettings();
void setValues( QHash<QString, QVariant>, int index );
void setValue( const QString& key, QVariant& value, int index );
QVariant& getValue( const QString& key );
private:
SettingsManager( QObject* parent = 0 );
~SettingsManager();
QVector<SettingsContainer*> m_settings;
public slots:
void saveSettings( QDomDocument& xmlfile, int index );
};
#endif
......@@ -24,23 +24,21 @@
#include "QDebug"
AudioProjectPreferences::AudioProjectPreferences( QWidget *parent )
: PreferenceWidget( parent )
AudioProjectPreferences::AudioProjectPreferences( QWidget *parent )
: PreferenceWidget( parent )
{
m_ui.setupUi( this );
m_ui.setupUi( this );
}
AudioProjectPreferences::~AudioProjectPreferences() { }
bool AudioProjectPreferences::load()
{
qDebug() << "Loading AudioProjectPreferences values";
return true;
qDebug() << "Loading AudioProjectPreferences values";
return true;
}
void AudioProjectPreferences::save( QSettings& settings )
void AudioProjectPreferences::save( QHash<QString, QVariant>& settings )
{
settings.beginGroup( "Project" );
//settings.setValue( "outputFPS", m_ui.outputFPS->text() );
settings.endGroup();
settings.insert( "AudioSampleRate", m_ui.SampleRate->value() );
}
......@@ -35,7 +35,7 @@ class AudioProjectPreferences : public PreferenceWidget
AudioProjectPreferences( QWidget *parent = 0 );
~AudioProjectPreferences();
bool load();
void save( QSettings& settings );
void save( QHash<QString, QVariant>& settings );
private:
Ui::AudioProjectPreferences m_ui;
};
......
......@@ -25,6 +25,7 @@
#include <QGraphicsWidget>
#include <QPainter>
#include <QDebug>
class GraphicsTrack : public QGraphicsWidget
{
......@@ -70,18 +71,31 @@ public:
protected:
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* = 0 )
{
Q_UNUSED( painter );
/*
Debugging of tracks.
Do not remove this block.
if ( m_type == Video )
painter->setBrush( Qt::green );
else
painter->setBrush( Qt::blue );
painter->setPen( Qt::transparent );
painter->drawRect( rect() );
*/
painter->setMatrixEnabled( false );
if ( m_trackNumber == 0 )
{
QString text;
switch ( m_type )
{
case Video:
text = tr( "Video" );
break;
case Audio:
text = tr( "Audio" );
break;
}
QRectF mapped = mapRectToScene( boundingRect() ).adjusted( 10, 1, 0, 0 );
QFont textFont;
textFont.setItalic( true );
textFont.setBold( true );
textFont.setPixelSize( mapped.height() + 12 );
painter->setPen( QPen( palette().window().color().lighter( 125 ) ) );
painter->setFont( textFont );
painter->drawText( mapped, Qt::AlignVCenter, text );
}
}
private:
......
......@@ -24,8 +24,11 @@
#ifndef PREFERENCEWIDGET_H
#define PREFERENCEWIDGET_H
#include <QSettings>
#include <QHash>
#include <QVariant>
#include <QString>
#include <QWidget>
#include <QVariant>
class PreferenceWidget : public QWidget
{
......@@ -34,7 +37,7 @@ class PreferenceWidget : public QWidget
virtual ~PreferenceWidget() {}
virtual bool load() = 0;
virtual void save( QSettings& settings ) = 0;
virtual void save( QHash<QString, QVariant>& settings ) = 0;
};
#endif
......@@ -96,11 +96,6 @@ void PreviewWidget::seekSliderPressed()
void PreviewWidget::seekSliderMoved( int )
{
if ( m_renderer->isRendering() == false )
{
m_ui->seekSlider->setValue( 0 );
return ;
}
if ( m_ui->seekSlider->value() == m_ui->seekSlider->maximum() )
{
m_endReached = true;
......
......@@ -29,23 +29,22 @@
#include "PreferenceWidget.h"
ProjectPreferences::ProjectPreferences( QWidget* parent )
: PreferenceWidget( parent )
ProjectPreferences::ProjectPreferences( QWidget* parent )
: PreferenceWidget( parent )
{
m_ui.setupUi( this );
m_ui.setupUi( this );
}
ProjectPreferences::~ProjectPreferences() { }
bool ProjectPreferences::load()
{
qDebug() << "Loading ProjectPreferences values";
return true;
qDebug() << "Loading ProjectPreferences values";
return true;
}
void ProjectPreferences::save( QSettings& settings )
void ProjectPreferences::save( QHash<QString, QVariant>& settings )
{
settings.beginGroup( "Project" );
//settings.setValue( "outputFPS", m_ui.outputFPS->text() );
settings.endGroup();
settings.insert( "ProjectName", QVariant( m_ui.ProjectNameLineEdit->text() ) );
settings.insert( "ProjectDirectory", QVariant( m_ui.ProjectDirectoryLineEdit->text() ) );
}
......@@ -36,7 +36,7 @@ class ProjectPreferences : public PreferenceWidget
ProjectPreferences( QWidget* parent = 0 );
virtual ~ProjectPreferences();
bool load();
void save( QSettings& settings );
void save( QHash<QString, QVariant>& settings );
private:
Ui::ProjectPreferences m_ui;
};
......
......@@ -29,8 +29,10 @@
#include <QIcon>
#include <QLabel>
#include <QtDebug>
#include <QVariant>
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "Settings.h"
#include "Panel.h"
......@@ -41,10 +43,14 @@ Settings::Settings( QWidget* parent, Qt::WindowFlags f )
{
m_panel = new Panel( this );
m_stackedWidgets = new QStackedWidget( this );
connect( m_panel, SIGNAL( changePanel( int ) ),
connect( m_panel,
SIGNAL( changePanel( int ) ),
SLOT( switchWidget( int ) ) );
QObject::connect( this, SIGNAL( widgetSwitched( int ) ),
m_stackedWidgets, SLOT( setCurrentIndex( int ) ));
QObject::connect( this,
SIGNAL( widgetSwitched( int ) ),
m_stackedWidgets,
SLOT( setCurrentIndex( int ) ));
m_settingsNumber = SettingsManager::getInstance()->createNewSettings();
}
Settings::~Settings()
......@@ -63,6 +69,7 @@ void Settings::addWidget( const QString& name,
int idx = m_stackedWidgets->indexOf( pWidget );
m_widgets.insert( idx, name );
m_pWidgets.push_back( pWidget );
m_panel->addButton( label, icon, idx );
if ( !m_currentWidget )
m_currentWidget = pWidget;
......@@ -119,20 +126,38 @@ void Settings::save( void )
void Settings::buttonClicked( QAbstractButton* button )
{
bool save = false;
bool hide = false ;
switch ( m_buttons->standardButton( button ) )
{
case QDialogButtonBox::Ok :
qDebug() << "MOK";
save = true;
hide = true;
break;
case QDialogButtonBox::Cancel :
qDebug() << "Oh NOES";
hide = true;
break;
case QDialogButtonBox::Apply :
qDebug() << "Apply";
save = true;
break;
default :
break;
}
if ( save == true )
{
qDebug() << "Saving Preferences";
//Save Settings
QHash<QString, QVariant> sett;
PreferenceWidget* widg;
foreach( widg, m_pWidgets )
widg->save( sett );
qDebug() << sett;
}
if ( hide == true )
{
setVisible( false );
}
}
void Settings::switchWidget( int widget )
......
......@@ -65,6 +65,8 @@ class Settings : public QDialog
QDialogButtonBox* m_buttons;
bool m_saved;
int m_settingsNumber;
public slots:
void switchWidget( int widget );
......
......@@ -96,6 +96,11 @@ void TracksView::createLayout()
addAudioTrack();
m_scene->addItem( container );
// Hack: make sure the tracks type appears correctly
m_layout->setMinimumWidth( 2000 );
m_layout->setMaximumWidth( 2000 );
setSceneRect( m_layout->contentsRect() );
}
void TracksView::addVideoTrack()
......@@ -455,15 +460,18 @@ void TracksView::drawBackground( QPainter* painter, const QRectF& rect )
{
// Draw the tracks separators
painter->setPen( QPen( QColor( 72, 72, 72 ) ) );
QList<QGraphicsItem*> gi = items( 0, 0, 1, sceneRect().height() );
for ( int i = 0; i < gi.count(); ++i )
for ( int i = 0; i < m_layout->count(); ++i )
{
GraphicsTrack* track = qgraphicsitem_cast<GraphicsTrack*>( gi.at( i ) );
QGraphicsItem* gi = m_layout->itemAt( i )->graphicsItem();
if ( !gi ) continue;
GraphicsTrack* track = qgraphicsitem_cast<GraphicsTrack*>( gi );
if ( !track ) continue;
if ( track->trackNumber() == 0 ) continue;
QRectF trackRect = track->mapRectToScene( track->boundingRect() );
painter->drawLine( trackRect.left(), trackRect.bottom(), rect.right(), trackRect.bottom() );
if ( track->type() == GraphicsTrack::Video )
painter->drawLine( trackRect.left(), trackRect.top(), rect.right(), trackRect.top() );
else
painter->drawLine( trackRect.left(), trackRect.bottom(), rect.right(), trackRect.bottom() );
}
// Audio/Video separator
......@@ -671,9 +679,14 @@ void TracksView::updateDuration()
m_projectDuration = projectDuration;
// Hack: make sure the tracks type appears correctly
int minimumWidth = qMax( m_projectDuration, 2000 );
// PreferredWidth not working ?
m_layout->setMinimumWidth( m_projectDuration );
m_layout->setMaximumWidth( m_projectDuration );
m_layout->setMinimumWidth( minimumWidth );
m_layout->setMaximumWidth( minimumWidth );
setSceneRect( m_layout->contentsRect() );
setSceneRect( m_layout->contentsRect() );
......
......@@ -38,9 +38,9 @@ bool VLMCPreferences::load()
return true;
}
void VLMCPreferences::save( QSettings& settings )
void VLMCPreferences::save( QHash<QString, QVariant>& settings )
{
settings.beginGroup( "Project" );
//settings.setValue( "outputFPS", m_ui.outputFPS->text() );
settings.endGroup();
settings.insert( "VLMCOutPutFPS", QVariant( m_ui.outputFPS->text() ) );
settings.insert( "VLMCPreviewFPS", QVariant( m_ui.previewFPS->text() ) );
settings.insert( "VLMCTracksNb", QVariant( m_ui.tracksNb->text() ) );
}
......@@ -35,7 +35,7 @@ class VLMCPreferences : public PreferenceWidget
VLMCPreferences( QWidget *parent = 0 );
~VLMCPreferences();
bool load();
void save( QSettings& settings );
void save( QHash<QString, QVariant>& settings );
private:
Ui::VLMCPreferences m_ui;
};
......
......@@ -25,22 +25,22 @@
#include "QDebug"
VideoProjectPreferences::VideoProjectPreferences( QWidget *parent )
: PreferenceWidget( parent )
: PreferenceWidget( parent )
{
m_ui.setupUi( this );
m_ui.setupUi( this );
}
VideoProjectPreferences::~VideoProjectPreferences() { }
bool VideoProjectPreferences::load()
{
qDebug() << "Loading VideoProjectPreferences values";
return true;
qDebug() << "Loading VideoProjectPreferences values";
return true;
}
void VideoProjectPreferences::save( QSettings& settings )
void VideoProjectPreferences::save( QHash<QString, QVariant>& settings )
{
settings.beginGroup( "Project" );
//settings.setValue( "outputFPS", m_ui.outputFPS->text() );
settings.endGroup();
settings.insert( "VideoProjectFPS", QVariant( m_ui.FPSSpinBox->value() ) );
settings.insert( "VideoProjectHeight", QVariant( m_ui.HeightSpinBox->value() ) );
settings.insert( "VideoProjectWidth", QVariant( m_ui.WidthSpinBox->value() ));
}
......@@ -35,7 +35,7 @@ class VideoProjectPreferences : public PreferenceWidget
VideoProjectPreferences( QWidget *parent = 0 );
~VideoProjectPreferences();
bool load();
void save( QSettings& settings );
void save( QHash<QString, QVariant>& settings );
private:
Ui::VideoProjectPreferences m_ui;
};
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>200</width>
<height>33</height>
<height>46</height>
</rect>
</property>
<property name="windowTitle">
......@@ -22,7 +22,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox"/>
<widget class="QSpinBox" name="SampleRate"/>
</item>
</layout>
</widget>
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>374</width>
<width>387</width>
<height>193</height>
</rect>
</property>
......@@ -29,7 +29,7 @@
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="HeightSpinBox_2">
<widget class="QSpinBox" name="HeightSpinBox">
<property name="suffix">
<string> Pixels</string>
</property>
......@@ -52,7 +52,7 @@
</widget>
</item>
<item row="1" column="4">
<widget class="QSpinBox" name="WidthSpinBox_2">
<widget class="QSpinBox" name="WidthSpinBox">
<property name="suffix">
<string> Pixels</string>
</property>
......
......@@ -133,6 +133,8 @@ bool Clip::matchMetaTag( const QString& tag ) const
{
if ( tag.length() == 0 )
return true;
if ( m_parent->matchMetaTag( tag ) == true )
return true;
QString metaTag;
foreach ( metaTag, m_metaTags )
{
......@@ -140,7 +142,6 @@ bool Clip::matchMetaTag( const QString& tag ) const
return true;
}
return false;
// m_metaTags.contains( tag, Qt::CaseInsensitive );
}
const QString& Clip::getNotes() const
......
......@@ -253,3 +253,26 @@ const QString& Media::getFileName() const
{
return m_fileName;
}
const QStringList& Media::getMetaTags() const
{
return m_metaTags;
}
void Media::setMetaTags( const QStringList& tags )
{
m_metaTags = tags;
}
bool Media::matchMetaTag( const QString& tag ) const
{
if ( tag.length() == 0 )
return true;
QString metaTag;
foreach ( metaTag, m_metaTags )
{
if ( metaTag.startsWith( tag, Qt::CaseInsensitive ) == true )
return true;
}
return false;
}
......@@ -137,6 +137,10 @@ public:
QVector<int*> getAudioFrameList() { return m_audioData.frameList; }
unsigned int getAudioNbSample() { return m_audioData.nbSample; }
const QStringList& getMetaTags() const;
void setMetaTags( const QStringList& tags );
bool matchMetaTag( const QString& tag ) const;
void emitMetaDataComputed();
private:
......@@ -161,6 +165,7 @@ protected:
FileType m_fileType;
InputType m_inputType;
QString m_fileName;
QStringList m_metaTags;
signals:
void metaDataComputed();
......
......@@ -29,7 +29,9 @@ ClipRenderer::ClipRenderer() :
GenericRenderer(),
m_clipLoaded( false ),
m_vlcMedia( NULL ),
m_selectedClip( NULL ),
m_selectedMedia( NULL ),