Commit 2b830399 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Preferences: Boolean value widget are autogenerated.

parent 979db9ad
......@@ -43,6 +43,7 @@ SET(VLMC_SRCS
Gui/library/MediaListViewController.cpp
Gui/library/StackViewController.cpp
Gui/library/StackViewNavController.cpp
Gui/settings/BoolWidget.cpp
Gui/settings/DoubleWidget.cpp
Gui/settings/IntWidget.cpp
Gui/settings/KeyboardShortcut.cpp
......@@ -129,6 +130,7 @@ SET (VLMC_HDRS
Gui/MainWindow.h
Gui/PreviewRuler.h
Gui/PreviewWidget.h
Gui/settings/BoolWidget.h
Gui/settings/DoubleWidget.h
Gui/settings/IntWidget.h
Gui/settings/ISettingsCategorieWidget.h
......
/*****************************************************************************
* BoolWidget.cpp Handle boolean settings.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "BoolWidget.h"
#include "SettingValue.h"
#include <QCheckBox>
BoolWidget::BoolWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
{
m_checkbox = new QCheckBox( parent );
m_checkbox->setChecked( s->get().toBool() );
}
QWidget*
BoolWidget::widget()
{
return m_checkbox;
}
void
BoolWidget::save()
{
m_setting->set( m_checkbox->isChecked() );
}
/*****************************************************************************
* BoolWidget.h Handle boolean settings.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef BOOLWIDGET_H
#define BOOLWIDGET_H
#include "ISettingsCategorieWidget.h"
#include <stddef.h>
class SettingValue;
class QCheckBox;
class BoolWidget : public ISettingsCategorieWidget
{
public:
BoolWidget( SettingValue *s, QWidget *parent = NULL );
QWidget* widget();
void save();
private:
SettingValue *m_setting;
QCheckBox *m_checkbox;
};
#endif // BOOLWIDGET_H
......@@ -29,7 +29,7 @@ DoubleWidget::DoubleWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
{
m_spinbox = new QDoubleSpinBox( parent );
m_spinbox->setValue( s->get().toInt() );
m_spinbox->setValue( s->get().toDouble() );
}
QWidget*
......
......@@ -26,11 +26,12 @@
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "BoolWidget.h"
#include "DoubleWidget.h"
#include "IntWidget.h"
#include "KeyboardShortcut.h"
#include "LanguageWidget.h"
#include "StringWidget.h"
#include "IntWidget.h"
#include "DoubleWidget.h"
#include <QFormLayout>
#include <QtDebug>
......@@ -48,13 +49,7 @@ PreferenceWidget::PreferenceWidget( const QString &categorie, SettingsManager::T
foreach ( SettingValue* s, settings.values() )
{
ISettingsCategorieWidget *widget = widgetFactory( s );
if ( widget == NULL )
layout->addRow( s->name(), new QLabel( s->description() ) );
else
{
layout->addRow( s->name(), widget->widget() );
m_settings.push_back( widget );
}
layout->addRow( s->name(), new QLabel( s->description() ) );
}
setLayout( layout );
......@@ -75,8 +70,8 @@ PreferenceWidget::widgetFactory( SettingValue *s )
return new IntWidget( s, this );
case SettingValue::Double:
return new DoubleWidget( s, this );
default:
return NULL;
case SettingValue::Bool:
return new BoolWidget( s, this );
}
}
......
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