author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kcolorbutton.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | microkde/kcolorbutton.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/microkde/kcolorbutton.cpp b/microkde/kcolorbutton.cpp index 197bea2..16618fc 100644 --- a/microkde/kcolorbutton.cpp +++ b/microkde/kcolorbutton.cpp | |||
@@ -1,54 +1,57 @@ | |||
1 | #include "kcolorbutton.h" | 1 | #include "kcolorbutton.h" |
2 | #include "kcolordialog.h" | 2 | #include "kcolordialog.h" |
3 | #include "qapplication.h" | 3 | #include "qapplication.h" |
4 | #include <QDesktopWidget> | ||
4 | 5 | ||
5 | 6 | ||
6 | #include "qlayout.h" | 7 | #include "qlayout.h" |
7 | #ifdef DESKTOP_VERSION | 8 | #ifdef DESKTOP_VERSION |
8 | #include <qcolordialog.h> | 9 | #include <qcolordialog.h> |
10 | //Added by qt3to4: | ||
11 | #include <QPixmap> | ||
9 | #endif | 12 | #endif |
10 | void KColorButton:: edit() | 13 | void KColorButton:: edit() |
11 | { | 14 | { |
12 | 15 | ||
13 | #ifdef DESKTOP_VERSION | 16 | #ifdef DESKTOP_VERSION |
14 | QColor col = QColorDialog::getColor ( mColor ); | 17 | QColor col = QColorDialog::getColor ( mColor ); |
15 | if ( col.isValid () ) { | 18 | if ( col.isValid () ) { |
16 | mColor = col; | 19 | mColor = col; |
17 | setColor ( mColor ); | 20 | setColor ( mColor ); |
18 | emit changed ( mColor ); | 21 | emit changed ( mColor ); |
19 | emit changedID ( mColor, id ); | 22 | emit changedID ( mColor, id ); |
20 | } | 23 | } |
21 | #else | 24 | #else |
22 | KColorDialog* k = new KColorDialog( this ); | 25 | KColorDialog* k = new KColorDialog( this ); |
23 | k->setColor( mColor ); | 26 | k->setColor( mColor ); |
24 | int res = k->exec(); | 27 | int res = k->exec(); |
25 | if ( res ) { | 28 | if ( res ) { |
26 | mColor = k->getColor(); | 29 | mColor = k->getColor(); |
27 | setColor ( mColor ); | 30 | setColor ( mColor ); |
28 | emit changed ( mColor ); | 31 | emit changed ( mColor ); |
29 | emit changedID ( mColor, id ); | 32 | emit changedID ( mColor, id ); |
30 | } | 33 | } |
31 | delete k; | 34 | delete k; |
32 | #endif | 35 | #endif |
33 | } | 36 | } |
34 | KColorButton::KColorButton( QWidget *p ):QPushButton( p ) | 37 | KColorButton::KColorButton( QWidget *p ):QPushButton( p ) |
35 | { | 38 | { |
36 | int size = 24; | 39 | int size = 24; |
37 | if( QApplication::desktop()->width() < 480 || QApplication::desktop()->height() <= 320 ) | 40 | if( QApplication::desktop()->width() < 480 || QApplication::desktop()->height() <= 320 ) |
38 | size = 18; | 41 | size = 18; |
39 | setFixedSize( size,size ); | 42 | setFixedSize( size,size ); |
40 | int id = 0; | 43 | int id = 0; |
41 | connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() )); | 44 | connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() )); |
42 | 45 | ||
43 | } | 46 | } |
44 | void KColorButton::setID ( int i) | 47 | void KColorButton::setID ( int i) |
45 | { | 48 | { |
46 | id = i; | 49 | id = i; |
47 | } | 50 | } |
48 | void KColorButton::setColor ( const QColor & c) | 51 | void KColorButton::setColor ( const QColor & c) |
49 | { | 52 | { |
50 | mColor = c; | 53 | mColor = c; |
51 | QPixmap pix ( height() - 4, width() - 4 ); | 54 | QPixmap pix ( height() - 4, width() - 4 ); |
52 | pix.fill( c ); | 55 | pix.fill( c ); |
53 | setPixmap ( pix ); | 56 | setPixmap ( pix ); |
54 | } | 57 | } |