00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (c) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00004 * Copyright (c) 2010 Arjen Hiemstra <ahiemstra@heimr.nl> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 00022 #include "colorpropertywidgetitem.h" 00023 00024 #include <QtGui/QColor> 00025 #include <KColorButton> 00026 00027 #include <core/gluonvarianttypes.h> 00028 00029 REGISTER_PROPERTYWIDGETITEM( GluonCreator, ColorPropertyWidgetItem ) 00030 00031 using namespace GluonCreator; 00032 00033 class ColorPropertyWidgetItem::ColorPropertyWidgetItemPrivate 00034 { 00035 public: 00036 ColorPropertyWidgetItemPrivate() { } 00037 00038 KColorButton* button; 00039 }; 00040 00041 ColorPropertyWidgetItem::ColorPropertyWidgetItem( QWidget* parent, Qt::WindowFlags f ): PropertyWidgetItem( parent, f ) 00042 { 00043 d = new ColorPropertyWidgetItemPrivate; 00044 00045 d->button = new KColorButton( this ); 00046 connect( d->button, SIGNAL( changed( const QColor& ) ), this, SLOT( colorValuechanged( const QColor& ) ) ); 00047 setEditWidget( d->button ); 00048 } 00049 00050 ColorPropertyWidgetItem::~ColorPropertyWidgetItem() 00051 { 00052 delete d; 00053 } 00054 00055 QStringList 00056 ColorPropertyWidgetItem::supportedDataTypes() const 00057 { 00058 QStringList supportedTypes; 00059 supportedTypes.append( "QColor" ); 00060 return supportedTypes; 00061 } 00062 00063 PropertyWidgetItem* 00064 ColorPropertyWidgetItem::instantiate() 00065 { 00066 return new ColorPropertyWidgetItem(); 00067 } 00068 00069 void 00070 ColorPropertyWidgetItem::setEditValue( const QVariant& value ) 00071 { 00072 QColor color = value.value<QColor>(); 00073 d->button->setColor( color ); 00074 } 00075 00076 void 00077 ColorPropertyWidgetItem::colorValuechanged( const QColor& value ) 00078 { 00079 PropertyWidgetItem::valueChanged( QVariant::fromValue<QColor>( value ) ); 00080 } 00081 00082 // #include "colorpropertywidgetitem.moc"