Commit 7a440688 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Preferences: Renaming XML and QSett enum members to Project and Vlmc

We don't have to expose the subsystem that will store the settings.
All that matters is to differenciate project and software settings.
parent a66442cf
......@@ -14,7 +14,7 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QWidget* pa
setKey( QKeySequence( set.toString() ) );
SettingsManager::getInstance()->watchValue( "keyboard/" + name, this,
SLOT( shortcutUpdated( const QVariant& ) ),
SettingsManager::QSett );
SettingsManager::Vlmc );
}
void KeyboardShortcutHelper::shortcutUpdated( const QVariant& value )
......
......@@ -39,9 +39,9 @@ SettingsManager::setValue( const QString &key,
const QVariant &value,
SettingsManager::Type type )
{
if ( type == XML )
if ( type == Project )
m_tmpXmlSettings.insert( key, new SettingValue( value ) );
else if ( type == QSett )
else if ( type == Vlmc )
m_tmpClassicSettings.insert( key, new SettingValue( value ) );
return ;
}
......@@ -53,9 +53,9 @@ SettingsManager::setImmediateValue( const QString &key,
{
QWriteLocker wlock( &m_rwLock );
SettingHash *settMap;
if ( type == XML )
if ( type == Project )
settMap = &m_xmlSettings;
else if ( type == QSett )
else if ( type == Vlmc )
{
QSettings sett;
sett.setValue( key, value );
......@@ -81,7 +81,7 @@ SettingsManager::value( const QString &key,
{
QReadLocker rl( &m_rwLock );
if ( ( type == XML || type == All ) )
if ( ( type == Project || type == All ) )
{
if ( m_xmlSettings.contains( key ) )
return m_xmlSettings.value( key )->get();
......@@ -91,7 +91,7 @@ SettingsManager::value( const QString &key,
return defaultValue;
}
}
else if ( type == QSett )
else if ( type == Vlmc )
{
if ( m_classicSettings.contains( key ) )
return m_classicSettings.value( key )->get();
......@@ -112,7 +112,7 @@ SettingsManager::group( const QString &groupName, SettingsManager::Type type )
{
QHash<QString, QVariant> ret;
QReadLocker rl( &m_rwLock );
if ( ( type == XML || type == All ) )
if ( ( type == Project || type == All ) )
{
SettingHash::const_iterator it = m_xmlSettings.begin();
SettingHash::const_iterator ed = m_xmlSettings.end();
......@@ -124,7 +124,7 @@ SettingsManager::group( const QString &groupName, SettingsManager::Type type )
- it.key().indexOf( "/" ) - 1 ), it.value()->get() );
}
}
if ( type == QSett || type == All )
if ( type == Vlmc || type == All )
{
SettingHash::const_iterator it = m_classicSettings.begin();
SettingHash::const_iterator ed = m_classicSettings.end();
......@@ -167,13 +167,13 @@ SettingsManager::watchValue( const QString &key,
{
QReadLocker rl( &m_rwLock );
if ( ( type == XML || type == All ) && m_xmlSettings.contains( key ) )
if ( ( type == Project || type == All ) && m_xmlSettings.contains( key ) )
{
connect( m_xmlSettings[key], SIGNAL( changed( const QVariant& ) ),
receiver, method );
return true;
}
else if ( ( type == QSett || type == All ) )
else if ( ( type == Vlmc || type == All ) )
{
if ( m_classicSettings.contains( key ) )
{
......@@ -272,7 +272,7 @@ SettingsManager::commit( SettingsManager::Type type )
{
{
QWriteLocker wlock( &m_rwLock );
if ( type == XML || type == All )
if ( type == Project || type == All )
{
SettingHash::iterator it;
SettingHash::iterator ed = m_tmpXmlSettings.end();
......@@ -284,7 +284,7 @@ SettingsManager::commit( SettingsManager::Type type )
m_xmlSettings.insert( it.key(), it.value() );
}
}
if ( type == QSett || type == All )
if ( type == Vlmc || type == All )
{
QSettings sett;
SettingHash::iterator it;
......
......@@ -45,34 +45,34 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
typedef QHash<QString, SettingValue*> SettingHash;
enum Type
{
XML,
QSett,
Project,
Vlmc,
All
};
void setValue( const QString &key,
const QVariant &value,
SettingsManager::Type type = QSett);
SettingsManager::Type type = Vlmc);
void setImmediateValue( const QString &key,
const QVariant &value,
SettingsManager::Type = QSett);
SettingsManager::Type = Vlmc);
QVariant value( const QString &key,
const QVariant &defaultValue = QVariant(),
SettingsManager::Type type = QSett );
SettingsManager::Type type = Vlmc );
QHash<QString, QVariant> group( const QString &groupName,
SettingsManager::Type type = QSett );
SettingsManager::Type type = Vlmc );
bool watchValue( const QString &key,
QObject* receiver,
const char *method,
SettingsManager::Type type,
Qt::ConnectionType cType = Qt::AutoConnection );
void save() const;
void save( QDomDocument &xmlfile, QDomElement& root ) const;
bool load( const QDomElement &element );
void save() const;
void save( QDomDocument &xmlfile, QDomElement& root ) const;
bool load( const QDomElement &element );
bool commit( SettingsManager::Type type );
void flush();
bool commit( SettingsManager::Type type );
void flush();
private:
friend class Singleton<SettingsManager>;
......
......@@ -35,7 +35,7 @@ QTranslator* LanguagePreferences::m_currentLang = NULL;
LanguagePreferences::LanguagePreferences( QWidget *parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::QSett )
m_type( SettingsManager::Vlmc )
{
m_ui.setupUi( this );
......
......@@ -30,13 +30,13 @@
RendererSettings::RendererSettings()
{
SettingsManager::Type xml = SettingsManager::XML;
SettingsManager::Type xml = SettingsManager::Project;
m_ui.setupUi( this );
connect( m_ui.outputFileNameButton, SIGNAL(clicked() ),
this, SLOT(selectOutputFileName() ) );
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480 ,xml );
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, xml );
QVariant outputFps = SettingsManager::getInstance()->value( "global/VLMCOutPutFPS", 30, SettingsManager::QSett );
QVariant outputFps = SettingsManager::getInstance()->value( "global/VLMCOutPutFPS", 30, SettingsManager::Vlmc );
m_ui.width->setValue( width.toInt() );
m_ui.height->setValue( height.toInt() );
m_ui.fps->setValue( outputFps.toDouble() );
......
......@@ -26,7 +26,7 @@
AudioProjectPreferences::AudioProjectPreferences( QWidget *parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::XML )
m_type( SettingsManager::Project )
{
m_ui.setupUi( this );
}
......
......@@ -28,10 +28,10 @@
KeyboardShortcut::KeyboardShortcut( QWidget* parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::QSett )
m_type( SettingsManager::Vlmc )
{
m_layout = new QFormLayout( this );
const QHash<QString, QVariant> shortcutGroup = SettingsManager::getInstance()->group( "keyboard", SettingsManager::QSett );
const QHash<QString, QVariant> shortcutGroup = SettingsManager::getInstance()->group( "keyboard", SettingsManager::Vlmc );
Q_ASSERT( !shortcutGroup.size() == 0 );
QHash<QString, QVariant>::const_iterator it = shortcutGroup.begin();
......
......@@ -34,7 +34,7 @@
ProjectPreferences::ProjectPreferences( QWidget* parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::XML )
m_type( SettingsManager::Project )
{
m_ui.setupUi( this );
}
......
......@@ -28,7 +28,7 @@
VLMCPreferences::VLMCPreferences( QWidget *parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::QSett )
m_type( SettingsManager::Vlmc )
{
m_ui.setupUi(this);
setAutomaticSaveLabelVisiblity( m_ui.automaticSave->isChecked() );
......
......@@ -27,7 +27,7 @@
VideoProjectPreferences::VideoProjectPreferences( QWidget *parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::XML )
m_type( SettingsManager::Project )
{
m_ui.setupUi( this );
}
......
......@@ -38,7 +38,7 @@ TracksRuler::TracksRuler( TracksView* tracksView, QWidget* parent )
//TODO We should really get that from the
// workflow and not directly from the settings.
SettingsManager* settings = SettingsManager::getInstance();
m_fps = qRound( settings->value( "global/VLMCOutPutFPS", 30, SettingsManager::QSett ).toDouble() );
m_fps = qRound( settings->value( "global/VLMCOutPutFPS", 30, SettingsManager::Vlmc ).toDouble() );
m_factor = 1;
m_scale = 3;
......
......@@ -58,7 +58,7 @@ void GeneralPage::initializePage()
//fetching the global workspace path
QString workspacePath = sManager->value( "global/VLMCWorkspace",
QDir::homePath(),
SettingsManager::QSett ).toString();
SettingsManager::Vlmc ).toString();
ui.lineEditWorkspace->setText( workspacePath );
updateProjectLocation();
......@@ -90,7 +90,7 @@ bool GeneralPage::validatePage()
}
QVariant projectName( ui.lineEditName->text() );
sManager->setValue( "project/ProjectName", projectName, SettingsManager::XML );
sManager->setValue( "project/ProjectName", projectName, SettingsManager::Project );
return true;
}
......
......@@ -98,10 +98,10 @@ bool VideoPage::validatePage()
QVariant projectHeight( ui.spinBoxVideoHeight->value() );
QVariant projectWidth( ui.spinBoxVideoWidth->value() );
sManager->setValue( "project/VideoProjectFPS", projectFps, SettingsManager::XML );
sManager->setValue( "project/VideoProjectHeight", projectHeight, SettingsManager::XML );
sManager->setValue( "project/VideoProjectWidth", projectWidth, SettingsManager::XML );
sManager->commit( SettingsManager::XML );
sManager->setValue( "project/VideoProjectFPS", projectFps, SettingsManager::Project );
sManager->setValue( "project/VideoProjectHeight", projectHeight, SettingsManager::Project );
sManager->setValue( "project/VideoProjectWidth", projectWidth, SettingsManager::Project );
sManager->commit( SettingsManager::Project );
return true;
}
......
......@@ -131,7 +131,7 @@ MetaDataWorker::metaDataAvailable()
}
else
{
QVariant val = SettingsManager::getInstance()->value( "project/VideoProjectFPS", 30, SettingsManager::XML );
QVariant val = SettingsManager::getInstance()->value( "project/VideoProjectFPS", 30, SettingsManager::Project );
Q_ASSERT_X( val.isNull() == false , "MetaDataWorker", "Can't operate without a project FPS value ");
m_media->setFps( val.toDouble() );
}
......
......@@ -75,25 +75,25 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
QVariant val =
SettingsManager::getInstance()->value( "project/ProjectName", unNamedProject, SettingsManager::XML );
SettingsManager::getInstance()->value( "project/ProjectName", unNamedProject, SettingsManager::Project );
SettingsManager::getInstance()->watchValue( "project/ProjectName", this,
SLOT(projectNameChanged(QVariant) ),
SettingsManager::XML );
SettingsManager::Project );
//Automatic save part :
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( autoSaveRequired() ) );
QVariant autoSaveEnabled =
SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::QSett );
SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::Vlmc );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackup", this,
SLOT( automaticSaveEnabledChanged(QVariant) ),
SettingsManager::QSett,
SettingsManager::Vlmc,
Qt::QueuedConnection );
QVariant autoSaveInterval =
SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::QSett );
SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::Vlmc );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackupInterval", this,
SLOT( automaticSaveIntervalChanged(QVariant) ),
SettingsManager::QSett,
SettingsManager::Vlmc,
Qt::QueuedConnection );
automaticSaveEnabledChanged( autoSaveEnabled );
}
......@@ -347,7 +347,7 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
if ( enabled == true )
{
QVariant interval = SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::QSett );
QVariant interval = SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::Vlmc );
m_timer->start( interval.toInt() * 1000 * 60 );
}
else
......@@ -356,7 +356,7 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
void ProjectManager::automaticSaveIntervalChanged( const QVariant& val )
{
QVariant enabled = SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::QSett );
QVariant enabled = SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::Vlmc );
if ( enabled.toBool() == false )
return ;
......
......@@ -160,14 +160,14 @@ WorkflowFileRenderer::getUnlockCallback()
quint32
WorkflowFileRenderer::width() const
{
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480, SettingsManager::XML );
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480, SettingsManager::Project );
return width.toUInt();
}
quint32
WorkflowFileRenderer::height() const
{
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, SettingsManager::XML );
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, SettingsManager::Project );
return height.toUInt();
}
......
......@@ -348,21 +348,21 @@ void* WorkflowRenderer::getUnlockCallback()
quint32
WorkflowRenderer::width() const
{
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480, SettingsManager::XML );
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480, SettingsManager::Project );
return width.toUInt();
}
quint32
WorkflowRenderer::height() const
{
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, SettingsManager::XML );
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, SettingsManager::Project );
return height.toUInt();
}
float
WorkflowRenderer::outputFps() const
{
QVariant outputFps = SettingsManager::getInstance()->value( "global/VLMCOutPutFPS", 30, SettingsManager::QSett );
QVariant outputFps = SettingsManager::getInstance()->value( "global/VLMCOutPutFPS", 30, SettingsManager::Vlmc );
return outputFps.toDouble();
}
......
......@@ -31,11 +31,11 @@ VlmcDebug::VlmcDebug() : m_logFile( NULL )
//setup log level :
QStringList args = qApp->arguments();
if ( args.indexOf( QRegExp( "-vvv*" ) ) >= 0 )
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtDebugMsg, SettingsManager::QSett );
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtDebugMsg, SettingsManager::Vlmc );
else if ( args.contains( "-v" ) == true )
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtWarningMsg, SettingsManager::QSett );
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtWarningMsg, SettingsManager::Vlmc );
else
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtCriticalMsg, SettingsManager::QSett );
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtCriticalMsg, SettingsManager::Vlmc );
int pos = args.indexOf( QRegExp( "--logfile=.*" ) );
if ( pos > 0 )
......@@ -45,14 +45,14 @@ VlmcDebug::VlmcDebug() : m_logFile( NULL )
if ( logFile.length() <= 0 )
qWarning() << tr("Invalid value supplied for argument --logfile" );
else
SettingsManager::getInstance()->setImmediateValue( "private/LogFile", logFile, SettingsManager::QSett );
SettingsManager::getInstance()->setImmediateValue( "private/LogFile", logFile, SettingsManager::Vlmc );
}
QVariant setVal = SettingsManager::getInstance()->value( "private/LogFile", "log.vlmc", SettingsManager::QSett );
QVariant setVal = SettingsManager::getInstance()->value( "private/LogFile", "log.vlmc", SettingsManager::Vlmc );
SettingsManager::getInstance()->watchValue( "private/LogFile", this,
SLOT( logFileChanged( const QVariant& ) ),
SettingsManager::QSett );
SettingsManager::Vlmc );
QObject::connect( qApp,
SIGNAL( aboutToQuit() ),
this,
......@@ -101,7 +101,7 @@ void VlmcDebug::vlmcMessageHandler( QtMsgType type, const char* msg )
VlmcDebug::getInstance()->m_logFile->write( "\n" );
}
if ( type != QtFatalMsg
&& type < SettingsManager::getInstance()->value( "private/LogLevel", QtDebugMsg, SettingsManager::QSett ).toInt() )
&& type < SettingsManager::getInstance()->value( "private/LogLevel", QtDebugMsg, SettingsManager::Vlmc ).toInt() )
return ;
switch ( type )
{
......
......@@ -44,8 +44,10 @@
#define EXPAND( x ) #x
#define STRINGIFY( x ) EXPAND( x )
#define ADD_SHORTCUT(NAME, KEYS) key = QString("keyboard/").append( QObject::tr( NAME ) ); \
settMan->setImmediateValue( key, QVariant( QObject::tr( KEYS ) ), SettingsManager::QSett )
#define ADD_SHORTCUT(NAME, KEYS) \
key = QString("keyboard/").append( QObject::tr( NAME ) ); \
settMan->setImmediateValue( key, QVariant( QObject::tr( KEYS ) ), \
SettingsManager::Vlmc )
static void initShorcuts()
{
QString key;
......
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