summaryrefslogtreecommitdiffabout
path: root/microkde/kcolorbutton.cpp
Unidiff
Diffstat (limited to 'microkde/kcolorbutton.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kcolorbutton.cpp36
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 @@
1#include "kcolorbutton.h"
2#include "kcolordialog.h"
3#include "qapplication.h"
4
5
6#include "qlayout.h"
7
8void KColorButton:: edit()
9{
10
11 KColorDialog* k = new KColorDialog( this );
12 k->setColor( mColor );
13 int res = k->exec();
14 if ( res ) {
15 mColor = k->getColor();
16 setColor ( mColor );
17 emit changed ( mColor );
18 }
19 delete k;
20}
21KColorButton::KColorButton( QWidget *p ):QPushButton( p )
22{
23 int size = 24;
24 if( QApplication::desktop()->width() < 480 )
25 size = 18;
26 setFixedSize( size,size );
27 connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() ));
28
29}
30void KColorButton::setColor ( const QColor & c)
31{
32 mColor = c;
33 QPixmap pix ( height() - 4, width() - 4 );
34 pix.fill( c );
35 setPixmap ( pix );
36}