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