summaryrefslogtreecommitdiffabout
path: root/microkde/kcolordialog.cpp
Unidiff
Diffstat (limited to 'microkde/kcolordialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kcolordialog.cpp92
1 files changed, 92 insertions, 0 deletions
diff --git a/microkde/kcolordialog.cpp b/microkde/kcolordialog.cpp
new file mode 100644
index 0000000..9a76e5e
--- a/dev/null
+++ b/microkde/kcolordialog.cpp
@@ -0,0 +1,92 @@
1#include "kcolordialog.h"
2#include <qdialog.h>
3#include <qlayout.h>
4#include <qlabel.h>
5#include <qslider.h>
6#include <qhbox.h>
7#include <qapplication.h>
8#include <qpushbutton.h>
9
10#include <kglobal.h>
11QColor KColorDialog::getColor( ) const
12{
13 QColor c ( r->value(), g->value(), b->value() );
14 lar->setText ( "R: " + QString::number ( c.red() ) );
15 lag->setText ( "G: " + QString::number ( c.green() ) );
16 lab->setText ( "B: " + QString::number ( c.blue() ) );
17 return c;
18}
19void KColorDialog::setColor( const QColor & d )
20{
21 r->setValue(d.red() );
22 g->setValue(d.green() );
23 b->setValue(d.blue() );
24 old_color->setPalette( QPalette( d.dark(), d ) );
25 lar->setText ( "R: " + QString::number ( d.red() ) );
26 lag->setText ( "G: " + QString::number ( d.green() ) );
27 lab->setText ( "B: " + QString::number ( d.blue() ) );
28
29}
30KColorDialog::KColorDialog( QWidget *p ):QDialog( p, "input-dialog", true )
31{
32 setCaption( i18n("Choose Color") );
33
34 setMaximumSize( QApplication::desktop()->width() - 20, QApplication::desktop()->height() - 40 ); // for zaurus 5500er.
35 QGridLayout* lay = new QGridLayout ( this, 4, 2 );
36 lay->setSpacing( 6 );
37 lay->setMargin( 11 );
38
39 old_color = new QLabel("Old color",this);
40 old_color->setFrameStyle( QFrame::Panel | QFrame::Plain );
41 old_color->setLineWidth( 1 );
42 lay->addWidget(old_color, 0, 0);
43
44 new_color = new QLabel("New color", this);
45 new_color->setFrameStyle( QFrame::Panel | QFrame::Plain );
46 new_color->setLineWidth( 1 );
47 lay->addWidget(new_color, 0, 1);
48 new_color->setAlignment( AlignCenter );
49
50 QHBox* hb = new QHBox ( this );
51 lar = new QLabel( hb );
52 lag = new QLabel( hb );
53 lab = new QLabel( hb );
54 lay->addMultiCellWidget( hb,1,1, 0,1 );
55
56 QLabel* lr = new QLabel ( "Red:", this );
57 lay->addWidget( lr,2,0 );
58 r = new QSlider ( 0, 255, 1, 1, Horizontal, this );
59 lay->addWidget(r ,2,1 );
60
61 QLabel* lg = new QLabel( "Green:",this );
62 lay->addWidget(lg ,3,0 );
63 g = new QSlider ( 0, 255, 1, 1, Horizontal, this );
64 lay->addWidget( g ,3,1 );
65
66 QLabel* lb = new QLabel ( "Blue:",this );
67 lay->addWidget( lb,4,0 );
68 b = new QSlider ( 0, 255, 1, 1, Horizontal, this );
69 lay->addWidget(b ,4,1 );
70
71 QColor d = backgroundColor();
72 r->setValue(d.red() );
73 g->setValue(d.green() );
74 b->setValue(d.blue() );
75 old_color->setPalette( QPalette( d.dark() , d ) );
76 // kannst du wieder reinnehmen, aber es geht auch so.
77 QPushButton * ok = new QPushButton (i18n(" OK "), this );
78 QPushButton * cancel = new QPushButton (i18n(" Cancel "), this );
79
80 lay->addWidget(ok ,5,0 );
81 lay->addWidget(cancel ,5,1 );
82 connect (ok, SIGNAL( clicked() ), this ,SLOT (accept() ));
83 connect (cancel, SIGNAL( clicked() ), this ,SLOT (reject() ));
84 connect (r, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
85 connect (g, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
86 connect (b, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) ));
87}
88void KColorDialog::updateColor( int )
89{
90 QColor c = getColor( ) ;
91 new_color->setPalette( QPalette( c.dark(), c ) );
92}