-rw-r--r-- | microkde/kcolorbutton.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/microkde/kcolorbutton.cpp b/microkde/kcolorbutton.cpp new file mode 100644 index 0000000..433f909 --- a/dev/null +++ b/microkde/kcolorbutton.cpp @@ -0,0 +1,36 @@ +#include "kcolorbutton.h" +#include "kcolordialog.h" +#include "qapplication.h" + + +#include "qlayout.h" + +void KColorButton:: edit() +{ + + KColorDialog* k = new KColorDialog( this ); + k->setColor( mColor ); + int res = k->exec(); + if ( res ) { + mColor = k->getColor(); + setColor ( mColor ); + emit changed ( mColor ); + } + delete k; +} +KColorButton::KColorButton( QWidget *p ):QPushButton( p ) +{ + int size = 24; + if( QApplication::desktop()->width() < 480 ) + size = 18; + setFixedSize( size,size ); + connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() )); + +} +void KColorButton::setColor ( const QColor & c) +{ + mColor = c; + QPixmap pix ( height() - 4, width() - 4 ); + pix.fill( c ); + setPixmap ( pix ); +} |