-rw-r--r-- | libqtaux/ocolorbutton.cpp | 50 | ||||
-rw-r--r-- | libqtaux/ocolorbutton.h | 44 |
2 files changed, 51 insertions, 43 deletions
diff --git a/libqtaux/ocolorbutton.cpp b/libqtaux/ocolorbutton.cpp index 004fafc..2a87be9 100644 --- a/libqtaux/ocolorbutton.cpp +++ b/libqtaux/ocolorbutton.cpp | |||
@@ -1,30 +1,30 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Robert Griebl <sandman@handhelds.org> | 3 | Copyright (C) Robert Griebl <sandman@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "ocolorpopupmenu.h" | 30 | #include "ocolorpopupmenu.h" |
@@ -88,20 +88,25 @@ QColor OColorButton::color ( ) const | |||
88 | /** | 88 | /** |
89 | * This method sets the color of the button | 89 | * This method sets the color of the button |
90 | * @param c The color to be set. | 90 | * @param c The color to be set. |
91 | */ | 91 | */ |
92 | void OColorButton::setColor ( const QColor &c ) | 92 | void OColorButton::setColor ( const QColor &c ) |
93 | { | 93 | { |
94 | updateColor ( c ); | 94 | updateColor ( c, true ); |
95 | } | 95 | } |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * @internal | 98 | * @internal |
99 | */ | 99 | */ |
100 | void OColorButton::updateColor ( const QColor &c ) | 100 | void OColorButton::updateColor ( const QColor &c ) |
101 | { | 101 | { |
102 | updateColor( c, true ); | ||
103 | } | ||
104 | |||
105 | void OColorButton::updateColor ( const QColor &c, bool sendSignal ) | ||
106 | { | ||
102 | d-> m_color = c; | 107 | d-> m_color = c; |
103 | 108 | ||
104 | QImage img ( width()-14, height()-6, 32 ); | 109 | QImage img ( width()-14, height()-6, 32 ); |
105 | img. fill ( 0 ); | 110 | img. fill ( 0 ); |
106 | 111 | ||
107 | int r, g, b; | 112 | int r, g, b; |
@@ -140,17 +145,18 @@ void OColorButton::updateColor ( const QColor &c ) | |||
140 | img. setAlphaBuffer ( true ); | 145 | img. setAlphaBuffer ( true ); |
141 | 146 | ||
142 | QPixmap pix; | 147 | QPixmap pix; |
143 | pix. convertFromImage ( img ); | 148 | pix. convertFromImage ( img ); |
144 | setPixmap ( pix ); | 149 | setPixmap ( pix ); |
145 | 150 | ||
146 | emit colorSelected ( c ); | 151 | if ( sendSignal ) |
152 | emit colorSelected ( c ); | ||
147 | } | 153 | } |
148 | 154 | ||
149 | 155 | ||
150 | /** | 156 | /** |
151 | * @internal | 157 | * @internal |
152 | */ | 158 | */ |
153 | void OColorButton::resizeEvent( QResizeEvent *ev ) { | 159 | void OColorButton::resizeEvent( QResizeEvent *ev ) { |
154 | QPushButton::resizeEvent( ev ); | 160 | QPushButton::resizeEvent( ev ); |
155 | updateColor(d->m_color); | 161 | updateColor( d->m_color, false ); |
156 | } | 162 | } |
diff --git a/libqtaux/ocolorbutton.h b/libqtaux/ocolorbutton.h index 10b77d5..4845c0d 100644 --- a/libqtaux/ocolorbutton.h +++ b/libqtaux/ocolorbutton.h | |||
@@ -1,30 +1,30 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Robert Griebl <sandman@handhelds.org> | 3 | Copyright (C) Robert Griebl <sandman@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OCOLORBUTTON_H | 30 | #ifndef OCOLORBUTTON_H |
@@ -51,15 +51,15 @@ class OColorButton : public QPushButton | |||
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 ); | 53 | OColorButton ( QWidget *parent = 0, const QColor & = black, const char *name = 0 ); |
54 | virtual ~OColorButton ( ); | 54 | virtual ~OColorButton ( ); |
55 | 55 | ||
56 | QColor color ( ) const; | 56 | QColor color ( ) const; |
57 | 57 | ||
58 | protected: | 58 | protected: |
59 | void resizeEvent( QResizeEvent* ); | 59 | void resizeEvent( QResizeEvent* ); |
60 | 60 | ||
61 | signals: | 61 | signals: |
62 | /** | 62 | /** |
63 | * emitted when a color gets selected | 63 | * emitted when a color gets selected |
64 | */ | 64 | */ |
65 | void colorSelected ( const QColor & ); | 65 | void colorSelected ( const QColor & ); |
@@ -72,12 +72,14 @@ protected slots: | |||
72 | * @internal | 72 | * @internal |
73 | */ | 73 | */ |
74 | virtual void updateColor ( const QColor & ); | 74 | virtual void updateColor ( const QColor & ); |
75 | 75 | ||
76 | private: | 76 | private: |
77 | OColorButtonPrivate *d; | 77 | OColorButtonPrivate *d; |
78 | |||
79 | void updateColor ( const QColor &, bool sendSignal = true ); | ||
78 | }; | 80 | }; |
79 | 81 | ||
80 | }; | 82 | }; |
81 | 83 | ||
82 | #endif | 84 | #endif |
83 | 85 | ||