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

EffectInstanceWidget: Adding a Color widget.

parent 92455d70
......@@ -177,6 +177,7 @@ ELSE(NOT WITH_GUI)
Gui/preview/PreviewWidget.cpp
Gui/project/GuiProjectManager.cpp
Gui/settings/BoolWidget.cpp
Gui/settings/ColorWidget.cpp
Gui/settings/DoubleWidget.cpp
Gui/settings/DoubleSliderWidget.cpp
Gui/settings/IntWidget.cpp
......@@ -244,6 +245,7 @@ ELSE(NOT WITH_GUI)
Gui/preview/PreviewWidget.h
Gui/project/GuiProjectManager.h
Gui/settings/BoolWidget.h
Gui/settings/ColorWidget.h
Gui/settings/DoubleWidget.h
Gui/settings/DoubleSliderWidget.h
Gui/settings/ISettingsCategoryWidget.h
......
......@@ -23,6 +23,7 @@
#include "EffectInstanceWidget.h"
#include "BoolWidget.h"
#include "ColorWidget.h"
#include "DoubleSliderWidget.h"
#include "Effect.h"
#include "EffectInstance.h"
......@@ -82,6 +83,8 @@ EffectInstanceWidget::widgetFactory( EffectSettingValue *s )
return new BoolWidget( s, this );
case SettingValue::Double:
return new DoubleSliderWidget( s, this );
case SettingValue::Color:
return new ColorWidget( s, this );
default:
return NULL;
}
......
/*****************************************************************************
* ColorWidget.cpp: Handle Settings of type Color
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: 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
* 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 "ColorWidget.h"
#include "SettingValue.h"
#include <QColorDialog>
#include <QPushButton>
ColorWidget::ColorWidget( SettingValue *s, QWidget *parent ) :
m_setting( 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() );
}
QWidget*
ColorWidget::widget()
{
return m_button;
}
void
ColorWidget::save()
{
m_setting->set( m_color );
}
void
ColorWidget::changed( const QVariant &val )
{
m_button->setPalette( QPalette( val.value<QColor>() ) );
}
void
ColorWidget::buttonClicked()
{
QColor color = QColorDialog::getColor( m_color, NULL );
if ( color.isValid() == true )
{
m_color = color;
changed( color );
}
}
/*****************************************************************************
* ColorWidget.cpp: Handle Settings of type Color
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: 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
* 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 COLORWIDGET_H
#define COLORWIDGET_H
#include "ISettingsCategoryWidget.h"
#include <QColor>
class SettingValue;
class QPushButton;
class ColorWidget : public ISettingsCategoryWidget
{
Q_OBJECT
public:
ColorWidget( SettingValue *s, QWidget *parent = NULL );
QWidget* widget();
void save();
private slots:
virtual void changed( const QVariant& );
void buttonClicked();
private:
SettingValue *m_setting;
QPushButton *m_button;
QColor m_color;
};
#endif // COLORWIDGET_H
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