author | sandman <sandman> | 2002-10-24 01:21:24 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-24 01:21:24 (UTC) |
commit | f09549e37fee6decd56168043209e8051b8757fb (patch) (unidiff) | |
tree | cfcfc40bfca40df380489829ab5b88cff91d1fee | |
parent | 36e13db0a1d44abd5a160a34e4679b90d62826c7 (diff) | |
download | opie-f09549e37fee6decd56168043209e8051b8757fb.zip opie-f09549e37fee6decd56168043209e8051b8757fb.tar.gz opie-f09549e37fee6decd56168043209e8051b8757fb.tar.bz2 |
- "what's this" widget drop shadows are drawn correctly now
- updated the QPL diff
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 8 | ||||
-rw-r--r-- | noncore/styles/liquid/opie-liquid.diff | 389 |
2 files changed, 237 insertions, 160 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index eb1ec6e..6812d16 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -1,2817 +1,2821 @@ | |||
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 | #include <qprogressbar.h> | 33 | #include <qprogressbar.h> |
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 | pixDict.insert(p->winId(), pix); | 128 | pixDict.insert(p->winId(), pix); |
129 | 129 | ||
130 | if ( !p->inherits("QPopupMenu")) | 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 | else if(ev->type() == QEvent::Hide){ | 143 | else if(ev->type() == QEvent::Hide){ |
144 | if(type == TransStippleBg || type == TransStippleBtn || | 144 | if(type == TransStippleBg || type == TransStippleBtn || |
145 | type == Custom){ | 145 | type == Custom){ |
146 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); | 146 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); |
147 | 147 | ||
148 | pixDict.remove(p->winId()); | 148 | pixDict.remove(p->winId()); |
149 | if ( !p->inherits("QPopupMenu")) | 149 | if ( !p->inherits("QPopupMenu")) |
150 | p->setBackgroundMode(QWidget::PaletteBackground); | 150 | p->setBackgroundMode(QWidget::PaletteBackground); |
151 | 151 | ||
152 | QObjectList *ol = p-> queryList("QWidget"); | 152 | QObjectList *ol = p-> queryList("QWidget"); |
153 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 153 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
154 | QWidget *wid = (QWidget *) it.current ( ); | 154 | QWidget *wid = (QWidget *) it.current ( ); |
155 | 155 | ||
156 | wid-> setBackgroundMode( QWidget::PaletteBackground ); | 156 | wid-> setBackgroundMode( QWidget::PaletteBackground ); |
157 | } | 157 | } |
158 | delete ol; | 158 | delete ol; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | return(false); | 161 | return(false); |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | LiquidStyle::LiquidStyle() | 165 | LiquidStyle::LiquidStyle() |
166 | :QWindowsStyle() | 166 | :QWindowsStyle() |
167 | { | 167 | { |
168 | setName ( "LiquidStyle" ); | 168 | setName ( "LiquidStyle" ); |
169 | 169 | ||
170 | flatTBButtons = false; | 170 | flatTBButtons = false; |
171 | 171 | ||
172 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 172 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
173 | btnMaskBmp.setMask(btnMaskBmp); | 173 | btnMaskBmp.setMask(btnMaskBmp); |
174 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 174 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
175 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); | 175 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); |
176 | headerHoverID = -1; | 176 | headerHoverID = -1; |
177 | highlightWidget = NULL; | 177 | highlightWidget = NULL; |
178 | setButtonDefaultIndicatorWidth(0); | 178 | setButtonDefaultIndicatorWidth(0); |
179 | btnDict.setAutoDelete(true); | 179 | btnDict.setAutoDelete(true); |
180 | bevelFillDict.setAutoDelete(true); | 180 | bevelFillDict.setAutoDelete(true); |
181 | smallBevelFillDict.setAutoDelete(true); | 181 | smallBevelFillDict.setAutoDelete(true); |
182 | customBtnColorList.setAutoDelete(true); | 182 | customBtnColorList.setAutoDelete(true); |
183 | customBtnIconList.setAutoDelete(true); | 183 | customBtnIconList.setAutoDelete(true); |
184 | customBtnLabelList.setAutoDelete(true); | 184 | customBtnLabelList.setAutoDelete(true); |
185 | 185 | ||
186 | rMatrix.rotate(270.0); | 186 | rMatrix.rotate(270.0); |
187 | highcolor = QPixmap::defaultDepth() > 8; | 187 | highcolor = QPixmap::defaultDepth() > 8; |
188 | btnBorderPix = new QPixmap; | 188 | btnBorderPix = new QPixmap; |
189 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); | 189 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); |
190 | btnBlendPix = new QPixmap; | 190 | btnBlendPix = new QPixmap; |
191 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); | 191 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); |
192 | bevelFillPix = new QPixmap; | 192 | bevelFillPix = new QPixmap; |
193 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); | 193 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); |
194 | smallBevelFillPix = new QPixmap; | 194 | smallBevelFillPix = new QPixmap; |
195 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); | 195 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); |
196 | // new stuff | 196 | // new stuff |
197 | vsbSliderFillPix = menuPix = NULL; | 197 | vsbSliderFillPix = menuPix = NULL; |
198 | menuHandler = new TransMenuHandler(this); | 198 | menuHandler = new TransMenuHandler(this); |
199 | setScrollBarExtent(15, 15); | 199 | setScrollBarExtent(15, 15); |
200 | int i; | 200 | int i; |
201 | for(i=0; i < BITMAP_ITEMS; ++i){ | 201 | for(i=0; i < BITMAP_ITEMS; ++i){ |
202 | pixmaps[i] = NULL; | 202 | pixmaps[i] = NULL; |
203 | } | 203 | } |
204 | oldSliderThickness = sliderThickness(); | 204 | oldSliderThickness = sliderThickness(); |
205 | setSliderThickness(11); | 205 | setSliderThickness(11); |
206 | } | 206 | } |
207 | 207 | ||
208 | LiquidStyle::~LiquidStyle() | 208 | LiquidStyle::~LiquidStyle() |
209 | { | 209 | { |
210 | if(btnBorderPix) | 210 | if(btnBorderPix) |
211 | delete btnBorderPix; | 211 | delete btnBorderPix; |
212 | if(btnBlendPix) | 212 | if(btnBlendPix) |
213 | delete btnBlendPix; | 213 | delete btnBlendPix; |
214 | if(bevelFillPix) | 214 | if(bevelFillPix) |
215 | delete bevelFillPix; | 215 | delete bevelFillPix; |
216 | if(smallBevelFillPix) | 216 | if(smallBevelFillPix) |
217 | delete smallBevelFillPix; | 217 | delete smallBevelFillPix; |
218 | if(vsbSliderFillPix) | 218 | if(vsbSliderFillPix) |
219 | delete vsbSliderFillPix; | 219 | delete vsbSliderFillPix; |
220 | if(menuPix) | 220 | if(menuPix) |
221 | delete menuPix; | 221 | delete menuPix; |
222 | 222 | ||
223 | setScrollBarExtent(16, 16); | 223 | setScrollBarExtent(16, 16); |
224 | setSliderThickness(oldSliderThickness); | 224 | setSliderThickness(oldSliderThickness); |
225 | int i; | 225 | int i; |
226 | for(i=0; i < BITMAP_ITEMS; ++i){ | 226 | for(i=0; i < BITMAP_ITEMS; ++i){ |
227 | if(pixmaps[i]) | 227 | if(pixmaps[i]) |
228 | delete pixmaps[i]; | 228 | delete pixmaps[i]; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | 231 | ||
232 | 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, |
233 | const QColor &c, const QColor &bg) | 233 | const QColor &c, const QColor &bg) |
234 | { | 234 | { |
235 | 235 | ||
236 | QPen oldPen = p->pen(); // headers need this | 236 | QPen oldPen = p->pen(); // headers need this |
237 | int x2 = x+w-1; | 237 | int x2 = x+w-1; |
238 | int y2 = y+h-1; | 238 | int y2 = y+h-1; |
239 | // outer dark rect | 239 | // outer dark rect |
240 | p->setPen(c.dark(130)); | 240 | p->setPen(c.dark(130)); |
241 | p->drawLine(x, y+2, x, y2-2); // l | 241 | p->drawLine(x, y+2, x, y2-2); // l |
242 | p->drawLine(x2, y+2, x2, y2-2); // r | 242 | p->drawLine(x2, y+2, x2, y2-2); // r |
243 | p->drawLine(x+2, y, x2-2, y); // t | 243 | p->drawLine(x+2, y, x2-2, y); // t |
244 | p->drawLine(x+2, y2, x2-2, y2); // b | 244 | p->drawLine(x+2, y2, x2-2, y2); // b |
245 | p->drawPoint(x+1, y+1); // tl | 245 | p->drawPoint(x+1, y+1); // tl |
246 | p->drawPoint(x2-1, y+1); // tr | 246 | p->drawPoint(x2-1, y+1); // tr |
247 | p->drawPoint(x+1, y2-1); // bl | 247 | p->drawPoint(x+1, y2-1); // bl |
248 | p->drawPoint(x2-1, y2-1); // br | 248 | p->drawPoint(x2-1, y2-1); // br |
249 | 249 | ||
250 | // inner top light lines | 250 | // inner top light lines |
251 | p->setPen(c.light(105)); | 251 | p->setPen(c.light(105)); |
252 | p->drawLine(x+2, y+1, x2-2, y+1); | 252 | p->drawLine(x+2, y+1, x2-2, y+1); |
253 | p->drawLine(x+1, y+2, x2-1, y+2); | 253 | p->drawLine(x+1, y+2, x2-1, y+2); |
254 | p->drawLine(x+1, y+3, x+2, y+3); | 254 | p->drawLine(x+1, y+3, x+2, y+3); |
255 | p->drawLine(x2-2, y+3, x2-1, y+3); | 255 | p->drawLine(x2-2, y+3, x2-1, y+3); |
256 | p->drawPoint(x+1, y+4); | 256 | p->drawPoint(x+1, y+4); |
257 | p->drawPoint(x2-1, y+4); | 257 | p->drawPoint(x2-1, y+4); |
258 | 258 | ||
259 | // inner bottom light lines | 259 | // inner bottom light lines |
260 | p->setPen(c.light(110)); | 260 | p->setPen(c.light(110)); |
261 | p->drawLine(x+2, y2-1, x2-2, y2-1); | 261 | p->drawLine(x+2, y2-1, x2-2, y2-1); |
262 | p->drawLine(x+1, y2-2, x2-1, y2-2); | 262 | p->drawLine(x+1, y2-2, x2-1, y2-2); |
263 | p->drawLine(x+1, y2-3, x+2, y2-3); | 263 | p->drawLine(x+1, y2-3, x+2, y2-3); |
264 | p->drawLine(x2-2, y2-3, x2-1, y2-3); | 264 | p->drawLine(x2-2, y2-3, x2-1, y2-3); |
265 | p->drawPoint(x+1, y2-4); | 265 | p->drawPoint(x+1, y2-4); |
266 | p->drawPoint(x2-1, y2-4); | 266 | p->drawPoint(x2-1, y2-4); |
267 | 267 | ||
268 | // inner left mid lines | 268 | // inner left mid lines |
269 | //p->setPen(c.light(105)); | 269 | //p->setPen(c.light(105)); |
270 | p->setPen(c); | 270 | p->setPen(c); |
271 | p->drawLine(x+1, y+5, x+1, y2-5); | 271 | p->drawLine(x+1, y+5, x+1, y2-5); |
272 | p->drawLine(x+2, y+4, x+2, y2-4); | 272 | p->drawLine(x+2, y+4, x+2, y2-4); |
273 | 273 | ||
274 | // inner right mid lines | 274 | // inner right mid lines |
275 | p->drawLine(x2-1, y+5, x2-1, y2-5); | 275 | p->drawLine(x2-1, y+5, x2-1, y2-5); |
276 | p->drawLine(x2-2, y+4, x2-2, y2-4); | 276 | p->drawLine(x2-2, y+4, x2-2, y2-4); |
277 | 277 | ||
278 | // fill | 278 | // fill |
279 | QPixmap *pix; | 279 | QPixmap *pix; |
280 | if(h >= 32){ | 280 | if(h >= 32){ |
281 | pix = bevelFillDict.find(c.rgb()); | 281 | pix = bevelFillDict.find(c.rgb()); |
282 | if(!pix){ | 282 | if(!pix){ |
283 | int h, s, v; | 283 | int h, s, v; |
284 | c.hsv(&h, &s, &v); | 284 | c.hsv(&h, &s, &v); |
285 | pix = new QPixmap(*bevelFillPix); | 285 | pix = new QPixmap(*bevelFillPix); |
286 | adjustHSV(*pix, h, s, v); | 286 | adjustHSV(*pix, h, s, v); |
287 | bevelFillDict.insert(c.rgb(), pix); | 287 | bevelFillDict.insert(c.rgb(), pix); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | else{ | 290 | else{ |
291 | pix = smallBevelFillDict.find(c.rgb()); | 291 | pix = smallBevelFillDict.find(c.rgb()); |
292 | if(!pix){ | 292 | if(!pix){ |
293 | int h, s, v; | 293 | int h, s, v; |
294 | c.hsv(&h, &s, &v); | 294 | c.hsv(&h, &s, &v); |
295 | pix = new QPixmap(*smallBevelFillPix); | 295 | pix = new QPixmap(*smallBevelFillPix); |
296 | adjustHSV(*pix, h, s, v); | 296 | adjustHSV(*pix, h, s, v); |
297 | smallBevelFillDict.insert(c.rgb(), pix); | 297 | smallBevelFillDict.insert(c.rgb(), pix); |
298 | } | 298 | } |
299 | } | 299 | } |
300 | p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); | 300 | p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix); |
301 | // blend | 301 | // blend |
302 | int red, green, blue; | 302 | int red, green, blue; |
303 | QColor btnColor(c.dark(130)); | 303 | QColor btnColor(c.dark(130)); |
304 | red = (btnColor.red() >> 1) + (bg.red() >> 1); | 304 | red = (btnColor.red() >> 1) + (bg.red() >> 1); |
305 | green = (btnColor.green() >> 1) + (bg.green() >> 1); | 305 | green = (btnColor.green() >> 1) + (bg.green() >> 1); |
306 | blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); | 306 | blue = (btnColor.blue() >> 1) + (bg.blue() >> 1); |
307 | btnColor.setRgb(red, green, blue); | 307 | btnColor.setRgb(red, green, blue); |
308 | 308 | ||
309 | p->setPen(btnColor); | 309 | p->setPen(btnColor); |
310 | p->drawPoint(x+1, y); | 310 | p->drawPoint(x+1, y); |
311 | p->drawPoint(x, y+1); | 311 | p->drawPoint(x, y+1); |
312 | p->drawPoint(x+1, y2); | 312 | p->drawPoint(x+1, y2); |
313 | p->drawPoint(x, y2-1); | 313 | p->drawPoint(x, y2-1); |
314 | 314 | ||
315 | p->drawPoint(x2-1, y); | 315 | p->drawPoint(x2-1, y); |
316 | p->drawPoint(x2, y+1); | 316 | p->drawPoint(x2, y+1); |
317 | p->drawPoint(x2-1, y2); | 317 | p->drawPoint(x2-1, y2); |
318 | p->drawPoint(x2, y2-1); | 318 | p->drawPoint(x2, y2-1); |
319 | 319 | ||
320 | p->setPen(oldPen); | 320 | p->setPen(oldPen); |
321 | 321 | ||
322 | } | 322 | } |
323 | 323 | ||
324 | void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, | 324 | void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c, |
325 | const QColor &back, int x, int y, int w, int h, | 325 | const QColor &back, int x, int y, int w, int h, |
326 | bool supportPushDown, bool pushedDown, | 326 | bool supportPushDown, bool pushedDown, |
327 | bool autoDefault, bool isMasked) | 327 | bool autoDefault, bool isMasked) |
328 | { | 328 | { |
329 | if(w < 21 || h < 21){ | 329 | if(w < 21 || h < 21){ |
330 | drawClearBevel(painter, x, y, w, h, c, back); | 330 | drawClearBevel(painter, x, y, w, h, c, back); |
331 | return; | 331 | return; |
332 | } | 332 | } |
333 | if(supportPushDown){ | 333 | if(supportPushDown){ |
334 | --w, --h; | 334 | --w, --h; |
335 | } | 335 | } |
336 | /* 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 |
337 | if(autoDefault){ | 337 | if(autoDefault){ |
338 | w = w-buttonDefaultIndicatorWidth()*2; | 338 | w = w-buttonDefaultIndicatorWidth()*2; |
339 | h = h-buttonDefaultIndicatorWidth()*2; | 339 | h = h-buttonDefaultIndicatorWidth()*2; |
340 | }*/ | 340 | }*/ |
341 | 341 | ||
342 | 342 | ||
343 | QPixmap *pix = btnDict.find(c.rgb()); | 343 | QPixmap *pix = btnDict.find(c.rgb()); |
344 | if(!pix){ | 344 | if(!pix){ |
345 | int h, s, v; | 345 | int h, s, v; |
346 | c.hsv(&h, &s, &v); | 346 | c.hsv(&h, &s, &v); |
347 | pix = new QPixmap(*btnBorderPix); | 347 | pix = new QPixmap(*btnBorderPix); |
348 | adjustHSV(*pix, h, s, v); | 348 | adjustHSV(*pix, h, s, v); |
349 | btnDict.insert(c.rgb(), pix); | 349 | btnDict.insert(c.rgb(), pix); |
350 | } | 350 | } |
351 | int x2 = x+w-1; | 351 | int x2 = x+w-1; |
352 | int y2 = y+h-1; | 352 | int y2 = y+h-1; |
353 | int bx2 = pix->width()-1; | 353 | int bx2 = pix->width()-1; |
354 | int by2 = pix->height()-1; | 354 | int by2 = pix->height()-1; |
355 | 355 | ||
356 | QPixmap tmpPix(w, h); | 356 | QPixmap tmpPix(w, h); |
357 | QPixmap tilePix; | 357 | QPixmap tilePix; |
358 | QPainter p; | 358 | QPainter p; |
359 | p.begin(&tmpPix); | 359 | p.begin(&tmpPix); |
360 | 360 | ||
361 | // do the fill | 361 | // do the fill |
362 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl | 362 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl |
363 | 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 |
364 | 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 |
365 | 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 |
366 | 366 | ||
367 | // edges | 367 | // edges |
368 | tilePix.resize(pix->width()-20, 10); | 368 | tilePix.resize(pix->width()-20, 10); |
369 | // top | 369 | // top |
370 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); | 370 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); |
371 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); | 371 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); |
372 | // bottom | 372 | // bottom |
373 | 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); |
374 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); | 374 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); |
375 | // left | 375 | // left |
376 | tilePix.resize(10, pix->height()-20); | 376 | tilePix.resize(10, pix->height()-20); |
377 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); | 377 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); |
378 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); | 378 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); |
379 | // right | 379 | // right |
380 | 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); |
381 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); | 381 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); |
382 | 382 | ||
383 | // middle | 383 | // middle |
384 | tilePix.resize(pix->width()-20, pix->height()-20); | 384 | tilePix.resize(pix->width()-20, pix->height()-20); |
385 | 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); |
386 | p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); | 386 | p.drawTiledPixmap(10, 10, w-20, h-20, tilePix); |
387 | 387 | ||
388 | 388 | ||
389 | // do the blend | 389 | // do the blend |
390 | QBitmap blendMask; | 390 | QBitmap blendMask; |
391 | if(!isMasked){ | 391 | if(!isMasked){ |
392 | //QRgb bgRgb = back.rgb(); | 392 | //QRgb bgRgb = back.rgb(); |
393 | //QRgb fgRgb = c.rgb(); | 393 | //QRgb fgRgb = c.rgb(); |
394 | //int r, g, b; | 394 | //int r, g, b; |
395 | 395 | ||
396 | //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); | 396 | //r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25); |
397 | //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); | 397 | //g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25); |
398 | //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); | 398 | //b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25); |
399 | //QColor blendColor(r, g, b); | 399 | //QColor blendColor(r, g, b); |
400 | int hue, sat, v1, v2; | 400 | int hue, sat, v1, v2; |
401 | QColor blendColor(autoDefault ? c : back); | 401 | QColor blendColor(autoDefault ? c : back); |
402 | back.hsv(&hue, &sat, &v1); | 402 | back.hsv(&hue, &sat, &v1); |
403 | blendColor.hsv(&hue, &sat, &v2); | 403 | blendColor.hsv(&hue, &sat, &v2); |
404 | if(v2 > v1) | 404 | if(v2 > v1) |
405 | blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); | 405 | blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25)); |
406 | 406 | ||
407 | pix = btnBorderDict.find(blendColor.rgb()); | 407 | pix = btnBorderDict.find(blendColor.rgb()); |
408 | if(!pix){ | 408 | if(!pix){ |
409 | int h, s, v; | 409 | int h, s, v; |
410 | blendColor.hsv(&h, &s, &v); | 410 | blendColor.hsv(&h, &s, &v); |
411 | pix = new QPixmap(*btnBlendPix); | 411 | pix = new QPixmap(*btnBlendPix); |
412 | adjustHSV(*pix, h, s, v); | 412 | adjustHSV(*pix, h, s, v); |
413 | btnBorderDict.insert(blendColor.rgb(), pix); | 413 | btnBorderDict.insert(blendColor.rgb(), pix); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | else{ | 416 | else{ |
417 | pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : | 417 | pix = pushedDown ? getPixmap(HTMLBtnBorderDown) : |
418 | getPixmap(HTMLBtnBorder); | 418 | getPixmap(HTMLBtnBorder); |
419 | } | 419 | } |
420 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl | 420 | p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl |
421 | 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 |
422 | 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 |
423 | 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 |
424 | 424 | ||
425 | // edges | 425 | // edges |
426 | tilePix.resize(pix->width()-20, 10); | 426 | tilePix.resize(pix->width()-20, 10); |
427 | blendMask.resize(pix->width()-20, 10); | 427 | blendMask.resize(pix->width()-20, 10); |
428 | // top | 428 | // top |
429 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); | 429 | bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10); |
430 | 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); |
431 | tilePix.setMask(blendMask); | 431 | tilePix.setMask(blendMask); |
432 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); | 432 | p.drawTiledPixmap(10, 0, w-20, 10, tilePix); |
433 | // bottom | 433 | // bottom |
434 | 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); |
435 | 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); |
436 | tilePix.setMask(blendMask); | 436 | tilePix.setMask(blendMask); |
437 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); | 437 | p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix); |
438 | // left | 438 | // left |
439 | tilePix.resize(10, pix->height()-20); | 439 | tilePix.resize(10, pix->height()-20); |
440 | blendMask.resize(10, pix->height()-20); | 440 | blendMask.resize(10, pix->height()-20); |
441 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); | 441 | bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20); |
442 | 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); |
443 | tilePix.setMask(blendMask); | 443 | tilePix.setMask(blendMask); |
444 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); | 444 | p.drawTiledPixmap(0, 10, 10, h-20, tilePix); |
445 | // right | 445 | // right |
446 | 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); |
447 | 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); |
448 | tilePix.setMask(blendMask); | 448 | tilePix.setMask(blendMask); |
449 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); | 449 | p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix); |
450 | 450 | ||
451 | p.end(); | 451 | p.end(); |
452 | 452 | ||
453 | // do the button mask - we don't automask buttons | 453 | // do the button mask - we don't automask buttons |
454 | QBitmap btnMask(w, h); | 454 | QBitmap btnMask(w, h); |
455 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; | 455 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; |
456 | p.begin(&btnMask); | 456 | p.begin(&btnMask); |
457 | p.fillRect(0, 0, w, h, Qt::color0); | 457 | p.fillRect(0, 0, w, h, Qt::color0); |
458 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl | 458 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl |
459 | 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 |
460 | 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 |
461 | 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 |
462 | // fills | 462 | // fills |
463 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top | 463 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top |
464 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 464 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
465 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle | 465 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle |
466 | p.end(); | 466 | p.end(); |
467 | tmpPix.setMask(btnMask); | 467 | tmpPix.setMask(btnMask); |
468 | /*if(autoDefault){ | 468 | /*if(autoDefault){ |
469 | if(supportPushDown && pushedDown){ | 469 | if(supportPushDown && pushedDown){ |
470 | painter->drawPixmap(x+3, y+3, tmpPix); | 470 | painter->drawPixmap(x+3, y+3, tmpPix); |
471 | } | 471 | } |
472 | else{ | 472 | else{ |
473 | painter->drawPixmap(x+2, y+2, tmpPix); | 473 | painter->drawPixmap(x+2, y+2, tmpPix); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | else */if(supportPushDown && pushedDown) | 476 | else */if(supportPushDown && pushedDown) |
477 | painter->drawPixmap(x+1, y+1, tmpPix); | 477 | painter->drawPixmap(x+1, y+1, tmpPix); |
478 | else | 478 | else |
479 | painter->drawPixmap(x, y, tmpPix); | 479 | painter->drawPixmap(x, y, tmpPix); |
480 | 480 | ||
481 | 481 | ||
482 | 482 | ||
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | 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, |
487 | bool blend) | 487 | bool blend) |
488 | { | 488 | { |
489 | QImage img(qembed_findImage(label)); | 489 | QImage img(qembed_findImage(label)); |
490 | img.detach(); | 490 | img.detach(); |
491 | if(img.isNull()){ // shouldn't happen, been tested | 491 | if(img.isNull()){ // shouldn't happen, been tested |
492 | qWarning("Invalid embedded label %s", label); | 492 | qWarning("Invalid embedded label %s", label); |
493 | return(NULL); | 493 | return(NULL); |
494 | } | 494 | } |
495 | if(img.depth() != 32) | 495 | if(img.depth() != 32) |
496 | img = img.convertDepth(32); | 496 | img = img.convertDepth(32); |
497 | unsigned int *data = (unsigned int *)img.bits(); | 497 | unsigned int *data = (unsigned int *)img.bits(); |
498 | int total = img.width()*img.height(); | 498 | int total = img.width()*img.height(); |
499 | int current; | 499 | int current; |
500 | QColor c; | 500 | QColor c; |
501 | int oldH, oldS, oldV; | 501 | int oldH, oldS, oldV; |
502 | int alpha; | 502 | int alpha; |
503 | if(v < 235) | 503 | if(v < 235) |
504 | v += 20; | 504 | v += 20; |
505 | else | 505 | else |
506 | v = 255; | 506 | v = 255; |
507 | float intensity = v/255.0; | 507 | float intensity = v/255.0; |
508 | 508 | ||
509 | for(current=0; current<total; ++current){ | 509 | for(current=0; current<total; ++current){ |
510 | alpha = qAlpha(data[current]); | 510 | alpha = qAlpha(data[current]); |
511 | c.setRgb(data[current]); | 511 | c.setRgb(data[current]); |
512 | c.hsv(&oldH, &oldS, &oldV); | 512 | c.hsv(&oldH, &oldS, &oldV); |
513 | oldV = (int)(oldV*intensity); | 513 | oldV = (int)(oldV*intensity); |
514 | c.setHsv(h, s, oldV); | 514 | c.setHsv(h, s, oldV); |
515 | if(blend && alpha != 255 && alpha != 0){ | 515 | if(blend && alpha != 255 && alpha != 0){ |
516 | float srcPercent = ((float)alpha)/255.0; | 516 | float srcPercent = ((float)alpha)/255.0; |
517 | float destPercent = 1.0-srcPercent; | 517 | float destPercent = 1.0-srcPercent; |
518 | oldH = (int)((srcPercent*h) + (destPercent*bH)); | 518 | oldH = (int)((srcPercent*h) + (destPercent*bH)); |
519 | oldS = (int)((srcPercent*s) + (destPercent*bS)); | 519 | oldS = (int)((srcPercent*s) + (destPercent*bS)); |
520 | oldV = (int)((srcPercent*oldV) + (destPercent*bV)); | 520 | oldV = (int)((srcPercent*oldV) + (destPercent*bV)); |
521 | c.setHsv(oldH, oldS, oldV); | 521 | c.setHsv(oldH, oldS, oldV); |
522 | alpha = 255; | 522 | alpha = 255; |
523 | } | 523 | } |
524 | data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); | 524 | data[current] = qRgba(c.red(), c.green(), c.blue(), alpha); |
525 | } | 525 | } |
526 | QPixmap *pix = new QPixmap; | 526 | QPixmap *pix = new QPixmap; |
527 | pix->convertFromImage(img); | 527 | pix->convertFromImage(img); |
528 | return(pix); | 528 | return(pix); |
529 | } | 529 | } |
530 | 530 | ||
531 | 531 | ||
532 | 532 | ||
533 | 533 | ||
534 | QPixmap* LiquidStyle::getPixmap(BitmapData item) | 534 | QPixmap* LiquidStyle::getPixmap(BitmapData item) |
535 | { | 535 | { |
536 | 536 | ||
537 | if(pixmaps[item]) | 537 | if(pixmaps[item]) |
538 | return(pixmaps[item]); | 538 | return(pixmaps[item]); |
539 | 539 | ||
540 | switch(item){ | 540 | switch(item){ |
541 | case HTMLBtnBorder: | 541 | case HTMLBtnBorder: |
542 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); | 542 | pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV); |
543 | break; | 543 | break; |
544 | case HTMLBtnBorderDown: | 544 | case HTMLBtnBorderDown: |
545 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); | 545 | pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV); |
546 | break; | 546 | break; |
547 | case HTMLCB: | 547 | case HTMLCB: |
548 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); | 548 | pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV); |
549 | break; | 549 | break; |
550 | case HTMLCBDown: | 550 | case HTMLCBDown: |
551 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); | 551 | pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV); |
552 | break; | 552 | break; |
553 | case HTMLCBHover: | 553 | case HTMLCBHover: |
554 | pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); | 554 | pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnH, btnS, btnV); |
555 | break; | 555 | break; |
556 | case HTMLCBDownHover: | 556 | case HTMLCBDownHover: |
557 | pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", | 557 | pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", |
558 | btnHoverH, btnHoverS, | 558 | btnHoverH, btnHoverS, |
559 | btnHoverV); | 559 | btnHoverV); |
560 | break; | 560 | break; |
561 | case HTMLRadio: | 561 | case HTMLRadio: |
562 | pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); | 562 | pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV); |
563 | case HTMLRadioDown: | 563 | case HTMLRadioDown: |
564 | pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); | 564 | pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV); |
565 | case HTMLRadioHover: | 565 | case HTMLRadioHover: |
566 | pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); | 566 | pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnH, btnS, btnV); |
567 | case HTMLRadioDownHover: | 567 | case HTMLRadioDownHover: |
568 | pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", | 568 | pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", |
569 | btnHoverH, btnHoverS, | 569 | btnHoverH, btnHoverS, |
570 | btnHoverV); | 570 | btnHoverV); |
571 | case RadioOn: | 571 | case RadioOn: |
572 | pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); | 572 | pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV, true); |
573 | break; | 573 | break; |
574 | case RadioOnHover: | 574 | case RadioOnHover: |
575 | pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, | 575 | pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, |
576 | btnHoverV, true); | 576 | btnHoverV, true); |
577 | break; | 577 | break; |
578 | case RadioOffHover: | 578 | case RadioOffHover: |
579 | pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); | 579 | pixmaps[RadioOffHover] = processEmbedded("radio", btnH, btnS, btnV, true); |
580 | break; | 580 | break; |
581 | case TabDown: | 581 | case TabDown: |
582 | pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); | 582 | pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV, true); |
583 | break; | 583 | break; |
584 | case TabFocus: | 584 | case TabFocus: |
585 | pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, | 585 | pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, |
586 | btnHoverS, true); | 586 | btnHoverS, true); |
587 | break; | 587 | break; |
588 | case CBDown: | 588 | case CBDown: |
589 | pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); | 589 | pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV, true); |
590 | break; | 590 | break; |
591 | case CBDownHover: | 591 | case CBDownHover: |
592 | pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, | 592 | pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, |
593 | btnHoverS, btnHoverV, true); | 593 | btnHoverS, btnHoverV, true); |
594 | break; | 594 | break; |
595 | case CBHover: | 595 | case CBHover: |
596 | pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); | 596 | pixmaps[CBHover] = processEmbedded("checkbox", btnH, btnS, btnV, true); |
597 | break; | 597 | break; |
598 | case HSlider: | 598 | case HSlider: |
599 | pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); | 599 | pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); |
600 | break; | 600 | break; |
601 | case VSlider: | 601 | case VSlider: |
602 | pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); | 602 | pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true); |
603 | *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); | 603 | *pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix); |
604 | break; | 604 | break; |
605 | case RadioOff: | 605 | case RadioOff: |
606 | pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); | 606 | pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV, true); |
607 | break; | 607 | break; |
608 | case Tab: | 608 | case Tab: |
609 | pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); | 609 | pixmaps[Tab] = processEmbedded("tab", bH, bS, bV, true); |
610 | break; | 610 | break; |
611 | case CB: | 611 | case CB: |
612 | pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); | 612 | pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV, true); |
613 | break; | 613 | break; |
614 | case VSBSliderTop: | 614 | case VSBSliderTop: |
615 | pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); | 615 | pixmaps[VSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); |
616 | break; | 616 | break; |
617 | case VSBSliderBtm: | 617 | case VSBSliderBtm: |
618 | pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); | 618 | pixmaps[VSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); |
619 | break; | 619 | break; |
620 | case VSBSliderMid: | 620 | case VSBSliderMid: |
621 | pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); | 621 | pixmaps[VSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); |
622 | break; | 622 | break; |
623 | case VSBSliderTopHover: | 623 | case VSBSliderTopHover: |
624 | pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); | 624 | pixmaps[VSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); |
625 | break; | 625 | break; |
626 | case VSBSliderBtmHover: | 626 | case VSBSliderBtmHover: |
627 | pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); | 627 | pixmaps[VSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); |
628 | break; | 628 | break; |
629 | case VSBSliderMidHover: | 629 | case VSBSliderMidHover: |
630 | pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); | 630 | pixmaps[VSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); |
631 | break; | 631 | break; |
632 | 632 | ||
633 | case HSBSliderTop: | 633 | case HSBSliderTop: |
634 | pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); | 634 | pixmaps[HSBSliderTop] = processEmbedded("sbslider_top", btnH, btnS, btnV, true); |
635 | *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); | 635 | *pixmaps[HSBSliderTop] = pixmaps[HSBSliderTop]->xForm(rMatrix); |
636 | break; | 636 | break; |
637 | case HSBSliderBtm: | 637 | case HSBSliderBtm: |
638 | pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); | 638 | pixmaps[HSBSliderBtm] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true); |
639 | *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); | 639 | *pixmaps[HSBSliderBtm] = pixmaps[HSBSliderBtm]->xForm(rMatrix); |
640 | break; | 640 | break; |
641 | case HSBSliderMid: | 641 | case HSBSliderMid: |
642 | pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); | 642 | pixmaps[HSBSliderMid] = processEmbedded("sbslider_mid", btnH, btnS, btnV); |
643 | *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); | 643 | *pixmaps[HSBSliderMid] = pixmaps[HSBSliderMid]->xForm(rMatrix); |
644 | break; | 644 | break; |
645 | case HSBSliderTopHover: | 645 | case HSBSliderTopHover: |
646 | pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); | 646 | pixmaps[HSBSliderTopHover] = processEmbedded("sbslider_top", btnHoverH, btnHoverS, btnHoverV, true); |
647 | *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); | 647 | *pixmaps[HSBSliderTopHover] = pixmaps[HSBSliderTopHover]->xForm(rMatrix); |
648 | break; | 648 | break; |
649 | case HSBSliderBtmHover: | 649 | case HSBSliderBtmHover: |
650 | pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); | 650 | pixmaps[HSBSliderBtmHover] = processEmbedded("sbslider_btm", btnHoverH, btnHoverS, btnHoverV, true); |
651 | *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); | 651 | *pixmaps[HSBSliderBtmHover] = pixmaps[HSBSliderBtmHover]->xForm(rMatrix); |
652 | break; | 652 | break; |
653 | case HSBSliderMidHover: | 653 | case HSBSliderMidHover: |
654 | pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); | 654 | pixmaps[HSBSliderMidHover] = processEmbedded("sbslider_mid", btnHoverH, btnHoverS, btnHoverV); |
655 | *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); | 655 | *pixmaps[HSBSliderMidHover] = pixmaps[HSBSliderMidHover]->xForm(rMatrix); |
656 | break; | 656 | break; |
657 | case VSBSliderTopBg: | 657 | case VSBSliderTopBg: |
658 | pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); | 658 | pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); |
659 | break; | 659 | break; |
660 | case VSBSliderBtmBg: | 660 | case VSBSliderBtmBg: |
661 | pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); | 661 | pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); |
662 | break; | 662 | break; |
663 | case VSBSliderMidBg: | 663 | case VSBSliderMidBg: |
664 | pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); | 664 | pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); |
665 | break; | 665 | break; |
666 | case HSBSliderTopBg: | 666 | case HSBSliderTopBg: |
667 | pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); | 667 | pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true); |
668 | *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); | 668 | *pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix); |
669 | break; | 669 | break; |
670 | case HSBSliderBtmBg: | 670 | case HSBSliderBtmBg: |
671 | pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); | 671 | pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true); |
672 | *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); | 672 | *pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix); |
673 | break; | 673 | break; |
674 | case HSBSliderMidBg: | 674 | case HSBSliderMidBg: |
675 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); | 675 | pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV); |
676 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); | 676 | *pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix); |
677 | break; | 677 | break; |
678 | default: | 678 | default: |
679 | break; | 679 | break; |
680 | } | 680 | } |
681 | return(pixmaps[item]); | 681 | return(pixmaps[item]); |
682 | } | 682 | } |
683 | 683 | ||
684 | void LiquidStyle::polish(QPalette &appPal) | 684 | void LiquidStyle::polish(QPalette &appPal) |
685 | { | 685 | { |
686 | int i; | 686 | int i; |
687 | for(i=0; i < BITMAP_ITEMS; ++i){ | 687 | for(i=0; i < BITMAP_ITEMS; ++i){ |
688 | if(pixmaps[i]){ | 688 | if(pixmaps[i]){ |
689 | delete pixmaps[i]; | 689 | delete pixmaps[i]; |
690 | pixmaps[i] = NULL; | 690 | pixmaps[i] = NULL; |
691 | } | 691 | } |
692 | } | 692 | } |
693 | QWidgetList *list = QApplication::allWidgets(); | 693 | QWidgetList *list = QApplication::allWidgets(); |
694 | QWidgetListIt it( *list ); | 694 | QWidgetListIt it( *list ); |
695 | QWidget *w; | 695 | QWidget *w; |
696 | while ((w=it.current()) != 0 ){ | 696 | while ((w=it.current()) != 0 ){ |
697 | ++it; | 697 | ++it; |
698 | if(w->inherits("QPushButton")){ | 698 | if(w->inherits("QPushButton")){ |
699 | unapplyCustomAttributes((QPushButton *)w); | 699 | unapplyCustomAttributes((QPushButton *)w); |
700 | } | 700 | } |
701 | } | 701 | } |
702 | 702 | ||
703 | loadCustomButtons(); | 703 | loadCustomButtons(); |
704 | lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; | 704 | lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; |
705 | btnDict.clear(); | 705 | btnDict.clear(); |
706 | btnBorderDict.clear(); | 706 | btnBorderDict.clear(); |
707 | bevelFillDict.clear(); | 707 | bevelFillDict.clear(); |
708 | smallBevelFillDict.clear(); | 708 | smallBevelFillDict.clear(); |
709 | 709 | ||
710 | Config config ( "qpe" ); | 710 | Config config ( "qpe" ); |
711 | config. setGroup ( "Liquid-Style" ); | 711 | config. setGroup ( "Liquid-Style" ); |
712 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); | 712 | int contrast = config. readNumEntry ( "StippleContrast", 5 ); |
713 | if ( contrast < 0 ) | 713 | if ( contrast < 0 ) |
714 | contrast = 0; | 714 | contrast = 0; |
715 | else if ( contrast > 10 ) | 715 | else if ( contrast > 10 ) |
716 | contrast = 10; | 716 | contrast = 10; |
717 | 717 | ||
718 | // QPalette pal = QApplication::palette(); | 718 | // QPalette pal = QApplication::palette(); |
719 | 719 | ||
720 | // button color stuff | 720 | // button color stuff |
721 | config. setGroup ( "Appearance" ); | 721 | config. setGroup ( "Appearance" ); |
722 | QColor c = // QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); | 722 | QColor c = // QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); |
723 | appPal. color ( QPalette::Active, QColorGroup::Button ); | 723 | appPal. color ( QPalette::Active, QColorGroup::Button ); |
724 | if ( c == appPal. color ( QPalette::Active, QColorGroup::Background ) | 724 | if ( c == appPal. color ( QPalette::Active, QColorGroup::Background ) |
725 | //QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( ))) | 725 | //QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( ))) |
726 | ) { | 726 | ) { |
727 | // force button color to be different from background | 727 | // force button color to be different from background |
728 | QBrush btnBrush(QColor(200, 202, 228)); | 728 | QBrush btnBrush(QColor(200, 202, 228)); |
729 | appPal.setBrush(QColorGroup::Button, btnBrush); | 729 | appPal.setBrush(QColorGroup::Button, btnBrush); |
730 | } | 730 | } |
731 | c.hsv(&btnH, &btnS, &btnV); | 731 | c.hsv(&btnH, &btnS, &btnV); |
732 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); | 732 | c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV); |
733 | 733 | ||
734 | // menu pixmap | 734 | // menu pixmap |
735 | if(!menuPix){ | 735 | if(!menuPix){ |
736 | menuPix = new QPixmap; | 736 | menuPix = new QPixmap; |
737 | menuPix->resize(64, 64); | 737 | menuPix->resize(64, 64); |
738 | } | 738 | } |
739 | QPainter painter; | 739 | QPainter painter; |
740 | menuPix->fill(c.rgb()); | 740 | menuPix->fill(c.rgb()); |
741 | painter.begin(menuPix); | 741 | painter.begin(menuPix); |
742 | painter.setPen(c.dark(105)); | 742 | painter.setPen(c.dark(105)); |
743 | for(i=0; i < 63; i+=4){ | 743 | for(i=0; i < 63; i+=4){ |
744 | painter.drawLine(0, i, 63, i); | 744 | painter.drawLine(0, i, 63, i); |
745 | painter.drawLine(0, i+1, 63, i+1); | 745 | painter.drawLine(0, i+1, 63, i+1); |
746 | }; | 746 | }; |
747 | painter.end(); | 747 | painter.end(); |
748 | menuBrush.setColor(c); | 748 | menuBrush.setColor(c); |
749 | menuBrush.setPixmap(*menuPix); | 749 | menuBrush.setPixmap(*menuPix); |
750 | 750 | ||
751 | // pager brush | 751 | // pager brush |
752 | c = c.dark(120); | 752 | c = c.dark(120); |
753 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 753 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
754 | if(!pix){ | 754 | if(!pix){ |
755 | int h, s, v; | 755 | int h, s, v; |
756 | c.hsv(&h, &s, &v); | 756 | c.hsv(&h, &s, &v); |
757 | pix = new QPixmap(*smallBevelFillPix); | 757 | pix = new QPixmap(*smallBevelFillPix); |
758 | adjustHSV(*pix, h, s, v); | 758 | adjustHSV(*pix, h, s, v); |
759 | smallBevelFillDict.insert(c.rgb(), pix); | 759 | smallBevelFillDict.insert(c.rgb(), pix); |
760 | } | 760 | } |
761 | pagerHoverBrush.setColor(c); | 761 | pagerHoverBrush.setColor(c); |
762 | pagerHoverBrush.setPixmap(*pix); | 762 | pagerHoverBrush.setPixmap(*pix); |
763 | 763 | ||
764 | c = c.dark(120); | 764 | c = c.dark(120); |
765 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 765 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
766 | if(!pix){ | 766 | if(!pix){ |
767 | int h, s, v; | 767 | int h, s, v; |
768 | c.hsv(&h, &s, &v); | 768 | c.hsv(&h, &s, &v); |
769 | pix = new QPixmap(*smallBevelFillPix); | 769 | pix = new QPixmap(*smallBevelFillPix); |
770 | adjustHSV(*pix, h, s, v); | 770 | adjustHSV(*pix, h, s, v); |
771 | smallBevelFillDict.insert(c.rgb(), pix); | 771 | smallBevelFillDict.insert(c.rgb(), pix); |
772 | } | 772 | } |
773 | pagerBrush.setColor(c); | 773 | pagerBrush.setColor(c); |
774 | pagerBrush.setPixmap(*pix); | 774 | pagerBrush.setPixmap(*pix); |
775 | 775 | ||
776 | // background color stuff | 776 | // background color stuff |
777 | c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background ); | 777 | c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background ); |
778 | c.hsv(&bH, &bS, &bV); | 778 | c.hsv(&bH, &bS, &bV); |
779 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); | 779 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); |
780 | 780 | ||
781 | // FIXME? | 781 | // FIXME? |
782 | if(vsbSliderFillPix) | 782 | if(vsbSliderFillPix) |
783 | delete vsbSliderFillPix; | 783 | delete vsbSliderFillPix; |
784 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); | 784 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); |
785 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); | 785 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); |
786 | 786 | ||
787 | // background brush | 787 | // background brush |
788 | QPixmap wallPaper(32, 32); | 788 | QPixmap wallPaper(32, 32); |
789 | wallPaper.fill(c.rgb()); | 789 | wallPaper.fill(c.rgb()); |
790 | painter.begin(&wallPaper); | 790 | painter.begin(&wallPaper); |
791 | for(i=0; i < 32; i+=4){ | 791 | for(i=0; i < 32; i+=4){ |
792 | painter.setPen(c.dark(100 + contrast)); | 792 | painter.setPen(c.dark(100 + contrast)); |
793 | painter.drawLine(0, i, 32, i); | 793 | painter.drawLine(0, i, 32, i); |
794 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); | 794 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); |
795 | painter.drawLine(0, i+1, 32, i+1); | 795 | painter.drawLine(0, i+1, 32, i+1); |
796 | }; | 796 | }; |
797 | painter.end(); | 797 | painter.end(); |
798 | bgBrush.setColor(c); | 798 | bgBrush.setColor(c); |
799 | bgBrush.setPixmap(wallPaper); | 799 | bgBrush.setPixmap(wallPaper); |
800 | appPal.setBrush(QColorGroup::Background, bgBrush); | 800 | appPal.setBrush(QColorGroup::Background, bgBrush); |
801 | 801 | ||
802 | // lineedits | 802 | // lineedits |
803 | c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base ); | 803 | c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base ); |
804 | QPixmap basePix; | 804 | QPixmap basePix; |
805 | basePix.resize(32, 32); | 805 | basePix.resize(32, 32); |
806 | basePix.fill(c.rgb()); | 806 | basePix.fill(c.rgb()); |
807 | painter.begin(&basePix); | 807 | painter.begin(&basePix); |
808 | painter.setPen(c.dark(105)); | 808 | painter.setPen(c.dark(105)); |
809 | for(i=0; i < 32; i+=4){ | 809 | for(i=0; i < 32; i+=4){ |
810 | painter.drawLine(0, i, 32, i); | 810 | painter.drawLine(0, i, 32, i); |
811 | painter.drawLine(0, i+1, 32, i+1); | 811 | painter.drawLine(0, i+1, 32, i+1); |
812 | }; | 812 | }; |
813 | painter.end(); | 813 | painter.end(); |
814 | baseBrush.setColor(c); | 814 | baseBrush.setColor(c); |
815 | baseBrush.setPixmap(basePix); | 815 | baseBrush.setPixmap(basePix); |
816 | it.toFirst(); | 816 | it.toFirst(); |
817 | while ((w=it.current()) != 0 ){ | 817 | while ((w=it.current()) != 0 ){ |
818 | ++it; | 818 | ++it; |
819 | if(w->inherits("QLineEdit")){ | 819 | if(w->inherits("QLineEdit")){ |
820 | QPalette pal = w->palette(); | 820 | QPalette pal = w->palette(); |
821 | pal.setBrush(QColorGroup::Base, baseBrush); | 821 | pal.setBrush(QColorGroup::Base, baseBrush); |
822 | w->setPalette(pal); | 822 | w->setPalette(pal); |
823 | } | 823 | } |
824 | else if(w->inherits("QPushButton")){ | 824 | else if(w->inherits("QPushButton")){ |
825 | applyCustomAttributes((QPushButton *)w); | 825 | applyCustomAttributes((QPushButton *)w); |
826 | } | 826 | } |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void LiquidStyle::polish(QWidget *w) | 830 | void LiquidStyle::polish(QWidget *w) |
831 | { | 831 | { |
832 | if(w->inherits("QMenuBar")){ | 832 | if(w->inherits("QMenuBar")){ |
833 | //((QFrame*)w)->setLineWidth(0); | 833 | //((QFrame*)w)->setLineWidth(0); |
834 | w->setBackgroundMode(QWidget::PaletteBackground); | 834 | w->setBackgroundMode(QWidget::PaletteBackground); |
835 | w->setBackgroundOrigin(QWidget::ParentOrigin); | 835 | w->setBackgroundOrigin(QWidget::ParentOrigin); |
836 | return; | 836 | return; |
837 | } | 837 | } |
838 | if(w->inherits("QToolBar")){ | 838 | if(w->inherits("QToolBar")){ |
839 | w->installEventFilter(this); | 839 | w->installEventFilter(this); |
840 | w->setBackgroundMode(QWidget::PaletteBackground); | 840 | w->setBackgroundMode(QWidget::PaletteBackground); |
841 | w->setBackgroundOrigin(QWidget::WidgetOrigin); | 841 | w->setBackgroundOrigin(QWidget::WidgetOrigin); |
842 | return; | 842 | return; |
843 | } | 843 | } |
844 | if(w->inherits("QPopupMenu")) | 844 | if(w->inherits("QPopupMenu")) |
845 | w->setBackgroundMode(QWidget::NoBackground); | 845 | w->setBackgroundMode(QWidget::NoBackground); |
846 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 846 | else if(w-> testWFlags(Qt::WType_Popup) && |
847 | !w->inherits("QListBox") && | ||
848 | ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { | ||
847 | w->installEventFilter(menuHandler); | 849 | w->installEventFilter(menuHandler); |
848 | } | 850 | } |
849 | 851 | ||
850 | if(w->isTopLevel()){ | 852 | if(w->isTopLevel()){ |
851 | return; | 853 | return; |
852 | } | 854 | } |
853 | 855 | ||
854 | if(w->inherits("QComboBox") || w->inherits("QProgressBar") || | 856 | if(w->inherits("QComboBox") || w->inherits("QProgressBar") || |
855 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 857 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
856 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 858 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
857 | w->installEventFilter(this); | 859 | w->installEventFilter(this); |
858 | } | 860 | } |
859 | if(w->inherits("QLineEdit")){ | 861 | if(w->inherits("QLineEdit")){ |
860 | QPalette pal = w->palette(); | 862 | QPalette pal = w->palette(); |
861 | pal.setBrush(QColorGroup::Base, baseBrush); | 863 | pal.setBrush(QColorGroup::Base, baseBrush); |
862 | w->setPalette(pal); | 864 | w->setPalette(pal); |
863 | } | 865 | } |
864 | if(w->inherits("QPushButton")){ | 866 | if(w->inherits("QPushButton")){ |
865 | applyCustomAttributes((QPushButton *)w); | 867 | applyCustomAttributes((QPushButton *)w); |
866 | w->installEventFilter(this); | 868 | w->installEventFilter(this); |
867 | } | 869 | } |
868 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ | 870 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ |
869 | w-> setBackgroundMode ( QWidget::PaletteBackground ); | 871 | w-> setBackgroundMode ( QWidget::PaletteBackground ); |
870 | w->setBackgroundOrigin ( QWidget::ParentOrigin); | 872 | w->setBackgroundOrigin ( QWidget::ParentOrigin); |
871 | } | 873 | } |
872 | 874 | ||
873 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || | 875 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || |
874 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; | 876 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; |
875 | bool isViewportChild = w->parent() && | 877 | bool isViewportChild = w->parent() && |
876 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 878 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
877 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 879 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
878 | 880 | ||
879 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ | 881 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ |
880 | w->setBackgroundMode(QWidget::X11ParentRelative); | 882 | w->setBackgroundMode(QWidget::X11ParentRelative); |
881 | return; | 883 | return; |
882 | } | 884 | } |
883 | if(isViewportChild){ | 885 | if(isViewportChild){ |
884 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 886 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
885 | if(w->parent()){ // heh, only way to test for KHTML children ;-) | 887 | if(w->parent()){ // heh, only way to test for KHTML children ;-) |
886 | if(w->parent()->parent()){ | 888 | if(w->parent()->parent()){ |
887 | if(w->parent()->parent()->parent() && | 889 | if(w->parent()->parent()->parent() && |
888 | w->parent()->parent()->parent()->inherits("KHTMLView")){ | 890 | w->parent()->parent()->parent()->inherits("KHTMLView")){ |
889 | w->setAutoMask(true); | 891 | w->setAutoMask(true); |
890 | w->setBackgroundMode(QWidget::NoBackground); | 892 | w->setBackgroundMode(QWidget::NoBackground); |
891 | } | 893 | } |
892 | } | 894 | } |
893 | } | 895 | } |
894 | return; | 896 | return; |
895 | } | 897 | } |
896 | } | 898 | } |
897 | if(w->inherits("QHeader")){ | 899 | if(w->inherits("QHeader")){ |
898 | w->setMouseTracking(true); | 900 | w->setMouseTracking(true); |
899 | w->installEventFilter(this); | 901 | w->installEventFilter(this); |
900 | } | 902 | } |
901 | if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { | 903 | if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { |
902 | ((QToolButton*)w)->setAutoRaise (flatTBButtons); | 904 | ((QToolButton*)w)->setAutoRaise (flatTBButtons); |
903 | if ( flatTBButtons ) | 905 | if ( flatTBButtons ) |
904 | w->setBackgroundOrigin(QWidget::ParentOrigin); | 906 | w->setBackgroundOrigin(QWidget::ParentOrigin); |
905 | } | 907 | } |
906 | if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { | 908 | if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { |
907 | ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); | 909 | ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); |
908 | } | 910 | } |
909 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 911 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
910 | return; | 912 | return; |
911 | } | 913 | } |
912 | 914 | ||
913 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 915 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
914 | palette().active().brush(QColorGroup::Background).pixmap()){ | 916 | palette().active().brush(QColorGroup::Background).pixmap()){ |
915 | qWarning("No parent pixmap for child widget %s", w->className()); | 917 | qWarning("No parent pixmap for child widget %s", w->className()); |
916 | return; | 918 | return; |
917 | } | 919 | } |
918 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && | 920 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && |
919 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { | 921 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { |
920 | if(w->backgroundMode() == QWidget::PaletteBackground || | 922 | if(w->backgroundMode() == QWidget::PaletteBackground || |
921 | w->backgroundMode() == QWidget::PaletteButton){ | 923 | w->backgroundMode() == QWidget::PaletteButton){ |
922 | w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); | 924 | w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); |
923 | w->setBackgroundOrigin(QWidget::ParentOrigin); | 925 | w->setBackgroundOrigin(QWidget::ParentOrigin); |
924 | // w->setBackgroundMode(QWidget::NoBackground); | 926 | // w->setBackgroundMode(QWidget::NoBackground); |
925 | } | 927 | } |
926 | } | 928 | } |
927 | if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) | 929 | if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) |
928 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | 930 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); |
929 | else if ( w-> inherits("QFrame") ) | 931 | else if ( w-> inherits("QFrame") ) |
930 | w->setBackgroundOrigin ( QWidget::WidgetOrigin ); | 932 | w->setBackgroundOrigin ( QWidget::WidgetOrigin ); |
931 | 933 | ||
932 | if ( w->parentWidget()->inherits ( "QWidgetStack" )) { | 934 | if ( w->parentWidget()->inherits ( "QWidgetStack" )) { |
933 | w->setBackgroundOrigin ( QWidget::WidgetOrigin ); | 935 | w->setBackgroundOrigin ( QWidget::WidgetOrigin ); |
934 | } | 936 | } |
935 | } | 937 | } |
936 | 938 | ||
937 | void LiquidStyle::unPolish(QWidget *w) | 939 | void LiquidStyle::unPolish(QWidget *w) |
938 | { | 940 | { |
939 | if(w->inherits("QMenuBar")){ | 941 | if(w->inherits("QMenuBar")){ |
940 | ((QFrame *)w)->setLineWidth(1); | 942 | ((QFrame *)w)->setLineWidth(1); |
941 | w->setBackgroundMode(QWidget::PaletteBackground); | 943 | w->setBackgroundMode(QWidget::PaletteBackground); |
942 | return; | 944 | return; |
943 | } | 945 | } |
944 | 946 | ||
945 | if(w->inherits("QPopupMenu")) | 947 | if(w->inherits("QPopupMenu")) |
946 | w->setBackgroundMode(QWidget::PaletteButton); | 948 | w->setBackgroundMode(QWidget::PaletteButton); |
947 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 949 | else if(w-> testWFlags(Qt::WType_Popup) && |
950 | !w->inherits("QListBox") && | ||
951 | ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { | ||
948 | w->removeEventFilter(menuHandler); | 952 | w->removeEventFilter(menuHandler); |
949 | } | 953 | } |
950 | 954 | ||
951 | if(w->isTopLevel()) | 955 | if(w->isTopLevel()) |
952 | return; | 956 | return; |
953 | 957 | ||
954 | // for viewport children, don't just check for NoBackground.... | 958 | // for viewport children, don't just check for NoBackground.... |
955 | bool isViewportChild = w->parent() && | 959 | bool isViewportChild = w->parent() && |
956 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 960 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
957 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 961 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
958 | 962 | ||
959 | w->unsetPalette(); | 963 | w->unsetPalette(); |
960 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ | 964 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ |
961 | if(w->inherits("QPushButton")) | 965 | if(w->inherits("QPushButton")) |
962 | w->setBackgroundMode(QWidget::PaletteButton); | 966 | w->setBackgroundMode(QWidget::PaletteButton); |
963 | else | 967 | else |
964 | w->setBackgroundMode(QWidget::PaletteBackground); | 968 | w->setBackgroundMode(QWidget::PaletteBackground); |
965 | } | 969 | } |
966 | 970 | ||
967 | if(isViewportChild) | 971 | if(isViewportChild) |
968 | w->setAutoMask(false); | 972 | w->setAutoMask(false); |
969 | 973 | ||
970 | if(w->inherits("QPushButton")){ | 974 | if(w->inherits("QPushButton")){ |
971 | unapplyCustomAttributes((QPushButton *)w); | 975 | unapplyCustomAttributes((QPushButton *)w); |
972 | w->removeEventFilter(this); | 976 | w->removeEventFilter(this); |
973 | } | 977 | } |
974 | /* | 978 | /* |
975 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ | 979 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ |
976 | w-> setBackgroundMode ( PaletteBackground ); | 980 | w-> setBackgroundMode ( PaletteBackground ); |
977 | } | 981 | } |
978 | */ | 982 | */ |
979 | if(w->inherits("QComboBox") || | 983 | if(w->inherits("QComboBox") || |
980 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 984 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
981 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 985 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
982 | w->removeEventFilter(this); | 986 | w->removeEventFilter(this); |
983 | } | 987 | } |
984 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 988 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
985 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ | 989 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ |
986 | w->setAutoMask(false); | 990 | w->setAutoMask(false); |
987 | } | 991 | } |
988 | } | 992 | } |
989 | if(w->inherits("QToolBar")){ | 993 | if(w->inherits("QToolBar")){ |
990 | w->removeEventFilter(this); | 994 | w->removeEventFilter(this); |
991 | w->setBackgroundMode(QWidget::PaletteBackground); | 995 | w->setBackgroundMode(QWidget::PaletteBackground); |
992 | return; | 996 | return; |
993 | } | 997 | } |
994 | if(w->inherits("QHeader")){ | 998 | if(w->inherits("QHeader")){ |
995 | w->setMouseTracking(false); | 999 | w->setMouseTracking(false); |
996 | w->removeEventFilter(this); | 1000 | w->removeEventFilter(this); |
997 | } | 1001 | } |
998 | } | 1002 | } |
999 | 1003 | ||
1000 | void LiquidStyle::polish(QApplication *app) | 1004 | void LiquidStyle::polish(QApplication *app) |
1001 | { | 1005 | { |
1002 | 1006 | ||
1003 | QWindowsStyle::polish(app); | 1007 | QWindowsStyle::polish(app); |
1004 | menuAni = app->isEffectEnabled(UI_AnimateMenu); | 1008 | menuAni = app->isEffectEnabled(UI_AnimateMenu); |
1005 | menuFade = app->isEffectEnabled(UI_FadeMenu); | 1009 | menuFade = app->isEffectEnabled(UI_FadeMenu); |
1006 | if(menuAni) | 1010 | if(menuAni) |
1007 | app->setEffectEnabled(UI_AnimateMenu, false); | 1011 | app->setEffectEnabled(UI_AnimateMenu, false); |
1008 | if(menuFade) | 1012 | if(menuFade) |
1009 | app->setEffectEnabled(UI_FadeMenu, false); | 1013 | app->setEffectEnabled(UI_FadeMenu, false); |
1010 | 1014 | ||
1011 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); | 1015 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); |
1012 | 1016 | ||
1013 | Config config ( "qpe" ); | 1017 | Config config ( "qpe" ); |
1014 | config. setGroup ( "Liquid-Style" ); | 1018 | config. setGroup ( "Liquid-Style" ); |
1015 | 1019 | ||
1016 | // if ( config. readBoolEntry ( "WinDecoration", true )) | 1020 | // if ( config. readBoolEntry ( "WinDecoration", true )) |
1017 | // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); | 1021 | // QApplication::qwsSetDecoration ( new LiquidDecoration ( )); |
1018 | 1022 | ||
1019 | flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); | 1023 | flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); |
1020 | } | 1024 | } |
1021 | 1025 | ||
1022 | void LiquidStyle::unPolish(QApplication *app) | 1026 | void LiquidStyle::unPolish(QApplication *app) |
1023 | { | 1027 | { |
1024 | QWindowsStyle::unPolish(app); | 1028 | QWindowsStyle::unPolish(app); |
1025 | app->setEffectEnabled(UI_AnimateMenu, menuAni); | 1029 | app->setEffectEnabled(UI_AnimateMenu, menuAni); |
1026 | app->setEffectEnabled(UI_FadeMenu, menuFade); | 1030 | app->setEffectEnabled(UI_FadeMenu, menuFade); |
1027 | 1031 | ||
1028 | qt_set_draw_menu_bar_impl ( 0 ); | 1032 | qt_set_draw_menu_bar_impl ( 0 ); |
1029 | 1033 | ||
1030 | // QApplication::qwsSetDecoration ( new QPEDecoration ( )); | 1034 | // QApplication::qwsSetDecoration ( new QPEDecoration ( )); |
1031 | } | 1035 | } |
1032 | 1036 | ||
1033 | 1037 | ||
1034 | /* !! HACK !! Beware | 1038 | /* !! HACK !! Beware |
1035 | * | 1039 | * |
1036 | * TT forgot to make the QProgressBar widget styleable in Qt 2.x | 1040 | * TT forgot to make the QProgressBar widget styleable in Qt 2.x |
1037 | * So the only way to customize the drawing, is to intercept the | 1041 | * So the only way to customize the drawing, is to intercept the |
1038 | * paint event - since we have to use protected functions, we need | 1042 | * paint event - since we have to use protected functions, we need |
1039 | * to derive a "hack" class from QProgressBar and do the painting | 1043 | * to derive a "hack" class from QProgressBar and do the painting |
1040 | * in there. | 1044 | * in there. |
1041 | * | 1045 | * |
1042 | * - sandman | 1046 | * - sandman |
1043 | */ | 1047 | */ |
1044 | 1048 | ||
1045 | class HackProgressBar : public QProgressBar { | 1049 | class HackProgressBar : public QProgressBar { |
1046 | public: | 1050 | public: |
1047 | HackProgressBar ( ); | 1051 | HackProgressBar ( ); |
1048 | 1052 | ||
1049 | void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) | 1053 | void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) |
1050 | { | 1054 | { |
1051 | QPainter p( this ); | 1055 | QPainter p( this ); |
1052 | 1056 | ||
1053 | if ( !contentsRect().contains( event->rect() ) ) { | 1057 | if ( !contentsRect().contains( event->rect() ) ) { |
1054 | p.save(); | 1058 | p.save(); |
1055 | p.setClipRegion( event->region().intersect(frameRect()) ); | 1059 | p.setClipRegion( event->region().intersect(frameRect()) ); |
1056 | drawFrame( &p); | 1060 | drawFrame( &p); |
1057 | p.restore(); | 1061 | p.restore(); |
1058 | } | 1062 | } |
1059 | if ( event->rect().intersects( contentsRect() )) { | 1063 | if ( event->rect().intersects( contentsRect() )) { |
1060 | p.setClipRegion( event->region().intersect( contentsRect() ) ); | 1064 | p.setClipRegion( event->region().intersect( contentsRect() ) ); |
1061 | 1065 | ||
1062 | int x, y, w, h; | 1066 | int x, y, w, h; |
1063 | contentsRect ( ). rect ( &x, &y, &w, &h ); | 1067 | contentsRect ( ). rect ( &x, &y, &w, &h ); |
1064 | 1068 | ||
1065 | int prog = progress ( ); | 1069 | int prog = progress ( ); |
1066 | int total = totalSteps ( ); | 1070 | int total = totalSteps ( ); |
1067 | if ( prog < 0 ) | 1071 | if ( prog < 0 ) |
1068 | prog = 0; | 1072 | prog = 0; |
1069 | if ( total <= 0 ) | 1073 | if ( total <= 0 ) |
1070 | total = 1; | 1074 | total = 1; |
1071 | int bw = w * prog / total; | 1075 | int bw = w * prog / total; |
1072 | if ( bw > w ) | 1076 | if ( bw > w ) |
1073 | bw = w; | 1077 | bw = w; |
1074 | 1078 | ||
1075 | p.setPen(g.button().dark(130)); | 1079 | p.setPen(g.button().dark(130)); |
1076 | p.drawRect(x, y, bw, h); | 1080 | p.drawRect(x, y, bw, h); |
1077 | p.setPen(g.button().light(120)); | 1081 | p.setPen(g.button().light(120)); |
1078 | p.drawRect(x+1, y+1, bw-2, h-2); | 1082 | p.drawRect(x+1, y+1, bw-2, h-2); |
1079 | 1083 | ||
1080 | if(bw >= 4 && h >= 4 && pix) | 1084 | if(bw >= 4 && h >= 4 && pix) |
1081 | p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); | 1085 | p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); |
1082 | 1086 | ||
1083 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { | 1087 | if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { |
1084 | QString pstr; | 1088 | QString pstr; |
1085 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); | 1089 | pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); |
1086 | p. setPen ( g.text());//g.highlightedText ( )); | 1090 | p. setPen ( g.text());//g.highlightedText ( )); |
1087 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); | 1091 | p. drawText (x,y,w-1,h-1,AlignCenter,pstr); |
1088 | } | 1092 | } |
1089 | } | 1093 | } |
1090 | } | 1094 | } |
1091 | }; | 1095 | }; |
1092 | 1096 | ||
1093 | 1097 | ||
1094 | 1098 | ||
1095 | /* | 1099 | /* |
1096 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1100 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
1097 | * force everything to erase and repaint on resize. This is going away, I'm | 1101 | * force everything to erase and repaint on resize. This is going away, I'm |
1098 | * trying to get shaped widgets to work right without masking. QPushButton, | 1102 | * trying to get shaped widgets to work right without masking. QPushButton, |
1099 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1103 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1100 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1104 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1101 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1105 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1102 | * caches them in QPixmapCache, which is bad for doing things like hover | 1106 | * caches them in QPixmapCache, which is bad for doing things like hover |
1103 | * because the style methods aren't called in paintEvents if everything | 1107 | * because the style methods aren't called in paintEvents if everything |
1104 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1108 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1105 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1109 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
1106 | * modifications. For QHeader, different header items are actually one widget | 1110 | * modifications. For QHeader, different header items are actually one widget |
1107 | * that draws multiple items, so we need to check which ID is hightlighted | 1111 | * that draws multiple items, so we need to check which ID is hightlighted |
1108 | * and draw it. Finally, we also check enter and leave events for QLineEdit, | 1112 | * and draw it. Finally, we also check enter and leave events for QLineEdit, |
1109 | * since if it's inside a combobox we want to highlight the combobox during | 1113 | * since if it's inside a combobox we want to highlight the combobox during |
1110 | * hovering in the edit. | 1114 | * hovering in the edit. |
1111 | */ | 1115 | */ |
1112 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | 1116 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) |
1113 | { | 1117 | { |
1114 | if(obj->inherits("QToolBar")){ | 1118 | if(obj->inherits("QToolBar")){ |
1115 | if(ev->type() == QEvent::Resize){ | 1119 | if(ev->type() == QEvent::Resize){ |
1116 | const QObjectList *tbChildList = obj->children(); | 1120 | const QObjectList *tbChildList = obj->children(); |
1117 | QObjectListIt it(*tbChildList); | 1121 | QObjectListIt it(*tbChildList); |
1118 | QObject *child; | 1122 | QObject *child; |
1119 | while((child = it.current()) != NULL){ | 1123 | while((child = it.current()) != NULL){ |
1120 | ++it; | 1124 | ++it; |
1121 | if(child->isWidgetType()) | 1125 | if(child->isWidgetType()) |
1122 | ((QWidget *)child)->repaint(true); | 1126 | ((QWidget *)child)->repaint(true); |
1123 | } | 1127 | } |
1124 | 1128 | ||
1125 | } | 1129 | } |
1126 | } | 1130 | } |
1127 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ | 1131 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ |
1128 | QWidget *btn = (QWidget *)obj; | 1132 | QWidget *btn = (QWidget *)obj; |
1129 | if(ev->type() == QEvent::Enter){ | 1133 | if(ev->type() == QEvent::Enter){ |
1130 | if(btn->isEnabled()){ | 1134 | if(btn->isEnabled()){ |
1131 | highlightWidget = btn; | 1135 | highlightWidget = btn; |
1132 | btn->repaint(false); | 1136 | btn->repaint(false); |
1133 | } | 1137 | } |
1134 | } | 1138 | } |
1135 | else if(ev->type() == QEvent::Leave){ | 1139 | else if(ev->type() == QEvent::Leave){ |
1136 | if(btn == highlightWidget){ | 1140 | if(btn == highlightWidget){ |
1137 | highlightWidget = NULL; | 1141 | highlightWidget = NULL; |
1138 | btn->repaint(false); | 1142 | btn->repaint(false); |
1139 | } | 1143 | } |
1140 | } | 1144 | } |
1141 | } | 1145 | } |
1142 | else if(obj->inherits("QToolButton")){ | 1146 | else if(obj->inherits("QToolButton")){ |
1143 | QToolButton *btn = (QToolButton *)btn; | 1147 | QToolButton *btn = (QToolButton *)btn; |
1144 | if(!btn->autoRaise()){ | 1148 | if(!btn->autoRaise()){ |
1145 | if(btn->isEnabled()){ | 1149 | if(btn->isEnabled()){ |
1146 | highlightWidget = btn; | 1150 | highlightWidget = btn; |
1147 | btn->repaint(false); | 1151 | btn->repaint(false); |
1148 | } | 1152 | } |
1149 | } | 1153 | } |
1150 | else if(ev->type() == QEvent::Leave){ | 1154 | else if(ev->type() == QEvent::Leave){ |
1151 | QWidget *btn = (QWidget *)obj; | 1155 | QWidget *btn = (QWidget *)obj; |
1152 | if(btn == highlightWidget){ | 1156 | if(btn == highlightWidget){ |
1153 | highlightWidget = NULL; | 1157 | highlightWidget = NULL; |
1154 | btn->repaint(false); | 1158 | btn->repaint(false); |
1155 | } | 1159 | } |
1156 | } | 1160 | } |
1157 | else | 1161 | else |
1158 | highlightWidget = NULL; | 1162 | highlightWidget = NULL; |
1159 | } | 1163 | } |
1160 | else if(obj->inherits("QScrollBar")){ | 1164 | else if(obj->inherits("QScrollBar")){ |
1161 | QScrollBar *sb = (QScrollBar *)obj; | 1165 | QScrollBar *sb = (QScrollBar *)obj; |
1162 | if(ev->type() == QEvent::Enter){ | 1166 | if(ev->type() == QEvent::Enter){ |
1163 | if(sb->isEnabled()){ | 1167 | if(sb->isEnabled()){ |
1164 | highlightWidget = sb; | 1168 | highlightWidget = sb; |
1165 | sb->repaint(false); | 1169 | sb->repaint(false); |
1166 | } | 1170 | } |
1167 | } | 1171 | } |
1168 | else if(ev->type() == QEvent::Leave){ | 1172 | else if(ev->type() == QEvent::Leave){ |
1169 | if(sb == highlightWidget && !sb->draggingSlider()){ | 1173 | if(sb == highlightWidget && !sb->draggingSlider()){ |
1170 | highlightWidget = NULL; | 1174 | highlightWidget = NULL; |
1171 | sb->repaint(false); | 1175 | sb->repaint(false); |
1172 | } | 1176 | } |
1173 | } | 1177 | } |
1174 | else if(ev->type() == QEvent::MouseButtonRelease){ | 1178 | else if(ev->type() == QEvent::MouseButtonRelease){ |
1175 | QMouseEvent *me = (QMouseEvent *)ev; | 1179 | QMouseEvent *me = (QMouseEvent *)ev; |
1176 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ | 1180 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ |
1177 | highlightWidget = NULL; | 1181 | highlightWidget = NULL; |
1178 | sb->repaint(false); | 1182 | sb->repaint(false); |
1179 | } | 1183 | } |
1180 | } | 1184 | } |
1181 | } | 1185 | } |
1182 | else if(obj->inherits("QLineEdit")){ | 1186 | else if(obj->inherits("QLineEdit")){ |
1183 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ | 1187 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ |
1184 | QWidget *btn = (QComboBox *)obj->parent(); | 1188 | QWidget *btn = (QComboBox *)obj->parent(); |
1185 | if(ev->type() == QEvent::Enter){ | 1189 | if(ev->type() == QEvent::Enter){ |
1186 | if (btn->isEnabled()){ | 1190 | if (btn->isEnabled()){ |
1187 | highlightWidget = btn; | 1191 | highlightWidget = btn; |
1188 | btn->repaint(false); | 1192 | btn->repaint(false); |
1189 | } | 1193 | } |
1190 | } | 1194 | } |
1191 | else if(ev->type() == QEvent::Leave){ | 1195 | else if(ev->type() == QEvent::Leave){ |
1192 | if (btn == highlightWidget) | 1196 | if (btn == highlightWidget) |
1193 | highlightWidget = NULL; | 1197 | highlightWidget = NULL; |
1194 | btn->repaint(false); | 1198 | btn->repaint(false); |
1195 | } | 1199 | } |
1196 | } | 1200 | } |
1197 | } | 1201 | } |
1198 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ | 1202 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ |
1199 | QButton *btn = (QButton *)obj; | 1203 | QButton *btn = (QButton *)obj; |
1200 | bool isRadio = obj->inherits("QRadioButton"); | 1204 | bool isRadio = obj->inherits("QRadioButton"); |
1201 | if(ev->type() == QEvent::Paint){ | 1205 | if(ev->type() == QEvent::Paint){ |
1202 | //if(btn->autoMask()) | 1206 | //if(btn->autoMask()) |
1203 | btn->erase(); | 1207 | btn->erase(); |
1204 | QPainter p; | 1208 | QPainter p; |
1205 | p.begin(btn); | 1209 | p.begin(btn); |
1206 | QFontMetrics fm = btn->fontMetrics(); | 1210 | QFontMetrics fm = btn->fontMetrics(); |
1207 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1211 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1208 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1212 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1209 | : indicatorSize(); | 1213 | : indicatorSize(); |
1210 | 1214 | ||
1211 | if(btn->hasFocus()){ | 1215 | if(btn->hasFocus()){ |
1212 | QRect r = QRect(0, 0, btn->width(), btn->height()); | 1216 | QRect r = QRect(0, 0, btn->width(), btn->height()); |
1213 | p.setPen(btn->colorGroup().button().dark(140)); | 1217 | p.setPen(btn->colorGroup().button().dark(140)); |
1214 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1218 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1215 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1219 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1216 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1220 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1217 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1221 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1218 | } | 1222 | } |
1219 | int x = 0; | 1223 | int x = 0; |
1220 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1224 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1221 | if(isRadio) | 1225 | if(isRadio) |
1222 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1226 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1223 | btn->colorGroup(), btn->isOn(), | 1227 | btn->colorGroup(), btn->isOn(), |
1224 | btn->isDown(), btn->isEnabled()); | 1228 | btn->isDown(), btn->isEnabled()); |
1225 | else | 1229 | else |
1226 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1230 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1227 | btn->colorGroup(), btn->state(), btn->isDown(), | 1231 | btn->colorGroup(), btn->state(), btn->isDown(), |
1228 | btn->isEnabled()); | 1232 | btn->isEnabled()); |
1229 | x = sz.width() + 6; | 1233 | x = sz.width() + 6; |
1230 | y = 0; | 1234 | y = 0; |
1231 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), | 1235 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), |
1232 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, | 1236 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, |
1233 | btn->colorGroup(), btn->isEnabled(), | 1237 | btn->colorGroup(), btn->isEnabled(), |
1234 | btn->pixmap(), btn->text()); | 1238 | btn->pixmap(), btn->text()); |
1235 | p.end(); | 1239 | p.end(); |
1236 | return(true); | 1240 | return(true); |
1237 | } | 1241 | } |
1238 | // for hover, just redraw the indicator (not the text) | 1242 | // for hover, just redraw the indicator (not the text) |
1239 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || | 1243 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || |
1240 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ | 1244 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ |
1241 | QButton *btn = (QButton *)obj; | 1245 | QButton *btn = (QButton *)obj; |
1242 | bool isRadio = obj->inherits("QRadioButton"); | 1246 | bool isRadio = obj->inherits("QRadioButton"); |
1243 | 1247 | ||
1244 | if(ev->type() == QEvent::Enter) | 1248 | if(ev->type() == QEvent::Enter) |
1245 | highlightWidget = btn; | 1249 | highlightWidget = btn; |
1246 | else | 1250 | else |
1247 | highlightWidget = NULL; | 1251 | highlightWidget = NULL; |
1248 | QFontMetrics fm = btn->fontMetrics(); | 1252 | QFontMetrics fm = btn->fontMetrics(); |
1249 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1253 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1250 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1254 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1251 | : indicatorSize(); | 1255 | : indicatorSize(); |
1252 | int x = 0; | 1256 | int x = 0; |
1253 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1257 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1254 | //if(btn->autoMask()) | 1258 | //if(btn->autoMask()) |
1255 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); | 1259 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); |
1256 | QPainter p; | 1260 | QPainter p; |
1257 | p.begin(btn); | 1261 | p.begin(btn); |
1258 | if(isRadio) | 1262 | if(isRadio) |
1259 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1263 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1260 | btn->colorGroup(), btn->isOn(), | 1264 | btn->colorGroup(), btn->isOn(), |
1261 | btn->isDown(), btn->isEnabled()); | 1265 | btn->isDown(), btn->isEnabled()); |
1262 | else | 1266 | else |
1263 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1267 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1264 | btn->colorGroup(), btn->state(), btn->isDown(), | 1268 | btn->colorGroup(), btn->state(), btn->isDown(), |
1265 | btn->isEnabled()); | 1269 | btn->isEnabled()); |
1266 | p.end(); | 1270 | p.end(); |
1267 | } | 1271 | } |
1268 | } | 1272 | } |
1269 | else if(obj->inherits("QHeader")){ | 1273 | else if(obj->inherits("QHeader")){ |
1270 | QHeader *hw = (QHeader *)obj; | 1274 | QHeader *hw = (QHeader *)obj; |
1271 | if(ev->type() == QEvent::Enter){ | 1275 | if(ev->type() == QEvent::Enter){ |
1272 | currentHeader = hw; | 1276 | currentHeader = hw; |
1273 | headerHoverID = -1; | 1277 | headerHoverID = -1; |
1274 | } | 1278 | } |
1275 | else if(ev->type() == QEvent::Leave){ | 1279 | else if(ev->type() == QEvent::Leave){ |
1276 | currentHeader = NULL; | 1280 | currentHeader = NULL; |
1277 | if(headerHoverID != -1){ | 1281 | if(headerHoverID != -1){ |
1278 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1282 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1279 | hw->sectionSize(headerHoverID), hw->height()); | 1283 | hw->sectionSize(headerHoverID), hw->height()); |
1280 | } | 1284 | } |
1281 | headerHoverID = -1; | 1285 | headerHoverID = -1; |
1282 | } | 1286 | } |
1283 | else if(ev->type() == QEvent::MouseMove){ | 1287 | else if(ev->type() == QEvent::MouseMove){ |
1284 | QMouseEvent *me = (QMouseEvent *)ev; | 1288 | QMouseEvent *me = (QMouseEvent *)ev; |
1285 | int oldHeader = headerHoverID; | 1289 | int oldHeader = headerHoverID; |
1286 | headerHoverID = hw->sectionAt(me->x()); | 1290 | headerHoverID = hw->sectionAt(me->x()); |
1287 | if(oldHeader != headerHoverID){ | 1291 | if(oldHeader != headerHoverID){ |
1288 | // reset old header | 1292 | // reset old header |
1289 | if(oldHeader != -1){ | 1293 | if(oldHeader != -1){ |
1290 | hw->repaint(hw->sectionPos(oldHeader), 0, | 1294 | hw->repaint(hw->sectionPos(oldHeader), 0, |
1291 | hw->sectionSize(oldHeader), hw->height()); | 1295 | hw->sectionSize(oldHeader), hw->height()); |
1292 | } | 1296 | } |
1293 | if(headerHoverID != -1){ | 1297 | if(headerHoverID != -1){ |
1294 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1298 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1295 | hw->sectionSize(headerHoverID), hw->height()); | 1299 | hw->sectionSize(headerHoverID), hw->height()); |
1296 | } | 1300 | } |
1297 | } | 1301 | } |
1298 | } | 1302 | } |
1299 | } | 1303 | } |
1300 | else if (obj-> inherits( "QProgressBar" )) { | 1304 | else if (obj-> inherits( "QProgressBar" )) { |
1301 | if ( ev->type() == QEvent::Paint ) { | 1305 | if ( ev->type() == QEvent::Paint ) { |
1302 | HackProgressBar *p = (HackProgressBar *) obj; | 1306 | HackProgressBar *p = (HackProgressBar *) obj; |
1303 | const QColorGroup &g = p-> colorGroup ( ); | 1307 | const QColorGroup &g = p-> colorGroup ( ); |
1304 | 1308 | ||
1305 | QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); | 1309 | QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); |
1306 | if(!pix){ | 1310 | if(!pix){ |
1307 | int h, s, v; | 1311 | int h, s, v; |
1308 | g.button().dark(120).hsv(&h, &s, &v); | 1312 | g.button().dark(120).hsv(&h, &s, &v); |
1309 | pix = new QPixmap(*bevelFillPix); | 1313 | pix = new QPixmap(*bevelFillPix); |
1310 | adjustHSV(*pix, h, s, v); | 1314 | adjustHSV(*pix, h, s, v); |
1311 | bevelFillDict.insert(g.button().dark(120).rgb(), pix); | 1315 | bevelFillDict.insert(g.button().dark(120).rgb(), pix); |
1312 | } | 1316 | } |
1313 | p-> paint ((QPaintEvent *) ev, g, pix ); | 1317 | p-> paint ((QPaintEvent *) ev, g, pix ); |
1314 | return true; | 1318 | return true; |
1315 | } | 1319 | } |
1316 | } | 1320 | } |
1317 | return false ; | 1321 | return false ; |
1318 | } | 1322 | } |
1319 | 1323 | ||
1320 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 1324 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
1321 | const QColorGroup &g, bool sunken, | 1325 | const QColorGroup &g, bool sunken, |
1322 | const QBrush *) | 1326 | const QBrush *) |
1323 | { | 1327 | { |
1324 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), | 1328 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), |
1325 | x, y, w, h); | 1329 | x, y, w, h); |
1326 | } | 1330 | } |
1327 | 1331 | ||
1328 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | 1332 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, |
1329 | const QColorGroup &g, bool sunken, | 1333 | const QColorGroup &g, bool sunken, |
1330 | const QBrush *) | 1334 | const QBrush *) |
1331 | { | 1335 | { |
1332 | if(p->device()->devType() != QInternal::Widget){ | 1336 | if(p->device()->devType() != QInternal::Widget){ |
1333 | // drawing into a temp pixmap, don't use mask | 1337 | // drawing into a temp pixmap, don't use mask |
1334 | QColor c = sunken ? g.button() : g.background(); | 1338 | QColor c = sunken ? g.button() : g.background(); |
1335 | p->setPen(c.dark(130)); | 1339 | p->setPen(c.dark(130)); |
1336 | p->drawRect(x, y, w, h); | 1340 | p->drawRect(x, y, w, h); |
1337 | p->setPen(c.light(105)); | 1341 | p->setPen(c.light(105)); |
1338 | p->drawRect(x+1, y+1, w-2, h-2); | 1342 | p->drawRect(x+1, y+1, w-2, h-2); |
1339 | 1343 | ||
1340 | 1344 | ||
1341 | // fill | 1345 | // fill |
1342 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1346 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1343 | if(!pix){ | 1347 | if(!pix){ |
1344 | int h, s, v; | 1348 | int h, s, v; |
1345 | c.hsv(&h, &s, &v); | 1349 | c.hsv(&h, &s, &v); |
1346 | pix = new QPixmap(*bevelFillPix); | 1350 | pix = new QPixmap(*bevelFillPix); |
1347 | adjustHSV(*pix, h, s, v); | 1351 | adjustHSV(*pix, h, s, v); |
1348 | bevelFillDict.insert(c.rgb(), pix); | 1352 | bevelFillDict.insert(c.rgb(), pix); |
1349 | } | 1353 | } |
1350 | 1354 | ||
1351 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); | 1355 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); |
1352 | } | 1356 | } |
1353 | else{ | 1357 | else{ |
1354 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : | 1358 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : |
1355 | highlightWidget == p->device() ? g.button().light(110) : | 1359 | highlightWidget == p->device() ? g.button().light(110) : |
1356 | g.background(), g.background()); | 1360 | g.background(), g.background()); |
1357 | } | 1361 | } |
1358 | } | 1362 | } |
1359 | 1363 | ||
1360 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | 1364 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) |
1361 | { | 1365 | { |
1362 | QRect r = btn->rect(); | 1366 | QRect r = btn->rect(); |
1363 | bool sunken = btn->isOn() || btn->isDown(); | 1367 | bool sunken = btn->isOn() || btn->isDown(); |
1364 | QColorGroup g = btn->colorGroup(); | 1368 | QColorGroup g = btn->colorGroup(); |
1365 | 1369 | ||
1366 | 1370 | ||
1367 | //int dw = buttonDefaultIndicatorWidth(); | 1371 | //int dw = buttonDefaultIndicatorWidth(); |
1368 | if(btn->hasFocus() || btn->isDefault()){ | 1372 | if(btn->hasFocus() || btn->isDefault()){ |
1369 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); | 1373 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); |
1370 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1374 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1371 | if(!pix){ | 1375 | if(!pix){ |
1372 | int h, s, v; | 1376 | int h, s, v; |
1373 | c.hsv(&h, &s, &v); | 1377 | c.hsv(&h, &s, &v); |
1374 | pix = new QPixmap(*bevelFillPix); | 1378 | pix = new QPixmap(*bevelFillPix); |
1375 | adjustHSV(*pix, h, s, v); | 1379 | adjustHSV(*pix, h, s, v); |
1376 | bevelFillDict.insert(c.rgb(), pix); | 1380 | bevelFillDict.insert(c.rgb(), pix); |
1377 | } | 1381 | } |
1378 | p->setPen(c.dark(150)); | 1382 | p->setPen(c.dark(150)); |
1379 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1383 | p->drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1380 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1384 | p->drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1381 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1385 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1382 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1386 | p->drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1383 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1387 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1384 | } | 1388 | } |
1385 | 1389 | ||
1386 | QColor newColor = btn == highlightWidget || sunken ? | 1390 | QColor newColor = btn == highlightWidget || sunken ? |
1387 | g.button().light(120) : g.button(); | 1391 | g.button().light(120) : g.button(); |
1388 | 1392 | ||
1389 | drawRoundButton(p, newColor, g.background(), | 1393 | drawRoundButton(p, newColor, g.background(), |
1390 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), | 1394 | r.x(), r.y(), r.width(), r.height(), !btn->autoMask(), |
1391 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), | 1395 | sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(), |
1392 | btn->autoMask()); | 1396 | btn->autoMask()); |
1393 | } | 1397 | } |
1394 | 1398 | ||
1395 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) | 1399 | void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p) |
1396 | { | 1400 | { |
1397 | int x1, y1, x2, y2, w, h; | 1401 | int x1, y1, x2, y2, w, h; |
1398 | btn->rect().coords(&x1, &y1, &x2, &y2); | 1402 | btn->rect().coords(&x1, &y1, &x2, &y2); |
1399 | w = btn->width(); | 1403 | w = btn->width(); |
1400 | h = btn->height(); | 1404 | h = btn->height(); |
1401 | 1405 | ||
1402 | bool act = btn->isOn() || btn->isDown(); | 1406 | bool act = btn->isOn() || btn->isDown(); |
1403 | if(act){ | 1407 | if(act){ |
1404 | ++x1, ++y1; | 1408 | ++x1, ++y1; |
1405 | } | 1409 | } |
1406 | 1410 | ||
1407 | // Draw iconset first, if any | 1411 | // Draw iconset first, if any |
1408 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) | 1412 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) |
1409 | { | 1413 | { |
1410 | QIconSet::Mode mode = btn->isEnabled() | 1414 | QIconSet::Mode mode = btn->isEnabled() |
1411 | ? QIconSet::Normal : QIconSet::Disabled; | 1415 | ? QIconSet::Normal : QIconSet::Disabled; |
1412 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 1416 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
1413 | mode = QIconSet::Active; | 1417 | mode = QIconSet::Active; |
1414 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); | 1418 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); |
1415 | int pixw = pixmap.width(); | 1419 | int pixw = pixmap.width(); |
1416 | int pixh = pixmap.height(); | 1420 | int pixh = pixmap.height(); |
1417 | 1421 | ||
1418 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); | 1422 | p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap ); |
1419 | x1 += pixw + 8; | 1423 | x1 += pixw + 8; |
1420 | w -= pixw + 8; | 1424 | w -= pixw + 8; |
1421 | } | 1425 | } |
1422 | 1426 | ||
1423 | if(act){ | 1427 | if(act){ |
1424 | QFont font = btn->font(); | 1428 | QFont font = btn->font(); |
1425 | font.setBold(true); | 1429 | font.setBold(true); |
1426 | p->setFont(font); | 1430 | p->setFont(font); |
1427 | QColor shadow(btn->colorGroup().button().dark(130)); | 1431 | QColor shadow(btn->colorGroup().button().dark(130)); |
1428 | drawItem( p, x1+1, y1+1, w, h, | 1432 | drawItem( p, x1+1, y1+1, w, h, |
1429 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1433 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1430 | btn->pixmap(), btn->text(), -1, | 1434 | btn->pixmap(), btn->text(), -1, |
1431 | &shadow); | 1435 | &shadow); |
1432 | 1436 | ||
1433 | drawItem( p, x1, y1, w, h, | 1437 | drawItem( p, x1, y1, w, h, |
1434 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1438 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1435 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); | 1439 | btn->pixmap(), btn->text(), -1, &btn->colorGroup().light()); |
1436 | } | 1440 | } |
1437 | else{ | 1441 | else{ |
1438 | /* Too blurry | 1442 | /* Too blurry |
1439 | drawItem( p, x1+1, y1+1, w, h, | 1443 | drawItem( p, x1+1, y1+1, w, h, |
1440 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), | 1444 | AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(), |
1441 | btn->pixmap(), btn->text(), -1, | 1445 | btn->pixmap(), btn->text(), -1, |
1442 | &btn->colorGroup().button().dark(115)); | 1446 | &btn->colorGroup().button().dark(115)); |
1443 | */ | 1447 | */ |
1444 | drawItem( p, x1, y1, w, h, | 1448 | drawItem( p, x1, y1, w, h, |
1445 | AlignCenter | ShowPrefix, | 1449 | AlignCenter | ShowPrefix, |
1446 | btn->colorGroup(), btn->isEnabled(), | 1450 | btn->colorGroup(), btn->isEnabled(), |
1447 | btn->pixmap(), btn->text(), -1, | 1451 | btn->pixmap(), btn->text(), -1, |
1448 | &btn->colorGroup().buttonText()); | 1452 | &btn->colorGroup().buttonText()); |
1449 | } | 1453 | } |
1450 | } | 1454 | } |
1451 | 1455 | ||
1452 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) | 1456 | void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h) |
1453 | { | 1457 | { |
1454 | int x2 = x+w-1; | 1458 | int x2 = x+w-1; |
1455 | int y2 = y+h-1; | 1459 | int y2 = y+h-1; |
1456 | 1460 | ||
1457 | p->setPen(Qt::color1); | 1461 | p->setPen(Qt::color1); |
1458 | p->fillRect(x, y, w, h, Qt::color0); | 1462 | p->fillRect(x, y, w, h, Qt::color0); |
1459 | if(w < 21 || h < 21){ | 1463 | if(w < 21 || h < 21){ |
1460 | // outer rect | 1464 | // outer rect |
1461 | p->drawLine(x, y+2, x, y2-2); // l | 1465 | p->drawLine(x, y+2, x, y2-2); // l |
1462 | p->drawLine(x2, y+2, x2, y2-2); // r | 1466 | p->drawLine(x2, y+2, x2, y2-2); // r |
1463 | p->drawLine(x+2, y, x2-2, y); // t | 1467 | p->drawLine(x+2, y, x2-2, y); // t |
1464 | p->drawLine(x+2, y2, x2-2, y2); // b | 1468 | p->drawLine(x+2, y2, x2-2, y2); // b |
1465 | p->drawLine(x+1, y+1, x2-1, y+1); // top second line | 1469 | p->drawLine(x+1, y+1, x2-1, y+1); // top second line |
1466 | p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line | 1470 | p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line |
1467 | p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); | 1471 | p->fillRect(x+1, y+2, w-2, h-4, Qt::color1); |
1468 | } | 1472 | } |
1469 | else{ | 1473 | else{ |
1470 | int x2 = x+w-1; | 1474 | int x2 = x+w-1; |
1471 | int y2 = y+h-1; | 1475 | int y2 = y+h-1; |
1472 | int bx2 = htmlBtnMaskBmp.width()-1; | 1476 | int bx2 = htmlBtnMaskBmp.width()-1; |
1473 | int by2 = htmlBtnMaskBmp.height()-1; | 1477 | int by2 = htmlBtnMaskBmp.height()-1; |
1474 | p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl | 1478 | p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl |
1475 | p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr | 1479 | p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr |
1476 | p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl | 1480 | p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl |
1477 | p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br | 1481 | p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br |
1478 | // fills | 1482 | // fills |
1479 | p->fillRect(10, 0, w-20, 10, Qt::color1); // top | 1483 | p->fillRect(10, 0, w-20, 10, Qt::color1); // top |
1480 | p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 1484 | p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
1481 | p->fillRect(0, 10, w, h-20, Qt::color1); // middle | 1485 | p->fillRect(0, 10, w, h-20, Qt::color1); // middle |
1482 | } | 1486 | } |
1483 | } | 1487 | } |
1484 | 1488 | ||
1485 | void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, | 1489 | void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, |
1486 | const QColorGroup &g, bool sunken, | 1490 | const QColorGroup &g, bool sunken, |
1487 | const QBrush */*fill*/) | 1491 | const QBrush */*fill*/) |
1488 | { | 1492 | { |
1489 | if(currentHeader && p->device() == currentHeader){ | 1493 | if(currentHeader && p->device() == currentHeader){ |
1490 | int id = currentHeader->sectionAt(x); | 1494 | int id = currentHeader->sectionAt(x); |
1491 | bool isHeaderHover = id != -1 && id == headerHoverID; | 1495 | bool isHeaderHover = id != -1 && id == headerHoverID; |
1492 | drawClearBevel(p, x, y, w, h, sunken ? | 1496 | drawClearBevel(p, x, y, w, h, sunken ? |
1493 | g.button() : isHeaderHover ? g.button().light(110) : | 1497 | g.button() : isHeaderHover ? g.button().light(110) : |
1494 | g.background(), g.background()); | 1498 | g.background(), g.background()); |
1495 | } | 1499 | } |
1496 | else | 1500 | else |
1497 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), | 1501 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), |
1498 | g.background()); | 1502 | g.background()); |
1499 | } | 1503 | } |
1500 | 1504 | ||
1501 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) | 1505 | QRect LiquidStyle::buttonRect(int x, int y, int w, int h) |
1502 | { | 1506 | { |
1503 | return(QRect(x+5, y+5, w-10, h-10)); | 1507 | return(QRect(x+5, y+5, w-10, h-10)); |
1504 | } | 1508 | } |
1505 | 1509 | ||
1506 | void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, | 1510 | void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, |
1507 | const QColorGroup &g, bool sunken, | 1511 | const QColorGroup &g, bool sunken, |
1508 | bool edit, bool, const QBrush *) | 1512 | bool edit, bool, const QBrush *) |
1509 | { | 1513 | { |
1510 | bool isHover = highlightWidget == painter->device(); | 1514 | bool isHover = highlightWidget == painter->device(); |
1511 | bool isMasked = false; | 1515 | bool isMasked = false; |
1512 | if(painter->device()->devType() == QInternal::Widget) | 1516 | if(painter->device()->devType() == QInternal::Widget) |
1513 | isMasked = ((QWidget*)painter->device())->autoMask(); | 1517 | isMasked = ((QWidget*)painter->device())->autoMask(); |
1514 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap | 1518 | // TODO: Do custom code, don't just call drawRoundButton into a pixmap |
1515 | QPixmap tmpPix(w, h); | 1519 | QPixmap tmpPix(w, h); |
1516 | QPainter p(&tmpPix); | 1520 | QPainter p(&tmpPix); |
1517 | 1521 | ||
1518 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, | 1522 | drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, |
1519 | sunken, false, isMasked); | 1523 | sunken, false, isMasked); |
1520 | if(!isHover){ | 1524 | if(!isHover){ |
1521 | p.setClipRect(0, 0, w-17, h); | 1525 | p.setClipRect(0, 0, w-17, h); |
1522 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, | 1526 | drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, |
1523 | sunken, false, isMasked); | 1527 | sunken, false, isMasked); |
1524 | } | 1528 | } |
1525 | p.end(); | 1529 | p.end(); |
1526 | int x2 = x+w-1; | 1530 | int x2 = x+w-1; |
1527 | int y2 = y+h-1; | 1531 | int y2 = y+h-1; |
1528 | int bx2 = btnMaskBmp.width()-1; | 1532 | int bx2 = btnMaskBmp.width()-1; |
1529 | int by2 = btnMaskBmp.height()-1; | 1533 | int by2 = btnMaskBmp.height()-1; |
1530 | QBitmap btnMask(w, h); | 1534 | QBitmap btnMask(w, h); |
1531 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; | 1535 | QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; |
1532 | p.begin(&btnMask); | 1536 | p.begin(&btnMask); |
1533 | p.fillRect(0, 0, w, h, Qt::color0); | 1537 | p.fillRect(0, 0, w, h, Qt::color0); |
1534 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl | 1538 | p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl |
1535 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr | 1539 | p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr |
1536 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl | 1540 | p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl |
1537 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br | 1541 | p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br |
1538 | // fills | 1542 | // fills |
1539 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top | 1543 | p.fillRect(10, 0, w-20, 10, Qt::color1); // top |
1540 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom | 1544 | p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom |
1541 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle | 1545 | p.fillRect(0, 10, w, h-20, Qt::color1); // middle |
1542 | p.end(); | 1546 | p.end(); |
1543 | tmpPix.setMask(btnMask); | 1547 | tmpPix.setMask(btnMask); |
1544 | 1548 | ||
1545 | painter->drawPixmap(x, y, tmpPix); | 1549 | painter->drawPixmap(x, y, tmpPix); |
1546 | 1550 | ||
1547 | painter->setPen(g.button().dark(120)); | 1551 | painter->setPen(g.button().dark(120)); |
1548 | painter->drawLine(x2-16, y+1, x2-16, y2-1); | 1552 | painter->drawLine(x2-16, y+1, x2-16, y2-1); |
1549 | 1553 | ||
1550 | if(edit){ | 1554 | if(edit){ |
1551 | painter->setPen(g.mid()); | 1555 | painter->setPen(g.mid()); |
1552 | painter->drawRect(x+8, y+2, w-25, h-4); | 1556 | painter->drawRect(x+8, y+2, w-25, h-4); |
1553 | } | 1557 | } |
1554 | int arrow_h = h / 3; | 1558 | int arrow_h = h / 3; |
1555 | int arrow_w = arrow_h; | 1559 | int arrow_w = arrow_h; |
1556 | int arrow_x = w - arrow_w - 6; | 1560 | int arrow_x = w - arrow_w - 6; |
1557 | int arrow_y = (h - arrow_h) / 2; | 1561 | int arrow_y = (h - arrow_h) / 2; |
1558 | drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); | 1562 | drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true); |
1559 | } | 1563 | } |
1560 | 1564 | ||
1561 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) | 1565 | void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h) |
1562 | { | 1566 | { |
1563 | drawButtonMask(p, x, y, w, h); | 1567 | drawButtonMask(p, x, y, w, h); |
1564 | } | 1568 | } |
1565 | 1569 | ||
1566 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) | 1570 | QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h) |
1567 | { | 1571 | { |
1568 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); | 1572 | //return(QRect(x+3, y+3, w - (h / 3) - 13, h-6)); |
1569 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); | 1573 | return(QRect(x+9, y+3, w - (h / 3) - 20, h-6)); |
1570 | } | 1574 | } |
1571 | 1575 | ||
1572 | QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) | 1576 | QRect LiquidStyle::comboButtonFocusRect(int x, int y, int w, int h) |
1573 | { | 1577 | { |
1574 | return(QRect(x+5, y+3, w-(h/3)-13, h-5)); | 1578 | return(QRect(x+5, y+3, w-(h/3)-13, h-5)); |
1575 | } | 1579 | } |
1576 | 1580 | ||
1577 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, | 1581 | void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb, |
1578 | int sliderStart, uint controls, | 1582 | int sliderStart, uint controls, |
1579 | uint activeControl) | 1583 | uint activeControl) |
1580 | { | 1584 | { |
1581 | bool isHover = highlightWidget == p->device(); | 1585 | bool isHover = highlightWidget == p->device(); |
1582 | int sliderMin, sliderMax, sliderLength, buttonDim; | 1586 | int sliderMin, sliderMax, sliderLength, buttonDim; |
1583 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 1587 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
1584 | 1588 | ||
1585 | if (sliderStart > sliderMax) | 1589 | if (sliderStart > sliderMax) |
1586 | sliderStart = sliderMax; | 1590 | sliderStart = sliderMax; |
1587 | 1591 | ||
1588 | bool horiz = sb->orientation() == QScrollBar::Horizontal; | 1592 | bool horiz = sb->orientation() == QScrollBar::Horizontal; |
1589 | QColorGroup g = sb->colorGroup(); | 1593 | QColorGroup g = sb->colorGroup(); |
1590 | QRect addB, subHC, subB; | 1594 | QRect addB, subHC, subB; |
1591 | QRect addPageR, subPageR, sliderR; | 1595 | QRect addPageR, subPageR, sliderR; |
1592 | int addX, addY, subX, subY; | 1596 | int addX, addY, subX, subY; |
1593 | int len = horiz ? sb->width() : sb->height(); | 1597 | int len = horiz ? sb->width() : sb->height(); |
1594 | int extent = horiz ? sb->height() : sb->width(); | 1598 | int extent = horiz ? sb->height() : sb->width(); |
1595 | 1599 | ||
1596 | // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar | 1600 | // a few apps (ie: KSpread), are broken and use a hardcoded scrollbar |
1597 | // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. | 1601 | // extent of 16. Luckily, most apps (ie: Kate), seem fixed by now. |
1598 | bool brokenApp; | 1602 | bool brokenApp; |
1599 | if(extent == 16) | 1603 | if(extent == 16) |
1600 | brokenApp = true; | 1604 | brokenApp = true; |
1601 | else | 1605 | else |
1602 | brokenApp = false; | 1606 | brokenApp = false; |
1603 | 1607 | ||
1604 | if (horiz) { | 1608 | if (horiz) { |
1605 | subY = addY = ( extent - buttonDim ) / 2; | 1609 | subY = addY = ( extent - buttonDim ) / 2; |
1606 | subX = 0; | 1610 | subX = 0; |
1607 | addX = len - buttonDim; | 1611 | addX = len - buttonDim; |
1608 | if(sbBuffer.size() != sb->size()) | 1612 | if(sbBuffer.size() != sb->size()) |
1609 | sbBuffer.resize(sb->size()); | 1613 | sbBuffer.resize(sb->size()); |
1610 | } | 1614 | } |
1611 | else { | 1615 | else { |
1612 | subX = addX = ( extent - buttonDim ) / 2; | 1616 | subX = addX = ( extent - buttonDim ) / 2; |
1613 | subY = 0; | 1617 | subY = 0; |
1614 | addY = len - buttonDim; | 1618 | addY = len - buttonDim; |
1615 | if(sbBuffer.size() != sb->size()) | 1619 | if(sbBuffer.size() != sb->size()) |
1616 | sbBuffer.resize(sb->size()); | 1620 | sbBuffer.resize(sb->size()); |
1617 | } | 1621 | } |
1618 | subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); | 1622 | subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); |
1619 | addB.setRect( addX,addY,buttonDim,buttonDim ); | 1623 | addB.setRect( addX,addY,buttonDim,buttonDim ); |
1620 | if(horiz) | 1624 | if(horiz) |
1621 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); | 1625 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); |
1622 | else | 1626 | else |
1623 | subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); | 1627 | subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim ); |
1624 | 1628 | ||
1625 | int sliderEnd = sliderStart + sliderLength; | 1629 | int sliderEnd = sliderStart + sliderLength; |
1626 | int sliderW = extent; | 1630 | int sliderW = extent; |
1627 | 1631 | ||
1628 | if (horiz) { | 1632 | if (horiz) { |
1629 | subPageR.setRect( subB.right() + 1, 0, | 1633 | subPageR.setRect( subB.right() + 1, 0, |
1630 | sliderStart - subB.right() - 1 , sliderW ); | 1634 | sliderStart - subB.right() - 1 , sliderW ); |
1631 | addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); | 1635 | addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW ); |
1632 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); | 1636 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); |
1633 | } | 1637 | } |
1634 | else { | 1638 | else { |
1635 | subPageR.setRect( 0, subB.bottom() + 1, sliderW, | 1639 | subPageR.setRect( 0, subB.bottom() + 1, sliderW, |
1636 | sliderStart - subB.bottom() - 1 ); | 1640 | sliderStart - subB.bottom() - 1 ); |
1637 | addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); | 1641 | addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd); |
1638 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); | 1642 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); |
1639 | } | 1643 | } |
1640 | 1644 | ||
1641 | bool maxed = sb->maxValue() == sb->minValue(); | 1645 | bool maxed = sb->maxValue() == sb->minValue(); |
1642 | 1646 | ||
1643 | QPainter painter; | 1647 | QPainter painter; |
1644 | if(!horiz){ | 1648 | if(!horiz){ |
1645 | painter.begin(&sbBuffer); | 1649 | painter.begin(&sbBuffer); |
1646 | QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); | 1650 | QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); |
1647 | if(sliderR.height() >= 8){ | 1651 | if(sliderR.height() >= 8){ |
1648 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, | 1652 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, |
1649 | 13, 8); | 1653 | 13, 8); |
1650 | painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); | 1654 | painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg)); |
1651 | painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, | 1655 | painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13, |
1652 | bgR.height()-16, *getPixmap(VSBSliderMidBg)); | 1656 | bgR.height()-16, *getPixmap(VSBSliderMidBg)); |
1653 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, | 1657 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix, |
1654 | 0, 0, 13, 8); | 1658 | 0, 0, 13, 8); |
1655 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); | 1659 | painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg)); |
1656 | } | 1660 | } |
1657 | else{ | 1661 | else{ |
1658 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), | 1662 | painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(), |
1659 | *getPixmap(VSBSliderMidBg)); | 1663 | *getPixmap(VSBSliderMidBg)); |
1660 | painter.setPen(g.background().dark(210)); | 1664 | painter.setPen(g.background().dark(210)); |
1661 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); | 1665 | painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1); |
1662 | painter.setPen(g.mid()); | 1666 | painter.setPen(g.mid()); |
1663 | painter.drawPoint(bgR.x()+1, bgR.y()); | 1667 | painter.drawPoint(bgR.x()+1, bgR.y()); |
1664 | painter.drawPoint(bgR.x()+13, bgR.y()); | 1668 | painter.drawPoint(bgR.x()+13, bgR.y()); |
1665 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); | 1669 | painter.drawPoint(bgR.x()+1, bgR.bottom()-1); |
1666 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); | 1670 | painter.drawPoint(bgR.x()+13, bgR.bottom()-1); |
1667 | } | 1671 | } |
1668 | if(controls & Slider){ | 1672 | if(controls & Slider){ |
1669 | if(sliderR.height() >= 16){ | 1673 | if(sliderR.height() >= 16){ |
1670 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), | 1674 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), |
1671 | isHover ? *getPixmap(VSBSliderTopHover): | 1675 | isHover ? *getPixmap(VSBSliderTopHover): |
1672 | *getPixmap(VSBSliderTop)); | 1676 | *getPixmap(VSBSliderTop)); |
1673 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, | 1677 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13, |
1674 | sliderR.height()-16, isHover ? | 1678 | sliderR.height()-16, isHover ? |
1675 | *getPixmap(VSBSliderMidHover) : | 1679 | *getPixmap(VSBSliderMidHover) : |
1676 | *getPixmap(VSBSliderMid)); | 1680 | *getPixmap(VSBSliderMid)); |
1677 | painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, | 1681 | painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, |
1678 | isHover ? *getPixmap(VSBSliderBtmHover) : | 1682 | isHover ? *getPixmap(VSBSliderBtmHover) : |
1679 | *getPixmap(VSBSliderBtm)); | 1683 | *getPixmap(VSBSliderBtm)); |
1680 | } | 1684 | } |
1681 | else if(sliderR.height() >= 8){ | 1685 | else if(sliderR.height() >= 8){ |
1682 | int m = sliderR.height()/2; | 1686 | int m = sliderR.height()/2; |
1683 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), | 1687 | painter.drawPixmap(sliderR.x()+1, sliderR.y(), |
1684 | isHover ? *getPixmap(VSBSliderTopHover): | 1688 | isHover ? *getPixmap(VSBSliderTopHover): |
1685 | *getPixmap(VSBSliderTop), 0, 0, 13, m); | 1689 | *getPixmap(VSBSliderTop), 0, 0, 13, m); |
1686 | painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, | 1690 | painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, |
1687 | isHover ? *getPixmap(VSBSliderBtmHover): | 1691 | isHover ? *getPixmap(VSBSliderBtmHover): |
1688 | *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); | 1692 | *getPixmap(VSBSliderBtm), 0, 8-m, 13, m); |
1689 | } | 1693 | } |
1690 | else{ | 1694 | else{ |
1691 | painter.setPen(g.button().dark(210)); | 1695 | painter.setPen(g.button().dark(210)); |
1692 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), | 1696 | drawRoundRect(&painter, sliderR.x()+1, sliderR.y(), |
1693 | 13, sliderR.height()); | 1697 | 13, sliderR.height()); |
1694 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, | 1698 | painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1, |
1695 | 11, sliderR.height()-2, | 1699 | 11, sliderR.height()-2, |
1696 | isHover ? *getPixmap(VSBSliderMidHover) : | 1700 | isHover ? *getPixmap(VSBSliderMidHover) : |
1697 | *getPixmap(VSBSliderMid), 1, 0); | 1701 | *getPixmap(VSBSliderMid), 1, 0); |
1698 | } | 1702 | } |
1699 | } | 1703 | } |
1700 | painter.setPen(g.mid()); | 1704 | painter.setPen(g.mid()); |
1701 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); | 1705 | painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom()); |
1702 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); | 1706 | painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom()); |
1703 | if(brokenApp && (controls & Slider)){ | 1707 | if(brokenApp && (controls & Slider)){ |
1704 | painter.setPen(g.background()); | 1708 | painter.setPen(g.background()); |
1705 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, | 1709 | painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1, |
1706 | bgR.bottom()); | 1710 | bgR.bottom()); |
1707 | } | 1711 | } |
1708 | painter.end(); | 1712 | painter.end(); |
1709 | } | 1713 | } |
1710 | else{ | 1714 | else{ |
1711 | painter.begin(&sbBuffer); | 1715 | painter.begin(&sbBuffer); |
1712 | QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); | 1716 | QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); |
1713 | if(sliderR.width() >= 8){ | 1717 | if(sliderR.width() >= 8){ |
1714 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, | 1718 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, |
1715 | 8, 13); | 1719 | 8, 13); |
1716 | painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); | 1720 | painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg)); |
1717 | painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, | 1721 | painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16, |
1718 | 13, *getPixmap(HSBSliderMidBg)); | 1722 | 13, *getPixmap(HSBSliderMidBg)); |
1719 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, | 1723 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix, |
1720 | 0, 0, 8, 13); | 1724 | 0, 0, 8, 13); |
1721 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); | 1725 | painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg)); |
1722 | } | 1726 | } |
1723 | else{ | 1727 | else{ |
1724 | painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, | 1728 | painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13, |
1725 | *getPixmap(HSBSliderMidBg)); | 1729 | *getPixmap(HSBSliderMidBg)); |
1726 | painter.setPen(g.background().dark(210)); | 1730 | painter.setPen(g.background().dark(210)); |
1727 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); | 1731 | painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13); |
1728 | painter.setPen(g.mid()); | 1732 | painter.setPen(g.mid()); |
1729 | painter.drawPoint(bgR.x(), bgR.y()+1); | 1733 | painter.drawPoint(bgR.x(), bgR.y()+1); |
1730 | painter.drawPoint(bgR.x(), bgR.bottom()-1); | 1734 | painter.drawPoint(bgR.x(), bgR.bottom()-1); |
1731 | painter.drawPoint(bgR.right()-1, bgR.y()+1); | 1735 | painter.drawPoint(bgR.right()-1, bgR.y()+1); |
1732 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); | 1736 | painter.drawPoint(bgR.right()-1, bgR.bottom()-1); |
1733 | } | 1737 | } |
1734 | if(controls & Slider){ | 1738 | if(controls & Slider){ |
1735 | if(sliderR.width() >= 16){ | 1739 | if(sliderR.width() >= 16){ |
1736 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, | 1740 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, |
1737 | isHover ? *getPixmap(HSBSliderTopHover) : | 1741 | isHover ? *getPixmap(HSBSliderTopHover) : |
1738 | *getPixmap(HSBSliderTop)); | 1742 | *getPixmap(HSBSliderTop)); |
1739 | painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, | 1743 | painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16, |
1740 | 13, isHover ? *getPixmap(HSBSliderMidHover) : | 1744 | 13, isHover ? *getPixmap(HSBSliderMidHover) : |
1741 | *getPixmap(HSBSliderMid)); | 1745 | *getPixmap(HSBSliderMid)); |
1742 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? | 1746 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? |
1743 | *getPixmap(HSBSliderBtmHover) : | 1747 | *getPixmap(HSBSliderBtmHover) : |
1744 | *getPixmap(HSBSliderBtm)); | 1748 | *getPixmap(HSBSliderBtm)); |
1745 | } | 1749 | } |
1746 | else if(sliderR.width() >= 8){ | 1750 | else if(sliderR.width() >= 8){ |
1747 | int m = sliderR.width()/2; | 1751 | int m = sliderR.width()/2; |
1748 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, | 1752 | painter.drawPixmap(sliderR.x(), sliderR.y()+1, |
1749 | isHover ? *getPixmap(HSBSliderTopHover) : | 1753 | isHover ? *getPixmap(HSBSliderTopHover) : |
1750 | *getPixmap(HSBSliderTop), 0, 0, m, 13); | 1754 | *getPixmap(HSBSliderTop), 0, 0, m, 13); |
1751 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? | 1755 | painter.drawPixmap(sliderR.right()-8, sliderR.y()+1, isHover ? |
1752 | *getPixmap(HSBSliderBtmHover) : | 1756 | *getPixmap(HSBSliderBtmHover) : |
1753 | *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); | 1757 | *getPixmap(HSBSliderBtm), 8-m, 0, m, 13); |
1754 | } | 1758 | } |
1755 | else{ | 1759 | else{ |
1756 | painter.setPen(g.button().dark(210)); | 1760 | painter.setPen(g.button().dark(210)); |
1757 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, | 1761 | drawRoundRect(&painter, sliderR.x(), sliderR.y()+1, |
1758 | sliderR.width(), 13); | 1762 | sliderR.width(), 13); |
1759 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, | 1763 | painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2, |
1760 | sliderR.width()-2, 11, isHover ? | 1764 | sliderR.width()-2, 11, isHover ? |
1761 | *getPixmap(HSBSliderMidHover) : | 1765 | *getPixmap(HSBSliderMidHover) : |
1762 | *getPixmap(HSBSliderMid), 0, 1); | 1766 | *getPixmap(HSBSliderMid), 0, 1); |
1763 | } | 1767 | } |
1764 | } | 1768 | } |
1765 | painter.setPen(g.mid()); | 1769 | painter.setPen(g.mid()); |
1766 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); | 1770 | painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y()); |
1767 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); | 1771 | painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom()); |
1768 | if(brokenApp && (controls & Slider)){ | 1772 | if(brokenApp && (controls & Slider)){ |
1769 | painter.setPen(g.background()); | 1773 | painter.setPen(g.background()); |
1770 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), | 1774 | painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(), |
1771 | bgR.bottom()-1); | 1775 | bgR.bottom()-1); |
1772 | } | 1776 | } |
1773 | painter.end(); | 1777 | painter.end(); |
1774 | } | 1778 | } |
1775 | 1779 | ||
1776 | if ( controls & AddLine ) { | 1780 | if ( controls & AddLine ) { |
1777 | drawSBButton(p, addB, g, activeControl == AddLine); | 1781 | drawSBButton(p, addB, g, activeControl == AddLine); |
1778 | drawArrow( p, horiz ? RightArrow : DownArrow, | 1782 | drawArrow( p, horiz ? RightArrow : DownArrow, |
1779 | false, addB.x()+4, addB.y()+4, | 1783 | false, addB.x()+4, addB.y()+4, |
1780 | addB.width()-8, addB.height()-8, g, !maxed); | 1784 | addB.width()-8, addB.height()-8, g, !maxed); |
1781 | } | 1785 | } |
1782 | if ( controls & SubLine ) { | 1786 | if ( controls & SubLine ) { |
1783 | // drawSBButton(p, subB, g, activeControl == SubLine); | 1787 | // drawSBButton(p, subB, g, activeControl == SubLine); |
1784 | // drawArrow( p, horiz ? LeftArrow : UpArrow, | 1788 | // drawArrow( p, horiz ? LeftArrow : UpArrow, |
1785 | // false, subB.x()+4, subB.y()+4, | 1789 | // false, subB.x()+4, subB.y()+4, |
1786 | // subB.width()-8, subB.height()-8, g, !maxed); | 1790 | // subB.width()-8, subB.height()-8, g, !maxed); |
1787 | drawSBButton(p, subHC, g, activeControl == SubLine); | 1791 | drawSBButton(p, subHC, g, activeControl == SubLine); |
1788 | drawArrow( p, horiz ? LeftArrow : UpArrow, | 1792 | drawArrow( p, horiz ? LeftArrow : UpArrow, |
1789 | false, subHC.x()+4, subHC.y()+4, | 1793 | false, subHC.x()+4, subHC.y()+4, |
1790 | subHC.width()-8, subHC.height()-8, g, !maxed); | 1794 | subHC.width()-8, subHC.height()-8, g, !maxed); |
1791 | } | 1795 | } |
1792 | 1796 | ||
1793 | if(controls & AddPage){ | 1797 | if(controls & AddPage){ |
1794 | if(addPageR.width()){ | 1798 | if(addPageR.width()){ |
1795 | p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, | 1799 | p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer, |
1796 | addPageR.x(), addPageR.y(), addPageR.width(), | 1800 | addPageR.x(), addPageR.y(), addPageR.width(), |
1797 | addPageR.height()); | 1801 | addPageR.height()); |
1798 | } | 1802 | } |
1799 | } | 1803 | } |
1800 | if(controls & SubPage){ | 1804 | if(controls & SubPage){ |
1801 | if(subPageR.height()){ | 1805 | if(subPageR.height()){ |
1802 | p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, | 1806 | p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer, |
1803 | subPageR.x(), subPageR.y(), subPageR.width(), | 1807 | subPageR.x(), subPageR.y(), subPageR.width(), |
1804 | subPageR.height()); | 1808 | subPageR.height()); |
1805 | } | 1809 | } |
1806 | } | 1810 | } |
1807 | if ( controls & Slider ) { | 1811 | if ( controls & Slider ) { |
1808 | p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, | 1812 | p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer, |
1809 | sliderR.x(), sliderR.y(), sliderR.width(), | 1813 | sliderR.x(), sliderR.y(), sliderR.width(), |
1810 | sliderR.height()); | 1814 | sliderR.height()); |
1811 | } | 1815 | } |
1812 | } | 1816 | } |
1813 | 1817 | ||
1814 | void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, | 1818 | void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g, |
1815 | bool down, bool /*fast*/) | 1819 | bool down, bool /*fast*/) |
1816 | { | 1820 | { |
1817 | p->setPen(g.mid()); | 1821 | p->setPen(g.mid()); |
1818 | p->drawRect(r); | 1822 | p->drawRect(r); |
1819 | QColor c(down ? g.button() : g.background()); | 1823 | QColor c(down ? g.button() : g.background()); |
1820 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1824 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1821 | if(!pix){ | 1825 | if(!pix){ |
1822 | int h, s, v; | 1826 | int h, s, v; |
1823 | c.hsv(&h, &s, &v); | 1827 | c.hsv(&h, &s, &v); |
1824 | pix = new QPixmap(*bevelFillPix); | 1828 | pix = new QPixmap(*bevelFillPix); |
1825 | adjustHSV(*pix, h, s, v); | 1829 | adjustHSV(*pix, h, s, v); |
1826 | bevelFillDict.insert(c.rgb(), pix); | 1830 | bevelFillDict.insert(c.rgb(), pix); |
1827 | } | 1831 | } |
1828 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); | 1832 | p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix); |
1829 | 1833 | ||
1830 | } | 1834 | } |
1831 | 1835 | ||
1832 | void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, | 1836 | void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g, |
1833 | bool horiz) | 1837 | bool horiz) |
1834 | { | 1838 | { |
1835 | if(horiz){ | 1839 | if(horiz){ |
1836 | if(r.width() >= 15){ | 1840 | if(r.width() >= 15){ |
1837 | int y = r.y()+3; | 1841 | int y = r.y()+3; |
1838 | int x = r.x() + (r.width()-7)/2; | 1842 | int x = r.x() + (r.width()-7)/2; |
1839 | int y2 = r.bottom()-3; | 1843 | int y2 = r.bottom()-3; |
1840 | p->setPen(g.light()); | 1844 | p->setPen(g.light()); |
1841 | p->drawLine(x, y, x, y2); | 1845 | p->drawLine(x, y, x, y2); |
1842 | p->drawLine(x+3, y, x+3, y2); | 1846 | p->drawLine(x+3, y, x+3, y2); |
1843 | p->drawLine(x+6, y, x+6, y2); | 1847 | p->drawLine(x+6, y, x+6, y2); |
1844 | 1848 | ||
1845 | p->setPen(g.mid()); | 1849 | p->setPen(g.mid()); |
1846 | p->drawLine(x+1, y, x+1, y2); | 1850 | p->drawLine(x+1, y, x+1, y2); |
1847 | p->drawLine(x+4, y, x+4, y2); | 1851 | p->drawLine(x+4, y, x+4, y2); |
1848 | p->drawLine(x+7, y, x+7, y2); | 1852 | p->drawLine(x+7, y, x+7, y2); |
1849 | } | 1853 | } |
1850 | } | 1854 | } |
1851 | else{ | 1855 | else{ |
1852 | if(r.height() >= 15){ | 1856 | if(r.height() >= 15){ |
1853 | int x = r.x()+3; | 1857 | int x = r.x()+3; |
1854 | int y = r.y() + (r.height()-7)/2; | 1858 | int y = r.y() + (r.height()-7)/2; |
1855 | int x2 = r.right()-3; | 1859 | int x2 = r.right()-3; |
1856 | p->setPen(g.light()); | 1860 | p->setPen(g.light()); |
1857 | p->drawLine(x, y, x2, y); | 1861 | p->drawLine(x, y, x2, y); |
1858 | p->drawLine(x, y+3, x2, y+3); | 1862 | p->drawLine(x, y+3, x2, y+3); |
1859 | p->drawLine(x, y+6, x2, y+6); | 1863 | p->drawLine(x, y+6, x2, y+6); |
1860 | 1864 | ||
1861 | p->setPen(g.mid()); | 1865 | p->setPen(g.mid()); |
1862 | p->drawLine(x, y+1, x2, y+1); | 1866 | p->drawLine(x, y+1, x2, y+1); |
1863 | p->drawLine(x, y+4, x2, y+4); | 1867 | p->drawLine(x, y+4, x2, y+4); |
1864 | p->drawLine(x, y+7, x2, y+7); | 1868 | p->drawLine(x, y+7, x2, y+7); |
1865 | } | 1869 | } |
1866 | } | 1870 | } |
1867 | 1871 | ||
1868 | } | 1872 | } |
1869 | 1873 | ||
1870 | 1874 | ||
1871 | void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, | 1875 | void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, |
1872 | int &sliderMax, int &sliderLength, | 1876 | int &sliderMax, int &sliderLength, |
1873 | int &buttonDim) | 1877 | int &buttonDim) |
1874 | { | 1878 | { |
1875 | 1879 | ||
1876 | int maxLength; | 1880 | int maxLength; |
1877 | int b = 0; | 1881 | int b = 0; |
1878 | bool horiz = sb->orientation() == QScrollBar::Horizontal; | 1882 | bool horiz = sb->orientation() == QScrollBar::Horizontal; |
1879 | int length = horiz ? sb->width() : sb->height(); | 1883 | int length = horiz ? sb->width() : sb->height(); |
1880 | int extent = horiz ? sb->height() : sb->width(); | 1884 | int extent = horiz ? sb->height() : sb->width(); |
1881 | 1885 | ||
1882 | if ( length > ( extent - b*2 - 1 )*2 + b*2 ) | 1886 | if ( length > ( extent - b*2 - 1 )*2 + b*2 ) |
1883 | buttonDim = extent - b*2; | 1887 | buttonDim = extent - b*2; |
1884 | else | 1888 | else |
1885 | buttonDim = ( length - b*2 )/2 - 1; | 1889 | buttonDim = ( length - b*2 )/2 - 1; |
1886 | 1890 | ||
1887 | sliderMin = b + 0; // buttonDim; | 1891 | sliderMin = b + 0; // buttonDim; |
1888 | maxLength = length - b*2 - buttonDim*2; // 3; | 1892 | maxLength = length - b*2 - buttonDim*2; // 3; |
1889 | 1893 | ||
1890 | if ( sb->maxValue() == sb->minValue() ) { | 1894 | if ( sb->maxValue() == sb->minValue() ) { |
1891 | sliderLength = maxLength; | 1895 | sliderLength = maxLength; |
1892 | } else { | 1896 | } else { |
1893 | sliderLength = (sb->pageStep()*maxLength)/ | 1897 | sliderLength = (sb->pageStep()*maxLength)/ |
1894 | (sb->maxValue()-sb->minValue()+sb->pageStep()); | 1898 | (sb->maxValue()-sb->minValue()+sb->pageStep()); |
1895 | uint range = sb->maxValue()-sb->minValue(); | 1899 | uint range = sb->maxValue()-sb->minValue(); |
1896 | if ( sliderLength < 9 || range > INT_MAX/2 ) | 1900 | if ( sliderLength < 9 || range > INT_MAX/2 ) |
1897 | sliderLength = 9; | 1901 | sliderLength = 9; |
1898 | if ( sliderLength > maxLength ) | 1902 | if ( sliderLength > maxLength ) |
1899 | sliderLength = maxLength; | 1903 | sliderLength = maxLength; |
1900 | } | 1904 | } |
1901 | sliderMax = sliderMin + maxLength - sliderLength; | 1905 | sliderMax = sliderMin + maxLength - sliderLength; |
1902 | 1906 | ||
1903 | } | 1907 | } |
1904 | 1908 | ||
1905 | QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, | 1909 | QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, |
1906 | int sliderStart, | 1910 | int sliderStart, |
1907 | const QPoint &p) | 1911 | const QPoint &p) |
1908 | { | 1912 | { |
1909 | if ( !sb->rect().contains( p ) ) | 1913 | if ( !sb->rect().contains( p ) ) |
1910 | return NoScroll; | 1914 | return NoScroll; |
1911 | int sliderMin, sliderMax, sliderLength, buttonDim, pos; | 1915 | int sliderMin, sliderMax, sliderLength, buttonDim, pos; |
1912 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 1916 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
1913 | pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y(); | 1917 | pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y(); |
1914 | if ( pos < sliderMin ) | 1918 | if ( pos < sliderMin ) |
1915 | return SubLine; | 1919 | return SubLine; |
1916 | if ( pos < sliderStart ) | 1920 | if ( pos < sliderStart ) |
1917 | return SubPage; | 1921 | return SubPage; |
1918 | if ( pos < sliderStart + sliderLength ) | 1922 | if ( pos < sliderStart + sliderLength ) |
1919 | return Slider; | 1923 | return Slider; |
1920 | if ( pos < sliderMax + sliderLength) | 1924 | if ( pos < sliderMax + sliderLength) |
1921 | return AddPage; | 1925 | return AddPage; |
1922 | if(pos > sliderMax + sliderLength + 16) | 1926 | if(pos > sliderMax + sliderLength + 16) |
1923 | return AddLine; | 1927 | return AddLine; |
1924 | 1928 | ||
1925 | return SubLine; | 1929 | return SubLine; |
1926 | } | 1930 | } |
1927 | 1931 | ||
1928 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 1932 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
1929 | 1933 | ||
1930 | 1934 | ||
1931 | QSize LiquidStyle::exclusiveIndicatorSize() const | 1935 | QSize LiquidStyle::exclusiveIndicatorSize() const |
1932 | { | 1936 | { |
1933 | return(QSize(16, 16)); | 1937 | return(QSize(16, 16)); |
1934 | } | 1938 | } |
1935 | 1939 | ||
1936 | void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, | 1940 | void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, |
1937 | int /*h*/, const QColorGroup &/*g*/, bool on, | 1941 | int /*h*/, const QColorGroup &/*g*/, bool on, |
1938 | bool down, bool) | 1942 | bool down, bool) |
1939 | { | 1943 | { |
1940 | bool isHover = highlightWidget == p->device(); | 1944 | bool isHover = highlightWidget == p->device(); |
1941 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget | 1945 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget |
1942 | && ((QWidget*)p->device())->autoMask(); | 1946 | && ((QWidget*)p->device())->autoMask(); |
1943 | 1947 | ||
1944 | if(isMasked){ | 1948 | if(isMasked){ |
1945 | if(on || down){ | 1949 | if(on || down){ |
1946 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) : | 1950 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) : |
1947 | *getPixmap(HTMLRadioDown)); | 1951 | *getPixmap(HTMLRadioDown)); |
1948 | } | 1952 | } |
1949 | else | 1953 | else |
1950 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) : | 1954 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) : |
1951 | *getPixmap(HTMLRadio)); | 1955 | *getPixmap(HTMLRadio)); |
1952 | 1956 | ||
1953 | } | 1957 | } |
1954 | else{ | 1958 | else{ |
1955 | if(on || down){ | 1959 | if(on || down){ |
1956 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) : | 1960 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) : |
1957 | *getPixmap(RadioOn)); | 1961 | *getPixmap(RadioOn)); |
1958 | } | 1962 | } |
1959 | else | 1963 | else |
1960 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) : | 1964 | p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) : |
1961 | *getPixmap(RadioOff)); | 1965 | *getPixmap(RadioOff)); |
1962 | } | 1966 | } |
1963 | } | 1967 | } |
1964 | 1968 | ||
1965 | void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, | 1969 | void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, |
1966 | int h, bool) | 1970 | int h, bool) |
1967 | { | 1971 | { |
1968 | p->fillRect(x, y, w, h, Qt::color0); | 1972 | p->fillRect(x, y, w, h, Qt::color0); |
1969 | p->setPen(Qt::color1); | 1973 | p->setPen(Qt::color1); |
1970 | p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); | 1974 | p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); |
1971 | } | 1975 | } |
1972 | 1976 | ||
1973 | 1977 | ||
1974 | QSize LiquidStyle::indicatorSize() const | 1978 | QSize LiquidStyle::indicatorSize() const |
1975 | { | 1979 | { |
1976 | return(QSize(20, 22)); | 1980 | return(QSize(20, 22)); |
1977 | } | 1981 | } |
1978 | 1982 | ||
1979 | void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 1983 | void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
1980 | const QColorGroup &/*g*/, int state, bool /*down*/, bool) | 1984 | const QColorGroup &/*g*/, int state, bool /*down*/, bool) |
1981 | { | 1985 | { |
1982 | bool isHover = highlightWidget == p->device(); | 1986 | bool isHover = highlightWidget == p->device(); |
1983 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget | 1987 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget |
1984 | && ((QWidget*)p->device())->autoMask(); | 1988 | && ((QWidget*)p->device())->autoMask(); |
1985 | if(isMasked){ | 1989 | if(isMasked){ |
1986 | if(state != QButton::Off){ | 1990 | if(state != QButton::Off){ |
1987 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) : | 1991 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) : |
1988 | *getPixmap(HTMLCBDown)); | 1992 | *getPixmap(HTMLCBDown)); |
1989 | } | 1993 | } |
1990 | else | 1994 | else |
1991 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) : | 1995 | p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) : |
1992 | *getPixmap(HTMLCB)); | 1996 | *getPixmap(HTMLCB)); |
1993 | 1997 | ||
1994 | } | 1998 | } |
1995 | else{ | 1999 | else{ |
1996 | if(state != QButton::Off){ | 2000 | if(state != QButton::Off){ |
1997 | p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) : | 2001 | p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) : |
1998 | *getPixmap(CBDown)); | 2002 | *getPixmap(CBDown)); |
1999 | /* Todo - tristate | 2003 | /* Todo - tristate |
2000 | if(state == QButton::On){ | 2004 | if(state == QButton::On){ |
2001 | p->setPen(Qt::black); | 2005 | p->setPen(Qt::black); |
2002 | p->drawPixmap(3, 3, xBmp); | 2006 | p->drawPixmap(3, 3, xBmp); |
2003 | } | 2007 | } |
2004 | else{ | 2008 | else{ |
2005 | p->setPen(g.dark()); | 2009 | p->setPen(g.dark()); |
2006 | p->drawRect(x+2, y+2, w-4, h-4); | 2010 | p->drawRect(x+2, y+2, w-4, h-4); |
2007 | p->setPen(Qt::black); | 2011 | p->setPen(Qt::black); |
2008 | p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); | 2012 | p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); |
2009 | p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); | 2013 | p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); |
2010 | p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); | 2014 | p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); |
2011 | }*/ | 2015 | }*/ |
2012 | } | 2016 | } |
2013 | else | 2017 | else |
2014 | p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB)); | 2018 | p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB)); |
2015 | } | 2019 | } |
2016 | } | 2020 | } |
2017 | 2021 | ||
2018 | void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 2022 | void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
2019 | int /*state*/) | 2023 | int /*state*/) |
2020 | { | 2024 | { |
2021 | // needed for some reason by KHtml, even tho it's all filled ;P | 2025 | // needed for some reason by KHtml, even tho it's all filled ;P |
2022 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); | 2026 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); |
2023 | 2027 | ||
2024 | } | 2028 | } |
2025 | 2029 | ||
2026 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, | 2030 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, |
2027 | const QColorGroup &/*g*/, Orientation orient, | 2031 | const QColorGroup &/*g*/, Orientation orient, |
2028 | bool, bool) | 2032 | bool, bool) |
2029 | { | 2033 | { |
2030 | QWidget *parent = (QWidget *)p->device(); | 2034 | QWidget *parent = (QWidget *)p->device(); |
2031 | p->setBrushOrigin(parent->pos()); | 2035 | p->setBrushOrigin(parent->pos()); |
2032 | parent->erase(x, y, w, h); | 2036 | parent->erase(x, y, w, h); |
2033 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : | 2037 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : |
2034 | *getPixmap(VSlider)); | 2038 | *getPixmap(VSlider)); |
2035 | } | 2039 | } |
2036 | 2040 | ||
2037 | void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 2041 | void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
2038 | Orientation orient, bool, bool) | 2042 | Orientation orient, bool, bool) |
2039 | { | 2043 | { |
2040 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : | 2044 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : |
2041 | *getPixmap(VSlider)->mask()); | 2045 | *getPixmap(VSlider)->mask()); |
2042 | } | 2046 | } |
2043 | 2047 | ||
2044 | int LiquidStyle::sliderLength() const | 2048 | int LiquidStyle::sliderLength() const |
2045 | { | 2049 | { |
2046 | return(10); | 2050 | return(10); |
2047 | } | 2051 | } |
2048 | 2052 | ||
2049 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 2053 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
2050 | 2054 | ||
2051 | void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, | 2055 | void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, |
2052 | int y, int w, int h, const QColorGroup &g, | 2056 | int y, int w, int h, const QColorGroup &g, |
2053 | bool enabled, const QBrush *) | 2057 | bool enabled, const QBrush *) |
2054 | { | 2058 | { |
2055 | static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5}; | 2059 | static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5}; |
2056 | static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6}; | 2060 | static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6}; |
2057 | static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7}; | 2061 | static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7}; |
2058 | static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4}; | 2062 | static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4}; |
2059 | 2063 | ||
2060 | p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid()); | 2064 | p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid()); |
2061 | if(w > 8){ | 2065 | if(w > 8){ |
2062 | x = x + (w-8)/2; | 2066 | x = x + (w-8)/2; |
2063 | y = y + (h-8)/2; | 2067 | y = y + (h-8)/2; |
2064 | } | 2068 | } |
2065 | 2069 | ||
2066 | QPointArray a; | 2070 | QPointArray a; |
2067 | switch(type){ | 2071 | switch(type){ |
2068 | case Qt::UpArrow: | 2072 | case Qt::UpArrow: |
2069 | a.setPoints(QCOORDARRLEN(u_arrow), u_arrow); | 2073 | a.setPoints(QCOORDARRLEN(u_arrow), u_arrow); |
2070 | break; | 2074 | break; |
2071 | case Qt::DownArrow: | 2075 | case Qt::DownArrow: |
2072 | a.setPoints(QCOORDARRLEN(d_arrow), d_arrow); | 2076 | a.setPoints(QCOORDARRLEN(d_arrow), d_arrow); |
2073 | break; | 2077 | break; |
2074 | case Qt::LeftArrow: | 2078 | case Qt::LeftArrow: |
2075 | a.setPoints(QCOORDARRLEN(l_arrow), l_arrow); | 2079 | a.setPoints(QCOORDARRLEN(l_arrow), l_arrow); |
2076 | break; | 2080 | break; |
2077 | default: | 2081 | default: |
2078 | a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); | 2082 | a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); |
2079 | break; | 2083 | break; |
2080 | } | 2084 | } |
2081 | 2085 | ||
2082 | a.translate(x, y); | 2086 | a.translate(x, y); |
2083 | p->drawLineSegments(a); | 2087 | p->drawLineSegments(a); |
2084 | } | 2088 | } |
2085 | 2089 | ||
2086 | 2090 | ||
2087 | void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, | 2091 | void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, |
2088 | QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) | 2092 | QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) |
2089 | { | 2093 | { |
2090 | if(active){ | 2094 | if(active){ |
2091 | x -= 2; // Bug in Qt/E | 2095 | x -= 2; // Bug in Qt/E |
2092 | y -= 2; | 2096 | y -= 2; |
2093 | w += 2; | 2097 | w += 2; |
2094 | h += 2; | 2098 | h += 2; |
2095 | } | 2099 | } |
2096 | 2100 | ||
2097 | QWidget *parent = (QWidget *)p->device(); | 2101 | QWidget *parent = (QWidget *)p->device(); |
2098 | p->setBrushOrigin(parent->pos()); | 2102 | p->setBrushOrigin(parent->pos()); |
2099 | parent->erase(x, y, w, h); | 2103 | parent->erase(x, y, w, h); |
2100 | 2104 | ||
2101 | if(menuHandler->useShadowText()){ | 2105 | if(menuHandler->useShadowText()){ |
2102 | QColor shadow; | 2106 | QColor shadow; |
2103 | if(p->device() && p->device()->devType() == QInternal::Widget && | 2107 | if(p->device() && p->device()->devType() == QInternal::Widget && |
2104 | ((QWidget *)p->device())->inherits("QMenuBar")){ | 2108 | ((QWidget *)p->device())->inherits("QMenuBar")){ |
2105 | shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : | 2109 | shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : |
2106 | g.background().dark(130); | 2110 | g.background().dark(130); |
2107 | } | 2111 | } |
2108 | else | 2112 | else |
2109 | shadow = g.background().dark(130); | 2113 | shadow = g.background().dark(130); |
2110 | 2114 | ||
2111 | if(active){ | 2115 | if(active){ |
2112 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); | 2116 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); |
2113 | QApplication::style().drawItem(p, x+1, y+1, w, h, | 2117 | QApplication::style().drawItem(p, x+1, y+1, w, h, |
2114 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2118 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2115 | g, mi->isEnabled(), NULL, mi->text(), | 2119 | g, mi->isEnabled(), NULL, mi->text(), |
2116 | -1, &shadow); | 2120 | -1, &shadow); |
2117 | QApplication::style().drawItem(p, x, y, w, h, | 2121 | QApplication::style().drawItem(p, x, y, w, h, |
2118 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2122 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2119 | g, mi->isEnabled(), NULL, mi->text(), | 2123 | g, mi->isEnabled(), NULL, mi->text(), |
2120 | -1, &g.text()); | 2124 | -1, &g.text()); |
2121 | } | 2125 | } |
2122 | else{ | 2126 | else{ |
2123 | QApplication::style().drawItem(p, x+1, y+1, w, h, | 2127 | QApplication::style().drawItem(p, x+1, y+1, w, h, |
2124 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2128 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2125 | g, mi->isEnabled(), NULL, mi->text(), | 2129 | g, mi->isEnabled(), NULL, mi->text(), |
2126 | -1, &shadow); | 2130 | -1, &shadow); |
2127 | QApplication::style().drawItem(p, x, y, w, h, | 2131 | QApplication::style().drawItem(p, x, y, w, h, |
2128 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2132 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2129 | g, mi->isEnabled(), NULL, mi->text(), | 2133 | g, mi->isEnabled(), NULL, mi->text(), |
2130 | -1, &g.text()); | 2134 | -1, &g.text()); |
2131 | } | 2135 | } |
2132 | } | 2136 | } |
2133 | else{ | 2137 | else{ |
2134 | if(active) | 2138 | if(active) |
2135 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); | 2139 | drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); |
2136 | QApplication::style().drawItem(p, x, y, w, h, | 2140 | QApplication::style().drawItem(p, x, y, w, h, |
2137 | AlignCenter|ShowPrefix|DontClip|SingleLine, | 2141 | AlignCenter|ShowPrefix|DontClip|SingleLine, |
2138 | g, mi->isEnabled(), NULL, mi->text(), | 2142 | g, mi->isEnabled(), NULL, mi->text(), |
2139 | -1, &g.text()); | 2143 | -1, &g.text()); |
2140 | } | 2144 | } |
2141 | } | 2145 | } |
2142 | 2146 | ||
2143 | void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, | 2147 | void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, |
2144 | const QColorGroup &g, int /*lineWidth*/, | 2148 | const QColorGroup &g, int /*lineWidth*/, |
2145 | const QBrush * /*fill*/) | 2149 | const QBrush * /*fill*/) |
2146 | { | 2150 | { |
2147 | QColor c; | 2151 | QColor c; |
2148 | switch(menuHandler->transType()){ | 2152 | switch(menuHandler->transType()){ |
2149 | case None: | 2153 | case None: |
2150 | case StippledBg: | 2154 | case StippledBg: |
2151 | case TransStippleBg: | 2155 | case TransStippleBg: |
2152 | c = g.background(); | 2156 | c = g.background(); |
2153 | break; | 2157 | break; |
2154 | case StippledBtn: | 2158 | case StippledBtn: |
2155 | case TransStippleBtn: | 2159 | case TransStippleBtn: |
2156 | c = g.button(); | 2160 | c = g.button(); |
2157 | break; | 2161 | break; |
2158 | default: | 2162 | default: |
2159 | c = menuHandler->bgColor(); | 2163 | c = menuHandler->bgColor(); |
2160 | } | 2164 | } |
2161 | p->setPen(c.dark(140)); | 2165 | p->setPen(c.dark(140)); |
2162 | p->drawRect(x, y, w, h); | 2166 | p->drawRect(x, y, w, h); |
2163 | p->setPen(c.light(120)); | 2167 | p->setPen(c.light(120)); |
2164 | p->drawRect(x+1, y+1, w-2, h-2); | 2168 | p->drawRect(x+1, y+1, w-2, h-2); |
2165 | } | 2169 | } |
2166 | 2170 | ||
2167 | void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, | 2171 | void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, |
2168 | int tab, QMenuItem* mi, | 2172 | int tab, QMenuItem* mi, |
2169 | const QPalette& pal, bool act, | 2173 | const QPalette& pal, bool act, |
2170 | bool enabled, int x, int y, int w, int h) | 2174 | bool enabled, int x, int y, int w, int h) |
2171 | { | 2175 | { |
2172 | static const int motifItemFrame = 2; | 2176 | static const int motifItemFrame = 2; |
2173 | static const int motifItemHMargin = 3; | 2177 | static const int motifItemHMargin = 3; |
2174 | static const int motifItemVMargin = 2; | 2178 | static const int motifItemVMargin = 2; |
2175 | static const int motifArrowHMargin = 6; | 2179 | static const int motifArrowHMargin = 6; |
2176 | static const int windowsRightBorder = 12; | 2180 | static const int windowsRightBorder = 12; |
2177 | 2181 | ||
2178 | maxpmw = QMAX( maxpmw, 20 ); | 2182 | maxpmw = QMAX( maxpmw, 20 ); |
2179 | 2183 | ||
2180 | 2184 | ||
2181 | bool dis = !enabled; | 2185 | bool dis = !enabled; |
2182 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); | 2186 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); |
2183 | 2187 | ||
2184 | int checkcol = maxpmw; | 2188 | int checkcol = maxpmw; |
2185 | if(act){ | 2189 | if(act){ |
2186 | 2190 | ||
2187 | // FIXME | 2191 | // FIXME |
2188 | drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background()); | 2192 | drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background()); |
2189 | } | 2193 | } |
2190 | //else if(((QWidget*)p->device())->backgroundPixmap()){ | 2194 | //else if(((QWidget*)p->device())->backgroundPixmap()){ |
2191 | // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(), | 2195 | // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(), |
2192 | // x, y, w, h); | 2196 | // x, y, w, h); |
2193 | //} | 2197 | //} |
2194 | else{ | 2198 | else{ |
2195 | if(menuHandler->transType() == None){ | 2199 | if(menuHandler->transType() == None){ |
2196 | p->fillRect(x, y, w, h, pal.active().background()); | 2200 | p->fillRect(x, y, w, h, pal.active().background()); |
2197 | } | 2201 | } |
2198 | else if(menuHandler->transType() == StippledBg){ | 2202 | else if(menuHandler->transType() == StippledBg){ |
2199 | p->fillRect(x, y, w, h, bgBrush); | 2203 | p->fillRect(x, y, w, h, bgBrush); |
2200 | } | 2204 | } |
2201 | else if(menuHandler->transType() == StippledBtn){ | 2205 | else if(menuHandler->transType() == StippledBtn){ |
2202 | p->fillRect(x, y, w, h, menuBrush); | 2206 | p->fillRect(x, y, w, h, menuBrush); |
2203 | } | 2207 | } |
2204 | else{ | 2208 | else{ |
2205 | QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); | 2209 | QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); |
2206 | if(pix) | 2210 | if(pix) |
2207 | p->drawPixmap(x, y, *pix, x, y, w, h); | 2211 | p->drawPixmap(x, y, *pix, x, y, w, h); |
2208 | } | 2212 | } |
2209 | } | 2213 | } |
2210 | 2214 | ||
2211 | if(!mi) | 2215 | if(!mi) |
2212 | return; | 2216 | return; |
2213 | 2217 | ||
2214 | QColor discol; | 2218 | QColor discol; |
2215 | if (dis) { | 2219 | if (dis) { |
2216 | discol = itemg.mid(); | 2220 | discol = itemg.mid(); |
2217 | p->setPen(discol); | 2221 | p->setPen(discol); |
2218 | } | 2222 | } |
2219 | 2223 | ||
2220 | QColorGroup cg2(itemg); | 2224 | QColorGroup cg2(itemg); |
2221 | 2225 | ||
2222 | if(menuHandler->transType() == Custom){ | 2226 | if(menuHandler->transType() == Custom){ |
2223 | cg2.setColor(QColorGroup::Foreground, menuHandler->textColor()); | 2227 | cg2.setColor(QColorGroup::Foreground, menuHandler->textColor()); |
2224 | cg2.setColor(QColorGroup::Text, menuHandler->textColor()); | 2228 | cg2.setColor(QColorGroup::Text, menuHandler->textColor()); |
2225 | cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120)); | 2229 | cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120)); |
2226 | cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120)); | 2230 | cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120)); |
2227 | } | 2231 | } |
2228 | else{ | 2232 | else{ |
2229 | cg2 = QColorGroup(discol, itemg.highlight(), black, black, | 2233 | cg2 = QColorGroup(discol, itemg.highlight(), black, black, |
2230 | dis ? discol : black, discol, black); | 2234 | dis ? discol : black, discol, black); |
2231 | } | 2235 | } |
2232 | 2236 | ||
2233 | if(mi->isSeparator()){ | 2237 | if(mi->isSeparator()){ |
2234 | QColor c; | 2238 | QColor c; |
2235 | switch(menuHandler->transType()){ | 2239 | switch(menuHandler->transType()){ |
2236 | case None: | 2240 | case None: |
2237 | case StippledBg: | 2241 | case StippledBg: |
2238 | case TransStippleBg: | 2242 | case TransStippleBg: |
2239 | c = QApplication::palette().active().background(); | 2243 | c = QApplication::palette().active().background(); |
2240 | break; | 2244 | break; |
2241 | case StippledBtn: | 2245 | case StippledBtn: |
2242 | case TransStippleBtn: | 2246 | case TransStippleBtn: |
2243 | c = QApplication::palette().active().button(); | 2247 | c = QApplication::palette().active().button(); |
2244 | break; | 2248 | break; |
2245 | default: | 2249 | default: |
2246 | c = menuHandler->bgColor(); | 2250 | c = menuHandler->bgColor(); |
2247 | } | 2251 | } |
2248 | p->setPen(c.dark(140)); | 2252 | p->setPen(c.dark(140)); |
2249 | p->drawLine(x, y, x+w, y ); | 2253 | p->drawLine(x, y, x+w, y ); |
2250 | p->setPen(c.light(115)); | 2254 | p->setPen(c.light(115)); |
2251 | p->drawLine(x, y+1, x+w, y+1 ); | 2255 | p->drawLine(x, y+1, x+w, y+1 ); |
2252 | return; | 2256 | return; |
2253 | } | 2257 | } |
2254 | if(mi->iconSet()) { | 2258 | if(mi->iconSet()) { |
2255 | QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; | 2259 | QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; |
2256 | if (!dis) | 2260 | if (!dis) |
2257 | mode = QIconSet::Active; | 2261 | mode = QIconSet::Active; |
2258 | QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); | 2262 | QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); |
2259 | int pixw = pixmap.width(); | 2263 | int pixw = pixmap.width(); |
2260 | int pixh = pixmap.height(); | 2264 | int pixh = pixmap.height(); |
2261 | QRect cr(x, y, checkcol, h); | 2265 | QRect cr(x, y, checkcol, h); |
2262 | QRect pmr(0, 0, pixw, pixh); | 2266 | QRect pmr(0, 0, pixw, pixh); |
2263 | pmr.moveCenter( cr.center() ); | 2267 | pmr.moveCenter( cr.center() ); |
2264 | p->setPen(itemg.highlightedText()); | 2268 | p->setPen(itemg.highlightedText()); |
2265 | p->drawPixmap(pmr.topLeft(), pixmap ); | 2269 | p->drawPixmap(pmr.topLeft(), pixmap ); |
2266 | 2270 | ||
2267 | } | 2271 | } |
2268 | else if(checkable) { | 2272 | else if(checkable) { |
2269 | int mw = checkcol + motifItemFrame; | 2273 | int mw = checkcol + motifItemFrame; |
2270 | int mh = h - 2*motifItemFrame; | 2274 | int mh = h - 2*motifItemFrame; |
2271 | if (mi->isChecked()){ | 2275 | if (mi->isChecked()){ |
2272 | drawCheckMark( p, x + motifItemFrame, | 2276 | drawCheckMark( p, x + motifItemFrame, |
2273 | y+motifItemFrame, mw, mh, cg2, act, dis ); | 2277 | y+motifItemFrame, mw, mh, cg2, act, dis ); |
2274 | } | 2278 | } |
2275 | } | 2279 | } |
2276 | if(menuHandler->transType() == Custom) | 2280 | if(menuHandler->transType() == Custom) |
2277 | p->setPen(menuHandler->textColor()); | 2281 | p->setPen(menuHandler->textColor()); |
2278 | else | 2282 | else |
2279 | p->setPen(itemg.text()); | 2283 | p->setPen(itemg.text()); |
2280 | 2284 | ||
2281 | 2285 | ||
2282 | int xm = motifItemFrame + checkcol + motifItemHMargin; | 2286 | int xm = motifItemFrame + checkcol + motifItemHMargin; |
2283 | QString s = mi->text(); | 2287 | QString s = mi->text(); |
2284 | if (!s.isNull()) { | 2288 | if (!s.isNull()) { |
2285 | int t = s.find( '\t' ); | 2289 | int t = s.find( '\t' ); |
2286 | int m = motifItemVMargin; | 2290 | int m = motifItemVMargin; |
2287 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; | 2291 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; |
2288 | QPen oldPen = p->pen(); | 2292 | QPen oldPen = p->pen(); |
2289 | if(menuHandler->useShadowText()){ | 2293 | if(menuHandler->useShadowText()){ |
2290 | if(menuHandler->transType() == Custom) | 2294 | if(menuHandler->transType() == Custom) |
2291 | p->setPen(menuHandler->bgColor().dark(130)); | 2295 | p->setPen(menuHandler->bgColor().dark(130)); |
2292 | else if(menuHandler->transType() == StippledBtn || | 2296 | else if(menuHandler->transType() == StippledBtn || |
2293 | menuHandler->transType() == TransStippleBtn) | 2297 | menuHandler->transType() == TransStippleBtn) |
2294 | p->setPen(itemg.button().dark(130)); | 2298 | p->setPen(itemg.button().dark(130)); |
2295 | else | 2299 | else |
2296 | p->setPen(bgBrush.color().dark(130)); | 2300 | p->setPen(bgBrush.color().dark(130)); |
2297 | 2301 | ||
2298 | if (t >= 0) { | 2302 | if (t >= 0) { |
2299 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2, | 2303 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2, |
2300 | y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 )); | 2304 | y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 )); |
2301 | } | 2305 | } |
2302 | p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t); | 2306 | p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t); |
2303 | } | 2307 | } |
2304 | p->setPen(oldPen); | 2308 | p->setPen(oldPen); |
2305 | if (t >= 0) { | 2309 | if (t >= 0) { |
2306 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, | 2310 | p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, |
2307 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); | 2311 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); |
2308 | } | 2312 | } |
2309 | p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t); | 2313 | p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t); |
2310 | 2314 | ||
2311 | } | 2315 | } |
2312 | else if (mi->pixmap()) { | 2316 | else if (mi->pixmap()) { |
2313 | QPixmap *pixmap = mi->pixmap(); | 2317 | QPixmap *pixmap = mi->pixmap(); |
2314 | if (pixmap->depth() == 1) | 2318 | if (pixmap->depth() == 1) |
2315 | p->setBackgroundMode(OpaqueMode); | 2319 | p->setBackgroundMode(OpaqueMode); |
2316 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap); | 2320 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap); |
2317 | if (pixmap->depth() == 1) | 2321 | if (pixmap->depth() == 1) |
2318 | p->setBackgroundMode(TransparentMode); | 2322 | p->setBackgroundMode(TransparentMode); |
2319 | } | 2323 | } |
2320 | if (mi->popup()) { | 2324 | if (mi->popup()) { |
2321 | int dim = (h-2*motifItemFrame) / 2; | 2325 | int dim = (h-2*motifItemFrame) / 2; |
2322 | drawArrow(p, RightArrow, true, | 2326 | drawArrow(p, RightArrow, true, |
2323 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, | 2327 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, |
2324 | dim, dim, cg2, TRUE); | 2328 | dim, dim, cg2, TRUE); |
2325 | } | 2329 | } |
2326 | } | 2330 | } |
2327 | 2331 | ||
2328 | int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, | 2332 | int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, |
2329 | const QFontMetrics &fm) | 2333 | const QFontMetrics &fm) |
2330 | { | 2334 | { |
2331 | if (mi->isSeparator()) | 2335 | if (mi->isSeparator()) |
2332 | return 2; | 2336 | return 2; |
2333 | 2337 | ||
2334 | int h = 0; | 2338 | int h = 0; |
2335 | if (mi->pixmap()) | 2339 | if (mi->pixmap()) |
2336 | h = mi->pixmap()->height(); | 2340 | h = mi->pixmap()->height(); |
2337 | 2341 | ||
2338 | if (mi->iconSet()) | 2342 | if (mi->iconSet()) |
2339 | h = QMAX(mi->iconSet()-> | 2343 | h = QMAX(mi->iconSet()-> |
2340 | pixmap(QIconSet::Small, QIconSet::Normal).height(), h); | 2344 | pixmap(QIconSet::Small, QIconSet::Normal).height(), h); |
2341 | 2345 | ||
2342 | h = QMAX(fm.height() + 4, h); | 2346 | h = QMAX(fm.height() + 4, h); |
2343 | 2347 | ||
2344 | // we want a minimum size of 18 | 2348 | // we want a minimum size of 18 |
2345 | h = QMAX(h, 18); | 2349 | h = QMAX(h, 18); |
2346 | 2350 | ||
2347 | return h; | 2351 | return h; |
2348 | } | 2352 | } |
2349 | 2353 | ||
2350 | 2354 | ||
2351 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, | 2355 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, |
2352 | const QColorGroup &g, const QColor *c, | 2356 | const QColorGroup &g, const QColor *c, |
2353 | bool atBorder) | 2357 | bool atBorder) |
2354 | { | 2358 | { |
2355 | // are we painting a widget? | 2359 | // are we painting a widget? |
2356 | if(p->device()->devType() == QInternal::Widget){ | 2360 | if(p->device()->devType() == QInternal::Widget){ |
2357 | // if so does it use a special focus rectangle? | 2361 | // if so does it use a special focus rectangle? |
2358 | QWidget *w = (QWidget *)p->device(); | 2362 | QWidget *w = (QWidget *)p->device(); |
2359 | if(w->inherits("QPushButton") || w->inherits("QSlider")){ | 2363 | if(w->inherits("QPushButton") || w->inherits("QSlider")){ |
2360 | return; | 2364 | return; |
2361 | } | 2365 | } |
2362 | else{ | 2366 | else{ |
2363 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 2367 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
2364 | } | 2368 | } |
2365 | } | 2369 | } |
2366 | else | 2370 | else |
2367 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 2371 | QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
2368 | 2372 | ||
2369 | } | 2373 | } |
2370 | 2374 | ||
2371 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) | 2375 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) |
2372 | { | 2376 | { |
2373 | mnu->installEventFilter(menuHandler); | 2377 | mnu->installEventFilter(menuHandler); |
2374 | QWindowsStyle::polishPopupMenu(mnu); | 2378 | QWindowsStyle::polishPopupMenu(mnu); |
2375 | } | 2379 | } |
2376 | 2380 | ||
2377 | void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, | 2381 | void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, |
2378 | bool selected) | 2382 | bool selected) |
2379 | { | 2383 | { |
2380 | if(tabBar->shape() != QTabBar::RoundedAbove){ | 2384 | if(tabBar->shape() != QTabBar::RoundedAbove){ |
2381 | QWindowsStyle::drawTab(p, tabBar, tab, selected); | 2385 | QWindowsStyle::drawTab(p, tabBar, tab, selected); |
2382 | return; | 2386 | return; |
2383 | } | 2387 | } |
2384 | QPixmap tilePix; | 2388 | QPixmap tilePix; |
2385 | QRect r = tab->rect(); | 2389 | QRect r = tab->rect(); |
2386 | //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] : | 2390 | //QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] : |
2387 | // pixmaps[TabDown] : pixmaps[Tab]; | 2391 | // pixmaps[TabDown] : pixmaps[Tab]; |
2388 | 2392 | ||
2389 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); | 2393 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); |
2390 | p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height()); | 2394 | p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height()); |
2391 | p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height()); | 2395 | p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height()); |
2392 | tilePix.resize(pix->width()-18, r.height()); | 2396 | tilePix.resize(pix->width()-18, r.height()); |
2393 | bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height()); | 2397 | bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height()); |
2394 | p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix); | 2398 | p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix); |
2395 | QColor c = tabBar->colorGroup().button(); | 2399 | QColor c = tabBar->colorGroup().button(); |
2396 | if(!selected){ | 2400 | if(!selected){ |
2397 | p->setPen(c.dark(130)); | 2401 | p->setPen(c.dark(130)); |
2398 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); | 2402 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); |
2399 | } | 2403 | } |
2400 | 2404 | ||
2401 | /* | 2405 | /* |
2402 | p->setPen(c.light(110)); | 2406 | p->setPen(c.light(110)); |
2403 | p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1); | 2407 | p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1); |
2404 | p->setPen(c); | 2408 | p->setPen(c); |
2405 | p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2); | 2409 | p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2); |
2406 | p->setPen(c.light(110)); | 2410 | p->setPen(c.light(110)); |
2407 | p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3); | 2411 | p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3); |
2408 | p->setPen(c.light(120)); | 2412 | p->setPen(c.light(120)); |
2409 | p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4); | 2413 | p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4); |
2410 | */ | 2414 | */ |
2411 | 2415 | ||
2412 | /* | 2416 | /* |
2413 | QColor c = tabBar->colorGroup().button(); | 2417 | QColor c = tabBar->colorGroup().button(); |
2414 | pix = bevelFillDict.find(c.rgb()); | 2418 | pix = bevelFillDict.find(c.rgb()); |
2415 | if(!pix){ | 2419 | if(!pix){ |
2416 | int h, s, v; | 2420 | int h, s, v; |
2417 | c.hsv(&h, &s, &v); | 2421 | c.hsv(&h, &s, &v); |
2418 | pix = new QPixmap(*bevelFillPix); | 2422 | pix = new QPixmap(*bevelFillPix); |
2419 | adjustHSV(*pix, h, s); | 2423 | adjustHSV(*pix, h, s); |
2420 | bevelFillDict.insert(c.rgb(), pix); | 2424 | bevelFillDict.insert(c.rgb(), pix); |
2421 | }*/ | 2425 | }*/ |
2422 | 2426 | ||
2423 | /* | 2427 | /* |
2424 | QRect r = tab->rect(); | 2428 | QRect r = tab->rect(); |
2425 | QColorGroup g = tabBar->colorGroup(); | 2429 | QColorGroup g = tabBar->colorGroup(); |
2426 | if(!selected){ | 2430 | if(!selected){ |
2427 | r.setY(r.y()+1); | 2431 | r.setY(r.y()+1); |
2428 | p->setPen(g.dark()); | 2432 | p->setPen(g.dark()); |
2429 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2); | 2433 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2); |
2430 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); | 2434 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); |
2431 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); | 2435 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); |
2432 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2); | 2436 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2); |
2433 | 2437 | ||
2434 | p->setPen(g.midlight()); | 2438 | p->setPen(g.midlight()); |
2435 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); | 2439 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); |
2436 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); | 2440 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); |
2437 | p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1); | 2441 | p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1); |
2438 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); | 2442 | p->drawLine(r.x(), r.bottom(), r.right(), r.bottom()); |
2439 | 2443 | ||
2440 | p->setPen(g.mid()); | 2444 | p->setPen(g.mid()); |
2441 | p->drawPoint(r.right()-1, r.y()+1); | 2445 | p->drawPoint(r.right()-1, r.y()+1); |
2442 | p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2); | 2446 | p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2); |
2443 | p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3); | 2447 | p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3); |
2444 | 2448 | ||
2445 | p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6, | 2449 | p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6, |
2446 | g.brush(QColorGroup::Mid)); | 2450 | g.brush(QColorGroup::Mid)); |
2447 | 2451 | ||
2448 | p->setPen(g.light()); | 2452 | p->setPen(g.light()); |
2449 | p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1); | 2453 | p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1); |
2450 | 2454 | ||
2451 | } | 2455 | } |
2452 | else{ | 2456 | else{ |
2453 | p->setPen(g.light()); | 2457 | p->setPen(g.light()); |
2454 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()); | 2458 | p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()); |
2455 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); | 2459 | p->drawLine(r.x(), r.y()+4, r.x()+4, r.y()); |
2456 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); | 2460 | p->drawLine(r.x()+4, r.y(), r.right()-1, r.y()); |
2457 | p->setPen(g.dark()); | 2461 | p->setPen(g.dark()); |
2458 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()); | 2462 | p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()); |
2459 | 2463 | ||
2460 | p->setPen(g.midlight()); | 2464 | p->setPen(g.midlight()); |
2461 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); | 2465 | p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom()); |
2462 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); | 2466 | p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1); |
2463 | p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1); | 2467 | p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1); |
2464 | p->setPen(g.mid()); | 2468 | p->setPen(g.mid()); |
2465 | p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()); | 2469 | p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()); |
2466 | }*/ | 2470 | }*/ |
2467 | 2471 | ||
2468 | } | 2472 | } |
2469 | 2473 | ||
2470 | 2474 | ||
2471 | 2475 | ||
2472 | void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab, | 2476 | void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab, |
2473 | bool selected) | 2477 | bool selected) |
2474 | 2478 | ||
2475 | 2479 | ||
2476 | { | 2480 | { |
2477 | //p->fillRect(tab->rect(), Qt::color1); | 2481 | //p->fillRect(tab->rect(), Qt::color1); |
2478 | QRect r = tab->rect(); | 2482 | QRect r = tab->rect(); |
2479 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); | 2483 | QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab); |
2480 | p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height()); | 2484 | p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height()); |
2481 | p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height()); | 2485 | p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height()); |
2482 | p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1); | 2486 | p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1); |
2483 | } | 2487 | } |
2484 | 2488 | ||
2485 | void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame, | 2489 | void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame, |
2486 | int &overlap) | 2490 | int &overlap) |
2487 | { | 2491 | { |
2488 | if(t->shape() == QTabBar::RoundedAbove){ | 2492 | if(t->shape() == QTabBar::RoundedAbove){ |
2489 | overlap = 1; | 2493 | overlap = 1; |
2490 | hFrame = 18; // was 24 | 2494 | hFrame = 18; // was 24 |
2491 | vFrame = 8; // was 10 | 2495 | vFrame = 8; // was 10 |
2492 | } | 2496 | } |
2493 | else | 2497 | else |
2494 | QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); | 2498 | QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); |
2495 | } | 2499 | } |
2496 | 2500 | ||
2497 | 2501 | ||
2498 | 2502 | ||
2499 | void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h, | 2503 | void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h, |
2500 | const QColorGroup &g, Orientation) | 2504 | const QColorGroup &g, Orientation) |
2501 | { | 2505 | { |
2502 | drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? | 2506 | drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? |
2503 | g.button().light(120) : g.button(), g.background()); | 2507 | g.button().light(120) : g.button(), g.background()); |
2504 | } | 2508 | } |
2505 | 2509 | ||
2506 | 2510 | ||
2507 | void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h, | 2511 | void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h, |
2508 | const QColorGroup &g, bool sunken, | 2512 | const QColorGroup &g, bool sunken, |
2509 | int lineWidth, const QBrush *fill) | 2513 | int lineWidth, const QBrush *fill) |
2510 | { | 2514 | { |
2511 | if(p->device()->devType() == QInternal::Widget && | 2515 | if(p->device()->devType() == QInternal::Widget && |
2512 | ((QWidget *)p->device())->inherits("QLineEdit")){ | 2516 | ((QWidget *)p->device())->inherits("QLineEdit")){ |
2513 | int x2 = x+w-1; | 2517 | int x2 = x+w-1; |
2514 | int y2 = y+h-1; | 2518 | int y2 = y+h-1; |
2515 | p->setPen(g.dark()); | 2519 | p->setPen(g.dark()); |
2516 | p->drawRect(x, y, w, h); | 2520 | p->drawRect(x, y, w, h); |
2517 | p->setPen(g.mid()); | 2521 | p->setPen(g.mid()); |
2518 | p->drawLine(x+1, y+1, x2-2, y+1); | 2522 | p->drawLine(x+1, y+1, x2-2, y+1); |
2519 | p->drawLine(x+1, y+1, x+1, y2-1); | 2523 | p->drawLine(x+1, y+1, x+1, y2-1); |
2520 | } | 2524 | } |
2521 | else if(lineWidth != 2 || !sunken) | 2525 | else if(lineWidth != 2 || !sunken) |
2522 | QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); | 2526 | QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); |
2523 | else{ | 2527 | else{ |
2524 | QPen oldPen = p->pen(); | 2528 | QPen oldPen = p->pen(); |
2525 | int x2 = x+w-1; | 2529 | int x2 = x+w-1; |
2526 | int y2 = y+h-1; | 2530 | int y2 = y+h-1; |
2527 | p->setPen(g.light()); | 2531 | p->setPen(g.light()); |
2528 | p->drawLine(x, y2, x2, y2); | 2532 | p->drawLine(x, y2, x2, y2); |
2529 | p->drawLine(x2, y, x2, y2); | 2533 | p->drawLine(x2, y, x2, y2); |
2530 | p->setPen(g.mid()); | 2534 | p->setPen(g.mid()); |
2531 | p->drawLine(x, y, x2, y); | 2535 | p->drawLine(x, y, x2, y); |
2532 | p->drawLine(x, y, x, y2); | 2536 | p->drawLine(x, y, x, y2); |
2533 | 2537 | ||
2534 | p->setPen(g.midlight()); | 2538 | p->setPen(g.midlight()); |
2535 | p->drawLine(x+1, y2-1, x2-1, y2-1); | 2539 | p->drawLine(x+1, y2-1, x2-1, y2-1); |
2536 | p->drawLine(x2-1, y+1, x2-1, y2-1); | 2540 | p->drawLine(x2-1, y+1, x2-1, y2-1); |
2537 | p->setPen(g.dark()); | 2541 | p->setPen(g.dark()); |
2538 | p->drawLine(x+1, y+1, x2-1, y+1); | 2542 | p->drawLine(x+1, y+1, x2-1, y+1); |
2539 | p->drawLine(x+1, y+1, x+1, y2-1); | 2543 | p->drawLine(x+1, y+1, x+1, y2-1); |
2540 | p->setPen(oldPen); | 2544 | p->setPen(oldPen); |
2541 | if(fill){ | 2545 | if(fill){ |
2542 | // I believe here we are only supposed to fill if there is a | 2546 | // I believe here we are only supposed to fill if there is a |
2543 | // specified fill brush... | 2547 | // specified fill brush... |
2544 | p->fillRect(x+2, y+2, w-4, h-4, *fill); | 2548 | p->fillRect(x+2, y+2, w-4, h-4, *fill); |
2545 | } | 2549 | } |
2546 | } | 2550 | } |
2547 | } | 2551 | } |
2548 | 2552 | ||
2549 | 2553 | ||
2550 | void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) | 2554 | void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) |
2551 | { | 2555 | { |
2552 | QBitmap *maskBmp = NULL; | 2556 | QBitmap *maskBmp = NULL; |
2553 | if(pix.mask()) | 2557 | if(pix.mask()) |
2554 | maskBmp = new QBitmap(*pix.mask()); | 2558 | maskBmp = new QBitmap(*pix.mask()); |
2555 | QImage img = pix.convertToImage(); | 2559 | QImage img = pix.convertToImage(); |
2556 | if(img.depth() != 32) | 2560 | if(img.depth() != 32) |
2557 | img = img.convertDepth(32); | 2561 | img = img.convertDepth(32); |
2558 | unsigned int *data = (unsigned int *)img.bits(); | 2562 | unsigned int *data = (unsigned int *)img.bits(); |
2559 | int total = img.width()*img.height(); | 2563 | int total = img.width()*img.height(); |
2560 | int current; | 2564 | int current; |
2561 | QColor c; | 2565 | QColor c; |
2562 | int oldH, oldS, oldV; | 2566 | int oldH, oldS, oldV; |
2563 | if(v < 235) | 2567 | if(v < 235) |
2564 | v += 20; | 2568 | v += 20; |
2565 | else | 2569 | else |
2566 | v = 255; | 2570 | v = 255; |
2567 | float intensity = v/255.0; | 2571 | float intensity = v/255.0; |
2568 | 2572 | ||
2569 | for(current=0; current<total; ++current){ | 2573 | for(current=0; current<total; ++current){ |
2570 | c.setRgb(data[current]); | 2574 | c.setRgb(data[current]); |
2571 | c.hsv(&oldH, &oldS, &oldV); | 2575 | c.hsv(&oldH, &oldS, &oldV); |
2572 | oldV = (int)(oldV*intensity); | 2576 | oldV = (int)(oldV*intensity); |
2573 | c.setHsv(h, s, oldV); | 2577 | c.setHsv(h, s, oldV); |
2574 | data[current] = c.rgb(); | 2578 | data[current] = c.rgb(); |
2575 | } | 2579 | } |
2576 | pix.convertFromImage(img); | 2580 | pix.convertFromImage(img); |
2577 | if(maskBmp) | 2581 | if(maskBmp) |
2578 | pix.setMask(*maskBmp); | 2582 | pix.setMask(*maskBmp); |
2579 | } | 2583 | } |
2580 | 2584 | ||
2581 | void LiquidStyle::intensity(QPixmap &pix, float percent) | 2585 | void LiquidStyle::intensity(QPixmap &pix, float percent) |
2582 | { | 2586 | { |
2583 | QImage image = pix.convertToImage(); | 2587 | QImage image = pix.convertToImage(); |
2584 | int i, tmp, r, g, b; | 2588 | int i, tmp, r, g, b; |
2585 | int segColors = image.depth() > 8 ? 256 : image.numColors(); | 2589 | int segColors = image.depth() > 8 ? 256 : image.numColors(); |
2586 | unsigned char *segTbl = new unsigned char[segColors]; | 2590 | unsigned char *segTbl = new unsigned char[segColors]; |
2587 | int pixels = image.depth() > 8 ? image.width()*image.height() : | 2591 | int pixels = image.depth() > 8 ? image.width()*image.height() : |
2588 | image.numColors(); | 2592 | image.numColors(); |
2589 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : | 2593 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : |
2590 | (unsigned int *)image.colorTable(); | 2594 | (unsigned int *)image.colorTable(); |
2591 | 2595 | ||
2592 | bool brighten = (percent >= 0); | 2596 | bool brighten = (percent >= 0); |
2593 | if(percent < 0) | 2597 | if(percent < 0) |
2594 | percent = -percent; | 2598 | percent = -percent; |
2595 | 2599 | ||
2596 | if(brighten){ // keep overflow check out of loops | 2600 | if(brighten){ // keep overflow check out of loops |
2597 | for(i=0; i < segColors; ++i){ | 2601 | for(i=0; i < segColors; ++i){ |
2598 | tmp = (int)(i*percent); | 2602 | tmp = (int)(i*percent); |
2599 | if(tmp > 255) | 2603 | if(tmp > 255) |
2600 | tmp = 255; | 2604 | tmp = 255; |
2601 | segTbl[i] = tmp; | 2605 | segTbl[i] = tmp; |
2602 | } | 2606 | } |
2603 | } | 2607 | } |
2604 | else{ | 2608 | else{ |
2605 | for(i=0; i < segColors; ++i){ | 2609 | for(i=0; i < segColors; ++i){ |
2606 | tmp = (int)(i*percent); | 2610 | tmp = (int)(i*percent); |
2607 | if(tmp < 0) | 2611 | if(tmp < 0) |
2608 | tmp = 0; | 2612 | tmp = 0; |
2609 | segTbl[i] = tmp; | 2613 | segTbl[i] = tmp; |
2610 | } | 2614 | } |
2611 | } | 2615 | } |
2612 | 2616 | ||
2613 | if(brighten){ // same here | 2617 | if(brighten){ // same here |
2614 | for(i=0; i < pixels; ++i){ | 2618 | for(i=0; i < pixels; ++i){ |
2615 | r = qRed(data[i]); | 2619 | r = qRed(data[i]); |
2616 | g = qGreen(data[i]); | 2620 | g = qGreen(data[i]); |
2617 | b = qBlue(data[i]); | 2621 | b = qBlue(data[i]); |
2618 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; | 2622 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; |
2619 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; | 2623 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; |
2620 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; | 2624 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; |
2621 | data[i] = qRgb(r, g, b); | 2625 | data[i] = qRgb(r, g, b); |
2622 | } | 2626 | } |
2623 | } | 2627 | } |
2624 | else{ | 2628 | else{ |
2625 | for(i=0; i < pixels; ++i){ | 2629 | for(i=0; i < pixels; ++i){ |
2626 | r = qRed(data[i]); | 2630 | r = qRed(data[i]); |
2627 | g = qGreen(data[i]); | 2631 | g = qGreen(data[i]); |
2628 | b = qBlue(data[i]); | 2632 | b = qBlue(data[i]); |
2629 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; | 2633 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; |
2630 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; | 2634 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; |
2631 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; | 2635 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; |
2632 | data[i] = qRgb(r, g, b); | 2636 | data[i] = qRgb(r, g, b); |
2633 | } | 2637 | } |
2634 | } | 2638 | } |
2635 | delete [] segTbl; | 2639 | delete [] segTbl; |
2636 | pix.convertFromImage(image); | 2640 | pix.convertFromImage(image); |
2637 | } | 2641 | } |
2638 | 2642 | ||
2639 | void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h) | 2643 | void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h) |
2640 | { | 2644 | { |
2641 | int x2 = x+w-1; | 2645 | int x2 = x+w-1; |
2642 | int y2 = y+h-1; | 2646 | int y2 = y+h-1; |
2643 | p->drawLine(x+1, y, x2-1, y); | 2647 | p->drawLine(x+1, y, x2-1, y); |
2644 | p->drawLine(x, y+1, x, y2-1); | 2648 | p->drawLine(x, y+1, x, y2-1); |
2645 | p->drawLine(x+1, y2, x2-1, y2); | 2649 | p->drawLine(x+1, y2, x2-1, y2); |
2646 | p->drawLine(x2, y+1, x2, y2-1); | 2650 | p->drawLine(x2, y+1, x2, y2-1); |
2647 | } | 2651 | } |
2648 | 2652 | ||
2649 | void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h, | 2653 | void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h, |
2650 | const QColorGroup &g, QCOORD, | 2654 | const QColorGroup &g, QCOORD, |
2651 | Orientation orient) | 2655 | Orientation orient) |
2652 | { | 2656 | { |
2653 | bool isFocus = ((QWidget *)p->device())->hasFocus(); | 2657 | bool isFocus = ((QWidget *)p->device())->hasFocus(); |
2654 | QColor c = isFocus ? g.background().dark(120) : g.background(); | 2658 | QColor c = isFocus ? g.background().dark(120) : g.background(); |
2655 | if(orient == Qt::Horizontal){ | 2659 | if(orient == Qt::Horizontal){ |
2656 | int x2 = x+w-1; | 2660 | int x2 = x+w-1; |
2657 | y+=2; | 2661 | y+=2; |
2658 | p->setPen(c.dark(130)); | 2662 | p->setPen(c.dark(130)); |
2659 | p->drawLine(x+1, y, x2-1, y); | 2663 | p->drawLine(x+1, y, x2-1, y); |
2660 | p->setPen(c.dark(150)); | 2664 | p->setPen(c.dark(150)); |
2661 | p->drawLine(x, y+1, x2, y+1); | 2665 | p->drawLine(x, y+1, x2, y+1); |
2662 | p->setPen(c.dark(125)); | 2666 | p->setPen(c.dark(125)); |
2663 | p->drawLine(x, y+2, x2, y+2); | 2667 | p->drawLine(x, y+2, x2, y+2); |
2664 | p->setPen(c.dark(130)); | 2668 | p->setPen(c.dark(130)); |
2665 | p->drawLine(x, y+3, x2, y+3); | 2669 | p->drawLine(x, y+3, x2, y+3); |
2666 | p->setPen(c.dark(120)); | 2670 | p->setPen(c.dark(120)); |
2667 | p->drawLine(x, y+4, x2, y+4); | 2671 | p->drawLine(x, y+4, x2, y+4); |
2668 | p->setPen(c.light(110)); | 2672 | p->setPen(c.light(110)); |
2669 | p->drawLine(x+1, y+5, x2-1, y+5); | 2673 | p->drawLine(x+1, y+5, x2-1, y+5); |
2670 | } | 2674 | } |
2671 | else{ | 2675 | else{ |
2672 | int y2 = y+h-1; | 2676 | int y2 = y+h-1; |
2673 | x+=2; | 2677 | x+=2; |
2674 | p->setPen(c.dark(130)); | 2678 | p->setPen(c.dark(130)); |
2675 | p->drawLine(x, y+1, x, y2-1); | 2679 | p->drawLine(x, y+1, x, y2-1); |
2676 | p->setPen(c.dark(150)); | 2680 | p->setPen(c.dark(150)); |
2677 | p->drawLine(x+1, y, x+1, y2); | 2681 | p->drawLine(x+1, y, x+1, y2); |
2678 | p->setPen(c.dark(125)); | 2682 | p->setPen(c.dark(125)); |
2679 | p->drawLine(x+2, y, x+2, y2); | 2683 | p->drawLine(x+2, y, x+2, y2); |
2680 | p->setPen(c.dark(130)); | 2684 | p->setPen(c.dark(130)); |
2681 | p->drawLine(x+3, y, x+3, y2); | 2685 | p->drawLine(x+3, y, x+3, y2); |
2682 | p->setPen(c.dark(120)); | 2686 | p->setPen(c.dark(120)); |
2683 | p->drawLine(x+4, y, x+4, y2); | 2687 | p->drawLine(x+4, y, x+4, y2); |
2684 | p->setPen(c.light(110)); | 2688 | p->setPen(c.light(110)); |
2685 | p->drawLine(x+5, y+1, x+5, y2-1); | 2689 | p->drawLine(x+5, y+1, x+5, y2-1); |
2686 | } | 2690 | } |
2687 | //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient); | 2691 | //QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient); |
2688 | 2692 | ||
2689 | } | 2693 | } |
2690 | 2694 | ||
2691 | void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, | 2695 | void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w, |
2692 | int h, QCOORD, Orientation orient) | 2696 | int h, QCOORD, Orientation orient) |
2693 | { | 2697 | { |
2694 | p->fillRect(x, y, w, h, Qt::color0); | 2698 | p->fillRect(x, y, w, h, Qt::color0); |
2695 | p->setPen(Qt::color1); | 2699 | p->setPen(Qt::color1); |
2696 | if(orient == Qt::Horizontal){ | 2700 | if(orient == Qt::Horizontal){ |
2697 | int x2 = x+w-1; | 2701 | int x2 = x+w-1; |
2698 | y+=2; | 2702 | y+=2; |
2699 | p->drawLine(x+1, y, x2-1, y); | 2703 | p->drawLine(x+1, y, x2-1, y); |
2700 | p->fillRect(x, y+1, w, 4, Qt::color1); | 2704 | p->fillRect(x, y+1, w, 4, Qt::color1); |
2701 | p->drawLine(x+1, y+5, x2-1, y+5); | 2705 | p->drawLine(x+1, y+5, x2-1, y+5); |
2702 | } | 2706 | } |
2703 | else{ | 2707 | else{ |
2704 | int y2 = y+h-1; | 2708 | int y2 = y+h-1; |
2705 | x+=2; | 2709 | x+=2; |
2706 | p->drawLine(x, y+1, x, y2-1); | 2710 | p->drawLine(x, y+1, x, y2-1); |
2707 | p->fillRect(x+1, y, 4, h, Qt::color1); | 2711 | p->fillRect(x+1, y, 4, h, Qt::color1); |
2708 | p->drawLine(x+5, y+1, x+5, y2-1); | 2712 | p->drawLine(x+5, y+1, x+5, y2-1); |
2709 | } | 2713 | } |
2710 | } | 2714 | } |
2711 | 2715 | ||
2712 | // I'm debating if to use QValueList or QList here. I like QValueList better, | 2716 | // I'm debating if to use QValueList or QList here. I like QValueList better, |
2713 | // but QList handles pointers which is good for a lot of empty icons... | 2717 | // but QList handles pointers which is good for a lot of empty icons... |
2714 | 2718 | ||
2715 | void LiquidStyle::loadCustomButtons() | 2719 | void LiquidStyle::loadCustomButtons() |
2716 | { | 2720 | { |
2717 | return; // TODO | 2721 | return; // TODO |
2718 | customBtnColorList.clear(); | 2722 | customBtnColorList.clear(); |
2719 | customBtnIconList.clear(); | 2723 | customBtnIconList.clear(); |
2720 | customBtnLabelList.clear(); | 2724 | customBtnLabelList.clear(); |
2721 | 2725 | ||
2722 | // KConfig *config = KGlobal::config(); | 2726 | // KConfig *config = KGlobal::config(); |
2723 | // QString oldGrp = config->group(); | 2727 | // QString oldGrp = config->group(); |
2724 | // config->setGroup("MosfetButtons"); | 2728 | // config->setGroup("MosfetButtons"); |
2725 | 2729 | ||
2726 | QStrList iconList, colorList; //temp, we store QPixmaps and QColors | 2730 | QStrList iconList, colorList; //temp, we store QPixmaps and QColors |
2727 | iconList.setAutoDelete(true); | 2731 | iconList.setAutoDelete(true); |
2728 | colorList.setAutoDelete(true); | 2732 | colorList.setAutoDelete(true); |
2729 | // config->readListEntry("Labels", customBtnLabelList); | 2733 | // config->readListEntry("Labels", customBtnLabelList); |
2730 | // config->readListEntry("Icons", iconList); | 2734 | // config->readListEntry("Icons", iconList); |
2731 | // config->readListEntry("Colors", colorList); | 2735 | // config->readListEntry("Colors", colorList); |
2732 | 2736 | ||
2733 | const char *labelStr = customBtnLabelList.first(); | 2737 | const char *labelStr = customBtnLabelList.first(); |
2734 | const char *colorStr = colorList.first(); | 2738 | const char *colorStr = colorList.first(); |
2735 | const char *iconStr = iconList.first(); | 2739 | const char *iconStr = iconList.first(); |
2736 | 2740 | ||
2737 | // KIconLoader *ldr = KGlobal::iconLoader(); | 2741 | // KIconLoader *ldr = KGlobal::iconLoader(); |
2738 | while(labelStr != NULL){ | 2742 | while(labelStr != NULL){ |
2739 | QColor *c = new QColor; | 2743 | QColor *c = new QColor; |
2740 | c->setNamedColor(QString(colorStr)); | 2744 | c->setNamedColor(QString(colorStr)); |
2741 | customBtnColorList.append(c); | 2745 | customBtnColorList.append(c); |
2742 | 2746 | ||
2743 | QString tmpStr(iconStr); | 2747 | QString tmpStr(iconStr); |
2744 | if(!tmpStr.isEmpty()){ | 2748 | if(!tmpStr.isEmpty()){ |
2745 | QPixmap *pixmap = | 2749 | QPixmap *pixmap = |
2746 | new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small)); | 2750 | new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small)); |
2747 | if(pixmap->isNull()){ | 2751 | if(pixmap->isNull()){ |
2748 | delete pixmap; | 2752 | delete pixmap; |
2749 | customBtnIconList.append(NULL); | 2753 | customBtnIconList.append(NULL); |
2750 | } | 2754 | } |
2751 | else | 2755 | else |
2752 | customBtnIconList.append(pixmap); | 2756 | customBtnIconList.append(pixmap); |
2753 | } | 2757 | } |
2754 | else | 2758 | else |
2755 | customBtnIconList.append(NULL); | 2759 | customBtnIconList.append(NULL); |
2756 | 2760 | ||
2757 | labelStr = customBtnLabelList.next(); | 2761 | labelStr = customBtnLabelList.next(); |
2758 | colorStr = colorList.next(); | 2762 | colorStr = colorList.next(); |
2759 | iconStr = iconList.next(); | 2763 | iconStr = iconList.next(); |
2760 | } | 2764 | } |
2761 | } | 2765 | } |
2762 | 2766 | ||
2763 | void LiquidStyle::applyCustomAttributes(QPushButton *btn) | 2767 | void LiquidStyle::applyCustomAttributes(QPushButton *btn) |
2764 | { | 2768 | { |
2765 | return; // TODO | 2769 | return; // TODO |
2766 | QString str = btn->text(); | 2770 | QString str = btn->text(); |
2767 | if(str.isEmpty()) | 2771 | if(str.isEmpty()) |
2768 | return; | 2772 | return; |
2769 | while(str.contains('&') != 0) | 2773 | while(str.contains('&') != 0) |
2770 | str = str.remove(str.find('&'), 1); | 2774 | str = str.remove(str.find('&'), 1); |
2771 | 2775 | ||
2772 | const char *s; | 2776 | const char *s; |
2773 | int idx = 0; | 2777 | int idx = 0; |
2774 | for(s = customBtnLabelList.first(); s != NULL; | 2778 | for(s = customBtnLabelList.first(); s != NULL; |
2775 | ++idx, s = customBtnLabelList.next()){ | 2779 | ++idx, s = customBtnLabelList.next()){ |
2776 | if(qstricmp(s, str.latin1()) == 0){ | 2780 | if(qstricmp(s, str.latin1()) == 0){ |
2777 | QPalette pal = btn->palette(); | 2781 | QPalette pal = btn->palette(); |
2778 | pal.setColor(QColorGroup::Button, | 2782 | pal.setColor(QColorGroup::Button, |
2779 | *customBtnColorList.at(idx)); | 2783 | *customBtnColorList.at(idx)); |
2780 | btn->setPalette(pal); | 2784 | btn->setPalette(pal); |
2781 | /* | 2785 | /* |
2782 | if(customBtnIconList.at(idx) != NULL){ | 2786 | if(customBtnIconList.at(idx) != NULL){ |
2783 | QPixmap *pix = customBtnIconList.at(idx); | 2787 | QPixmap *pix = customBtnIconList.at(idx); |
2784 | btn->setIconSet(QIconSet(*pix)); | 2788 | btn->setIconSet(QIconSet(*pix)); |
2785 | }*/ | 2789 | }*/ |
2786 | break; | 2790 | break; |
2787 | } | 2791 | } |
2788 | } | 2792 | } |
2789 | } | 2793 | } |
2790 | 2794 | ||
2791 | void LiquidStyle::unapplyCustomAttributes(QPushButton *btn) | 2795 | void LiquidStyle::unapplyCustomAttributes(QPushButton *btn) |
2792 | { | 2796 | { |
2793 | return; // TODO | 2797 | return; // TODO |
2794 | QString str = btn->text(); | 2798 | QString str = btn->text(); |
2795 | if(str.isEmpty()) | 2799 | if(str.isEmpty()) |
2796 | return; | 2800 | return; |
2797 | while(str.contains('&') != 0) | 2801 | while(str.contains('&') != 0) |
2798 | str = str.remove(str.find('&'), 1); | 2802 | str = str.remove(str.find('&'), 1); |
2799 | 2803 | ||
2800 | const char *s; | 2804 | const char *s; |
2801 | for(s = customBtnLabelList.first(); s != NULL; s = customBtnLabelList.next()){ | 2805 | for(s = customBtnLabelList.first(); s != NULL; s = customBtnLabelList.next()){ |
2802 | if(qstricmp(s, str.latin1()) == 0){ | 2806 | if(qstricmp(s, str.latin1()) == 0){ |
2803 | btn->setPalette(QApplication::palette()); | 2807 | btn->setPalette(QApplication::palette()); |
2804 | btn->setIconSet(QIconSet()); | 2808 | btn->setIconSet(QIconSet()); |
2805 | break; | 2809 | break; |
2806 | } | 2810 | } |
2807 | } | 2811 | } |
2808 | } | 2812 | } |
2809 | 2813 | ||
2810 | // #include "liquid.moc" | 2814 | // #include "liquid.moc" |
2811 | 2815 | ||
2812 | 2816 | ||
2813 | 2817 | ||
2814 | 2818 | ||
2815 | 2819 | ||
2816 | 2820 | ||
2817 | /* vim: set noet sw=8 ts=8: */ | 2821 | /* vim: set noet sw=8 ts=8: */ |
diff --git a/noncore/styles/liquid/opie-liquid.diff b/noncore/styles/liquid/opie-liquid.diff index 90ece90..f3531e5 100644 --- a/noncore/styles/liquid/opie-liquid.diff +++ b/noncore/styles/liquid/opie-liquid.diff | |||
@@ -1,1435 +1,1508 @@ | |||
1 | This is a patch to mosfet's liquid 0.7. | 1 | This is a patch to mosfet's liquid 0.7. |
2 | Features: | 2 | Features: |
3 | - Qt-only | 3 | - Qt-only |
4 | - works with Qt/E on QPE/OPIE | 4 | - works with Qt/E on QPE/OPIE |
5 | 5 | ||
6 | --- -Sat Sep 21 05:31:47 2002 | 6 | --- -2002-10-24 03:19:30.000000000 +0200 |
7 | +++ liquid.hMon Jul 15 02:52:50 2002 | 7 | +++ liquid.h2002-07-15 02:52:50.000000000 +0200 |
8 | @@ -2,7 +2,7 @@ | 8 | @@ -2,7 +2,7 @@ |
9 | #define LIQUID_STYLE_H | 9 | #define LIQUID_STYLE_H |
10 | 10 | ||
11 | 11 | ||
12 | -#include <kstyle.h> | 12 | -#include <kstyle.h> |
13 | +#include <qwindowsstyle.h> | 13 | +#include <qwindowsstyle.h> |
14 | #include <qpainter.h> | 14 | #include <qpainter.h> |
15 | #include <qdrawutil.h> | 15 | #include <qdrawutil.h> |
16 | #include <qpalette.h> | 16 | #include <qpalette.h> |
17 | @@ -20,7 +20,7 @@ | 17 | @@ -20,7 +20,7 @@ |
18 | * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. | 18 | * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | -class KPixmap; | 21 | -class KPixmap; |
22 | +class QPixmap; | 22 | +class QPixmap; |
23 | 23 | ||
24 | #define BITMAP_ITEMS 41 | 24 | #define BITMAP_ITEMS 41 |
25 | #define LIQUID_MENU_CHANGE 667 | 25 | #define LIQUID_MENU_CHANGE 667 |
26 | @@ -50,24 +50,22 @@ | 26 | @@ -50,24 +50,22 @@ |
27 | ~TransMenuHandler(){;} | 27 | ~TransMenuHandler(){;} |
28 | void reloadSettings(); | 28 | void reloadSettings(); |
29 | int transType(){return(type);} | 29 | int transType(){return(type);} |
30 | - KPixmap *pixmap(WId id){return(pixDict.find(id));} | 30 | - KPixmap *pixmap(WId id){return(pixDict.find(id));} |
31 | + QPixmap *pixmap(WId id){return(pixDict.find(id));} | 31 | + QPixmap *pixmap(WId id){return(pixDict.find(id));} |
32 | const QColor& textColor(){return(fgColor);} | 32 | const QColor& textColor(){return(fgColor);} |
33 | const QColor& bgColor(){return(color);} | 33 | const QColor& bgColor(){return(color);} |
34 | bool useShadowText(){return(shadowText);} | 34 | bool useShadowText(){return(shadowText);} |
35 | -protected slots: | 35 | -protected slots: |
36 | - void slotKIPCMessage(int id, int arg); | 36 | - void slotKIPCMessage(int id, int arg); |
37 | protected: | 37 | protected: |
38 | bool eventFilter(QObject *obj, QEvent *ev); | 38 | bool eventFilter(QObject *obj, QEvent *ev); |
39 | - void stripePixmap(KPixmap &pix, const QColor &color); | 39 | - void stripePixmap(KPixmap &pix, const QColor &color); |
40 | + void stripePixmap(QPixmap &pix, const QColor &color); | 40 | + void stripePixmap(QPixmap &pix, const QColor &color); |
41 | 41 | ||
42 | QColor color, fgColor; | 42 | QColor color, fgColor; |
43 | int opacity; | 43 | int opacity; |
44 | int type; | 44 | int type; |
45 | bool shadowText; | 45 | bool shadowText; |
46 | - QIntDict<KPixmap>pixDict; | 46 | - QIntDict<KPixmap>pixDict; |
47 | + QIntDict<QPixmap>pixDict; | 47 | + QIntDict<QPixmap>pixDict; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | -class LiquidStyle : public KStyle | 50 | -class LiquidStyle : public KStyle |
51 | +class LiquidStyle : public QWindowsStyle | 51 | +class LiquidStyle : public QWindowsStyle |
52 | { | 52 | { |
53 | friend class TransMenuHandler; | 53 | friend class TransMenuHandler; |
54 | public: | 54 | public: |
55 | @@ -121,33 +119,14 @@ | 55 | @@ -121,33 +119,14 @@ |
56 | bool tickAbove, bool tickBelow); | 56 | bool tickAbove, bool tickBelow); |
57 | void drawSliderMask(QPainter *p, int x, int y, int w, int h, | 57 | void drawSliderMask(QPainter *p, int x, int y, int w, int h, |
58 | Orientation orient, bool, bool); | 58 | Orientation orient, bool, bool); |
59 | - void drawKToolBar(QPainter *p, int x, int y, int w, int h, | 59 | - void drawKToolBar(QPainter *p, int x, int y, int w, int h, |
60 | - const QColorGroup &g, KToolBarPos type, | 60 | - const QColorGroup &g, KToolBarPos type, |
61 | - QBrush *fill=NULL); | 61 | - QBrush *fill=NULL); |
62 | - void drawKBarHandle(QPainter *p, int x, int y, int w, int h, | 62 | - void drawKBarHandle(QPainter *p, int x, int y, int w, int h, |
63 | - const QColorGroup &g, | 63 | - const QColorGroup &g, |
64 | - KToolBarPos type, QBrush *fill=NULL); | 64 | - KToolBarPos type, QBrush *fill=NULL); |
65 | - void drawKMenuBar(QPainter *p, int x, int y, int w, int h, | 65 | - void drawKMenuBar(QPainter *p, int x, int y, int w, int h, |
66 | - const QColorGroup &g, bool macMode, | 66 | - const QColorGroup &g, bool macMode, |
67 | - QBrush *fill=NULL); | 67 | - QBrush *fill=NULL); |
68 | - void drawKToolBarButton(QPainter *p, int x, int y, int w, int h, | 68 | - void drawKToolBarButton(QPainter *p, int x, int y, int w, int h, |
69 | - const QColorGroup &g, bool sunken=false, | 69 | - const QColorGroup &g, bool sunken=false, |
70 | - bool raised = true, bool enabled = true, | 70 | - bool raised = true, bool enabled = true, |
71 | - bool popup = false, | 71 | - bool popup = false, |
72 | - KToolButtonType icontext = Icon, | 72 | - KToolButtonType icontext = Icon, |
73 | - const QString& btext=QString::null, | 73 | - const QString& btext=QString::null, |
74 | - const QPixmap *icon=NULL, | 74 | - const QPixmap *icon=NULL, |
75 | - QFont *font=NULL, QWidget *btn=NULL); | 75 | - QFont *font=NULL, QWidget *btn=NULL); |
76 | - void drawKMenuItem(QPainter *p, int x, int y, int w, int h, | 76 | - void drawKMenuItem(QPainter *p, int x, int y, int w, int h, |
77 | - const QColorGroup &g, bool active, | 77 | - const QColorGroup &g, bool active, |
78 | - QMenuItem *item, QBrush *fill=NULL); | 78 | - QMenuItem *item, QBrush *fill=NULL); |
79 | +void drawMenuBarItem(QPainter *p, int x, int y, int w, int h, | 79 | +void drawMenuBarItem(QPainter *p, int x, int y, int w, int h, |
80 | + QMenuItem *mi, QColorGroup &g, bool enabled, bool active ); | 80 | + QMenuItem *mi, QColorGroup &g, bool enabled, bool active ); |
81 | + | 81 | + |
82 | void drawPopupMenuItem(QPainter *p, bool checkable, int maxpmw, | 82 | void drawPopupMenuItem(QPainter *p, bool checkable, int maxpmw, |
83 | int tab, QMenuItem *mi, const QPalette &pal, | 83 | int tab, QMenuItem *mi, const QPalette &pal, |
84 | bool act, bool enabled, int x, int y, int w, | 84 | bool act, bool enabled, int x, int y, int w, |
85 | int h); | 85 | int h); |
86 | int popupMenuItemHeight(bool c, QMenuItem *mi, const QFontMetrics &fm); | 86 | int popupMenuItemHeight(bool c, QMenuItem *mi, const QFontMetrics &fm); |
87 | - void drawKProgressBlock(QPainter *p, int x, int y, int w, int h, | 87 | - void drawKProgressBlock(QPainter *p, int x, int y, int w, int h, |
88 | - const QColorGroup &g, QBrush *fill); | 88 | - const QColorGroup &g, QBrush *fill); |
89 | void drawFocusRect(QPainter *p, const QRect &r, const QColorGroup &g, | 89 | void drawFocusRect(QPainter *p, const QRect &r, const QColorGroup &g, |
90 | const QColor *pen, bool atBorder); | 90 | const QColor *pen, bool atBorder); |
91 | int defaultFrameWidth() const {return(2);} | 91 | int defaultFrameWidth() const {return(2);} |
92 | @@ -167,12 +146,6 @@ | 92 | @@ -167,12 +146,6 @@ |
93 | void drawToolButton(QPainter *p, int x, int y, int w, | 93 | void drawToolButton(QPainter *p, int x, int y, int w, |
94 | int h, const QColorGroup &g, | 94 | int h, const QColorGroup &g, |
95 | bool sunken, const QBrush *fill); | 95 | bool sunken, const QBrush *fill); |
96 | - void drawKickerAppletHandle(QPainter *p, int x, int y, int w, int h, | 96 | - void drawKickerAppletHandle(QPainter *p, int x, int y, int w, int h, |
97 | - const QColorGroup &g, QBrush *); | 97 | - const QColorGroup &g, QBrush *); |
98 | - void drawKickerTaskButton(QPainter *p, int x, int y, int w, int h, | 98 | - void drawKickerTaskButton(QPainter *p, int x, int y, int w, int h, |
99 | - const QColorGroup &g, | 99 | - const QColorGroup &g, |
100 | - const QString &title, bool active, | 100 | - const QString &title, bool active, |
101 | - QPixmap *icon, QBrush *fill); | 101 | - QPixmap *icon, QBrush *fill); |
102 | // for repainting toolbuttons when the toolbar is resized | 102 | // for repainting toolbuttons when the toolbar is resized |
103 | bool eventFilter(QObject *obj, QEvent *ev); | 103 | bool eventFilter(QObject *obj, QEvent *ev); |
104 | void drawSliderGroove(QPainter * p, int x, int y, int w, int h, | 104 | void drawSliderGroove(QPainter * p, int x, int y, int w, int h, |
105 | @@ -204,6 +177,7 @@ | 105 | @@ -204,6 +177,7 @@ |
106 | QPixmap* getPixmap(BitmapData item); | 106 | QPixmap* getPixmap(BitmapData item); |
107 | QPixmap* processEmbedded(const char *label, int h, int s, int v, bool blend=false); | 107 | QPixmap* processEmbedded(const char *label, int h, int s, int v, bool blend=false); |
108 | private: | 108 | private: |
109 | +bool flatTBButtons; | 109 | +bool flatTBButtons; |
110 | bool highcolor; | 110 | bool highcolor; |
111 | QColorGroup radioOnGrp; | 111 | QColorGroup radioOnGrp; |
112 | QWidget *highlightWidget; | 112 | QWidget *highlightWidget; |
113 | --- -Sat Sep 21 05:31:48 2002 | 113 | --- -2002-10-24 03:19:31.000000000 +0200 |
114 | +++ liquid.cppSat Sep 21 05:18:54 2002 | 114 | +++ liquid.cpp2002-10-24 03:18:15.000000000 +0200 |
115 | @@ -10,12 +10,10 @@ | 115 | @@ -10,12 +10,10 @@ |
116 | 116 | ||
117 | #include <qmenudata.h> | 117 | #include <qmenudata.h> |
118 | #include "liquid.h" | 118 | #include "liquid.h" |
119 | -#include <kapp.h> | 119 | -#include <kapp.h> |
120 | -#include <kglobal.h> | 120 | -#include <kglobal.h> |
121 | -#include <kconfig.h> | 121 | -#include <kconfig.h> |
122 | -#include <kdrawutil.h> | 122 | -#include <kdrawutil.h> |
123 | -#include <kglobalsettings.h> | 123 | -#include <kglobalsettings.h> |
124 | -#include <kpixmapeffect.h> | 124 | -#include <kpixmapeffect.h> |
125 | +#include "liquiddeco.h" | 125 | +//#include "liquiddeco.h" |
126 | +#include <qapplication.h> | 126 | +#include <qapplication.h> |
127 | +#include <qpe/config.h> | 127 | +#include <qpe/config.h> |
128 | +#include "effects.h" | 128 | +#include "effects.h" |
129 | #include <qpalette.h> | 129 | #include <qpalette.h> |
130 | #include <qbitmap.h> | 130 | #include <qbitmap.h> |
131 | #include <qtabbar.h> | 131 | #include <qtabbar.h> |
132 | @@ -25,28 +23,29 @@ | 132 | @@ -25,28 +23,29 @@ |
133 | #include <qtimer.h> | 133 | #include <qtimer.h> |
134 | #include <qpixmapcache.h> | 134 | #include <qpixmapcache.h> |
135 | #include <qradiobutton.h> | 135 | #include <qradiobutton.h> |
136 | -#include <kimageeffect.h> | 136 | -#include <kimageeffect.h> |
137 | -#include <ktoolbar.h> | 137 | -#include <ktoolbar.h> |
138 | +#include <qcombobox.h> | 138 | +#include <qcombobox.h> |
139 | #include <qdrawutil.h> | 139 | #include <qdrawutil.h> |
140 | #include <qwidgetlist.h> | 140 | #include <qwidgetlist.h> |
141 | #include <qtoolbutton.h> | 141 | #include <qtoolbutton.h> |
142 | #include <qheader.h> | 142 | #include <qheader.h> |
143 | #include <unistd.h> | 143 | #include <unistd.h> |
144 | -#include <klocale.h> | 144 | -#include <klocale.h> |
145 | -#include <kiconloader.h> | 145 | -#include <kiconloader.h> |
146 | -#include <kmenubar.h> | 146 | -#include <kmenubar.h> |
147 | -#include <kipc.h> | 147 | -#include <kipc.h> |
148 | +#include <qmenubar.h> | 148 | +#include <qmenubar.h> |
149 | +#include <qprogressbar.h> | ||
149 | 150 | ||
150 | -#include <X11/X.h> | 151 | -#include <X11/X.h> |
151 | -#include <X11/Xlib.h> | 152 | -#include <X11/Xlib.h> |
152 | + | ||
153 | +#include <stdio.h> | 153 | +#include <stdio.h> |
154 | 154 | ||
155 | #include "htmlmasks.h" | 155 | #include "htmlmasks.h" |
156 | #include "embeddata.h" | 156 | #include "embeddata.h" |
157 | 157 | ||
158 | -void TransMenuHandler::stripePixmap(KPixmap &pix, const QColor &color) | 158 | -void TransMenuHandler::stripePixmap(KPixmap &pix, const QColor &color) |
159 | +typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | 159 | +typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, |
160 | + QColorGroup &, bool, bool); | 160 | + QColorGroup &, bool, bool); |
161 | + | 161 | + |
162 | +QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); | 162 | +QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); |
163 | + | 163 | + |
164 | +void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) | 164 | +void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) |
165 | { | 165 | { |
166 | QImage img(pix.convertToImage()); | 166 | QImage img(pix.convertToImage()); |
167 | - KImageEffect::fade(img, 0.9, color); | 167 | - KImageEffect::fade(img, 0.9, color); |
168 | + QImageEffect::fade(img, 0.9, color); | 168 | + QImageEffect::fade(img, 0.9, color); |
169 | int x, y; | 169 | int x, y; |
170 | int r, g, b; | 170 | int r, g, b; |
171 | for(y=0; y < img.height(); y+=3){ | 171 | for(y=0; y < img.height(); y+=3){ |
172 | @@ -71,35 +70,37 @@ | 172 | @@ -71,35 +70,37 @@ |
173 | : QObject(parent) | 173 | : QObject(parent) |
174 | { | 174 | { |
175 | pixDict.setAutoDelete(true); | 175 | pixDict.setAutoDelete(true); |
176 | - connect(kapp, SIGNAL(kipcMessage(int, int)), this, | 176 | - connect(kapp, SIGNAL(kipcMessage(int, int)), this, |
177 | - SLOT(slotKIPCMessage(int, int))); | 177 | - SLOT(slotKIPCMessage(int, int))); |
178 | reloadSettings(); | 178 | reloadSettings(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void TransMenuHandler::reloadSettings() | 181 | void TransMenuHandler::reloadSettings() |
182 | { | 182 | { |
183 | pixDict.clear(); | 183 | pixDict.clear(); |
184 | - KConfig *config = KGlobal::config(); | 184 | - KConfig *config = KGlobal::config(); |
185 | - config->setGroup("MosfetMenus"); | 185 | - config->setGroup("MosfetMenus"); |
186 | 186 | ||
187 | - type = config->readNumEntry("Type", TransStippleBg); | 187 | - type = config->readNumEntry("Type", TransStippleBg); |
188 | - color = config->readColorEntry("Color", | 188 | - color = config->readColorEntry("Color", |
189 | - &QApplication::palette().active().button()); | 189 | - &QApplication::palette().active().button()); |
190 | - fgColor = config->readColorEntry("TextColor", | 190 | - fgColor = config->readColorEntry("TextColor", |
191 | - &QApplication::palette().active().text()); | 191 | - &QApplication::palette().active().text()); |
192 | - opacity = config->readNumEntry("Opacity", 10); | 192 | - opacity = config->readNumEntry("Opacity", 10); |
193 | - shadowText = config->readBoolEntry("ShadowText", true); | 193 | - shadowText = config->readBoolEntry("ShadowText", true); |
194 | + Config config ( "qpe" ); | 194 | + Config config ( "qpe" ); |
195 | + config. setGroup ( "Liquid-Style" ); | 195 | + config. setGroup ( "Liquid-Style" ); |
196 | + | 196 | + |
197 | + type = config. readNumEntry("Type", TransStippleBg); | 197 | + type = config. readNumEntry("Type", TransStippleBg); |
198 | + color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); | 198 | + color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); |
199 | + fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); | 199 | + fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); |
200 | + opacity = config. readNumEntry("Opacity", 10); | 200 | + opacity = config. readNumEntry("Opacity", 10); |
201 | + if ( opacity < -20 ) | 201 | + if ( opacity < -20 ) |
202 | + opacity = 20; | 202 | + opacity = 20; |
203 | + else if ( opacity > 20 ) | 203 | + else if ( opacity > 20 ) |
204 | + opacity = 20; | 204 | + opacity = 20; |
205 | + | 205 | + |
206 | + shadowText = config. readBoolEntry("ShadowText", true); | 206 | + shadowText = config. readBoolEntry("ShadowText", true); |
207 | } | 207 | } |
208 | 208 | ||
209 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | 209 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) |
210 | { | 210 | { |
211 | - QPopupMenu *p = (QPopupMenu *)obj; | 211 | - QPopupMenu *p = (QPopupMenu *)obj; |
212 | + QWidget *p = (QWidget *)obj; | 212 | + QWidget *p = (QWidget *)obj; |
213 | 213 | ||
214 | if(ev->type() == QEvent::Show){ | 214 | if(ev->type() == QEvent::Show){ |
215 | if(type == TransStippleBg || type == TransStippleBtn || | 215 | if(type == TransStippleBg || type == TransStippleBtn || |
216 | type == Custom){ | 216 | type == Custom){ |
217 | QApplication::syncX(); | 217 | QApplication::syncX(); |
218 | - KPixmap *pix = new KPixmap; | 218 | - KPixmap *pix = new KPixmap; |
219 | + QPixmap *pix = new QPixmap; | 219 | + QPixmap *pix = new QPixmap; |
220 | if(p->testWFlags(Qt::WType_Popup)){ | 220 | if(p->testWFlags(Qt::WType_Popup)){ |
221 | QRect r(p->x(), p->y(), p->width(), p->height()); | 221 | QRect r(p->x(), p->y(), p->width(), p->height()); |
222 | QRect deskR = QApplication::desktop()->rect(); | 222 | QRect deskR = QApplication::desktop()->rect(); |
223 | @@ -107,7 +108,7 @@ | 223 | @@ -107,7 +108,7 @@ |
224 | r.setBottom(deskR.bottom()); | 224 | r.setBottom(deskR.bottom()); |
225 | r.setRight(deskR.right()); | 225 | r.setRight(deskR.right()); |
226 | } | 226 | } |
227 | - *pix = QPixmap::grabWindow(qt_xrootwin(), r.x(), r.y(), | 227 | - *pix = QPixmap::grabWindow(qt_xrootwin(), r.x(), r.y(), |
228 | + *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), | 228 | + *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), |
229 | r.width(), r.height()); | 229 | r.width(), r.height()); |
230 | } | 230 | } |
231 | else{ // tear off menu | 231 | else{ // tear off menu |
232 | @@ -121,82 +122,55 @@ | 232 | @@ -121,82 +122,53 @@ |
233 | stripePixmap(*pix, p->colorGroup().button()); | 233 | stripePixmap(*pix, p->colorGroup().button()); |
234 | } | 234 | } |
235 | else{ | 235 | else{ |
236 | - KPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); | 236 | - KPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); |
237 | + QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); | 237 | + QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); |
238 | } | 238 | } |
239 | + | 239 | + |
240 | pixDict.insert(p->winId(), pix); | 240 | pixDict.insert(p->winId(), pix); |
241 | + | 241 | + |
242 | + if (!p->inherits("QPopupMenu")) { | 242 | + if ( !p->inherits("QPopupMenu")) |
243 | + p->setBackgroundPixmap(*pix); | 243 | + p->setBackgroundPixmap(*pix); |
244 | + | 244 | + |
245 | + QObjectList *ol = p-> queryList("QWidget"); | 245 | + QObjectList *ol = p-> queryList("QWidget"); |
246 | + for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 246 | + for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
247 | + QWidget *wid = (QWidget *) it.current ( ); | 247 | + QWidget *wid = (QWidget *) it.current ( ); |
248 | + | 248 | + |
249 | + wid-> setBackgroundPixmap(*pix); | 249 | + wid-> setBackgroundPixmap(*pix); |
250 | + wid-> setBackgroundOrigin(QWidget::ParentOrigin); | 250 | + wid-> setBackgroundOrigin(QWidget::ParentOrigin); |
251 | + } | 251 | + } |
252 | + delete ol; | 252 | + delete ol; |
253 | + } | ||
254 | } | 253 | } |
255 | } | 254 | } |
256 | else if(ev->type() == QEvent::Hide){ | 255 | else if(ev->type() == QEvent::Hide){ |
257 | if(type == TransStippleBg || type == TransStippleBtn || | 256 | if(type == TransStippleBg || type == TransStippleBtn || |
258 | type == Custom){ | 257 | type == Custom){ |
259 | - qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); | 258 | - qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); |
260 | - pixDict.remove(p->winId()); | 259 | - pixDict.remove(p->winId()); |
261 | - } | 260 | - } |
262 | - } | 261 | - } |
263 | - return(false); | 262 | - return(false); |
264 | -} | 263 | -} |
265 | - | 264 | - |
266 | -void TransMenuHandler::slotKIPCMessage(int id, int) | 265 | -void TransMenuHandler::slotKIPCMessage(int id, int) |
267 | -{ | 266 | -{ |
268 | - if(id == LIQUID_MENU_CHANGE){ | 267 | - if(id == LIQUID_MENU_CHANGE){ |
269 | - bool oldShadow = shadowText; | 268 | - bool oldShadow = shadowText; |
270 | +// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); | 269 | +// qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); |
271 | 270 | ||
272 | - KConfig *config = KGlobal::config(); | 271 | - KConfig *config = KGlobal::config(); |
273 | - config->reparseConfiguration(); // in case KControl changed values | 272 | - config->reparseConfiguration(); // in case KControl changed values |
274 | - | 273 | - |
275 | - // Make sure no popupmenus are shown. There shouldn't be any because | 274 | - // Make sure no popupmenus are shown. There shouldn't be any because |
276 | - // the user just clicked "Apply", but there can be tear offs ;-) | 275 | - // the user just clicked "Apply", but there can be tear offs ;-) |
277 | - // We just close them so the pixmaps are deleted and regenerated. | 276 | - // We just close them so the pixmaps are deleted and regenerated. |
278 | - QWidgetList *list = QApplication::topLevelWidgets(); | 277 | - QWidgetList *list = QApplication::topLevelWidgets(); |
279 | - QWidgetListIt it( *list ); | 278 | - QWidgetListIt it( *list ); |
280 | - QWidget *w; | 279 | - QWidget *w; |
281 | - while ((w=it.current()) != 0 ){ | 280 | - while ((w=it.current()) != 0 ){ |
282 | - ++it; | 281 | - ++it; |
283 | - if(w->inherits("QPopupMenu")){ | 282 | - if(w->inherits("QPopupMenu")){ |
284 | - w->close(); | 283 | - w->close(); |
285 | - } | 284 | - } |
286 | - } | 285 | - } |
287 | + pixDict.remove(p->winId()); | 286 | + pixDict.remove(p->winId()); |
288 | + if (!p->inherits("QPopupMenu")) { | 287 | + if ( !p->inherits("QPopupMenu")) |
289 | + p->setBackgroundMode(QWidget::PaletteBackground); | 288 | + p->setBackgroundMode(QWidget::PaletteBackground); |
290 | 289 | ||
291 | - reloadSettings(); | 290 | - reloadSettings(); |
292 | + QObjectList *ol = p-> queryList("QWidget"); | 291 | + QObjectList *ol = p-> queryList("QWidget"); |
293 | + for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 292 | + for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
294 | + QWidget *wid = (QWidget *) it.current ( ); | 293 | + QWidget *wid = (QWidget *) it.current ( ); |
295 | 294 | ||
296 | - // Now repaint menubar if needed | 295 | - // Now repaint menubar if needed |
297 | - if(shadowText != oldShadow){ | 296 | - if(shadowText != oldShadow){ |
298 | - it.toFirst(); | 297 | - it.toFirst(); |
299 | - while ((w=it.current()) != 0 ){ | 298 | - while ((w=it.current()) != 0 ){ |
300 | - ++it; | 299 | - ++it; |
301 | - if(w->inherits("QMenuBar")){ | 300 | - if(w->inherits("QMenuBar")){ |
302 | - w->repaint(); | 301 | - w->repaint(); |
303 | - } | 302 | + wid-> setBackgroundMode( QWidget::PaletteBackground ); |
304 | - } | 303 | } |
305 | + wid-> setBackgroundMode( QWidget::PaletteBackground ); | 304 | + delete ol; |
305 | } | ||
306 | } | 306 | } |
307 | - } | 307 | - } |
308 | - else if(id == MOSFET_BUTTON_CHANGE){ | 308 | - else if(id == MOSFET_BUTTON_CHANGE){ |
309 | - qWarning("In mosfet button change"); | 309 | - qWarning("In mosfet button change"); |
310 | - // really, this should be in LiquidStyle, but what the hell? ;-) | 310 | - // really, this should be in LiquidStyle, but what the hell? ;-) |
311 | - QWidgetList *list = QApplication::allWidgets(); | 311 | - QWidgetList *list = QApplication::allWidgets(); |
312 | - QWidgetListIt it( *list ); | 312 | - QWidgetListIt it( *list ); |
313 | - QWidget *w; | 313 | - QWidget *w; |
314 | - while ((w=it.current()) != 0 ){ | 314 | - while ((w=it.current()) != 0 ){ |
315 | - ++it; | 315 | - ++it; |
316 | - if(w->inherits("QPushButton")){ | 316 | - if(w->inherits("QPushButton")){ |
317 | - ((LiquidStyle*)parent())->unapplyCustomAttributes((QPushButton *)w); | 317 | - ((LiquidStyle*)parent())->unapplyCustomAttributes((QPushButton *)w); |
318 | - } | 318 | - } |
319 | - } | 319 | - } |
320 | - ((LiquidStyle*)parent())->loadCustomButtons(); | 320 | - ((LiquidStyle*)parent())->loadCustomButtons(); |
321 | - it.toFirst(); | 321 | - it.toFirst(); |
322 | - while ((w=it.current()) != 0 ){ | 322 | - while ((w=it.current()) != 0 ){ |
323 | - ++it; | 323 | - ++it; |
324 | - if(w->inherits("QPushButton")){ | 324 | - if(w->inherits("QPushButton")){ |
325 | - ((LiquidStyle*)parent())->applyCustomAttributes((QPushButton *)w); | 325 | - ((LiquidStyle*)parent())->applyCustomAttributes((QPushButton *)w); |
326 | + delete ol; | 326 | - } |
327 | } | 327 | - } |
328 | } | ||
329 | - | 328 | - |
330 | } | 329 | - } |
331 | + return(false); | 330 | + return(false); |
332 | } | 331 | } |
333 | 332 | ||
334 | + | 333 | + |
335 | LiquidStyle::LiquidStyle() | 334 | LiquidStyle::LiquidStyle() |
336 | - :KStyle() | 335 | - :KStyle() |
337 | + :QWindowsStyle() | 336 | + :QWindowsStyle() |
338 | { | 337 | { |
339 | + setName ( "LiquidStyle" ); | 338 | + setName ( "LiquidStyle" ); |
340 | + | 339 | + |
341 | +flatTBButtons = false; | 340 | +flatTBButtons = false; |
342 | + | 341 | + |
343 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 342 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
344 | btnMaskBmp.setMask(btnMaskBmp); | 343 | btnMaskBmp.setMask(btnMaskBmp); |
345 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 344 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
346 | @@ -711,7 +685,6 @@ | 345 | @@ -711,7 +683,6 @@ |
347 | 346 | ||
348 | void LiquidStyle::polish(QPalette &appPal) | 347 | void LiquidStyle::polish(QPalette &appPal) |
349 | { | 348 | { |
350 | - | 349 | - |
351 | int i; | 350 | int i; |
352 | for(i=0; i < BITMAP_ITEMS; ++i){ | 351 | for(i=0; i < BITMAP_ITEMS; ++i){ |
353 | if(pixmaps[i]){ | 352 | if(pixmaps[i]){ |
354 | @@ -730,20 +703,29 @@ | 353 | @@ -730,20 +701,29 @@ |
355 | } | 354 | } |
356 | 355 | ||
357 | loadCustomButtons(); | 356 | loadCustomButtons(); |
358 | - lowLightVal = 100 + (2*KGlobalSettings::contrast()+4)*10; | 357 | - lowLightVal = 100 + (2*KGlobalSettings::contrast()+4)*10; |
359 | + lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; | 358 | + lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10; |
360 | btnDict.clear(); | 359 | btnDict.clear(); |
361 | btnBorderDict.clear(); | 360 | btnBorderDict.clear(); |
362 | bevelFillDict.clear(); | 361 | bevelFillDict.clear(); |
363 | smallBevelFillDict.clear(); | 362 | smallBevelFillDict.clear(); |
364 | 363 | ||
365 | - KConfig *config = KGlobal::config(); | 364 | - KConfig *config = KGlobal::config(); |
366 | - QString oldGrp = config->group(); | 365 | - QString oldGrp = config->group(); |
367 | - QPalette pal = QApplication::palette(); | 366 | - QPalette pal = QApplication::palette(); |
368 | + Config config ( "qpe" ); | 367 | + Config config ( "qpe" ); |
369 | + config. setGroup ( "Liquid-Style" ); | 368 | + config. setGroup ( "Liquid-Style" ); |
370 | +int contrast = config. readNumEntry ( "StippleContrast", 5 ); | 369 | +int contrast = config. readNumEntry ( "StippleContrast", 5 ); |
371 | +if ( contrast < 0 ) | 370 | +if ( contrast < 0 ) |
372 | + contrast = 0; | 371 | + contrast = 0; |
373 | +else if ( contrast > 10 ) | 372 | +else if ( contrast > 10 ) |
374 | + contrast = 10; | 373 | + contrast = 10; |
375 | + | 374 | + |
376 | +// QPalette pal = QApplication::palette(); | 375 | +// QPalette pal = QApplication::palette(); |
377 | 376 | ||
378 | // button color stuff | 377 | // button color stuff |
379 | - config->setGroup("General"); | 378 | - config->setGroup("General"); |
380 | - QColor c = config->readColorEntry("buttonBackground", &Qt::lightGray); | 379 | - QColor c = config->readColorEntry("buttonBackground", &Qt::lightGray); |
381 | - if(c == config->readColorEntry("background", &Qt::lightGray)){ | 380 | - if(c == config->readColorEntry("background", &Qt::lightGray)){ |
382 | + config. setGroup ( "Appearance" ); | 381 | + config. setGroup ( "Appearance" ); |
383 | + QColor c = // QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); | 382 | + QColor c = // QColor ( config. readEntry("Button", ( Qt::lightGray ). name ( ))); |
384 | + appPal. color ( QPalette::Active, QColorGroup::Button ); | 383 | + appPal. color ( QPalette::Active, QColorGroup::Button ); |
385 | + if ( c == appPal. color ( QPalette::Active, QColorGroup::Background ) | 384 | + if ( c == appPal. color ( QPalette::Active, QColorGroup::Background ) |
386 | + //QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( ))) | 385 | + //QColor ( config. readEntry ( "background", ( Qt::lightGray ). name ( ))) |
387 | + ) { | 386 | + ) { |
388 | // force button color to be different from background | 387 | // force button color to be different from background |
389 | QBrush btnBrush(QColor(200, 202, 228)); | 388 | QBrush btnBrush(QColor(200, 202, 228)); |
390 | appPal.setBrush(QColorGroup::Button, btnBrush); | 389 | appPal.setBrush(QColorGroup::Button, btnBrush); |
391 | @@ -794,15 +776,7 @@ | 390 | @@ -794,15 +774,7 @@ |
392 | pagerBrush.setPixmap(*pix); | 391 | pagerBrush.setPixmap(*pix); |
393 | 392 | ||
394 | // background color stuff | 393 | // background color stuff |
395 | - c = config->readColorEntry("background", &Qt::lightGray); | 394 | - c = config->readColorEntry("background", &Qt::lightGray); |
396 | - if(qstrcmp(kapp->argv()[0], "kicker") == 0){ | 395 | - if(qstrcmp(kapp->argv()[0], "kicker") == 0){ |
397 | - appPal.setColor(QColorGroup::Mid, menuBrush.color().dark(110)); | 396 | - appPal.setColor(QColorGroup::Mid, menuBrush.color().dark(110)); |
398 | - appPal.setColor(QColorGroup::Dark, menuBrush.color().dark(130)); | 397 | - appPal.setColor(QColorGroup::Dark, menuBrush.color().dark(130)); |
399 | - appPal.setColor(QColorGroup::Midlight, menuBrush.color().light(110)); | 398 | - appPal.setColor(QColorGroup::Midlight, menuBrush.color().light(110)); |
400 | - appPal.setColor(QColorGroup::Light, menuBrush.color().light(115)); | 399 | - appPal.setColor(QColorGroup::Light, menuBrush.color().light(115)); |
401 | - menuBrush.setColor(c); // hack - used for kicker applets | 400 | - menuBrush.setColor(c); // hack - used for kicker applets |
402 | - appPal.setBrush(QColorGroup::Background, menuBrush); | 401 | - appPal.setBrush(QColorGroup::Background, menuBrush); |
403 | - } | 402 | - } |
404 | + c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background ); | 403 | + c = /*QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Background ); |
405 | c.hsv(&bH, &bS, &bV); | 404 | c.hsv(&bH, &bS, &bV); |
406 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); | 405 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); |
407 | 406 | ||
408 | @@ -817,21 +791,18 @@ | 407 | @@ -817,21 +789,18 @@ |
409 | wallPaper.fill(c.rgb()); | 408 | wallPaper.fill(c.rgb()); |
410 | painter.begin(&wallPaper); | 409 | painter.begin(&wallPaper); |
411 | for(i=0; i < 32; i+=4){ | 410 | for(i=0; i < 32; i+=4){ |
412 | - painter.setPen(c.dark(105)); | 411 | - painter.setPen(c.dark(105)); |
413 | + painter.setPen(c.dark(100 + contrast)); | 412 | + painter.setPen(c.dark(100 + contrast)); |
414 | painter.drawLine(0, i, 32, i); | 413 | painter.drawLine(0, i, 32, i); |
415 | - painter.setPen(c.dark(103)); | 414 | - painter.setPen(c.dark(103)); |
416 | + painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); | 415 | + painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); |
417 | painter.drawLine(0, i+1, 32, i+1); | 416 | painter.drawLine(0, i+1, 32, i+1); |
418 | }; | 417 | }; |
419 | painter.end(); | 418 | painter.end(); |
420 | bgBrush.setColor(c); | 419 | bgBrush.setColor(c); |
421 | bgBrush.setPixmap(wallPaper); | 420 | bgBrush.setPixmap(wallPaper); |
422 | - if(qstrcmp(kapp->argv()[0], "kicker") != 0 && | 421 | - if(qstrcmp(kapp->argv()[0], "kicker") != 0 && |
423 | - qstrcmp(kapp->argv()[0], "ksplash") != 0){ | 422 | - qstrcmp(kapp->argv()[0], "ksplash") != 0){ |
424 | appPal.setBrush(QColorGroup::Background, bgBrush); | 423 | appPal.setBrush(QColorGroup::Background, bgBrush); |
425 | - } | 424 | - } |
426 | 425 | ||
427 | // lineedits | 426 | // lineedits |
428 | - c = config->readColorEntry("windowBackground", &Qt::white); | 427 | - c = config->readColorEntry("windowBackground", &Qt::white); |
429 | + c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base ); | 428 | + c = /*QColor ( config. readEntry("Base", ( Qt::white). name ( )));*/ appPal. color ( QPalette::Active, QColorGroup::Base ); |
430 | QPixmap basePix; | 429 | QPixmap basePix; |
431 | basePix.resize(32, 32); | 430 | basePix.resize(32, 32); |
432 | basePix.fill(c.rgb()); | 431 | basePix.fill(c.rgb()); |
433 | @@ -856,52 +827,39 @@ | 432 | @@ -856,52 +825,37 @@ |
434 | applyCustomAttributes((QPushButton *)w); | 433 | applyCustomAttributes((QPushButton *)w); |
435 | } | 434 | } |
436 | } | 435 | } |
437 | - | 436 | - |
438 | - config->setGroup(oldGrp); | 437 | - config->setGroup(oldGrp); |
439 | } | 438 | } |
440 | 439 | ||
441 | void LiquidStyle::polish(QWidget *w) | 440 | void LiquidStyle::polish(QWidget *w) |
442 | { | 441 | { |
443 | if(w->inherits("QMenuBar")){ | 442 | if(w->inherits("QMenuBar")){ |
444 | - ((QFrame*)w)->setLineWidth(0); | 443 | - ((QFrame*)w)->setLineWidth(0); |
445 | - w->setBackgroundMode(QWidget::NoBackground); | 444 | - w->setBackgroundMode(QWidget::NoBackground); |
446 | + //((QFrame*)w)->setLineWidth(0); | 445 | + //((QFrame*)w)->setLineWidth(0); |
447 | + w->setBackgroundMode(QWidget::PaletteBackground); | 446 | + w->setBackgroundMode(QWidget::PaletteBackground); |
448 | + w->setBackgroundOrigin(QWidget::ParentOrigin); | 447 | + w->setBackgroundOrigin(QWidget::ParentOrigin); |
449 | + return; | 448 | + return; |
450 | + } | 449 | + } |
451 | + if(w->inherits("QToolBar")){ | 450 | + if(w->inherits("QToolBar")){ |
452 | + w->installEventFilter(this); | 451 | + w->installEventFilter(this); |
453 | + w->setBackgroundMode(QWidget::PaletteBackground); | 452 | + w->setBackgroundMode(QWidget::PaletteBackground); |
454 | + w->setBackgroundOrigin(QWidget::WidgetOrigin); | 453 | + w->setBackgroundOrigin(QWidget::WidgetOrigin); |
455 | return; | 454 | return; |
456 | } | 455 | } |
457 | if(w->inherits("QPopupMenu")) | 456 | if(w->inherits("QPopupMenu")) |
458 | w->setBackgroundMode(QWidget::NoBackground); | 457 | w->setBackgroundMode(QWidget::NoBackground); |
459 | + else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 458 | + else if(w-> testWFlags(Qt::WType_Popup) && |
459 | + !w->inherits("QListBox") && | ||
460 | + ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { | ||
460 | + w->installEventFilter(menuHandler); | 461 | + w->installEventFilter(menuHandler); |
461 | + } | 462 | + } |
462 | 463 | ||
463 | if(w->isTopLevel()){ | 464 | if(w->isTopLevel()){ |
464 | - if(!w->inherits("QPopupMenu") && | 465 | - if(!w->inherits("QPopupMenu") && |
465 | - qstrcmp(kapp->argv()[0], "kicker") == 0){ | 466 | - qstrcmp(kapp->argv()[0], "kicker") == 0){ |
466 | - qWarning("Got panel toplevel %s", w->className()); | 467 | - qWarning("Got panel toplevel %s", w->className()); |
467 | - // force extensions and child panels to use proper palette. | 468 | - // force extensions and child panels to use proper palette. |
468 | - if(w->inherits("Panel")){ | 469 | - if(w->inherits("Panel")){ |
469 | - qWarning("Setting panel palette"); | 470 | - qWarning("Setting panel palette"); |
470 | - w->setPalette(kapp->palette()); | 471 | - w->setPalette(kapp->palette()); |
471 | - } | 472 | - } |
472 | - else{ | 473 | - else{ |
473 | - // reset palette for everything else | 474 | - // reset palette for everything else |
474 | - QPalette pal = kapp->palette(); | 475 | - QPalette pal = kapp->palette(); |
475 | - pal.setBrush(QColorGroup::Background, bgBrush); | 476 | - pal.setBrush(QColorGroup::Background, bgBrush); |
476 | - pal.setColor(QColorGroup::Mid, bgBrush.color().dark(130)); | 477 | - pal.setColor(QColorGroup::Mid, bgBrush.color().dark(130)); |
477 | - pal.setColor(QColorGroup::Dark, bgBrush.color().dark(150)); | 478 | - pal.setColor(QColorGroup::Dark, bgBrush.color().dark(150)); |
478 | - pal.setColor(QColorGroup::Midlight, bgBrush.color().light(110)); | 479 | - pal.setColor(QColorGroup::Midlight, bgBrush.color().light(110)); |
479 | - pal.setColor(QColorGroup::Light, bgBrush.color().light(120)); | 480 | - pal.setColor(QColorGroup::Light, bgBrush.color().light(120)); |
480 | - w->setPalette(pal); | 481 | - w->setPalette(pal); |
481 | - } | 482 | - } |
482 | - } | 483 | - } |
483 | return; | 484 | return; |
484 | } | 485 | } |
485 | - if(qstrcmp(kapp->argv()[0], "kicker") == 0 && | 486 | - if(qstrcmp(kapp->argv()[0], "kicker") == 0 && |
486 | - w->inherits("KPanelExtension")){ // FIXME - doesn't work | 487 | - w->inherits("KPanelExtension")){ // FIXME - doesn't work |
487 | - w->setPalette(kapp->palette()); | 488 | - w->setPalette(kapp->palette()); |
488 | - } | 489 | - } |
489 | + | ||
490 | + | ||
491 | + if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) | ||
492 | + w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | ||
493 | 490 | ||
494 | if(w->inherits("QComboBox") || | 491 | - if(w->inherits("QComboBox") || |
492 | + if(w->inherits("QComboBox") || w->inherits("QProgressBar") || | ||
495 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 493 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
496 | - w->inherits("QCheckBox") || w->inherits("QScrollBar") || | 494 | - w->inherits("QCheckBox") || w->inherits("QScrollBar") || |
497 | - w->isA("AppletHandle") || w->inherits("KMiniPagerButton") || | 495 | - w->isA("AppletHandle") || w->inherits("KMiniPagerButton") || |
498 | - w->inherits("TaskContainer")){ | 496 | - w->inherits("TaskContainer")){ |
499 | + w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 497 | + w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
500 | w->installEventFilter(this); | 498 | w->installEventFilter(this); |
501 | } | 499 | } |
502 | if(w->inherits("QLineEdit")){ | 500 | if(w->inherits("QLineEdit")){ |
503 | @@ -913,6 +871,9 @@ | 501 | @@ -913,6 +867,10 @@ |
504 | applyCustomAttributes((QPushButton *)w); | 502 | applyCustomAttributes((QPushButton *)w); |
505 | w->installEventFilter(this); | 503 | w->installEventFilter(this); |
506 | } | 504 | } |
507 | + if(w->inherits("QButton") || w-> inherits("QComboBox")){ | 505 | + if(w->inherits("QButton") || w-> inherits("QComboBox")){ |
508 | + w-> setBackgroundMode ( QWidget::PaletteBackground ); | 506 | + w-> setBackgroundMode ( QWidget::PaletteBackground ); |
507 | + w->setBackgroundOrigin ( QWidget::ParentOrigin); | ||
509 | + } | 508 | + } |
510 | 509 | ||
511 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || | 510 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || |
512 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; | 511 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; |
513 | @@ -942,11 +903,14 @@ | 512 | @@ -942,11 +900,17 @@ |
514 | w->setMouseTracking(true); | 513 | w->setMouseTracking(true); |
515 | w->installEventFilter(this); | 514 | w->installEventFilter(this); |
516 | } | 515 | } |
517 | + if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { | 516 | + if(w-> inherits("QToolButton")&&w->parent()->inherits("QToolBar")) { |
518 | + ((QToolButton*)w)->setAutoRaise (flatTBButtons); | 517 | + ((QToolButton*)w)->setAutoRaise (flatTBButtons); |
519 | + if ( flatTBButtons ) | 518 | + if ( flatTBButtons ) |
520 | + w->setBackgroundOrigin(QWidget::ParentOrigin); | 519 | + w->setBackgroundOrigin(QWidget::ParentOrigin); |
521 | + } | 520 | + } |
521 | + if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) { | ||
522 | + ((QFrame *) w)-> setFrameShape ( QFrame::NoFrame ); | ||
523 | + } | ||
522 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 524 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
523 | return; | 525 | return; |
524 | } | 526 | } |
525 | - if(w->inherits("PanelButtonBase")) | 527 | - if(w->inherits("PanelButtonBase")) |
526 | - return; | 528 | - return; |
527 | 529 | ||
528 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 530 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
529 | palette().active().brush(QColorGroup::Background).pixmap()){ | 531 | palette().active().brush(QColorGroup::Background).pixmap()){ |
530 | @@ -954,17 +918,13 @@ | 532 | @@ -954,16 +918,21 @@ |
531 | return; | 533 | return; |
532 | } | 534 | } |
533 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && | 535 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && |
534 | - !w->inherits("KDesktop") && !w->inherits("PasswordDlg")){ | 536 | - !w->inherits("KDesktop") && !w->inherits("PasswordDlg")){ |
535 | + !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { | 537 | + !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { |
536 | if(w->backgroundMode() == QWidget::PaletteBackground || | 538 | if(w->backgroundMode() == QWidget::PaletteBackground || |
537 | w->backgroundMode() == QWidget::PaletteButton){ | 539 | w->backgroundMode() == QWidget::PaletteButton){ |
538 | w->setBackgroundMode(QWidget::X11ParentRelative); | 540 | - w->setBackgroundMode(QWidget::X11ParentRelative); |
541 | + w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/); | ||
542 | + w->setBackgroundOrigin(QWidget::ParentOrigin); | ||
543 | +// w->setBackgroundMode(QWidget::NoBackground); | ||
539 | } | 544 | } |
540 | } | 545 | } |
541 | - if(w->inherits("KToolBar")){ | 546 | - if(w->inherits("KToolBar")){ |
542 | - w->installEventFilter(this); | 547 | - w->installEventFilter(this); |
543 | - //w->setBackgroundMode(QWidget::NoBackground); | 548 | - //w->setBackgroundMode(QWidget::NoBackground); |
544 | - return; | 549 | - return; |
545 | - } | 550 | + if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) |
551 | + w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | ||
552 | +else if ( w-> inherits("QFrame") ) | ||
553 | + w->setBackgroundOrigin ( QWidget::WidgetOrigin ); | ||
546 | + | 554 | + |
555 | +if ( w->parentWidget()->inherits ( "QWidgetStack" )) { | ||
556 | + w->setBackgroundOrigin ( QWidget::WidgetOrigin ); | ||
557 | } | ||
547 | } | 558 | } |
548 | 559 | ||
549 | void LiquidStyle::unPolish(QWidget *w) | 560 | @@ -977,6 +946,11 @@ |
550 | @@ -977,6 +937,9 @@ | ||
551 | 561 | ||
552 | if(w->inherits("QPopupMenu")) | 562 | if(w->inherits("QPopupMenu")) |
553 | w->setBackgroundMode(QWidget::PaletteButton); | 563 | w->setBackgroundMode(QWidget::PaletteButton); |
554 | + else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 564 | + else if(w-> testWFlags(Qt::WType_Popup) && |
565 | + !w->inherits("QListBox") && | ||
566 | + ( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) { | ||
555 | + w->removeEventFilter(menuHandler); | 567 | + w->removeEventFilter(menuHandler); |
556 | + } | 568 | + } |
557 | 569 | ||
558 | if(w->isTopLevel()) | 570 | if(w->isTopLevel()) |
559 | return; | 571 | return; |
560 | @@ -986,7 +949,7 @@ | 572 | @@ -986,7 +960,7 @@ |
561 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 573 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
562 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 574 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
563 | 575 | ||
564 | - w->setPalette(QApplication::palette()); | 576 | - w->setPalette(QApplication::palette()); |
565 | + w->unsetPalette(); | 577 | + w->unsetPalette(); |
566 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ | 578 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ |
567 | if(w->inherits("QPushButton")) | 579 | if(w->inherits("QPushButton")) |
568 | w->setBackgroundMode(QWidget::PaletteButton); | 580 | w->setBackgroundMode(QWidget::PaletteButton); |
569 | @@ -1001,12 +964,14 @@ | 581 | @@ -1001,12 +975,14 @@ |
570 | unapplyCustomAttributes((QPushButton *)w); | 582 | unapplyCustomAttributes((QPushButton *)w); |
571 | w->removeEventFilter(this); | 583 | w->removeEventFilter(this); |
572 | } | 584 | } |
573 | - | 585 | - |
574 | +/* | 586 | +/* |
575 | + if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ | 587 | + if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ |
576 | + w-> setBackgroundMode ( PaletteBackground ); | 588 | + w-> setBackgroundMode ( PaletteBackground ); |
577 | + } | 589 | + } |
578 | +*/ | 590 | +*/ |
579 | if(w->inherits("QComboBox") || | 591 | if(w->inherits("QComboBox") || |
580 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 592 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
581 | - w->inherits("QCheckBox") || w->inherits("QScrollBar") || | 593 | - w->inherits("QCheckBox") || w->inherits("QScrollBar") || |
582 | - w->isA("AppletHandle") || w->inherits("KMiniPagerButton") || | 594 | - w->isA("AppletHandle") || w->inherits("KMiniPagerButton") || |
583 | - w->inherits("TaskContainer")){ | 595 | - w->inherits("TaskContainer")){ |
584 | + w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 596 | + w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
585 | w->removeEventFilter(this); | 597 | w->removeEventFilter(this); |
586 | } | 598 | } |
587 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 599 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
588 | @@ -1014,9 +979,9 @@ | 600 | @@ -1014,9 +990,9 @@ |
589 | w->setAutoMask(false); | 601 | w->setAutoMask(false); |
590 | } | 602 | } |
591 | } | 603 | } |
592 | - if(w->inherits("KToolBar")){ | 604 | - if(w->inherits("KToolBar")){ |
593 | + if(w->inherits("QToolBar")){ | 605 | + if(w->inherits("QToolBar")){ |
594 | w->removeEventFilter(this); | 606 | w->removeEventFilter(this); |
595 | - //w->setBackgroundMode(QWidget::PaletteBackground); | 607 | - //w->setBackgroundMode(QWidget::PaletteBackground); |
596 | + w->setBackgroundMode(QWidget::PaletteBackground); | 608 | + w->setBackgroundMode(QWidget::PaletteBackground); |
597 | return; | 609 | return; |
598 | } | 610 | } |
599 | if(w->inherits("QHeader")){ | 611 | if(w->inherits("QHeader")){ |
600 | @@ -1028,20 +993,34 @@ | 612 | @@ -1028,22 +1004,98 @@ |
601 | void LiquidStyle::polish(QApplication *app) | 613 | void LiquidStyle::polish(QApplication *app) |
602 | { | 614 | { |
603 | 615 | ||
604 | - KStyle::polish(app); | 616 | - KStyle::polish(app); |
605 | + QWindowsStyle::polish(app); | 617 | + QWindowsStyle::polish(app); |
606 | menuAni = app->isEffectEnabled(UI_AnimateMenu); | 618 | menuAni = app->isEffectEnabled(UI_AnimateMenu); |
607 | menuFade = app->isEffectEnabled(UI_FadeMenu); | 619 | menuFade = app->isEffectEnabled(UI_FadeMenu); |
608 | if(menuAni) | 620 | if(menuAni) |
609 | app->setEffectEnabled(UI_AnimateMenu, false); | 621 | app->setEffectEnabled(UI_AnimateMenu, false); |
610 | if(menuFade) | 622 | if(menuFade) |
611 | app->setEffectEnabled(UI_FadeMenu, false); | 623 | app->setEffectEnabled(UI_FadeMenu, false); |
612 | + | 624 | + |
613 | + qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); | 625 | + qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); |
614 | + | 626 | + |
615 | + Config config ( "qpe" ); | 627 | + Config config ( "qpe" ); |
616 | + config. setGroup ( "Liquid-Style" ); | 628 | + config. setGroup ( "Liquid-Style" ); |
617 | + | 629 | + |
618 | +// if ( config. readBoolEntry ( "WinDecoration", true )) | 630 | +// if ( config. readBoolEntry ( "WinDecoration", true )) |
619 | +// QApplication::qwsSetDecoration ( new LiquidDecoration ( )); | 631 | +// QApplication::qwsSetDecoration ( new LiquidDecoration ( )); |
620 | + | 632 | + |
621 | +flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); | 633 | +flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false ); |
622 | } | 634 | } |
623 | 635 | ||
624 | void LiquidStyle::unPolish(QApplication *app) | 636 | void LiquidStyle::unPolish(QApplication *app) |
625 | { | 637 | { |
626 | - KStyle::unPolish(app); | 638 | - KStyle::unPolish(app); |
627 | + QWindowsStyle::unPolish(app); | 639 | + QWindowsStyle::unPolish(app); |
628 | app->setEffectEnabled(UI_AnimateMenu, menuAni); | 640 | app->setEffectEnabled(UI_AnimateMenu, menuAni); |
629 | app->setEffectEnabled(UI_FadeMenu, menuFade); | 641 | app->setEffectEnabled(UI_FadeMenu, menuFade); |
630 | + | 642 | + |
631 | + qt_set_draw_menu_bar_impl ( 0 ); | 643 | + qt_set_draw_menu_bar_impl ( 0 ); |
632 | + | 644 | + |
633 | +// QApplication::qwsSetDecoration ( new QPEDecoration ( )); | 645 | +// QApplication::qwsSetDecoration ( new QPEDecoration ( )); |
634 | } | 646 | } |
635 | 647 | ||
648 | + | ||
649 | +/* !! HACK !! Beware | ||
650 | + * | ||
651 | + * TT forgot to make the QProgressBar widget styleable in Qt 2.x | ||
652 | + * So the only way to customize the drawing, is to intercept the | ||
653 | + * paint event - since we have to use protected functions, we need | ||
654 | + * to derive a "hack" class from QProgressBar and do the painting | ||
655 | + * in there. | ||
656 | + * | ||
657 | + * - sandman | ||
658 | + */ | ||
659 | + | ||
660 | +class HackProgressBar : public QProgressBar { | ||
661 | +public: | ||
662 | +HackProgressBar ( ); | ||
663 | + | ||
664 | +void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix ) | ||
665 | +{ | ||
666 | + QPainter p( this ); | ||
667 | + | ||
668 | + if ( !contentsRect().contains( event->rect() ) ) { | ||
669 | + p.save(); | ||
670 | + p.setClipRegion( event->region().intersect(frameRect()) ); | ||
671 | + drawFrame( &p); | ||
672 | + p.restore(); | ||
673 | + } | ||
674 | + if ( event->rect().intersects( contentsRect() )) { | ||
675 | + p.setClipRegion( event->region().intersect( contentsRect() ) ); | ||
676 | + | ||
677 | + int x, y, w, h; | ||
678 | + contentsRect ( ). rect ( &x, &y, &w, &h ); | ||
679 | + | ||
680 | + int prog = progress ( ); | ||
681 | + int total = totalSteps ( ); | ||
682 | + if ( prog < 0 ) | ||
683 | + prog = 0; | ||
684 | + if ( total <= 0 ) | ||
685 | + total = 1; | ||
686 | + int bw = w * prog / total; | ||
687 | + if ( bw > w ) | ||
688 | + bw = w; | ||
689 | + | ||
690 | + p.setPen(g.button().dark(130)); | ||
691 | + p.drawRect(x, y, bw, h); | ||
692 | + p.setPen(g.button().light(120)); | ||
693 | + p.drawRect(x+1, y+1, bw-2, h-2); | ||
694 | + | ||
695 | + if(bw >= 4 && h >= 4 && pix) | ||
696 | + p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix); | ||
697 | + | ||
698 | + if ( progress ( )>= 0 && totalSteps ( ) > 0 ) { | ||
699 | + QString pstr; | ||
700 | + pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ()); | ||
701 | + p. setPen ( g.text());//g.highlightedText ( )); | ||
702 | + p. drawText (x,y,w-1,h-1,AlignCenter,pstr); | ||
703 | + } | ||
704 | + } | ||
705 | +} | ||
706 | +}; | ||
707 | + | ||
708 | + | ||
709 | + | ||
636 | /* | 710 | /* |
637 | @@ -1063,7 +1042,7 @@ | 711 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
712 | * force everything to erase and repaint on resize. This is going away, I'm | ||
713 | @@ -1063,7 +1115,7 @@ | ||
638 | */ | 714 | */ |
639 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | 715 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) |
640 | { | 716 | { |
641 | - if(obj->inherits("KToolBar")){ | 717 | - if(obj->inherits("KToolBar")){ |
642 | + if(obj->inherits("QToolBar")){ | 718 | + if(obj->inherits("QToolBar")){ |
643 | if(ev->type() == QEvent::Resize){ | 719 | if(ev->type() == QEvent::Resize){ |
644 | const QObjectList *tbChildList = obj->children(); | 720 | const QObjectList *tbChildList = obj->children(); |
645 | QObjectListIt it(*tbChildList); | 721 | QObjectListIt it(*tbChildList); |
646 | @@ -1076,35 +1055,7 @@ | 722 | @@ -1076,35 +1128,7 @@ |
647 | 723 | ||
648 | } | 724 | } |
649 | } | 725 | } |
650 | - else if(obj->inherits("KMiniPagerButton")){ | 726 | - else if(obj->inherits("KMiniPagerButton")){ |
651 | - QButton *btn = (QButton *)obj; | 727 | - QButton *btn = (QButton *)obj; |
652 | - if(ev->type() == QEvent::Paint){ | 728 | - if(ev->type() == QEvent::Paint){ |
653 | - if(!(btn->isOn() || btn->isDown())){ | 729 | - if(!(btn->isOn() || btn->isDown())){ |
654 | - QPalette pal = btn->palette(); | 730 | - QPalette pal = btn->palette(); |
655 | - pal.setBrush(QColorGroup::Dark, btn == highlightWidget ? | 731 | - pal.setBrush(QColorGroup::Dark, btn == highlightWidget ? |
656 | - pagerHoverBrush : pagerBrush); | 732 | - pagerHoverBrush : pagerBrush); |
657 | - btn->setPalette(pal); | 733 | - btn->setPalette(pal); |
658 | - } | 734 | - } |
659 | - else{ | 735 | - else{ |
660 | - QPalette pal = btn->palette(); | 736 | - QPalette pal = btn->palette(); |
661 | - pal.setBrush(QColorGroup::Dark, | 737 | - pal.setBrush(QColorGroup::Dark, |
662 | - QApplication::palette().active().brush(QColorGroup::Dark)); | 738 | - QApplication::palette().active().brush(QColorGroup::Dark)); |
663 | - btn->setPalette(pal); | 739 | - btn->setPalette(pal); |
664 | - | 740 | - |
665 | - } | 741 | - } |
666 | - } | 742 | - } |
667 | - else if(ev->type() == QEvent::Enter){ | 743 | - else if(ev->type() == QEvent::Enter){ |
668 | - highlightWidget = btn; | 744 | - highlightWidget = btn; |
669 | - btn->repaint(false); | 745 | - btn->repaint(false); |
670 | - } | 746 | - } |
671 | - else if(ev->type() == QEvent::Leave){ | 747 | - else if(ev->type() == QEvent::Leave){ |
672 | - highlightWidget = NULL; | 748 | - highlightWidget = NULL; |
673 | - btn->repaint(false); | 749 | - btn->repaint(false); |
674 | - } | 750 | - } |
675 | - | 751 | - |
676 | - } | 752 | - } |
677 | - else if(obj->inherits("QPushButton") || obj->inherits("QComboBox") || | 753 | - else if(obj->inherits("QPushButton") || obj->inherits("QComboBox") || |
678 | - obj->isA("AppletHandle")){ | 754 | - obj->isA("AppletHandle")){ |
679 | + else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ | 755 | + else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ |
680 | QWidget *btn = (QWidget *)obj; | 756 | QWidget *btn = (QWidget *)obj; |
681 | if(ev->type() == QEvent::Enter){ | 757 | if(ev->type() == QEvent::Enter){ |
682 | if(btn->isEnabled()){ | 758 | if(btn->isEnabled()){ |
683 | @@ -1119,20 +1070,7 @@ | 759 | @@ -1119,20 +1143,7 @@ |
684 | } | 760 | } |
685 | } | 761 | } |
686 | } | 762 | } |
687 | - else if(obj->inherits("TaskContainer")){ | 763 | - else if(obj->inherits("TaskContainer")){ |
688 | - QButton *btn = (QButton *)obj; | 764 | - QButton *btn = (QButton *)obj; |
689 | - QPalette pal = btn->palette(); | 765 | - QPalette pal = btn->palette(); |
690 | - if(ev->type() == QEvent::Enter){ | 766 | - if(ev->type() == QEvent::Enter){ |
691 | - pal.setColor(QColorGroup::Background, pal.active().button().light(110)); | 767 | - pal.setColor(QColorGroup::Background, pal.active().button().light(110)); |
692 | - btn->setPalette(pal); | 768 | - btn->setPalette(pal); |
693 | - } | 769 | - } |
694 | - else if(ev->type() == QEvent::Leave){ | 770 | - else if(ev->type() == QEvent::Leave){ |
695 | - pal.setColor(QColorGroup::Background, | 771 | - pal.setColor(QColorGroup::Background, |
696 | - QApplication::palette().active().background()); | 772 | - QApplication::palette().active().background()); |
697 | - btn->setPalette(pal); | 773 | - btn->setPalette(pal); |
698 | - } | 774 | - } |
699 | - } | 775 | - } |
700 | - else if(obj->inherits("QToolButton") && !obj->inherits("KToolBarButton")){ | 776 | - else if(obj->inherits("QToolButton") && !obj->inherits("KToolBarButton")){ |
701 | + else if(obj->inherits("QToolButton")){ | 777 | + else if(obj->inherits("QToolButton")){ |
702 | QToolButton *btn = (QToolButton *)btn; | 778 | QToolButton *btn = (QToolButton *)btn; |
703 | if(!btn->autoRaise()){ | 779 | if(!btn->autoRaise()){ |
704 | if(btn->isEnabled()){ | 780 | if(btn->isEnabled()){ |
705 | @@ -1340,11 +1278,6 @@ | 781 | @@ -1290,7 +1301,24 @@ |
782 | } | ||
783 | } | ||
784 | } | ||
785 | - return(false); | ||
786 | + else if (obj-> inherits( "QProgressBar" )) { | ||
787 | + if ( ev->type() == QEvent::Paint ) { | ||
788 | + HackProgressBar *p = (HackProgressBar *) obj; | ||
789 | + const QColorGroup &g = p-> colorGroup ( ); | ||
790 | + | ||
791 | + QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); | ||
792 | + if(!pix){ | ||
793 | + int h, s, v; | ||
794 | + g.button().dark(120).hsv(&h, &s, &v); | ||
795 | + pix = new QPixmap(*bevelFillPix); | ||
796 | + adjustHSV(*pix, h, s, v); | ||
797 | + bevelFillDict.insert(g.button().dark(120).rgb(), pix); | ||
798 | + } | ||
799 | + p-> paint ((QPaintEvent *) ev, g, pix ); | ||
800 | + return true; | ||
801 | + } | ||
802 | + } | ||
803 | +return false ; | ||
804 | } | ||
805 | |||
806 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | ||
807 | @@ -1340,11 +1368,6 @@ | ||
706 | QColorGroup g = btn->colorGroup(); | 808 | QColorGroup g = btn->colorGroup(); |
707 | 809 | ||
708 | 810 | ||
709 | - QColor testColor; | 811 | - QColor testColor; |
710 | - if(btn->parent() && btn->parent()->isWidgetType()){ | 812 | - if(btn->parent() && btn->parent()->isWidgetType()){ |
711 | - testColor = p->backgroundColor(); // remove me | 813 | - testColor = p->backgroundColor(); // remove me |
712 | - } | 814 | - } |
713 | - | 815 | - |
714 | //int dw = buttonDefaultIndicatorWidth(); | 816 | //int dw = buttonDefaultIndicatorWidth(); |
715 | if(btn->hasFocus() || btn->isDefault()){ | 817 | if(btn->hasFocus() || btn->isDefault()){ |
716 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); | 818 | QColor c = btn->hasFocus() ? g.button().light(110) : g.background(); |
717 | @@ -1596,7 +1529,7 @@ | 819 | @@ -1596,7 +1619,7 @@ |
718 | if(sbBuffer.size() != sb->size()) | 820 | if(sbBuffer.size() != sb->size()) |
719 | sbBuffer.resize(sb->size()); | 821 | sbBuffer.resize(sb->size()); |
720 | } | 822 | } |
721 | - subB.setRect( subX,subY,buttonDim,buttonDim ); | 823 | - subB.setRect( subX,subY,buttonDim,buttonDim ); |
722 | + subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); | 824 | + subB.setRect( subX,subY,0,0); // buttonDim,buttonDim ); |
723 | addB.setRect( addX,addY,buttonDim,buttonDim ); | 825 | addB.setRect( addX,addY,buttonDim,buttonDim ); |
724 | if(horiz) | 826 | if(horiz) |
725 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); | 827 | subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim ); |
726 | @@ -1624,7 +1557,7 @@ | 828 | @@ -1624,7 +1647,7 @@ |
727 | QPainter painter; | 829 | QPainter painter; |
728 | if(!horiz){ | 830 | if(!horiz){ |
729 | painter.begin(&sbBuffer); | 831 | painter.begin(&sbBuffer); |
730 | - QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*3))+1); | 832 | - QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*3))+1); |
731 | + QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); | 833 | + QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1); |
732 | if(sliderR.height() >= 8){ | 834 | if(sliderR.height() >= 8){ |
733 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, | 835 | painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0, |
734 | 13, 8); | 836 | 13, 8); |
735 | @@ -1690,7 +1623,7 @@ | 837 | @@ -1690,7 +1713,7 @@ |
736 | } | 838 | } |
737 | else{ | 839 | else{ |
738 | painter.begin(&sbBuffer); | 840 | painter.begin(&sbBuffer); |
739 | - QRect bgR(subB.right()+1, 0, (len-(buttonDim*3))+1, sb->height()); | 841 | - QRect bgR(subB.right()+1, 0, (len-(buttonDim*3))+1, sb->height()); |
740 | + QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); | 842 | + QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height()); |
741 | if(sliderR.width() >= 8){ | 843 | if(sliderR.width() >= 8){ |
742 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, | 844 | painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0, |
743 | 8, 13); | 845 | 8, 13); |
744 | @@ -1761,10 +1694,10 @@ | 846 | @@ -1761,10 +1784,10 @@ |
745 | addB.width()-8, addB.height()-8, g, !maxed); | 847 | addB.width()-8, addB.height()-8, g, !maxed); |
746 | } | 848 | } |
747 | if ( controls & SubLine ) { | 849 | if ( controls & SubLine ) { |
748 | - drawSBButton(p, subB, g, activeControl == SubLine); | 850 | - drawSBButton(p, subB, g, activeControl == SubLine); |
749 | - drawArrow( p, horiz ? LeftArrow : UpArrow, | 851 | - drawArrow( p, horiz ? LeftArrow : UpArrow, |
750 | - false, subB.x()+4, subB.y()+4, | 852 | - false, subB.x()+4, subB.y()+4, |
751 | - subB.width()-8, subB.height()-8, g, !maxed); | 853 | - subB.width()-8, subB.height()-8, g, !maxed); |
752 | + // drawSBButton(p, subB, g, activeControl == SubLine); | 854 | + // drawSBButton(p, subB, g, activeControl == SubLine); |
753 | + // drawArrow( p, horiz ? LeftArrow : UpArrow, | 855 | + // drawArrow( p, horiz ? LeftArrow : UpArrow, |
754 | + // false, subB.x()+4, subB.y()+4, | 856 | + // false, subB.x()+4, subB.y()+4, |
755 | + // subB.width()-8, subB.height()-8, g, !maxed); | 857 | + // subB.width()-8, subB.height()-8, g, !maxed); |
756 | drawSBButton(p, subHC, g, activeControl == SubLine); | 858 | drawSBButton(p, subHC, g, activeControl == SubLine); |
757 | drawArrow( p, horiz ? LeftArrow : UpArrow, | 859 | drawArrow( p, horiz ? LeftArrow : UpArrow, |
758 | false, subHC.x()+4, subHC.y()+4, | 860 | false, subHC.x()+4, subHC.y()+4, |
759 | @@ -1865,8 +1798,8 @@ | 861 | @@ -1865,8 +1888,8 @@ |
760 | else | 862 | else |
761 | buttonDim = ( length - b*2 )/2 - 1; | 863 | buttonDim = ( length - b*2 )/2 - 1; |
762 | 864 | ||
763 | - sliderMin = b + buttonDim; | 865 | - sliderMin = b + buttonDim; |
764 | - maxLength = length - b*2 - buttonDim*3; | 866 | - maxLength = length - b*2 - buttonDim*3; |
765 | + sliderMin = b + 0; // buttonDim; | 867 | + sliderMin = b + 0; // buttonDim; |
766 | + maxLength = length - b*2 - buttonDim*2; // 3; | 868 | + maxLength = length - b*2 - buttonDim*2; // 3; |
767 | 869 | ||
768 | if ( sb->maxValue() == sb->minValue() ) { | 870 | if ( sb->maxValue() == sb->minValue() ) { |
769 | sliderLength = maxLength; | 871 | sliderLength = maxLength; |
770 | @@ -1914,8 +1847,8 @@ | 872 | @@ -1914,8 +1937,8 @@ |
771 | return(QSize(16, 16)); | 873 | return(QSize(16, 16)); |
772 | } | 874 | } |
773 | 875 | ||
774 | -void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, | 876 | -void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int w, |
775 | - int h, const QColorGroup &g, bool on, | 877 | - int h, const QColorGroup &g, bool on, |
776 | +void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, | 878 | +void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, |
777 | + int /*h*/, const QColorGroup &/*g*/, bool on, | 879 | + int /*h*/, const QColorGroup &/*g*/, bool on, |
778 | bool down, bool) | 880 | bool down, bool) |
779 | { | 881 | { |
780 | bool isHover = highlightWidget == p->device(); | 882 | bool isHover = highlightWidget == p->device(); |
781 | @@ -1957,8 +1890,8 @@ | 883 | @@ -1957,8 +1980,8 @@ |
782 | return(QSize(20, 22)); | 884 | return(QSize(20, 22)); |
783 | } | 885 | } |
784 | 886 | ||
785 | -void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int w, int h, | 887 | -void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int w, int h, |
786 | - const QColorGroup &g, int state, bool down, bool) | 888 | - const QColorGroup &g, int state, bool down, bool) |
787 | +void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 889 | +void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
788 | + const QColorGroup &/*g*/, int state, bool /*down*/, bool) | 890 | + const QColorGroup &/*g*/, int state, bool /*down*/, bool) |
789 | { | 891 | { |
790 | bool isHover = highlightWidget == p->device(); | 892 | bool isHover = highlightWidget == p->device(); |
791 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget | 893 | bool isMasked = p->device() && p->device()->devType() == QInternal::Widget |
792 | @@ -1996,8 +1929,8 @@ | 894 | @@ -1996,8 +2019,8 @@ |
793 | } | 895 | } |
794 | } | 896 | } |
795 | 897 | ||
796 | -void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int w, int h, | 898 | -void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int w, int h, |
797 | - int state) | 899 | - int state) |
798 | +void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 900 | +void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
799 | + int /*state*/) | 901 | + int /*state*/) |
800 | { | 902 | { |
801 | // needed for some reason by KHtml, even tho it's all filled ;P | 903 | // needed for some reason by KHtml, even tho it's all filled ;P |
802 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); | 904 | p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); |
803 | @@ -2005,18 +1938,17 @@ | 905 | @@ -2005,18 +2028,17 @@ |
804 | } | 906 | } |
805 | 907 | ||
806 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, | 908 | void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, |
807 | - const QColorGroup &g, Orientation orient, | 909 | - const QColorGroup &g, Orientation orient, |
808 | + const QColorGroup &/*g*/, Orientation orient, | 910 | + const QColorGroup &/*g*/, Orientation orient, |
809 | bool, bool) | 911 | bool, bool) |
810 | { | 912 | { |
811 | QWidget *parent = (QWidget *)p->device(); | 913 | QWidget *parent = (QWidget *)p->device(); |
812 | p->setBrushOrigin(parent->pos()); | 914 | p->setBrushOrigin(parent->pos()); |
813 | - p->fillRect(x, y, w, h, | 915 | - p->fillRect(x, y, w, h, |
814 | - QApplication::palette().active().brush(QColorGroup::Background)); | 916 | - QApplication::palette().active().brush(QColorGroup::Background)); |
815 | + parent->erase(x, y, w, h); | 917 | + parent->erase(x, y, w, h); |
816 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : | 918 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : |
817 | *getPixmap(VSlider)); | 919 | *getPixmap(VSlider)); |
818 | } | 920 | } |
819 | 921 | ||
820 | -void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int w, int h, | 922 | -void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int w, int h, |
821 | +void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, | 923 | +void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, |
822 | Orientation orient, bool, bool) | 924 | Orientation orient, bool, bool) |
823 | { | 925 | { |
824 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : | 926 | p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : |
825 | @@ -2065,203 +1997,26 @@ | 927 | @@ -2065,203 +2087,26 @@ |
826 | p->drawLineSegments(a); | 928 | p->drawLineSegments(a); |
827 | } | 929 | } |
828 | 930 | ||
829 | -void LiquidStyle::drawKBarHandle(QPainter *p, int x, int y, int w, int h, | 931 | -void LiquidStyle::drawKBarHandle(QPainter *p, int x, int y, int w, int h, |
830 | - const QColorGroup &g, KToolBarPos, | 932 | - const QColorGroup &g, KToolBarPos, |
831 | - QBrush *) | 933 | - QBrush *) |
832 | -{ | 934 | -{ |
833 | - p->setPen(g.button().dark(120)); | 935 | - p->setPen(g.button().dark(120)); |
834 | - int x2 = x+w-1; | 936 | - int x2 = x+w-1; |
835 | - int y2 = y+h-1; | 937 | - int y2 = y+h-1; |
836 | - p->drawLine(x+1, y, x2-1, y); | 938 | - p->drawLine(x+1, y, x2-1, y); |
837 | - p->drawLine(x+1, y2, x2-1, y2); | 939 | - p->drawLine(x+1, y2, x2-1, y2); |
838 | - p->drawLine(x, y+1, x, y2-1); | 940 | - p->drawLine(x, y+1, x, y2-1); |
839 | - p->drawLine(x2, y+1, x2, y2-1); | 941 | - p->drawLine(x2, y+1, x2, y2-1); |
840 | - | 942 | - |
841 | - p->setPen(g.background()); | 943 | - p->setPen(g.background()); |
842 | - p->drawPoint(x, y); | 944 | - p->drawPoint(x, y); |
843 | - p->drawPoint(x2, y); | 945 | - p->drawPoint(x2, y); |
844 | - p->drawPoint(x, y2); | 946 | - p->drawPoint(x, y2); |
845 | - p->drawPoint(x2, y2); | 947 | - p->drawPoint(x2, y2); |
846 | - | 948 | - |
847 | - | 949 | |
848 | - | 950 | - |
849 | - // p->drawRect(x, y, w, h); | 951 | - // p->drawRect(x, y, w, h); |
850 | - QPixmap *pix = bevelFillDict.find(g.button().rgb()); | 952 | - QPixmap *pix = bevelFillDict.find(g.button().rgb()); |
851 | - if(!pix){ | 953 | - if(!pix){ |
852 | - int h, s, v; | 954 | - int h, s, v; |
853 | - g.button().hsv(&h, &s, &v); | 955 | - g.button().hsv(&h, &s, &v); |
854 | - pix = new QPixmap(*bevelFillPix); | 956 | - pix = new QPixmap(*bevelFillPix); |
855 | - adjustHSV(*pix, h, s, v); | 957 | - adjustHSV(*pix, h, s, v); |
856 | - bevelFillDict.insert(g.button().rgb(), pix); | 958 | - bevelFillDict.insert(g.button().rgb(), pix); |
857 | - } | 959 | - } |
858 | - | 960 | - |
859 | - p->drawTiledPixmap(x+1, y+1, w-2, h-2, *pix); | 961 | - p->drawTiledPixmap(x+1, y+1, w-2, h-2, *pix); |
860 | -} | 962 | -} |
861 | - | 963 | - |
862 | -void LiquidStyle::drawKMenuBar(QPainter *p, int x, int y, int w, int h, | 964 | -void LiquidStyle::drawKMenuBar(QPainter *p, int x, int y, int w, int h, |
863 | - const QColorGroup &g, bool mac, QBrush *) | 965 | - const QColorGroup &g, bool mac, QBrush *) |
864 | -{ | 966 | +void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, |
967 | + QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) | ||
968 | { | ||
865 | - if(p->device() && p->device()->devType() == QInternal::Widget && | 969 | - if(p->device() && p->device()->devType() == QInternal::Widget && |
866 | - ((KMenuBar *)p->device())->isTopLevelMenu()){ | 970 | - ((KMenuBar *)p->device())->isTopLevelMenu()){ |
867 | - p->setPen(Qt::black); | 971 | - p->setPen(Qt::black); |
868 | - p->drawRect(x, y, w, h); | 972 | - p->drawRect(x, y, w, h); |
869 | - p->drawTiledPixmap(x+1, y+1, w-2, h-2, *menuPix); | 973 | - p->drawTiledPixmap(x+1, y+1, w-2, h-2, *menuPix); |
870 | - // left | 974 | - // left |
871 | - p->drawLine(x+1, y+1, x+1, y+5); | 975 | - p->drawLine(x+1, y+1, x+1, y+5); |
872 | - p->drawLine(x+2, y+1, x+2, y+3); | 976 | - p->drawLine(x+2, y+1, x+2, y+3); |
873 | - p->drawLine(x+3, y+1, x+3, y+2); | 977 | - p->drawLine(x+3, y+1, x+3, y+2); |
874 | - p->drawLine(x+4, y+1, x+6, y+1); | 978 | - p->drawLine(x+4, y+1, x+6, y+1); |
875 | - // right | 979 | - // right |
876 | - int x2 = x+w-1; | 980 | - int x2 = x+w-1; |
877 | - p->drawLine(x2-1, y+1, x2-1, y+5); | 981 | - p->drawLine(x2-1, y+1, x2-1, y+5); |
878 | - p->drawLine(x2-2, y+1, x2-2, y+3); | 982 | - p->drawLine(x2-2, y+1, x2-2, y+3); |
879 | - p->drawLine(x2-3, y+1, x2-3, y+2); | 983 | - p->drawLine(x2-3, y+1, x2-3, y+2); |
880 | - p->drawLine(x2-4, y+1, x2-6, y+1); | 984 | - p->drawLine(x2-4, y+1, x2-6, y+1); |
881 | - } | 985 | - } |
882 | - else{ | 986 | - else{ |
883 | - qDrawShadePanel(p, x, y, w, h, g, false, 1, | 987 | - qDrawShadePanel(p, x, y, w, h, g, false, 1, |
884 | - &g.brush(QColorGroup::Background)); | 988 | - &g.brush(QColorGroup::Background)); |
885 | - } | 989 | - } |
886 | - | 990 | - |
887 | -} | 991 | -} |
888 | 992 | - | |
889 | -void LiquidStyle::drawKToolBar(QPainter *p, int x, int y, int w, int h, | 993 | -void LiquidStyle::drawKToolBar(QPainter *p, int x, int y, int w, int h, |
890 | - const QColorGroup &g, KToolBarPos, QBrush *) | 994 | - const QColorGroup &g, KToolBarPos, QBrush *) |
891 | +void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, | 995 | -{ |
892 | + QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) | ||
893 | { | ||
894 | - //p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); | 996 | - //p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); |
895 | -} | 997 | -} |
896 | - | 998 | - |
897 | -void LiquidStyle::drawKToolBarButton(QPainter *p, int x, int y, int w, int h, | 999 | -void LiquidStyle::drawKToolBarButton(QPainter *p, int x, int y, int w, int h, |
898 | - const QColorGroup &g, bool sunken, | 1000 | - const QColorGroup &g, bool sunken, |
899 | - bool raised, bool enabled, bool popup, | 1001 | - bool raised, bool enabled, bool popup, |
900 | - KToolButtonType icontext, | 1002 | - KToolButtonType icontext, |
901 | - const QString& btext, const QPixmap *pixmap, | 1003 | - const QString& btext, const QPixmap *pixmap, |
902 | - QFont *font, QWidget *btn) | 1004 | - QFont *font, QWidget *btn) |
903 | -{ | 1005 | -{ |
904 | - int dx, dy; | 1006 | - int dx, dy; |
905 | - | 1007 | - |
906 | - QFontMetrics fm(*font); | 1008 | - QFontMetrics fm(*font); |
907 | - | 1009 | - |
908 | - QToolBar* toolbar = 0; | 1010 | - QToolBar* toolbar = 0; |
909 | - if(btn->parent() && btn->parent()->isWidgetType() && btn->parent()->inherits("QToolBar")) | 1011 | - if(btn->parent() && btn->parent()->isWidgetType() && btn->parent()->inherits("QToolBar")) |
910 | - toolbar = static_cast<QToolBar*>(btn->parent()); | 1012 | - toolbar = static_cast<QToolBar*>(btn->parent()); |
911 | - | 1013 | - |
912 | - --w, --h; | 1014 | - --w, --h; |
913 | - if(sunken) | 1015 | - if(sunken) |
914 | - ++x, ++y; | 1016 | - ++x, ++y; |
915 | - | 1017 | - |
916 | - QColor btnColor(sunken ? g.button() : raised ? g.button().light(110) : | 1018 | - QColor btnColor(sunken ? g.button() : raised ? g.button().light(110) : |
917 | - g.background()); | 1019 | - g.background()); |
918 | - drawClearBevel(p, x, y, w, h, btnColor, g.background()); | 1020 | - drawClearBevel(p, x, y, w, h, btnColor, g.background()); |
919 | - | 1021 | - |
920 | - p->setPen(g.text()); | 1022 | - p->setPen(g.text()); |
921 | - | 1023 | - |
922 | - if (icontext == Icon){ // icon only | 1024 | - if (icontext == Icon){ // icon only |
923 | - if (pixmap){ | 1025 | - if (pixmap){ |
924 | - dx = ( w - pixmap->width() ) / 2; | 1026 | - dx = ( w - pixmap->width() ) / 2; |
925 | - dy = ( h - pixmap->height() ) / 2; | 1027 | - dy = ( h - pixmap->height() ) / 2; |
926 | - if ( sunken ) | 1028 | - if ( sunken ) |
927 | - { | 1029 | - { |
928 | - ++dx; | 1030 | - ++dx; |
929 | - ++dy; | 1031 | - ++dy; |
930 | - } | 1032 | - } |
931 | - p->drawPixmap( x+dx, y+dy, *pixmap ); | 1033 | - p->drawPixmap( x+dx, y+dy, *pixmap ); |
932 | - } | 1034 | - } |
933 | - } | 1035 | - } |
934 | - else if (icontext == IconTextRight){ // icon and text (if any) | 1036 | - else if (icontext == IconTextRight){ // icon and text (if any) |
935 | - if (pixmap){ | 1037 | - if (pixmap){ |
936 | - dx = 4; | 1038 | - dx = 4; |
937 | - dy = ( h - pixmap->height() ) / 2; | 1039 | - dy = ( h - pixmap->height() ) / 2; |
938 | - if ( sunken ){ | 1040 | - if ( sunken ){ |
939 | - ++dx; | 1041 | - ++dx; |
940 | - ++dy; | 1042 | - ++dy; |
941 | - } | 1043 | - } |
942 | - p->drawPixmap( x+dx, y+dy, *pixmap ); | 1044 | - p->drawPixmap( x+dx, y+dy, *pixmap ); |
943 | - } | 1045 | - } |
944 | - if (!btext.isNull()){ | 1046 | - if (!btext.isNull()){ |
945 | - int tf = AlignVCenter|AlignLeft; | 1047 | - int tf = AlignVCenter|AlignLeft; |
946 | - if (pixmap) | 1048 | - if (pixmap) |
947 | - dx= 4 + pixmap->width() + 2; | 1049 | - dx= 4 + pixmap->width() + 2; |
948 | - else | 1050 | - else |
949 | - dx= 4; | 1051 | - dx= 4; |
950 | - dy = 0; | 1052 | - dy = 0; |
951 | - if ( sunken ){ | 1053 | - if ( sunken ){ |
952 | - ++dx; | 1054 | - ++dx; |
953 | - ++dy; | 1055 | - ++dy; |
954 | - } | 1056 | - } |
955 | - if (font) | 1057 | - if (font) |
956 | - p->setFont(*font); | 1058 | - p->setFont(*font); |
957 | - if(raised) | 1059 | - if(raised) |
958 | - p->setPen(KGlobalSettings::toolBarHighlightColor()); | 1060 | - p->setPen(KGlobalSettings::toolBarHighlightColor()); |
959 | - p->drawText(x+dx, y+dy, w-dx, h, tf, btext); | 1061 | - p->drawText(x+dx, y+dy, w-dx, h, tf, btext); |
960 | - } | 1062 | - } |
961 | - } | 1063 | - } |
962 | - else if (icontext == Text){ // only text, even if there is a icon | 1064 | - else if (icontext == Text){ // only text, even if there is a icon |
963 | - if (!btext.isNull()){ | 1065 | - if (!btext.isNull()){ |
964 | - int tf = AlignVCenter|AlignLeft; | 1066 | - int tf = AlignVCenter|AlignLeft; |
965 | - if (!enabled) | 1067 | - if (!enabled) |
966 | - p->setPen(g.dark()); | 1068 | - p->setPen(g.dark()); |
967 | - dx= (w - fm.width(btext)) / 2; | 1069 | - dx= (w - fm.width(btext)) / 2; |
968 | - dy= (h - fm.lineSpacing()) / 2; | 1070 | - dy= (h - fm.lineSpacing()) / 2; |
969 | - if ( sunken ){ | 1071 | - if ( sunken ){ |
970 | - ++dx; | 1072 | - ++dx; |
971 | - ++dy; | 1073 | - ++dy; |
972 | - } | 1074 | - } |
973 | - if (font) | 1075 | - if (font) |
974 | - p->setFont(*font); | 1076 | - p->setFont(*font); |
975 | - if(raised) | 1077 | - if(raised) |
976 | - p->setPen(KGlobalSettings::toolBarHighlightColor()); | 1078 | - p->setPen(KGlobalSettings::toolBarHighlightColor()); |
977 | - p->drawText(x+dx, y+dy, fm.width(btext), fm.lineSpacing(), tf, btext); | 1079 | - p->drawText(x+dx, y+dy, fm.width(btext), fm.lineSpacing(), tf, btext); |
978 | - } | 1080 | - } |
979 | - } | 1081 | - } |
980 | - else if (icontext == IconTextBottom){ | 1082 | - else if (icontext == IconTextBottom){ |
981 | - if (pixmap){ | 1083 | - if (pixmap){ |
982 | - dx = (w - pixmap->width()) / 2; | 1084 | - dx = (w - pixmap->width()) / 2; |
983 | - dy = (h - fm.lineSpacing() - pixmap->height()) / 2; | 1085 | - dy = (h - fm.lineSpacing() - pixmap->height()) / 2; |
984 | - if ( sunken ){ | 1086 | - if ( sunken ){ |
985 | - ++dx; | 1087 | - ++dx; |
986 | - ++dy; | 1088 | - ++dy; |
987 | - } | 1089 | - } |
988 | - p->drawPixmap( x+dx, y+dy, *pixmap ); | 1090 | - p->drawPixmap( x+dx, y+dy, *pixmap ); |
989 | - } | 1091 | - } |
990 | - if (!btext.isNull()){ | 1092 | - if (!btext.isNull()){ |
991 | - int tf = AlignBottom|AlignHCenter; | 1093 | - int tf = AlignBottom|AlignHCenter; |
992 | - dy= pixmap->height(); | 1094 | - dy= pixmap->height(); |
993 | - dx = 2; | 1095 | - dx = 2; |
994 | - if ( sunken ){ | 1096 | - if ( sunken ){ |
995 | - ++dx; | 1097 | - ++dx; |
996 | - ++dy; | 1098 | - ++dy; |
997 | - } | 1099 | - } |
998 | - if (font) | 1100 | - if (font) |
999 | - p->setFont(*font); | 1101 | - p->setFont(*font); |
1000 | - if(raised) | 1102 | - if(raised) |
1001 | - p->setPen(KGlobalSettings::toolBarHighlightColor()); | 1103 | - p->setPen(KGlobalSettings::toolBarHighlightColor()); |
1002 | - p->drawText(x, y, w, h-3, tf, btext); | 1104 | - p->drawText(x, y, w, h-3, tf, btext); |
1003 | - } | 1105 | - } |
1004 | - } | 1106 | - } |
1005 | - if (popup){ | 1107 | - if (popup){ |
1006 | - if (enabled) | 1108 | - if (enabled) |
1007 | - qDrawArrow (p, Qt::DownArrow, Qt::WindowsStyle, false, w-5, h-5, 0, 0, | 1109 | - qDrawArrow (p, Qt::DownArrow, Qt::WindowsStyle, false, w-5, h-5, 0, 0, |
1008 | - g, true); | 1110 | - g, true); |
1009 | - else | 1111 | - else |
1010 | - qDrawArrow (p, Qt::DownArrow, Qt::WindowsStyle, false, w-5, h-5, | 1112 | - qDrawArrow (p, Qt::DownArrow, Qt::WindowsStyle, false, w-5, h-5, |
1011 | - 0, 0, g, false); | 1113 | - 0, 0, g, false); |
1012 | + if(active){ | 1114 | + if(active){ |
1013 | + x -= 2; // Bug in Qt/E | 1115 | + x -= 2; // Bug in Qt/E |
1014 | + y -= 2; | 1116 | + y -= 2; |
1015 | + w += 2; | 1117 | + w += 2; |
1016 | + h += 2; | 1118 | + h += 2; |
1017 | } | 1119 | } |
1018 | -} | 1120 | -} |
1019 | 1121 | ||
1020 | - | 1122 | - |
1021 | -void LiquidStyle::drawKMenuItem(QPainter *p, int x, int y, int w, int h, | 1123 | -void LiquidStyle::drawKMenuItem(QPainter *p, int x, int y, int w, int h, |
1022 | - const QColorGroup &g, bool active, QMenuItem *mi, | 1124 | - const QColorGroup &g, bool active, QMenuItem *mi, |
1023 | - QBrush *) | 1125 | - QBrush *) |
1024 | -{ | 1126 | -{ |
1025 | - if ( p->font() == KGlobalSettings::generalFont() ) | 1127 | - if ( p->font() == KGlobalSettings::generalFont() ) |
1026 | - p->setFont( KGlobalSettings::menuFont() ); | 1128 | - p->setFont( KGlobalSettings::menuFont() ); |
1027 | + QWidget *parent = (QWidget *)p->device(); | 1129 | + QWidget *parent = (QWidget *)p->device(); |
1028 | + p->setBrushOrigin(parent->pos()); | 1130 | + p->setBrushOrigin(parent->pos()); |
1029 | + parent->erase(x, y, w, h); | 1131 | + parent->erase(x, y, w, h); |
1030 | 1132 | ||
1031 | if(menuHandler->useShadowText()){ | 1133 | if(menuHandler->useShadowText()){ |
1032 | QColor shadow; | 1134 | QColor shadow; |
1033 | if(p->device() && p->device()->devType() == QInternal::Widget && | 1135 | if(p->device() && p->device()->devType() == QInternal::Widget && |
1034 | - ((QWidget *)p->device())->inherits("KMenuBar")){ | 1136 | - ((QWidget *)p->device())->inherits("KMenuBar")){ |
1035 | - shadow = ((KMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : | 1137 | - shadow = ((KMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : |
1036 | + ((QWidget *)p->device())->inherits("QMenuBar")){ | 1138 | + ((QWidget *)p->device())->inherits("QMenuBar")){ |
1037 | + shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : | 1139 | + shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : |
1038 | g.background().dark(130); | 1140 | g.background().dark(130); |
1039 | } | 1141 | } |
1040 | else | 1142 | else |
1041 | @@ -2300,8 +2055,8 @@ | 1143 | @@ -2300,8 +2145,8 @@ |
1042 | } | 1144 | } |
1043 | 1145 | ||
1044 | void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, | 1146 | void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, |
1045 | - const QColorGroup &g, int lineWidth, | 1147 | - const QColorGroup &g, int lineWidth, |
1046 | - const QBrush * fill) | 1148 | - const QBrush * fill) |
1047 | + const QColorGroup &g, int /*lineWidth*/, | 1149 | + const QColorGroup &g, int /*lineWidth*/, |
1048 | + const QBrush * /*fill*/) | 1150 | + const QBrush * /*fill*/) |
1049 | { | 1151 | { |
1050 | QColor c; | 1152 | QColor c; |
1051 | switch(menuHandler->transType()){ | 1153 | switch(menuHandler->transType()){ |
1052 | @@ -2336,8 +2091,6 @@ | 1154 | @@ -2336,8 +2181,6 @@ |
1053 | 1155 | ||
1054 | maxpmw = QMAX( maxpmw, 20 ); | 1156 | maxpmw = QMAX( maxpmw, 20 ); |
1055 | 1157 | ||
1056 | - if ( p->font() == KGlobalSettings::generalFont() ) | 1158 | - if ( p->font() == KGlobalSettings::generalFont() ) |
1057 | - p->setFont( KGlobalSettings::menuFont() ); | 1159 | - p->setFont( KGlobalSettings::menuFont() ); |
1058 | 1160 | ||
1059 | bool dis = !enabled; | 1161 | bool dis = !enabled; |
1060 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); | 1162 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); |
1061 | @@ -2363,7 +2116,7 @@ | 1163 | @@ -2363,7 +2206,7 @@ |
1062 | p->fillRect(x, y, w, h, menuBrush); | 1164 | p->fillRect(x, y, w, h, menuBrush); |
1063 | } | 1165 | } |
1064 | else{ | 1166 | else{ |
1065 | - KPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); | 1167 | - KPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); |
1066 | + QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); | 1168 | + QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); |
1067 | if(pix) | 1169 | if(pix) |
1068 | p->drawPixmap(x, y, *pix, x, y, w, h); | 1170 | p->drawPixmap(x, y, *pix, x, y, w, h); |
1069 | } | 1171 | } |
1070 | @@ -2508,25 +2261,6 @@ | 1172 | @@ -2508,25 +2351,6 @@ |
1071 | return h; | 1173 | return h; |
1072 | } | 1174 | } |
1073 | 1175 | ||
1074 | -void LiquidStyle::drawKProgressBlock(QPainter *p, int x, int y, int w, int h, | 1176 | -void LiquidStyle::drawKProgressBlock(QPainter *p, int x, int y, int w, int h, |
1075 | - const QColorGroup &g, QBrush *fill) | 1177 | - const QColorGroup &g, QBrush *fill) |
1076 | -{ | 1178 | -{ |
1077 | - p->setPen(g.button().dark(130)); | 1179 | - p->setPen(g.button().dark(130)); |
1078 | - p->drawRect(x, y, w, h); | 1180 | - p->drawRect(x, y, w, h); |
1079 | - p->setPen(g.button().light(120)); | 1181 | - p->setPen(g.button().light(120)); |
1080 | - p->drawRect(x+1, y+1, w-2, h-2); | 1182 | - p->drawRect(x+1, y+1, w-2, h-2); |
1081 | - if(w >= 4 && h >= 4){ | 1183 | - if(w >= 4 && h >= 4){ |
1082 | - QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); | 1184 | - QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb()); |
1083 | - if(!pix){ | 1185 | - if(!pix){ |
1084 | - int h, s, v; | 1186 | - int h, s, v; |
1085 | - g.button().dark(120).hsv(&h, &s, &v); | 1187 | - g.button().dark(120).hsv(&h, &s, &v); |
1086 | - pix = new QPixmap(*bevelFillPix); | 1188 | - pix = new QPixmap(*bevelFillPix); |
1087 | - adjustHSV(*pix, h, s, v); | 1189 | - adjustHSV(*pix, h, s, v); |
1088 | - bevelFillDict.insert(g.button().dark(120).rgb(), pix); | 1190 | - bevelFillDict.insert(g.button().dark(120).rgb(), pix); |
1089 | - } | 1191 | - } |
1090 | - p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); | 1192 | - p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); |
1091 | - } | 1193 | - } |
1092 | -} | 1194 | -} |
1093 | 1195 | ||
1094 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, | 1196 | void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, |
1095 | const QColorGroup &g, const QColor *c, | 1197 | const QColorGroup &g, const QColor *c, |
1096 | @@ -2540,25 +2274,25 @@ | 1198 | @@ -2540,25 +2364,25 @@ |
1097 | return; | 1199 | return; |
1098 | } | 1200 | } |
1099 | else{ | 1201 | else{ |
1100 | - KStyle::drawFocusRect(p, r, g, c, atBorder); | 1202 | - KStyle::drawFocusRect(p, r, g, c, atBorder); |
1101 | + QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 1203 | + QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
1102 | } | 1204 | } |
1103 | } | 1205 | } |
1104 | else | 1206 | else |
1105 | - KStyle::drawFocusRect(p, r, g, c, atBorder); | 1207 | - KStyle::drawFocusRect(p, r, g, c, atBorder); |
1106 | + QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); | 1208 | + QWindowsStyle::drawFocusRect(p, r, g, c, atBorder); |
1107 | 1209 | ||
1108 | } | 1210 | } |
1109 | 1211 | ||
1110 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) | 1212 | void LiquidStyle::polishPopupMenu(QPopupMenu *mnu) |
1111 | { | 1213 | { |
1112 | mnu->installEventFilter(menuHandler); | 1214 | mnu->installEventFilter(menuHandler); |
1113 | - KStyle::polishPopupMenu(mnu); | 1215 | - KStyle::polishPopupMenu(mnu); |
1114 | + QWindowsStyle::polishPopupMenu(mnu); | 1216 | + QWindowsStyle::polishPopupMenu(mnu); |
1115 | } | 1217 | } |
1116 | 1218 | ||
1117 | void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, | 1219 | void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab, |
1118 | bool selected) | 1220 | bool selected) |
1119 | { | 1221 | { |
1120 | if(tabBar->shape() != QTabBar::RoundedAbove){ | 1222 | if(tabBar->shape() != QTabBar::RoundedAbove){ |
1121 | - KStyle::drawTab(p, tabBar, tab, selected); | 1223 | - KStyle::drawTab(p, tabBar, tab, selected); |
1122 | + QWindowsStyle::drawTab(p, tabBar, tab, selected); | 1224 | + QWindowsStyle::drawTab(p, tabBar, tab, selected); |
1123 | return; | 1225 | return; |
1124 | } | 1226 | } |
1125 | QPixmap tilePix; | 1227 | QPixmap tilePix; |
1126 | @@ -2671,7 +2405,7 @@ | 1228 | @@ -2671,7 +2495,7 @@ |
1127 | vFrame = 8; // was 10 | 1229 | vFrame = 8; // was 10 |
1128 | } | 1230 | } |
1129 | else | 1231 | else |
1130 | - KStyle::tabbarMetrics(t, hFrame, vFrame, overlap); | 1232 | - KStyle::tabbarMetrics(t, hFrame, vFrame, overlap); |
1131 | + QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); | 1233 | + QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap); |
1132 | } | 1234 | } |
1133 | 1235 | ||
1134 | 1236 | ||
1135 | @@ -2699,7 +2433,7 @@ | 1237 | @@ -2699,7 +2523,7 @@ |
1136 | p->drawLine(x+1, y+1, x+1, y2-1); | 1238 | p->drawLine(x+1, y+1, x+1, y2-1); |
1137 | } | 1239 | } |
1138 | else if(lineWidth != 2 || !sunken) | 1240 | else if(lineWidth != 2 || !sunken) |
1139 | - KStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); | 1241 | - KStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); |
1140 | + QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); | 1242 | + QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill); |
1141 | else{ | 1243 | else{ |
1142 | QPen oldPen = p->pen(); | 1244 | QPen oldPen = p->pen(); |
1143 | int x2 = x+w-1; | 1245 | int x2 = x+w-1; |
1144 | @@ -2726,105 +2460,6 @@ | 1246 | @@ -2726,105 +2550,6 @@ |
1145 | } | 1247 | } |
1146 | } | 1248 | } |
1147 | 1249 | ||
1148 | -void LiquidStyle::drawKickerAppletHandle(QPainter *p, int x, int y, int w, int h, | 1250 | -void LiquidStyle::drawKickerAppletHandle(QPainter *p, int x, int y, int w, int h, |
1149 | - const QColorGroup &g, QBrush *) | 1251 | - const QColorGroup &g, QBrush *) |
1150 | -{ | 1252 | -{ |
1151 | - p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); | 1253 | - p->fillRect(x, y, w, h, g.brush(QColorGroup::Background)); |
1152 | - drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? | 1254 | - drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ? |
1153 | - g.button().light(120) : g.button(), g.button()); | 1255 | - g.button().light(120) : g.button(), g.button()); |
1154 | - /* | 1256 | - /* |
1155 | - if(h > w){ | 1257 | - if(h > w){ |
1156 | - int y2 = y+h-1; | 1258 | - int y2 = y+h-1; |
1157 | - | 1259 | - |
1158 | - p->setPen(g.light()); | 1260 | - p->setPen(g.light()); |
1159 | - | 1261 | - |
1160 | - p->drawLine(x+1, y+2, x+1, y2-2); | 1262 | - p->drawLine(x+1, y+2, x+1, y2-2); |
1161 | - p->drawLine(x+4, y+2, x+4, y2-2); | 1263 | - p->drawLine(x+4, y+2, x+4, y2-2); |
1162 | - | 1264 | - |
1163 | - p->setPen(g.dark()); | 1265 | - p->setPen(g.dark()); |
1164 | - p->drawLine(x+2, y+2, x+2, y2-2); | 1266 | - p->drawLine(x+2, y+2, x+2, y2-2); |
1165 | - p->drawLine(x+5, y+2, x+5, y2-2); | 1267 | - p->drawLine(x+5, y+2, x+5, y2-2); |
1166 | - | 1268 | - |
1167 | - } | 1269 | - } |
1168 | - else{ | 1270 | - else{ |
1169 | - int x2 = x+w-1; | 1271 | - int x2 = x+w-1; |
1170 | - | 1272 | - |
1171 | - p->setPen(g.light()); | 1273 | - p->setPen(g.light()); |
1172 | - | 1274 | - |
1173 | - p->drawLine(x+2, y+1, x2-2, y+1); | 1275 | - p->drawLine(x+2, y+1, x2-2, y+1); |
1174 | - p->drawLine(x+2, y+4, x2-2, y+4); | 1276 | - p->drawLine(x+2, y+4, x2-2, y+4); |
1175 | - | 1277 | - |
1176 | - p->setPen(g.dark()); | 1278 | - p->setPen(g.dark()); |
1177 | - p->drawLine(x+2, y+2, x2-2, y+2); | 1279 | - p->drawLine(x+2, y+2, x2-2, y+2); |
1178 | - p->drawLine(x+2, y+5, x2-2, y+5); | 1280 | - p->drawLine(x+2, y+5, x2-2, y+5); |
1179 | - }*/ | 1281 | - }*/ |
1180 | - | 1282 | - |
1181 | -} | 1283 | -} |
1182 | - | 1284 | - |
1183 | -void LiquidStyle::drawKickerTaskButton(QPainter *p, int x, int y, int w, int h, | 1285 | -void LiquidStyle::drawKickerTaskButton(QPainter *p, int x, int y, int w, int h, |
1184 | - const QColorGroup &g, | 1286 | - const QColorGroup &g, |
1185 | - const QString &text, bool sunken, | 1287 | - const QString &text, bool sunken, |
1186 | - QPixmap *pixmap, QBrush *) | 1288 | - QPixmap *pixmap, QBrush *) |
1187 | -{ | 1289 | -{ |
1188 | - p->fillRect(x, y, w, h, g.brush(QColorGroup::Button)); | 1290 | - p->fillRect(x, y, w, h, g.brush(QColorGroup::Button)); |
1189 | - drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), g.button()); | 1291 | - drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), g.button()); |
1190 | - p->setPen(g.buttonText()); // Kicker doesn't set this ;-) | 1292 | - p->setPen(g.buttonText()); // Kicker doesn't set this ;-) |
1191 | - | 1293 | - |
1192 | - if(text.isNull() && !pixmap) | 1294 | - if(text.isNull() && !pixmap) |
1193 | - return; | 1295 | - return; |
1194 | - | 1296 | - |
1195 | - const int pxWidth = 20; | 1297 | - const int pxWidth = 20; |
1196 | - int textPos = pxWidth; | 1298 | - int textPos = pxWidth; |
1197 | - QRect br(buttonRect(x, y, w, h)); | 1299 | - QRect br(buttonRect(x, y, w, h)); |
1198 | - | 1300 | - |
1199 | - if (sunken) | 1301 | - if (sunken) |
1200 | - p->translate(1,1); | 1302 | - p->translate(1,1); |
1201 | - | 1303 | - |
1202 | - if ( pixmap && !pixmap->isNull() ) { | 1304 | - if ( pixmap && !pixmap->isNull() ) { |
1203 | - int dx = ( pxWidth - pixmap->width() ) / 2; | 1305 | - int dx = ( pxWidth - pixmap->width() ) / 2; |
1204 | - int dy = ( h - pixmap->height() ) / 2; | 1306 | - int dy = ( h - pixmap->height() ) / 2; |
1205 | - p->drawPixmap( br.x()+dx, dy, *pixmap ); | 1307 | - p->drawPixmap( br.x()+dx, dy, *pixmap ); |
1206 | - } | 1308 | - } |
1207 | - | 1309 | - |
1208 | - QString s = text; | 1310 | - QString s = text; |
1209 | - static const QString &modStr = KGlobal::staticQString( | 1311 | - static const QString &modStr = KGlobal::staticQString( |
1210 | - QString::fromUtf8("[") + i18n("modified") + QString::fromUtf8("]")); | 1312 | - QString::fromUtf8("[") + i18n("modified") + QString::fromUtf8("]")); |
1211 | - | 1313 | - |
1212 | - int modStrPos = s.find(modStr); | 1314 | - int modStrPos = s.find(modStr); |
1213 | - | 1315 | - |
1214 | - if (-1 != modStrPos) { | 1316 | - if (-1 != modStrPos) { |
1215 | - | 1317 | - |
1216 | - // +1 because we include a space after the closing brace. | 1318 | - // +1 because we include a space after the closing brace. |
1217 | - s.remove(modStrPos, modStr.length()+1); | 1319 | - s.remove(modStrPos, modStr.length()+1); |
1218 | - | 1320 | - |
1219 | - QPixmap modPixmap = SmallIcon("modified"); | 1321 | - QPixmap modPixmap = SmallIcon("modified"); |
1220 | - | 1322 | - |
1221 | - int dx = (pxWidth - modPixmap.width()) / 2; | 1323 | - int dx = (pxWidth - modPixmap.width()) / 2; |
1222 | - int dy = (h - modPixmap.height()) / 2; | 1324 | - int dy = (h - modPixmap.height()) / 2; |
1223 | - | 1325 | - |
1224 | - p->drawPixmap(br.x() + textPos + dx, dy, modPixmap); | 1326 | - p->drawPixmap(br.x() + textPos + dx, dy, modPixmap); |
1225 | - | 1327 | - |
1226 | - textPos += pxWidth; | 1328 | - textPos += pxWidth; |
1227 | - } | 1329 | - } |
1228 | - | 1330 | - |
1229 | - if (!s.isEmpty()){ | 1331 | - if (!s.isEmpty()){ |
1230 | - if (p->fontMetrics().width(s) > br.width() - textPos) { | 1332 | - if (p->fontMetrics().width(s) > br.width() - textPos) { |
1231 | - | 1333 | - |
1232 | - int maxLen = br.width() - textPos - p->fontMetrics().width("..."); | 1334 | - int maxLen = br.width() - textPos - p->fontMetrics().width("..."); |
1233 | - | 1335 | - |
1234 | - while ((!s.isEmpty()) && (p->fontMetrics().width(s) > maxLen)) | 1336 | - while ((!s.isEmpty()) && (p->fontMetrics().width(s) > maxLen)) |
1235 | - s.truncate(s.length() - 1); | 1337 | - s.truncate(s.length() - 1); |
1236 | - | 1338 | - |
1237 | - s.append("..."); | 1339 | - s.append("..."); |
1238 | - } | 1340 | - } |
1239 | - | 1341 | - |
1240 | - p->setPen(g.buttonText()); | 1342 | - p->setPen(g.buttonText()); |
1241 | - | 1343 | - |
1242 | - p->drawText(br.x()+ textPos, -1, w-textPos, h, | 1344 | - p->drawText(br.x()+ textPos, -1, w-textPos, h, |
1243 | - AlignLeft|AlignVCenter, s); | 1345 | - AlignLeft|AlignVCenter, s); |
1244 | - } | 1346 | - } |
1245 | - | 1347 | - |
1246 | -} | 1348 | -} |
1247 | 1349 | ||
1248 | void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) | 1350 | void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v) |
1249 | { | 1351 | { |
1250 | @@ -2998,22 +2633,22 @@ | 1352 | @@ -2998,22 +2723,22 @@ |
1251 | customBtnIconList.clear(); | 1353 | customBtnIconList.clear(); |
1252 | customBtnLabelList.clear(); | 1354 | customBtnLabelList.clear(); |
1253 | 1355 | ||
1254 | - KConfig *config = KGlobal::config(); | 1356 | - KConfig *config = KGlobal::config(); |
1255 | - QString oldGrp = config->group(); | 1357 | - QString oldGrp = config->group(); |
1256 | - config->setGroup("MosfetButtons"); | 1358 | - config->setGroup("MosfetButtons"); |
1257 | +// KConfig *config = KGlobal::config(); | 1359 | +// KConfig *config = KGlobal::config(); |
1258 | +// QString oldGrp = config->group(); | 1360 | +// QString oldGrp = config->group(); |
1259 | +// config->setGroup("MosfetButtons"); | 1361 | +// config->setGroup("MosfetButtons"); |
1260 | 1362 | ||
1261 | QStrList iconList, colorList; //temp, we store QPixmaps and QColors | 1363 | QStrList iconList, colorList; //temp, we store QPixmaps and QColors |
1262 | iconList.setAutoDelete(true); | 1364 | iconList.setAutoDelete(true); |
1263 | colorList.setAutoDelete(true); | 1365 | colorList.setAutoDelete(true); |
1264 | - config->readListEntry("Labels", customBtnLabelList); | 1366 | - config->readListEntry("Labels", customBtnLabelList); |
1265 | - config->readListEntry("Icons", iconList); | 1367 | - config->readListEntry("Icons", iconList); |
1266 | - config->readListEntry("Colors", colorList); | 1368 | - config->readListEntry("Colors", colorList); |
1267 | +// config->readListEntry("Labels", customBtnLabelList); | 1369 | +// config->readListEntry("Labels", customBtnLabelList); |
1268 | +// config->readListEntry("Icons", iconList); | 1370 | +// config->readListEntry("Icons", iconList); |
1269 | +// config->readListEntry("Colors", colorList); | 1371 | +// config->readListEntry("Colors", colorList); |
1270 | 1372 | ||
1271 | const char *labelStr = customBtnLabelList.first(); | 1373 | const char *labelStr = customBtnLabelList.first(); |
1272 | const char *colorStr = colorList.first(); | 1374 | const char *colorStr = colorList.first(); |
1273 | const char *iconStr = iconList.first(); | 1375 | const char *iconStr = iconList.first(); |
1274 | 1376 | ||
1275 | - KIconLoader *ldr = KGlobal::iconLoader(); | 1377 | - KIconLoader *ldr = KGlobal::iconLoader(); |
1276 | +// KIconLoader *ldr = KGlobal::iconLoader(); | 1378 | +// KIconLoader *ldr = KGlobal::iconLoader(); |
1277 | while(labelStr != NULL){ | 1379 | while(labelStr != NULL){ |
1278 | QColor *c = new QColor; | 1380 | QColor *c = new QColor; |
1279 | c->setNamedColor(QString(colorStr)); | 1381 | c->setNamedColor(QString(colorStr)); |
1280 | @@ -3022,7 +2657,7 @@ | 1382 | @@ -3022,7 +2747,7 @@ |
1281 | QString tmpStr(iconStr); | 1383 | QString tmpStr(iconStr); |
1282 | if(!tmpStr.isEmpty()){ | 1384 | if(!tmpStr.isEmpty()){ |
1283 | QPixmap *pixmap = | 1385 | QPixmap *pixmap = |
1284 | - new QPixmap(ldr->loadIcon(tmpStr, KIcon::Small)); | 1386 | - new QPixmap(ldr->loadIcon(tmpStr, KIcon::Small)); |
1285 | + new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small)); | 1387 | + new QPixmap();//ldr->loadIcon(tmpStr, KIcon::Small)); |
1286 | if(pixmap->isNull()){ | 1388 | if(pixmap->isNull()){ |
1287 | delete pixmap; | 1389 | delete pixmap; |
1288 | customBtnIconList.append(NULL); | 1390 | customBtnIconList.append(NULL); |
1289 | @@ -3037,7 +2672,6 @@ | 1391 | @@ -3037,7 +2762,6 @@ |
1290 | colorStr = colorList.next(); | 1392 | colorStr = colorList.next(); |
1291 | iconStr = iconList.next(); | 1393 | iconStr = iconList.next(); |
1292 | } | 1394 | } |
1293 | - config->setGroup(oldGrp); | 1395 | - config->setGroup(oldGrp); |
1294 | } | 1396 | } |
1295 | 1397 | ||
1296 | void LiquidStyle::applyCustomAttributes(QPushButton *btn) | 1398 | void LiquidStyle::applyCustomAttributes(QPushButton *btn) |
1297 | @@ -3087,7 +2721,7 @@ | 1399 | @@ -3087,7 +2811,7 @@ |
1298 | } | 1400 | } |
1299 | } | 1401 | } |
1300 | 1402 | ||
1301 | -#include "liquid.moc" | 1403 | -#include "liquid.moc" |
1302 | +// #include "liquid.moc" | 1404 | +// #include "liquid.moc" |
1303 | 1405 | ||
1304 | 1406 | ||
1305 | 1407 | ||
1306 | --- -Sat Sep 21 05:31:48 2002 | 1408 | --- -2002-10-24 03:19:31.000000000 +0200 |
1307 | +++ plugin.cppMon Jul 8 02:42:56 2002 | 1409 | +++ plugin.cpp2002-10-04 03:37:38.000000000 +0200 |
1308 | @@ -1,29 +1,113 @@ | 1410 | @@ -1,29 +1,84 @@ |
1411 | +#include <qapplication.h> | ||
1412 | + | ||
1309 | #include "liquid.h" | 1413 | #include "liquid.h" |
1310 | -#include <klocale.h> | 1414 | -#include <klocale.h> |
1311 | +#include "liquidset.h" | 1415 | +#include "liquidset.h" |
1312 | +#include "plugin.h" | 1416 | +#include "plugin.h" |
1313 | 1417 | + | |
1314 | -extern "C" { | ||
1315 | - KStyle* allocate(); | ||
1316 | - int minor_version(); | ||
1317 | - int major_version(); | ||
1318 | - const char *description(); | ||
1319 | + | 1418 | + |
1320 | + | 1419 | + |
1321 | +LiquidInterface::LiquidInterface ( ) : ref ( 0 ) | 1420 | +LiquidInterface::LiquidInterface ( ) : ref ( 0 ) |
1322 | +{ | 1421 | +{ |
1422 | +m_widget = 0; | ||
1323 | +} | 1423 | +} |
1324 | + | 1424 | + |
1325 | +LiquidInterface::~LiquidInterface ( ) | 1425 | +LiquidInterface::~LiquidInterface ( ) |
1326 | +{ | 1426 | +{ |
1327 | +} | 1427 | +} |
1328 | + | 1428 | + |
1329 | +QStyle *LiquidInterface::create ( ) | 1429 | +QStyle *LiquidInterface::style ( ) |
1330 | +{ | 1430 | +{ |
1331 | +return new LiquidStyle ( ); | 1431 | +return new LiquidStyle ( ); |
1332 | +} | 1432 | +} |
1333 | + | 1433 | + |
1334 | +QString LiquidInterface::name ( ) | 1434 | +QString LiquidInterface::name ( ) const |
1435 | +{ | ||
1436 | +return qApp-> translate ( "Styles", "Liquid" ); | ||
1437 | +} | ||
1438 | + | ||
1439 | +QString LiquidInterface::description ( ) const | ||
1440 | +{ | ||
1441 | +return qApp-> translate ( "Styles", "High Performance Liquid style by Mosfet" ); | ||
1442 | +} | ||
1443 | + | ||
1444 | +bool LiquidInterface::hasSettings ( ) const | ||
1445 | +{ | ||
1446 | +return true; | ||
1447 | +} | ||
1448 | + | ||
1449 | +QWidget *LiquidInterface::create ( QWidget *parent, const char *name ) | ||
1335 | +{ | 1450 | +{ |
1336 | +return QObject::tr( "Liquid", "name" ); | 1451 | +m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); |
1452 | |||
1453 | -extern "C" { | ||
1454 | - KStyle* allocate(); | ||
1455 | - int minor_version(); | ||
1456 | - int major_version(); | ||
1457 | - const char *description(); | ||
1458 | +return m_widget; | ||
1337 | } | 1459 | } |
1338 | 1460 | ||
1339 | -KStyle* allocate() | 1461 | -KStyle* allocate() |
1340 | +QString LiquidInterface::description ( ) | 1462 | +bool LiquidInterface::accept ( ) |
1341 | { | 1463 | { |
1342 | - return(new LiquidStyle); | 1464 | - return(new LiquidStyle); |
1343 | +return QObject::tr( "High Performance Liquid style by Mosfet", "description" ); | 1465 | +if ( !m_widget ) |
1466 | + return false; | ||
1467 | + | ||
1468 | +return m_widget-> writeConfig ( ); | ||
1344 | } | 1469 | } |
1345 | 1470 | ||
1346 | -int minor_version() | 1471 | -int minor_version() |
1347 | +QCString LiquidInterface::key ( ) | 1472 | +void LiquidInterface::reject ( ) |
1348 | { | 1473 | { |
1349 | - return(0); | 1474 | - return(0); |
1350 | +return QCString ( "liquid" ); | ||
1351 | } | 1475 | } |
1352 | 1476 | ||
1353 | -int major_version() | 1477 | -int major_version() |
1354 | +unsigned int LiquidInterface::version ( ) | 1478 | + |
1479 | +QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | ||
1355 | { | 1480 | { |
1356 | - return(1); | 1481 | - return(1); |
1357 | +return 100; // 1.0.0 (\d+.\d.\d) | ||
1358 | } | ||
1359 | |||
1360 | -const char *description() | ||
1361 | +QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | ||
1362 | +{ | ||
1363 | +static LiquidSettingsInterface *setiface = 0; | ||
1364 | + | ||
1365 | +*iface = 0; | 1482 | +*iface = 0; |
1366 | + | 1483 | + |
1367 | +if ( uuid == IID_QUnknown ) | 1484 | +if ( uuid == IID_QUnknown ) |
1368 | + *iface = this; | 1485 | + *iface = this; |
1369 | +else if ( uuid == IID_Style ) | 1486 | +else if ( uuid == IID_Style ) |
1370 | + *iface = this; | 1487 | + *iface = this; |
1371 | +else if ( uuid == IID_StyleSettings ) { | 1488 | +else if ( uuid == IID_StyleExtended ) |
1372 | + if ( !setiface ) | 1489 | + *iface = this; |
1373 | + setiface = new LiquidSettingsInterface ( ); | ||
1374 | + *iface = setiface; | ||
1375 | +} | ||
1376 | + | 1490 | + |
1377 | +if ( *iface ) | 1491 | +if ( *iface ) |
1378 | + (*iface)-> addRef ( ); | 1492 | + (*iface)-> addRef ( ); |
1379 | + | 1493 | + |
1380 | +return QS_OK; | 1494 | +return QS_OK; |
1381 | +} | 1495 | } |
1382 | + | 1496 | |
1497 | -const char *description() | ||
1383 | +Q_EXPORT_INTERFACE() | 1498 | +Q_EXPORT_INTERFACE() |
1384 | +{ | ||
1385 | +Q_CREATE_INSTANCE( LiquidInterface ) | ||
1386 | +} | ||
1387 | + | ||
1388 | + | ||
1389 | +LiquidSettingsInterface::LiquidSettingsInterface ( ) : ref ( 0 ) | ||
1390 | { | 1499 | { |
1391 | - return(i18n("High performance liquid plugin").utf8()); | 1500 | - return(i18n("High performance liquid plugin").utf8()); |
1392 | +m_widget = 0; | 1501 | +Q_CREATE_INSTANCE( LiquidInterface ) |
1393 | } | 1502 | } |
1394 | + | ||
1395 | +LiquidSettingsInterface::~LiquidSettingsInterface ( ) | ||
1396 | +{ | ||
1397 | +} | ||
1398 | + | ||
1399 | +QWidget *LiquidSettingsInterface::create ( QWidget *parent, const char *name ) | ||
1400 | +{ | ||
1401 | +m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); | ||
1402 | + | ||
1403 | +return m_widget; | ||
1404 | +} | ||
1405 | + | ||
1406 | +bool LiquidSettingsInterface::accept ( ) | ||
1407 | +{ | ||
1408 | +if ( !m_widget ) | ||
1409 | + return false; | ||
1410 | + | 1503 | + |
1411 | +return m_widget-> writeConfig ( ); | ||
1412 | +} | ||
1413 | + | 1504 | + |
1414 | +void LiquidSettingsInterface::reject ( ) | 1505 | + |
1415 | +{ | ||
1416 | +} | ||
1417 | + | ||
1418 | +QRESULT LiquidSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | ||
1419 | +{ | ||
1420 | +*iface = 0; | ||
1421 | + | ||
1422 | + | ||
1423 | +if ( uuid == IID_QUnknown ) | ||
1424 | + *iface = this; | ||
1425 | +else if ( uuid == IID_StyleSettings ) | ||
1426 | + *iface = this; | ||
1427 | + | ||
1428 | +if ( *iface ) | ||
1429 | + (*iface)-> addRef ( ); | ||
1430 | + | ||
1431 | +return QS_OK; | ||
1432 | +} | ||
1433 | + | 1506 | + |
1434 | +// Hack for Retail Z experiments | 1507 | +// Hack for Retail Z experiments |
1435 | +extern "C" { QStyle *allocate ( ) { return new LiquidStyle ( ); } } | 1508 | +extern "C" { QStyle *allocate ( ) { return new LiquidStyle ( ); } } |