Commit 6e58f38a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Preferences: Int settings widgets are now autogenerated

parent e698ba98
......@@ -43,6 +43,7 @@ SET(VLMC_SRCS
Gui/library/MediaListViewController.cpp
Gui/library/StackViewController.cpp
Gui/library/StackViewNavController.cpp
Gui/settings/IntWidget.cpp
Gui/settings/KeyboardShortcut.cpp
Gui/settings/KeyboardShortcutInput.cpp
Gui/settings/LanguageWidget.cpp
......@@ -127,6 +128,7 @@ SET (VLMC_HDRS
Gui/MainWindow.h
Gui/PreviewRuler.h
Gui/PreviewWidget.h
Gui/settings/IntWidget.h
Gui/settings/ISettingsCategorieWidget.h
Gui/settings/KeyboardShortcut.h
Gui/settings/KeyboardShortcutInput.h
......
/*****************************************************************************
* IntWidget.cpp Handle integer 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 "IntWidget.h"
#include "SettingValue.h"
#include <QSpinBox>
IntWidget::IntWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
{
m_lineEdit = new QSpinBox( parent );
m_lineEdit->setValue( s->get().toInt() );
}
QWidget*
IntWidget::widget()
{
return m_lineEdit;
}
void
IntWidget::save()
{
m_setting->set( m_lineEdit->value() );
}
/*****************************************************************************
* IntWidget.h Handle integer 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 INTWIDGET_H
#define INTWIDGET_H
#include "ISettingsCategorieWidget.h"
#include <stddef.h>
class SettingValue;
class QSpinBox;
class IntWidget : public ISettingsCategorieWidget
{
public:
IntWidget( SettingValue *s, QWidget *parent = NULL );
QWidget* widget();
void save();
private:
SettingValue *m_setting;
QSpinBox *m_lineEdit;
};
#endif // INTWIDGET_H
......@@ -29,6 +29,7 @@
#include "KeyboardShortcut.h"
#include "LanguageWidget.h"
#include "StringWidget.h"
#include "IntWidget.h"
#include <QFormLayout>
#include <QtDebug>
......@@ -69,6 +70,8 @@ PreferenceWidget::widgetFactory( SettingValue *s )
return new LanguageWidget( s, this );
case SettingValue::String:
return new StringWidget( s, this );
case SettingValue::Int:
return new IntWidget( s, this );
default:
return NULL;
}
......
/*****************************************************************************
* StringWidget: Handle text settings.
* StringWidget.h: Handle text settings.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
......
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