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

Settings: Add a flag to force the value to be a 8 multiple.

Also: QFlag is now used to store flags combination.
parent caf9c00b
......@@ -38,6 +38,10 @@ IntWidget::IntWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
if ( s->max().isValid() )
m_spinbox->setMaximum( s->max().toInt() );
}
if ( ( s->flags() & SettingValue::EightMultiple ) != 0 )
{
m_spinbox->setSingleStep( 8 );
}
changed( s->get() );
}
......
......@@ -52,12 +52,12 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
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" ),
SettingValue::Clamped );
SettingValue::Flags( SettingValue::Clamped | SettingValue::EightMultiple ) );
width->setLimits( 0, 2048 );
SettingValue *height = VLMC_CREATE_PROJECT_VAR( SettingValue::Int, "video/VideoProjectHeight", 300,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Video height" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Height resolution of the output video" ),
SettingValue::Clamped );
SettingValue::Flag( SettingValue::Clamped | SettingValue::EightMultiple ) );
height->setLimits( 0, 2048 );
VLMC_CREATE_PROJECT_INT( "audio/AudioSampleRate", 0,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Audio samplerate" ),
......
......@@ -47,14 +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,
Clamped = 1 << 2, ///< When used, the m_min and m_max will be used
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
......
......@@ -231,7 +231,7 @@ 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 );
......
......@@ -129,7 +129,7 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
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