[vlmc-devel] commit: Settings: Add a flag to force the value to be a 8 multiple. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Mon Jul 26 22:15:18 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Jul 26 11:43:34 2010 +0200| [935c4bbaa950c3bd703da2799acc8fcaae61ecc0] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=935c4bbaa950c3bd703da2799acc8fcaae61ecc0
---

 src/Gui/settings/IntWidget.cpp   |    4 ++++
 src/Project/ProjectManager.cpp   |    4 ++--
 src/Settings/SettingValue.h      |   12 +++++++-----
 src/Settings/SettingsManager.cpp |    2 +-
 src/Settings/SettingsManager.h   |    2 +-
 5 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/Gui/settings/IntWidget.cpp b/src/Gui/settings/IntWidget.cpp
index 4792ab1..4a6a27a 100644
--- a/src/Gui/settings/IntWidget.cpp
+++ b/src/Gui/settings/IntWidget.cpp
@@ -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() );
 }
 
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index e0e9122..bed0c2e 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -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" ),
diff --git a/src/Settings/SettingValue.h b/src/Settings/SettingValue.h
index 8170504..97c4009 100644
--- a/src/Settings/SettingValue.h
+++ b/src/Settings/SettingValue.h
@@ -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
diff --git a/src/Settings/SettingsManager.cpp b/src/Settings/SettingsManager.cpp
index 5eddd18..6f955a2 100644
--- a/src/Settings/SettingsManager.cpp
+++ b/src/Settings/SettingsManager.cpp
@@ -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 );
 
diff --git a/src/Settings/SettingsManager.h b/src/Settings/SettingsManager.h
index b15f36f..3bbf1ee 100644
--- a/src/Settings/SettingsManager.h
+++ b/src/Settings/SettingsManager.h
@@ -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,



More information about the Vlmc-devel mailing list