summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp14
-rw-r--r--noncore/styles/liquid/plugin.cpp2
2 files changed, 3 insertions, 13 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 4653639..2b6eaa4 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,363 +1,354 @@
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 6
7#ifndef INCLUDE_MENUITEM_DEF 7#ifndef INCLUDE_MENUITEM_DEF
8#define INCLUDE_MENUITEM_DEF 8#define INCLUDE_MENUITEM_DEF
9#endif 9#endif
10 10
11#include <qmenudata.h> 11#include <qmenudata.h>
12#include "liquid.h" 12#include "liquid.h"
13#include <qapplication.h> 13#include <qapplication.h>
14#include <qpe/config.h> 14#include <qpe/config.h>
15#include "effects.h" 15#include "effects.h"
16#include <qpalette.h> 16#include <qpalette.h>
17#include <qbitmap.h> 17#include <qbitmap.h>
18#include <qtabbar.h> 18#include <qtabbar.h>
19#include <qpopupmenu.h> 19#include <qpopupmenu.h>
20#include <qobjectlist.h> 20#include <qobjectlist.h>
21#include <qimage.h> 21#include <qimage.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qpixmapcache.h> 23#include <qpixmapcache.h>
24#include <qradiobutton.h> 24#include <qradiobutton.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qdrawutil.h> 26#include <qdrawutil.h>
27#include <qwidgetlist.h> 27#include <qwidgetlist.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qheader.h> 29#include <qheader.h>
30#include <unistd.h> 30#include <unistd.h>
31#include <qmenubar.h> 31#include <qmenubar.h>
32 32
33 33
34#include <stdio.h> 34#include <stdio.h>
35 35
36#include "htmlmasks.h" 36#include "htmlmasks.h"
37#include "embeddata.h" 37#include "embeddata.h"
38 38
39typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 39typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
40 QColorGroup &, bool, bool); 40 QColorGroup &, bool, bool);
41 41
42QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 42QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
43 43
44void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 44void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
45{ 45{
46 QImage img(pix.convertToImage()); 46 QImage img(pix.convertToImage());
47 QImageEffect::fade(img, 0.9, color); 47 QImageEffect::fade(img, 0.9, color);
48 int x, y; 48 int x, y;
49 int r, g, b; 49 int r, g, b;
50 for(y=0; y < img.height(); y+=3){ 50 for(y=0; y < img.height(); y+=3){
51 unsigned int *data = (unsigned int *) img.scanLine(y); 51 unsigned int *data = (unsigned int *) img.scanLine(y);
52 for(x=0; x < img.width(); ++x){ 52 for(x=0; x < img.width(); ++x){
53 r = qRed(data[x]); 53 r = qRed(data[x]);
54 g = qGreen(data[x]); 54 g = qGreen(data[x]);
55 b = qBlue(data[x]); 55 b = qBlue(data[x]);
56 if(r-10) 56 if(r-10)
57 r-=10; 57 r-=10;
58 if(g-10) 58 if(g-10)
59 g-=10; 59 g-=10;
60 if(b-10) 60 if(b-10)
61 b-=10; 61 b-=10;
62 data[x] = qRgb(r, g, b); 62 data[x] = qRgb(r, g, b);
63 } 63 }
64 } 64 }
65 pix.convertFromImage(img); 65 pix.convertFromImage(img);
66} 66}
67 67
68TransMenuHandler::TransMenuHandler(QObject *parent) 68TransMenuHandler::TransMenuHandler(QObject *parent)
69 : QObject(parent) 69 : QObject(parent)
70{ 70{
71 pixDict.setAutoDelete(true); 71 pixDict.setAutoDelete(true);
72 reloadSettings(); 72 reloadSettings();
73} 73}
74 74
75void TransMenuHandler::reloadSettings() 75void TransMenuHandler::reloadSettings()
76{ 76{
77 pixDict.clear(); 77 pixDict.clear();
78 78
79 Config config ( "qpe" ); 79 Config config ( "qpe" );
80 config. setGroup ( "MosfetMenus" ); 80 config. setGroup ( "MosfetMenus" );
81 81
82 type = config. readNumEntry("Type", TransStippleBg); 82 type = config. readNumEntry("Type", TransStippleBg);
83 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 83 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
84 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 84 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
85 opacity = config. readNumEntry("Opacity", 10); 85 opacity = config. readNumEntry("Opacity", 10);
86 if ( opacity < -20 ) 86 if ( opacity < -20 )
87 opacity = 20; 87 opacity = 20;
88 else if ( opacity > 20 ) 88 else if ( opacity > 20 )
89 opacity = 20; 89 opacity = 20;
90 90
91 shadowText = config. readBoolEntry("ShadowText", true); 91 shadowText = config. readBoolEntry("ShadowText", true);
92} 92}
93 93
94bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) 94bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
95{ 95{
96 QWidget *p = (QWidget *)obj; 96 QWidget *p = (QWidget *)obj;
97 97
98 if(ev->type() == QEvent::Show){ 98 if(ev->type() == QEvent::Show){
99 if(type == TransStippleBg || type == TransStippleBtn || 99 if(type == TransStippleBg || type == TransStippleBtn ||
100 type == Custom){ 100 type == Custom){
101 QApplication::syncX(); 101 QApplication::syncX();
102 QPixmap *pix = new QPixmap; 102 QPixmap *pix = new QPixmap;
103 if(p->testWFlags(Qt::WType_Popup)){ 103 if(p->testWFlags(Qt::WType_Popup)){
104 QRect r(p->x(), p->y(), p->width(), p->height()); 104 QRect r(p->x(), p->y(), p->width(), p->height());
105 QRect deskR = QApplication::desktop()->rect(); 105 QRect deskR = QApplication::desktop()->rect();
106 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ 106 if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
107 r.setBottom(deskR.bottom()); 107 r.setBottom(deskR.bottom());
108 r.setRight(deskR.right()); 108 r.setRight(deskR.right());
109 } 109 }
110 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), 110 *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
111 r.width(), r.height()); 111 r.width(), r.height());
112 } 112 }
113 else{ // tear off menu 113 else{ // tear off menu
114 pix->resize(p->width(), p->height()); 114 pix->resize(p->width(), p->height());
115 pix->fill(Qt::black.rgb()); 115 pix->fill(Qt::black.rgb());
116 } 116 }
117 if(type == TransStippleBg){ 117 if(type == TransStippleBg){
118 stripePixmap(*pix, p->colorGroup().background()); 118 stripePixmap(*pix, p->colorGroup().background());
119 } 119 }
120 else if(type == TransStippleBtn){ 120 else if(type == TransStippleBtn){
121 stripePixmap(*pix, p->colorGroup().button()); 121 stripePixmap(*pix, p->colorGroup().button());
122 } 122 }
123 else{ 123 else{
124 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); 124 QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
125 } 125 }
126 126
127 if (p->inherits("QPopupMenu")) 127 if (p->inherits("QPopupMenu"))
128 pixDict.insert(p->winId(), pix); 128 pixDict.insert(p->winId(), pix);
129 else { 129 else {
130 p->setBackgroundPixmap(*pix); 130 p->setBackgroundPixmap(*pix);
131 131
132 QObjectList *ol = p-> queryList("QWidget"); 132 QObjectList *ol = p-> queryList("QWidget");
133 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 133 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
134 QWidget *wid = (QWidget *) it.current ( ); 134 QWidget *wid = (QWidget *) it.current ( );
135 135
136 wid-> setBackgroundPixmap(*pix); 136 wid-> setBackgroundPixmap(*pix);
137 wid-> setBackgroundOrigin(QWidget::ParentOrigin); 137 wid-> setBackgroundOrigin(QWidget::ParentOrigin);
138 } 138 }
139 delete ol; 139 delete ol;
140 } 140 }
141 } 141 }
142 } 142 }
143 else if(ev->type() == QEvent::Hide){ 143 else if(ev->type() == QEvent::Hide){
144 if(type == TransStippleBg || type == TransStippleBtn || 144 if(type == TransStippleBg || type == TransStippleBtn ||
145 type == Custom){ 145 type == Custom){
146// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); 146// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
147 147
148 if (p->inherits("QPopupMenu")) 148 if (p->inherits("QPopupMenu"))
149 pixDict.remove(p->winId()); 149 pixDict.remove(p->winId());
150 else { 150 else {
151 p->setBackgroundMode(QWidget::PaletteBackground); 151 p->setBackgroundMode(QWidget::PaletteBackground);
152 152
153 QObjectList *ol = p-> queryList("QWidget"); 153 QObjectList *ol = p-> queryList("QWidget");
154 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { 154 for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
155 QWidget *wid = (QWidget *) it.current ( ); 155 QWidget *wid = (QWidget *) it.current ( );
156 156
157 wid-> setBackgroundMode( QWidget::PaletteBackground ); 157 wid-> setBackgroundMode( QWidget::PaletteBackground );
158 } 158 }
159 delete ol; 159 delete ol;
160 } 160 }
161 } 161 }
162 } 162 }
163 else if(ev->type() == QEvent::Paint){
164 if(type == TransStippleBg || type == TransStippleBtn ||
165 type == Custom){
166// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width());
167
168 if (!p->inherits("QPopupMenu"))
169 p->erase();
170 }
171 }
172 return(false); 163 return(false);
173} 164}
174 165
175 166
176LiquidStyle::LiquidStyle() 167LiquidStyle::LiquidStyle()
177 :QWindowsStyle() 168 :QWindowsStyle()
178{ 169{
179 setName ( "LiquidStyle" ); 170 setName ( "LiquidStyle" );
180 171
181 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); 172 btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
182 btnMaskBmp.setMask(btnMaskBmp); 173 btnMaskBmp.setMask(btnMaskBmp);
183 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); 174 htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
184 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); 175 htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
185 headerHoverID = -1; 176 headerHoverID = -1;
186 highlightWidget = NULL; 177 highlightWidget = NULL;
187 setButtonDefaultIndicatorWidth(0); 178 setButtonDefaultIndicatorWidth(0);
188 btnDict.setAutoDelete(true); 179 btnDict.setAutoDelete(true);
189 bevelFillDict.setAutoDelete(true); 180 bevelFillDict.setAutoDelete(true);
190 smallBevelFillDict.setAutoDelete(true); 181 smallBevelFillDict.setAutoDelete(true);
191 customBtnColorList.setAutoDelete(true); 182 customBtnColorList.setAutoDelete(true);
192 customBtnIconList.setAutoDelete(true); 183 customBtnIconList.setAutoDelete(true);
193 customBtnLabelList.setAutoDelete(true); 184 customBtnLabelList.setAutoDelete(true);
194 185
195 rMatrix.rotate(270.0); 186 rMatrix.rotate(270.0);
196 highcolor = QPixmap::defaultDepth() > 8; 187 highcolor = QPixmap::defaultDepth() > 8;
197 btnBorderPix = new QPixmap; 188 btnBorderPix = new QPixmap;
198 btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); 189 btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
199 btnBlendPix = new QPixmap; 190 btnBlendPix = new QPixmap;
200 btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); 191 btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
201 bevelFillPix = new QPixmap; 192 bevelFillPix = new QPixmap;
202 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); 193 bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
203 smallBevelFillPix = new QPixmap; 194 smallBevelFillPix = new QPixmap;
204 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); 195 smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
205 // new stuff 196 // new stuff
206 vsbSliderFillPix = menuPix = NULL; 197 vsbSliderFillPix = menuPix = NULL;
207 menuHandler = new TransMenuHandler(this); 198 menuHandler = new TransMenuHandler(this);
208 setScrollBarExtent(15, 15); 199 setScrollBarExtent(15, 15);
209 int i; 200 int i;
210 for(i=0; i < BITMAP_ITEMS; ++i){ 201 for(i=0; i < BITMAP_ITEMS; ++i){
211 pixmaps[i] = NULL; 202 pixmaps[i] = NULL;
212 } 203 }
213 oldSliderThickness = sliderThickness(); 204 oldSliderThickness = sliderThickness();
214 setSliderThickness(11); 205 setSliderThickness(11);
215} 206}
216 207
217LiquidStyle::~LiquidStyle() 208LiquidStyle::~LiquidStyle()
218{ 209{
219 if(btnBorderPix) 210 if(btnBorderPix)
220 delete btnBorderPix; 211 delete btnBorderPix;
221 if(btnBlendPix) 212 if(btnBlendPix)
222 delete btnBlendPix; 213 delete btnBlendPix;
223 if(bevelFillPix) 214 if(bevelFillPix)
224 delete bevelFillPix; 215 delete bevelFillPix;
225 if(smallBevelFillPix) 216 if(smallBevelFillPix)
226 delete smallBevelFillPix; 217 delete smallBevelFillPix;
227 if(vsbSliderFillPix) 218 if(vsbSliderFillPix)
228 delete vsbSliderFillPix; 219 delete vsbSliderFillPix;
229 if(menuPix) 220 if(menuPix)
230 delete menuPix; 221 delete menuPix;
231 222
232 setScrollBarExtent(16, 16); 223 setScrollBarExtent(16, 16);
233 setSliderThickness(oldSliderThickness); 224 setSliderThickness(oldSliderThickness);
234 int i; 225 int i;
235 for(i=0; i < BITMAP_ITEMS; ++i){ 226 for(i=0; i < BITMAP_ITEMS; ++i){
236 if(pixmaps[i]) 227 if(pixmaps[i])
237 delete pixmaps[i]; 228 delete pixmaps[i];
238 } 229 }
239} 230}
240 231
241void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, 232void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h,
242 const QColor &c, const QColor &bg) 233 const QColor &c, const QColor &bg)
243{ 234{
244 235
245 QPen oldPen = p->pen(); // headers need this 236 QPen oldPen = p->pen(); // headers need this
246 int x2 = x+w-1; 237 int x2 = x+w-1;
247 int y2 = y+h-1; 238 int y2 = y+h-1;
248 // outer dark rect 239 // outer dark rect
249 p->setPen(c.dark(130)); 240 p->setPen(c.dark(130));
250 p->drawLine(x, y+2, x, y2-2); // l 241 p->drawLine(x, y+2, x, y2-2); // l
251 p->drawLine(x2, y+2, x2, y2-2); // r 242 p->drawLine(x2, y+2, x2, y2-2); // r
252 p->drawLine(x+2, y, x2-2, y); // t 243 p->drawLine(x+2, y, x2-2, y); // t
253 p->drawLine(x+2, y2, x2-2, y2); // b 244 p->drawLine(x+2, y2, x2-2, y2); // b
254 p->drawPoint(x+1, y+1); // tl 245 p->drawPoint(x+1, y+1); // tl
255 p->drawPoint(x2-1, y+1); // tr 246 p->drawPoint(x2-1, y+1); // tr
256 p->drawPoint(x+1, y2-1); // bl 247 p->drawPoint(x+1, y2-1); // bl
257 p->drawPoint(x2-1, y2-1); // br 248 p->drawPoint(x2-1, y2-1); // br
258 249
259 // inner top light lines 250 // inner top light lines
260 p->setPen(c.light(105)); 251 p->setPen(c.light(105));
261 p->drawLine(x+2, y+1, x2-2, y+1); 252 p->drawLine(x+2, y+1, x2-2, y+1);
262 p->drawLine(x+1, y+2, x2-1, y+2); 253 p->drawLine(x+1, y+2, x2-1, y+2);
263 p->drawLine(x+1, y+3, x+2, y+3); 254 p->drawLine(x+1, y+3, x+2, y+3);
264 p->drawLine(x2-2, y+3, x2-1, y+3); 255 p->drawLine(x2-2, y+3, x2-1, y+3);
265 p->drawPoint(x+1, y+4); 256 p->drawPoint(x+1, y+4);
266 p->drawPoint(x2-1, y+4); 257 p->drawPoint(x2-1, y+4);
267 258
268 // inner bottom light lines 259 // inner bottom light lines
269 p->setPen(c.light(110)); 260 p->setPen(c.light(110));
270 p->drawLine(x+2, y2-1, x2-2, y2-1); 261 p->drawLine(x+2, y2-1, x2-2, y2-1);
271 p->drawLine(x+1, y2-2, x2-1, y2-2); 262 p->drawLine(x+1, y2-2, x2-1, y2-2);
272 p->drawLine(x+1, y2-3, x+2, y2-3); 263 p->drawLine(x+1, y2-3, x+2, y2-3);
273 p->drawLine(x2-2, y2-3, x2-1, y2-3); 264 p->drawLine(x2-2, y2-3, x2-1, y2-3);
274 p->drawPoint(x+1, y2-4); 265 p->drawPoint(x+1, y2-4);
275 p->drawPoint(x2-1, y2-4); 266 p->drawPoint(x2-1, y2-4);
276 267
277 // inner left mid lines 268 // inner left mid lines
278 //p->setPen(c.light(105)); 269 //p->setPen(c.light(105));
279 p->setPen(c); 270 p->setPen(c);
280 p->drawLine(x+1, y+5, x+1, y2-5); 271 p->drawLine(x+1, y+5, x+1, y2-5);
281 p->drawLine(x+2, y+4, x+2, y2-4); 272 p->drawLine(x+2, y+4, x+2, y2-4);
282 273
283 // inner right mid lines 274 // inner right mid lines
284 p->drawLine(x2-1, y+5, x2-1, y2-5); 275 p->drawLine(x2-1, y+5, x2-1, y2-5);
285 p->drawLine(x2-2, y+4, x2-2, y2-4); 276 p->drawLine(x2-2, y+4, x2-2, y2-4);
286 277
287 // fill 278 // fill
288 QPixmap *pix; 279 QPixmap *pix;
289 if(h >= 32){ 280 if(h >= 32){
290 pix = bevelFillDict.find(c.rgb()); 281 pix = bevelFillDict.find(c.rgb());
291 if(!pix){ 282 if(!pix){
292 int h, s, v; 283 int h, s, v;
293 c.hsv(&h, &s, &v); 284 c.hsv(&h, &s, &v);
294 pix = new QPixmap(*bevelFillPix); 285 pix = new QPixmap(*bevelFillPix);
295 adjustHSV(*pix, h, s, v); 286 adjustHSV(*pix, h, s, v);
296 bevelFillDict.insert(c.rgb(), pix); 287 bevelFillDict.insert(c.rgb(), pix);
297 } 288 }
298 } 289 }
299 else{ 290 else{
300 pix = smallBevelFillDict.find(c.rgb()); 291 pix = smallBevelFillDict.find(c.rgb());
301 if(!pix){ 292 if(!pix){
302 int h, s, v; 293 int h, s, v;
303 c.hsv(&h, &s, &v); 294 c.hsv(&h, &s, &v);
304 pix = new QPixmap(*smallBevelFillPix); 295 pix = new QPixmap(*smallBevelFillPix);
305 adjustHSV(*pix, h, s, v); 296 adjustHSV(*pix, h, s, v);
306 smallBevelFillDict.insert(c.rgb(), pix); 297 smallBevelFillDict.insert(c.rgb(), pix);
307 } 298 }
308 } 299 }
309 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); 300 p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
310 // blend 301 // blend
311 int red, green, blue; 302 int red, green, blue;
312 QColor btnColor(c.dark(130)); 303 QColor btnColor(c.dark(130));
313 red = (btnColor.red() >> 1) + (bg.red() >> 1); 304 red = (btnColor.red() >> 1) + (bg.red() >> 1);
314 green = (btnColor.green() >> 1) + (bg.green() >> 1); 305 green = (btnColor.green() >> 1) + (bg.green() >> 1);
315 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); 306 blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
316 btnColor.setRgb(red, green, blue); 307 btnColor.setRgb(red, green, blue);
317 308
318 p->setPen(btnColor); 309 p->setPen(btnColor);
319 p->drawPoint(x+1, y); 310 p->drawPoint(x+1, y);
320 p->drawPoint(x, y+1); 311 p->drawPoint(x, y+1);
321 p->drawPoint(x+1, y2); 312 p->drawPoint(x+1, y2);
322 p->drawPoint(x, y2-1); 313 p->drawPoint(x, y2-1);
323 314
324 p->drawPoint(x2-1, y); 315 p->drawPoint(x2-1, y);
325 p->drawPoint(x2, y+1); 316 p->drawPoint(x2, y+1);
326 p->drawPoint(x2-1, y2); 317 p->drawPoint(x2-1, y2);
327 p->drawPoint(x2, y2-1); 318 p->drawPoint(x2, y2-1);
328 319
329 p->setPen(oldPen); 320 p->setPen(oldPen);
330 321
331} 322}
332 323
333void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, 324void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
334 const QColor &back, int x, int y, int w, int h, 325 const QColor &back, int x, int y, int w, int h,
335 bool supportPushDown, bool pushedDown, 326 bool supportPushDown, bool pushedDown,
336 bool autoDefault, bool isMasked) 327 bool autoDefault, bool isMasked)
337{ 328{
338 if(w < 21 || h < 21){ 329 if(w < 21 || h < 21){
339 drawClearBevel(painter, x, y, w, h, c, back); 330 drawClearBevel(painter, x, y, w, h, c, back);
340 return; 331 return;
341 } 332 }
342 if(supportPushDown){ 333 if(supportPushDown){
343 --w, --h; 334 --w, --h;
344 } 335 }
345 /* We don't make the round buttons smaller, since they don't look as good 336 /* We don't make the round buttons smaller, since they don't look as good
346 if(autoDefault){ 337 if(autoDefault){
347 w = w-buttonDefaultIndicatorWidth()*2; 338 w = w-buttonDefaultIndicatorWidth()*2;
348 h = h-buttonDefaultIndicatorWidth()*2; 339 h = h-buttonDefaultIndicatorWidth()*2;
349 }*/ 340 }*/
350 341
351 342
352 QPixmap *pix = btnDict.find(c.rgb()); 343 QPixmap *pix = btnDict.find(c.rgb());
353 if(!pix){ 344 if(!pix){
354 int h, s, v; 345 int h, s, v;
355 c.hsv(&h, &s, &v); 346 c.hsv(&h, &s, &v);
356 pix = new QPixmap(*btnBorderPix); 347 pix = new QPixmap(*btnBorderPix);
357 adjustHSV(*pix, h, s, v); 348 adjustHSV(*pix, h, s, v);
358 btnDict.insert(c.rgb(), pix); 349 btnDict.insert(c.rgb(), pix);
359 } 350 }
360 int x2 = x+w-1; 351 int x2 = x+w-1;
361 int y2 = y+h-1; 352 int y2 = y+h-1;
362 int bx2 = pix->width()-1; 353 int bx2 = pix->width()-1;
363 int by2 = pix->height()-1; 354 int by2 = pix->height()-1;
@@ -648,480 +639,479 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
648 *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); 639 *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix);
649 break; 640 break;
650 case HSBSliderMid: 641 case HSBSliderMid:
651 pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); 642 pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
652 *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); 643 *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix);
653 break; 644 break;
654 case HSBSliderTopHover: 645 case HSBSliderTopHover:
655 pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); 646 pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true);
656 *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); 647 *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix);
657 break; 648 break;
658 case HSBSliderBtmHover: 649 case HSBSliderBtmHover:
659 pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); 650 pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true);
660 *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); 651 *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix);
661 break; 652 break;
662 case HSBSliderMidHover: 653 case HSBSliderMidHover:
663 pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); 654 pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV);
664 *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); 655 *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix);
665 break; 656 break;
666 case VSBSliderTopBg: 657 case VSBSliderTopBg:
667 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); 658 pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true);
668 break; 659 break;
669 case VSBSliderBtmBg: 660 case VSBSliderBtmBg:
670 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); 661 pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true);
671 break; 662 break;
672 case VSBSliderMidBg: 663 case VSBSliderMidBg:
673 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 664 pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
674 break; 665 break;
675 case HSBSliderTopBg: 666 case HSBSliderTopBg:
676 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); 667 pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true);
677 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); 668 *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
678 break; 669 break;
679 case HSBSliderBtmBg: 670 case HSBSliderBtmBg:
680 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); 671 pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true);
681 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); 672 *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
682 break; 673 break;
683 case HSBSliderMidBg: 674 case HSBSliderMidBg:
684 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); 675 pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
685 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); 676 *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix);
686 break; 677 break;
687 default: 678 default:
688 break; 679 break;
689 } 680 }
690 return(pixmaps[item]); 681 return(pixmaps[item]);
691} 682}
692 683
693void LiquidStyle::polish(QPalette &appPal) 684void LiquidStyle::polish(QPalette &appPal)
694{ 685{
695 686
696 int i; 687 int i;
697 for(i=0; i < BITMAP_ITEMS; ++i){ 688 for(i=0; i < BITMAP_ITEMS; ++i){
698 if(pixmaps[i]){ 689 if(pixmaps[i]){
699 delete pixmaps[i]; 690 delete pixmaps[i];
700 pixmaps[i] = NULL; 691 pixmaps[i] = NULL;
701 } 692 }
702 } 693 }
703 QWidgetList *list = QApplication::allWidgets(); 694 QWidgetList *list = QApplication::allWidgets();
704 QWidgetListIt it( *list ); 695 QWidgetListIt it( *list );
705 QWidget *w; 696 QWidget *w;
706 while ((w=it.current()) != 0 ){ 697 while ((w=it.current()) != 0 ){
707 ++it; 698 ++it;
708 if(w->inherits("QPushButton")){ 699 if(w->inherits("QPushButton")){
709 unapplyCustomAttributes((QPushButton *)w); 700 unapplyCustomAttributes((QPushButton *)w);
710 } 701 }
711 } 702 }
712 703
713 loadCustomButtons(); 704 loadCustomButtons();
714 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; 705 lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
715 btnDict.clear(); 706 btnDict.clear();
716 btnBorderDict.clear(); 707 btnBorderDict.clear();
717 bevelFillDict.clear(); 708 bevelFillDict.clear();
718 smallBevelFillDict.clear(); 709 smallBevelFillDict.clear();
719 710
720 Config config ( "qpe" ); 711 Config config ( "qpe" );
721 QPalette pal = QApplication::palette(); 712 QPalette pal = QApplication::palette();
722 713
723 // button color stuff 714 // button color stuff
724 config. setGroup ( "Appearance" ); 715 config. setGroup ( "Appearance" );
725 QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); 716 QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( )));
726 if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) { 717 if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) {
727 // force button color to be different from background 718 // force button color to be different from background
728 QBrush btnBrush(QColor(200, 202, 228)); 719 QBrush btnBrush(QColor(200, 202, 228));
729 appPal.setBrush(QColorGroup::Button, btnBrush); 720 appPal.setBrush(QColorGroup::Button, btnBrush);
730 } 721 }
731 c.hsv(&btnH, &btnS, &btnV); 722 c.hsv(&btnH, &btnS, &btnV);
732 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); 723 c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV);
733 724
734 // menu pixmap 725 // menu pixmap
735 if(!menuPix){ 726 if(!menuPix){
736 menuPix = new QPixmap; 727 menuPix = new QPixmap;
737 menuPix->resize(64, 64); 728 menuPix->resize(64, 64);
738 } 729 }
739 QPainter painter; 730 QPainter painter;
740 menuPix->fill(c.rgb()); 731 menuPix->fill(c.rgb());
741 painter.begin(menuPix); 732 painter.begin(menuPix);
742 painter.setPen(c.dark(105)); 733 painter.setPen(c.dark(105));
743 for(i=0; i < 63; i+=4){ 734 for(i=0; i < 63; i+=4){
744 painter.drawLine(0, i, 63, i); 735 painter.drawLine(0, i, 63, i);
745 painter.drawLine(0, i+1, 63, i+1); 736 painter.drawLine(0, i+1, 63, i+1);
746 }; 737 };
747 painter.end(); 738 painter.end();
748 menuBrush.setColor(c); 739 menuBrush.setColor(c);
749 menuBrush.setPixmap(*menuPix); 740 menuBrush.setPixmap(*menuPix);
750 741
751 // pager brush 742 // pager brush
752 c = c.dark(120); 743 c = c.dark(120);
753 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 744 QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
754 if(!pix){ 745 if(!pix){
755 int h, s, v; 746 int h, s, v;
756 c.hsv(&h, &s, &v); 747 c.hsv(&h, &s, &v);
757 pix = new QPixmap(*smallBevelFillPix); 748 pix = new QPixmap(*smallBevelFillPix);
758 adjustHSV(*pix, h, s, v); 749 adjustHSV(*pix, h, s, v);
759 smallBevelFillDict.insert(c.rgb(), pix); 750 smallBevelFillDict.insert(c.rgb(), pix);
760 } 751 }
761 pagerHoverBrush.setColor(c); 752 pagerHoverBrush.setColor(c);
762 pagerHoverBrush.setPixmap(*pix); 753 pagerHoverBrush.setPixmap(*pix);
763 754
764 c = c.dark(120); 755 c = c.dark(120);
765 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) 756 pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
766 if(!pix){ 757 if(!pix){
767 int h, s, v; 758 int h, s, v;
768 c.hsv(&h, &s, &v); 759 c.hsv(&h, &s, &v);
769 pix = new QPixmap(*smallBevelFillPix); 760 pix = new QPixmap(*smallBevelFillPix);
770 adjustHSV(*pix, h, s, v); 761 adjustHSV(*pix, h, s, v);
771 smallBevelFillDict.insert(c.rgb(), pix); 762 smallBevelFillDict.insert(c.rgb(), pix);
772 } 763 }
773 pagerBrush.setColor(c); 764 pagerBrush.setColor(c);
774 pagerBrush.setPixmap(*pix); 765 pagerBrush.setPixmap(*pix);
775 766
776 // background color stuff 767 // background color stuff
777 c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); 768 c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));
778 c.hsv(&bH, &bS, &bV); 769 c.hsv(&bH, &bS, &bV);
779 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); 770 c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
780 771
781 // FIXME? 772 // FIXME?
782 if(vsbSliderFillPix) 773 if(vsbSliderFillPix)
783 delete vsbSliderFillPix; 774 delete vsbSliderFillPix;
784 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); 775 vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
785 adjustHSV(*vsbSliderFillPix, bH, bS, bV); 776 adjustHSV(*vsbSliderFillPix, bH, bS, bV);
786 777
787 // background brush 778 // background brush
788 QPixmap wallPaper(32, 32); 779 QPixmap wallPaper(32, 32);
789 wallPaper.fill(c.rgb()); 780 wallPaper.fill(c.rgb());
790 painter.begin(&wallPaper); 781 painter.begin(&wallPaper);
791 for(i=0; i < 32; i+=4){ 782 for(i=0; i < 32; i+=4){
792 painter.setPen(c.dark(105)); 783 painter.setPen(c.dark(105));
793 painter.drawLine(0, i, 32, i); 784 painter.drawLine(0, i, 32, i);
794 painter.setPen(c.dark(103)); 785 painter.setPen(c.dark(103));
795 painter.drawLine(0, i+1, 32, i+1); 786 painter.drawLine(0, i+1, 32, i+1);
796 }; 787 };
797 painter.end(); 788 painter.end();
798 bgBrush.setColor(c); 789 bgBrush.setColor(c);
799 bgBrush.setPixmap(wallPaper); 790 bgBrush.setPixmap(wallPaper);
800 appPal.setBrush(QColorGroup::Background, bgBrush); 791 appPal.setBrush(QColorGroup::Background, bgBrush);
801 792
802 // lineedits 793 // lineedits
803 c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); 794 c = QColor ( config. readEntry("Base", ( Qt::white). name ( )));
804 QPixmap basePix; 795 QPixmap basePix;
805 basePix.resize(32, 32); 796 basePix.resize(32, 32);
806 basePix.fill(c.rgb()); 797 basePix.fill(c.rgb());
807 painter.begin(&basePix); 798 painter.begin(&basePix);
808 painter.setPen(c.dark(105)); 799 painter.setPen(c.dark(105));
809 for(i=0; i < 32; i+=4){ 800 for(i=0; i < 32; i+=4){
810 painter.drawLine(0, i, 32, i); 801 painter.drawLine(0, i, 32, i);
811 painter.drawLine(0, i+1, 32, i+1); 802 painter.drawLine(0, i+1, 32, i+1);
812 }; 803 };
813 painter.end(); 804 painter.end();
814 baseBrush.setColor(c); 805 baseBrush.setColor(c);
815 baseBrush.setPixmap(basePix); 806 baseBrush.setPixmap(basePix);
816 it.toFirst(); 807 it.toFirst();
817 while ((w=it.current()) != 0 ){ 808 while ((w=it.current()) != 0 ){
818 ++it; 809 ++it;
819 if(w->inherits("QLineEdit")){ 810 if(w->inherits("QLineEdit")){
820 QPalette pal = w->palette(); 811 QPalette pal = w->palette();
821 pal.setBrush(QColorGroup::Base, baseBrush); 812 pal.setBrush(QColorGroup::Base, baseBrush);
822 w->setPalette(pal); 813 w->setPalette(pal);
823 } 814 }
824 else if(w->inherits("QPushButton")){ 815 else if(w->inherits("QPushButton")){
825 applyCustomAttributes((QPushButton *)w); 816 applyCustomAttributes((QPushButton *)w);
826 } 817 }
827 } 818 }
828 819
829} 820}
830 821
831void LiquidStyle::polish(QWidget *w) 822void LiquidStyle::polish(QWidget *w)
832{ 823{
833 if(w->inherits("QMenuBar")){ 824 if(w->inherits("QMenuBar")){
834 //((QFrame*)w)->setLineWidth(0); 825 //((QFrame*)w)->setLineWidth(0);
835 w->setBackgroundMode(QWidget::PaletteBackground); 826 w->setBackgroundMode(QWidget::PaletteBackground);
836 return; 827 return;
837 } 828 }
838 if(w->inherits("QPopupMenu")) 829 if(w->inherits("QPopupMenu"))
839 w->setBackgroundMode(QWidget::NoBackground); 830 w->setBackgroundMode(QWidget::NoBackground);
840 else if(w-> testWFlags(Qt::WType_Popup)) { 831 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) {
841 printf("install popup: %s\n", w-> className ( ));
842 w->installEventFilter(menuHandler); 832 w->installEventFilter(menuHandler);
843 } 833 }
844 834
845 if(w->isTopLevel()){ 835 if(w->isTopLevel()){
846 return; 836 return;
847 } 837 }
848 838
849 839
850 w-> setBackgroundOrigin ( QWidget::ParentOrigin ); 840 w-> setBackgroundOrigin ( QWidget::ParentOrigin );
851 841
852 if(w->inherits("QComboBox") || 842 if(w->inherits("QComboBox") ||
853 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 843 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
854 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 844 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
855 w->installEventFilter(this); 845 w->installEventFilter(this);
856 } 846 }
857 if(w->inherits("QLineEdit")){ 847 if(w->inherits("QLineEdit")){
858 QPalette pal = w->palette(); 848 QPalette pal = w->palette();
859 pal.setBrush(QColorGroup::Base, baseBrush); 849 pal.setBrush(QColorGroup::Base, baseBrush);
860 w->setPalette(pal); 850 w->setPalette(pal);
861 } 851 }
862 if(w->inherits("QPushButton")){ 852 if(w->inherits("QPushButton")){
863 applyCustomAttributes((QPushButton *)w); 853 applyCustomAttributes((QPushButton *)w);
864 w->installEventFilter(this); 854 w->installEventFilter(this);
865 } 855 }
866 if(w->inherits("QButton") || w-> inherits("QComboBox")){ 856 if(w->inherits("QButton") || w-> inherits("QComboBox")){
867 w-> setBackgroundMode ( QWidget::PaletteBackground ); 857 w-> setBackgroundMode ( QWidget::PaletteBackground );
868 } 858 }
869 859
870 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || 860 bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
871 qstrcmp(w->name(), "qt_clipped_viewport") == 0; 861 qstrcmp(w->name(), "qt_clipped_viewport") == 0;
872 bool isViewportChild = w->parent() && 862 bool isViewportChild = w->parent() &&
873 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 863 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
874 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 864 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
875 865
876 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ 866 if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
877 w->setBackgroundMode(QWidget::X11ParentRelative); 867 w->setBackgroundMode(QWidget::X11ParentRelative);
878 return; 868 return;
879 } 869 }
880 if(isViewportChild){ 870 if(isViewportChild){
881 if(w->inherits("QButton") || w->inherits("QComboBox")){ 871 if(w->inherits("QButton") || w->inherits("QComboBox")){
882 if(w->parent()){ // heh, only way to test for KHTML children ;-) 872 if(w->parent()){ // heh, only way to test for KHTML children ;-)
883 if(w->parent()->parent()){ 873 if(w->parent()->parent()){
884 if(w->parent()->parent()->parent() && 874 if(w->parent()->parent()->parent() &&
885 w->parent()->parent()->parent()->inherits("KHTMLView")){ 875 w->parent()->parent()->parent()->inherits("KHTMLView")){
886 w->setAutoMask(true); 876 w->setAutoMask(true);
887 w->setBackgroundMode(QWidget::NoBackground); 877 w->setBackgroundMode(QWidget::NoBackground);
888 } 878 }
889 } 879 }
890 } 880 }
891 return; 881 return;
892 } 882 }
893 } 883 }
894 if(w->inherits("QHeader")){ 884 if(w->inherits("QHeader")){
895 w->setMouseTracking(true); 885 w->setMouseTracking(true);
896 w->installEventFilter(this); 886 w->installEventFilter(this);
897 } 887 }
898 if(w-> inherits("QToolButton")) { 888 if(w-> inherits("QToolButton")) {
899 ((QToolButton*)w)->setAutoRaise (false); 889 ((QToolButton*)w)->setAutoRaise (false);
900 } 890 }
901 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ 891 if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
902 return; 892 return;
903 } 893 }
904 894
905 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> 895 if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
906 palette().active().brush(QColorGroup::Background).pixmap()){ 896 palette().active().brush(QColorGroup::Background).pixmap()){
907 qWarning("No parent pixmap for child widget %s", w->className()); 897 qWarning("No parent pixmap for child widget %s", w->className());
908 return; 898 return;
909 } 899 }
910 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && 900 if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
911 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { 901 !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
912 if(w->backgroundMode() == QWidget::PaletteBackground || 902 if(w->backgroundMode() == QWidget::PaletteBackground ||
913 w->backgroundMode() == QWidget::PaletteButton){ 903 w->backgroundMode() == QWidget::PaletteButton){
914 w->setBackgroundMode(QWidget::X11ParentRelative); 904 w->setBackgroundMode(QWidget::X11ParentRelative);
915 } 905 }
916 } 906 }
917 if(w->inherits("QToolBar")){ 907 if(w->inherits("QToolBar")){
918 w->installEventFilter(this); 908 w->installEventFilter(this);
919 w->setBackgroundMode(QWidget::PaletteBackground); 909 w->setBackgroundMode(QWidget::PaletteBackground);
920 return; 910 return;
921 } 911 }
922 912
923} 913}
924 914
925void LiquidStyle::unPolish(QWidget *w) 915void LiquidStyle::unPolish(QWidget *w)
926{ 916{
927 if(w->inherits("QMenuBar")){ 917 if(w->inherits("QMenuBar")){
928 ((QFrame *)w)->setLineWidth(1); 918 ((QFrame *)w)->setLineWidth(1);
929 w->setBackgroundMode(QWidget::PaletteBackground); 919 w->setBackgroundMode(QWidget::PaletteBackground);
930 return; 920 return;
931 } 921 }
932 922
933 if(w->inherits("QPopupMenu")) 923 if(w->inherits("QPopupMenu"))
934 w->setBackgroundMode(QWidget::PaletteButton); 924 w->setBackgroundMode(QWidget::PaletteButton);
935 else if(w-> testWFlags(Qt::WType_Popup)) { 925 else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) {
936 w->removeEventFilter(menuHandler); 926 w->removeEventFilter(menuHandler);
937 } 927 }
938 928
939 if(w->isTopLevel()) 929 if(w->isTopLevel())
940 return; 930 return;
941 931
942 // for viewport children, don't just check for NoBackground.... 932 // for viewport children, don't just check for NoBackground....
943 bool isViewportChild = w->parent() && 933 bool isViewportChild = w->parent() &&
944 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || 934 ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
945 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); 935 (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
946 936
947 w->setPalette(QApplication::palette()); 937 w->setPalette(QApplication::palette());
948 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ 938 if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
949 if(w->inherits("QPushButton")) 939 if(w->inherits("QPushButton"))
950 w->setBackgroundMode(QWidget::PaletteButton); 940 w->setBackgroundMode(QWidget::PaletteButton);
951 else 941 else
952 w->setBackgroundMode(QWidget::PaletteBackground); 942 w->setBackgroundMode(QWidget::PaletteBackground);
953 } 943 }
954 944
955 if(isViewportChild) 945 if(isViewportChild)
956 w->setAutoMask(false); 946 w->setAutoMask(false);
957 947
958 if(w->inherits("QPushButton")){ 948 if(w->inherits("QPushButton")){
959 unapplyCustomAttributes((QPushButton *)w); 949 unapplyCustomAttributes((QPushButton *)w);
960 w->removeEventFilter(this); 950 w->removeEventFilter(this);
961 } 951 }
962/* 952/*
963 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ 953 if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
964 w-> setBackgroundMode ( PaletteBackground ); 954 w-> setBackgroundMode ( PaletteBackground );
965 } 955 }
966*/ 956*/
967 if(w->inherits("QComboBox") || 957 if(w->inherits("QComboBox") ||
968 w->inherits("QLineEdit") || w->inherits("QRadioButton") || 958 w->inherits("QLineEdit") || w->inherits("QRadioButton") ||
969 w->inherits("QCheckBox") || w->inherits("QScrollBar")) { 959 w->inherits("QCheckBox") || w->inherits("QScrollBar")) {
970 w->removeEventFilter(this); 960 w->removeEventFilter(this);
971 } 961 }
972 if(w->inherits("QButton") || w->inherits("QComboBox")){ 962 if(w->inherits("QButton") || w->inherits("QComboBox")){
973 if(w->parent() && w->parent()->inherits("KHTMLPart")){ 963 if(w->parent() && w->parent()->inherits("KHTMLPart")){
974 w->setAutoMask(false); 964 w->setAutoMask(false);
975 } 965 }
976 } 966 }
977 if(w->inherits("QToolBar")){ 967 if(w->inherits("QToolBar")){
978 w->removeEventFilter(this); 968 w->removeEventFilter(this);
979 w->setBackgroundMode(QWidget::PaletteBackground); 969 w->setBackgroundMode(QWidget::PaletteBackground);
980 return; 970 return;
981 } 971 }
982 if(w->inherits("QHeader")){ 972 if(w->inherits("QHeader")){
983 w->setMouseTracking(false); 973 w->setMouseTracking(false);
984 w->removeEventFilter(this); 974 w->removeEventFilter(this);
985 } 975 }
986} 976}
987 977
988void LiquidStyle::polish(QApplication *app) 978void LiquidStyle::polish(QApplication *app)
989{ 979{
990 980
991 QWindowsStyle::polish(app); 981 QWindowsStyle::polish(app);
992 menuAni = app->isEffectEnabled(UI_AnimateMenu); 982 menuAni = app->isEffectEnabled(UI_AnimateMenu);
993 menuFade = app->isEffectEnabled(UI_FadeMenu); 983 menuFade = app->isEffectEnabled(UI_FadeMenu);
994 if(menuAni) 984 if(menuAni)
995 app->setEffectEnabled(UI_AnimateMenu, false); 985 app->setEffectEnabled(UI_AnimateMenu, false);
996 if(menuFade) 986 if(menuFade)
997 app->setEffectEnabled(UI_FadeMenu, false); 987 app->setEffectEnabled(UI_FadeMenu, false);
998 988
999 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); 989 qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
1000} 990}
1001 991
1002void LiquidStyle::unPolish(QApplication *app) 992void LiquidStyle::unPolish(QApplication *app)
1003{ 993{
1004 QWindowsStyle::unPolish(app); 994 QWindowsStyle::unPolish(app);
1005 app->setEffectEnabled(UI_AnimateMenu, menuAni); 995 app->setEffectEnabled(UI_AnimateMenu, menuAni);
1006 app->setEffectEnabled(UI_FadeMenu, menuFade); 996 app->setEffectEnabled(UI_FadeMenu, menuFade);
1007 997
1008 qt_set_draw_menu_bar_impl ( 0 ); 998 qt_set_draw_menu_bar_impl ( 0 );
1009} 999}
1010 1000
1011/* 1001/*
1012 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to 1002 * This is a fun method ;-) Here's an overview. KToolBar grabs resize to
1013 * force everything to erase and repaint on resize. This is going away, I'm 1003 * force everything to erase and repaint on resize. This is going away, I'm
1014 * trying to get shaped widgets to work right without masking. QPushButton, 1004 * trying to get shaped widgets to work right without masking. QPushButton,
1015 * QComboBox, and Panel applet handles capture mouse enter and leaves in order 1005 * QComboBox, and Panel applet handles capture mouse enter and leaves in order
1016 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and 1006 * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and
1017 * RadioButtons need to do this differently. Qt buffers these in pixmaps and 1007 * RadioButtons need to do this differently. Qt buffers these in pixmaps and
1018 * caches them in QPixmapCache, which is bad for doing things like hover 1008 * caches them in QPixmapCache, which is bad for doing things like hover
1019 * because the style methods aren't called in paintEvents if everything 1009 * because the style methods aren't called in paintEvents if everything
1020 * is cached. We use our own Paint event handler instead. Taskbuttons and 1010 * is cached. We use our own Paint event handler instead. Taskbuttons and
1021 * pager buttons draw into a pixmap buffer, so we handle those with palette 1011 * pager buttons draw into a pixmap buffer, so we handle those with palette
1022 * modifications. For QHeader, different header items are actually one widget 1012 * modifications. For QHeader, different header items are actually one widget
1023 * that draws multiple items, so we need to check which ID is hightlighted 1013 * that draws multiple items, so we need to check which ID is hightlighted
1024 * and draw it. Finally, we also check enter and leave events for QLineEdit, 1014 * and draw it. Finally, we also check enter and leave events for QLineEdit,
1025 * since if it's inside a combobox we want to highlight the combobox during 1015 * since if it's inside a combobox we want to highlight the combobox during
1026 * hovering in the edit. 1016 * hovering in the edit.
1027 */ 1017 */
1028bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) 1018bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
1029{ 1019{
1030 if(obj->inherits("QToolBar")){ 1020 if(obj->inherits("QToolBar")){
1031 if(ev->type() == QEvent::Resize){ 1021 if(ev->type() == QEvent::Resize){
1032 const QObjectList *tbChildList = obj->children(); 1022 const QObjectList *tbChildList = obj->children();
1033 QObjectListIt it(*tbChildList); 1023 QObjectListIt it(*tbChildList);
1034 QObject *child; 1024 QObject *child;
1035 while((child = it.current()) != NULL){ 1025 while((child = it.current()) != NULL){
1036 ++it; 1026 ++it;
1037 if(child->isWidgetType()) 1027 if(child->isWidgetType())
1038 ((QWidget *)child)->repaint(true); 1028 ((QWidget *)child)->repaint(true);
1039 } 1029 }
1040 1030
1041 } 1031 }
1042 } 1032 }
1043 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ 1033 else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){
1044 QWidget *btn = (QWidget *)obj; 1034 QWidget *btn = (QWidget *)obj;
1045 if(ev->type() == QEvent::Enter){ 1035 if(ev->type() == QEvent::Enter){
1046 if(btn->isEnabled()){ 1036 if(btn->isEnabled()){
1047 highlightWidget = btn; 1037 highlightWidget = btn;
1048 btn->repaint(false); 1038 btn->repaint(false);
1049 } 1039 }
1050 } 1040 }
1051 else if(ev->type() == QEvent::Leave){ 1041 else if(ev->type() == QEvent::Leave){
1052 if(btn == highlightWidget){ 1042 if(btn == highlightWidget){
1053 highlightWidget = NULL; 1043 highlightWidget = NULL;
1054 btn->repaint(false); 1044 btn->repaint(false);
1055 } 1045 }
1056 } 1046 }
1057 } 1047 }
1058 else if(obj->inherits("QToolButton")){ 1048 else if(obj->inherits("QToolButton")){
1059 QToolButton *btn = (QToolButton *)btn; 1049 QToolButton *btn = (QToolButton *)btn;
1060 if(!btn->autoRaise()){ 1050 if(!btn->autoRaise()){
1061 if(btn->isEnabled()){ 1051 if(btn->isEnabled()){
1062 highlightWidget = btn; 1052 highlightWidget = btn;
1063 btn->repaint(false); 1053 btn->repaint(false);
1064 } 1054 }
1065 } 1055 }
1066 else if(ev->type() == QEvent::Leave){ 1056 else if(ev->type() == QEvent::Leave){
1067 QWidget *btn = (QWidget *)obj; 1057 QWidget *btn = (QWidget *)obj;
1068 if(btn == highlightWidget){ 1058 if(btn == highlightWidget){
1069 highlightWidget = NULL; 1059 highlightWidget = NULL;
1070 btn->repaint(false); 1060 btn->repaint(false);
1071 } 1061 }
1072 } 1062 }
1073 else 1063 else
1074 highlightWidget = NULL; 1064 highlightWidget = NULL;
1075 } 1065 }
1076 else if(obj->inherits("QScrollBar")){ 1066 else if(obj->inherits("QScrollBar")){
1077 QScrollBar *sb = (QScrollBar *)obj; 1067 QScrollBar *sb = (QScrollBar *)obj;
1078 if(ev->type() == QEvent::Enter){ 1068 if(ev->type() == QEvent::Enter){
1079 if(sb->isEnabled()){ 1069 if(sb->isEnabled()){
1080 highlightWidget = sb; 1070 highlightWidget = sb;
1081 sb->repaint(false); 1071 sb->repaint(false);
1082 } 1072 }
1083 } 1073 }
1084 else if(ev->type() == QEvent::Leave){ 1074 else if(ev->type() == QEvent::Leave){
1085 if(sb == highlightWidget && !sb->draggingSlider()){ 1075 if(sb == highlightWidget && !sb->draggingSlider()){
1086 highlightWidget = NULL; 1076 highlightWidget = NULL;
1087 sb->repaint(false); 1077 sb->repaint(false);
1088 } 1078 }
1089 } 1079 }
1090 else if(ev->type() == QEvent::MouseButtonRelease){ 1080 else if(ev->type() == QEvent::MouseButtonRelease){
1091 QMouseEvent *me = (QMouseEvent *)ev; 1081 QMouseEvent *me = (QMouseEvent *)ev;
1092 if(sb == highlightWidget && !sb->rect().contains(me->pos())){ 1082 if(sb == highlightWidget && !sb->rect().contains(me->pos())){
1093 highlightWidget = NULL; 1083 highlightWidget = NULL;
1094 sb->repaint(false); 1084 sb->repaint(false);
1095 } 1085 }
1096 } 1086 }
1097 } 1087 }
1098 else if(obj->inherits("QLineEdit")){ 1088 else if(obj->inherits("QLineEdit")){
1099 if(obj->parent() && obj->parent()->inherits("QComboBox")){ 1089 if(obj->parent() && obj->parent()->inherits("QComboBox")){
1100 QWidget *btn = (QComboBox *)obj->parent(); 1090 QWidget *btn = (QComboBox *)obj->parent();
1101 if(ev->type() == QEvent::Enter){ 1091 if(ev->type() == QEvent::Enter){
1102 if (btn->isEnabled()){ 1092 if (btn->isEnabled()){
1103 highlightWidget = btn; 1093 highlightWidget = btn;
1104 btn->repaint(false); 1094 btn->repaint(false);
1105 } 1095 }
1106 } 1096 }
1107 else if(ev->type() == QEvent::Leave){ 1097 else if(ev->type() == QEvent::Leave){
1108 if (btn == highlightWidget) 1098 if (btn == highlightWidget)
1109 highlightWidget = NULL; 1099 highlightWidget = NULL;
1110 btn->repaint(false); 1100 btn->repaint(false);
1111 } 1101 }
1112 } 1102 }
1113 } 1103 }
1114 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ 1104 else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){
1115 QButton *btn = (QButton *)obj; 1105 QButton *btn = (QButton *)obj;
1116 bool isRadio = obj->inherits("QRadioButton"); 1106 bool isRadio = obj->inherits("QRadioButton");
1117 if(ev->type() == QEvent::Paint){ 1107 if(ev->type() == QEvent::Paint){
1118 //if(btn->autoMask()) 1108 //if(btn->autoMask())
1119 btn->erase(); 1109 btn->erase();
1120 QPainter p; 1110 QPainter p;
1121 p.begin(btn); 1111 p.begin(btn);
1122 QFontMetrics fm = btn->fontMetrics(); 1112 QFontMetrics fm = btn->fontMetrics();
1123 QSize lsz = fm.size(ShowPrefix, btn->text()); 1113 QSize lsz = fm.size(ShowPrefix, btn->text());
1124 QSize sz = isRadio ? exclusiveIndicatorSize() 1114 QSize sz = isRadio ? exclusiveIndicatorSize()
1125 : indicatorSize(); 1115 : indicatorSize();
1126 1116
1127 if(btn->hasFocus()){ 1117 if(btn->hasFocus()){
diff --git a/noncore/styles/liquid/plugin.cpp b/noncore/styles/liquid/plugin.cpp
index fca7c06..d9aa8ef 100644
--- a/noncore/styles/liquid/plugin.cpp
+++ b/noncore/styles/liquid/plugin.cpp
@@ -1,29 +1,29 @@
1#include "liquid.h" 1#include "liquid.h"
2 2
3 3
4extern "C" { 4extern "C" {
5 QStyle* allocate ( ); 5 QStyle* allocate ( );
6 int minor_version ( ); 6 int minor_version ( );
7 int major_version ( ); 7 int major_version ( );
8 const char *description ( ); 8 const char *description ( );
9} 9}
10 10
11QStyle* allocate ( ) 11QStyle* allocate ( )
12{ 12{
13 return new LiquidStyle ( ); 13 return new LiquidStyle ( );
14} 14}
15 15
16int minor_version ( ) 16int minor_version ( )
17{ 17{
18 return 0; 18 return 0;
19} 19}
20 20
21int major_version ( ) 21int major_version ( )
22{ 22{
23 return 1; 23 return 1;
24} 24}
25 25
26const char *description ( ) 26const char *description ( )
27{ 27{
28 return "High performance liquid plugin"; 28 return "High Performance Liquid";
29} 29}