Commit 87d38694 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Adding a name for each settings. Cleaning up categories.

parent 56264f75
......@@ -23,9 +23,11 @@
#include "SettingValue.h"
#include <QtDebug>
SettingValue::SettingValue( const QVariant& defaultValue, const QString& desc ) :
SettingValue::SettingValue( const QVariant& defaultValue, const QString &name,
const QString& desc ) :
m_val( defaultValue ),
m_defaultVal( defaultValue ),
m_name( name ),
m_desc( desc )
{
}
......@@ -57,3 +59,9 @@ SettingValue::restoreDefault()
{
set( m_defaultVal );
}
const QString&
SettingValue::name() const
{
return m_name;
}
......@@ -43,7 +43,8 @@ class SettingValue : public QObject
* \param defaultValue The setting default value.
* \param desc The setting description
*/
SettingValue( const QVariant& defaultValue, const QString& desc );
SettingValue( const QVariant& defaultValue, const QString& name,
const QString& desc );
/**
* \brief setter for the m_val member
......@@ -64,12 +65,15 @@ class SettingValue : public QObject
* \brief Set the setting to its default value.
*/
void restoreDefault();
const QString &name() const;
private:
/**
* \brief the QVariant containingthe value of the settings
*/
QVariant m_val;
QVariant m_defaultVal;
QString m_name;
QString m_desc;
signals:
/**
......
......@@ -277,14 +277,15 @@ SettingsManager::commit( SettingsManager::Type type )
void
SettingsManager::createVar( const QString &key, const QVariant &defaultValue,
const QString &desc, SettingsManager::Type type /*= Vlmc*/ )
const QString &name, 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 ) );
m_classicSettings.insert( key, new SettingValue( defaultValue, name, desc ) );
else if ( type == Project && m_xmlSettings.contains( key ) == false )
m_xmlSettings.insert( key, new SettingValue( defaultValue, desc ) );
m_xmlSettings.insert( key, new SettingValue( defaultValue, name, desc ) );
else
Q_ASSERT_X( false, __FILE__, "creating an already created variable" );
}
......
......@@ -52,12 +52,12 @@ class QDomDocument;
#define VLMC_PROJECT_GET_BOOL( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->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 );
#define VLMC_CREATE_PROJECT_VAR( key, defaultValue, name, desc ) \
SettingsManager::getInstance()->createVar( key, defaultValue, QObject::tr( name ), \
QObject::tr(desc), SettingsManager::Project );
#define VLMC_CREATE_PREFERENCE( key, defaultValue, name, desc ) \
SettingsManager::getInstance()->createVar( key, defaultValue, QObject::tr( name ), \
QObject::tr(desc), SettingsManager::Vlmc );
class SettingsManager : public QObject, public Singleton<SettingsManager>
{
......@@ -84,7 +84,8 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
void createVar( const QString &key,
const QVariant &defaultValue,
const QString &desc, Type type = Vlmc );
const QString &name, const QString &desc,
Type type = Vlmc );
bool watchValue( const QString &key,
QObject* receiver,
const char *method,
......
......@@ -79,7 +79,7 @@ LanguagePreferences::~LanguagePreferences() {}
void LanguagePreferences::load()
{
QString lang = VLMC_GET_STRING( "global/VLMCLang" );
QString lang = VLMC_GET_STRING( "general/VLMCLang" );
int idx = m_ui.comboBoxLanguage->findData( lang );
if ( idx != -1 )
......
......@@ -172,26 +172,26 @@ void MainWindow::changeEvent( QEvent *e )
void
MainWindow::initVlmcPreferences()
{
VLMC_CREATE_PREFERENCE( "keyboard/defaultmode", "n", "Select mode" );
VLMC_CREATE_PREFERENCE( "keyboard/cutmode", "x", "Cut mode" );
VLMC_CREATE_PREFERENCE( "keyboard/mediapreview", "Ctrl+Return", "Media preview" );
VLMC_CREATE_PREFERENCE( "keyboard/renderpreview", "Space", "Render preview" );
VLMC_CREATE_PREFERENCE( "keyboard/defaultmode", "n", "Select mode", "Select the selection tool in the timeline" );
VLMC_CREATE_PREFERENCE( "keyboard/cutmode", "x", "Cut mode", "Select the cut/razor tool in the timeline" );
VLMC_CREATE_PREFERENCE( "keyboard/mediapreview", "Ctrl+Return", "Media preview", "Preview the selected media, or pause the current preview" );
VLMC_CREATE_PREFERENCE( "keyboard/renderpreview", "Space", "Render preview", "Preview the project, or pause the current preview" );
//A bit nasty, but we better use what Qt's providing as default shortcut
VLMC_CREATE_PREFERENCE( "keyboard/undo", QKeySequence( QKeySequence::Undo ).toString().toLocal8Bit(), "Undo" );
VLMC_CREATE_PREFERENCE( "keyboard/redo", QKeySequence( QKeySequence::Redo ).toString().toLocal8Bit(), "Redo" );
VLMC_CREATE_PREFERENCE( "keyboard/help", QKeySequence( QKeySequence::HelpContents ).toString().toLocal8Bit(), "Help" );
VLMC_CREATE_PREFERENCE( "keyboard/quit", "Ctrl+Q", "Quit" );
VLMC_CREATE_PREFERENCE( "keyboard/preferences", "Alt+P", "Preferences" );
VLMC_CREATE_PREFERENCE( "keyboard/fullscreen", "F", "Fullscreen" );
VLMC_CREATE_PREFERENCE( "keyboard/newproject", QKeySequence( QKeySequence::New ).toString().toLocal8Bit(), "New project" );
VLMC_CREATE_PREFERENCE( "keyboard/openproject", QKeySequence( QKeySequence::Open ).toString().toLocal8Bit(), "Open a project" );
VLMC_CREATE_PREFERENCE( "keyboard/save", QKeySequence( QKeySequence::Save ).toString().toLocal8Bit(), "Save" );
VLMC_CREATE_PREFERENCE( "keyboard/saveas", "Ctrl+Shift+S", "Save as" );
VLMC_CREATE_PREFERENCE( "keyboard/closeproject", QKeySequence( QKeySequence::Close ).toString().toLocal8Bit(), "Close the project" );
VLMC_CREATE_PREFERENCE( "keyboard/importmedia", "Ctrl+I", "Import media" );
VLMC_CREATE_PREFERENCE( "keyboard/renderproject", "Ctrl+R", "Render the project" );
VLMC_CREATE_PREFERENCE( "global/VLMCLang", "en_US", "The VLMC's UI language" );
VLMC_CREATE_PREFERENCE( "keyboard/undo", QKeySequence( QKeySequence::Undo ).toString().toLocal8Bit(), "Undo", "Undo the last action" );
VLMC_CREATE_PREFERENCE( "keyboard/redo", QKeySequence( QKeySequence::Redo ).toString().toLocal8Bit(), "Redo", "Redo the last action" );
VLMC_CREATE_PREFERENCE( "keyboard/help", QKeySequence( QKeySequence::HelpContents ).toString().toLocal8Bit(), "Help", "Toggle the help page" );
VLMC_CREATE_PREFERENCE( "keyboard/quit", "Ctrl+Q", "Quit", "Quit VLMC" );
VLMC_CREATE_PREFERENCE( "keyboard/preferences", "Alt+P", "Preferences", "Open VLMC preferences" );
VLMC_CREATE_PREFERENCE( "keyboard/fullscreen", "F", "Fullscreen", "Switch to fullscreen mode" );
VLMC_CREATE_PREFERENCE( "keyboard/newproject", QKeySequence( QKeySequence::New ).toString().toLocal8Bit(), "New project", "Open the new project wizzard" );
VLMC_CREATE_PREFERENCE( "keyboard/openproject", QKeySequence( QKeySequence::Open ).toString().toLocal8Bit(), "Open a project", "Open an existing project" );
VLMC_CREATE_PREFERENCE( "keyboard/save", QKeySequence( QKeySequence::Save ).toString().toLocal8Bit(), "Save", "Save the current project" );
VLMC_CREATE_PREFERENCE( "keyboard/saveas", "Ctrl+Shift+S", "Save as", "Save the current project to a new file" );
VLMC_CREATE_PREFERENCE( "keyboard/closeproject", QKeySequence( QKeySequence::Close ).toString().toLocal8Bit(), "Close the project", "Close the current project" );
VLMC_CREATE_PREFERENCE( "keyboard/importmedia", "Ctrl+I", "Import media", "Open the import window" );
VLMC_CREATE_PREFERENCE( "keyboard/renderproject", "Ctrl+R", "Render the project", "Render the project to a file" );
VLMC_CREATE_PREFERENCE( "global/VLMCLang", "en_US", "Langage", "The VLMC's UI language" );
}
void MainWindow::setupLibrary()
......
......@@ -34,9 +34,9 @@ RendererSettings::RendererSettings()
m_ui.setupUi( this );
connect( m_ui.outputFileNameButton, SIGNAL(clicked() ),
this, SLOT(selectOutputFileName() ) );
m_ui.width->setValue( VLMC_GET_INT( "project/VideoProjectWidth" ) );
m_ui.height->setValue( VLMC_GET_INT( "project/VideoProjectHeight" ) );
m_ui.fps->setValue( VLMC_GET_DOUBLE( "global/VLMCOutputFPS" ) );
m_ui.width->setValue( VLMC_GET_INT( "video/VideoProjectWidth" ) );
m_ui.height->setValue( VLMC_GET_INT( "video/VideoProjectHeight" ) );
m_ui.fps->setValue( VLMC_GET_DOUBLE( "video/VLMCOutputFPS" ) );
}
void
......
......@@ -35,7 +35,7 @@ AudioProjectPreferences::~AudioProjectPreferences() { }
void AudioProjectPreferences::load()
{
int sampleRate = VLMC_PROJECT_GET_INT( "project/AudioSampleRate" );
int sampleRate = VLMC_PROJECT_GET_INT( "audio/AudioSampleRate" );
m_ui.SampleRate->setValue( sampleRate );
return ;
}
......@@ -44,7 +44,7 @@ void AudioProjectPreferences::save()
{
SettingsManager* setMan = SettingsManager::getInstance();
QVariant sampleRate( m_ui.SampleRate->value() );
setMan->setImmediateValue( "project/AudioSampleRate", sampleRate, m_type );
setMan->setImmediateValue( "audio/AudioSampleRate", sampleRate, m_type );
return ;
}
......
......@@ -39,7 +39,7 @@ ProjectPreferences::~ProjectPreferences() { }
void ProjectPreferences::load()
{
QString Name = VLMC_PROJECT_GET_STRING( "project/ProjectName" );
QString Name = VLMC_PROJECT_GET_STRING( "general/ProjectName" );
m_ui.ProjectNameLineEdit->setText( Name );
}
......@@ -49,7 +49,7 @@ void ProjectPreferences::save()
SettingsManager* settMan = SettingsManager::getInstance();
QVariant name( m_ui.ProjectNameLineEdit->text() );
settMan->setImmediateValue( "project/ProjectName", name, m_type );
settMan->setImmediateValue( "general/ProjectName", name, m_type );
}
void ProjectPreferences::changeEvent( QEvent *e )
......
......@@ -53,8 +53,8 @@ void VLMCPreferences::setAutomaticSaveLabelVisiblity( bool visible )
void VLMCPreferences::load()
{
bool autoSave = VLMC_GET_BOOL( "global/AutomaticBackup" );
QString autoSaveInterval = VLMC_GET_STRING( "global/AutomaticBackupInterval" );
bool autoSave = VLMC_GET_BOOL( "general/AutomaticBackup" );
QString autoSaveInterval = VLMC_GET_STRING( "general/AutomaticBackupInterval" );
m_ui.automaticSave->setChecked( autoSave );
m_ui.automaticSaveInterval->setText( autoSaveInterval );
......@@ -67,8 +67,8 @@ void VLMCPreferences::save()
QVariant autoSave( m_ui.automaticSave->isChecked() );
QVariant autoSaveInterval( m_ui.automaticSaveInterval->text() );
settMan->setImmediateValue( "global/AutomaticBackup", autoSave, m_type );
settMan->setImmediateValue( "global/AutomaticBackupInterval", autoSaveInterval, m_type );
settMan->setImmediateValue( "general/AutomaticBackup", autoSave, m_type );
settMan->setImmediateValue( "general/AutomaticBackupInterval", autoSaveInterval, m_type );
}
void VLMCPreferences::changeEvent( QEvent *e )
......
......@@ -36,10 +36,10 @@ VideoProjectPreferences::~VideoProjectPreferences() { }
void VideoProjectPreferences::load()
{
int projectWidth = VLMC_PROJECT_GET_INT( "project/VideoProjectWidth" );
int projectHeight = VLMC_PROJECT_GET_INT( "project/VideoProjectHeight" );
int projectWidth = VLMC_PROJECT_GET_INT( "video/VideoProjectWidth" );
int projectHeight = VLMC_PROJECT_GET_INT( "video/VideoProjectHeight" );
//FIXME: fps is a double value
int projectFps = VLMC_PROJECT_GET_INT( "global/VLMCOutputFPS" );
int projectFps = VLMC_PROJECT_GET_INT( "video/VLMCOutputFPS" );
m_ui.FPSSpinBox->setValue( projectFps );
m_ui.HeightSpinBox->setValue( projectHeight );
......@@ -53,9 +53,9 @@ void VideoProjectPreferences::save()
QVariant projectHeight( m_ui.HeightSpinBox->value() );
QVariant projectWidth( m_ui.WidthSpinBox->value() );
settMan->setImmediateValue( "global/VLMCOutputFPS", projectFps, m_type );
settMan->setImmediateValue( "project/VideoProjectHeight", projectHeight, m_type );
settMan->setImmediateValue( "project/VideoProjectWidth", projectWidth, m_type );
settMan->setImmediateValue( "video/VLMCOutputFPS", projectFps, m_type );
settMan->setImmediateValue( "video/VideoProjectHeight", projectHeight, m_type );
settMan->setImmediateValue( "video/VideoProjectWidth", projectWidth, m_type );
return ;
}
......
......@@ -37,7 +37,7 @@ TracksRuler::TracksRuler( TracksView* tracksView, QWidget* parent )
//TODO We should really get that from the
// workflow and not directly from the settings.
m_fps = qRound( VLMC_PROJECT_GET_DOUBLE( "global/VLMCOutputFPS" ) );
m_fps = qRound( VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) );
m_factor = 1;
m_scale = 3;
......
......@@ -54,7 +54,7 @@ void GeneralPage::initializePage()
ui.lineEditName->setText( projectName );
//fetching the global workspace path
QString workspacePath = VLMC_PROJECT_GET_STRING( "global/VLMCWorkspace" );
QString workspacePath = VLMC_PROJECT_GET_STRING( "general/VLMCWorkspace" );
ui.lineEditWorkspace->setText( workspacePath );
updateProjectLocation();
......
......@@ -139,7 +139,7 @@ MetaDataWorker::metaDataAvailable()
}
else
{
double fps = VLMC_GET_DOUBLE( "project/VideoProjectFPS" );
double fps = VLMC_GET_DOUBLE( "video/VideoProjectFPS" );
m_media->setFps( fps );
}
m_media->setLength( m_mediaPlayer->getLength() );
......
......@@ -74,13 +74,13 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
VLMC_CREATE_PROJECT_VAR( "global/VLMCOutputFPS", 29.97, "Output video FPS" );
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( "project/AudioSampleRate", 0, "The project audio samplerate" );
VLMC_CREATE_PROJECT_VAR( "global/VLMCWorkspace", "", "The place where all project's videos will be stored" );
VLMC_CREATE_PROJECT_VAR( "video/VLMCOutputFPS", 29.97, "Output video FPS", "Frame Per Second used when previewing and rendering the project" );
VLMC_CREATE_PROJECT_VAR( "video/VideoProjectWidth", 480, "Video width", "Width resolution of the output video" );
VLMC_CREATE_PROJECT_VAR( "video/VideoProjectHeight", 300, "Video height", "Height resolution of the output video" );
VLMC_CREATE_PROJECT_VAR( "audio/AudioSampleRate", 0, "Audio samplerate", "Output project audio samplerate" );
VLMC_CREATE_PROJECT_VAR( "general/VLMCWorkspace", QDir::homePath(), "Workspace location", "The place where all project's videos will be stored" );
VLMC_CREATE_PROJECT_VAR( "project/ProjectName", unNamedProject, "The project name" );
VLMC_CREATE_PROJECT_VAR( "general/ProjectName", unNamedProject, "Project name", "The project name" );
SettingsManager::getInstance()->watchValue( "project/ProjectName", this,
SLOT(projectNameChanged(QVariant) ),
SettingsManager::Project );
......@@ -88,19 +88,20 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
//Automatic save part :
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( autoSaveRequired() ) );
VLMC_CREATE_PREFERENCE( "global/AutomaticBackup", false, "When this option is activated,"
"vlmc will automatically save your project at a specified interval" );
VLMC_CREATE_PREFERENCE( "general/AutomaticBackup", false, "Automatic save",
"When this option is activated,"
"VLMC will automatically save your project at a specified interval" );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackup", this,
SLOT( automaticSaveEnabledChanged(QVariant) ),
SettingsManager::Vlmc,
Qt::QueuedConnection );
VLMC_CREATE_PREFERENCE( "global/AutomaticBackupInterval", 5, "This is the interval that"
"vlmc will wait between two automatic save" );
VLMC_CREATE_PREFERENCE( "general/AutomaticBackupInterval", 5, "Automatic save interval",
"This is the interval that VLMC will wait between two automatic save" );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackupInterval", this,
SLOT( automaticSaveIntervalChanged(QVariant) ),
SettingsManager::Vlmc,
Qt::QueuedConnection );
automaticSaveEnabledChanged( VLMC_GET_BOOL( "global/AutomaticBackup" ) );
automaticSaveEnabledChanged( VLMC_GET_BOOL( "general/AutomaticBackup" ) );
}
ProjectManager::~ProjectManager()
......@@ -353,7 +354,7 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
if ( enabled == true )
{
int interval = VLMC_GET_INT( "global/AutomaticBackupInterval" );
int interval = VLMC_GET_INT( "general/AutomaticBackupInterval" );
m_timer->start( interval * 1000 * 60 );
}
else
......@@ -362,7 +363,7 @@ void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
void ProjectManager::automaticSaveIntervalChanged( const QVariant& val )
{
bool enabled = VLMC_GET_BOOL( "global/AutomaticBackup" );
bool enabled = VLMC_GET_BOOL( "general/AutomaticBackup" );
if ( enabled == false )
return ;
......
......@@ -160,13 +160,13 @@ WorkflowFileRenderer::getUnlockCallback()
quint32
WorkflowFileRenderer::width() const
{
return VLMC_GET_UINT( "project/VideoProjectWidth" );
return VLMC_GET_UINT( "video/VideoProjectWidth" );
}
quint32
WorkflowFileRenderer::height() const
{
return VLMC_GET_UINT( "project/VideoProjectHeight" );
return VLMC_GET_UINT( "video/VideoProjectHeight" );
}
void
......
......@@ -348,19 +348,19 @@ void* WorkflowRenderer::getUnlockCallback()
quint32
WorkflowRenderer::width() const
{
return VLMC_GET_UINT( "project/VideoProjectWidth" );
return VLMC_GET_UINT( "video/VideoProjectWidth" );
}
quint32
WorkflowRenderer::height() const
{
return VLMC_GET_UINT( "project/VideoProjectHeight" );
return VLMC_GET_UINT( "video/VideoProjectHeight" );
}
float
WorkflowRenderer::outputFps() const
{
return VLMC_GET_DOUBLE( "global/VLMCOutPutFPS" );
return VLMC_GET_DOUBLE( "video/VLMCOutPutFPS" );
}
bool
......
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