-rw-r--r-- | libopie/oclickablelabel.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/oclickablelabel.cpp b/libopie/oclickablelabel.cpp index 43a0524..5768529 100644 --- a/libopie/oclickablelabel.cpp +++ b/libopie/oclickablelabel.cpp | |||
@@ -1,88 +1,88 @@ | |||
1 | #include "oclickablelabel.h" | 1 | #include "oclickablelabel.h" |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | 3 | ||
4 | OClickableLabel::OClickableLabel(QWidget* parent, | 4 | OClickableLabel::OClickableLabel(QWidget* parent, |
5 | const char* name, | 5 | const char* name, |
6 | WFlags fl) : | 6 | WFlags fl) : |
7 | QLabel(parent,name,fl) | 7 | QLabel(parent,name,fl) |
8 | { | 8 | { |
9 | textInverted=false; | 9 | textInverted=false; |
10 | isToggle=false; | 10 | isToggle=false; |
11 | isDown=false; | 11 | isDown=false; |
12 | showState(false); | 12 | showState(false); |
13 | setFrameShadow(Sunken); | 13 | setFrameShadow(Sunken); |
14 | } | 14 | } |
15 | 15 | ||
16 | void OClickableLabel::setToggleButton(bool t) { | 16 | void OClickableLabel::setToggleButton(bool t) { |
17 | isToggle=t; | 17 | isToggle=t; |
18 | } | 18 | } |
19 | 19 | ||
20 | void OClickableLabel::mousePressEvent( QMouseEvent *e ) { | 20 | void OClickableLabel::mousePressEvent( QMouseEvent * /*e*/ ) { |
21 | if (isToggle && isDown) { | 21 | if (isToggle && isDown) { |
22 | showState(false); | 22 | showState(false); |
23 | } else { | 23 | } else { |
24 | showState(true); | 24 | showState(true); |
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { | 28 | void OClickableLabel::mouseReleaseEvent( QMouseEvent *e ) { |
29 | if (rect().contains(e->pos()) && isToggle) isDown=!isDown; | 29 | if (rect().contains(e->pos()) && isToggle) isDown=!isDown; |
30 | 30 | ||
31 | if (isToggle && isDown) { | 31 | if (isToggle && isDown) { |
32 | showState(true); | 32 | showState(true); |
33 | } else { | 33 | } else { |
34 | showState(false); | 34 | showState(false); |
35 | } | 35 | } |
36 | 36 | ||
37 | if (rect().contains(e->pos())) { | 37 | if (rect().contains(e->pos())) { |
38 | if (isToggle) { | 38 | if (isToggle) { |
39 | emit toggled(isDown); | 39 | emit toggled(isDown); |
40 | } | 40 | } |
41 | emit clicked(); | 41 | emit clicked(); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) { | 45 | void OClickableLabel::mouseMoveEvent( QMouseEvent *e ) { |
46 | if (rect().contains(e->pos())) { | 46 | if (rect().contains(e->pos())) { |
47 | if (isToggle && isDown) { | 47 | if (isToggle && isDown) { |
48 | showState(false); | 48 | showState(false); |
49 | } else { | 49 | } else { |
50 | showState(true); | 50 | showState(true); |
51 | } | 51 | } |
52 | } else { | 52 | } else { |
53 | if (isToggle && isDown) { | 53 | if (isToggle && isDown) { |
54 | showState(true); | 54 | showState(true); |
55 | } else { | 55 | } else { |
56 | showState(false); | 56 | showState(false); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | void OClickableLabel::showState(bool on) { | 61 | void OClickableLabel::showState(bool on) { |
62 | if (on) { | 62 | if (on) { |
63 | //setFrameShape(Panel); | 63 | //setFrameShape(Panel); |
64 | setInverted(true); | 64 | setInverted(true); |
65 | setBackgroundMode(PaletteHighlight); | 65 | setBackgroundMode(PaletteHighlight); |
66 | } else { | 66 | } else { |
67 | //setFrameShape(NoFrame); | 67 | //setFrameShape(NoFrame); |
68 | setInverted(false); | 68 | setInverted(false); |
69 | setBackgroundMode(PaletteBackground); | 69 | setBackgroundMode(PaletteBackground); |
70 | } | 70 | } |
71 | repaint(); | 71 | repaint(); |
72 | } | 72 | } |
73 | 73 | ||
74 | void OClickableLabel::setInverted(bool on) { | 74 | void OClickableLabel::setInverted(bool on) { |
75 | if ( (!textInverted && on) || (textInverted && !on) ) { | 75 | if ( (!textInverted && on) || (textInverted && !on) ) { |
76 | QPalette pal=palette(); | 76 | QPalette pal=palette(); |
77 | QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground); | 77 | QColor col=pal.color(QPalette::Normal, QColorGroup::Foreground); |
78 | col.setRgb(255-col.red(),255-col.green(),255-col.blue()); | 78 | col.setRgb(255-col.red(),255-col.green(),255-col.blue()); |
79 | pal.setColor(QPalette::Normal, QColorGroup::Foreground, col); | 79 | pal.setColor(QPalette::Normal, QColorGroup::Foreground, col); |
80 | setPalette(pal); | 80 | setPalette(pal); |
81 | textInverted=!textInverted; | 81 | textInverted=!textInverted; |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | void OClickableLabel::setOn(bool on) { | 85 | void OClickableLabel::setOn(bool on) { |
86 | isDown=on; | 86 | isDown=on; |
87 | showState(isDown); | 87 | showState(isDown); |
88 | } | 88 | } |