summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 4a65952..bac882c 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,375 +1,369 @@
1/*- 1/*-
2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. 2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
3 */ 3 */
4 4
5// 5//
6// (c) 2002 Robert 'sandman' Griebl 6// (c) 2002 Robert 'sandman' Griebl
7// 7//
8 8
9 9
10#ifndef INCLUDE_MENUITEM_DEF 10#ifndef INCLUDE_MENUITEM_DEF
11#define INCLUDE_MENUITEM_DEF 11#define INCLUDE_MENUITEM_DEF
12#endif 12#endif
13 13
14#include <qmenudata.h> 14#include <qmenudata.h>
15#include "liquid.h" 15#include "liquid.h"
16//#include "liquiddeco.h" 16//#include "liquiddeco.h"
17#include <qapplication.h> 17#include <qapplication.h>
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include "effects.h" 19#include "effects.h"
20#include <qpalette.h> 20#include <qpalette.h>
21#include <qbitmap.h> 21#include <qbitmap.h>
22#include <qtabbar.h> 22#include <qtabbar.h>
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qobjectlist.h> 24#include <qobjectlist.h>
25#include <qimage.h> 25#include <qimage.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qpixmapcache.h> 27#include <qpixmapcache.h>
28#include <qradiobutton.h> 28#include <qradiobutton.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qdrawutil.h> 30#include <qdrawutil.h>
31#include <qwidgetlist.h> 31#include <qwidgetlist.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qheader.h> 33#include <qheader.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <qmenubar.h> 35#include <qmenubar.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qlistbox.h> 38#include <qlistbox.h>
39 39
40#include <stdio.h> 40#include <stdio.h>
41 41
42#include "htmlmasks.h" 42#include "htmlmasks.h"
43#include "embeddata.h" 43#include "embeddata.h"
44 44
45 45
46typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 46typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
47 QColorGroup &, bool, bool); 47 QColorGroup &, bool, bool);
48 48
49QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 49QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
50 50
51void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 51void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
52{ 52{
53 QImage img(pix.convertToImage()); 53 QImage img(pix.convertToImage());
54 QImageEffect::fade(img, 0.9, color); 54 QImageEffect::fade(img, 0.9, color);
55 int x, y; 55 int x, y;
56 int r, g, b; 56 int r, g, b;
57 for(y=0; y < img.height(); y+=3){ 57 for(y=0; y < img.height(); y+=3){
58 unsigned int *data = (unsigned int *) img.scanLine(y); 58 unsigned int *data = (unsigned int *) img.scanLine(y);
59 for(x=0; x < img.width(); ++x){ 59 for(x=0; x < img.width(); ++x){
60 r = qRed(data[x]); 60 r = qRed(data[x]);
61 g = qGreen(data[x]); 61 g = qGreen(data[x]);
62 b = qBlue(data[x]); 62 b = qBlue(data[x]);
63 if(r-10) 63 if(r-10)
64 r-=10; 64 r-=10;
65 if(g-10) 65 if(g-10)
66 g-=10; 66 g-=10;
67 if(b-10) 67 if(b-10)
68 b-=10; 68 b-=10;
69 data[x] = qRgb(r, g, b); 69 data[x] = qRgb(r, g, b);
70 } 70 }
71 } 71 }
72 pix.convertFromImage(img); 72 pix.convertFromImage(img);
73} 73}
74 74
75TransMenuHandler::TransMenuHandler(QObject *parent) 75TransMenuHandler::TransMenuHandler(QObject *parent)
76 : QObject(parent) 76 : QObject(parent)
77{ 77{
78 pixDict.setAutoDelete(true); 78 pixDict.setAutoDelete(true);
79 reloadSettings(); 79 reloadSettings();
80} 80}
81 81
82void TransMenuHandler::reloadSettings() 82void TransMenuHandler::reloadSettings()
83{ 83{
84 pixDict.clear(); 84 pixDict.clear();
85 85
86 Config config ( "qpe" ); 86 Config config ( "qpe" );
87 config. setGroup ( "Liquid-Style" ); 87 config. setGroup ( "Liquid-Style" );
88 88
89 type = config. readNumEntry("Type", TransStippleBg); 89 type = config. readNumEntry("Type", TransStippleBg);
90 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 90 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
91 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 91 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
92 opacity = config. readNumEntry("Opacity", 10); 92 opacity = config. readNumEntry("Opacity", 10);
93 if ( opacity < -20 ) 93 if ( opacity < -20 )
94 opacity = 20; 94 opacity = 20;
95 else if ( opacity > 20 ) 95 else if ( opacity > 20 )
96 opacity = 20; 96 opacity = 20;
97 97
98 shadowText = config. readBoolEntry("ShadowText", true); 98 shadowText = config. readBoolEntry("ShadowText", true);
99} 99}
100 100
101bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 101bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
102{ 102{
103 QWidget *p = (QWidget *)obj; 103 QWidget *p = (QWidget *)obj;
104 104
105 if(ev->type() == QEvent::Show){ 105 if(ev->type() == QEvent::Show){
106 if(type == TransStippleBg || type == TransStippleBtn || 106 if(type == TransStippleBg || type == TransStippleBtn ||
107 type == Custom){ 107 type == Custom){
108 QApplication::syncX(); 108 QApplication::syncX();
109 QPixmap *pix = new QPixmap; 109 QPixmap *pix = new QPixmap;
110 if(p->testWFlags(Qt::WType_Popup)){ 110 if(p->testWFlags(Qt::WType_Popup)){
111 QRect r(p->x(), p->y(), p->width(), p->height()); 111 QRect r(p->x(), p->y(), p->width(), p->height());
112 QRect deskR = QApplication::desktop()->rect(); 112 QRect deskR = QApplication::desktop()->rect();
113 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 113 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
114 r.setBottom(deskR.bottom()); 114 r.setBottom(deskR.bottom());
115 r.setRight(deskR.right()); 115 r.setRight(deskR.right());
116 } 116 }
117 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 117 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
118 r.width(), r.height()); 118 r.width(), r.height());
119 } 119 }
120 else{ // tear off menu 120 else{ // tear off menu
121 pix->resize(p->width(), p->height()); 121 pix->resize(p->width(), p->height());
122 pix->fill(Qt::black.rgb()); 122 pix->fill(Qt::black.rgb());
123 } 123 }
124 if(type == TransStippleBg){ 124 if(type == TransStippleBg){
125 stripePixmap(*pix, p->colorGroup().background()); 125 stripePixmap(*pix, p->colorGroup().background());
126 } 126 }
127 else if(type == TransStippleBtn){ 127 else if(type == TransStippleBtn){
128 stripePixmap(*pix, p->colorGroup().button()); 128 stripePixmap(*pix, p->colorGroup().button());
129 } 129 }
130 else{ 130 else{
131 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 131 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
132 } 132 }
133 133
134 pixDict.insert(p->winId(), pix); 134 pixDict.insert(p->winId(), pix);
135 135
136 if ( !p->inherits("QPopupMenu")) 136 if ( !p->inherits("QPopupMenu"))
137 p->setBackgroundPixmap(*pix); 137 p->setBackgroundPixmap(*pix);
138 138
139 QObjectList *ol = p-> queryList("QWidget"); 139 QObjectList *ol = p-> queryList("QWidget");
140 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 140 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
141 QWidget *wid = (QWidget *) it.current ( ); 141 QWidget *wid = (QWidget *) it.current ( );
142 142
143 wid-> setBackgroundPixmap(*pix); 143 wid-> setBackgroundPixmap(*pix);
144 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 144 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
145 } 145 }
146 delete ol; 146 delete ol;
147 } 147 }
148 } 148 }
149 else if(ev->type() == QEvent::Hide){ 149 else if(ev->type() == QEvent::Hide){
150 if(type == TransStippleBg || type == TransStippleBtn || 150 if(type == TransStippleBg || type == TransStippleBtn ||
151 type == Custom){ 151 type == Custom){
152// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); 152// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
153 153
154 pixDict.remove(p->winId()); 154 pixDict.remove(p->winId());
155 if ( !p->inherits("QPopupMenu")) 155 if ( !p->inherits("QPopupMenu"))
156 p->setBackgroundMode(QWidget::PaletteBackground); 156 p->setBackgroundMode(QWidget::PaletteBackground);
157 157
158 QObjectList *ol = p-> queryList("QWidget"); 158 QObjectList *ol = p-> queryList("QWidget");
159 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 159 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
160 QWidget *wid = (QWidget *) it.current ( ); 160 QWidget *wid = (QWidget *) it.current ( );
161 161
162 wid-> setBackgroundMode( QWidget::PaletteBackground ); 162 wid-> setBackgroundMode( QWidget::PaletteBackground );
163 } 163 }
164 delete ol; 164 delete ol;
165 } 165 }
166 } 166 }
167 return(false); 167 return(false);
168} 168}
169 169
170 170
171static int qt_version ( )
172{
173 const char *qver = qVersion ( );
174 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
175}
176 171
177 172
178LiquidStyle::LiquidStyle() 173LiquidStyle::LiquidStyle()
179 :QWindowsStyle() 174 :QWindowsStyle()
180{ 175{
181 setName ( "LiquidStyle" ); 176 setName ( "LiquidStyle" );
182 177
183 oldqte = ( qt_version ( ) < 234 );
184 flatTBButtons = false; 178 flatTBButtons = false;
185 currentHeader = 0; 179 currentHeader = 0;
186 180
187 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 181 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
188 btnMaskBmp.setMask(btnMaskBmp); 182 btnMaskBmp.setMask(btnMaskBmp);
189 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 183 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
190 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); 184 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
191 headerHoverID = -1; 185 headerHoverID = -1;
192 highlightWidget = NULL; 186 highlightWidget = NULL;
193 setButtonDefaultIndicatorWidth(0); 187 setButtonDefaultIndicatorWidth(0);
194 btnDict.setAutoDelete(true); 188 btnDict.setAutoDelete(true);
195 bevelFillDict.setAutoDelete(true); 189 bevelFillDict.setAutoDelete(true);
196 smallBevelFillDict.setAutoDelete(true); 190 smallBevelFillDict.setAutoDelete(true);
197 191
198 rMatrix.rotate(270.0); 192 rMatrix.rotate(270.0);
199 btnBorderPix = new QPixmap; 193 btnBorderPix = new QPixmap;
200 btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); 194 btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
201 btnBlendPix = new QPixmap; 195 btnBlendPix = new QPixmap;
202 btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); 196 btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
203 bevelFillPix = new QPixmap; 197 bevelFillPix = new QPixmap;
204 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); 198 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
205 smallBevelFillPix = new QPixmap; 199 smallBevelFillPix = new QPixmap;
206 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); 200 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
207 // new stuff 201 // new stuff
208 vsbSliderFillPix = menuPix = NULL; 202 vsbSliderFillPix = menuPix = NULL;
209 menuHandler = new TransMenuHandler(this); 203 menuHandler = new TransMenuHandler(this);
210 setScrollBarExtent(15, 15); 204 setScrollBarExtent(15, 15);
211 int i; 205 int i;
212 for(i=0; i < BITMAP_ITEMS; ++i){ 206 for(i=0; i < BITMAP_ITEMS; ++i){
213 pixmaps[i] = NULL; 207 pixmaps[i] = NULL;
214 } 208 }
215 oldSliderThickness = sliderThickness(); 209 oldSliderThickness = sliderThickness();
216 setSliderThickness(11); 210 setSliderThickness(11);
217} 211}
218 212
219LiquidStyle::~LiquidStyle() 213LiquidStyle::~LiquidStyle()
220{ 214{
221 if(btnBorderPix) 215 if(btnBorderPix)
222 delete btnBorderPix; 216 delete btnBorderPix;
223 if(btnBlendPix) 217 if(btnBlendPix)
224 delete btnBlendPix; 218 delete btnBlendPix;
225 if(bevelFillPix) 219 if(bevelFillPix)
226 delete bevelFillPix; 220 delete bevelFillPix;
227 if(smallBevelFillPix) 221 if(smallBevelFillPix)
228 delete smallBevelFillPix; 222 delete smallBevelFillPix;
229 if(vsbSliderFillPix) 223 if(vsbSliderFillPix)
230 delete vsbSliderFillPix; 224 delete vsbSliderFillPix;
231 if(menuPix) 225 if(menuPix)
232 delete menuPix; 226 delete menuPix;
233 227
234 setScrollBarExtent(16, 16); 228 setScrollBarExtent(16, 16);
235 setSliderThickness(oldSliderThickness); 229 setSliderThickness(oldSliderThickness);
236 int i; 230 int i;
237 for(i=0; i < BITMAP_ITEMS; ++i){ 231 for(i=0; i < BITMAP_ITEMS; ++i){
238 if(pixmaps[i]) 232 if(pixmaps[i])
239 delete pixmaps[i]; 233 delete pixmaps[i];
240 } 234 }
241} 235}
242 236
243void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, 237void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h,
244 const QColor &c, const QColor &bg) 238 const QColor &c, const QColor &bg)
245{ 239{
246 240
247 QPen oldPen = p->pen(); // headers need this 241 QPen oldPen = p->pen(); // headers need this
248 int x2 = x+w-1; 242 int x2 = x+w-1;
249 int y2 = y+h-1; 243 int y2 = y+h-1;
250 // outer dark rect 244 // outer dark rect
251 p->setPen(c.dark(130)); 245 p->setPen(c.dark(130));
252 p->drawLine(x, y+2, x, y2-2); // l 246 p->drawLine(x, y+2, x, y2-2); // l
253 p->drawLine(x2, y+2, x2, y2-2); // r 247 p->drawLine(x2, y+2, x2, y2-2); // r
254 p->drawLine(x+2, y, x2-2, y); // t 248 p->drawLine(x+2, y, x2-2, y); // t
255 p->drawLine(x+2, y2, x2-2, y2); // b 249 p->drawLine(x+2, y2, x2-2, y2); // b
256 p->drawPoint(x+1, y+1); // tl 250 p->drawPoint(x+1, y+1); // tl
257 p->drawPoint(x2-1, y+1); // tr 251 p->drawPoint(x2-1, y+1); // tr
258 p->drawPoint(x+1, y2-1); // bl 252 p->drawPoint(x+1, y2-1); // bl
259 p->drawPoint(x2-1, y2-1); // br 253 p->drawPoint(x2-1, y2-1); // br
260 254
261 // inner top light lines 255 // inner top light lines
262 p->setPen(c.light(105)); 256 p->setPen(c.light(105));
263 p->drawLine(x+2, y+1, x2-2, y+1); 257 p->drawLine(x+2, y+1, x2-2, y+1);
264 p->drawLine(x+1, y+2, x2-1, y+2); 258 p->drawLine(x+1, y+2, x2-1, y+2);
265 p->drawLine(x+1, y+3, x+2, y+3); 259 p->drawLine(x+1, y+3, x+2, y+3);
266 p->drawLine(x2-2, y+3, x2-1, y+3); 260 p->drawLine(x2-2, y+3, x2-1, y+3);
267 p->drawPoint(x+1, y+4); 261 p->drawPoint(x+1, y+4);
268 p->drawPoint(x2-1, y+4); 262 p->drawPoint(x2-1, y+4);
269 263
270 // inner bottom light lines 264 // inner bottom light lines
271 p->setPen(c.light(110)); 265 p->setPen(c.light(110));
272 p->drawLine(x+2, y2-1, x2-2, y2-1); 266 p->drawLine(x+2, y2-1, x2-2, y2-1);
273 p->drawLine(x+1, y2-2, x2-1, y2-2); 267 p->drawLine(x+1, y2-2, x2-1, y2-2);
274 p->drawLine(x+1, y2-3, x+2, y2-3); 268 p->drawLine(x+1, y2-3, x+2, y2-3);
275 p->drawLine(x2-2, y2-3, x2-1, y2-3); 269 p->drawLine(x2-2, y2-3, x2-1, y2-3);
276 p->drawPoint(x+1, y2-4); 270 p->drawPoint(x+1, y2-4);
277 p->drawPoint(x2-1, y2-4); 271 p->drawPoint(x2-1, y2-4);
278 272
279 // inner left mid lines 273 // inner left mid lines
280 //p->setPen(c.light(105)); 274 //p->setPen(c.light(105));
281 p->setPen(c); 275 p->setPen(c);
282 p->drawLine(x+1, y+5, x+1, y2-5); 276 p->drawLine(x+1, y+5, x+1, y2-5);
283 p->drawLine(x+2, y+4, x+2, y2-4); 277 p->drawLine(x+2, y+4, x+2, y2-4);
284 278
285 // inner right mid lines 279 // inner right mid lines
286 p->drawLine(x2-1, y+5, x2-1, y2-5); 280 p->drawLine(x2-1, y+5, x2-1, y2-5);
287 p->drawLine(x2-2, y+4, x2-2, y2-4); 281 p->drawLine(x2-2, y+4, x2-2, y2-4);
288 282
289 // fill 283 // fill
290 QPixmap *pix; 284 QPixmap *pix;
291 if(h >= 32){ 285 if(h >= 32){
292 pix = bevelFillDict.find(c.rgb()); 286 pix = bevelFillDict.find(c.rgb());
293 if(!pix){ 287 if(!pix){
294 int h, s, v; 288 int h, s, v;
295 c.hsv(&h, &s, &v); 289 c.hsv(&h, &s, &v);
296 pix = new QPixmap(*bevelFillPix); 290 pix = new QPixmap(*bevelFillPix);
297 adjustHSV(*pix, h, s, v); 291 adjustHSV(*pix, h, s, v);
298 bevelFillDict.insert(c.rgb(), pix); 292 bevelFillDict.insert(c.rgb(), pix);
299 } 293 }
300 } 294 }
301 else{ 295 else{
302 pix = smallBevelFillDict.find(c.rgb()); 296 pix = smallBevelFillDict.find(c.rgb());
303 if(!pix){ 297 if(!pix){
304 int h, s, v; 298 int h, s, v;
305 c.hsv(&h, &s, &v); 299 c.hsv(&h, &s, &v);
306 pix = new QPixmap(*smallBevelFillPix); 300 pix = new QPixmap(*smallBevelFillPix);
307 adjustHSV(*pix, h, s, v); 301 adjustHSV(*pix, h, s, v);
308 smallBevelFillDict.insert(c.rgb(), pix); 302 smallBevelFillDict.insert(c.rgb(), pix);
309 } 303 }
310 } 304 }
311 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); 305 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
312 // blend 306 // blend
313 int red, green, blue; 307 int red, green, blue;
314 QColor btnColor(c.dark(130)); 308 QColor btnColor(c.dark(130));
315 red = (btnColor.red() >> 1) + (bg.red() >> 1); 309 red = (btnColor.red() >> 1) + (bg.red() >> 1);
316 green = (btnColor.green() >> 1) + (bg.green() >> 1); 310 green = (btnColor.green() >> 1) + (bg.green() >> 1);
317 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); 311 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
318 btnColor.setRgb(red, green, blue); 312 btnColor.setRgb(red, green, blue);
319 313
320 p->setPen(btnColor); 314 p->setPen(btnColor);
321 p->drawPoint(x+1, y); 315 p->drawPoint(x+1, y);
322 p->drawPoint(x, y+1); 316 p->drawPoint(x, y+1);
323 p->drawPoint(x+1, y2); 317 p->drawPoint(x+1, y2);
324 p->drawPoint(x, y2-1); 318 p->drawPoint(x, y2-1);
325 319
326 p->drawPoint(x2-1, y); 320 p->drawPoint(x2-1, y);
327 p->drawPoint(x2, y+1); 321 p->drawPoint(x2, y+1);
328 p->drawPoint(x2-1, y2); 322 p->drawPoint(x2-1, y2);
329 p->drawPoint(x2, y2-1); 323 p->drawPoint(x2, y2-1);
330 324
331 p->setPen(oldPen); 325 p->setPen(oldPen);
332 326
333} 327}
334 328
335void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, 329void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
336 const QColor &back, int x, int y, int w, int h, 330 const QColor &back, int x, int y, int w, int h,
337 bool supportPushDown, bool pushedDown, 331 bool supportPushDown, bool pushedDown,
338 bool autoDefault, bool isMasked) 332 bool autoDefault, bool isMasked)
339{ 333{
340 if(w < 21 || h < 21){ 334 if(w < 21 || h < 21){
341 drawClearBevel(painter, x, y, w, h, c, back); 335 drawClearBevel(painter, x, y, w, h, c, back);
342 return; 336 return;
343 } 337 }
344 if(supportPushDown){ 338 if(supportPushDown){
345 --w, --h; 339 --w, --h;
346 } 340 }
347 /* We don't make the round buttons smaller, since they don't look as good 341 /* We don't make the round buttons smaller, since they don't look as good
348 if(autoDefault){ 342 if(autoDefault){
349 w = w-buttonDefaultIndicatorWidth()*2; 343 w = w-buttonDefaultIndicatorWidth()*2;
350 h = h-buttonDefaultIndicatorWidth()*2; 344 h = h-buttonDefaultIndicatorWidth()*2;
351 }*/ 345 }*/
352 346
353 347
354 QPixmap *pix = btnDict.find(c.rgb()); 348 QPixmap *pix = btnDict.find(c.rgb());
355 if(!pix){ 349 if(!pix){
356 int h, s, v; 350 int h, s, v;
357 c.hsv(&h, &s, &v); 351 c.hsv(&h, &s, &v);
358 pix = new QPixmap(*btnBorderPix); 352 pix = new QPixmap(*btnBorderPix);
359 adjustHSV(*pix, h, s, v); 353 adjustHSV(*pix, h, s, v);
360 btnDict.insert(c.rgb(), pix); 354 btnDict.insert(c.rgb(), pix);
361 } 355 }
362 int x2 = x+w-1; 356 int x2 = x+w-1;
363 int y2 = y+h-1; 357 int y2 = y+h-1;
364 int bx2 = pix->width()-1; 358 int bx2 = pix->width()-1;
365 int by2 = pix->height()-1; 359 int by2 = pix->height()-1;
366 360
367 QPixmap tmpPix(w, h); 361 QPixmap tmpPix(w, h);
368 QPixmap tilePix; 362 QPixmap tilePix;
369 QPainter p; 363 QPainter p;
370 p.begin(&tmpPix); 364 p.begin(&tmpPix);
371 365
372 // do the fill 366 // do the fill
373 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl 367 p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
374 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr 368 p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
375 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl 369 p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
@@ -518,440 +512,437 @@ QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
518 float intensity = v/255.0; 512 float intensity = v/255.0;
519 513
520 for(current=0; current<total; ++current){ 514 for(current=0; current<total; ++current){
521 alpha = qAlpha(data[current]); 515 alpha = qAlpha(data[current]);
522 c.setRgb(data[current]); 516 c.setRgb(data[current]);
523 c.hsv(&oldH, &oldS, &oldV); 517 c.hsv(&oldH, &oldS, &oldV);
524 oldV = (int)(oldV*intensity); 518 oldV = (int)(oldV*intensity);
525 c.setHsv(h, s, oldV); 519 c.setHsv(h, s, oldV);
526 if(blend && alpha != 255 && alpha != 0){ 520 if(blend && alpha != 255 && alpha != 0){
527 float srcPercent = ((float)alpha)/255.0; 521 float srcPercent = ((float)alpha)/255.0;
528 float destPercent = 1.0-srcPercent; 522 float destPercent = 1.0-srcPercent;
529 oldH = (int)((srcPercent*h) + (destPercent*bH)); 523 oldH = (int)((srcPercent*h) + (destPercent*bH));
530 oldS = (int)((srcPercent*s) + (destPercent*bS)); 524 oldS = (int)((srcPercent*s) + (destPercent*bS));
531 oldV = (int)((srcPercent*oldV) + (destPercent*bV)); 525 oldV = (int)((srcPercent*oldV) + (destPercent*bV));
532 c.setHsv(oldH, oldS, oldV); 526 c.setHsv(oldH, oldS, oldV);
533 alpha = 255; 527 alpha = 255;
534 } 528 }
535 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); 529 data[current] = qRgba(c.red(), c.green(), c.blue(), alpha);
536 } 530 }
537 QPixmap *pix = new QPixmap; 531 QPixmap *pix = new QPixmap;
538 pix->convertFromImage(img); 532 pix->convertFromImage(img);
539 return(pix); 533 return(pix);
540} 534}
541 535
542 536
543 537
544 538
545QPixmap* LiquidStyle::getPixmap(BitmapData item) 539QPixmap* LiquidStyle::getPixmap(BitmapData item)
546{ 540{
547 541
548 if(pixmaps[item]) 542 if(pixmaps[item])
549 return(pixmaps[item]); 543 return(pixmaps[item]);
550 544
551 switch(item){ 545 switch(item){
552 case HTMLBtnBorder: 546 case HTMLBtnBorder:
553 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); 547 pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV);
554 break; 548 break;
555 case HTMLBtnBorderDown: 549 case HTMLBtnBorderDown:
556 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); 550 pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV);
557 break; 551 break;
558 552
559 case HTMLCB: 553 case HTMLCB:
560 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); 554 pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV);
561 break; 555 break;
562 case HTMLCBHover: 556 case HTMLCBHover:
563 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV); 557 pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV);
564 break; 558 break;
565 case HTMLCBDown: 559 case HTMLCBDown:
566 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); 560 pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV);
567 break; 561 break;
568 case HTMLCBDownHover: 562 case HTMLCBDownHover:
569 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV); 563 pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV);
570 break; 564 break;
571 565
572 case HTMLRadio: 566 case HTMLRadio:
573 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); 567 pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV);
574 break; 568 break;
575 case HTMLRadioHover: 569 case HTMLRadioHover:
576 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV); 570 pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV);
577 break; 571 break;
578 case HTMLRadioDown: 572 case HTMLRadioDown:
579 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); 573 pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV);
580 break; 574 break;
581 case HTMLRadioDownHover: 575 case HTMLRadioDownHover:
582 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV); 576 pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV);
583 break; 577 break;
584 578
585 case RadioOff: 579 case RadioOff:
586 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/); 580 pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/);
587 break; 581 break;
588 case RadioOffHover: 582 case RadioOffHover:
589 pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/); 583 pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/);
590 break; 584 break;
591 case RadioOn: 585 case RadioOn:
592 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/); 586 pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/);
593 break; 587 break;
594 case RadioOnHover: 588 case RadioOnHover:
595 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/); 589 pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/);
596 break; 590 break;
597 591
598 case Tab: 592 case Tab:
599 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/); 593 pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/);
600 break; 594 break;
601 case TabDown: 595 case TabDown:
602 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/); 596 pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/);
603 break; 597 break;
604 case TabFocus: 598 case TabFocus:
605 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/); 599 pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/);
606 break; 600 break;
607 601
608 case CB: 602 case CB:
609 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/); 603 pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/);
610 break; 604 break;
611 case CBHover: 605 case CBHover:
612 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/); 606 pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/);
613 break; 607 break;
614 case CBDown: 608 case CBDown:
615 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/); 609 pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/);
616 break; 610 break;
617 case CBDownHover: 611 case CBDownHover:
618 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/); 612 pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/);
619 break; 613 break;
620 614
621 case VSlider: 615 case VSlider:
622 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true ); 616 pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true );
623 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); 617 *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix);
624 break; 618 break;
625 case VSBSliderTop: 619 case VSBSliderTop:
626 case VSBSliderTopHover: 620 case VSBSliderTopHover:
627 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/); 621 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/);
628 break; 622 break;
629 case VSBSliderBtm: 623 case VSBSliderBtm:
630 case VSBSliderBtmHover: 624 case VSBSliderBtmHover:
631 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/); 625 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/);
632 break; 626 break;
633 case VSBSliderMid: 627 case VSBSliderMid:
634 case VSBSliderMidHover: 628 case VSBSliderMidHover:
635 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 629 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
636 break; 630 break;
637 case VSBSliderTopBg: 631 case VSBSliderTopBg:
638 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/); 632 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/);
639 break; 633 break;
640 case VSBSliderBtmBg: 634 case VSBSliderBtmBg:
641 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/); 635 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/);
642 break; 636 break;
643 case VSBSliderMidBg: 637 case VSBSliderMidBg:
644 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 638 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
645 break; 639 break;
646 640
647 case HSlider: 641 case HSlider:
648 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/); 642 pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/);
649 break; 643 break;
650 case HSBSliderTop: 644 case HSBSliderTop:
651 case HSBSliderTopHover: 645 case HSBSliderTopHover:
652 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true ); 646 pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true );
653 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 647 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
654 break; 648 break;
655 case HSBSliderBtm: 649 case HSBSliderBtm:
656 case HSBSliderBtmHover: 650 case HSBSliderBtmHover:
657 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true ); 651 pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true );
658 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 652 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
659 break; 653 break;
660 case HSBSliderMid: 654 case HSBSliderMid:
661 case HSBSliderMidHover: 655 case HSBSliderMidHover:
662 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 656 pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
663 *pixmaps[item] = pixmaps[item]->xForm(rMatrix); 657 *pixmaps[item] = pixmaps[item]->xForm(rMatrix);
664 break; 658 break;
665 case HSBSliderTopBg: 659 case HSBSliderTopBg:
666 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true ); 660 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true );
667 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); 661 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
668 break; 662 break;
669 case HSBSliderBtmBg: 663 case HSBSliderBtmBg:
670 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true ); 664 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true );
671 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); 665 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
672 break; 666 break;
673 case HSBSliderMidBg: 667 case HSBSliderMidBg:
674 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 668 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
675 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); 669 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix);
676 break; 670 break;
677 default: 671 default:
678 break; 672 break;
679 } 673 }
680 return(pixmaps[item]); 674 return(pixmaps[item]);
681} 675}
682 676
683void LiquidStyle::polish(QPalette &appPal) 677void LiquidStyle::polish(QPalette &appPal)
684{ 678{
685 int i; 679 int i;
686 for(i=0; i < BITMAP_ITEMS; ++i){ 680 for(i=0; i < BITMAP_ITEMS; ++i){
687 if(pixmaps[i]){ 681 if(pixmaps[i]){
688 delete pixmaps[i]; 682 delete pixmaps[i];
689 pixmaps[i] = NULL; 683 pixmaps[i] = NULL;
690 } 684 }
691 } 685 }
692 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; 686 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
693 btnDict.clear(); 687 btnDict.clear();
694 btnBorderDict.clear(); 688 btnBorderDict.clear();
695 bevelFillDict.clear(); 689 bevelFillDict.clear();
696 smallBevelFillDict.clear(); 690 smallBevelFillDict.clear();
697 691
698 Config config ( "qpe" ); 692 Config config ( "qpe" );
699 config. setGroup ( "Liquid-Style" ); 693 config. setGroup ( "Liquid-Style" );
700 int contrast = config. readNumEntry ( "StippleContrast", 5 ); 694 int contrast = config. readNumEntry ( "StippleContrast", 5 );
701 if ( contrast < 0 ) 695 if ( contrast < 0 )
702 contrast = 0; 696 contrast = 0;
703 else if ( contrast > 10 ) 697 else if ( contrast > 10 )
704 contrast = 10; 698 contrast = 10;
705 699
706// QPalette pal = QApplication::palette(); 700// QPalette pal = QApplication::palette();
707 701
708 // button color stuff 702 // button color stuff
709 config. setGroup ( "Appearance" ); 703 config. setGroup ( "Appearance" );
710 QColor c = oldqte ? QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))) 704 QColor c = appPal. color ( QPalette::Active, QColorGroup::Button );
711 : appPal. color ( QPalette::Active, QColorGroup::Button ); 705 if ( c == appPal. color ( QPalette::Active, QColorGroup::Background )) {
712 if ( c == ( oldqte ? QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))
713 : appPal. color ( QPalette::Active, QColorGroup::Background ))) {
714 // force button color to be different from background 706 // force button color to be different from background
715 QBrush btnBrush(QColor(200, 202, 228)); 707 QBrush btnBrush(QColor(200, 202, 228));
716 appPal.setBrush(QColorGroup::Button, btnBrush); 708 appPal.setBrush(QColorGroup::Button, btnBrush);
717 } 709 }
718 c.hsv(&btnH, &btnS, &btnV); 710 c.hsv(&btnH, &btnS, &btnV);
719 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); 711 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV);
720 712
721 // menu pixmap 713 // menu pixmap
722 if(!menuPix){ 714 if(!menuPix){
723 menuPix = new QPixmap; 715 menuPix = new QPixmap;
724 menuPix->resize(64, 64); 716 menuPix->resize(64, 64);
725 } 717 }
726 QPainter painter; 718 QPainter painter;
727 menuPix->fill(c.rgb()); 719 menuPix->fill(c.rgb());
728 painter.begin(menuPix); 720 painter.begin(menuPix);
729 painter.setPen(c.dark(105)); 721 painter.setPen(c.dark(105));
730 for(i=0; i < 63; i+=4){ 722 for(i=0; i < 63; i+=4){
731 painter.drawLine(0, i, 63, i); 723 painter.drawLine(0, i, 63, i);
732 painter.drawLine(0, i+1, 63, i+1); 724 painter.drawLine(0, i+1, 63, i+1);
733 }; 725 };
734 painter.end(); 726 painter.end();
735 menuBrush.setColor(c); 727 menuBrush.setColor(c);
736 menuBrush.setPixmap(*menuPix); 728 menuBrush.setPixmap(*menuPix);
737 729
738 // pager brush 730 // pager brush
739 c = c.dark(120); 731 c = c.dark(120);
740 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 732 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
741 if(!pix){ 733 if(!pix){
742 int h, s, v; 734 int h, s, v;
743 c.hsv(&h, &s, &v); 735 c.hsv(&h, &s, &v);
744 pix = new QPixmap(*smallBevelFillPix); 736 pix = new QPixmap(*smallBevelFillPix);
745 adjustHSV(*pix, h, s, v); 737 adjustHSV(*pix, h, s, v);
746 smallBevelFillDict.insert(c.rgb(), pix); 738 smallBevelFillDict.insert(c.rgb(), pix);
747 } 739 }
748// pagerHoverBrush.setColor(c); 740// pagerHoverBrush.setColor(c);
749// pagerHoverBrush.setPixmap(*pix); 741// pagerHoverBrush.setPixmap(*pix);
750 742
751 c = c.dark(120); 743 c = c.dark(120);
752 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 744 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
753 if(!pix){ 745 if(!pix){
754 int h, s, v; 746 int h, s, v;
755 c.hsv(&h, &s, &v); 747 c.hsv(&h, &s, &v);
756 pix = new QPixmap(*smallBevelFillPix); 748 pix = new QPixmap(*smallBevelFillPix);
757 adjustHSV(*pix, h, s, v); 749 adjustHSV(*pix, h, s, v);
758 smallBevelFillDict.insert(c.rgb(), pix); 750 smallBevelFillDict.insert(c.rgb(), pix);
759 } 751 }
760// pagerBrush.setColor(c); 752// pagerBrush.setColor(c);
761// pagerBrush.setPixmap(*pix); 753// pagerBrush.setPixmap(*pix);
762 754
763 // background color stuff 755 // background color stuff
764 c = oldqte ? QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))) 756 c = appPal. color ( QPalette::Active, QColorGroup::Background );
765 : appPal. color ( QPalette::Active, QColorGroup::Background );
766 757
767 c.hsv(&bH, &bS, &bV); 758 c.hsv(&bH, &bS, &bV);
768 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); 759 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
769 760
770 // FIXME? 761 // FIXME?
771 if(vsbSliderFillPix) 762 if(vsbSliderFillPix)
772 delete vsbSliderFillPix; 763 delete vsbSliderFillPix;
773 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); 764 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
774 adjustHSV(*vsbSliderFillPix, bH, bS, bV); 765 adjustHSV(*vsbSliderFillPix, bH, bS, bV);
775 766
776 // background brush 767 // background brush
777 QPixmap wallPaper(32, 32); 768 QPixmap wallPaper(32, 32);
778 wallPaper.fill(c.rgb()); 769 wallPaper.fill(c.rgb());
779 painter.begin(&wallPaper); 770 painter.begin(&wallPaper);
780 for(i=0; i < 32; i+=4){ 771 for(i=0; i < 32; i+=4){
781 painter.setPen(c.dark(100 + contrast)); 772 painter.setPen(c.dark(100 + contrast));
782 painter.drawLine(0, i, 32, i); 773 painter.drawLine(0, i, 32, i);
783 painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); 774 painter.setPen(c.dark(100 + 3 * contrast / 5 ) );
784 painter.drawLine(0, i+1, 32, i+1); 775 painter.drawLine(0, i+1, 32, i+1);
785 }; 776 };
786 painter.end(); 777 painter.end();
787 bgBrush.setColor(c); 778 bgBrush.setColor(c);
788 bgBrush.setPixmap(wallPaper); 779 bgBrush.setPixmap(wallPaper);
789 appPal.setBrush(QColorGroup::Background, bgBrush); 780 appPal.setBrush(QColorGroup::Background, bgBrush);
790} 781}
791 782
792void LiquidStyle::polish(QWidget *w) 783void LiquidStyle::polish(QWidget *w)
793{ 784{
794 if(w->inherits("QMenuBar")){ 785 if(w->inherits("QMenuBar")){
795 //((QFrame*)w)->setLineWidth(0); 786 //((QFrame*)w)->setLineWidth(0);
796 w->setBackgroundMode(QWidget::PaletteBackground); 787 w->setBackgroundMode(QWidget::PaletteBackground);
797 w->setBackgroundOrigin(QWidget::ParentOrigin); 788 w->setBackgroundOrigin(QWidget::ParentOrigin);
798 return; 789 return;
799 } 790 }
800 if(w->inherits("QToolBar")){ 791 if(w->inherits("QToolBar")){
801 w->installEventFilter(this); 792 w->installEventFilter(this);
802 w->setBackgroundMode(QWidget::PaletteBackground); 793 w->setBackgroundMode(QWidget::PaletteBackground);
803 w->setBackgroundOrigin(QWidget::WidgetOrigin); 794 w->setBackgroundOrigin(QWidget::WidgetOrigin);
804 return; 795 return;
805 } 796 }
806 if(w->inherits("QPopupMenu")) 797 if(w->inherits("QPopupMenu"))
807 w->setBackgroundMode(QWidget::NoBackground); 798 w->setBackgroundMode(QWidget::NoBackground);
808 else if(w-> testWFlags(Qt::WType_Popup) && 799 else if(w-> testWFlags(Qt::WType_Popup) &&
809 !w->inherits("QListBox") && 800 !w->inherits("QListBox") &&
810 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 801 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
811 w->installEventFilter(menuHandler); 802 w->installEventFilter(menuHandler);
812 } 803 }
813 804
814 if(w->isTopLevel()){ 805 if(w->isTopLevel()){
815 return; 806 return;
816 } 807 }
817 808
818 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { 809 if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
819 w->installEventFilter(this); 810 w->installEventFilter(this);
820 } 811 }
821 812
822 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 813 if(w->inherits("QButton") || w-> inherits("QComboBox")){
823 w-> setBackgroundMode ( QWidget::PaletteBackground ); 814 w-> setBackgroundMode ( QWidget::PaletteBackground );
824 w->setBackgroundOrigin ( QWidget::ParentOrigin); 815 w->setBackgroundOrigin ( QWidget::ParentOrigin);
825 } 816 }
826 817
827 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 818 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
828 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 819 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
829 bool isViewportChild = w->parent() && 820 bool isViewportChild = w->parent() &&
830 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 821 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
831 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 822 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
832 823
833 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ 824 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
834 w->setBackgroundMode(QWidget::X11ParentRelative); 825 w->setBackgroundMode(QWidget::X11ParentRelative);
835 return; 826 return;
836 } 827 }
837 if(isViewportChild){ 828 if(isViewportChild){
838 if(w->inherits("QButton") || w->inherits("QComboBox")){ 829 if(w->inherits("QButton") || w->inherits("QComboBox")){
839 if(w->parent()){ // heh, only way to test for KHTML children ;-) 830 if(w->parent()){ // heh, only way to test for KHTML children ;-)
840 if(w->parent()->parent()){ 831 if(w->parent()->parent()){
841 if(w->parent()->parent()->parent() && 832 if(w->parent()->parent()->parent() &&
842 w->parent()->parent()->parent()->inherits("KHTMLView")){ 833 w->parent()->parent()->parent()->inherits("KHTMLView")){
843 w->setAutoMask(true); 834 w->setAutoMask(true);
844 w->setBackgroundMode(QWidget::NoBackground); 835 w->setBackgroundMode(QWidget::NoBackground);
845 } 836 }
846 } 837 }
847 } 838 }
848 return; 839 return;
849 } 840 }
850 } 841 }
851 if(w->inherits("QHeader")){ 842 if(w->inherits("QHeader")){
852 w->setMouseTracking(true); 843 w->setMouseTracking(true);
853 w->installEventFilter(this); 844 w->installEventFilter(this);
854 } 845 }
855 if(w-> inherits("QToolButton")) { 846 if(w-> inherits("QToolButton")) {
856 if (w->parent()->inherits("QToolBar")) { 847 if (w->parent()->inherits("QToolBar")) {
857 ((QToolButton*)w)->setAutoRaise (flatTBButtons); 848 ((QToolButton*)w)->setAutoRaise (flatTBButtons);
858 if ( flatTBButtons ) 849 if ( flatTBButtons )
859 w->setBackgroundOrigin(QWidget::ParentOrigin); 850 w->setBackgroundOrigin(QWidget::ParentOrigin);
860 } 851 }
861 w-> installEventFilter ( this ); 852 w-> installEventFilter ( this );
862 } 853 }
863 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { 854 if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
864 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); 855 ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
865 } 856 }
866 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 857 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
867 return; 858 return;
868 } 859 }
869 860
870 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 861 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
871 palette().active().brush(QColorGroup::Background).pixmap()){ 862 palette().active().brush(QColorGroup::Background).pixmap()){
872 qWarning("No parent pixmap for child widget %s", w->className()); 863 qWarning("No parent pixmap for child widget %s", w->className());
873 return; 864 return;
874 } 865 }
875 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 866 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
876 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 867 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
877 if(w->backgroundMode() == QWidget::PaletteBackground || 868 if(w->backgroundMode() == QWidget::PaletteBackground ||
878 w->backgroundMode() == QWidget::PaletteButton){ 869 w->backgroundMode() == QWidget::PaletteButton){
879 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); 870 w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
880 w->setBackgroundOrigin(QWidget::ParentOrigin); 871 w->setBackgroundOrigin(QWidget::ParentOrigin);
881 // w->setBackgroundMode(QWidget::NoBackground); 872 // w->setBackgroundMode(QWidget::NoBackground);
882 } 873 }
883 } 874 }
884 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) 875 if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
885 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 876 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
886 else if ( w-> inherits("QFrame") ) 877 else if ( w-> inherits("QFrame") )
887 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 878 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
888 879
889 if ( w->parentWidget()->inherits ( "QWidgetStack" )) { 880 if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
890 w->setBackgroundOrigin ( QWidget::WidgetOrigin ); 881 w->setBackgroundOrigin ( QWidget::WidgetOrigin );
891 } 882 }
892} 883}
893 884
894void LiquidStyle::unPolish(QWidget *w) 885void LiquidStyle::unPolish(QWidget *w)
895{ 886{
896 if(w->inherits("QMenuBar")){ 887 if(w->inherits("QMenuBar")){
897 ((QFrame *)w)->setLineWidth(1); 888 ((QFrame *)w)->setLineWidth(1);
898 w->setBackgroundMode(QWidget::PaletteBackground); 889 w->setBackgroundMode(QWidget::PaletteBackground);
899 return; 890 return;
900 } 891 }
901 892
902 if(w->inherits("QPopupMenu")) 893 if(w->inherits("QPopupMenu"))
903 w->setBackgroundMode(QWidget::PaletteButton); 894 w->setBackgroundMode(QWidget::PaletteButton);
904 else if(w-> testWFlags(Qt::WType_Popup) && 895 else if(w-> testWFlags(Qt::WType_Popup) &&
905 !w->inherits("QListBox") && 896 !w->inherits("QListBox") &&
906 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { 897 ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
907 w->removeEventFilter(menuHandler); 898 w->removeEventFilter(menuHandler);
908 } 899 }
909 900
910 if(w->isTopLevel()) 901 if(w->isTopLevel())
911 return; 902 return;
912 903
913 // for viewport children, don't just check for NoBackground.... 904 // for viewport children, don't just check for NoBackground....
914 bool isViewportChild = w->parent() && 905 bool isViewportChild = w->parent() &&
915 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 906 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
916 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 907 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
917 908
918 w->unsetPalette(); 909 w->unsetPalette();
919 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 910 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
920 if(w->inherits("QPushButton")) 911 if(w->inherits("QPushButton"))
921 w->setBackgroundMode(QWidget::PaletteButton); 912 w->setBackgroundMode(QWidget::PaletteButton);
922 else 913 else
923 w->setBackgroundMode(QWidget::PaletteBackground); 914 w->setBackgroundMode(QWidget::PaletteBackground);
924 } 915 }
925 916
926 if(isViewportChild) 917 if(isViewportChild)
927 w->setAutoMask(false); 918 w->setAutoMask(false);
928 919
929/* 920/*
930 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ 921 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
931 w-> setBackgroundMode ( PaletteBackground ); 922 w-> setBackgroundMode ( PaletteBackground );
932 } 923 }
933*/ 924*/
934 if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) { 925 if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
935 w->removeEventFilter(this); 926 w->removeEventFilter(this);
936 } 927 }
937 if(w->inherits("QButton") || w->inherits("QComboBox")){ 928 if(w->inherits("QButton") || w->inherits("QComboBox")){
938 if(w->parent() && w->parent()->inherits("KHTMLPart")){ 929 if(w->parent() && w->parent()->inherits("KHTMLPart")){
939 w->setAutoMask(false); 930 w->setAutoMask(false);
940 } 931 }
941 } 932 }
942 if(w-> inherits("QToolButton")) { 933 if(w-> inherits("QToolButton")) {
943 w-> removeEventFilter ( this ); 934 w-> removeEventFilter ( this );
944 } 935 }
945 if(w->inherits("QToolBar")){ 936 if(w->inherits("QToolBar")){
946 w->removeEventFilter(this); 937 w->removeEventFilter(this);
947 w->setBackgroundMode(QWidget::PaletteBackground); 938 w->setBackgroundMode(QWidget::PaletteBackground);
948 return; 939 return;
949 } 940 }
950 if(w->inherits("QHeader")){ 941 if(w->inherits("QHeader")){
951 w->setMouseTracking(false); 942 w->setMouseTracking(false);
952 w->removeEventFilter(this); 943 w->removeEventFilter(this);
953 } 944 }
954} 945}
955 946
956void LiquidStyle::polish(QApplication *app) 947void LiquidStyle::polish(QApplication *app)
957{ 948{