Commit d0570b53 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Preferences are now loaded on starting

parent 15348a09
......@@ -76,12 +76,12 @@ MainWindow::MainWindow( QWidget *parent ) :
//VLC Instance:
LibVLCpp::Instance::getInstance( this );
//Preferences
initVlmcPreferences();
//Creating the project manager first (so it can create all the project variables)
ProjectManager::getInstance();
//Preferences
initVlmcPreferences();
// GUI
DockWidgetManager::instance( this )->setMainWindow( this );
createGlobalPreferences();
......@@ -191,6 +191,22 @@ MainWindow::initVlmcPreferences()
CREATE_MENU_SHORTCUT( "keyboard/renderproject", "Ctrl+R", "Render the project", "Render the project to a file", actionRender );
VLMC_CREATE_PREFERENCE_LANGUAGE( "general/VLMCLang", "en_US", "Langage", "The VLMC's UI language" );
//Load saved preferences :
loadVlmcPreferences( "keyboard" );
loadVlmcPreferences( "general" );
}
void
MainWindow::loadVlmcPreferences( const QString &subPart )
{
QSettings s;
s.beginGroup( subPart );
foreach ( QString key, s.allKeys() )
{
SettingsManager::getInstance()->setValue( subPart + "/" + key, s.value( key ),
SettingsManager::Vlmc );
}
}
#undef CREATE_MENU_SHORTCUT
......@@ -343,7 +359,7 @@ void MainWindow::initializeDockWidgets( void )
void MainWindow::createGlobalPreferences()
{
m_globalPreferences = new Settings( this );
m_globalPreferences = new Settings( SettingsManager::Vlmc, this );
m_globalPreferences->addCategorie( "general", SettingsManager::Vlmc,
QIcon( ":/images/images/vlmc.png" ),
tr ( "VLMC settings" ) );
......@@ -354,7 +370,7 @@ void MainWindow::createGlobalPreferences()
void MainWindow::createProjectPreferences()
{
m_projectPreferences = new Settings( this );
m_projectPreferences = new Settings( SettingsManager::Project, this );
m_projectPreferences->addCategorie( "general", SettingsManager::Project,
QIcon( ":/images/images/vlmc.png" ),
tr ( "Project settings" ) );
......
......@@ -66,6 +66,7 @@ private:
void createGlobalPreferences();
void createProjectPreferences();
void initVlmcPreferences();
void loadVlmcPreferences( const QString& subPart );
#ifdef WITH_CRASHBUTTON
void setupCrashTester();
#endif
......
......@@ -38,10 +38,10 @@
Settings::Settings( QWidget* parent,
Qt::WindowFlags f )
: QDialog( parent, f ),
m_currentWidget( NULL )
Settings::Settings( SettingsManager::Type type, QWidget* parent, Qt::WindowFlags f ) :
QDialog( parent, f ),
m_currentWidget( NULL ),
m_type( type )
{
setMinimumHeight( 400 );
setMinimumWidth( 600 );
......@@ -150,7 +150,9 @@ void Settings::buttonClicked( QAbstractButton* button )
// Ask each widget to save their state
for ( int i = 0; i < m_pWidgets.count(); ++i )
m_pWidgets.at( i )->save();
//If we're handling vlmc preferences, save the value in the QSettings
if ( m_type == SettingsManager::Vlmc )
SettingsManager::getInstance()->save();
}
if ( hide == true )
setVisible( false );
......
......@@ -45,8 +45,7 @@ class Settings : public QDialog
Q_DISABLE_COPY( Settings )
public:
Settings( QWidget* parent = 0,
Qt::WindowFlags f = 0 );
Settings( SettingsManager::Type type, QWidget* parent = 0, Qt::WindowFlags f = 0 );
virtual ~Settings();
void addCategorie( const QString& name,
......@@ -65,6 +64,7 @@ class Settings : public QDialog
Panel* m_panel;
QLabel* m_title;
QScrollArea* m_configPanel;
SettingsManager::Type m_type;
public slots:
void switchWidget( int index );
......
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