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

Settings widgets: Refactoring.

parent 1ac27de1
......@@ -26,11 +26,9 @@
#include <QCheckBox>
BoolWidget::BoolWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_checkbox = new QCheckBox( parent );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
changed( s->get() );
}
......
......@@ -43,7 +43,6 @@ class BoolWidget : public ISettingsCategoryWidget
virtual void changed( const QVariant& );
private:
SettingValue *m_setting;
QCheckBox *m_checkbox;
};
......
......@@ -28,14 +28,12 @@
#include <QPushButton>
ColorWidget::ColorWidget( SettingValue *s, QWidget *parent ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_color = s->get().value<QColor>();
m_button = new QPushButton( parent );
m_button->setPalette( QPalette( m_color ) );
connect( m_button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
changed( s->get() );
}
......
......@@ -44,7 +44,6 @@ class ColorWidget : public ISettingsCategoryWidget
void buttonClicked();
private:
SettingValue *m_setting;
QPushButton *m_button;
QColor m_color;
......
......@@ -29,7 +29,7 @@
#include <QSlider>
DoubleSliderWidget::DoubleSliderWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_container = new QWidget( parent );
//Creating the slider
......@@ -48,8 +48,6 @@ DoubleSliderWidget::DoubleSliderWidget( SettingValue *s, QWidget *parent /*= NUL
m_slider->setMaximum( s->max().toDouble() * 100.0 );
m_slider->setMinimum( s->min().toDouble() * 100.0 );
changed ( s->get() );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
connect( m_slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) );
}
......
......@@ -40,7 +40,6 @@ class DoubleSliderWidget : public ISettingsCategoryWidget
void save();
private:
SettingValue *m_setting;
QSlider *m_slider;
QWidget *m_container;
QLabel *m_valueDisplayer;
......
......@@ -26,7 +26,7 @@
#include <QDoubleSpinBox>
DoubleWidget::DoubleWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_spinbox = new QDoubleSpinBox( parent );
changed( s->get() );
......
......@@ -43,7 +43,6 @@ class DoubleWidget : public ISettingsCategoryWidget
virtual void changed( const QVariant& );
private:
SettingValue *m_setting;
QDoubleSpinBox *m_spinbox;
};
......
......@@ -24,6 +24,8 @@
#ifndef ISETTINGSCATEGORYWIDGET_H
#define ISETTINGSCATEGORYWIDGET_H
#include "SettingValue.h"
class QVariant;
class QWidget;
......@@ -34,9 +36,20 @@ class ISettingsCategoryWidget : public QObject
Q_OBJECT
public:
virtual SettingValue *setting() { return m_setting; }
virtual QWidget* widget() = 0;
virtual void save() = 0;
protected:
ISettingsCategoryWidget( SettingValue* s ) : m_setting( s )
{
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
}
protected:
SettingValue *m_setting;
protected slots:
virtual void changed( const QVariant& ) = 0;
};
......
......@@ -26,11 +26,9 @@
#include <QSpinBox>
IntWidget::IntWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_spinbox = new QSpinBox( parent );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
if ( ( s->flags() & SettingValue::Clamped ) != 0 )
{
if ( s->min().isValid() )
......
......@@ -43,7 +43,6 @@ class IntWidget : public ISettingsCategoryWidget
virtual void changed( const QVariant& );
private:
SettingValue *m_setting;
QSpinBox *m_spinbox;
};
......
......@@ -25,7 +25,7 @@
#include "SettingValue.h"
KeyboardShortcut::KeyboardShortcut( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_input = new KeyboardShortcutInput( s->name(), s->get().toString(), parent );
}
......
......@@ -43,7 +43,6 @@ class KeyboardShortcut : public ISettingsCategoryWidget
virtual void changed( const QVariant& ){}
private:
SettingValue *m_setting;
KeyboardShortcutInput *m_input;
};
......
......@@ -34,7 +34,7 @@
#define TS_PREFIX "vlmc_"
LanguageWidget::LanguageWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_list = new QComboBox( parent );
QDir dir( ":/ts/", "*.qm", QDir::Name | QDir::IgnoreCase, QDir::Files );
......@@ -75,8 +75,6 @@ LanguageWidget::LanguageWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
// Add the system default option (auto-detection of the locale)
m_list->insertItem( 0, "System Locale (autodetect)", "default" );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
changed( s->get() );
}
......
......@@ -43,7 +43,6 @@ class LanguageWidget : public ISettingsCategoryWidget
virtual void changed( const QVariant& );
private:
SettingValue *m_setting;
QComboBox *m_list;
};
......
......@@ -29,7 +29,7 @@
#include <QPushButton>
PathWidget::PathWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_widget = new QWidget( parent );
QHBoxLayout *layout = new QHBoxLayout;
......@@ -40,8 +40,6 @@ PathWidget::PathWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
layout->addWidget( m_pushButton );
m_widget->setLayout( layout );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
changed( s->get() );
connect( m_pushButton, SIGNAL( clicked() ), this, SLOT( selectPathButtonPressed() ) );
}
......
......@@ -44,7 +44,6 @@ class PathWidget : public ISettingsCategoryWidget
virtual void changed( const QVariant& );
void selectPathButtonPressed();
private:
SettingValue *m_setting;
QLineEdit *m_lineEdit;
QPushButton *m_pushButton;
QWidget *m_widget;
......
......@@ -26,13 +26,11 @@
#include <QLineEdit>
StringWidget::StringWidget( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
ISettingsCategoryWidget( s )
{
m_lineEdit = new QLineEdit( parent );
if ( ( s->flags() & SettingValue::Password ) != 0 )
m_lineEdit->setEchoMode( QLineEdit::Password );
connect( s, SIGNAL( changed( const QVariant& ) ),
this, SLOT( changed( const QVariant& ) ) );
changed( s->get() );
}
......
......@@ -43,7 +43,6 @@ class StringWidget : public ISettingsCategoryWidget
virtual void changed( const QVariant& );
private:
SettingValue *m_setting;
QLineEdit *m_lineEdit;
};
......
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