author | zautrix <zautrix> | 2005-06-18 17:14:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-18 17:14:20 (UTC) |
commit | 45c93de5a458e7ca0c293eebe504a9d949cc045c (patch) (unidiff) | |
tree | c303812528fbd3fa1868928abfe198471395bb5b /microkde/kcolordialog.cpp | |
parent | 1919ddd25fb835b0eb03a44cbfbf4713d45266b8 (diff) | |
download | kdepimpi-45c93de5a458e7ca0c293eebe504a9d949cc045c.zip kdepimpi-45c93de5a458e7ca0c293eebe504a9d949cc045c.tar.gz kdepimpi-45c93de5a458e7ca0c293eebe504a9d949cc045c.tar.bz2 |
color dialog
-rw-r--r-- | microkde/kcolordialog.cpp | 78 |
1 files changed, 2 insertions, 76 deletions
diff --git a/microkde/kcolordialog.cpp b/microkde/kcolordialog.cpp index a3d8973..b9bb5bb 100644 --- a/microkde/kcolordialog.cpp +++ b/microkde/kcolordialog.cpp | |||
@@ -7,87 +7,13 @@ | |||
7 | #include <qapplication.h> | 7 | #include <qapplication.h> |
8 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
9 | 9 | ||
10 | #include <kglobal.h> | 10 | #include <kglobal.h> |
11 | QColor KColorDialog::getColor( ) const | 11 | QColor KColorDialog::getColor( ) const |
12 | { | 12 | { |
13 | QColor c ( r->value(), g->value(), b->value() ); | 13 | return color(); |
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 | } | 14 | } |
19 | void 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 | 15 | ||
29 | } | 16 | KColorDialog::KColorDialog( QWidget *p ):FNColorDialog( p, "input-dialog" ) |
30 | KColorDialog::KColorDialog( QWidget *p ):QDialog( p, "input-dialog", true ) | ||
31 | { | 17 | { |
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 | 18 | ||
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 | ok->setDefault( true ); | ||
79 | QPushButton * cancel = new QPushButton (i18n(" Cancel "), this ); | ||
80 | |||
81 | lay->addWidget(ok ,5,0 ); | ||
82 | lay->addWidget(cancel ,5,1 ); | ||
83 | connect (ok, SIGNAL( clicked() ), this ,SLOT (accept() )); | ||
84 | connect (cancel, SIGNAL( clicked() ), this ,SLOT (reject() )); | ||
85 | connect (r, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); | ||
86 | connect (g, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); | ||
87 | connect (b, SIGNAL( valueChanged ( int ) ), this ,SLOT (updateColor( int ) )); | ||
88 | } | ||
89 | void KColorDialog::updateColor( int ) | ||
90 | { | ||
91 | QColor c = getColor( ) ; | ||
92 | new_color->setPalette( QPalette( c.dark(), c ) ); | ||
93 | } | 19 | } |