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

Merge branch 'master' into effect-engine

Conflicts:
	src/Project/ProjectManager.cpp
parents f1faa9d9 646b43c4
......@@ -32,6 +32,13 @@ DoubleWidget::DoubleWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
changed( s->get() );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
if ( ( s->flags() & SettingValue::Clamped ) != 0 )
{
if ( s->min().isValid() )
m_spinbox->setMinimum( s->min().toDouble() );
if ( s->max().isValid() )
m_spinbox->setMaximum( s->max().toDouble() );
}
}
QWidget*
......
......@@ -31,6 +31,17 @@ IntWidget::IntWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_spinbox = new QSpinBox( parent );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
if ( ( s->flags() & SettingValue::Clamped ) != 0 )
{
if ( s->min().isValid() )
m_spinbox->setMinimum( s->min().toInt() );
if ( s->max().isValid() )
m_spinbox->setMaximum( s->max().toInt() );
}
if ( ( s->flags() & SettingValue::EightMultiple ) != 0 )
{
m_spinbox->setSingleStep( 8 );
}
changed( s->get() );
}
......
......@@ -49,12 +49,16 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
VLMC_CREATE_PROJECT_DOUBLE( "video/VLMCOutputFPS", 29.97,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Output video FPS" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Frame Per Second used when previewing and rendering the project" ) );
VLMC_CREATE_PROJECT_INT( "video/VideoProjectWidth", 480,
SettingValue *width = VLMC_CREATE_PROJECT_VAR( SettingValue::Int, "video/VideoProjectWidth", 480,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Video width" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Width resolution of the output video" ) );
VLMC_CREATE_PROJECT_INT( "video/VideoProjectHeight", 320,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Width resolution of the output video" ),
SettingValue::Flags( SettingValue::Clamped | SettingValue::EightMultiple ) );
width->setLimits( 0, 2048 );
SettingValue *height = VLMC_CREATE_PROJECT_VAR( SettingValue::Int, "video/VideoProjectHeight", 320,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Video height" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Height resolution of the output video" ) );
QT_TRANSLATE_NOOP( "PreferenceWidget", "Height resolution of the output video" ),
SettingValue::Flag( SettingValue::Clamped | SettingValue::EightMultiple ) );
height->setLimits( 0, 2048 );
VLMC_CREATE_PROJECT_INT( "audio/AudioSampleRate", 0,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Audio samplerate" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Output project audio samplerate" ) );
......
......@@ -35,10 +35,20 @@ SettingValue::SettingValue( SettingValue::Type type, const QVariant& defaultValu
}
void
SettingValue::set( const QVariant& val )
SettingValue::set( const QVariant& _val )
{
QVariant val = _val;
if ( val != m_val )
{
if ( ( m_flags & Clamped ) != 0 )
{
if ( m_min.isValid() && val.toDouble() < m_min.toDouble() )
val = m_min;
if ( m_max.isValid() && val.toDouble() > m_max.toDouble() )
val = m_max;
}
if ( ( m_flags & EightMultiple ) != 0 )
val = ( val.toInt() + 7 ) & ~7;
m_val = val;
emit changed( m_val );
}
......@@ -79,3 +89,24 @@ SettingValue::flags() const
{
return m_flags;
}
void
SettingValue::setLimits( const QVariant& min, const QVariant& max )
{
if ( min.isValid() == true )
m_min = min;
if ( max.isValid() == true )
m_max = max;
}
const QVariant&
SettingValue::min() const
{
return m_min;
}
const QVariant&
SettingValue::max() const
{
return m_max;
}
......@@ -47,13 +47,16 @@ class SettingValue : public QObject
KeyboardShortcut,
Path,
};
enum Flags
enum Flag
{
Nothing = 0,
Nothing = 0,
/// If this flag is used, then the variable should not be shown in the config widgets.
Private = 1 << 0,
Password = 1 << 1,
Private = 1 << 0,
Password = 1 << 1,
Clamped = 1 << 2, ///< When used, the m_min and m_max will be used
EightMultiple = 1 << 3, ///< Forces the value to be a multiple of 8
};
Q_DECLARE_FLAGS( Flags, Flag );
/**
* \brief Constructs a setting value with its default value and description
......@@ -88,6 +91,10 @@ class SettingValue : public QObject
Type type() const;
Flags flags() const;
void setLimits( const QVariant& min, const QVariant& max );
const QVariant& min() const;
const QVariant& max() const;
private:
/**
* \brief the QVariant containingthe value of the settings
......@@ -98,6 +105,8 @@ class SettingValue : public QObject
const char* m_desc;
Type m_type;
Flags m_flags;
QVariant m_min;
QVariant m_max;
signals:
/**
* \brief This signal is emmited while the m_val
......
......@@ -227,20 +227,28 @@ SettingsManager::load( const QDomElement &root )
return true;
}
void
SettingValue*
SettingsManager::createVar( SettingValue::Type type, const QString &key,
const QVariant &defaultValue, const char *name,
const char *desc, SettingsManager::Type varType /*= Vlmc*/,
SettingValue::Flags flags /*= SettingValue::Nothing*/ )
QFlags<SettingValue::Flag> flags /*= SettingValue::Nothing*/ )
{
QWriteLocker wlock( &m_rwLock );
SettingValue *val = NULL;
if ( varType == Vlmc && getPair( m_classicSettings, key ) == m_classicSettings.end() )
m_classicSettings.push_back( Pair( key, new SettingValue( type, defaultValue, name, desc, flags ) ) );
{
val = new SettingValue( type, defaultValue, name, desc, flags );
m_classicSettings.push_back( Pair( key, val ) );
}
else if ( varType == Project && getPair( m_xmlSettings, key ) == m_xmlSettings.end() )
m_xmlSettings.push_back( Pair( key, new SettingValue( type, defaultValue, name, desc, flags ) ) );
{
val = new SettingValue( type, defaultValue, name, desc, flags );
m_xmlSettings.push_back( Pair( key, val ) );
}
else
Q_ASSERT_X( false, __FILE__, "creating an already created variable" );
return val;
}
SettingsManager::Pair::Pair( const QString &_key, SettingValue *_value ) :
......
......@@ -125,11 +125,11 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
SettingList group( const QString &groupName,
SettingsManager::Type type = Vlmc );
void createVar( SettingValue::Type type, const QString &key,
SettingValue *createVar( SettingValue::Type type, const QString &key,
const QVariant &defaultValue,
const char *name, const char *desc,
Type varType = Vlmc,
SettingValue::Flags flags = SettingValue::Nothing );
QFlags<SettingValue::Flag> flags = SettingValue::Nothing );
bool watchValue( const QString &key,
QObject* receiver,
const char *method,
......
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