Commit 5b091082 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Starting a settings refactor

parent 1711cd64
...@@ -9,9 +9,11 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QWidget* pa ...@@ -9,9 +9,11 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QWidget* pa
m_name( name ), m_name( name ),
m_menu( menu ) m_menu( menu )
{ {
QVariant set = SettingsManager::getInstance()->value( name );
if ( m_menu == false ) if ( m_menu == false )
setKey( QKeySequence( set.toString() ) ); {
QString set = VLMC_GET_STRING( name );
setKey( QKeySequence( set ) );
}
SettingsManager::getInstance()->watchValue( "keyboard/" + name, this, SettingsManager::getInstance()->watchValue( "keyboard/" + name, this,
SLOT( shortcutUpdated( const QVariant& ) ), SLOT( shortcutUpdated( const QVariant& ) ),
SettingsManager::Vlmc ); SettingsManager::Vlmc );
......
...@@ -23,11 +23,15 @@ ...@@ -23,11 +23,15 @@
#include "SettingValue.h" #include "SettingValue.h"
#include <QtDebug> #include <QtDebug>
SettingValue::SettingValue( const QVariant& val ) : m_val ( val ) SettingValue::SettingValue( const QVariant& defaultValue, const QString& desc ) :
m_val( defaultValue ),
m_defaultVal( defaultValue ),
m_desc( desc )
{ {
} }
void SettingValue::set( const QVariant& val ) void
SettingValue::set( const QVariant& val )
{ {
if ( val != m_val ) if ( val != m_val )
{ {
...@@ -36,7 +40,20 @@ void SettingValue::set( const QVariant& val ) ...@@ -36,7 +40,20 @@ void SettingValue::set( const QVariant& val )
} }
} }
const QVariant& SettingValue::get() const const QVariant&
SettingValue::get() const
{ {
return m_val; return m_val;
} }
const QString&
SettingValue::description() const
{
return m_desc;
}
void
SettingValue::restoreDefault()
{
set( m_defaultVal );
}
...@@ -32,13 +32,18 @@ ...@@ -32,13 +32,18 @@
* \brief represent a setting value * \brief represent a setting value
* *
*/ */
class SettingValue : public QObject class SettingValue : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY( SettingValue ); Q_DISABLE_COPY( SettingValue );
public: public:
SettingValue( const QVariant& val ); /**
* \brief Constructs a setting value with its default value and description
*
* \param defaultValue The setting default value.
* \param desc The setting description
*/
SettingValue( const QVariant& defaultValue, const QString& desc );
/** /**
* \brief setter for the m_val member * \brief setter for the m_val member
...@@ -50,13 +55,22 @@ class SettingValue : public QObject ...@@ -50,13 +55,22 @@ class SettingValue : public QObject
/** /**
* \brief getter for the m_val member * \brief getter for the m_val member
*/ */
const QVariant& get() const; const QVariant& get() const;
/**
* \return The setting's description
*/
const QString &description() const;
/**
* \brief Set the setting to its default value.
*/
void restoreDefault();
private: private:
/** /**
* \brief the QVariant containingthe value of the settings * \brief the QVariant containingthe value of the settings
*/ */
QVariant m_val; QVariant m_val;
QVariant m_defaultVal;
QString m_desc;
signals: signals:
/** /**
* \brief This signal is emmited while the m_val * \brief This signal is emmited while the m_val
......
...@@ -39,10 +39,11 @@ SettingsManager::setValue( const QString &key, ...@@ -39,10 +39,11 @@ SettingsManager::setValue( const QString &key,
const QVariant &value, const QVariant &value,
SettingsManager::Type type ) SettingsManager::Type type )
{ {
if ( type == Project ) if ( type == Project && m_xmlSettings.contains( key ) == true )
m_tmpXmlSettings.insert( key, new SettingValue( value ) ); m_xmlSettings[key]->set( value );
else if ( type == Vlmc ) else if ( type == Vlmc && m_classicSettings.contains( key) == true )
m_tmpClassicSettings.insert( key, new SettingValue( value ) ); m_classicSettings[key]->set( value );
qWarning() << "Setting" << key << "does not exist.";
return ; return ;
} }
...@@ -66,15 +67,11 @@ SettingsManager::setImmediateValue( const QString &key, ...@@ -66,15 +67,11 @@ SettingsManager::setImmediateValue( const QString &key,
{ {
settMap->value( key )->set( value ); settMap->value( key )->set( value );
} }
else qWarning() << "Setting" << key << "does not exist.";
{
settMap->insert( key, new SettingValue( value ) );
}
return ; return ;
} }
QVariant SettingValue*
SettingsManager::value( const QString &key, SettingsManager::value( const QString &key,
const QVariant &defaultValue, const QVariant &defaultValue,
SettingsManager::Type type ) SettingsManager::Type type )
...@@ -84,34 +81,22 @@ SettingsManager::value( const QString &key, ...@@ -84,34 +81,22 @@ SettingsManager::value( const QString &key,
if ( type == Project ) if ( type == Project )
{ {
if ( m_xmlSettings.contains( key ) ) if ( m_xmlSettings.contains( key ) )
return m_xmlSettings.value( key )->get(); return m_xmlSettings.value( key );
else
{
m_xmlSettings.insert( key, new SettingValue( defaultValue ) );
return defaultValue;
}
} }
else else
{ {
if ( m_classicSettings.contains( key ) ) if ( m_classicSettings.contains( key ) )
return m_classicSettings.value( key )->get(); return m_classicSettings.value( key );
else
{
QSettings sett;
QVariant val = sett.value( key, defaultValue );
if ( val != defaultValue )
m_classicSettings.insert( key, new SettingValue( val ) );
return val;
}
} }
qWarning() << "Setting" << key << "does not exist.";
return NULL;
} }
QHash<QString, QVariant> QHash<QString, QVariant>
SettingsManager::group( const QString &groupName, SettingsManager::Type type ) SettingsManager::group( const QString &groupName, SettingsManager::Type type )
{ {
QHash<QString, QVariant> ret; QHash<QString, QVariant> ret;
QReadLocker rl( &m_rwLock ); QReadLocker rl( &m_rwLock );
if ( type == Project ) if ( type == Project )
{ {
SettingHash::const_iterator it = m_xmlSettings.begin(); SettingHash::const_iterator it = m_xmlSettings.begin();
...@@ -150,8 +135,9 @@ SettingsManager::group( const QString &groupName, SettingsManager::Type type ) ...@@ -150,8 +135,9 @@ SettingsManager::group( const QString &groupName, SettingsManager::Type type )
{ {
ret.insert( key.right( key.size() ret.insert( key.right( key.size()
- key.indexOf( "/" ) - 1 ), sett.value( key ) ); - key.indexOf( "/" ) - 1 ), sett.value( key ) );
if ( !m_classicSettings.contains( key ) ) //FIXME !
m_classicSettings.insert( key, new SettingValue( sett.value( key ) ) ); // if ( !m_classicSettings.contains( key ) )
// m_classicSettings.insert( key, new SettingValue( sett.value( key ) ) );
} }
} }
} }
...@@ -260,9 +246,6 @@ SettingsManager::load( const QDomElement &element ) ...@@ -260,9 +246,6 @@ SettingsManager::load( const QDomElement &element )
QString key = "project/" + list.at( idx ).toElement().tagName(); QString key = "project/" + list.at( idx ).toElement().tagName();
if ( m_xmlSettings.contains( key ) ) if ( m_xmlSettings.contains( key ) )
m_xmlSettings[key]->set( QVariant( attrMap.item( 0 ).nodeValue() ) ); m_xmlSettings[key]->set( QVariant( attrMap.item( 0 ).nodeValue() ) );
else
m_xmlSettings.insert( key,
new SettingValue( QVariant( attrMap.item( 0 ).nodeValue() ) ) );
} }
return true; return true;
} }
...@@ -302,6 +285,18 @@ SettingsManager::commit( SettingsManager::Type type ) ...@@ -302,6 +285,18 @@ SettingsManager::commit( SettingsManager::Type type )
flush(); flush();
} }
void
SettingsManager::createVar( const QString &key, const QVariant &defaultValue,
const QString &desc, SettingsManager::Type type /*= Vlmc*/ )
{
QWriteLocker wlock( &m_rwLock );
if ( type == Vlmc && m_classicSettings.contains( key ) == false )
m_classicSettings.insert( key, new SettingValue( defaultValue, desc ) );
else if ( type == Project && m_xmlSettings.contains( key ) == false )
m_classicSettings.insert( key, new SettingValue( defaultValue, desc ) );
}
void void
SettingsManager::flush() SettingsManager::flush()
{ {
......
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
#ifndef SETTINGSMANAGER_H #ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H #define SETTINGSMANAGER_H
#include <Singleton.hpp> #include "SettingValue.h"
#include "Singleton.hpp"
#include <QString> #include <QString>
#include <QHash> #include <QHash>
...@@ -35,7 +36,21 @@ class SettingValue; ...@@ -35,7 +36,21 @@ class SettingValue;
class QXmlStreamWriter; class QXmlStreamWriter;
class QDomElement; class QDomElement;
class QDomDocument; class QDomDocument;
class SettingValue;
//Var helpers :
#define VLMC_GET_STRING( key ) SettingsManager::getInstance()->value( key )->get().toString()
#define VLMC_GET_INT( key ) SettingsManager::getInstance()->value( key )->get().toInt()
#define VLMC_GET_UINT( key ) SettingsManager::getInstance()->value( key )->get().toUInt()
#define VLMC_GET_DOUBLE( key ) SettingsManager::getInstance()->value( key )->get().toDouble()
#define VLMC_GET_BOOL( key ) SettingsManager::getInstance()->value( key )->get().toBool()
#define VLMC_CREATE_PROJECT_VAR( key, defaultValue, desc ) \
SettingsManager::getInstance()->createVar( key, defaultValue, QObject::tr(desc), \
SettingsManager::Project );
#define VLMC_CREATE_PREFERENCE( key, defaultValue, desc ) \
SettingsManager::getInstance()->createVar( key, defaultValue, QObject::tr(desc), \
SettingsManager::Vlmc );
class SettingsManager : public QObject, public Singleton<SettingsManager> class SettingsManager : public QObject, public Singleton<SettingsManager>
{ {
...@@ -50,17 +65,20 @@ class SettingsManager : public QObject, public Singleton<SettingsManager> ...@@ -50,17 +65,20 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
}; };
void setValue( const QString &key, void setValue( const QString &key,
const QVariant &value, const QVariant &value,
SettingsManager::Type type = Vlmc); SettingsManager::Type type = Vlmc);
void setImmediateValue( const QString &key, void setImmediateValue( const QString &key,
const QVariant &value, const QVariant &value,
SettingsManager::Type = Vlmc); SettingsManager::Type = Vlmc);
QVariant value( const QString &key, SettingValue *value( const QString &key,
const QVariant &defaultValue = QVariant(), const QVariant &defaultValue = QVariant(),
SettingsManager::Type type = Vlmc ); SettingsManager::Type type = Vlmc );
QHash<QString, QVariant> group( const QString &groupName, QHash<QString, QVariant> group( const QString &groupName,
SettingsManager::Type type = Vlmc ); SettingsManager::Type type = Vlmc );
void createVar( const QString &key,
const QVariant &defaultValue,
const QString &desc, Type type = Vlmc );
bool watchValue( const QString &key, bool watchValue( const QString &key,
QObject* receiver, QObject* receiver,
const char *method, const char *method,
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "SettingsManager.h" #include "SettingsManager.h"
#include "LanguagePreferences.h" #include "LanguagePreferences.h"
#include "ui_LanguagePreferences.h" #include "ui_LanguagePreferences.h"
#include "SettingValue.h"
#include <QVariant> #include <QVariant>
#include <QDir> #include <QDir>
...@@ -72,6 +73,7 @@ LanguagePreferences::LanguagePreferences( QWidget *parent ) ...@@ -72,6 +73,7 @@ LanguagePreferences::LanguagePreferences( QWidget *parent )
// Sort the combobox // Sort the combobox
m_ui.comboBoxLanguage->model()->sort( 0 ); m_ui.comboBoxLanguage->model()->sort( 0 );
VLMC_CREATE_PREFERENCE( "global/VLMCLang", "en_US", "The VLMC's UI language" );
} }
LanguagePreferences::~LanguagePreferences() {} LanguagePreferences::~LanguagePreferences() {}
...@@ -80,7 +82,7 @@ void LanguagePreferences::load() ...@@ -80,7 +82,7 @@ void LanguagePreferences::load()
{ {
SettingsManager *setMan = SettingsManager::getInstance(); SettingsManager *setMan = SettingsManager::getInstance();
QVariant lang = setMan->value( "global/VLMCLang", "en_US", m_type ); QVariant lang = setMan->value( "global/VLMCLang", "en_US", m_type )->get();
int idx = m_ui.comboBoxLanguage->findData( lang ); int idx = m_ui.comboBoxLanguage->findData( lang );
if ( idx != -1 ) if ( idx != -1 )
......
...@@ -479,10 +479,10 @@ void MainWindow::on_actionRedo_triggered() ...@@ -479,10 +479,10 @@ void MainWindow::on_actionRedo_triggered()
} }
#define INIT_SHORTCUT( instName, shortcutName, actionInstance ) \ #define INIT_SHORTCUT( instName, shortcutName, actionInstance ) \
QVariant instName = SettingsManager::getInstance()->value( "keyboard/" shortcutName );\ QString instName = VLMC_GET_STRING( "keyboard/"shortcutName ); \
KeyboardShortcutHelper* helper##instName = new KeyboardShortcutHelper( shortcutName, this, true ); \ KeyboardShortcutHelper* helper##instName = new KeyboardShortcutHelper( shortcutName, this, true ); \
connect( helper##instName, SIGNAL( changed( const QString&, const QString&) ), this, SLOT( keyboardShortcutChanged(const QString&, const QString&)) ); \ connect( helper##instName, SIGNAL( changed( const QString&, const QString&) ), this, SLOT( keyboardShortcutChanged(const QString&, const QString&)) ); \
m_ui.actionInstance->setShortcut( instName.toString() ); m_ui.actionInstance->setShortcut( instName );
void MainWindow::initializeMenuKeyboardShortcut() void MainWindow::initializeMenuKeyboardShortcut()
{ {
......
...@@ -34,12 +34,9 @@ RendererSettings::RendererSettings() ...@@ -34,12 +34,9 @@ RendererSettings::RendererSettings()
m_ui.setupUi( this ); m_ui.setupUi( this );
connect( m_ui.outputFileNameButton, SIGNAL(clicked() ), connect( m_ui.outputFileNameButton, SIGNAL(clicked() ),
this, SLOT(selectOutputFileName() ) ); this, SLOT(selectOutputFileName() ) );
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480 ,xml ); m_ui.width->setValue( VLMC_GET_INT( "project/VideoProjectWidth" ) );
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, xml ); m_ui.height->setValue( VLMC_GET_INT( "project/VideoProjectHeight" ) );
QVariant outputFps = SettingsManager::getInstance()->value( "global/VLMCOutPutFPS", 30, SettingsManager::Vlmc ); m_ui.fps->setValue( VLMC_GET_DOUBLE( "global/VLMCOutputFPS" ) );
m_ui.width->setValue( width.toInt() );
m_ui.height->setValue( height.toInt() );
m_ui.fps->setValue( outputFps.toDouble() );
} }
void void
......
...@@ -29,16 +29,15 @@ AudioProjectPreferences::AudioProjectPreferences( QWidget *parent ) ...@@ -29,16 +29,15 @@ AudioProjectPreferences::AudioProjectPreferences( QWidget *parent )
m_type( SettingsManager::Project ) m_type( SettingsManager::Project )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
VLMC_CREATE_PROJECT_VAR( "project/AudioSampleRate", 0, "The project audio samplerate" );
} }
AudioProjectPreferences::~AudioProjectPreferences() { } AudioProjectPreferences::~AudioProjectPreferences() { }
void AudioProjectPreferences::load() void AudioProjectPreferences::load()
{ {
SettingsManager* setMan = SettingsManager::getInstance(); int sampleRate = VLMC_GET_INT( "project/AudioSampleRate" );
int sampleRate = setMan->value( "project/AudioSampleRate", 0, m_type ).toInt();
m_ui.SampleRate->setValue( sampleRate ); m_ui.SampleRate->setValue( sampleRate );
return ; return ;
} }
......
...@@ -27,16 +27,14 @@ ...@@ -27,16 +27,14 @@
#include "ProjectManager.h" #include "ProjectManager.h"
#include <QWidget> #include <QWidget>
//DEBUG
#include <QtDebug>
//!DEBUG
ProjectPreferences::ProjectPreferences( QWidget* parent ) ProjectPreferences::ProjectPreferences( QWidget* parent )
: PreferenceWidget( parent ), : PreferenceWidget( parent ),
m_type( SettingsManager::Project ) m_type( SettingsManager::Project )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
VLMC_CREATE_PROJECT_VAR( "project/ProjectName", ProjectManager::unSavedProject,
"The project name" );
} }
ProjectPreferences::~ProjectPreferences() { } ProjectPreferences::~ProjectPreferences() { }
...@@ -44,9 +42,7 @@ ProjectPreferences::~ProjectPreferences() { } ...@@ -44,9 +42,7 @@ ProjectPreferences::~ProjectPreferences() { }
void ProjectPreferences::load() void ProjectPreferences::load()
{ {
SettingsManager* settMan = SettingsManager::getInstance(); SettingsManager* settMan = SettingsManager::getInstance();
QString Name = settMan->value( "project/ProjectName", QString Name = VLMC_GET_STRING( "project/ProjectName" );
ProjectManager::unNamedProject,
m_type ).toString();
m_ui.ProjectNameLineEdit->setText( Name ); m_ui.ProjectNameLineEdit->setText( Name );
} }
......
...@@ -55,10 +55,10 @@ void VLMCPreferences::load() ...@@ -55,10 +55,10 @@ void VLMCPreferences::load()
{ {
SettingsManager* settMan = SettingsManager::getInstance(); SettingsManager* settMan = SettingsManager::getInstance();
QString outputFPS = settMan->value( "global/VLMCOutPutFPS", "30", m_type ).toString(); QString outputFPS = VLMC_GET_STRING( "global/VLMCOutputFPS" );
QString tracksNb = settMan->value( "global/VLMCTracksNb", "64", m_type ).toString(); QString tracksNb = VLMC_GET_STRING( "global/VLMCTracksNb" );
bool autoSave = settMan->value( "global/AutomaticBackup", false, m_type ).toBool(); bool autoSave = VLMC_GET_BOOL( "global/AutomaticBackup" );
QString autoSaveInterval = settMan->value( "global/AutomaticBackupInterval", "5", m_type ).toString(); QString autoSaveInterval = VLMC_GET_STRING( "global/AutomaticBackupInterval" );
m_ui.outputFPS->setText( outputFPS ); m_ui.outputFPS->setText( outputFPS );
m_ui.tracksNb->setText( tracksNb ); m_ui.tracksNb->setText( tracksNb );
......
...@@ -30,6 +30,9 @@ VideoProjectPreferences::VideoProjectPreferences( QWidget *parent ) ...@@ -30,6 +30,9 @@ VideoProjectPreferences::VideoProjectPreferences( QWidget *parent )
m_type( SettingsManager::Project ) m_type( SettingsManager::Project )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
VLMC_CREATE_PROJECT_VAR( "project/VideoProjectWidth", 480, "The project video width" );
VLMC_CREATE_PROJECT_VAR( "project/VideoProjectHeight", 300, "The project video height" );
VLMC_CREATE_PROJECT_VAR( "global/VLMCOutputFPS", 30, "The project output FPS" );
} }
VideoProjectPreferences::~VideoProjectPreferences() { } VideoProjectPreferences::~VideoProjectPreferences() { }
...@@ -38,9 +41,10 @@ void VideoProjectPreferences::load() ...@@ -38,9 +41,10 @@ void VideoProjectPreferences::load()
{ {
SettingsManager* setMan = SettingsManager::getInstance(); SettingsManager* setMan = SettingsManager::getInstance();
int projectFps = setMan->value( "project/VideoProjectFPS", 30, m_type ).toInt(); int projectWidth = VLMC_GET_INT( "project/VideoProjectWidth" );
int projectHeight = setMan->value( "project/VideoProjectHeight", 300, m_type ).toInt(); int projectHeight = VLMC_GET_INT( "project/VideoProjectHeight" );
int projectWidth = setMan->value( "project/VideoProjectWidth", 480, m_type ).toInt(); //FIXME: fps is a double value
int projectFps = VLMC_GET_INT( "global/VLMCOutputFPS" );
m_ui.FPSSpinBox->setValue( projectFps ); m_ui.FPSSpinBox->setValue( projectFps );
m_ui.HeightSpinBox->setValue( projectHeight ); m_ui.HeightSpinBox->setValue( projectHeight );
......
...@@ -37,8 +37,7 @@ TracksRuler::TracksRuler( TracksView* tracksView, QWidget* parent ) ...@@ -37,8 +37,7 @@ TracksRuler::TracksRuler( TracksView* tracksView, QWidget* parent )
//TODO We should really get that from the //TODO We should really get that from the
// workflow and not directly from the settings. // workflow and not directly from the settings.
SettingsManager* settings = SettingsManager::getInstance(); m_fps = qRound( VLMC_GET_DOUBLE( "global/VLMCOutputFPS" ) );
m_fps = qRound( settings->value( "global/VLMCOutPutFPS", 30, SettingsManager::Vlmc ).toDouble() );
m_factor = 1; m_factor = 1;
m_scale = 3; m_scale = 3;
......
...@@ -49,16 +49,12 @@ int GeneralPage::nextId() const ...@@ -49,16 +49,12 @@ int GeneralPage::nextId() const
void GeneralPage::initializePage() void GeneralPage::initializePage()
{ {
SettingsManager* sManager = SettingsManager::getInstance();
//Since this is a new project, it will be unnamed //Since this is a new project, it will be unnamed
QString projectName = ProjectManager::unNamedProject; QString projectName = ProjectManager::unNamedProject;
ui.lineEditName->setText( projectName ); ui.lineEditName->setText( projectName );
//fetching the global workspace path //fetching the global workspace path
QString workspacePath = sManager->value( "global/VLMCWorkspace", QString workspacePath = VLMC_GET_STRING( "global/VLMCWorkspace" );
QDir::homePath(),
SettingsManager::Vlmc ).toString();
ui.lineEditWorkspace->setText( workspacePath ); ui.lineEditWorkspace->setText( workspacePath );
updateProjectLocation(); updateProjectLocation();
......
...@@ -139,9 +139,8 @@ MetaDataWorker::metaDataAvailable() ...@@ -139,9 +139,8 @@ MetaDataWorker::metaDataAvailable()
} }
else else
{ {
QVariant val = SettingsManager::getInstance()->value( "project/VideoProjectFPS", 30, SettingsManager::Project ); double fps = VLMC_GET_DOUBLE( "project/VideoProjectFPS" );
Q_ASSERT_X( val.isNull() == false , "MetaDataWorker", "Can't operate without a project FPS value "); m_media->setFps( fps );
m_media->setFps( val.toDouble() );
} }
m_media->setLength( m_mediaPlayer->getLength() ); m_media->setLength( m_mediaPlayer->getLength() );
......
...@@ -74,8 +74,7 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false ) ...@@ -74,8 +74,7 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) ); connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) ); connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
QVariant val = VLMC_CREATE_PROJECT_VAR( "project/ProjectName", unNamedProject, "The project name" );
SettingsManager::getInstance()->value( "project/ProjectName", unNamedProject, SettingsManager::Project );
SettingsManager::getInstance()->watchValue( "project/ProjectName", this, SettingsManager::getInstance()->watchValue( "project/ProjectName", this,
SLOT(projectNameChanged(QVariant) ), SLOT(projectNameChanged(QVariant) ),
SettingsManager::Project ); SettingsManager::Project );
...@@ -83,19 +82,19 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false ) ...@@ -83,19 +82,19 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
//Automatic save part : //Automatic save part :
m_timer = new QTimer( this ); m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( autoSaveRequired() ) ); connect( m_timer, SIGNAL( timeout() ), this, SLOT( autoSaveRequired() ) );
QVariant autoSaveEnabled = VLMC_CREATE_PREFERENCE( "global/AutomaticBackup", false, "When this option is activated,"
SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::Vlmc ); "vlmc will automatically save your project at a specified interval" );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackup", this, SettingsManager::getInstance()->watchValue( "global/AutomaticBackup", this,
SLOT( automaticSaveEnabledChanged(QVariant) ), SLOT( automaticSaveEnabledChanged(QVariant) ),
SettingsManager::Vlmc, SettingsManager::Vlmc,
Qt::QueuedConnection ); Qt::QueuedConnection );
QVariant autoSaveInterval = VLMC_CREATE_PREFERENCE( "global/AutomaticBackupInterval", 5, "This is the interval that"
SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::Vlmc ); "vlmc will wait between two automatic save" );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackupInterval", this, SettingsManager::getInstance()->watchValue( "global/AutomaticBackupInterval", this,
SLOT( automaticSaveIntervalChanged(QVariant) ), SLOT( automaticSaveIntervalChanged(QVariant) ),
SettingsManager::Vlmc, SettingsManager::Vlmc,
Qt::QueuedConnection ); Qt::QueuedConnection );
automaticSaveEnabledChanged( autoSaveEnabled ); automaticSaveEnabledChanged( VLMC_GET_BOOL( "global/AutomaticBackup" ) );
} }
ProjectManager::~ProjectManager() ProjectManager::~ProjectManager()
...@@ -348,8 +347,8 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val ) ...@@ -348,8 +347,8 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
if ( enabled == true ) if ( enabled == true )
{ {
QVariant interval = SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::Vlmc ); int interval = VLMC_GET_INT( "global/AutomaticBackupInterval" );
m_timer->start( interval.toInt() * 1000 * 60 ); m_timer->start( interval * 1000 * 60 );
} }
else else
m_timer->stop(); m_timer->stop();
...@@ -357,9 +356,9 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val ) ...@@ -357,9 +356,9 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
void ProjectManager::automaticSaveIntervalChanged( const QVariant& val ) void ProjectManager::automaticSaveIntervalChanged( const QVariant& val )
{ {
QVariant enabled = SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::Vlmc ); bool enabled = VLMC_GET_BOOL( "global/AutomaticBackup" );
if ( enabled.toBool() == false ) if ( enabled == false )
return ; return ;
m_timer->start( val.toInt() * 1000 * 60 ); m_timer->start( val.toInt() * 1000 * 60 );
} }
......
...@@ -160,15 +160,13 @@ WorkflowFileRenderer::getUnlockCallback() ...@@ -160,15 +160,13 @@ WorkflowFileRenderer::getUnlockCallback()
quint32 quint32
WorkflowFileRenderer::width() const WorkflowFileRenderer::width() const
{