-rw-r--r-- | kaddressbook/views/colorlistbox.cpp | 10 | ||||
-rw-r--r-- | microkde/kcolorbutton.cpp | 13 |
2 files changed, 22 insertions, 1 deletions
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp index 7386207..2bddca6 100644 --- a/kaddressbook/views/colorlistbox.cpp +++ b/kaddressbook/views/colorlistbox.cpp | |||
@@ -14,32 +14,35 @@ | |||
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qpainter.h> | 21 | #include <qpainter.h> |
22 | 22 | ||
23 | #include <kcolordialog.h> | 23 | #include <kcolordialog.h> |
24 | 24 | ||
25 | #ifndef KAB_EMBEDDED | 25 | #ifndef KAB_EMBEDDED |
26 | #include <kcolordrag.h> | 26 | #include <kcolordrag.h> |
27 | #endif //KAB_EMBEDDED | 27 | #endif //KAB_EMBEDDED |
28 | 28 | ||
29 | #include "colorlistbox.h" | 29 | #include "colorlistbox.h" |
30 | #ifdef DESKTOP_VERSION | ||
31 | #include <qcolordialog.h> | ||
32 | #endif | ||
30 | 33 | ||
31 | ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) | 34 | ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) |
32 | :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) | 35 | :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) |
33 | { | 36 | { |
34 | connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); | 37 | connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); |
35 | connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); | 38 | connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); |
36 | setAcceptDrops( true); | 39 | setAcceptDrops( true); |
37 | } | 40 | } |
38 | 41 | ||
39 | 42 | ||
40 | void ColorListBox::setEnabled( bool state ) | 43 | void ColorListBox::setEnabled( bool state ) |
41 | { | 44 | { |
42 | if( state == isEnabled() ) | 45 | if( state == isEnabled() ) |
43 | { | 46 | { |
44 | return; | 47 | return; |
45 | } | 48 | } |
@@ -84,39 +87,46 @@ void ColorListBox::slotNewColor(QListBoxItem * i) | |||
84 | void ColorListBox::newColor( int index ) | 87 | void ColorListBox::newColor( int index ) |
85 | { | 88 | { |
86 | if( isEnabled() == false ) | 89 | if( isEnabled() == false ) |
87 | { | 90 | { |
88 | return; | 91 | return; |
89 | } | 92 | } |
90 | 93 | ||
91 | if( (uint)index < count() ) | 94 | if( (uint)index < count() ) |
92 | { | 95 | { |
93 | QColor c = color( index ); | 96 | QColor c = color( index ); |
94 | #ifndef KAB_EMBEDDED | 97 | #ifndef KAB_EMBEDDED |
95 | if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) | 98 | if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) |
96 | { | 99 | { |
97 | setColor( index, c ); | 100 | setColor( index, c ); |
98 | } | 101 | } |
99 | #else //KAB_EMBEDDED | 102 | #else //KAB_EMBEDDED |
103 | #ifdef DESKTOP_VERSION | ||
104 | QColor col = QColorDialog::getColor ( c ); | ||
105 | if ( col.isValid () ) { | ||
106 | setColor( index, col ); | ||
107 | } | ||
108 | #else | ||
100 | KColorDialog* k = new KColorDialog( this ); | 109 | KColorDialog* k = new KColorDialog( this ); |
101 | k->setColor( c ); | 110 | k->setColor( c ); |
102 | int res = k->exec(); | 111 | int res = k->exec(); |
103 | if ( res ) { | 112 | if ( res ) { |
104 | setColor( index, k->getColor() ); | 113 | setColor( index, k->getColor() ); |
105 | } | 114 | } |
106 | delete k; | 115 | delete k; |
116 | #endif | ||
107 | #endif //KAB_EMBEDDED | 117 | #endif //KAB_EMBEDDED |
108 | 118 | ||
109 | } | 119 | } |
110 | } | 120 | } |
111 | 121 | ||
112 | 122 | ||
113 | void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) | 123 | void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) |
114 | { | 124 | { |
115 | #ifndef KAB_EMBEDDED | 125 | #ifndef KAB_EMBEDDED |
116 | if( KColorDrag::canDecode(e) && isEnabled() ) | 126 | if( KColorDrag::canDecode(e) && isEnabled() ) |
117 | { | 127 | { |
118 | mCurrentOnDragEnter = currentItem(); | 128 | mCurrentOnDragEnter = currentItem(); |
119 | e->accept( true ); | 129 | e->accept( true ); |
120 | } | 130 | } |
121 | else | 131 | else |
122 | { | 132 | { |
diff --git a/microkde/kcolorbutton.cpp b/microkde/kcolorbutton.cpp index 433f909..c7c6088 100644 --- a/microkde/kcolorbutton.cpp +++ b/microkde/kcolorbutton.cpp | |||
@@ -1,35 +1,46 @@ | |||
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 | 4 | ||
5 | 5 | ||
6 | #include "qlayout.h" | 6 | #include "qlayout.h" |
7 | 7 | #ifdef DESKTOP_VERSION | |
8 | #include <qcolordialog.h> | ||
9 | #endif | ||
8 | void KColorButton:: edit() | 10 | void KColorButton:: edit() |
9 | { | 11 | { |
10 | 12 | ||
13 | #ifdef DESKTOP_VERSION | ||
14 | QColor col = QColorDialog::getColor ( mColor ); | ||
15 | if ( col.isValid () ) { | ||
16 | mColor = col; | ||
17 | setColor ( mColor ); | ||
18 | emit changed ( mColor ); | ||
19 | } | ||
20 | #else | ||
11 | KColorDialog* k = new KColorDialog( this ); | 21 | KColorDialog* k = new KColorDialog( this ); |
12 | k->setColor( mColor ); | 22 | k->setColor( mColor ); |
13 | int res = k->exec(); | 23 | int res = k->exec(); |
14 | if ( res ) { | 24 | if ( res ) { |
15 | mColor = k->getColor(); | 25 | mColor = k->getColor(); |
16 | setColor ( mColor ); | 26 | setColor ( mColor ); |
17 | emit changed ( mColor ); | 27 | emit changed ( mColor ); |
18 | } | 28 | } |
19 | delete k; | 29 | delete k; |
30 | #endif | ||
20 | } | 31 | } |
21 | KColorButton::KColorButton( QWidget *p ):QPushButton( p ) | 32 | KColorButton::KColorButton( QWidget *p ):QPushButton( p ) |
22 | { | 33 | { |
23 | int size = 24; | 34 | int size = 24; |
24 | if( QApplication::desktop()->width() < 480 ) | 35 | if( QApplication::desktop()->width() < 480 ) |
25 | size = 18; | 36 | size = 18; |
26 | setFixedSize( size,size ); | 37 | setFixedSize( size,size ); |
27 | connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() )); | 38 | connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() )); |
28 | 39 | ||
29 | } | 40 | } |
30 | void KColorButton::setColor ( const QColor & c) | 41 | void KColorButton::setColor ( const QColor & c) |
31 | { | 42 | { |
32 | mColor = c; | 43 | mColor = c; |
33 | QPixmap pix ( height() - 4, width() - 4 ); | 44 | QPixmap pix ( height() - 4, width() - 4 ); |
34 | pix.fill( c ); | 45 | pix.fill( c ); |
35 | setPixmap ( pix ); | 46 | setPixmap ( pix ); |