summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp
authorkergoth <kergoth>2003-08-09 16:12:19 (UTC)
committer kergoth <kergoth>2003-08-09 16:12:19 (UTC)
commit1c58d1407f9584fedcdae390a04e2b37e5853361 (patch) (unidiff)
tree3c6e741c4d382d1a53c182930052b684d6e35b91 /noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp
parente3f4607edd0c1ca1434adb446df1d4a1d27c6a86 (diff)
downloadopie-1c58d1407f9584fedcdae390a04e2b37e5853361.zip
opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.gz
opie-1c58d1407f9584fedcdae390a04e2b37e5853361.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp
index 976f1db..5d21f15 100644
--- a/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp
+++ b/noncore/apps/tinykate/libkate/microkde/kcolorbtn.cpp
@@ -2,85 +2,83 @@
2 Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org) 3 Copyright (C) 1999 Cristian Tibirna (ctibirna@kde.org)
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdialog.h> 21#include <qdialog.h>
22#include <qpainter.h> 22#include <qpainter.h>
23#include <qdrawutil.h> 23#include <qdrawutil.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <kglobalsettings.h> 25#include <kglobalsettings.h>
26//#include "kcolordialog.h" 26#include "kcolordialog.h"
27#include "kcolorbtn.h" 27#include "kcolorbtn.h"
28 28
29#include <opie/colordialog.h>
30
31KColorButton::KColorButton( QWidget *parent, const char *name ) 29KColorButton::KColorButton( QWidget *parent, const char *name )
32 : QPushButton( parent, name ), dragFlag(false) 30 : QPushButton( parent, name ), dragFlag(false)
33{ 31{
34 // 2000-10-15 (putzer): fixes broken keyboard usage 32 // 2000-10-15 (putzer): fixes broken keyboard usage
35 connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); 33 connect (this, SIGNAL(clicked()), this, SLOT(chooseColor()));
36} 34}
37 35
38KColorButton::KColorButton( const QColor &c, QWidget *parent, 36KColorButton::KColorButton( const QColor &c, QWidget *parent,
39 const char *name ) 37 const char *name )
40 : QPushButton( parent, name ), col(c), dragFlag(false) 38 : QPushButton( parent, name ), col(c), dragFlag(false)
41{ 39{
42 40
43 // 2000-10-15 (putzer): fixes broken keyboard usage 41 // 2000-10-15 (putzer): fixes broken keyboard usage
44 connect (this, SIGNAL(clicked()), this, SLOT(chooseColor())); 42 connect (this, SIGNAL(clicked()), this, SLOT(chooseColor()));
45} 43}
46 44
47void KColorButton::setColor( const QColor &c ) 45void KColorButton::setColor( const QColor &c )
48{ 46{
49 col = c; 47 col = c;
50 repaint( false ); 48 repaint( false );
51} 49}
52 50
53void KColorButton::drawButtonLabel( QPainter *painter ) 51void KColorButton::drawButtonLabel( QPainter *painter )
54{ 52{
55 QRect r = QApplication::style().buttonRect( 0, 0, width(), height() ); 53 QRect r = QApplication::style().buttonRect( 0, 0, width(), height() );
56 int l = r.x(); 54 int l = r.x();
57 int t = r.y(); 55 int t = r.y();
58 int w = r.width(); 56 int w = r.width();
59 int h = r.height(); 57 int h = r.height();
60 int b = 5; 58 int b = 5;
61 59
62 QColor lnCol = colorGroup().text(); 60 QColor lnCol = colorGroup().text();
63 QColor fillCol = isEnabled() ? col : backgroundColor(); 61 QColor fillCol = isEnabled() ? col : backgroundColor();
64 62
65 if ( isDown() ) { 63 if ( isDown() ) {
66 qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 ); 64 qDrawPlainRect( painter, l+b+1, t+b+1, w-b*2, h-b*2, lnCol, 1, 0 );
67 b++; 65 b++;
68 painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol ); 66 painter->fillRect( l+b+1, t+b+1, w-b*2, h-b*2, fillCol );
69 } else { 67 } else {
70 qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 ); 68 qDrawPlainRect( painter, l+b, t+b, w-b*2, h-b*2, lnCol, 1, 0 );
71 b++; 69 b++;
72 painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol ); 70 painter->fillRect( l+b, t+b, w-b*2, h-b*2, fillCol );
73 } 71 }
74} 72}
75 73
76void KColorButton::chooseColor() 74void KColorButton::chooseColor()
77{ 75{
78 QColor newCol=OColorDialog::getColor( col); 76 if( KColorDialog::getColor( col) == QDialog::Rejected )
79 if( newCol != QDialog::Rejected )
80 { 77 {
81 col=newCol; 78 return;
79 }
80
82 repaint( false ); 81 repaint( false );
83 emit changed( col ); 82 emit changed( col );
84 }
85} 83}
86 84