-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,408 +1,407 @@ | |||
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()); |
@@ -592,513 +591,514 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item) | |||
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")){ |
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 ( ); } } | ||