author | sandman <sandman> | 2002-07-08 00:42:56 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-07-08 00:42:56 (UTC) |
commit | 923a6290c8cc93914d54e583f1d79a6bae638fab (patch) (unidiff) | |
tree | b2562e4dbf6d71631b358021f8c4ec29f36a6d12 | |
parent | 895f43bd1850b3e0c43edaaad18a7d7f2613033b (diff) | |
download | opie-923a6290c8cc93914d54e583f1d79a6bae638fab.zip opie-923a6290c8cc93914d54e583f1d79a6bae638fab.tar.gz opie-923a6290c8cc93914d54e583f1d79a6bae638fab.tar.bz2 |
- Fix a memory leak (bg pixmaps for taskbar applets were never freed)
- Try to be more intelligent about stipple alignment in child widgets
(in every app I tested the stipple is now always aligned right)
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 16 | ||||
-rw-r--r-- | noncore/styles/liquid/plugin.cpp | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index 67e53e9..fc925b8 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -1,1360 +1,1360 @@ | |||
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 "liquiddeco.h" | 13 | #include "liquiddeco.h" |
14 | #include <qapplication.h> | 14 | #include <qapplication.h> |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include "effects.h" | 16 | #include "effects.h" |
17 | #include <qpalette.h> | 17 | #include <qpalette.h> |
18 | #include <qbitmap.h> | 18 | #include <qbitmap.h> |
19 | #include <qtabbar.h> | 19 | #include <qtabbar.h> |
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qobjectlist.h> | 21 | #include <qobjectlist.h> |
22 | #include <qimage.h> | 22 | #include <qimage.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qpixmapcache.h> | 24 | #include <qpixmapcache.h> |
25 | #include <qradiobutton.h> | 25 | #include <qradiobutton.h> |
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qwidgetlist.h> | 28 | #include <qwidgetlist.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qheader.h> | 30 | #include <qheader.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | 33 | ||
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | #include "htmlmasks.h" | 37 | #include "htmlmasks.h" |
38 | #include "embeddata.h" | 38 | #include "embeddata.h" |
39 | 39 | ||
40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | 40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, |
41 | QColorGroup &, bool, bool); | 41 | QColorGroup &, bool, bool); |
42 | 42 | ||
43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); | 43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); |
44 | 44 | ||
45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) | 45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) |
46 | { | 46 | { |
47 | QImage img(pix.convertToImage()); | 47 | QImage img(pix.convertToImage()); |
48 | QImageEffect::fade(img, 0.9, color); | 48 | QImageEffect::fade(img, 0.9, color); |
49 | int x, y; | 49 | int x, y; |
50 | int r, g, b; | 50 | int r, g, b; |
51 | for(y=0; y < img.height(); y+=3){ | 51 | for(y=0; y < img.height(); y+=3){ |
52 | unsigned int *data = (unsigned int *) img.scanLine(y); | 52 | unsigned int *data = (unsigned int *) img.scanLine(y); |
53 | for(x=0; x < img.width(); ++x){ | 53 | for(x=0; x < img.width(); ++x){ |
54 | r = qRed(data[x]); | 54 | r = qRed(data[x]); |
55 | g = qGreen(data[x]); | 55 | g = qGreen(data[x]); |
56 | b = qBlue(data[x]); | 56 | b = qBlue(data[x]); |
57 | if(r-10) | 57 | if(r-10) |
58 | r-=10; | 58 | r-=10; |
59 | if(g-10) | 59 | if(g-10) |
60 | g-=10; | 60 | g-=10; |
61 | if(b-10) | 61 | if(b-10) |
62 | b-=10; | 62 | b-=10; |
63 | data[x] = qRgb(r, g, b); | 63 | data[x] = qRgb(r, g, b); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | pix.convertFromImage(img); | 66 | pix.convertFromImage(img); |
67 | } | 67 | } |
68 | 68 | ||
69 | TransMenuHandler::TransMenuHandler(QObject *parent) | 69 | TransMenuHandler::TransMenuHandler(QObject *parent) |
70 | : QObject(parent) | 70 | : QObject(parent) |
71 | { | 71 | { |
72 | pixDict.setAutoDelete(true); | 72 | pixDict.setAutoDelete(true); |
73 | reloadSettings(); | 73 | reloadSettings(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void TransMenuHandler::reloadSettings() | 76 | void TransMenuHandler::reloadSettings() |
77 | { | 77 | { |
78 | pixDict.clear(); | 78 | pixDict.clear(); |
79 | 79 | ||
80 | Config config ( "qpe" ); | 80 | Config config ( "qpe" ); |
81 | config. setGroup ( "Liquid-Style" ); | 81 | config. setGroup ( "Liquid-Style" ); |
82 | 82 | ||
83 | type = config. readNumEntry("Type", TransStippleBg); | 83 | type = config. readNumEntry("Type", TransStippleBg); |
84 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); | 84 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); |
85 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); | 85 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); |
86 | opacity = config. readNumEntry("Opacity", 10); | 86 | opacity = config. readNumEntry("Opacity", 10); |
87 | if ( opacity < -20 ) | 87 | if ( opacity < -20 ) |
88 | opacity = 20; | 88 | opacity = 20; |
89 | else if ( opacity > 20 ) | 89 | else if ( opacity > 20 ) |
90 | opacity = 20; | 90 | opacity = 20; |
91 | 91 | ||
92 | shadowText = config. readBoolEntry("ShadowText", true); | 92 | shadowText = config. readBoolEntry("ShadowText", true); |
93 | } | 93 | } |
94 | 94 | ||
95 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | 95 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) |
96 | { | 96 | { |
97 | QWidget *p = (QWidget *)obj; | 97 | QWidget *p = (QWidget *)obj; |
98 | 98 | ||
99 | if(ev->type() == QEvent::Show){ | 99 | if(ev->type() == QEvent::Show){ |
100 | if(type == TransStippleBg || type == TransStippleBtn || | 100 | if(type == TransStippleBg || type == TransStippleBtn || |
101 | type == Custom){ | 101 | type == Custom){ |
102 | QApplication::syncX(); | 102 | QApplication::syncX(); |
103 | QPixmap *pix = new QPixmap; | 103 | QPixmap *pix = new QPixmap; |
104 | if(p->testWFlags(Qt::WType_Popup)){ | 104 | if(p->testWFlags(Qt::WType_Popup)){ |
105 | QRect r(p->x(), p->y(), p->width(), p->height()); | 105 | QRect r(p->x(), p->y(), p->width(), p->height()); |
106 | QRect deskR = QApplication::desktop()->rect(); | 106 | QRect deskR = QApplication::desktop()->rect(); |
107 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ | 107 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ |
108 | r.setBottom(deskR.bottom()); | 108 | r.setBottom(deskR.bottom()); |
109 | r.setRight(deskR.right()); | 109 | r.setRight(deskR.right()); |
110 | } | 110 | } |
111 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), | 111 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), |
112 | r.width(), r.height()); | 112 | r.width(), r.height()); |
113 | } | 113 | } |
114 | else{ // tear off menu | 114 | else{ // tear off menu |
115 | pix->resize(p->width(), p->height()); | 115 | pix->resize(p->width(), p->height()); |
116 | pix->fill(Qt::black.rgb()); | 116 | pix->fill(Qt::black.rgb()); |
117 | } | 117 | } |
118 | if(type == TransStippleBg){ | 118 | if(type == TransStippleBg){ |
119 | stripePixmap(*pix, p->colorGroup().background()); | 119 | stripePixmap(*pix, p->colorGroup().background()); |
120 | } | 120 | } |
121 | else if(type == TransStippleBtn){ | 121 | else if(type == TransStippleBtn){ |
122 | stripePixmap(*pix, p->colorGroup().button()); | 122 | stripePixmap(*pix, p->colorGroup().button()); |
123 | } | 123 | } |
124 | else{ | 124 | else{ |
125 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); | 125 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); |
126 | } | 126 | } |
127 | 127 | ||
128 | if (p->inherits("QPopupMenu")) | 128 | pixDict.insert(p->winId(), pix); |
129 | pixDict.insert(p->winId(), pix); | 129 | |
130 | else { | 130 | if (!p->inherits("QPopupMenu")) { |
131 | p->setBackgroundPixmap(*pix); | 131 | p->setBackgroundPixmap(*pix); |
132 | 132 | ||
133 | QObjectList *ol = p-> queryList("QWidget"); | 133 | QObjectList *ol = p-> queryList("QWidget"); |
134 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 134 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
135 | QWidget *wid = (QWidget *) it.current ( ); | 135 | QWidget *wid = (QWidget *) it.current ( ); |
136 | 136 | ||
137 | wid-> setBackgroundPixmap(*pix); | 137 | wid-> setBackgroundPixmap(*pix); |
138 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); | 138 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); |
139 | } | 139 | } |
140 | delete ol; | 140 | delete ol; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | } | 143 | } |
144 | else if(ev->type() == QEvent::Hide){ | 144 | else if(ev->type() == QEvent::Hide){ |
145 | if(type == TransStippleBg || type == TransStippleBtn || | 145 | if(type == TransStippleBg || type == TransStippleBtn || |
146 | type == Custom){ | 146 | type == Custom){ |
147 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); | 147 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); |
148 | 148 | ||
149 | if (p->inherits("QPopupMenu")) | 149 | pixDict.remove(p->winId()); |
150 | pixDict.remove(p->winId()); | 150 | if (!p->inherits("QPopupMenu")) { |
151 | else { | 151 | p->setBackgroundMode(QWidget::PaletteBackground); |
152 | p->setBackgroundMode(QWidget::PaletteBackground); | ||
153 | 152 | ||
154 | QObjectList *ol = p-> queryList("QWidget"); | 153 | QObjectList *ol = p-> queryList("QWidget"); |
155 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 154 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
156 | QWidget *wid = (QWidget *) it.current ( ); | 155 | QWidget *wid = (QWidget *) it.current ( ); |
157 | 156 | ||
158 | wid-> setBackgroundMode( QWidget::PaletteBackground ); | 157 | wid-> setBackgroundMode( QWidget::PaletteBackground ); |
159 | } | 158 | } |
160 | delete ol; | 159 | delete ol; |
161 | } | 160 | } |
162 | } | 161 | } |
163 | } | 162 | } |
164 | return(false); | 163 | return(false); |
165 | } | 164 | } |
166 | 165 | ||
167 | 166 | ||
168 | LiquidStyle::LiquidStyle() | 167 | LiquidStyle::LiquidStyle() |
169 | :QWindowsStyle() | 168 | :QWindowsStyle() |
170 | { | 169 | { |
171 | setName ( "LiquidStyle" ); | 170 | setName ( "LiquidStyle" ); |
172 | 171 | ||
173 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 172 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
174 | btnMaskBmp.setMask(btnMaskBmp); | 173 | btnMaskBmp.setMask(btnMaskBmp); |
175 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 174 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
176 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); | 175 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); |
177 | headerHoverID = -1; | 176 | headerHoverID = -1; |
178 | highlightWidget = NULL; | 177 | highlightWidget = NULL; |
179 | setButtonDefaultIndicatorWidth(0); | 178 | setButtonDefaultIndicatorWidth(0); |
180 | btnDict.setAutoDelete(true); | 179 | btnDict.setAutoDelete(true); |
181 | bevelFillDict.setAutoDelete(true); | 180 | bevelFillDict.setAutoDelete(true); |
182 | smallBevelFillDict.setAutoDelete(true); | 181 | smallBevelFillDict.setAutoDelete(true); |
183 | customBtnColorList.setAutoDelete(true); | 182 | customBtnColorList.setAutoDelete(true); |
184 | customBtnIconList.setAutoDelete(true); | 183 | customBtnIconList.setAutoDelete(true); |
185 | customBtnLabelList.setAutoDelete(true); | 184 | customBtnLabelList.setAutoDelete(true); |
186 | 185 | ||
187 | rMatrix.rotate(270.0); | 186 | rMatrix.rotate(270.0); |
188 | highcolor = QPixmap::defaultDepth() > 8; | 187 | highcolor = QPixmap::defaultDepth() > 8; |
189 | btnBorderPix = new QPixmap; | 188 | btnBorderPix = new QPixmap; |
190 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); | 189 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); |
191 | btnBlendPix = new QPixmap; | 190 | btnBlendPix = new QPixmap; |
192 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); | 191 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); |
193 | bevelFillPix = new QPixmap; | 192 | bevelFillPix = new QPixmap; |
194 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); | 193 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); |
195 | smallBevelFillPix = new QPixmap; | 194 | smallBevelFillPix = new QPixmap; |
196 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); | 195 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); |
197 | // new stuff | 196 | // new stuff |
198 | vsbSliderFillPix = menuPix = NULL; | 197 | vsbSliderFillPix = menuPix = NULL; |
199 | menuHandler = new TransMenuHandler(this); | 198 | menuHandler = new TransMenuHandler(this); |
200 | setScrollBarExtent(15, 15); | 199 | setScrollBarExtent(15, 15); |
201 | int i; | 200 | int i; |
202 | for(i=0; i < BITMAP_ITEMS; ++i){ | 201 | for(i=0; i < BITMAP_ITEMS; ++i){ |
203 | pixmaps[i] = NULL; | 202 | pixmaps[i] = NULL; |
204 | } | 203 | } |
205 | oldSliderThickness = sliderThickness(); | 204 | oldSliderThickness = sliderThickness(); |
206 | setSliderThickness(11); | 205 | setSliderThickness(11); |
207 | } | 206 | } |
208 | 207 | ||
209 | LiquidStyle::~LiquidStyle() | 208 | LiquidStyle::~LiquidStyle() |
210 | { | 209 | { |
211 | if(btnBorderPix) | 210 | if(btnBorderPix) |
212 | delete btnBorderPix; | 211 | delete btnBorderPix; |
213 | if(btnBlendPix) | 212 | if(btnBlendPix) |
214 | delete btnBlendPix; | 213 | delete btnBlendPix; |
215 | if(bevelFillPix) | 214 | if(bevelFillPix) |
216 | delete bevelFillPix; | 215 | delete bevelFillPix; |
217 | if(smallBevelFillPix) | 216 | if(smallBevelFillPix) |
218 | delete smallBevelFillPix; | 217 | delete smallBevelFillPix; |
219 | if(vsbSliderFillPix) | 218 | if(vsbSliderFillPix) |
220 | delete vsbSliderFillPix; | 219 | delete vsbSliderFillPix; |
221 | if(menuPix) | 220 | if(menuPix) |
222 | delete menuPix; | 221 | delete menuPix; |
223 | 222 | ||
224 | setScrollBarExtent(16, 16); | 223 | setScrollBarExtent(16, 16); |
225 | setSliderThickness(oldSliderThickness); | 224 | setSliderThickness(oldSliderThickness); |
226 | int i; | 225 | int i; |
227 | for(i=0; i < BITMAP_ITEMS; ++i){ | 226 | for(i=0; i < BITMAP_ITEMS; ++i){ |
228 | if(pixmaps[i]) | 227 | if(pixmaps[i]) |
229 | delete pixmaps[i]; | 228 | delete pixmaps[i]; |
230 | } | 229 | } |
231 | } | 230 | } |
232 | 231 | ||
233 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, | 232 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, |
234 | const QColor &c, const QColor &bg) | 233 | const QColor &c, const QColor &bg) |
235 | { | 234 | { |
236 | 235 | ||
237 | QPen oldPen = p->pen(); // headers need this | 236 | QPen oldPen = p->pen(); // headers need this |
238 | int x2 = x+w-1; | 237 | int x2 = x+w-1; |
239 | int y2 = y+h-1; | 238 | int y2 = y+h-1; |
240 | // outer dark rect | 239 | // outer dark rect |
241 | p->setPen(c.dark(130)); | 240 | p->setPen(c.dark(130)); |
242 | p->drawLine(x, y+2, x, y2-2); // l | 241 | p->drawLine(x, y+2, x, y2-2); // l |
243 | p->drawLine(x2, y+2, x2, y2-2); // r | 242 | p->drawLine(x2, y+2, x2, y2-2); // r |
244 | p->drawLine(x+2, y, x2-2, y); // t | 243 | p->drawLine(x+2, y, x2-2, y); // t |
245 | p->drawLine(x+2, y2, x2-2, y2); // b | 244 | p->drawLine(x+2, y2, x2-2, y2); // b |
246 | p->drawPoint(x+1, y+1); // tl | 245 | p->drawPoint(x+1, y+1); // tl |
247 | p->drawPoint(x2-1, y+1); // tr | 246 | p->drawPoint(x2-1, y+1); // tr |
248 | p->drawPoint(x+1, y2-1); // bl | 247 | p->drawPoint(x+1, y2-1); // bl |
249 | p->drawPoint(x2-1, y2-1); // br | 248 | p->drawPoint(x2-1, y2-1); // br |
250 | 249 | ||
251 | // inner top light lines | 250 | // inner top light lines |
252 | p->setPen(c.light(105)); | 251 | p->setPen(c.light(105)); |
253 | p->drawLine(x+2, y+1, x2-2, y+1); | 252 | p->drawLine(x+2, y+1, x2-2, y+1); |
254 | p->drawLine(x+1, y+2, x2-1, y+2); | 253 | p->drawLine(x+1, y+2, x2-1, y+2); |
255 | p->drawLine(x+1, y+3, x+2, y+3); | 254 | p->drawLine(x+1, y+3, x+2, y+3); |
256 | p->drawLine(x2-2, y+3, x2-1, y+3); | 255 | p->drawLine(x2-2, y+3, x2-1, y+3); |
257 | p->drawPoint(x+1, y+4); | 256 | p->drawPoint(x+1, y+4); |
258 | p->drawPoint(x2-1, y+4); | 257 | p->drawPoint(x2-1, y+4); |
259 | 258 | ||
260 | // inner bottom light lines | 259 | // inner bottom light lines |
261 | p->setPen(c.light(110)); | 260 | p->setPen(c.light(110)); |
262 | p->drawLine(x+2, y2-1, x2-2, y2-1); | 261 | p->drawLine(x+2, y2-1, x2-2, y2-1); |
263 | p->drawLine(x+1, y2-2, x2-1, y2-2); | 262 | p->drawLine(x+1, y2-2, x2-1, y2-2); |
264 | p->drawLine(x+1, y2-3, x+2, y2-3); | 263 | p->drawLine(x+1, y2-3, x+2, y2-3); |
265 | p->drawLine(x2-2, y2-3, x2-1, y2-3); | 264 | p->drawLine(x2-2, y2-3, x2-1, y2-3); |
266 | p->drawPoint(x+1, y2-4); | 265 | p->drawPoint(x+1, y2-4); |
267 | p->drawPoint(x2-1, y2-4); | 266 | p->drawPoint(x2-1, y2-4); |
268 | 267 | ||
269 | // inner left mid lines | 268 | // inner left mid lines |
270 | //p->setPen(c.light(105)); | 269 | //p->setPen(c.light(105)); |
271 | p->setPen(c); | 270 | p->setPen(c); |
272 | p->drawLine(x+1, y+5, x+1, y2-5); | 271 | p->drawLine(x+1, y+5, x+1, y2-5); |
273 | p->drawLine(x+2, y+4, x+2, y2-4); | 272 | p->drawLine(x+2, y+4, x+2, y2-4); |
274 | 273 | ||
275 | // inner right mid lines | 274 | // inner right mid lines |
276 | p->drawLine(x2-1, y+5, x2-1, y2-5); | 275 | p->drawLine(x2-1, y+5, x2-1, y2-5); |
277 | p->drawLine(x2-2, y+4, x2-2, y2-4); | 276 | p->drawLine(x2-2, y+4, x2-2, y2-4); |
278 | 277 | ||
279 | // fill | 278 | // fill |
280 | QPixmap *pix; | 279 | QPixmap *pix; |
281 | if(h >= 32){ | 280 | if(h >= 32){ |
282 | pix = bevelFillDict.find(c.rgb()); | 281 | pix = bevelFillDict.find(c.rgb()); |
283 | if(!pix){ | 282 | if(!pix){ |
284 | int h, s, v; | 283 | int h, s, v; |
285 | c.hsv(&h, &s, &v); | 284 | c.hsv(&h, &s, &v); |
286 | pix = new QPixmap(*bevelFillPix); | 285 | pix = new QPixmap(*bevelFillPix); |
287 | adjustHSV(*pix, h, s, v); | 286 | adjustHSV(*pix, h, s, v); |
288 | bevelFillDict.insert(c.rgb(), pix); | 287 | bevelFillDict.insert(c.rgb(), pix); |
289 | } | 288 | } |
290 | } | 289 | } |
291 | else{ | 290 | else{ |
292 | pix = smallBevelFillDict.find(c.rgb()); | 291 | pix = smallBevelFillDict.find(c.rgb()); |
293 | if(!pix){ | 292 | if(!pix){ |
294 | int h, s, v; | 293 | int h, s, v; |
295 | c.hsv(&h, &s, &v); | 294 | c.hsv(&h, &s, &v); |
296 | pix = new QPixmap(*smallBevelFillPix); | 295 | pix = new QPixmap(*smallBevelFillPix); |
297 | adjustHSV(*pix, h, s, v); | 296 | adjustHSV(*pix, h, s, v); |
298 | smallBevelFillDict.insert(c.rgb(), pix); | 297 | smallBevelFillDict.insert(c.rgb(), pix); |
299 | } | 298 | } |
300 | } | 299 | } |
301 | p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); | 300 | p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); |
302 | // blend | 301 | // blend |
303 | int red, green, blue; | 302 | int red, green, blue; |
304 | QColor btnColor(c.dark(130)); | 303 | QColor btnColor(c.dark(130)); |
305 | red = (btnColor.red() >> 1) + (bg.red() >> 1); | 304 | red = (btnColor.red() >> 1) + (bg.red() >> 1); |
306 | green = (btnColor.green() >> 1) + (bg.green() >> 1); | 305 | green = (btnColor.green() >> 1) + (bg.green() >> 1); |
307 | blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); | 306 | blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); |
308 | btnColor.setRgb(red, green, blue); | 307 | btnColor.setRgb(red, green, blue); |
309 | 308 | ||
310 | p->setPen(btnColor); | 309 | p->setPen(btnColor); |
311 | p->drawPoint(x+1, y); | 310 | p->drawPoint(x+1, y); |
312 | p->drawPoint(x, y+1); | 311 | p->drawPoint(x, y+1); |
313 | p->drawPoint(x+1, y2); | 312 | p->drawPoint(x+1, y2); |
314 | p->drawPoint(x, y2-1); | 313 | p->drawPoint(x, y2-1); |
315 | 314 | ||
316 | p->drawPoint(x2-1, y); | 315 | p->drawPoint(x2-1, y); |
317 | p->drawPoint(x2, y+1); | 316 | p->drawPoint(x2, y+1); |
318 | p->drawPoint(x2-1, y2); | 317 | p->drawPoint(x2-1, y2); |
319 | p->drawPoint(x2, y2-1); | 318 | p->drawPoint(x2, y2-1); |
320 | 319 | ||
321 | p->setPen(oldPen); | 320 | p->setPen(oldPen); |
322 | 321 | ||
323 | } | 322 | } |
324 | 323 | ||
325 | void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, | 324 | void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, |
326 | const QColor &back, int x, int y, int w, int h, | 325 | const QColor &back, int x, int y, int w, int h, |
327 | bool supportPushDown, bool pushedDown, | 326 | bool supportPushDown, bool pushedDown, |
328 | bool autoDefault, bool isMasked) | 327 | bool autoDefault, bool isMasked) |
329 | { | 328 | { |
330 | if(w < 21 || h < 21){ | 329 | if(w < 21 || h < 21){ |
331 | drawClearBevel(painter, x, y, w, h, c, back); | 330 | drawClearBevel(painter, x, y, w, h, c, back); |
332 | return; | 331 | return; |
333 | } | 332 | } |
334 | if(supportPushDown){ | 333 | if(supportPushDown){ |
335 | --w, --h; | 334 | --w, --h; |
336 | } | 335 | } |
337 | /* 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 |
338 | if(autoDefault){ | 337 | if(autoDefault){ |
339 | w = w-buttonDefaultIndicatorWidth()*2; | 338 | w = w-buttonDefaultIndicatorWidth()*2; |
340 | h = h-buttonDefaultIndicatorWidth()*2; | 339 | h = h-buttonDefaultIndicatorWidth()*2; |
341 | }*/ | 340 | }*/ |
342 | 341 | ||
343 | 342 | ||
344 | QPixmap *pix = btnDict.find(c.rgb()); | 343 | QPixmap *pix = btnDict.find(c.rgb()); |
345 | if(!pix){ | 344 | if(!pix){ |
346 | int h, s, v; | 345 | int h, s, v; |
347 | c.hsv(&h, &s, &v); | 346 | c.hsv(&h, &s, &v); |
348 | pix = new QPixmap(*btnBorderPix); | 347 | pix = new QPixmap(*btnBorderPix); |
349 | adjustHSV(*pix, h, s, v); | 348 | adjustHSV(*pix, h, s, v); |
350 | btnDict.insert(c.rgb(), pix); | 349 | btnDict.insert(c.rgb(), pix); |
351 | } | 350 | } |
352 | int x2 = x+w-1; | 351 | int x2 = x+w-1; |
353 | int y2 = y+h-1; | 352 | int y2 = y+h-1; |
354 | int bx2 = pix->width()-1; | 353 | int bx2 = pix->width()-1; |
355 | int by2 = pix->height()-1; | 354 | int by2 = pix->height()-1; |
356 | 355 | ||
357 | QPixmap tmpPix(w, h); | 356 | QPixmap tmpPix(w, h); |
358 | QPixmap tilePix; | 357 | QPixmap tilePix; |
359 | QPainter p; | 358 | QPainter p; |
360 | p.begin(&tmpPix); | 359 | p.begin(&tmpPix); |
361 | 360 | ||
362 | // do the fill | 361 | // do the fill |
363 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl | 362 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl |
364 | p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr | 363 | p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr |
365 | p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl | 364 | p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl |
366 | p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br | 365 | p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br |
367 | 366 | ||
368 | // edges | 367 | // edges |
369 | tilePix.resize(pix->width()-20, 10); | 368 | tilePix.resize(pix->width()-20, 10); |
370 | // top | 369 | // top |
371 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); | 370 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); |
372 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); | 371 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); |
373 | // bottom | 372 | // bottom |
374 | bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); | 373 | bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); |
375 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); | 374 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); |
376 | // left | 375 | // left |
377 | tilePix.resize(10, pix->height()-20); | 376 | tilePix.resize(10, pix->height()-20); |
378 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); | 377 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); |
379 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); | 378 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); |
380 | // right | 379 | // right |
381 | bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); | 380 | bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); |
382 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); | 381 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); |
383 | 382 | ||
384 | // middle | 383 | // middle |
385 | tilePix.resize(pix->width()-20, pix->height()-20); | 384 | tilePix.resize(pix->width()-20, pix->height()-20); |
386 | bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); | 385 | bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20); |
387 | p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); | 386 | p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); |
388 | 387 | ||
389 | 388 | ||
390 | // do the blend | 389 | // do the blend |
391 | QBitmap blendMask; | 390 | QBitmap blendMask; |
392 | if(!isMasked){ | 391 | if(!isMasked){ |
393 | //QRgb bgRgb = back.rgb(); | 392 | //QRgb bgRgb = back.rgb(); |
394 | //QRgb fgRgb = c.rgb(); | 393 | //QRgb fgRgb = c.rgb(); |
395 | //int r, g, b; | 394 | //int r, g, b; |
396 | 395 | ||
397 | //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); | 396 | //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); |
398 | //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); | 397 | //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); |
399 | //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); | 398 | //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); |
400 | //QColor blendColor(r, g, b); | 399 | //QColor blendColor(r, g, b); |
401 | int hue, sat, v1, v2; | 400 | int hue, sat, v1, v2; |
402 | QColor blendColor(autoDefault ? c : back); | 401 | QColor blendColor(autoDefault ? c : back); |
403 | back.hsv(&hue, &sat, &v1); | 402 | back.hsv(&hue, &sat, &v1); |
404 | blendColor.hsv(&hue, &sat, &v2); | 403 | blendColor.hsv(&hue, &sat, &v2); |
405 | if(v2 > v1) | 404 | if(v2 > v1) |
406 | blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); | 405 | blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); |
407 | 406 | ||
408 | pix = btnBorderDict.find(blendColor.rgb()); | 407 | pix = btnBorderDict.find(blendColor.rgb()); |
409 | if(!pix){ | 408 | if(!pix){ |
410 | int h, s, v; | 409 | int h, s, v; |
411 | blendColor.hsv(&h, &s, &v); | 410 | blendColor.hsv(&h, &s, &v); |
412 | pix = new QPixmap(*btnBlendPix); | 411 | pix = new QPixmap(*btnBlendPix); |
413 | adjustHSV(*pix, h, s, v); | 412 | adjustHSV(*pix, h, s, v); |
414 | btnBorderDict.insert(blendColor.rgb(), pix); | 413 | btnBorderDict.insert(blendColor.rgb(), pix); |
415 | } | 414 | } |
416 | } | 415 | } |
417 | else{ | 416 | else{ |
418 | pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : | 417 | pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : |
419 | getPixmap(HTMLBtnBorder); | 418 | getPixmap(HTMLBtnBorder); |
420 | } | 419 | } |
421 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl | 420 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl |
422 | p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr | 421 | p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr |
423 | p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl | 422 | p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl |
424 | p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br | 423 | p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br |
425 | 424 | ||
426 | // edges | 425 | // edges |
427 | tilePix.resize(pix->width()-20, 10); | 426 | tilePix.resize(pix->width()-20, 10); |
428 | blendMask.resize(pix->width()-20, 10); | 427 | blendMask.resize(pix->width()-20, 10); |
429 | // top | 428 | // top |
430 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); | 429 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); |
431 | bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10); | 430 | bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10); |
432 | tilePix.setMask(blendMask); | 431 | tilePix.setMask(blendMask); |
433 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); | 432 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); |
434 | // bottom | 433 | // bottom |
435 | bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); | 434 | bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20); |
436 | bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20); | 435 | bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20); |
437 | tilePix.setMask(blendMask); | 436 | tilePix.setMask(blendMask); |
438 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); | 437 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); |
439 | // left | 438 | // left |
440 | tilePix.resize(10, pix->height()-20); | 439 | tilePix.resize(10, pix->height()-20); |
441 | blendMask.resize(10, pix->height()-20); | 440 | blendMask.resize(10, pix->height()-20); |
442 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); | 441 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); |
443 | bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20); | 442 | bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20); |
444 | tilePix.setMask(blendMask); | 443 | tilePix.setMask(blendMask); |
445 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); | 444 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); |
446 | // right | 445 | // right |
447 | bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); | 446 | bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20); |
448 | bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20); | 447 | bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20); |
449 | tilePix.setMask(blendMask); | 448 | tilePix.setMask(blendMask); |
450 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); | 449 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); |
451 | 450 | ||
452 | p.end(); | 451 | p.end(); |
453 | 452 | ||
454 | // do the button mask - we don't automask buttons | 453 | // do the button mask - we don't automask buttons |
455 | QBitmap btnMask(w, h); | 454 | QBitmap btnMask(w, h); |
456 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; | 455 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; |
457 | p.begin(&btnMask); | 456 | p.begin(&btnMask); |
458 | p.fillRect(0, 0, w, h, Qt::color0); | 457 | p.fillRect(0, 0, w, h, Qt::color0); |
459 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl | 458 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl |
460 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr | 459 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr |
461 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl | 460 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl |
462 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br | 461 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br |
463 | // fills | 462 | // fills |
464 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top | 463 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top |
465 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 464 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
466 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle | 465 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle |
467 | p.end(); | 466 | p.end(); |
468 | tmpPix.setMask(btnMask); | 467 | tmpPix.setMask(btnMask); |
469 | /*if(autoDefault){ | 468 | /*if(autoDefault){ |
470 | if(supportPushDown && pushedDown){ | 469 | if(supportPushDown && pushedDown){ |
471 | painter->drawPixmap(x+3, y+3, tmpPix); | 470 | painter->drawPixmap(x+3, y+3, tmpPix); |
472 | } | 471 | } |
473 | else{ | 472 | else{ |
474 | painter->drawPixmap(x+2, y+2, tmpPix); | 473 | painter->drawPixmap(x+2, y+2, tmpPix); |
475 | } | 474 | } |
476 | } | 475 | } |
477 | else */if(supportPushDown && pushedDown) | 476 | else */if(supportPushDown && pushedDown) |
478 | painter->drawPixmap(x+1, y+1, tmpPix); | 477 | painter->drawPixmap(x+1, y+1, tmpPix); |
479 | else | 478 | else |
480 | painter->drawPixmap(x, y, tmpPix); | 479 | painter->drawPixmap(x, y, tmpPix); |
481 | 480 | ||
482 | 481 | ||
483 | 482 | ||
484 | } | 483 | } |
485 | 484 | ||
486 | 485 | ||
487 | QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, | 486 | QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v, |
488 | bool blend) | 487 | bool blend) |
489 | { | 488 | { |
490 | QImage img(qembed_findImage(label)); | 489 | QImage img(qembed_findImage(label)); |
491 | img.detach(); | 490 | img.detach(); |
492 | if(img.isNull()){ // shouldn't happen, been tested | 491 | if(img.isNull()){ // shouldn't happen, been tested |
493 | qWarning("Invalid embedded label %s", label); | 492 | qWarning("Invalid embedded label %s", label); |
494 | return(NULL); | 493 | return(NULL); |
495 | } | 494 | } |
496 | if(img.depth() != 32) | 495 | if(img.depth() != 32) |
497 | img = img.convertDepth(32); | 496 | img = img.convertDepth(32); |
498 | unsigned int *data = (unsigned int *)img.bits(); | 497 | unsigned int *data = (unsigned int *)img.bits(); |
499 | int total = img.width()*img.height(); | 498 | int total = img.width()*img.height(); |
500 | int current; | 499 | int current; |
501 | QColor c; | 500 | QColor c; |
502 | int oldH, oldS, oldV; | 501 | int oldH, oldS, oldV; |
503 | int alpha; | 502 | int alpha; |
504 | if(v < 235) | 503 | if(v < 235) |
505 | v += 20; | 504 | v += 20; |
506 | else | 505 | else |
507 | v = 255; | 506 | v = 255; |
508 | float intensity = v/255.0; | 507 | float intensity = v/255.0; |
509 | 508 | ||
510 | for(current=0; current<total; ++current){ | 509 | for(current=0; current<total; ++current){ |
511 | alpha = qAlpha(data[current]); | 510 | alpha = qAlpha(data[current]); |
512 | c.setRgb(data[current]); | 511 | c.setRgb(data[current]); |
513 | c.hsv(&oldH, &oldS, &oldV); | 512 | c.hsv(&oldH, &oldS, &oldV); |
514 | oldV = (int)(oldV*intensity); | 513 | oldV = (int)(oldV*intensity); |
515 | c.setHsv(h, s, oldV); | 514 | c.setHsv(h, s, oldV); |
516 | if(blend && alpha != 255 && alpha != 0){ | 515 | if(blend && alpha != 255 && alpha != 0){ |
517 | float srcPercent = ((float)alpha)/255.0; | 516 | float srcPercent = ((float)alpha)/255.0; |
518 | float destPercent = 1.0-srcPercent; | 517 | float destPercent = 1.0-srcPercent; |
519 | oldH = (int)((srcPercent*h) + (destPercent*bH)); | 518 | oldH = (int)((srcPercent*h) + (destPercent*bH)); |
520 | oldS = (int)((srcPercent*s) + (destPercent*bS)); | 519 | oldS = (int)((srcPercent*s) + (destPercent*bS)); |
521 | oldV = (int)((srcPercent*oldV) + (destPercent*bV)); | 520 | oldV = (int)((srcPercent*oldV) + (destPercent*bV)); |
522 | c.setHsv(oldH, oldS, oldV); | 521 | c.setHsv(oldH, oldS, oldV); |
523 | alpha = 255; | 522 | alpha = 255; |
524 | } | 523 | } |
525 | data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); | 524 | data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); |
526 | } | 525 | } |
527 | QPixmap *pix = new QPixmap; | 526 | QPixmap *pix = new QPixmap; |
528 | pix->convertFromImage(img); | 527 | pix->convertFromImage(img); |
529 | return(pix); | 528 | return(pix); |
530 | } | 529 | } |
531 | 530 | ||
532 | 531 | ||
533 | 532 | ||
534 | 533 | ||
535 | QPixmap* LiquidStyle::getPixmap(BitmapData item) | 534 | QPixmap* LiquidStyle::getPixmap(BitmapData item) |
536 | { | 535 | { |
537 | 536 | ||
538 | if(pixmaps[item]) | 537 | if(pixmaps[item]) |
539 | return(pixmaps[item]); | 538 | return(pixmaps[item]); |
540 | 539 | ||
541 | switch(item){ | 540 | switch(item){ |
542 | case HTMLBtnBorder: | 541 | case HTMLBtnBorder: |
543 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); | 542 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); |
544 | break; | 543 | break; |
545 | case HTMLBtnBorderDown: | 544 | case HTMLBtnBorderDown: |
546 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); | 545 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); |
547 | break; | 546 | break; |
548 | case HTMLCB: | 547 | case HTMLCB: |
549 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); | 548 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); |
550 | break; | 549 | break; |
551 | case HTMLCBDown: | 550 | case HTMLCBDown: |
552 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); | 551 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); |
553 | break; | 552 | break; |
554 | case HTMLCBHover: | 553 | case HTMLCBHover: |
555 | pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); | 554 | pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); |
556 | break; | 555 | break; |
557 | case HTMLCBDownHover: | 556 | case HTMLCBDownHover: |
558 | pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", | 557 | pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", |
559 | btnHoverH, btnHoverS, | 558 | btnHoverH, btnHoverS, |
560 | btnHoverV); | 559 | btnHoverV); |
561 | break; | 560 | break; |
562 | case HTMLRadio: | 561 | case HTMLRadio: |
563 | pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); | 562 | pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); |
564 | case HTMLRadioDown: | 563 | case HTMLRadioDown: |
565 | pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); | 564 | pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); |
566 | case HTMLRadioHover: | 565 | case HTMLRadioHover: |
567 | pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); | 566 | pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); |
568 | case HTMLRadioDownHover: | 567 | case HTMLRadioDownHover: |
569 | pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", | 568 | pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", |
570 | btnHoverH, btnHoverS, | 569 | btnHoverH, btnHoverS, |
571 | btnHoverV); | 570 | btnHoverV); |
572 | case RadioOn: | 571 | case RadioOn: |
573 | pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); | 572 | pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); |
574 | break; | 573 | break; |
575 | case RadioOnHover: | 574 | case RadioOnHover: |
576 | pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, | 575 | pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, |
577 | btnHoverV, true); | 576 | btnHoverV, true); |
578 | break; | 577 | break; |
579 | case RadioOffHover: | 578 | case RadioOffHover: |
580 | pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); | 579 | pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); |
581 | break; | 580 | break; |
582 | case TabDown: | 581 | case TabDown: |
583 | pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); | 582 | pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); |
584 | break; | 583 | break; |
585 | case TabFocus: | 584 | case TabFocus: |
586 | pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, | 585 | pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, |
587 | btnHoverS, true); | 586 | btnHoverS, true); |
588 | break; | 587 | break; |
589 | case CBDown: | 588 | case CBDown: |
590 | pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); | 589 | pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); |
591 | break; | 590 | break; |
592 | case CBDownHover: | 591 | case CBDownHover: |
593 | pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, | 592 | pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, |
594 | btnHoverS, btnHoverV, true); | 593 | btnHoverS, btnHoverV, true); |
595 | break; | 594 | break; |
596 | case CBHover: | 595 | case CBHover: |
597 | pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); | 596 | pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); |
598 | break; | 597 | break; |
599 | case HSlider: | 598 | case HSlider: |
600 | pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); | 599 | pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); |
601 | break; | 600 | break; |
602 | case VSlider: | 601 | case VSlider: |
603 | pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); | 602 | pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); |
604 | *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); | 603 | *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); |
605 | break; | 604 | break; |
606 | case RadioOff: | 605 | case RadioOff: |
607 | pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); | 606 | pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); |
608 | break; | 607 | break; |
609 | case Tab: | 608 | case Tab: |
610 | pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); | 609 | pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); |
611 | break; | 610 | break; |
612 | case CB: | 611 | case CB: |
613 | pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); | 612 | pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); |
614 | break; | 613 | break; |
615 | case VSBSliderTop: | 614 | case VSBSliderTop: |
616 | pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); | 615 | pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); |
617 | break; | 616 | break; |
618 | case VSBSliderBtm: | 617 | case VSBSliderBtm: |
619 | pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); | 618 | pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); |
620 | break; | 619 | break; |
621 | case VSBSliderMid: | 620 | case VSBSliderMid: |
622 | pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); | 621 | pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); |
623 | break; | 622 | break; |
624 | case VSBSliderTopHover: | 623 | case VSBSliderTopHover: |
625 | pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); | 624 | pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); |
626 | break; | 625 | break; |
627 | case VSBSliderBtmHover: | 626 | case VSBSliderBtmHover: |
628 | pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); | 627 | pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); |
629 | break; | 628 | break; |
630 | case VSBSliderMidHover: | 629 | case VSBSliderMidHover: |
631 | pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); | 630 | pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); |
632 | break; | 631 | break; |
633 | 632 | ||
634 | case HSBSliderTop: | 633 | case HSBSliderTop: |
635 | pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); | 634 | pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); |
636 | *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); | 635 | *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); |
637 | break; | 636 | break; |
638 | case HSBSliderBtm: | 637 | case HSBSliderBtm: |
639 | pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); | 638 | pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); |
640 | *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); | 639 | *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); |
641 | break; | 640 | break; |
642 | case HSBSliderMid: | 641 | case HSBSliderMid: |
643 | pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); | 642 | pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); |
644 | *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); | 643 | *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); |
645 | break; | 644 | break; |
646 | case HSBSliderTopHover: | 645 | case HSBSliderTopHover: |
647 | pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); | 646 | pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); |
648 | *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); | 647 | *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); |
649 | break; | 648 | break; |
650 | case HSBSliderBtmHover: | 649 | case HSBSliderBtmHover: |
651 | pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); | 650 | pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); |
652 | *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); | 651 | *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); |
653 | break; | 652 | break; |
654 | case HSBSliderMidHover: | 653 | case HSBSliderMidHover: |
655 | pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); | 654 | pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); |
656 | *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); | 655 | *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); |
657 | break; | 656 | break; |
658 | case VSBSliderTopBg: | 657 | case VSBSliderTopBg: |
659 | pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); | 658 | pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); |
660 | break; | 659 | break; |
661 | case VSBSliderBtmBg: | 660 | case VSBSliderBtmBg: |
662 | pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); | 661 | pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); |
663 | break; | 662 | break; |
664 | case VSBSliderMidBg: | 663 | case VSBSliderMidBg: |
665 | pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); | 664 | pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); |
666 | break; | 665 | break; |
667 | case HSBSliderTopBg: | 666 | case HSBSliderTopBg: |
668 | pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); | 667 | pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); |
669 | *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); | 668 | *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); |
670 | break; | 669 | break; |
671 | case HSBSliderBtmBg: | 670 | case HSBSliderBtmBg: |
672 | pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); | 671 | pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); |
673 | *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); | 672 | *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); |
674 | break; | 673 | break; |
675 | case HSBSliderMidBg: | 674 | case HSBSliderMidBg: |
676 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); | 675 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); |
677 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); | 676 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); |
678 | break; | 677 | break; |
679 | default: | 678 | default: |
680 | break; | 679 | break; |
681 | } | 680 | } |
682 | return(pixmaps[item]); | 681 | return(pixmaps[item]); |
683 | } | 682 | } |
684 | 683 | ||
685 | void LiquidStyle::polish(QPalette &appPal) | 684 | void LiquidStyle::polish(QPalette &appPal) |
686 | { | 685 | { |
687 | 686 | ||
688 | int i; | 687 | int i; |
689 | for(i=0; i < BITMAP_ITEMS; ++i){ | 688 | for(i=0; i < BITMAP_ITEMS; ++i){ |
690 | if(pixmaps[i]){ | 689 | if(pixmaps[i]){ |
691 | delete pixmaps[i]; | 690 | delete pixmaps[i]; |
692 | pixmaps[i] = NULL; | 691 | pixmaps[i] = NULL; |
693 | } | 692 | } |
694 | } | 693 | } |
695 | QWidgetList *list = QApplication::allWidgets(); | 694 | QWidgetList *list = QApplication::allWidgets(); |
696 | QWidgetListIt it( *list ); | 695 | QWidgetListIt it( *list ); |
697 | QWidget *w; | 696 | QWidget *w; |
698 | while ((w=it.current()) != 0 ){ | 697 | while ((w=it.current()) != 0 ){ |
699 | ++it; | 698 | ++it; |
700 | if(w->inherits("QPushButton")){ | 699 | if(w->inherits("QPushButton")){ |
701 | unapplyCustomAttributes((QPushButton *)w); | 700 | unapplyCustomAttributes((QPushButton *)w); |
702 | } | 701 | } |
703 | } | 702 | } |
704 | 703 | ||
705 | loadCustomButtons(); | 704 | loadCustomButtons(); |
706 | lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; | 705 | lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; |
707 | btnDict.clear(); | 706 | btnDict.clear(); |
708 | btnBorderDict.clear(); | 707 | btnBorderDict.clear(); |
709 | bevelFillDict.clear(); | 708 | bevelFillDict.clear(); |
710 | smallBevelFillDict.clear(); | 709 | smallBevelFillDict.clear(); |
711 | 710 | ||
712 | Config config ( "qpe" ); | 711 | Config config ( "qpe" ); |
713 | config. setGroup ( "Liquid-Style" ); | 712 | config. setGroup ( "Liquid-Style" ); |
714 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); | 713 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); |
715 | if ( contrast < 0 ) | 714 | if ( contrast < 0 ) |
716 | contrast = 0; | 715 | contrast = 0; |
717 | else if ( contrast > 10 ) | 716 | else if ( contrast > 10 ) |
718 | contrast = 10; | 717 | contrast = 10; |
719 | 718 | ||
720 | QPalette pal = QApplication::palette(); | 719 | QPalette pal = QApplication::palette(); |
721 | 720 | ||
722 | // button color stuff | 721 | // button color stuff |
723 | config. setGroup ( "Appearance" ); | 722 | config. setGroup ( "Appearance" ); |
724 | QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); | 723 | QColor c = QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); |
725 | if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) { | 724 | if ( c == QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( )))) { |
726 | // force button color to be different from background | 725 | // force button color to be different from background |
727 | QBrush btnBrush(QColor(200, 202, 228)); | 726 | QBrush btnBrush(QColor(200, 202, 228)); |
728 | appPal.setBrush(QColorGroup::Button, btnBrush); | 727 | appPal.setBrush(QColorGroup::Button, btnBrush); |
729 | } | 728 | } |
730 | c.hsv(&btnH, &btnS, &btnV); | 729 | c.hsv(&btnH, &btnS, &btnV); |
731 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); | 730 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); |
732 | 731 | ||
733 | // menu pixmap | 732 | // menu pixmap |
734 | if(!menuPix){ | 733 | if(!menuPix){ |
735 | menuPix = new QPixmap; | 734 | menuPix = new QPixmap; |
736 | menuPix->resize(64, 64); | 735 | menuPix->resize(64, 64); |
737 | } | 736 | } |
738 | QPainter painter; | 737 | QPainter painter; |
739 | menuPix->fill(c.rgb()); | 738 | menuPix->fill(c.rgb()); |
740 | painter.begin(menuPix); | 739 | painter.begin(menuPix); |
741 | painter.setPen(c.dark(105)); | 740 | painter.setPen(c.dark(105)); |
742 | for(i=0; i < 63; i+=4){ | 741 | for(i=0; i < 63; i+=4){ |
743 | painter.drawLine(0, i, 63, i); | 742 | painter.drawLine(0, i, 63, i); |
744 | painter.drawLine(0, i+1, 63, i+1); | 743 | painter.drawLine(0, i+1, 63, i+1); |
745 | }; | 744 | }; |
746 | painter.end(); | 745 | painter.end(); |
747 | menuBrush.setColor(c); | 746 | menuBrush.setColor(c); |
748 | menuBrush.setPixmap(*menuPix); | 747 | menuBrush.setPixmap(*menuPix); |
749 | 748 | ||
750 | // pager brush | 749 | // pager brush |
751 | c = c.dark(120); | 750 | c = c.dark(120); |
752 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 751 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
753 | if(!pix){ | 752 | if(!pix){ |
754 | int h, s, v; | 753 | int h, s, v; |
755 | c.hsv(&h, &s, &v); | 754 | c.hsv(&h, &s, &v); |
756 | pix = new QPixmap(*smallBevelFillPix); | 755 | pix = new QPixmap(*smallBevelFillPix); |
757 | adjustHSV(*pix, h, s, v); | 756 | adjustHSV(*pix, h, s, v); |
758 | smallBevelFillDict.insert(c.rgb(), pix); | 757 | smallBevelFillDict.insert(c.rgb(), pix); |
759 | } | 758 | } |
760 | pagerHoverBrush.setColor(c); | 759 | pagerHoverBrush.setColor(c); |
761 | pagerHoverBrush.setPixmap(*pix); | 760 | pagerHoverBrush.setPixmap(*pix); |
762 | 761 | ||
763 | c = c.dark(120); | 762 | c = c.dark(120); |
764 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 763 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
765 | if(!pix){ | 764 | if(!pix){ |
766 | int h, s, v; | 765 | int h, s, v; |
767 | c.hsv(&h, &s, &v); | 766 | c.hsv(&h, &s, &v); |
768 | pix = new QPixmap(*smallBevelFillPix); | 767 | pix = new QPixmap(*smallBevelFillPix); |
769 | adjustHSV(*pix, h, s, v); | 768 | adjustHSV(*pix, h, s, v); |
770 | smallBevelFillDict.insert(c.rgb(), pix); | 769 | smallBevelFillDict.insert(c.rgb(), pix); |
771 | } | 770 | } |
772 | pagerBrush.setColor(c); | 771 | pagerBrush.setColor(c); |
773 | pagerBrush.setPixmap(*pix); | 772 | pagerBrush.setPixmap(*pix); |
774 | 773 | ||
775 | // background color stuff | 774 | // background color stuff |
776 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); | 775 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); |
777 | c.hsv(&bH, &bS, &bV); | 776 | c.hsv(&bH, &bS, &bV); |
778 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); | 777 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); |
779 | 778 | ||
780 | // FIXME? | 779 | // FIXME? |
781 | if(vsbSliderFillPix) | 780 | if(vsbSliderFillPix) |
782 | delete vsbSliderFillPix; | 781 | delete vsbSliderFillPix; |
783 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); | 782 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); |
784 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); | 783 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); |
785 | 784 | ||
786 | // background brush | 785 | // background brush |
787 | QPixmap wallPaper(32, 32); | 786 | QPixmap wallPaper(32, 32); |
788 | wallPaper.fill(c.rgb()); | 787 | wallPaper.fill(c.rgb()); |
789 | painter.begin(&wallPaper); | 788 | painter.begin(&wallPaper); |
790 | for(i=0; i < 32; i+=4){ | 789 | for(i=0; i < 32; i+=4){ |
791 | painter.setPen(c.dark(100 + contrast)); | 790 | painter.setPen(c.dark(100 + contrast)); |
792 | painter.drawLine(0, i, 32, i); | 791 | painter.drawLine(0, i, 32, i); |
793 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); | 792 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); |
794 | painter.drawLine(0, i+1, 32, i+1); | 793 | painter.drawLine(0, i+1, 32, i+1); |
795 | }; | 794 | }; |
796 | painter.end(); | 795 | painter.end(); |
797 | bgBrush.setColor(c); | 796 | bgBrush.setColor(c); |
798 | bgBrush.setPixmap(wallPaper); | 797 | bgBrush.setPixmap(wallPaper); |
799 | appPal.setBrush(QColorGroup::Background, bgBrush); | 798 | appPal.setBrush(QColorGroup::Background, bgBrush); |
800 | 799 | ||
801 | // lineedits | 800 | // lineedits |
802 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); | 801 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); |
803 | QPixmap basePix; | 802 | QPixmap basePix; |
804 | basePix.resize(32, 32); | 803 | basePix.resize(32, 32); |
805 | basePix.fill(c.rgb()); | 804 | basePix.fill(c.rgb()); |
806 | painter.begin(&basePix); | 805 | painter.begin(&basePix); |
807 | painter.setPen(c.dark(105)); | 806 | painter.setPen(c.dark(105)); |
808 | for(i=0; i < 32; i+=4){ | 807 | for(i=0; i < 32; i+=4){ |
809 | painter.drawLine(0, i, 32, i); | 808 | painter.drawLine(0, i, 32, i); |
810 | painter.drawLine(0, i+1, 32, i+1); | 809 | painter.drawLine(0, i+1, 32, i+1); |
811 | }; | 810 | }; |
812 | painter.end(); | 811 | painter.end(); |
813 | baseBrush.setColor(c); | 812 | baseBrush.setColor(c); |
814 | baseBrush.setPixmap(basePix); | 813 | baseBrush.setPixmap(basePix); |
815 | it.toFirst(); | 814 | it.toFirst(); |
816 | while ((w=it.current()) != 0 ){ | 815 | while ((w=it.current()) != 0 ){ |
817 | ++it; | 816 | ++it; |
818 | if(w->inherits("QLineEdit")){ | 817 | if(w->inherits("QLineEdit")){ |
819 | QPalette pal = w->palette(); | 818 | QPalette pal = w->palette(); |
820 | pal.setBrush(QColorGroup::Base, baseBrush); | 819 | pal.setBrush(QColorGroup::Base, baseBrush); |
821 | w->setPalette(pal); | 820 | w->setPalette(pal); |
822 | } | 821 | } |
823 | else if(w->inherits("QPushButton")){ | 822 | else if(w->inherits("QPushButton")){ |
824 | applyCustomAttributes((QPushButton *)w); | 823 | applyCustomAttributes((QPushButton *)w); |
825 | } | 824 | } |
826 | } | 825 | } |
827 | 826 | ||
828 | } | 827 | } |
829 | 828 | ||
830 | void LiquidStyle::polish(QWidget *w) | 829 | void LiquidStyle::polish(QWidget *w) |
831 | { | 830 | { |
832 | if(w->inherits("QMenuBar")){ | 831 | if(w->inherits("QMenuBar")){ |
833 | //((QFrame*)w)->setLineWidth(0); | 832 | //((QFrame*)w)->setLineWidth(0); |
834 | w->setBackgroundMode(QWidget::PaletteBackground); | 833 | w->setBackgroundMode(QWidget::PaletteBackground); |
835 | return; | 834 | return; |
836 | } | 835 | } |
837 | if(w->inherits("QPopupMenu")) | 836 | if(w->inherits("QPopupMenu")) |
838 | w->setBackgroundMode(QWidget::NoBackground); | 837 | w->setBackgroundMode(QWidget::NoBackground); |
839 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 838 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
840 | w->installEventFilter(menuHandler); | 839 | w->installEventFilter(menuHandler); |
841 | } | 840 | } |
842 | 841 | ||
843 | if(w->isTopLevel()){ | 842 | if(w->isTopLevel()){ |
844 | return; | 843 | return; |
845 | } | 844 | } |
846 | 845 | ||
847 | 846 | ||
848 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | 847 | if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) |
848 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | ||
849 | 849 | ||
850 | if(w->inherits("QComboBox") || | 850 | if(w->inherits("QComboBox") || |
851 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 851 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
852 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 852 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
853 | w->installEventFilter(this); | 853 | w->installEventFilter(this); |
854 | } | 854 | } |
855 | if(w->inherits("QLineEdit")){ | 855 | if(w->inherits("QLineEdit")){ |
856 | QPalette pal = w->palette(); | 856 | QPalette pal = w->palette(); |
857 | pal.setBrush(QColorGroup::Base, baseBrush); | 857 | pal.setBrush(QColorGroup::Base, baseBrush); |
858 | w->setPalette(pal); | 858 | w->setPalette(pal); |
859 | } | 859 | } |
860 | if(w->inherits("QPushButton")){ | 860 | if(w->inherits("QPushButton")){ |
861 | applyCustomAttributes((QPushButton *)w); | 861 | applyCustomAttributes((QPushButton *)w); |
862 | w->installEventFilter(this); | 862 | w->installEventFilter(this); |
863 | } | 863 | } |
864 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ | 864 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ |
865 | w-> setBackgroundMode ( QWidget::PaletteBackground ); | 865 | w-> setBackgroundMode ( QWidget::PaletteBackground ); |
866 | } | 866 | } |
867 | 867 | ||
868 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || | 868 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || |
869 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; | 869 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; |
870 | bool isViewportChild = w->parent() && | 870 | bool isViewportChild = w->parent() && |
871 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 871 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
872 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 872 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
873 | 873 | ||
874 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ | 874 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ |
875 | w->setBackgroundMode(QWidget::X11ParentRelative); | 875 | w->setBackgroundMode(QWidget::X11ParentRelative); |
876 | return; | 876 | return; |
877 | } | 877 | } |
878 | if(isViewportChild){ | 878 | if(isViewportChild){ |
879 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 879 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
880 | if(w->parent()){ // heh, only way to test for KHTML children ;-) | 880 | if(w->parent()){ // heh, only way to test for KHTML children ;-) |
881 | if(w->parent()->parent()){ | 881 | if(w->parent()->parent()){ |
882 | if(w->parent()->parent()->parent() && | 882 | if(w->parent()->parent()->parent() && |
883 | w->parent()->parent()->parent()->inherits("KHTMLView")){ | 883 | w->parent()->parent()->parent()->inherits("KHTMLView")){ |
884 | w->setAutoMask(true); | 884 | w->setAutoMask(true); |
885 | w->setBackgroundMode(QWidget::NoBackground); | 885 | w->setBackgroundMode(QWidget::NoBackground); |
886 | } | 886 | } |
887 | } | 887 | } |
888 | } | 888 | } |
889 | return; | 889 | return; |
890 | } | 890 | } |
891 | } | 891 | } |
892 | if(w->inherits("QHeader")){ | 892 | if(w->inherits("QHeader")){ |
893 | w->setMouseTracking(true); | 893 | w->setMouseTracking(true); |
894 | w->installEventFilter(this); | 894 | w->installEventFilter(this); |
895 | } | 895 | } |
896 | if(w-> inherits("QToolButton")) { | 896 | if(w-> inherits("QToolButton")) { |
897 | ((QToolButton*)w)->setAutoRaise (false); | 897 | ((QToolButton*)w)->setAutoRaise (false); |
898 | } | 898 | } |
899 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 899 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
900 | return; | 900 | return; |
901 | } | 901 | } |
902 | 902 | ||
903 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 903 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
904 | palette().active().brush(QColorGroup::Background).pixmap()){ | 904 | palette().active().brush(QColorGroup::Background).pixmap()){ |
905 | qWarning("No parent pixmap for child widget %s", w->className()); | 905 | qWarning("No parent pixmap for child widget %s", w->className()); |
906 | return; | 906 | return; |
907 | } | 907 | } |
908 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && | 908 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && |
909 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { | 909 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { |
910 | if(w->backgroundMode() == QWidget::PaletteBackground || | 910 | if(w->backgroundMode() == QWidget::PaletteBackground || |
911 | w->backgroundMode() == QWidget::PaletteButton){ | 911 | w->backgroundMode() == QWidget::PaletteButton){ |
912 | w->setBackgroundMode(QWidget::X11ParentRelative); | 912 | w->setBackgroundMode(QWidget::X11ParentRelative); |
913 | } | 913 | } |
914 | } | 914 | } |
915 | if(w->inherits("QToolBar")){ | 915 | if(w->inherits("QToolBar")){ |
916 | w->installEventFilter(this); | 916 | w->installEventFilter(this); |
917 | w->setBackgroundMode(QWidget::PaletteBackground); | 917 | w->setBackgroundMode(QWidget::PaletteBackground); |
918 | return; | 918 | return; |
919 | } | 919 | } |
920 | 920 | ||
921 | } | 921 | } |
922 | 922 | ||
923 | void LiquidStyle::unPolish(QWidget *w) | 923 | void LiquidStyle::unPolish(QWidget *w) |
924 | { | 924 | { |
925 | if(w->inherits("QMenuBar")){ | 925 | if(w->inherits("QMenuBar")){ |
926 | ((QFrame *)w)->setLineWidth(1); | 926 | ((QFrame *)w)->setLineWidth(1); |
927 | w->setBackgroundMode(QWidget::PaletteBackground); | 927 | w->setBackgroundMode(QWidget::PaletteBackground); |
928 | return; | 928 | return; |
929 | } | 929 | } |
930 | 930 | ||
931 | if(w->inherits("QPopupMenu")) | 931 | if(w->inherits("QPopupMenu")) |
932 | w->setBackgroundMode(QWidget::PaletteButton); | 932 | w->setBackgroundMode(QWidget::PaletteButton); |
933 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 933 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
934 | w->removeEventFilter(menuHandler); | 934 | w->removeEventFilter(menuHandler); |
935 | } | 935 | } |
936 | 936 | ||
937 | if(w->isTopLevel()) | 937 | if(w->isTopLevel()) |
938 | return; | 938 | return; |
939 | 939 | ||
940 | // for viewport children, don't just check for NoBackground.... | 940 | // for viewport children, don't just check for NoBackground.... |
941 | bool isViewportChild = w->parent() && | 941 | bool isViewportChild = w->parent() && |
942 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 942 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
943 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 943 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
944 | 944 | ||
945 | w->setPalette(QApplication::palette()); | 945 | w->setPalette(QApplication::palette()); |
946 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ | 946 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ |
947 | if(w->inherits("QPushButton")) | 947 | if(w->inherits("QPushButton")) |
948 | w->setBackgroundMode(QWidget::PaletteButton); | 948 | w->setBackgroundMode(QWidget::PaletteButton); |
949 | else | 949 | else |
950 | w->setBackgroundMode(QWidget::PaletteBackground); | 950 | w->setBackgroundMode(QWidget::PaletteBackground); |
951 | } | 951 | } |
952 | 952 | ||
953 | if(isViewportChild) | 953 | if(isViewportChild) |
954 | w->setAutoMask(false); | 954 | w->setAutoMask(false); |
955 | 955 | ||
956 | if(w->inherits("QPushButton")){ | 956 | if(w->inherits("QPushButton")){ |
957 | unapplyCustomAttributes((QPushButton *)w); | 957 | unapplyCustomAttributes((QPushButton *)w); |
958 | w->removeEventFilter(this); | 958 | w->removeEventFilter(this); |
959 | } | 959 | } |
960 | /* | 960 | /* |
961 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ | 961 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ |
962 | w-> setBackgroundMode ( PaletteBackground ); | 962 | w-> setBackgroundMode ( PaletteBackground ); |
963 | } | 963 | } |
964 | */ | 964 | */ |
965 | if(w->inherits("QComboBox") || | 965 | if(w->inherits("QComboBox") || |
966 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 966 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
967 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 967 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
968 | w->removeEventFilter(this); | 968 | w->removeEventFilter(this); |
969 | } | 969 | } |
970 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 970 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
971 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ | 971 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ |
972 | w->setAutoMask(false); | 972 | w->setAutoMask(false); |
973 | } | 973 | } |
974 | } | 974 | } |
975 | if(w->inherits("QToolBar")){ | 975 | if(w->inherits("QToolBar")){ |
976 | w->removeEventFilter(this); | 976 | w->removeEventFilter(this); |
977 | w->setBackgroundMode(QWidget::PaletteBackground); | 977 | w->setBackgroundMode(QWidget::PaletteBackground); |
978 | return; | 978 | return; |
979 | } | 979 | } |
980 | if(w->inherits("QHeader")){ | 980 | if(w->inherits("QHeader")){ |
981 | w->setMouseTracking(false); | 981 | w->setMouseTracking(false); |
982 | w->removeEventFilter(this); | 982 | w->removeEventFilter(this); |
983 | } | 983 | } |
984 | } | 984 | } |
985 | 985 | ||
986 | void LiquidStyle::polish(QApplication *app) | 986 | void LiquidStyle::polish(QApplication *app) |
987 | { | 987 | { |
988 | 988 | ||
989 | QWindowsStyle::polish(app); | 989 | QWindowsStyle::polish(app); |
990 | menuAni = app->isEffectEnabled(UI_AnimateMenu); | 990 | menuAni = app->isEffectEnabled(UI_AnimateMenu); |
991 | menuFade = app->isEffectEnabled(UI_FadeMenu); | 991 | menuFade = app->isEffectEnabled(UI_FadeMenu); |
992 | if(menuAni) | 992 | if(menuAni) |
993 | app->setEffectEnabled(UI_AnimateMenu, false); | 993 | app->setEffectEnabled(UI_AnimateMenu, false); |
994 | if(menuFade) | 994 | if(menuFade) |
995 | app->setEffectEnabled(UI_FadeMenu, false); | 995 | app->setEffectEnabled(UI_FadeMenu, false); |
996 | 996 | ||
997 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); | 997 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); |
998 | 998 | ||
999 | Config config ( "qpe" ); | 999 | Config config ( "qpe" ); |
1000 | config. setGroup ( "Liquid-Style" ); | 1000 | config. setGroup ( "Liquid-Style" ); |
1001 | 1001 | ||
1002 | if ( config. readBoolEntry ( "WinDecoration", true )) | 1002 | if ( config. readBoolEntry ( "WinDecoration", true )) |
1003 | QApplication::qwsSetDecoration ( new LiquidDecoration ( )); | 1003 | QApplication::qwsSetDecoration ( new LiquidDecoration ( )); |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | void LiquidStyle::unPolish(QApplication *app) | 1006 | void LiquidStyle::unPolish(QApplication *app) |
1007 | { | 1007 | { |
1008 | QWindowsStyle::unPolish(app); | 1008 | QWindowsStyle::unPolish(app); |
1009 | app->setEffectEnabled(UI_AnimateMenu, menuAni); | 1009 | app->setEffectEnabled(UI_AnimateMenu, menuAni); |
1010 | app->setEffectEnabled(UI_FadeMenu, menuFade); | 1010 | app->setEffectEnabled(UI_FadeMenu, menuFade); |
1011 | 1011 | ||
1012 | qt_set_draw_menu_bar_impl ( 0 ); | 1012 | qt_set_draw_menu_bar_impl ( 0 ); |
1013 | 1013 | ||
1014 | QApplication::qwsSetDecoration ( new QPEDecoration ( )); | 1014 | QApplication::qwsSetDecoration ( new QPEDecoration ( )); |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | /* | 1017 | /* |
1018 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1018 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
1019 | * force everything to erase and repaint on resize. This is going away, I'm | 1019 | * force everything to erase and repaint on resize. This is going away, I'm |
1020 | * trying to get shaped widgets to work right without masking. QPushButton, | 1020 | * trying to get shaped widgets to work right without masking. QPushButton, |
1021 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1021 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1022 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1022 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1023 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1023 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1024 | * caches them in QPixmapCache, which is bad for doing things like hover | 1024 | * caches them in QPixmapCache, which is bad for doing things like hover |
1025 | * because the style methods aren't called in paintEvents if everything | 1025 | * because the style methods aren't called in paintEvents if everything |
1026 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1026 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1027 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1027 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
1028 | * modifications. For QHeader, different header items are actually one widget | 1028 | * modifications. For QHeader, different header items are actually one widget |
1029 | * that draws multiple items, so we need to check which ID is hightlighted | 1029 | * that draws multiple items, so we need to check which ID is hightlighted |
1030 | * and draw it. Finally, we also check enter and leave events for QLineEdit, | 1030 | * and draw it. Finally, we also check enter and leave events for QLineEdit, |
1031 | * since if it's inside a combobox we want to highlight the combobox during | 1031 | * since if it's inside a combobox we want to highlight the combobox during |
1032 | * hovering in the edit. | 1032 | * hovering in the edit. |
1033 | */ | 1033 | */ |
1034 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | 1034 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) |
1035 | { | 1035 | { |
1036 | if(obj->inherits("QToolBar")){ | 1036 | if(obj->inherits("QToolBar")){ |
1037 | if(ev->type() == QEvent::Resize){ | 1037 | if(ev->type() == QEvent::Resize){ |
1038 | const QObjectList *tbChildList = obj->children(); | 1038 | const QObjectList *tbChildList = obj->children(); |
1039 | QObjectListIt it(*tbChildList); | 1039 | QObjectListIt it(*tbChildList); |
1040 | QObject *child; | 1040 | QObject *child; |
1041 | while((child = it.current()) != NULL){ | 1041 | while((child = it.current()) != NULL){ |
1042 | ++it; | 1042 | ++it; |
1043 | if(child->isWidgetType()) | 1043 | if(child->isWidgetType()) |
1044 | ((QWidget *)child)->repaint(true); | 1044 | ((QWidget *)child)->repaint(true); |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ | 1049 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ |
1050 | QWidget *btn = (QWidget *)obj; | 1050 | QWidget *btn = (QWidget *)obj; |
1051 | if(ev->type() == QEvent::Enter){ | 1051 | if(ev->type() == QEvent::Enter){ |
1052 | if(btn->isEnabled()){ | 1052 | if(btn->isEnabled()){ |
1053 | highlightWidget = btn; | 1053 | highlightWidget = btn; |
1054 | btn->repaint(false); | 1054 | btn->repaint(false); |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | else if(ev->type() == QEvent::Leave){ | 1057 | else if(ev->type() == QEvent::Leave){ |
1058 | if(btn == highlightWidget){ | 1058 | if(btn == highlightWidget){ |
1059 | highlightWidget = NULL; | 1059 | highlightWidget = NULL; |
1060 | btn->repaint(false); | 1060 | btn->repaint(false); |
1061 | } | 1061 | } |
1062 | } | 1062 | } |
1063 | } | 1063 | } |
1064 | else if(obj->inherits("QToolButton")){ | 1064 | else if(obj->inherits("QToolButton")){ |
1065 | QToolButton *btn = (QToolButton *)btn; | 1065 | QToolButton *btn = (QToolButton *)btn; |
1066 | if(!btn->autoRaise()){ | 1066 | if(!btn->autoRaise()){ |
1067 | if(btn->isEnabled()){ | 1067 | if(btn->isEnabled()){ |
1068 | highlightWidget = btn; | 1068 | highlightWidget = btn; |
1069 | btn->repaint(false); | 1069 | btn->repaint(false); |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | else if(ev->type() == QEvent::Leave){ | 1072 | else if(ev->type() == QEvent::Leave){ |
1073 | QWidget *btn = (QWidget *)obj; | 1073 | QWidget *btn = (QWidget *)obj; |
1074 | if(btn == highlightWidget){ | 1074 | if(btn == highlightWidget){ |
1075 | highlightWidget = NULL; | 1075 | highlightWidget = NULL; |
1076 | btn->repaint(false); | 1076 | btn->repaint(false); |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | else | 1079 | else |
1080 | highlightWidget = NULL; | 1080 | highlightWidget = NULL; |
1081 | } | 1081 | } |
1082 | else if(obj->inherits("QScrollBar")){ | 1082 | else if(obj->inherits("QScrollBar")){ |
1083 | QScrollBar *sb = (QScrollBar *)obj; | 1083 | QScrollBar *sb = (QScrollBar *)obj; |
1084 | if(ev->type() == QEvent::Enter){ | 1084 | if(ev->type() == QEvent::Enter){ |
1085 | if(sb->isEnabled()){ | 1085 | if(sb->isEnabled()){ |
1086 | highlightWidget = sb; | 1086 | highlightWidget = sb; |
1087 | sb->repaint(false); | 1087 | sb->repaint(false); |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | else if(ev->type() == QEvent::Leave){ | 1090 | else if(ev->type() == QEvent::Leave){ |
1091 | if(sb == highlightWidget && !sb->draggingSlider()){ | 1091 | if(sb == highlightWidget && !sb->draggingSlider()){ |
1092 | highlightWidget = NULL; | 1092 | highlightWidget = NULL; |
1093 | sb->repaint(false); | 1093 | sb->repaint(false); |
1094 | } | 1094 | } |
1095 | } | 1095 | } |
1096 | else if(ev->type() == QEvent::MouseButtonRelease){ | 1096 | else if(ev->type() == QEvent::MouseButtonRelease){ |
1097 | QMouseEvent *me = (QMouseEvent *)ev; | 1097 | QMouseEvent *me = (QMouseEvent *)ev; |
1098 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ | 1098 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ |
1099 | highlightWidget = NULL; | 1099 | highlightWidget = NULL; |
1100 | sb->repaint(false); | 1100 | sb->repaint(false); |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | else if(obj->inherits("QLineEdit")){ | 1104 | else if(obj->inherits("QLineEdit")){ |
1105 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ | 1105 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ |
1106 | QWidget *btn = (QComboBox *)obj->parent(); | 1106 | QWidget *btn = (QComboBox *)obj->parent(); |
1107 | if(ev->type() == QEvent::Enter){ | 1107 | if(ev->type() == QEvent::Enter){ |
1108 | if (btn->isEnabled()){ | 1108 | if (btn->isEnabled()){ |
1109 | highlightWidget = btn; | 1109 | highlightWidget = btn; |
1110 | btn->repaint(false); | 1110 | btn->repaint(false); |
1111 | } | 1111 | } |
1112 | } | 1112 | } |
1113 | else if(ev->type() == QEvent::Leave){ | 1113 | else if(ev->type() == QEvent::Leave){ |
1114 | if (btn == highlightWidget) | 1114 | if (btn == highlightWidget) |
1115 | highlightWidget = NULL; | 1115 | highlightWidget = NULL; |
1116 | btn->repaint(false); | 1116 | btn->repaint(false); |
1117 | } | 1117 | } |
1118 | } | 1118 | } |
1119 | } | 1119 | } |
1120 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ | 1120 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ |
1121 | QButton *btn = (QButton *)obj; | 1121 | QButton *btn = (QButton *)obj; |
1122 | bool isRadio = obj->inherits("QRadioButton"); | 1122 | bool isRadio = obj->inherits("QRadioButton"); |
1123 | if(ev->type() == QEvent::Paint){ | 1123 | if(ev->type() == QEvent::Paint){ |
1124 | //if(btn->autoMask()) | 1124 | //if(btn->autoMask()) |
1125 | btn->erase(); | 1125 | btn->erase(); |
1126 | QPainter p; | 1126 | QPainter p; |
1127 | p.begin(btn); | 1127 | p.begin(btn); |
1128 | QFontMetrics fm = btn->fontMetrics(); | 1128 | QFontMetrics fm = btn->fontMetrics(); |
1129 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1129 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1130 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1130 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1131 | : indicatorSize(); | 1131 | : indicatorSize(); |
1132 | 1132 | ||
1133 | if(btn->hasFocus()){ | 1133 | if(btn->hasFocus()){ |
1134 | QRect r = QRect(0, 0, btn->width(), btn->height()); | 1134 | QRect r = QRect(0, 0, btn->width(), btn->height()); |
1135 | p.setPen(btn->colorGroup().button().dark(140)); | 1135 | p.setPen(btn->colorGroup().button().dark(140)); |
1136 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1136 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1137 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1137 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1138 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1138 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1139 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1139 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1140 | } | 1140 | } |
1141 | int x = 0; | 1141 | int x = 0; |
1142 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1142 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1143 | if(isRadio) | 1143 | if(isRadio) |
1144 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1144 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1145 | btn->colorGroup(), btn->isOn(), | 1145 | btn->colorGroup(), btn->isOn(), |
1146 | btn->isDown(), btn->isEnabled()); | 1146 | btn->isDown(), btn->isEnabled()); |
1147 | else | 1147 | else |
1148 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1148 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1149 | btn->colorGroup(), btn->state(), btn->isDown(), | 1149 | btn->colorGroup(), btn->state(), btn->isDown(), |
1150 | btn->isEnabled()); | 1150 | btn->isEnabled()); |
1151 | x = sz.width() + 6; | 1151 | x = sz.width() + 6; |
1152 | y = 0; | 1152 | y = 0; |
1153 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), | 1153 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), |
1154 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, | 1154 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, |
1155 | btn->colorGroup(), btn->isEnabled(), | 1155 | btn->colorGroup(), btn->isEnabled(), |
1156 | btn->pixmap(), btn->text()); | 1156 | btn->pixmap(), btn->text()); |
1157 | p.end(); | 1157 | p.end(); |
1158 | return(true); | 1158 | return(true); |
1159 | } | 1159 | } |
1160 | // for hover, just redraw the indicator (not the text) | 1160 | // for hover, just redraw the indicator (not the text) |
1161 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || | 1161 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || |
1162 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ | 1162 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ |
1163 | QButton *btn = (QButton *)obj; | 1163 | QButton *btn = (QButton *)obj; |
1164 | bool isRadio = obj->inherits("QRadioButton"); | 1164 | bool isRadio = obj->inherits("QRadioButton"); |
1165 | 1165 | ||
1166 | if(ev->type() == QEvent::Enter) | 1166 | if(ev->type() == QEvent::Enter) |
1167 | highlightWidget = btn; | 1167 | highlightWidget = btn; |
1168 | else | 1168 | else |
1169 | highlightWidget = NULL; | 1169 | highlightWidget = NULL; |
1170 | QFontMetrics fm = btn->fontMetrics(); | 1170 | QFontMetrics fm = btn->fontMetrics(); |
1171 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1171 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1172 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1172 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1173 | : indicatorSize(); | 1173 | : indicatorSize(); |
1174 | int x = 0; | 1174 | int x = 0; |
1175 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1175 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1176 | //if(btn->autoMask()) | 1176 | //if(btn->autoMask()) |
1177 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); | 1177 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); |
1178 | QPainter p; | 1178 | QPainter p; |
1179 | p.begin(btn); | 1179 | p.begin(btn); |
1180 | if(isRadio) | 1180 | if(isRadio) |
1181 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1181 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1182 | btn->colorGroup(), btn->isOn(), | 1182 | btn->colorGroup(), btn->isOn(), |
1183 | btn->isDown(), btn->isEnabled()); | 1183 | btn->isDown(), btn->isEnabled()); |
1184 | else | 1184 | else |
1185 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1185 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1186 | btn->colorGroup(), btn->state(), btn->isDown(), | 1186 | btn->colorGroup(), btn->state(), btn->isDown(), |
1187 | btn->isEnabled()); | 1187 | btn->isEnabled()); |
1188 | p.end(); | 1188 | p.end(); |
1189 | } | 1189 | } |
1190 | } | 1190 | } |
1191 | else if(obj->inherits("QHeader")){ | 1191 | else if(obj->inherits("QHeader")){ |
1192 | QHeader *hw = (QHeader *)obj; | 1192 | QHeader *hw = (QHeader *)obj; |
1193 | if(ev->type() == QEvent::Enter){ | 1193 | if(ev->type() == QEvent::Enter){ |
1194 | currentHeader = hw; | 1194 | currentHeader = hw; |
1195 | headerHoverID = -1; | 1195 | headerHoverID = -1; |
1196 | } | 1196 | } |
1197 | else if(ev->type() == QEvent::Leave){ | 1197 | else if(ev->type() == QEvent::Leave){ |
1198 | currentHeader = NULL; | 1198 | currentHeader = NULL; |
1199 | if(headerHoverID != -1){ | 1199 | if(headerHoverID != -1){ |
1200 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1200 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1201 | hw->sectionSize(headerHoverID), hw->height()); | 1201 | hw->sectionSize(headerHoverID), hw->height()); |
1202 | } | 1202 | } |
1203 | headerHoverID = -1; | 1203 | headerHoverID = -1; |
1204 | } | 1204 | } |
1205 | else if(ev->type() == QEvent::MouseMove){ | 1205 | else if(ev->type() == QEvent::MouseMove){ |
1206 | QMouseEvent *me = (QMouseEvent *)ev; | 1206 | QMouseEvent *me = (QMouseEvent *)ev; |
1207 | int oldHeader = headerHoverID; | 1207 | int oldHeader = headerHoverID; |
1208 | headerHoverID = hw->sectionAt(me->x()); | 1208 | headerHoverID = hw->sectionAt(me->x()); |
1209 | if(oldHeader != headerHoverID){ | 1209 | if(oldHeader != headerHoverID){ |
1210 | // reset old header | 1210 | // reset old header |
1211 | if(oldHeader != -1){ | 1211 | if(oldHeader != -1){ |
1212 | hw->repaint(hw->sectionPos(oldHeader), 0, | 1212 | hw->repaint(hw->sectionPos(oldHeader), 0, |
1213 | hw->sectionSize(oldHeader), hw->height()); | 1213 | hw->sectionSize(oldHeader), hw->height()); |
1214 | } | 1214 | } |
1215 | if(headerHoverID != -1){ | 1215 | if(headerHoverID != -1){ |
1216 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1216 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1217 | hw->sectionSize(headerHoverID), hw->height()); | 1217 | hw->sectionSize(headerHoverID), hw->height()); |
1218 | } | 1218 | } |
1219 | } | 1219 | } |
1220 | } | 1220 | } |
1221 | } | 1221 | } |
1222 | return(false); | 1222 | return(false); |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 1225 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
1226 | const QColorGroup &g, bool sunken, | 1226 | const QColorGroup &g, bool sunken, |
1227 | const QBrush *) | 1227 | const QBrush *) |
1228 | { | 1228 | { |
1229 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), | 1229 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), |
1230 | x, y, w, h); | 1230 | x, y, w, h); |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | 1233 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, |
1234 | const QColorGroup &g, bool sunken, | 1234 | const QColorGroup &g, bool sunken, |
1235 | const QBrush *) | 1235 | const QBrush *) |
1236 | { | 1236 | { |
1237 | if(p->device()->devType() != QInternal::Widget){ | 1237 | if(p->device()->devType() != QInternal::Widget){ |
1238 | // drawing into a temp pixmap, don't use mask | 1238 | // drawing into a temp pixmap, don't use mask |
1239 | QColor c = sunken ? g.button() : g.background(); | 1239 | QColor c = sunken ? g.button() : g.background(); |
1240 | p->setPen(c.dark(130)); | 1240 | p->setPen(c.dark(130)); |
1241 | p->drawRect(x, y, w, h); | 1241 | p->drawRect(x, y, w, h); |
1242 | p->setPen(c.light(105)); | 1242 | p->setPen(c.light(105)); |
1243 | p->drawRect(x+1, y+1, w-2, h-2); | 1243 | p->drawRect(x+1, y+1, w-2, h-2); |
1244 | 1244 | ||
1245 | 1245 | ||
1246 | // fill | 1246 | // fill |
1247 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1247 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1248 | if(!pix){ | 1248 | if(!pix){ |
1249 | int h, s, v; | 1249 | int h, s, v; |
1250 | c.hsv(&h, &s, &v); | 1250 | c.hsv(&h, &s, &v); |
1251 | pix = new QPixmap(*bevelFillPix); | 1251 | pix = new QPixmap(*bevelFillPix); |
1252 | adjustHSV(*pix, h, s, v); | 1252 | adjustHSV(*pix, h, s, v); |
1253 | bevelFillDict.insert(c.rgb(), pix); | 1253 | bevelFillDict.insert(c.rgb(), pix); |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); | 1256 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); |
1257 | } | 1257 | } |
1258 | else{ | 1258 | else{ |
1259 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : | 1259 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : |
1260 | highlightWidget == p->device() ? g.button().light(110) : | 1260 | highlightWidget == p->device() ? g.button().light(110) : |
1261 | g.background(), g.background()); | 1261 | g.background(), g.background()); |
1262 | } | 1262 | } |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | 1265 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) |
1266 | { | 1266 | { |
1267 | QRect r = btn->rect(); | 1267 | QRect r = btn->rect(); |
1268 | bool sunken = btn->isOn() || btn->isDown(); | 1268 | bool sunken = btn->isOn() || btn->isDown(); |
1269 | QColorGroup g = btn->colorGroup(); | 1269 | QColorGroup g = btn->colorGroup(); |
1270 | 1270 | ||
1271 | 1271 | ||
1272 | //int dw = buttonDefaultIndicatorWidth(); | 1272 | //int dw = buttonDefaultIndicatorWidth(); |
1273 | if(btn->hasFocus() || btn->isDefault()){ | 1273 | if(btn->hasFocus() || btn->isDefault()){ |
1274 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); | 1274 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); |
1275 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1275 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1276 | if(!pix){ | 1276 | if(!pix){ |
1277 | int h, s, v; | 1277 | int h, s, v; |
1278 | c.hsv(&h, &s, &v); | 1278 | c.hsv(&h, &s, &v); |
1279 | pix = new QPixmap(*bevelFillPix); | 1279 | pix = new QPixmap(*bevelFillPix); |
1280 | adjustHSV(*pix, h, s, v); | 1280 | adjustHSV(*pix, h, s, v); |
1281 | bevelFillDict.insert(c.rgb(), pix); | 1281 | bevelFillDict.insert(c.rgb(), pix); |
1282 | } | 1282 | } |
1283 | p->setPen(c.dark(150)); | 1283 | p->setPen(c.dark(150)); |
1284 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1284 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1285 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1285 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1286 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1286 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1287 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1287 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1288 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1288 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | QColor newColor = btn == highlightWidget || sunken ? | 1291 | QColor newColor = btn == highlightWidget || sunken ? |
1292 | g.button().light(120) : g.button(); | 1292 | g.button().light(120) : g.button(); |
1293 | 1293 | ||
1294 | drawRoundButton(p, newColor, g.background(), | 1294 | drawRoundButton(p, newColor, g.background(), |
1295 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), | 1295 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), |
1296 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), | 1296 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), |
1297 | btn->autoMask()); | 1297 | btn->autoMask()); |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) | 1300 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) |
1301 | { | 1301 | { |
1302 | int x1, y1, x2, y2, w, h; | 1302 | int x1, y1, x2, y2, w, h; |
1303 | btn->rect().coords(&x1, &y1, &x2, &y2); | 1303 | btn->rect().coords(&x1, &y1, &x2, &y2); |
1304 | w = btn->width(); | 1304 | w = btn->width(); |
1305 | h = btn->height(); | 1305 | h = btn->height(); |
1306 | 1306 | ||
1307 | bool act = btn->isOn() || btn->isDown(); | 1307 | bool act = btn->isOn() || btn->isDown(); |
1308 | if(act){ | 1308 | if(act){ |
1309 | ++x1, ++y1; | 1309 | ++x1, ++y1; |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | // Draw iconset first, if any | 1312 | // Draw iconset first, if any |
1313 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) | 1313 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) |
1314 | { | 1314 | { |
1315 | QIconSet::Mode mode = btn->isEnabled() | 1315 | QIconSet::Mode mode = btn->isEnabled() |
1316 | ? QIconSet::Normal : QIconSet::Disabled; | 1316 | ? QIconSet::Normal : QIconSet::Disabled; |
1317 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 1317 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
1318 | mode = QIconSet::Active; | 1318 | mode = QIconSet::Active; |
1319 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); | 1319 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); |
1320 | int pixw = pixmap.width(); | 1320 | int pixw = pixmap.width(); |
1321 | int pixh = pixmap.height(); | 1321 | int pixh = pixmap.height(); |
1322 | 1322 | ||
1323 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); | 1323 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); |
1324 | x1 += pixw + 8; | 1324 | x1 += pixw + 8; |
1325 | w -= pixw + 8; | 1325 | w -= pixw + 8; |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | if(act){ | 1328 | if(act){ |
1329 | QFont font = btn->font(); | 1329 | QFont font = btn->font(); |
1330 | font.setBold(true); | 1330 | font.setBold(true); |
1331 | p->setFont(font); | 1331 | p->setFont(font); |
1332 | QColor shadow(btn->colorGroup().button().dark(130)); | 1332 | QColor shadow(btn->colorGroup().button().dark(130)); |
1333 | drawItem( p, x1+1, y1+1, w, h, | 1333 | drawItem( p, x1+1, y1+1, w, h, |
1334 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1334 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1335 | btn->pixmap(), btn->text(), -1, | 1335 | btn->pixmap(), btn->text(), -1, |
1336 | &shadow); | 1336 | &shadow); |
1337 | 1337 | ||
1338 | drawItem( p, x1, y1, w, h, | 1338 | drawItem( p, x1, y1, w, h, |
1339 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1339 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1340 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); | 1340 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); |
1341 | } | 1341 | } |
1342 | else{ | 1342 | else{ |
1343 | /* Too blurry | 1343 | /* Too blurry |
1344 | drawItem( p, x1+1, y1+1, w, h, | 1344 | drawItem( p, x1+1, y1+1, w, h, |
1345 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1345 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1346 | btn->pixmap(), btn->text(), -1, | 1346 | btn->pixmap(), btn->text(), -1, |
1347 | &btn->colorGroup().button().dark(115)); | 1347 | &btn->colorGroup().button().dark(115)); |
1348 | */ | 1348 | */ |
1349 | drawItem( p, x1, y1, w, h, | 1349 | drawItem( p, x1, y1, w, h, |
1350 | AlignCenter | ShowPrefix, | 1350 | AlignCenter | ShowPrefix, |
1351 | btn->colorGroup(), btn->isEnabled(), | 1351 | btn->colorGroup(), btn->isEnabled(), |
1352 | btn->pixmap(), btn->text(), -1, | 1352 | btn->pixmap(), btn->text(), -1, |
1353 | &btn->colorGroup().buttonText()); | 1353 | &btn->colorGroup().buttonText()); |
1354 | } | 1354 | } |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) | 1357 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) |
1358 | { | 1358 | { |
1359 | int x2 = x+w-1; | 1359 | int x2 = x+w-1; |
1360 | int y2 = y+h-1; | 1360 | int y2 = y+h-1; |
diff --git a/noncore/styles/liquid/plugin.cpp b/noncore/styles/liquid/plugin.cpp index f149c29..5f4c8e5 100644 --- a/noncore/styles/liquid/plugin.cpp +++ b/noncore/styles/liquid/plugin.cpp | |||
@@ -1,111 +1,113 @@ | |||
1 | #include "liquid.h" | 1 | #include "liquid.h" |
2 | #include "liquidset.h" | 2 | #include "liquidset.h" |
3 | #include "plugin.h" | 3 | #include "plugin.h" |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | LiquidInterface::LiquidInterface ( ) : ref ( 0 ) | 7 | LiquidInterface::LiquidInterface ( ) : ref ( 0 ) |
8 | { | 8 | { |
9 | } | 9 | } |
10 | 10 | ||
11 | LiquidInterface::~LiquidInterface ( ) | 11 | LiquidInterface::~LiquidInterface ( ) |
12 | { | 12 | { |
13 | } | 13 | } |
14 | 14 | ||
15 | QStyle *LiquidInterface::create ( ) | 15 | QStyle *LiquidInterface::create ( ) |
16 | { | 16 | { |
17 | return new LiquidStyle ( ); | 17 | return new LiquidStyle ( ); |
18 | } | 18 | } |
19 | 19 | ||
20 | QString LiquidInterface::name ( ) | 20 | QString LiquidInterface::name ( ) |
21 | { | 21 | { |
22 | return QObject::tr( "Liquid", "name" ); | 22 | return QObject::tr( "Liquid", "name" ); |
23 | } | 23 | } |
24 | 24 | ||
25 | QString LiquidInterface::description ( ) | 25 | QString LiquidInterface::description ( ) |
26 | { | 26 | { |
27 | return QObject::tr( "High Performance Liquid style by Mosfet", "description" ); | 27 | return QObject::tr( "High Performance Liquid style by Mosfet", "description" ); |
28 | } | 28 | } |
29 | 29 | ||
30 | QCString LiquidInterface::key ( ) | 30 | QCString LiquidInterface::key ( ) |
31 | { | 31 | { |
32 | return QCString ( "liquid" ); | 32 | return QCString ( "liquid" ); |
33 | } | 33 | } |
34 | 34 | ||
35 | unsigned int LiquidInterface::version ( ) | 35 | unsigned int LiquidInterface::version ( ) |
36 | { | 36 | { |
37 | return 100; // 1.0.0 (\d+.\d.\d) | 37 | return 100; // 1.0.0 (\d+.\d.\d) |
38 | } | 38 | } |
39 | 39 | ||
40 | QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 40 | QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
41 | { | 41 | { |
42 | static LiquidSettingsInterface *setiface = 0; | 42 | static LiquidSettingsInterface *setiface = 0; |
43 | 43 | ||
44 | *iface = 0; | 44 | *iface = 0; |
45 | 45 | ||
46 | if ( uuid == IID_QUnknown ) | 46 | if ( uuid == IID_QUnknown ) |
47 | *iface = this; | 47 | *iface = this; |
48 | else if ( uuid == IID_Style ) | 48 | else if ( uuid == IID_Style ) |
49 | *iface = this; | 49 | *iface = this; |
50 | else if ( uuid == IID_StyleSettings ) { | 50 | else if ( uuid == IID_StyleSettings ) { |
51 | if ( !setiface ) | 51 | if ( !setiface ) |
52 | setiface = new LiquidSettingsInterface ( ); | 52 | setiface = new LiquidSettingsInterface ( ); |
53 | *iface = setiface; | 53 | *iface = setiface; |
54 | } | 54 | } |
55 | 55 | ||
56 | if ( *iface ) | 56 | if ( *iface ) |
57 | (*iface)-> addRef ( ); | 57 | (*iface)-> addRef ( ); |
58 | 58 | ||
59 | return QS_OK; | 59 | return QS_OK; |
60 | } | 60 | } |
61 | 61 | ||
62 | Q_EXPORT_INTERFACE() | 62 | Q_EXPORT_INTERFACE() |
63 | { | 63 | { |
64 | Q_CREATE_INSTANCE( LiquidInterface ) | 64 | Q_CREATE_INSTANCE( LiquidInterface ) |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | LiquidSettingsInterface::LiquidSettingsInterface ( ) : ref ( 0 ) | 68 | LiquidSettingsInterface::LiquidSettingsInterface ( ) : ref ( 0 ) |
69 | { | 69 | { |
70 | m_widget = 0; | 70 | m_widget = 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | LiquidSettingsInterface::~LiquidSettingsInterface ( ) | 73 | LiquidSettingsInterface::~LiquidSettingsInterface ( ) |
74 | { | 74 | { |
75 | } | 75 | } |
76 | 76 | ||
77 | QWidget *LiquidSettingsInterface::create ( QWidget *parent, const char *name ) | 77 | QWidget *LiquidSettingsInterface::create ( QWidget *parent, const char *name ) |
78 | { | 78 | { |
79 | m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); | 79 | m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); |
80 | 80 | ||
81 | return m_widget; | 81 | return m_widget; |
82 | } | 82 | } |
83 | 83 | ||
84 | bool LiquidSettingsInterface::accept ( ) | 84 | bool LiquidSettingsInterface::accept ( ) |
85 | { | 85 | { |
86 | if ( !m_widget ) | 86 | if ( !m_widget ) |
87 | return false; | 87 | return false; |
88 | 88 | ||
89 | return m_widget-> writeConfig ( ); | 89 | return m_widget-> writeConfig ( ); |
90 | } | 90 | } |
91 | 91 | ||
92 | void LiquidSettingsInterface::reject ( ) | 92 | void LiquidSettingsInterface::reject ( ) |
93 | { | 93 | { |
94 | } | 94 | } |
95 | 95 | ||
96 | QRESULT LiquidSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 96 | QRESULT LiquidSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
97 | { | 97 | { |
98 | *iface = 0; | 98 | *iface = 0; |
99 | 99 | ||
100 | 100 | ||
101 | if ( uuid == IID_QUnknown ) | 101 | if ( uuid == IID_QUnknown ) |
102 | *iface = this; | 102 | *iface = this; |
103 | else if ( uuid == IID_StyleSettings ) | 103 | else if ( uuid == IID_StyleSettings ) |
104 | *iface = this; | 104 | *iface = this; |
105 | 105 | ||
106 | if ( *iface ) | 106 | if ( *iface ) |
107 | (*iface)-> addRef ( ); | 107 | (*iface)-> addRef ( ); |
108 | 108 | ||
109 | return QS_OK; | 109 | return QS_OK; |
110 | } | 110 | } |
111 | 111 | ||
112 | // Hack for Retail Z experiments | ||
113 | extern "C" { QStyle *allocate ( ) { return new LiquidStyle ( ); } } | ||