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
*
* Authors: Clement CHAVANCE <kinder@vlmc.org>
* Ludovic Fauvet <etix@l0cal.com>
* Authors: Ludovic Fauvet <etix@l0cal.com>
* Hugo Beauzée-Luyssen <beauze.h@gmail.com>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -27,17 +28,14 @@
#include "SettingsManager.h"
#include "Panel.h"
#include <QAbstractButton>
#include <QApplication>
#include <QDialogButtonBox>
#include <QAbstractButton>
#include <QIcon>
#include <QLabel>
#include <QScrollArea>
#include <QHBoxLayout>
#include <QStackedLayout>
#include <QtDebug>
Settings::Settings( SettingsManager::Type type, QWidget *parent ) :
QDialog( parent ),
m_type( type )
......@@ -50,14 +48,15 @@ Settings::Settings( SettingsManager::Type type, QWidget *parent ) :
QDialogButtonBox::Cancel |
QDialogButtonBox::Apply );
connect( m_buttons, SIGNAL( clicked( QAbstractButton* ) ),
this, SLOT( buttonClicked( QAbstractButton* ) ) );
// Create the layout
buildLayout();
connect( m_panel, SIGNAL( changePanel( 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
......@@ -104,35 +103,20 @@ Settings::buildLayout()
void
Settings::buttonClicked( QAbstractButton *button )
{
bool save = false;
bool hide = false;
switch ( m_buttons->standardButton( button ) )
{
case QDialogButtonBox::Ok:
save = true;
hide = true;
break;
case QDialogButtonBox::Cancel:
hide = true;
break;
case QDialogButtonBox::Apply:
save = true;
break;
default :
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 );
default:
break ;
}
}
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