Commit 06c6c7d9 authored by Clement CHAVANCE's avatar Clement CHAVANCE Committed by Hugo Beauzee-Luyssen

Updated all the call to SettingsManager::value and SettingsManager::setValue

Signed-off-by: default avatarHugo Beauzee-Luyssen <beauze.h@gmail.com>
parent c8740f67
......@@ -9,10 +9,10 @@ KeyboardShortcutHelper::KeyboardShortcutHelper( const QString& name, QWidget* pa
m_name( name ),
m_menu( menu )
{
const SettingValue* set = SettingsManager::getInstance()->getValue( "keyboard_shortcut", name );
QVariant set = SettingsManager::getInstance()->value( name );
if ( m_menu == false )
setKey( QKeySequence( set->get().toString() ) );
connect( set, SIGNAL( changed( const QVariant& ) ), this, SLOT( shortcutUpdated( const QVariant& ) ) );
setKey( QKeySequence( set.toString() ) );
//connect( set, SIGNAL( changed( const QVariant& ) ), this, SLOT( shortcutUpdated( const QVariant& ) ) );
}
void KeyboardShortcutHelper::shortcutUpdated( const QVariant& value )
......
......@@ -22,19 +22,20 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QVariant>
#include "SettingsManager.h"
#include "LanguagePreferences.h"
#include "ui_LanguagePreferences.h"
#include <QVariant>
#include <QDir>
#include <QLocale>
QTranslator* LanguagePreferences::m_currentLang = NULL;
LanguagePreferences::LanguagePreferences( QWidget *parent )
: PreferenceWidget( parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::QSett )
{
m_ui.setupUi( this );
......@@ -77,10 +78,10 @@ LanguagePreferences::~LanguagePreferences() {}
void LanguagePreferences::load()
{
const QString& part = m_defaults ? "default" : m_settName;
SettingsManager *setMan = SettingsManager::getInstance();
const SettingValue *lang = setMan->getValue( part, "VLMCLang" );
int idx = m_ui.comboBoxLanguage->findData( lang->get() );
QVariant lang = setMan->value( "global/VLMCLang", "en_US", m_type );
int idx = m_ui.comboBoxLanguage->findData( lang );
if ( idx != -1 )
m_ui.comboBoxLanguage->setCurrentIndex( idx );
......@@ -92,7 +93,7 @@ void LanguagePreferences::save()
SettingsManager* setMan = SettingsManager::getInstance();
QVariant lang = m_ui.comboBoxLanguage->itemData( m_ui.comboBoxLanguage->currentIndex() );
setMan->setValue( m_settName, "VLMCLang", lang );
setMan->setImmediateValue( "VLMCLang", lang, m_type );
changeLang( lang.toString() );
}
......
......@@ -26,10 +26,12 @@
#ifndef PREFERENCES_H
#define PREFERENCES_H
#include <QTranslator>
#include <QtDebug>
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "ui_LanguagePreferences.h"
#include <QTranslator>
#include <QtDebug>
#define TS_PREFIX "vlmc_"
......@@ -48,7 +50,8 @@ class LanguagePreferences : public PreferenceWidget
private:
Ui::LanguagePreferences m_ui;
static QTranslator* m_currentLang;
static QTranslator* m_currentLang;
SettingsManager::Type m_type;
};
#endif // PREFERENCES_H
......@@ -77,10 +77,6 @@ MainWindow::MainWindow( QWidget *parent ) :
qRegisterMetaType<MainWorkflow::FrameChangedReason>( "MainWorkflow::FrameChangedReason" );
qRegisterMetaType<QVariant>( "QVariant" );
// Settings
VLMCSettingsDefault::load( "default" );
VLMCSettingsDefault::load( "VLMC" );
VLMCSettingsDefault::loadKeyboardShortcutDefaults();
//We only install message handler here cause it uses configuration.
VlmcDebug::getInstance()->setup();
......@@ -312,7 +308,7 @@ void MainWindow::initializeDockWidgets( void )
void MainWindow::createGlobalPreferences()
{
m_globalPreferences = new Settings( false, "VLMC", this );
m_globalPreferences = new Settings( this );
m_globalPreferences->addWidget( tr ( "VLMC" ),
new VLMCPreferences( m_globalPreferences ),
QIcon( ":/images/images/vlmc.png" ),
......@@ -327,9 +323,9 @@ void MainWindow::createGlobalPreferences()
tr( "Keyboard Settings" ) );
}
void MainWindow::createProjectPreferences()
void MainWindow::createProjectPreferences()
{
m_projectPreferences = new Settings( false, "project", this );
m_projectPreferences = new Settings( this );
m_projectPreferences->addWidget( tr( "Project" ),
new ProjectPreferences,
QIcon( ":/images/images/vlmc.png" ),
......@@ -443,7 +439,7 @@ void MainWindow::on_actionBypass_effects_engine_toggled(bool toggled)
void MainWindow::on_actionProject_Preferences_triggered()
{
m_projectPreferences->show( "project" );
m_projectPreferences->show();
}
void MainWindow::closeEvent( QCloseEvent* e )
......@@ -479,11 +475,11 @@ void MainWindow::on_actionRedo_triggered()
UndoStack::getInstance( this )->redo();
}
#define INIT_SHORTCUT( instName, shortcutName, actionInstance ) \
const SettingValue* instName = SettingsManager::getInstance()->getValue( "keyboard_shortcut", shortcutName );\
#define INIT_SHORTCUT( instName, shortcutName, actionInstance ) \
QVariant instName = SettingsManager::getInstance()->value( shortcutName, "Ctrl+x" );\
KeyboardShortcutHelper* helper##instName = new KeyboardShortcutHelper( shortcutName, this, true ); \
connect( helper##instName, SIGNAL( changed( const QString&, const QString&) ), this, SLOT( keyboardShortcutChanged(QString,QString)) ); \
m_ui.actionInstance->setShortcut( instName->get().toString() );
m_ui.actionInstance->setShortcut( instName.toString() );
void MainWindow::initializeMenuKeyboardShortcut()
{
......
......@@ -30,18 +30,16 @@
RendererSettings::RendererSettings()
{
SettingsManager::Type xml = SettingsManager::XML;
m_ui.setupUi( this );
connect( m_ui.outputFileNameButton, SIGNAL(clicked() ),
this, SLOT(selectOutputFileName() ) );
const SettingValue *width = SettingsManager::getInstance()->getValue( "project",
"VideoProjectWidth" );
const SettingValue *height = SettingsManager::getInstance()->getValue( "project",
"VideoProjectHeight" );
const SettingValue *outputFps = SettingsManager::getInstance()->getValue( "VLMC",
"VLMCOutPutFPS" );
m_ui.width->setValue( width->get().toInt() );
m_ui.height->setValue( height->get().toInt() );
m_ui.fps->setValue( outputFps->get().toDouble() );
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 );
m_ui.width->setValue( width.toInt() );
m_ui.height->setValue( height.toInt() );
m_ui.fps->setValue( outputFps.toDouble() );
}
void
......
......@@ -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->getValue( "VLMC", "VLMCOutPutFPS" )->get().toDouble() );
m_fps = qRound( settings->value( "global/VLMCOutPutFPS", 30, SettingsManager::QSett ).toDouble() );
m_factor = 1;
m_scale = 3;
......
......@@ -5,6 +5,7 @@
#include "GeneralPage.h"
#include "ProjectWizard.h"
#include "SettingsManager.h"
#include "ProjectManager.h"
GeneralPage::GeneralPage( QWidget *parent ) :
QWizardPage( parent )
......@@ -50,10 +51,14 @@ void GeneralPage::initializePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
QString projectName = sManager->getValue( "default", "ProjectName" )->get().toString();
//Since this is a new project, it will be unnamed
QString projectName = ProjectManager::unNamedProject;
ui.lineEditName->setText( projectName );
QString workspacePath = sManager->getValue( "default", "VLMCWorkspace" )->get().toString();
//fetching the global workspace path
QString workspacePath = sManager->value( "global/VLMCWorkspace",
QDir::homePath(),
SettingsManager::QSett ).toString();
ui.lineEditWorkspace->setText( workspacePath );
updateProjectLocation();
......@@ -68,7 +73,7 @@ bool GeneralPage::validatePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
QString defaultProjectName = sManager->getValue( "default", "ProjectName" )->get().toString();
QString defaultProjectName = ProjectManager::unNamedProject;
if ( ui.lineEditName->text().isEmpty() || ui.lineEditName->text() == defaultProjectName )
{
QMessageBox::information( this, tr( "Form is incomplete" ),
......@@ -85,7 +90,7 @@ bool GeneralPage::validatePage()
}
QVariant projectName( ui.lineEditName->text() );
sManager->setValue( "project", "ProjectName", projectName );
sManager->setValue( "project/ProjectName", projectName, SettingsManager::XML );
return true;
}
......
......@@ -96,7 +96,7 @@ void ProjectWizard::accept()
if ( currentId() == Page_Video )
{
ProjectManager::getInstance()->newProject( field( "projectName" ).toString() );
SettingsManager::getInstance()->commit();
SettingsManager::getInstance()->commit( SettingsManager::All );
}
QDialog::accept();
}
......
......@@ -61,14 +61,11 @@ void VideoPage::initializePage()
{
SettingsManager* sManager = SettingsManager::getInstance();
int projectFps = sManager->getValue( "default",
"VideoProjectFPS" )->get().toDouble();
int projectHeight = sManager->getValue( "default",
"VideoProjectHeight" )->get().toInt();
int projectWidth = sManager->getValue( "default",
"VideoProjectWidth" )->get().toInt();
int sampleRate = sManager->getValue( "default",
"AudioSampleRate" )->get().toInt();
#warning __LINE__ __FILE__ DEFAULT VALUES !!!!!!
int projectFps = sManager->value( "default/VideoProjectFPS" ).toDouble();
int projectHeight = sManager->value( "default/VideoProjectHeight" ).toInt();
int projectWidth = sManager->value( "default/VideoProjectWidth" ).toInt();
int sampleRate = sManager->value( "default/AudioSampleRate" ).toInt();
ui.comboBoxVideoPresets->setCurrentIndex( 0 );
ui.comboBoxAudioPresets->setCurrentIndex( 0 );
......@@ -102,10 +99,10 @@ bool VideoPage::validatePage()
QVariant projectHeight( ui.spinBoxVideoHeight->value() );
QVariant projectWidth( ui.spinBoxVideoWidth->value() );
sManager->setValue( "project", "VideoProjectFPS", projectFps );
sManager->setValue( "project", "VideoProjectHeight", projectHeight );
sManager->setValue( "project", "VideoProjectWidth", projectWidth);
sManager->commit();
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 );
return true;
}
......
......@@ -128,9 +128,9 @@ MetaDataWorker::metaDataAvailable()
}
else
{
const SettingValue *val = SettingsManager::getInstance()->getValue( "project", "VideoProjectFPS" );
Q_ASSERT_X( val != NULL, "MetaDataWorker", "Can't operate without a project FPS value ");
m_media->setFps( val->get().toDouble() );
QVariant val = SettingsManager::getInstance()->value( "project/VideoProjectFPS", 30, SettingsManager::XML );
Q_ASSERT_X( val.isNull() , "MetaDataWorker", "Can't operate without a project FPS value ");
m_media->setFps( val.toDouble() );
}
m_media->setLength( m_mediaPlayer->getLength() );
......
......@@ -75,22 +75,25 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
const SettingValue* val =
SettingsManager::getInstance()->getValue( "project", "ProjectName");
connect( val, SIGNAL( changed( QVariant) ), this, SLOT(projectNameChanged(QVariant) ) );
QVariant val =
SettingsManager::getInstance()->value( "project/ProjectName", unNamedProject, SettingsManager::XML );
#warning __LINE__ __FILE__ FIXME !!!!
//connect( val, SIGNAL( changed( QVariant) ), this, SLOT(projectNameChanged(QVariant) ) );
//Automatic save part :
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( autoSaveRequired() ) );
const SettingValue* autoSaveEnabled =
SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackup" );
connect( autoSaveEnabled, SIGNAL( changed( QVariant ) ),
this, SLOT( automaticSaveEnabledChanged( QVariant ) ), Qt::QueuedConnection );
const SettingValue* autoSaveInterval =
SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackupInterval" );
connect( autoSaveInterval, SIGNAL( changed( QVariant ) ),
this, SLOT( automaticSaveIntervalChanged(QVariant) ), Qt::QueuedConnection );
automaticSaveEnabledChanged( autoSaveEnabled->get() );
QVariant autoSaveEnabled =
SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::QSett );
#warning __LINE__ __FILE__ FIXME !!!!
//connect( autoSaveEnabled, SIGNAL( changed( QVariant ) ),
// this, SLOT( automaticSaveEnabledChanged( QVariant ) ), Qt::QueuedConnection );
QVariant autoSaveInterval =
SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::QSett );
#warning __LINE__ __FILE__ FIXME !!!!
//connect( autoSaveInterval, SIGNAL( changed( QVariant ) ),
// this, SLOT( automaticSaveIntervalChanged(QVariant) ), Qt::QueuedConnection );
automaticSaveEnabledChanged( autoSaveEnabled );
}
ProjectManager::~ProjectManager()
......@@ -164,7 +167,8 @@ void ProjectManager::loadProject( const QString& fileName )
parseProjectNode( root.firstChildElement( "project" ) );
connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadTimeline() ) );
Library::getInstance()->loadProject( root.firstChildElement( "medias" ) );
SettingsManager::getInstance()->loadSettings( "project", root.firstChildElement( "project" ) );
#warning FIXME
//SettingsManager::getInstance()->load( root.firstChildElement( "project" ) );
}
QString ProjectManager::acquireProjectFileName()
......@@ -218,8 +222,10 @@ void ProjectManager::__saveProject( const QString &fileName )
Library::getInstance()->saveProject( doc, rootNode );
MainWorkflow::getInstance()->saveProject( doc, rootNode );
SettingsManager::getInstance()->saveSettings( "project", doc, rootNode );
SettingsManager::getInstance()->saveSettings( "keyboard_shortcut", doc, rootNode );
#warning FIXME
//SettingsManager::getInstance()->saveSettings( "project", doc, rootNode );
#warning FIXME
//SettingsManager::getInstance()->saveSettings( "keyboard_shortcut", doc, rootNode );
doc.appendChild( rootNode );
......@@ -342,8 +348,8 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
if ( enabled == true )
{
const SettingValue* interval = SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackupInterval" );
m_timer->start( interval->get().toInt() * 1000 * 60 );
QVariant interval = SettingsManager::getInstance()->value( "global/AutomaticBackupInterval", 5, SettingsManager::QSett );
m_timer->start( interval.toInt() * 1000 * 60 );
}
else
m_timer->stop();
......@@ -351,9 +357,9 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
void ProjectManager::automaticSaveIntervalChanged( const QVariant& val )
{
const SettingValue* enabled = SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackup" );
QVariant enabled = SettingsManager::getInstance()->value( "global/AutomaticBackup", false, SettingsManager::QSett );
if ( enabled->get().toBool() == false )
if ( enabled.toBool() == false )
return ;
m_timer->start( val.toInt() * 1000 * 60 );
}
......
......@@ -160,17 +160,15 @@ WorkflowFileRenderer::getUnlockCallback()
quint32
WorkflowFileRenderer::width() const
{
const SettingValue *width = SettingsManager::getInstance()->getValue( "project",
"VideoProjectWidth" );
return width->get().toUInt();
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480, SettingsManager::XML );
return width.toUInt();
}
quint32
WorkflowFileRenderer::height() const
{
const SettingValue *height = SettingsManager::getInstance()->getValue( "project",
"VideoProjectHeight" );
return height->get().toUInt();
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, SettingsManager::XML );
return height.toUInt();
}
void
......
......@@ -348,25 +348,22 @@ void* WorkflowRenderer::getUnlockCallback()
quint32
WorkflowRenderer::width() const
{
const SettingValue *width = SettingsManager::getInstance()->getValue( "project",
"VideoProjectWidth" );
return width->get().toUInt();
QVariant width = SettingsManager::getInstance()->value( "project/VideoProjectWidth", 480, SettingsManager::XML );
return width.toUInt();
}
quint32
WorkflowRenderer::height() const
{
const SettingValue *height = SettingsManager::getInstance()->getValue( "project",
"VideoProjectHeight" );
return height->get().toUInt();
QVariant height = SettingsManager::getInstance()->value( "project/VideoProjectHeight", 300, SettingsManager::XML );
return height.toUInt();
}
float
WorkflowRenderer::outputFps() const
{
const SettingValue *outputFps = SettingsManager::getInstance()->getValue( "VLMC",
"VLMCOutPutFPS" );
return outputFps->get().toDouble();
QVariant outputFps = SettingsManager::getInstance()->value( "global/VLMCOutPutFPS", 30, SettingsManager::QSett );
return outputFps.toDouble();
}
bool
......
......@@ -31,11 +31,11 @@ VlmcDebug::VlmcDebug() : m_logFile( NULL )
//setup log level :
QStringList args = qApp->arguments();
if ( args.indexOf( QRegExp( "-vvv*" ) ) >= 0 )
SettingsManager::getInstance()->setValue( "private", "LogLevel", QtDebugMsg );
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtDebugMsg, SettingsManager::QSett );
else if ( args.contains( "-v" ) == true )
SettingsManager::getInstance()->setValue( "private", "LogLevel", QtWarningMsg );
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtWarningMsg, SettingsManager::QSett );
else
SettingsManager::getInstance()->setValue( "private", "LogLevel", QtCriticalMsg );
SettingsManager::getInstance()->setImmediateValue( "private/LogLevel", QtCriticalMsg, SettingsManager::QSett );
int pos = args.indexOf( QRegExp( "--logfile=.*" ) );
if ( pos > 0 )
......@@ -45,19 +45,18 @@ VlmcDebug::VlmcDebug() : m_logFile( NULL )
if ( logFile.length() <= 0 )
qWarning() << tr("Invalid value supplied for argument --logfile" );
else
SettingsManager::getInstance()->setValue( "private", "LogFile", logFile );
SettingsManager::getInstance()->setImmediateValue( "private/LogFile", logFile, SettingsManager::QSett );
}
//Yeah I just changed preferences, but I have to commit. Though I don't feel like a widget...
SettingsManager::getInstance()->commit();
const SettingValue* setVal = SettingsManager::getInstance()->getValue( "private", "LogFile" );
connect( setVal, SIGNAL( changed( QVariant ) ), this, SLOT( logFileChanged( const QVariant& ) ) );
QVariant setVal = SettingsManager::getInstance()->value( "private/LogFile", "log.vlmc", SettingsManager::QSett );
#warning FIXME
//connect( setVal, SIGNAL( changed( QVariant ) ), this, SLOT( logFileChanged( const QVariant& ) ) );
QObject::connect( qApp,
SIGNAL( aboutToQuit() ),
this,
SLOT( deleteLater() ) );
QString logFile = setVal->get().toString();
QString logFile = setVal.toString();
if ( logFile.isEmpty() == false )
{
m_logFile = new QFile( logFile );
......@@ -101,7 +100,7 @@ void VlmcDebug::vlmcMessageHandler( QtMsgType type, const char* msg )
VlmcDebug::getInstance()->m_logFile->write( "\n" );
}
if ( type != QtFatalMsg
&& type < SettingsManager::getInstance()->getValue( "private", "LogLevel" )->get().toInt() )
&& type < SettingsManager::getInstance()->value( "private/LogLevel", QtDebugMsg, SettingsManager::QSett ).toInt() )
return ;
switch ( type )
{
......
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