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

Adapted the settings to match the new SettingsManager API

Signed-off-by: default avatarHugo Beauzee-Luyssen <beauze.h@gmail.com>
parent cdfd07f3
......@@ -23,10 +23,10 @@
#include <QDebug>
#include "AudioProjectPreferences.h"
#include "SettingsManager.h"
AudioProjectPreferences::AudioProjectPreferences( QWidget *parent )
: PreferenceWidget( parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::XML )
{
m_ui.setupUi( this );
}
......@@ -36,8 +36,7 @@ AudioProjectPreferences::~AudioProjectPreferences() { }
void AudioProjectPreferences::load()
{
SettingsManager* setMan = SettingsManager::getInstance();
const QString& part = m_defaults ? "default" : m_settName;
int sampleRate = setMan->getValue( part, "AudioSampleRate" )->get().toInt();
int sampleRate = setMan->value( "project/AudioSampleRate", 0, m_type ).toInt();
m_ui.SampleRate->setValue( sampleRate );
return ;
......@@ -47,7 +46,7 @@ void AudioProjectPreferences::save()
{
SettingsManager* setMan = SettingsManager::getInstance();
QVariant sampleRate( m_ui.SampleRate->value() );
setMan->setValue( m_settName, "AudioSampleRate", sampleRate );
setMan->setImmediateValue( "project/AudioSampleRate", sampleRate, m_type );
return ;
}
......
......@@ -24,8 +24,10 @@
#define AUDIOPROJECTPREFERENCES_H
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "ui_AudioProjectPreferences.h"
class QWidget;
class AudioProjectPreferences : public PreferenceWidget
......@@ -40,6 +42,7 @@ class AudioProjectPreferences : public PreferenceWidget
virtual void changeEvent( QEvent *e );
private:
Ui::AudioProjectPreferences m_ui;
const SettingsManager::Type m_type;
};
#endif // AUDIOPROJECTPREFERENCES_H
......@@ -26,25 +26,26 @@
#include "KeyboardShortcutInput.h"
#include "SettingsManager.h"
KeyboardShortcut::KeyboardShortcut( QWidget* parent ) :
PreferenceWidget( parent )
KeyboardShortcut::KeyboardShortcut( QWidget* parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::QSett )
{
m_layout = new QFormLayout( this );
const SettingsPart* parts = SettingsManager::getInstance()->getConfigPart( "keyboard_shortcut" );
Q_ASSERT( parts != NULL );
// m_layout = new QFormLayout( this );
// const SettingsPart* parts = SettingsManager::getInstance()->getConfigPart( "keyboard_shortcut" );
// Q_ASSERT( parts != NULL );
SettingsPart::ConfigPair::const_iterator it = parts->m_data.begin();
SettingsPart::ConfigPair::const_iterator ite = parts->m_data.end();
while ( it != ite )
{
m_keySeq[it.key()] = new QKeySequence( it.value()->get().toString() );
KeyboardShortcutInput* ksi = new KeyboardShortcutInput( it.key(), m_keySeq[it.key()]->toString(), this );
m_layout->addRow( it.key(), ksi );
connect( ksi, SIGNAL( changed( const QString&, const QString& ) ),
this, SLOT( shortcutUpdated( const QString&, const QString& ) ) );
++it;
}
setLayout( m_layout );
// SettingsPart::ConfigPair::const_iterator it = parts->m_data.begin();
// SettingsPart::ConfigPair::const_iterator ite = parts->m_data.end();
// while ( it != ite )
// {
// m_keySeq[it.key()] = new QKeySequence( it.value()->get().toString() );
// KeyboardShortcutInput* ksi = new KeyboardShortcutInput( it.key(), m_keySeq[it.key()]->toString(), this );
// m_layout->addRow( it.key(), ksi );
// connect( ksi, SIGNAL( changed( const QString&, const QString& ) ),
// this, SLOT( shortcutUpdated( const QString&, const QString& ) ) );
// ++it;
// }
// setLayout( m_layout );
}
KeyboardShortcut::~KeyboardShortcut()
......@@ -61,5 +62,5 @@ void KeyboardShortcut::save()
void KeyboardShortcut::shortcutUpdated( const QString& name, const QString& value )
{
SettingsManager::getInstance()->setValue( "keyboard_shortcut", name, value );
SettingsManager::getInstance()->setImmediateValue( name, value, m_type );
}
......@@ -24,6 +24,7 @@
#define KEYBOARDSHORTCUT_H
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include <QFormLayout>
#include <QHash>
......@@ -47,6 +48,7 @@ class KeyboardShortcut : public PreferenceWidget
private:
QFormLayout* m_layout;
QHash<QString, QKeySequence*> m_keySeq;
const SettingsManager::Type m_type;
};
#endif // KEYBOARDSHORTCUT_H
......@@ -26,26 +26,14 @@
#include "PreferenceWidget.h"
PreferenceWidget::PreferenceWidget( QWidget* parent )
: QWidget( parent ),
m_defaults( false ),
m_settName( "" )
: QWidget( parent )
{
}
void PreferenceWidget::setDefaults( bool defaults )
{
m_defaults = defaults;
}
void PreferenceWidget::setName( const QString& name )
{
m_settName = name;
}
void PreferenceWidget::loadThemAll( const QString& part,
void
PreferenceWidget::loadThemAll( const QString& part,
bool defaults)
{
m_defaults = defaults;
m_settName = part;
load();
}
......@@ -34,16 +34,9 @@ class PreferenceWidget : public QWidget
PreferenceWidget( QWidget* parent = 0 );
virtual ~PreferenceWidget() {}
void setDefaults( bool defaults );
void setName( const QString& name );
virtual void load() = 0;
virtual void save() = 0;
protected:
bool m_defaults;
QString m_settName;
protected slots:
void loadThemAll( const QString& part = "default",
bool defaults = false );
......
......@@ -24,6 +24,7 @@
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "ProjectManager.h"
#include <QWidget>
//DEBUG
......@@ -31,10 +32,11 @@
//!DEBUG
ProjectPreferences::ProjectPreferences( QWidget* parent )
: PreferenceWidget( parent )
ProjectPreferences::ProjectPreferences( QWidget* parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::XML )
{
m_ui.setupUi( this );
m_ui.setupUi( this );
}
ProjectPreferences::~ProjectPreferences() { }
......@@ -42,8 +44,9 @@ ProjectPreferences::~ProjectPreferences() { }
void ProjectPreferences::load()
{
SettingsManager* settMan = SettingsManager::getInstance();
const QString& part = m_defaults ? "default" : m_settName;
QString Name = settMan->getValue( part, "ProjectName" )->get().toString();
QString Name = settMan->value( "project/ProjectName",
ProjectManager::unNamedProject,
m_type ).toString();
m_ui.ProjectNameLineEdit->setText( Name );
}
......@@ -53,7 +56,7 @@ void ProjectPreferences::save()
SettingsManager* settMan = SettingsManager::getInstance();
QVariant name( m_ui.ProjectNameLineEdit->text() );
settMan->setValue( m_settName, "ProjectName", name );
settMan->setImmediateValue( "project/ProjectName", name, m_type );
}
void ProjectPreferences::changeEvent( QEvent *e )
......
......@@ -23,8 +23,9 @@
#ifndef PROJECTPREFERENCES_H
#define PROJECTPREFERENCES_H
#include "ui_ProjectPreferences.h"
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "ui_ProjectPreferences.h"
class QWidget;
......@@ -39,7 +40,8 @@ class ProjectPreferences : public PreferenceWidget
protected:
virtual void changeEvent( QEvent *e );
private:
Ui::ProjectPreferences m_ui;
Ui::ProjectPreferences m_ui;
const SettingsManager::Type m_type;
};
#endif
......@@ -34,16 +34,14 @@
#include <QScrollArea>
#include <QHBoxLayout>
#include <QtDebug>
Settings::Settings( bool loadDefaults,
const QString& name,
QWidget* parent,
Settings::Settings( QWidget* parent,
Qt::WindowFlags f )
: QDialog( parent, f ),
m_currentWidget( NULL ),
m_defaults( loadDefaults ),
m_name( name )
: QDialog( parent, f ),
m_currentWidget( NULL )
{
setMinimumHeight( 400 );
setMinimumWidth( 600 );
......@@ -60,12 +58,8 @@ Settings::Settings( bool loadDefaults,
// Create the layout
setLayout( buildLayout() );
SettingsManager::getInstance()->addNewSettingsPart( m_name );
connect( m_panel, SIGNAL( changePanel( int ) ),
this, SLOT( switchWidget( int ) ) );
connect( SettingsManager::getInstance(), SIGNAL( settingsLoaded() ),
this, SLOT( load() ) );
}
Settings::~Settings()
......@@ -73,13 +67,11 @@ Settings::~Settings()
}
void Settings::addWidget( const QString& name,
PreferenceWidget* pWidget,
const QIcon& icon,
const QString& label )
PreferenceWidget* pWidget,
const QIcon& icon,
const QString& label )
{
connect( this, SIGNAL( loadSettings( const QString&, bool ) ) ,
pWidget, SLOT( loadThemAll( const QString&, bool ) ) );
connect( this, SIGNAL( loadSettings() ), pWidget, SLOT( loadThemAll() ) );
// We don't want the widget to be visible
pWidget->hide();
......@@ -97,16 +89,10 @@ void Settings::addWidget( const QString& name,
switchWidget( 0 );
}
void Settings::show( const QString& part )
void Settings::show()
{
if ( part == "default" )
m_defaults = true;
else
{
m_name = part;
m_defaults = false;
}
load();
qDebug() << "Settings::show";
emit loadSettings();
switchWidget( 0 );
QWidget::show();
}
......@@ -173,8 +159,6 @@ void Settings::buttonClicked( QAbstractButton* button )
for ( int i = 0; i < m_pWidgets.count(); ++i )
m_pWidgets.at( i )->save();
// then commit
SettingsManager::getInstance()->commit();
}
if ( hide == true ) setVisible( false );
}
......@@ -202,7 +186,3 @@ void Settings::switchWidget( int index )
m_configPanel->setWidget( pWidget );
}
void Settings::load()
{
emit loadSettings( m_name, m_defaults );
}
......@@ -24,6 +24,8 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include "SettingsManager.h"
#include <QDialog>
#include <QString>
#include <QList>
......@@ -43,9 +45,7 @@ class Settings : public QDialog
Q_DISABLE_COPY( Settings )
public:
Settings( bool loadDefaults = false,
const QString& name = "default",
QWidget* parent = 0,
Settings( QWidget* parent = 0,
Qt::WindowFlags f = 0 );
virtual ~Settings();
......@@ -53,7 +53,7 @@ class Settings : public QDialog
PreferenceWidget* pWidget,
const QIcon& icon,
const QString& label );
void show( const QString& part = "default" );
void show();
private:
inline QHBoxLayout* buildLayout();
......@@ -65,20 +65,16 @@ class Settings : public QDialog
PreferenceWidget* m_currentWidget;
Panel* m_panel;
QLabel* m_title;
bool m_defaults;
QString m_name;
QScrollArea* m_configPanel;
public slots:
void switchWidget( int index );
void load();
private slots:
void buttonClicked( QAbstractButton* button );
signals:
void loadSettings( const QString& part, bool defaults );
void loadSettings();
};
#endif // SETTINGS_H
......@@ -27,7 +27,8 @@
#include <QtDebug>
VLMCPreferences::VLMCPreferences( QWidget *parent )
: PreferenceWidget( parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::QSett )
{
m_ui.setupUi(this);
setAutomaticSaveLabelVisiblity( m_ui.automaticSave->isChecked() );
......@@ -53,12 +54,11 @@ void VLMCPreferences::setAutomaticSaveLabelVisiblity( bool visible )
void VLMCPreferences::load()
{
SettingsManager* settMan = SettingsManager::getInstance();
const QString& part = m_defaults ? "default" : m_settName;
QString outputFPS = settMan->getValue( part, "VLMCOutPutFPS" )->get().toString();
QString tracksNb = settMan->getValue( part, "VLMCTracksNb" )->get().toString();
bool autoSave = settMan->getValue( part, "AutomaticBackup" )->get().toBool();
QString autoSaveInterval = settMan->getValue( part, "AutomaticBackupInterval" )->get().toString();
QString outputFPS = settMan->value( "global/VLMCOutPutFPS", "30", m_type ).toString();
QString tracksNb = settMan->value( "global/VLMCTracksNb", "64", m_type ).toString();
bool autoSave = settMan->value( "global/AutomaticBackup", false, m_type ).toBool();
QString autoSaveInterval = settMan->value( "global/AutomaticBackupInterval", "5", m_type ).toString();
m_ui.outputFPS->setText( outputFPS );
m_ui.tracksNb->setText( tracksNb );
......@@ -75,11 +75,10 @@ void VLMCPreferences::save()
QVariant autoSave( m_ui.automaticSave->isChecked() );
QVariant autoSaveInterval( m_ui.automaticSaveInterval->text() );
settMan->setValue( m_settName, "VLMCOutPutFPS", outputFPS );
settMan->setValue( m_settName, "VLMCTracksNb", tracksNb );
settMan->setValue( m_settName, "AutomaticBackup", autoSave );
settMan->setValue( m_settName, "AutomaticBackupInterval", autoSaveInterval );
settMan->commit();
settMan->setImmediateValue( "global/VLMCOutPutFPS", outputFPS, m_type );
settMan->setImmediateValue( "global/VLMCTracksNb", tracksNb, m_type );
settMan->setImmediateValue( "global/AutomaticBackup", autoSave, m_type );
settMan->setImmediateValue( "global/AutomaticBackupInterval", autoSaveInterval, m_type );
}
void VLMCPreferences::changeEvent( QEvent *e )
......
......@@ -24,6 +24,7 @@
#define VLMCPREFERENCES_H
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "ui_VLMCPreferences.h"
#include <QSettings>
......@@ -47,7 +48,8 @@ class VLMCPreferences : public PreferenceWidget
void setAutomaticSaveLabelVisiblity( int visible );
private:
Ui::VLMCPreferences m_ui;
Ui::VLMCPreferences m_ui;
const SettingsManager::Type m_type;
};
#endif // VLMCPREFERENCES_H
......@@ -26,9 +26,10 @@
#include "SettingsManager.h"
VideoProjectPreferences::VideoProjectPreferences( QWidget *parent )
: PreferenceWidget( parent )
: PreferenceWidget( parent ),
m_type( SettingsManager::XML )
{
m_ui.setupUi( this );
m_ui.setupUi( this );
}
VideoProjectPreferences::~VideoProjectPreferences() { }
......@@ -36,10 +37,10 @@ VideoProjectPreferences::~VideoProjectPreferences() { }
void VideoProjectPreferences::load()
{
SettingsManager* setMan = SettingsManager::getInstance();
const QString& part = m_defaults ? "default" : m_settName;
int projectFps = setMan->getValue( part, "VideoProjectFPS" )->get().toInt();
int projectHeight = setMan->getValue( part, "VideoProjectHeight" )->get().toInt();
int projectWidth = setMan->getValue( part, "VideoProjectWidth" )->get().toInt();
int projectFps = setMan->value( "VideoProjectFPS", 30, m_type ).toInt();
int projectHeight = setMan->value( "VideoProjectHeight", 300, m_type ).toInt();
int projectWidth = setMan->value( "VideoProjectWidth", 480, m_type ).toInt();
m_ui.FPSSpinBox->setValue( projectFps );
m_ui.HeightSpinBox->setValue( projectHeight );
......@@ -53,9 +54,9 @@ void VideoProjectPreferences::save()
QVariant projectHeight( m_ui.HeightSpinBox->value() );
QVariant projectWidth( m_ui.WidthSpinBox->value() );
settMan->setValue( m_settName,"VideoProjectFPS", projectFps );
settMan->setValue( m_settName,"VideoProjectHeight", projectHeight );
settMan->setValue( m_settName,"VideoProjectWidth", projectWidth);
settMan->setImmediateValue( "VideoProjectFPS", projectFps, m_type );
settMan->setImmediateValue( "VideoProjectHeight", projectHeight, m_type );
settMan->setImmediateValue( "VideoProjectWidth", projectWidth, m_type );
return ;
}
......
......@@ -24,6 +24,7 @@
#define VIDEOPROJECTPREFERENCES_H
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "ui_VideoProjectPreferences.h"
class QWidget;
......@@ -40,6 +41,7 @@ class VideoProjectPreferences : public PreferenceWidget
virtual void changeEvent( QEvent *e );
private:
Ui::VideoProjectPreferences m_ui;
const SettingsManager::Type m_type;
};
#endif // VIDEOPROJECTPREFERENCES_H
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