[vlmc-devel] commit: EffectInstanceWidget: Adding a Color widget. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Aug 22 22:54:19 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sat Aug 21 23:33:43 2010 +0200| [ec2666b7d22db33dab20f091a7c07772f3020720] | committer: Hugo Beauzée-Luyssen 

EffectInstanceWidget: Adding a Color widget.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=ec2666b7d22db33dab20f091a7c07772f3020720
---

 src/CMakeLists.txt                             |    2 +
 src/Gui/effectsengine/EffectInstanceWidget.cpp |    3 +
 src/Gui/settings/ColorWidget.cpp               |   69 ++++++++++++++++++++++++
 src/Gui/settings/ColorWidget.h                 |   53 ++++++++++++++++++
 4 files changed, 127 insertions(+), 0 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f4e3d59..6ca9bde 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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
diff --git a/src/Gui/effectsengine/EffectInstanceWidget.cpp b/src/Gui/effectsengine/EffectInstanceWidget.cpp
index 42c0a51..1843c90 100644
--- a/src/Gui/effectsengine/EffectInstanceWidget.cpp
+++ b/src/Gui/effectsengine/EffectInstanceWidget.cpp
@@ -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;
     }
diff --git a/src/Gui/settings/ColorWidget.cpp b/src/Gui/settings/ColorWidget.cpp
new file mode 100644
index 0000000..6fd9cd6
--- /dev/null
+++ b/src/Gui/settings/ColorWidget.cpp
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * ColorWidget.cpp: Handle Settings of type Color
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at 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 );
+    }
+}
diff --git a/src/Gui/settings/ColorWidget.h b/src/Gui/settings/ColorWidget.h
new file mode 100644
index 0000000..f83e698
--- /dev/null
+++ b/src/Gui/settings/ColorWidget.h
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * ColorWidget.cpp: Handle Settings of type Color
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at 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



More information about the Vlmc-devel mailing list