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

Settings: Remove unnecessary layer to watch setting changes

parent ca7d6a8e
...@@ -31,10 +31,9 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QWidget* pa ...@@ -31,10 +31,9 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QWidget* pa
m_name( name ), m_name( name ),
m_action( NULL ) m_action( NULL )
{ {
QString set = VLMC_GET_STRING( name ); SettingValue* setting = Core::getInstance()->settings()->value( name );
setKey( QKeySequence( set ) ); setKey( QKeySequence( setting->get().toString() ) );
Core::getInstance()->settings()->watchValue( name, this, connect( setting, SIGNAL( changed( QVariant ) ), this, SLOT( shortcutUpdated( const QVariant& ) ) );
SLOT( shortcutUpdated( const QVariant& ) ) );
} }
KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QAction *action, KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QAction *action,
...@@ -43,10 +42,9 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QAction *ac ...@@ -43,10 +42,9 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QAction *ac
m_name( name ), m_name( name ),
m_action( action ) m_action( action )
{ {
QString set = VLMC_GET_STRING( name ); SettingValue* setting = Core::getInstance()->settings()->value( name );
action->setShortcut( set ); action->setShortcut( setting->get().toString() );
Core::getInstance()->settings()->watchValue( name, this, connect( setting, SIGNAL( changed( QVariant ) ), this, SLOT( shortcutUpdated( const QVariant& ) ) );
SLOT( shortcutUpdated( const QVariant& ) ) );
} }
void void
......
...@@ -251,13 +251,13 @@ MainWindow::initVlmcPreferences() ...@@ -251,13 +251,13 @@ MainWindow::initVlmcPreferences()
QT_TRANSLATE_NOOP( "PreferenceWidget", "Select the cut/razor tool in the timeline" ), actionCut_mode ); QT_TRANSLATE_NOOP( "PreferenceWidget", "Select the cut/razor tool in the timeline" ), actionCut_mode );
//Setup VLMC Lang. Preferences... //Setup VLMC Lang. Preferences...
VLMC_CREATE_PREFERENCE_LANGUAGE( "vlmc/VLMCLang", "default", SettingValue* lang = VLMC_CREATE_PREFERENCE_LANGUAGE( "vlmc/VLMCLang", "default",
QT_TRANSLATE_NOOP( "PreferenceWidget", "Language" ), QT_TRANSLATE_NOOP( "PreferenceWidget", "Language" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "The VLMC's UI language" ) ); QT_TRANSLATE_NOOP( "PreferenceWidget", "The VLMC's UI language" ) );
Core::getInstance()->settings()->watchValue( "vlmc/VLMCLang", connect( lang, SIGNAL( changed( QVariant ) ),
LanguageHelper::getInstance(), LanguageHelper::getInstance(), SLOT( languageChanged( const QVariant& ) ) );
SLOT( languageChanged( const QVariant& ) ) );
//Setup VLMC General Preferences... //Setup VLMC General Preferences...
VLMC_CREATE_PREFERENCE_BOOL( "vlmc/ConfirmDeletion", true, VLMC_CREATE_PREFERENCE_BOOL( "vlmc/ConfirmDeletion", true,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Confirm clip deletion"), QT_TRANSLATE_NOOP( "PreferenceWidget", "Confirm clip deletion"),
......
...@@ -31,18 +31,18 @@ AutomaticBackup::AutomaticBackup( Settings* vlmcSettings, QObject *parent ) ...@@ -31,18 +31,18 @@ AutomaticBackup::AutomaticBackup( Settings* vlmcSettings, QObject *parent )
, m_vlmcSettings( vlmcSettings ) , m_vlmcSettings( vlmcSettings )
{ {
m_timer = new QTimer( this ); m_timer = new QTimer( this );
m_vlmcSettings->createVar( SettingValue::Bool, "vlmc/AutomaticBackup", false, SettingValue* autoBackup = m_vlmcSettings->createVar( SettingValue::Bool, "vlmc/AutomaticBackup", false,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Automatic save" ), QT_TRANSLATE_NOOP( "PreferenceWidget", "Automatic save" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "When this option is activated," QT_TRANSLATE_NOOP( "PreferenceWidget", "When this option is activated,"
"VLMC will automatically save your project " "VLMC will automatically save your project "
"at a specified interval" ), SettingValue::Nothing ); "at a specified interval" ), SettingValue::Nothing );
m_vlmcSettings->createVar( SettingValue::Int, "vlmc/AutomaticBackupInterval", 5, SettingValue* interval = m_vlmcSettings->createVar( SettingValue::Int, "vlmc/AutomaticBackupInterval", 5,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Automatic save interval" ), QT_TRANSLATE_NOOP( "PreferenceWidget", "Automatic save interval" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "This is the interval that VLMC will wait " QT_TRANSLATE_NOOP( "PreferenceWidget", "This is the interval that VLMC will wait "
"between two automatic save" ), SettingValue::Nothing ); "between two automatic save" ), SettingValue::Nothing );
vlmcSettings->watchValue( "vlmc/AutomaticBackup", this, SLOT( automaticSaveEnabledChanged( QVariant ) ) ); connect( autoBackup, SIGNAL( changed( QVariant ) ), this, SLOT( automaticSaveEnabledChanged( QVariant ) ) );
vlmcSettings->watchValue( "vlmc/AutomaticBackupInterval", this, SLOT( automaticSaveIntervalChanged( QVariant ) ) ); connect( interval, SIGNAL( changed( QVariant ) ), this, SLOT( automaticSaveIntervalChanged( QVariant ) ) );
} }
AutomaticBackup::~AutomaticBackup() AutomaticBackup::~AutomaticBackup()
......
...@@ -307,11 +307,11 @@ Project::initSettings() ...@@ -307,11 +307,11 @@ Project::initSettings()
QT_TRANSLATE_NOOP("PreferenceWidget", "Number of audio channels" ), QT_TRANSLATE_NOOP("PreferenceWidget", "Number of audio channels" ),
SettingValue::Clamped ); SettingValue::Clamped );
audioChannel->setLimits( 2, 2 ); audioChannel->setLimits( 2, 2 );
m_settings->createVar( SettingValue::String, "vlmc/ProjectName", unNamedProject, SettingValue* pName = m_settings->createVar( SettingValue::String, "vlmc/ProjectName", unNamedProject,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Project name" ), QT_TRANSLATE_NOOP( "PreferenceWidget", "Project name" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "The project name" ), QT_TRANSLATE_NOOP( "PreferenceWidget", "The project name" ),
SettingValue::NotEmpty ); SettingValue::NotEmpty );
m_settings->watchValue( "vlmc/ProjectName", this, SLOT( projectNameChanged( QVariant ) ) ); connect( pName, SIGNAL( changed( QVariant ) ), this, SLOT( projectNameChanged( QVariant ) ) );
} }
QString QString
......
...@@ -33,11 +33,10 @@ RecentProjects::RecentProjects( Settings* vlmcSettings, QObject *parent ) ...@@ -33,11 +33,10 @@ RecentProjects::RecentProjects( Settings* vlmcSettings, QObject *parent )
, m_settings( vlmcSettings ) , m_settings( vlmcSettings )
, m_project( NULL ) , m_project( NULL )
{ {
vlmcSettings->createVar( SettingValue::String, "private/RecentsProjects", "", SettingValue* recentProjects = vlmcSettings->createVar( SettingValue::String, "private/RecentsProjects", "",
"", "", SettingValue::Private ); "", "", SettingValue::Private );
vlmcSettings->watchValue( "private/RecentsProjects", connect( recentProjects, SIGNAL( changed( QVariant ) ), this, SLOT( loadRecentProjects( QVariant ) ) );
this, SLOT( loadRecentProjects( QVariant ) ) );
} }
void void
......
...@@ -47,20 +47,6 @@ Settings::~Settings() ...@@ -47,20 +47,6 @@ Settings::~Settings()
delete m_settingsFile; delete m_settingsFile;
} }
bool
Settings::watchValue( const QString &key, QObject* receiver, const char *method, Qt::ConnectionType cType )
{
SettingValue* s = value( key );
if ( s != NULL )
{
QObject::connect( s, SIGNAL( changed( const QVariant& ) ),
receiver, method , cType );
return true;
}
Q_ASSERT_X( false, __FILE__, "watching value without a created variable" );
return false;
}
void void
Settings::setSettingsFile(const QString &settingsFile) Settings::setSettingsFile(const QString &settingsFile)
{ {
......
...@@ -124,7 +124,6 @@ class Settings : public ILoadSave ...@@ -124,7 +124,6 @@ class Settings : public ILoadSave
bool load(); bool load();
bool save(); bool save();
bool save( QXmlStreamWriter& project ); bool save( QXmlStreamWriter& project );
bool watchValue( const QString &key, QObject* receiver, const char *method, Qt::ConnectionType cType = Qt::AutoConnection );
void setSettingsFile( const QString& settingsFile ); void setSettingsFile( const QString& settingsFile );
private: private:
......
...@@ -46,13 +46,9 @@ void ...@@ -46,13 +46,9 @@ void
VlmcLogger::setup() VlmcLogger::setup()
{ {
//setup log level : //setup log level :
{ SettingValue* logLevel = VLMC_CREATE_PREFERENCE( SettingValue::Int, "private/LogLevel", (int)VlmcLogger::Quiet,
SettingValue* logLevel = VLMC_CREATE_PREFERENCE( SettingValue::Int, "private/LogLevel", (int)VlmcLogger::Quiet, "", "", SettingValue::Private | SettingValue::Clamped | SettingValue::Runtime );
"", "", SettingValue::Private | SettingValue::Clamped | SettingValue::Runtime ); logLevel->setLimits((int)Debug, (int)Verbose);
logLevel->setLimits((int)Debug, (int)Verbose);
// Purposedly destroying the setting value, as we need to use the manager for other operations.
//FIXME: Actually I'm not sure for setting the value since this is a private variable.
}
QStringList args = qApp->arguments(); QStringList args = qApp->arguments();
if ( args.indexOf( QRegExp( "-vv+" ) ) >= 0 ) if ( args.indexOf( QRegExp( "-vv+" ) ) >= 0 )
m_currentLogLevel = VlmcLogger::Debug; m_currentLogLevel = VlmcLogger::Debug;
...@@ -60,9 +56,8 @@ VlmcLogger::setup() ...@@ -60,9 +56,8 @@ VlmcLogger::setup()
m_currentLogLevel = VlmcLogger::Verbose; m_currentLogLevel = VlmcLogger::Verbose;
else else
m_currentLogLevel = VlmcLogger::Quiet; m_currentLogLevel = VlmcLogger::Quiet;
Settings* settings = Core::getInstance()->settings(); logLevel->set( m_currentLogLevel );
settings->setValue( "private/LogLevel", m_currentLogLevel ); connect( logLevel, SIGNAL( changed(QVariant) ), this, SLOT( logLevelChanged( QVariant ) ) );
settings->watchValue( "private/LogLevel", this, SLOT(logLevelChanged( const QVariant& )), Qt::DirectConnection );
int pos = args.indexOf( QRegExp( "--logfile=.*" ) ); int pos = args.indexOf( QRegExp( "--logfile=.*" ) );
if ( pos > 0 ) if ( pos > 0 )
......
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