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