Commit c281d1f5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Settings: Cleaning.

parent dc5db88a
/***************************************************************************** /*****************************************************************************
* Settings.cpp: generic preferences interface * Settings.cpp: Generic preferences interface
***************************************************************************** *****************************************************************************
* Copyright (C) 2008-2010 VideoLAN * Copyright (C) 2008-2010 VideoLAN
* *
* Authors: Clement CHAVANCE <kinder@vlmc.org> * Authors: Ludovic Fauvet <etix@l0cal.com>
* Ludovic Fauvet <etix@l0cal.com> * Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -27,17 +28,14 @@ ...@@ -27,17 +28,14 @@
#include "SettingsManager.h" #include "SettingsManager.h"
#include "Panel.h" #include "Panel.h"
#include <QAbstractButton>
#include <QApplication> #include <QApplication>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QAbstractButton>
#include <QIcon>
#include <QLabel> #include <QLabel>
#include <QScrollArea> #include <QScrollArea>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QStackedLayout> #include <QStackedLayout>
#include <QtDebug>
Settings::Settings( SettingsManager::Type type, QWidget *parent ) : Settings::Settings( SettingsManager::Type type, QWidget *parent ) :
QDialog( parent ), QDialog( parent ),
m_type( type ) m_type( type )
...@@ -50,14 +48,15 @@ Settings::Settings( SettingsManager::Type type, QWidget *parent ) : ...@@ -50,14 +48,15 @@ Settings::Settings( SettingsManager::Type type, QWidget *parent ) :
QDialogButtonBox::Cancel | QDialogButtonBox::Cancel |
QDialogButtonBox::Apply ); QDialogButtonBox::Apply );
connect( m_buttons, SIGNAL( clicked( QAbstractButton* ) ),
this, SLOT( buttonClicked( QAbstractButton* ) ) );
// Create the layout // Create the layout
buildLayout(); buildLayout();
connect( m_panel, SIGNAL( changePanel( int ) ), connect( m_panel, SIGNAL( changePanel( int ) ),
this, SLOT( switchWidget( int ) ) ); this, SLOT( switchWidget( int ) ) );
connect( m_buttons, SIGNAL( clicked( QAbstractButton* ) ),
this, SLOT( buttonClicked( QAbstractButton* ) ) );
connect( m_buttons, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( m_buttons, SIGNAL( rejected() ), this, SLOT( reject() ) );
} }
void void
...@@ -84,7 +83,7 @@ Settings::buildLayout() ...@@ -84,7 +83,7 @@ Settings::buildLayout()
m_panel->setMaximumWidth( 130 ); m_panel->setMaximumWidth( 130 );
// Create the master layout // Create the master layout
QGridLayout *mLayout = new QGridLayout( this ); QGridLayout *mLayout = new QGridLayout( this );
mLayout->addWidget( m_panel, 0, 0, 2, 1 ); mLayout->addWidget( m_panel, 0, 0, 2, 1 );
m_title = new QLabel( this ); m_title = new QLabel( this );
...@@ -104,35 +103,20 @@ Settings::buildLayout() ...@@ -104,35 +103,20 @@ Settings::buildLayout()
void void
Settings::buttonClicked( QAbstractButton *button ) Settings::buttonClicked( QAbstractButton *button )
{ {
bool save = false;
bool hide = false;
switch ( m_buttons->standardButton( button ) ) switch ( m_buttons->standardButton( button ) )
{ {
case QDialogButtonBox::Ok: case QDialogButtonBox::Ok:
save = true; case QDialogButtonBox::Apply:
hide = true; {
break; for ( int i = 0; i < m_stackedLayout->count(); ++i )
case QDialogButtonBox::Cancel: qobject_cast<PreferenceWidget*>( m_stackedLayout->widget( i ) )->save();
hide = true; //If we're handling vlmc preferences, save the value in the QSettings
break; if ( m_type == SettingsManager::Vlmc )
case QDialogButtonBox::Apply: SettingsManager::getInstance()->save();
save = true; }
break; default:
default : break ;
break;
}
if ( save == true )
{
// Ask each widget to save their state
for ( int i = 0; i < m_stackedLayout->count(); ++i )
qobject_cast<PreferenceWidget*>( m_stackedLayout->widget( 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 );
} }
void void
......
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