-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 5 | ||||
-rw-r--r-- | noncore/styles/liquid/liquid.pro | 2 | ||||
-rw-r--r-- | noncore/styles/liquid/liquiddeco.cpp | 183 | ||||
-rw-r--r-- | noncore/styles/liquid/liquiddeco.h | 41 |
4 files changed, 231 insertions, 0 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index 2b6eaa4..9a7d2dd 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -1,268 +1,269 @@ | |||
1 | /*- | 1 | /*- |
2 | * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. | 2 | * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | #ifndef INCLUDE_MENUITEM_DEF | 7 | #ifndef INCLUDE_MENUITEM_DEF |
8 | #define INCLUDE_MENUITEM_DEF | 8 | #define INCLUDE_MENUITEM_DEF |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #include <qmenudata.h> | 11 | #include <qmenudata.h> |
12 | #include "liquid.h" | 12 | #include "liquid.h" |
13 | #include "liquiddeco.h" | ||
13 | #include <qapplication.h> | 14 | #include <qapplication.h> |
14 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
15 | #include "effects.h" | 16 | #include "effects.h" |
16 | #include <qpalette.h> | 17 | #include <qpalette.h> |
17 | #include <qbitmap.h> | 18 | #include <qbitmap.h> |
18 | #include <qtabbar.h> | 19 | #include <qtabbar.h> |
19 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
20 | #include <qobjectlist.h> | 21 | #include <qobjectlist.h> |
21 | #include <qimage.h> | 22 | #include <qimage.h> |
22 | #include <qtimer.h> | 23 | #include <qtimer.h> |
23 | #include <qpixmapcache.h> | 24 | #include <qpixmapcache.h> |
24 | #include <qradiobutton.h> | 25 | #include <qradiobutton.h> |
25 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
26 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
27 | #include <qwidgetlist.h> | 28 | #include <qwidgetlist.h> |
28 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
29 | #include <qheader.h> | 30 | #include <qheader.h> |
30 | #include <unistd.h> | 31 | #include <unistd.h> |
31 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
32 | 33 | ||
33 | 34 | ||
34 | #include <stdio.h> | 35 | #include <stdio.h> |
35 | 36 | ||
36 | #include "htmlmasks.h" | 37 | #include "htmlmasks.h" |
37 | #include "embeddata.h" | 38 | #include "embeddata.h" |
38 | 39 | ||
39 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | 40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, |
40 | QColorGroup &, bool, bool); | 41 | QColorGroup &, bool, bool); |
41 | 42 | ||
42 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); | 43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); |
43 | 44 | ||
44 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) | 45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) |
45 | { | 46 | { |
46 | QImage img(pix.convertToImage()); | 47 | QImage img(pix.convertToImage()); |
47 | QImageEffect::fade(img, 0.9, color); | 48 | QImageEffect::fade(img, 0.9, color); |
48 | int x, y; | 49 | int x, y; |
49 | int r, g, b; | 50 | int r, g, b; |
50 | for(y=0; y < img.height(); y+=3){ | 51 | for(y=0; y < img.height(); y+=3){ |
51 | unsigned int *data = (unsigned int *) img.scanLine(y); | 52 | unsigned int *data = (unsigned int *) img.scanLine(y); |
52 | for(x=0; x < img.width(); ++x){ | 53 | for(x=0; x < img.width(); ++x){ |
53 | r = qRed(data[x]); | 54 | r = qRed(data[x]); |
54 | g = qGreen(data[x]); | 55 | g = qGreen(data[x]); |
55 | b = qBlue(data[x]); | 56 | b = qBlue(data[x]); |
56 | if(r-10) | 57 | if(r-10) |
57 | r-=10; | 58 | r-=10; |
58 | if(g-10) | 59 | if(g-10) |
59 | g-=10; | 60 | g-=10; |
60 | if(b-10) | 61 | if(b-10) |
61 | b-=10; | 62 | b-=10; |
62 | data[x] = qRgb(r, g, b); | 63 | data[x] = qRgb(r, g, b); |
63 | } | 64 | } |
64 | } | 65 | } |
65 | pix.convertFromImage(img); | 66 | pix.convertFromImage(img); |
66 | } | 67 | } |
67 | 68 | ||
68 | TransMenuHandler::TransMenuHandler(QObject *parent) | 69 | TransMenuHandler::TransMenuHandler(QObject *parent) |
69 | : QObject(parent) | 70 | : QObject(parent) |
70 | { | 71 | { |
71 | pixDict.setAutoDelete(true); | 72 | pixDict.setAutoDelete(true); |
72 | reloadSettings(); | 73 | reloadSettings(); |
73 | } | 74 | } |
74 | 75 | ||
75 | void TransMenuHandler::reloadSettings() | 76 | void TransMenuHandler::reloadSettings() |
76 | { | 77 | { |
77 | pixDict.clear(); | 78 | pixDict.clear(); |
78 | 79 | ||
79 | Config config ( "qpe" ); | 80 | Config config ( "qpe" ); |
80 | config. setGroup ( "MosfetMenus" ); | 81 | config. setGroup ( "MosfetMenus" ); |
81 | 82 | ||
82 | type = config. readNumEntry("Type", TransStippleBg); | 83 | type = config. readNumEntry("Type", TransStippleBg); |
83 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); | 84 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); |
84 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); | 85 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); |
85 | opacity = config. readNumEntry("Opacity", 10); | 86 | opacity = config. readNumEntry("Opacity", 10); |
86 | if ( opacity < -20 ) | 87 | if ( opacity < -20 ) |
87 | opacity = 20; | 88 | opacity = 20; |
88 | else if ( opacity > 20 ) | 89 | else if ( opacity > 20 ) |
89 | opacity = 20; | 90 | opacity = 20; |
90 | 91 | ||
91 | shadowText = config. readBoolEntry("ShadowText", true); | 92 | shadowText = config. readBoolEntry("ShadowText", true); |
92 | } | 93 | } |
93 | 94 | ||
94 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | 95 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) |
95 | { | 96 | { |
96 | QWidget *p = (QWidget *)obj; | 97 | QWidget *p = (QWidget *)obj; |
97 | 98 | ||
98 | if(ev->type() == QEvent::Show){ | 99 | if(ev->type() == QEvent::Show){ |
99 | if(type == TransStippleBg || type == TransStippleBtn || | 100 | if(type == TransStippleBg || type == TransStippleBtn || |
100 | type == Custom){ | 101 | type == Custom){ |
101 | QApplication::syncX(); | 102 | QApplication::syncX(); |
102 | QPixmap *pix = new QPixmap; | 103 | QPixmap *pix = new QPixmap; |
103 | if(p->testWFlags(Qt::WType_Popup)){ | 104 | if(p->testWFlags(Qt::WType_Popup)){ |
104 | QRect r(p->x(), p->y(), p->width(), p->height()); | 105 | QRect r(p->x(), p->y(), p->width(), p->height()); |
105 | QRect deskR = QApplication::desktop()->rect(); | 106 | QRect deskR = QApplication::desktop()->rect(); |
106 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ | 107 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ |
107 | r.setBottom(deskR.bottom()); | 108 | r.setBottom(deskR.bottom()); |
108 | r.setRight(deskR.right()); | 109 | r.setRight(deskR.right()); |
109 | } | 110 | } |
110 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), | 111 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), |
111 | r.width(), r.height()); | 112 | r.width(), r.height()); |
112 | } | 113 | } |
113 | else{ // tear off menu | 114 | else{ // tear off menu |
114 | pix->resize(p->width(), p->height()); | 115 | pix->resize(p->width(), p->height()); |
115 | pix->fill(Qt::black.rgb()); | 116 | pix->fill(Qt::black.rgb()); |
116 | } | 117 | } |
117 | if(type == TransStippleBg){ | 118 | if(type == TransStippleBg){ |
118 | stripePixmap(*pix, p->colorGroup().background()); | 119 | stripePixmap(*pix, p->colorGroup().background()); |
119 | } | 120 | } |
120 | else if(type == TransStippleBtn){ | 121 | else if(type == TransStippleBtn){ |
121 | stripePixmap(*pix, p->colorGroup().button()); | 122 | stripePixmap(*pix, p->colorGroup().button()); |
122 | } | 123 | } |
123 | else{ | 124 | else{ |
124 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); | 125 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); |
125 | } | 126 | } |
126 | 127 | ||
127 | if (p->inherits("QPopupMenu")) | 128 | if (p->inherits("QPopupMenu")) |
128 | pixDict.insert(p->winId(), pix); | 129 | pixDict.insert(p->winId(), pix); |
129 | else { | 130 | else { |
130 | p->setBackgroundPixmap(*pix); | 131 | p->setBackgroundPixmap(*pix); |
131 | 132 | ||
132 | QObjectList *ol = p-> queryList("QWidget"); | 133 | QObjectList *ol = p-> queryList("QWidget"); |
133 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 134 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
134 | QWidget *wid = (QWidget *) it.current ( ); | 135 | QWidget *wid = (QWidget *) it.current ( ); |
135 | 136 | ||
136 | wid-> setBackgroundPixmap(*pix); | 137 | wid-> setBackgroundPixmap(*pix); |
137 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); | 138 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); |
138 | } | 139 | } |
139 | delete ol; | 140 | delete ol; |
140 | } | 141 | } |
141 | } | 142 | } |
142 | } | 143 | } |
143 | else if(ev->type() == QEvent::Hide){ | 144 | else if(ev->type() == QEvent::Hide){ |
144 | if(type == TransStippleBg || type == TransStippleBtn || | 145 | if(type == TransStippleBg || type == TransStippleBtn || |
145 | type == Custom){ | 146 | type == Custom){ |
146 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); | 147 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); |
147 | 148 | ||
148 | if (p->inherits("QPopupMenu")) | 149 | if (p->inherits("QPopupMenu")) |
149 | pixDict.remove(p->winId()); | 150 | pixDict.remove(p->winId()); |
150 | else { | 151 | else { |
151 | p->setBackgroundMode(QWidget::PaletteBackground); | 152 | p->setBackgroundMode(QWidget::PaletteBackground); |
152 | 153 | ||
153 | QObjectList *ol = p-> queryList("QWidget"); | 154 | QObjectList *ol = p-> queryList("QWidget"); |
154 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 155 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
155 | QWidget *wid = (QWidget *) it.current ( ); | 156 | QWidget *wid = (QWidget *) it.current ( ); |
156 | 157 | ||
157 | wid-> setBackgroundMode( QWidget::PaletteBackground ); | 158 | wid-> setBackgroundMode( QWidget::PaletteBackground ); |
158 | } | 159 | } |
159 | delete ol; | 160 | delete ol; |
160 | } | 161 | } |
161 | } | 162 | } |
162 | } | 163 | } |
163 | return(false); | 164 | return(false); |
164 | } | 165 | } |
165 | 166 | ||
166 | 167 | ||
167 | LiquidStyle::LiquidStyle() | 168 | LiquidStyle::LiquidStyle() |
168 | :QWindowsStyle() | 169 | :QWindowsStyle() |
169 | { | 170 | { |
170 | setName ( "LiquidStyle" ); | 171 | setName ( "LiquidStyle" ); |
171 | 172 | ||
172 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 173 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
173 | btnMaskBmp.setMask(btnMaskBmp); | 174 | btnMaskBmp.setMask(btnMaskBmp); |
174 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 175 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
175 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); | 176 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); |
176 | headerHoverID = -1; | 177 | headerHoverID = -1; |
177 | highlightWidget = NULL; | 178 | highlightWidget = NULL; |
178 | setButtonDefaultIndicatorWidth(0); | 179 | setButtonDefaultIndicatorWidth(0); |
179 | btnDict.setAutoDelete(true); | 180 | btnDict.setAutoDelete(true); |
180 | bevelFillDict.setAutoDelete(true); | 181 | bevelFillDict.setAutoDelete(true); |
181 | smallBevelFillDict.setAutoDelete(true); | 182 | smallBevelFillDict.setAutoDelete(true); |
182 | customBtnColorList.setAutoDelete(true); | 183 | customBtnColorList.setAutoDelete(true); |
183 | customBtnIconList.setAutoDelete(true); | 184 | customBtnIconList.setAutoDelete(true); |
184 | customBtnLabelList.setAutoDelete(true); | 185 | customBtnLabelList.setAutoDelete(true); |
185 | 186 | ||
186 | rMatrix.rotate(270.0); | 187 | rMatrix.rotate(270.0); |
187 | highcolor = QPixmap::defaultDepth() > 8; | 188 | highcolor = QPixmap::defaultDepth() > 8; |
188 | btnBorderPix = new QPixmap; | 189 | btnBorderPix = new QPixmap; |
189 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); | 190 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); |
190 | btnBlendPix = new QPixmap; | 191 | btnBlendPix = new QPixmap; |
191 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); | 192 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); |
192 | bevelFillPix = new QPixmap; | 193 | bevelFillPix = new QPixmap; |
193 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); | 194 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); |
194 | smallBevelFillPix = new QPixmap; | 195 | smallBevelFillPix = new QPixmap; |
195 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); | 196 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); |
196 | // new stuff | 197 | // new stuff |
197 | vsbSliderFillPix = menuPix = NULL; | 198 | vsbSliderFillPix = menuPix = NULL; |
198 | menuHandler = new TransMenuHandler(this); | 199 | menuHandler = new TransMenuHandler(this); |
199 | setScrollBarExtent(15, 15); | 200 | setScrollBarExtent(15, 15); |
200 | int i; | 201 | int i; |
201 | for(i=0; i < BITMAP_ITEMS; ++i){ | 202 | for(i=0; i < BITMAP_ITEMS; ++i){ |
202 | pixmaps[i] = NULL; | 203 | pixmaps[i] = NULL; |
203 | } | 204 | } |
204 | oldSliderThickness = sliderThickness(); | 205 | oldSliderThickness = sliderThickness(); |
205 | setSliderThickness(11); | 206 | setSliderThickness(11); |
206 | } | 207 | } |
207 | 208 | ||
208 | LiquidStyle::~LiquidStyle() | 209 | LiquidStyle::~LiquidStyle() |
209 | { | 210 | { |
210 | if(btnBorderPix) | 211 | if(btnBorderPix) |
211 | delete btnBorderPix; | 212 | delete btnBorderPix; |
212 | if(btnBlendPix) | 213 | if(btnBlendPix) |
213 | delete btnBlendPix; | 214 | delete btnBlendPix; |
214 | if(bevelFillPix) | 215 | if(bevelFillPix) |
215 | delete bevelFillPix; | 216 | delete bevelFillPix; |
216 | if(smallBevelFillPix) | 217 | if(smallBevelFillPix) |
217 | delete smallBevelFillPix; | 218 | delete smallBevelFillPix; |
218 | if(vsbSliderFillPix) | 219 | if(vsbSliderFillPix) |
219 | delete vsbSliderFillPix; | 220 | delete vsbSliderFillPix; |
220 | if(menuPix) | 221 | if(menuPix) |
221 | delete menuPix; | 222 | delete menuPix; |
222 | 223 | ||
223 | setScrollBarExtent(16, 16); | 224 | setScrollBarExtent(16, 16); |
224 | setSliderThickness(oldSliderThickness); | 225 | setSliderThickness(oldSliderThickness); |
225 | int i; | 226 | int i; |
226 | for(i=0; i < BITMAP_ITEMS; ++i){ | 227 | for(i=0; i < BITMAP_ITEMS; ++i){ |
227 | if(pixmaps[i]) | 228 | if(pixmaps[i]) |
228 | delete pixmaps[i]; | 229 | delete pixmaps[i]; |
229 | } | 230 | } |
230 | } | 231 | } |
231 | 232 | ||
232 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, | 233 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, |
233 | const QColor &c, const QColor &bg) | 234 | const QColor &c, const QColor &bg) |
234 | { | 235 | { |
235 | 236 | ||
236 | QPen oldPen = p->pen(); // headers need this | 237 | QPen oldPen = p->pen(); // headers need this |
237 | int x2 = x+w-1; | 238 | int x2 = x+w-1; |
238 | int y2 = y+h-1; | 239 | int y2 = y+h-1; |
239 | // outer dark rect | 240 | // outer dark rect |
240 | p->setPen(c.dark(130)); | 241 | p->setPen(c.dark(130)); |
241 | p->drawLine(x, y+2, x, y2-2); // l | 242 | p->drawLine(x, y+2, x, y2-2); // l |
242 | p->drawLine(x2, y+2, x2, y2-2); // r | 243 | p->drawLine(x2, y+2, x2, y2-2); // r |
243 | p->drawLine(x+2, y, x2-2, y); // t | 244 | p->drawLine(x+2, y, x2-2, y); // t |
244 | p->drawLine(x+2, y2, x2-2, y2); // b | 245 | p->drawLine(x+2, y2, x2-2, y2); // b |
245 | p->drawPoint(x+1, y+1); // tl | 246 | p->drawPoint(x+1, y+1); // tl |
246 | p->drawPoint(x2-1, y+1); // tr | 247 | p->drawPoint(x2-1, y+1); // tr |
247 | p->drawPoint(x+1, y2-1); // bl | 248 | p->drawPoint(x+1, y2-1); // bl |
248 | p->drawPoint(x2-1, y2-1); // br | 249 | p->drawPoint(x2-1, y2-1); // br |
249 | 250 | ||
250 | // inner top light lines | 251 | // inner top light lines |
251 | p->setPen(c.light(105)); | 252 | p->setPen(c.light(105)); |
252 | p->drawLine(x+2, y+1, x2-2, y+1); | 253 | p->drawLine(x+2, y+1, x2-2, y+1); |
253 | p->drawLine(x+1, y+2, x2-1, y+2); | 254 | p->drawLine(x+1, y+2, x2-1, y+2); |
254 | p->drawLine(x+1, y+3, x+2, y+3); | 255 | p->drawLine(x+1, y+3, x+2, y+3); |
255 | p->drawLine(x2-2, y+3, x2-1, y+3); | 256 | p->drawLine(x2-2, y+3, x2-1, y+3); |
256 | p->drawPoint(x+1, y+4); | 257 | p->drawPoint(x+1, y+4); |
257 | p->drawPoint(x2-1, y+4); | 258 | p->drawPoint(x2-1, y+4); |
258 | 259 | ||
259 | // inner bottom light lines | 260 | // inner bottom light lines |
260 | p->setPen(c.light(110)); | 261 | p->setPen(c.light(110)); |
261 | p->drawLine(x+2, y2-1, x2-2, y2-1); | 262 | p->drawLine(x+2, y2-1, x2-2, y2-1); |
262 | p->drawLine(x+1, y2-2, x2-1, y2-2); | 263 | p->drawLine(x+1, y2-2, x2-1, y2-2); |
263 | p->drawLine(x+1, y2-3, x+2, y2-3); | 264 | p->drawLine(x+1, y2-3, x+2, y2-3); |
264 | p->drawLine(x2-2, y2-3, x2-1, y2-3); | 265 | p->drawLine(x2-2, y2-3, x2-1, y2-3); |
265 | p->drawPoint(x+1, y2-4); | 266 | p->drawPoint(x+1, y2-4); |
266 | p->drawPoint(x2-1, y2-4); | 267 | p->drawPoint(x2-1, y2-4); |
267 | 268 | ||
268 | // inner left mid lines | 269 | // inner left mid lines |
@@ -734,521 +735,525 @@ void LiquidStyle::polish(QPalette &appPal) | |||
734 | for(i=0; i < 63; i+=4){ | 735 | for(i=0; i < 63; i+=4){ |
735 | painter.drawLine(0, i, 63, i); | 736 | painter.drawLine(0, i, 63, i); |
736 | painter.drawLine(0, i+1, 63, i+1); | 737 | painter.drawLine(0, i+1, 63, i+1); |
737 | }; | 738 | }; |
738 | painter.end(); | 739 | painter.end(); |
739 | menuBrush.setColor(c); | 740 | menuBrush.setColor(c); |
740 | menuBrush.setPixmap(*menuPix); | 741 | menuBrush.setPixmap(*menuPix); |
741 | 742 | ||
742 | // pager brush | 743 | // pager brush |
743 | c = c.dark(120); | 744 | c = c.dark(120); |
744 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 745 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
745 | if(!pix){ | 746 | if(!pix){ |
746 | int h, s, v; | 747 | int h, s, v; |
747 | c.hsv(&h, &s, &v); | 748 | c.hsv(&h, &s, &v); |
748 | pix = new QPixmap(*smallBevelFillPix); | 749 | pix = new QPixmap(*smallBevelFillPix); |
749 | adjustHSV(*pix, h, s, v); | 750 | adjustHSV(*pix, h, s, v); |
750 | smallBevelFillDict.insert(c.rgb(), pix); | 751 | smallBevelFillDict.insert(c.rgb(), pix); |
751 | } | 752 | } |
752 | pagerHoverBrush.setColor(c); | 753 | pagerHoverBrush.setColor(c); |
753 | pagerHoverBrush.setPixmap(*pix); | 754 | pagerHoverBrush.setPixmap(*pix); |
754 | 755 | ||
755 | c = c.dark(120); | 756 | c = c.dark(120); |
756 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 757 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
757 | if(!pix){ | 758 | if(!pix){ |
758 | int h, s, v; | 759 | int h, s, v; |
759 | c.hsv(&h, &s, &v); | 760 | c.hsv(&h, &s, &v); |
760 | pix = new QPixmap(*smallBevelFillPix); | 761 | pix = new QPixmap(*smallBevelFillPix); |
761 | adjustHSV(*pix, h, s, v); | 762 | adjustHSV(*pix, h, s, v); |
762 | smallBevelFillDict.insert(c.rgb(), pix); | 763 | smallBevelFillDict.insert(c.rgb(), pix); |
763 | } | 764 | } |
764 | pagerBrush.setColor(c); | 765 | pagerBrush.setColor(c); |
765 | pagerBrush.setPixmap(*pix); | 766 | pagerBrush.setPixmap(*pix); |
766 | 767 | ||
767 | // background color stuff | 768 | // background color stuff |
768 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); | 769 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); |
769 | c.hsv(&bH, &bS, &bV); | 770 | c.hsv(&bH, &bS, &bV); |
770 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); | 771 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); |
771 | 772 | ||
772 | // FIXME? | 773 | // FIXME? |
773 | if(vsbSliderFillPix) | 774 | if(vsbSliderFillPix) |
774 | delete vsbSliderFillPix; | 775 | delete vsbSliderFillPix; |
775 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); | 776 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); |
776 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); | 777 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); |
777 | 778 | ||
778 | // background brush | 779 | // background brush |
779 | QPixmap wallPaper(32, 32); | 780 | QPixmap wallPaper(32, 32); |
780 | wallPaper.fill(c.rgb()); | 781 | wallPaper.fill(c.rgb()); |
781 | painter.begin(&wallPaper); | 782 | painter.begin(&wallPaper); |
782 | for(i=0; i < 32; i+=4){ | 783 | for(i=0; i < 32; i+=4){ |
783 | painter.setPen(c.dark(105)); | 784 | painter.setPen(c.dark(105)); |
784 | painter.drawLine(0, i, 32, i); | 785 | painter.drawLine(0, i, 32, i); |
785 | painter.setPen(c.dark(103)); | 786 | painter.setPen(c.dark(103)); |
786 | painter.drawLine(0, i+1, 32, i+1); | 787 | painter.drawLine(0, i+1, 32, i+1); |
787 | }; | 788 | }; |
788 | painter.end(); | 789 | painter.end(); |
789 | bgBrush.setColor(c); | 790 | bgBrush.setColor(c); |
790 | bgBrush.setPixmap(wallPaper); | 791 | bgBrush.setPixmap(wallPaper); |
791 | appPal.setBrush(QColorGroup::Background, bgBrush); | 792 | appPal.setBrush(QColorGroup::Background, bgBrush); |
792 | 793 | ||
793 | // lineedits | 794 | // lineedits |
794 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); | 795 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); |
795 | QPixmap basePix; | 796 | QPixmap basePix; |
796 | basePix.resize(32, 32); | 797 | basePix.resize(32, 32); |
797 | basePix.fill(c.rgb()); | 798 | basePix.fill(c.rgb()); |
798 | painter.begin(&basePix); | 799 | painter.begin(&basePix); |
799 | painter.setPen(c.dark(105)); | 800 | painter.setPen(c.dark(105)); |
800 | for(i=0; i < 32; i+=4){ | 801 | for(i=0; i < 32; i+=4){ |
801 | painter.drawLine(0, i, 32, i); | 802 | painter.drawLine(0, i, 32, i); |
802 | painter.drawLine(0, i+1, 32, i+1); | 803 | painter.drawLine(0, i+1, 32, i+1); |
803 | }; | 804 | }; |
804 | painter.end(); | 805 | painter.end(); |
805 | baseBrush.setColor(c); | 806 | baseBrush.setColor(c); |
806 | baseBrush.setPixmap(basePix); | 807 | baseBrush.setPixmap(basePix); |
807 | it.toFirst(); | 808 | it.toFirst(); |
808 | while ((w=it.current()) != 0 ){ | 809 | while ((w=it.current()) != 0 ){ |
809 | ++it; | 810 | ++it; |
810 | if(w->inherits("QLineEdit")){ | 811 | if(w->inherits("QLineEdit")){ |
811 | QPalette pal = w->palette(); | 812 | QPalette pal = w->palette(); |
812 | pal.setBrush(QColorGroup::Base, baseBrush); | 813 | pal.setBrush(QColorGroup::Base, baseBrush); |
813 | w->setPalette(pal); | 814 | w->setPalette(pal); |
814 | } | 815 | } |
815 | else if(w->inherits("QPushButton")){ | 816 | else if(w->inherits("QPushButton")){ |
816 | applyCustomAttributes((QPushButton *)w); | 817 | applyCustomAttributes((QPushButton *)w); |
817 | } | 818 | } |
818 | } | 819 | } |
819 | 820 | ||
820 | } | 821 | } |
821 | 822 | ||
822 | void LiquidStyle::polish(QWidget *w) | 823 | void LiquidStyle::polish(QWidget *w) |
823 | { | 824 | { |
824 | if(w->inherits("QMenuBar")){ | 825 | if(w->inherits("QMenuBar")){ |
825 | //((QFrame*)w)->setLineWidth(0); | 826 | //((QFrame*)w)->setLineWidth(0); |
826 | w->setBackgroundMode(QWidget::PaletteBackground); | 827 | w->setBackgroundMode(QWidget::PaletteBackground); |
827 | return; | 828 | return; |
828 | } | 829 | } |
829 | if(w->inherits("QPopupMenu")) | 830 | if(w->inherits("QPopupMenu")) |
830 | w->setBackgroundMode(QWidget::NoBackground); | 831 | w->setBackgroundMode(QWidget::NoBackground); |
831 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 832 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
832 | w->installEventFilter(menuHandler); | 833 | w->installEventFilter(menuHandler); |
833 | } | 834 | } |
834 | 835 | ||
835 | if(w->isTopLevel()){ | 836 | if(w->isTopLevel()){ |
836 | return; | 837 | return; |
837 | } | 838 | } |
838 | 839 | ||
839 | 840 | ||
840 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | 841 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); |
841 | 842 | ||
842 | if(w->inherits("QComboBox") || | 843 | if(w->inherits("QComboBox") || |
843 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 844 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
844 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 845 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
845 | w->installEventFilter(this); | 846 | w->installEventFilter(this); |
846 | } | 847 | } |
847 | if(w->inherits("QLineEdit")){ | 848 | if(w->inherits("QLineEdit")){ |
848 | QPalette pal = w->palette(); | 849 | QPalette pal = w->palette(); |
849 | pal.setBrush(QColorGroup::Base, baseBrush); | 850 | pal.setBrush(QColorGroup::Base, baseBrush); |
850 | w->setPalette(pal); | 851 | w->setPalette(pal); |
851 | } | 852 | } |
852 | if(w->inherits("QPushButton")){ | 853 | if(w->inherits("QPushButton")){ |
853 | applyCustomAttributes((QPushButton *)w); | 854 | applyCustomAttributes((QPushButton *)w); |
854 | w->installEventFilter(this); | 855 | w->installEventFilter(this); |
855 | } | 856 | } |
856 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ | 857 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ |
857 | w-> setBackgroundMode ( QWidget::PaletteBackground ); | 858 | w-> setBackgroundMode ( QWidget::PaletteBackground ); |
858 | } | 859 | } |
859 | 860 | ||
860 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || | 861 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || |
861 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; | 862 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; |
862 | bool isViewportChild = w->parent() && | 863 | bool isViewportChild = w->parent() && |
863 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 864 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
864 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 865 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
865 | 866 | ||
866 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ | 867 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ |
867 | w->setBackgroundMode(QWidget::X11ParentRelative); | 868 | w->setBackgroundMode(QWidget::X11ParentRelative); |
868 | return; | 869 | return; |
869 | } | 870 | } |
870 | if(isViewportChild){ | 871 | if(isViewportChild){ |
871 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 872 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
872 | if(w->parent()){ // heh, only way to test for KHTML children ;-) | 873 | if(w->parent()){ // heh, only way to test for KHTML children ;-) |
873 | if(w->parent()->parent()){ | 874 | if(w->parent()->parent()){ |
874 | if(w->parent()->parent()->parent() && | 875 | if(w->parent()->parent()->parent() && |
875 | w->parent()->parent()->parent()->inherits("KHTMLView")){ | 876 | w->parent()->parent()->parent()->inherits("KHTMLView")){ |
876 | w->setAutoMask(true); | 877 | w->setAutoMask(true); |
877 | w->setBackgroundMode(QWidget::NoBackground); | 878 | w->setBackgroundMode(QWidget::NoBackground); |
878 | } | 879 | } |
879 | } | 880 | } |
880 | } | 881 | } |
881 | return; | 882 | return; |
882 | } | 883 | } |
883 | } | 884 | } |
884 | if(w->inherits("QHeader")){ | 885 | if(w->inherits("QHeader")){ |
885 | w->setMouseTracking(true); | 886 | w->setMouseTracking(true); |
886 | w->installEventFilter(this); | 887 | w->installEventFilter(this); |
887 | } | 888 | } |
888 | if(w-> inherits("QToolButton")) { | 889 | if(w-> inherits("QToolButton")) { |
889 | ((QToolButton*)w)->setAutoRaise (false); | 890 | ((QToolButton*)w)->setAutoRaise (false); |
890 | } | 891 | } |
891 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 892 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
892 | return; | 893 | return; |
893 | } | 894 | } |
894 | 895 | ||
895 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 896 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
896 | palette().active().brush(QColorGroup::Background).pixmap()){ | 897 | palette().active().brush(QColorGroup::Background).pixmap()){ |
897 | qWarning("No parent pixmap for child widget %s", w->className()); | 898 | qWarning("No parent pixmap for child widget %s", w->className()); |
898 | return; | 899 | return; |
899 | } | 900 | } |
900 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && | 901 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && |
901 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { | 902 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { |
902 | if(w->backgroundMode() == QWidget::PaletteBackground || | 903 | if(w->backgroundMode() == QWidget::PaletteBackground || |
903 | w->backgroundMode() == QWidget::PaletteButton){ | 904 | w->backgroundMode() == QWidget::PaletteButton){ |
904 | w->setBackgroundMode(QWidget::X11ParentRelative); | 905 | w->setBackgroundMode(QWidget::X11ParentRelative); |
905 | } | 906 | } |
906 | } | 907 | } |
907 | if(w->inherits("QToolBar")){ | 908 | if(w->inherits("QToolBar")){ |
908 | w->installEventFilter(this); | 909 | w->installEventFilter(this); |
909 | w->setBackgroundMode(QWidget::PaletteBackground); | 910 | w->setBackgroundMode(QWidget::PaletteBackground); |
910 | return; | 911 | return; |
911 | } | 912 | } |
912 | 913 | ||
913 | } | 914 | } |
914 | 915 | ||
915 | void LiquidStyle::unPolish(QWidget *w) | 916 | void LiquidStyle::unPolish(QWidget *w) |
916 | { | 917 | { |
917 | if(w->inherits("QMenuBar")){ | 918 | if(w->inherits("QMenuBar")){ |
918 | ((QFrame *)w)->setLineWidth(1); | 919 | ((QFrame *)w)->setLineWidth(1); |
919 | w->setBackgroundMode(QWidget::PaletteBackground); | 920 | w->setBackgroundMode(QWidget::PaletteBackground); |
920 | return; | 921 | return; |
921 | } | 922 | } |
922 | 923 | ||
923 | if(w->inherits("QPopupMenu")) | 924 | if(w->inherits("QPopupMenu")) |
924 | w->setBackgroundMode(QWidget::PaletteButton); | 925 | w->setBackgroundMode(QWidget::PaletteButton); |
925 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 926 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
926 | w->removeEventFilter(menuHandler); | 927 | w->removeEventFilter(menuHandler); |
927 | } | 928 | } |
928 | 929 | ||
929 | if(w->isTopLevel()) | 930 | if(w->isTopLevel()) |
930 | return; | 931 | return; |
931 | 932 | ||
932 | // for viewport children, don't just check for NoBackground.... | 933 | // for viewport children, don't just check for NoBackground.... |
933 | bool isViewportChild = w->parent() && | 934 | bool isViewportChild = w->parent() && |
934 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 935 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
935 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 936 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
936 | 937 | ||
937 | w->setPalette(QApplication::palette()); | 938 | w->setPalette(QApplication::palette()); |
938 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ | 939 | if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){ |
939 | if(w->inherits("QPushButton")) | 940 | if(w->inherits("QPushButton")) |
940 | w->setBackgroundMode(QWidget::PaletteButton); | 941 | w->setBackgroundMode(QWidget::PaletteButton); |
941 | else | 942 | else |
942 | w->setBackgroundMode(QWidget::PaletteBackground); | 943 | w->setBackgroundMode(QWidget::PaletteBackground); |
943 | } | 944 | } |
944 | 945 | ||
945 | if(isViewportChild) | 946 | if(isViewportChild) |
946 | w->setAutoMask(false); | 947 | w->setAutoMask(false); |
947 | 948 | ||
948 | if(w->inherits("QPushButton")){ | 949 | if(w->inherits("QPushButton")){ |
949 | unapplyCustomAttributes((QPushButton *)w); | 950 | unapplyCustomAttributes((QPushButton *)w); |
950 | w->removeEventFilter(this); | 951 | w->removeEventFilter(this); |
951 | } | 952 | } |
952 | /* | 953 | /* |
953 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ | 954 | if(w->inherits("QPushButton") || w-> inherits("QComboBox")){ |
954 | w-> setBackgroundMode ( PaletteBackground ); | 955 | w-> setBackgroundMode ( PaletteBackground ); |
955 | } | 956 | } |
956 | */ | 957 | */ |
957 | if(w->inherits("QComboBox") || | 958 | if(w->inherits("QComboBox") || |
958 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 959 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
959 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 960 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
960 | w->removeEventFilter(this); | 961 | w->removeEventFilter(this); |
961 | } | 962 | } |
962 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 963 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
963 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ | 964 | if(w->parent() && w->parent()->inherits("KHTMLPart")){ |
964 | w->setAutoMask(false); | 965 | w->setAutoMask(false); |
965 | } | 966 | } |
966 | } | 967 | } |
967 | if(w->inherits("QToolBar")){ | 968 | if(w->inherits("QToolBar")){ |
968 | w->removeEventFilter(this); | 969 | w->removeEventFilter(this); |
969 | w->setBackgroundMode(QWidget::PaletteBackground); | 970 | w->setBackgroundMode(QWidget::PaletteBackground); |
970 | return; | 971 | return; |
971 | } | 972 | } |
972 | if(w->inherits("QHeader")){ | 973 | if(w->inherits("QHeader")){ |
973 | w->setMouseTracking(false); | 974 | w->setMouseTracking(false); |
974 | w->removeEventFilter(this); | 975 | w->removeEventFilter(this); |
975 | } | 976 | } |
976 | } | 977 | } |
977 | 978 | ||
978 | void LiquidStyle::polish(QApplication *app) | 979 | void LiquidStyle::polish(QApplication *app) |
979 | { | 980 | { |
980 | 981 | ||
981 | QWindowsStyle::polish(app); | 982 | QWindowsStyle::polish(app); |
982 | menuAni = app->isEffectEnabled(UI_AnimateMenu); | 983 | menuAni = app->isEffectEnabled(UI_AnimateMenu); |
983 | menuFade = app->isEffectEnabled(UI_FadeMenu); | 984 | menuFade = app->isEffectEnabled(UI_FadeMenu); |
984 | if(menuAni) | 985 | if(menuAni) |
985 | app->setEffectEnabled(UI_AnimateMenu, false); | 986 | app->setEffectEnabled(UI_AnimateMenu, false); |
986 | if(menuFade) | 987 | if(menuFade) |
987 | app->setEffectEnabled(UI_FadeMenu, false); | 988 | app->setEffectEnabled(UI_FadeMenu, false); |
988 | 989 | ||
989 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); | 990 | qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem); |
991 | |||
992 | QApplication::qwsSetDecoration ( new LiquidDecoration ( )); | ||
990 | } | 993 | } |
991 | 994 | ||
992 | void LiquidStyle::unPolish(QApplication *app) | 995 | void LiquidStyle::unPolish(QApplication *app) |
993 | { | 996 | { |
994 | QWindowsStyle::unPolish(app); | 997 | QWindowsStyle::unPolish(app); |
995 | app->setEffectEnabled(UI_AnimateMenu, menuAni); | 998 | app->setEffectEnabled(UI_AnimateMenu, menuAni); |
996 | app->setEffectEnabled(UI_FadeMenu, menuFade); | 999 | app->setEffectEnabled(UI_FadeMenu, menuFade); |
997 | 1000 | ||
998 | qt_set_draw_menu_bar_impl ( 0 ); | 1001 | qt_set_draw_menu_bar_impl ( 0 ); |
1002 | |||
1003 | QApplication::qwsSetDecoration ( new QPEDecoration ( )); | ||
999 | } | 1004 | } |
1000 | 1005 | ||
1001 | /* | 1006 | /* |
1002 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to | 1007 | * This is a fun method ;-) Here's an overview. KToolBar grabs resize to |
1003 | * force everything to erase and repaint on resize. This is going away, I'm | 1008 | * force everything to erase and repaint on resize. This is going away, I'm |
1004 | * trying to get shaped widgets to work right without masking. QPushButton, | 1009 | * trying to get shaped widgets to work right without masking. QPushButton, |
1005 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order | 1010 | * QComboBox, and Panel applet handles capture mouse enter and leaves in order |
1006 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and | 1011 | * to set the highlightwidget and repaint for mouse hovers. CheckBoxes and |
1007 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and | 1012 | * RadioButtons need to do this differently. Qt buffers these in pixmaps and |
1008 | * caches them in QPixmapCache, which is bad for doing things like hover | 1013 | * caches them in QPixmapCache, which is bad for doing things like hover |
1009 | * because the style methods aren't called in paintEvents if everything | 1014 | * because the style methods aren't called in paintEvents if everything |
1010 | * is cached. We use our own Paint event handler instead. Taskbuttons and | 1015 | * is cached. We use our own Paint event handler instead. Taskbuttons and |
1011 | * pager buttons draw into a pixmap buffer, so we handle those with palette | 1016 | * pager buttons draw into a pixmap buffer, so we handle those with palette |
1012 | * modifications. For QHeader, different header items are actually one widget | 1017 | * modifications. For QHeader, different header items are actually one widget |
1013 | * that draws multiple items, so we need to check which ID is hightlighted | 1018 | * that draws multiple items, so we need to check which ID is hightlighted |
1014 | * and draw it. Finally, we also check enter and leave events for QLineEdit, | 1019 | * and draw it. Finally, we also check enter and leave events for QLineEdit, |
1015 | * since if it's inside a combobox we want to highlight the combobox during | 1020 | * since if it's inside a combobox we want to highlight the combobox during |
1016 | * hovering in the edit. | 1021 | * hovering in the edit. |
1017 | */ | 1022 | */ |
1018 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) | 1023 | bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev) |
1019 | { | 1024 | { |
1020 | if(obj->inherits("QToolBar")){ | 1025 | if(obj->inherits("QToolBar")){ |
1021 | if(ev->type() == QEvent::Resize){ | 1026 | if(ev->type() == QEvent::Resize){ |
1022 | const QObjectList *tbChildList = obj->children(); | 1027 | const QObjectList *tbChildList = obj->children(); |
1023 | QObjectListIt it(*tbChildList); | 1028 | QObjectListIt it(*tbChildList); |
1024 | QObject *child; | 1029 | QObject *child; |
1025 | while((child = it.current()) != NULL){ | 1030 | while((child = it.current()) != NULL){ |
1026 | ++it; | 1031 | ++it; |
1027 | if(child->isWidgetType()) | 1032 | if(child->isWidgetType()) |
1028 | ((QWidget *)child)->repaint(true); | 1033 | ((QWidget *)child)->repaint(true); |
1029 | } | 1034 | } |
1030 | 1035 | ||
1031 | } | 1036 | } |
1032 | } | 1037 | } |
1033 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ | 1038 | else if(obj->inherits("QPushButton") || obj->inherits("QComboBox")){ |
1034 | QWidget *btn = (QWidget *)obj; | 1039 | QWidget *btn = (QWidget *)obj; |
1035 | if(ev->type() == QEvent::Enter){ | 1040 | if(ev->type() == QEvent::Enter){ |
1036 | if(btn->isEnabled()){ | 1041 | if(btn->isEnabled()){ |
1037 | highlightWidget = btn; | 1042 | highlightWidget = btn; |
1038 | btn->repaint(false); | 1043 | btn->repaint(false); |
1039 | } | 1044 | } |
1040 | } | 1045 | } |
1041 | else if(ev->type() == QEvent::Leave){ | 1046 | else if(ev->type() == QEvent::Leave){ |
1042 | if(btn == highlightWidget){ | 1047 | if(btn == highlightWidget){ |
1043 | highlightWidget = NULL; | 1048 | highlightWidget = NULL; |
1044 | btn->repaint(false); | 1049 | btn->repaint(false); |
1045 | } | 1050 | } |
1046 | } | 1051 | } |
1047 | } | 1052 | } |
1048 | else if(obj->inherits("QToolButton")){ | 1053 | else if(obj->inherits("QToolButton")){ |
1049 | QToolButton *btn = (QToolButton *)btn; | 1054 | QToolButton *btn = (QToolButton *)btn; |
1050 | if(!btn->autoRaise()){ | 1055 | if(!btn->autoRaise()){ |
1051 | if(btn->isEnabled()){ | 1056 | if(btn->isEnabled()){ |
1052 | highlightWidget = btn; | 1057 | highlightWidget = btn; |
1053 | btn->repaint(false); | 1058 | btn->repaint(false); |
1054 | } | 1059 | } |
1055 | } | 1060 | } |
1056 | else if(ev->type() == QEvent::Leave){ | 1061 | else if(ev->type() == QEvent::Leave){ |
1057 | QWidget *btn = (QWidget *)obj; | 1062 | QWidget *btn = (QWidget *)obj; |
1058 | if(btn == highlightWidget){ | 1063 | if(btn == highlightWidget){ |
1059 | highlightWidget = NULL; | 1064 | highlightWidget = NULL; |
1060 | btn->repaint(false); | 1065 | btn->repaint(false); |
1061 | } | 1066 | } |
1062 | } | 1067 | } |
1063 | else | 1068 | else |
1064 | highlightWidget = NULL; | 1069 | highlightWidget = NULL; |
1065 | } | 1070 | } |
1066 | else if(obj->inherits("QScrollBar")){ | 1071 | else if(obj->inherits("QScrollBar")){ |
1067 | QScrollBar *sb = (QScrollBar *)obj; | 1072 | QScrollBar *sb = (QScrollBar *)obj; |
1068 | if(ev->type() == QEvent::Enter){ | 1073 | if(ev->type() == QEvent::Enter){ |
1069 | if(sb->isEnabled()){ | 1074 | if(sb->isEnabled()){ |
1070 | highlightWidget = sb; | 1075 | highlightWidget = sb; |
1071 | sb->repaint(false); | 1076 | sb->repaint(false); |
1072 | } | 1077 | } |
1073 | } | 1078 | } |
1074 | else if(ev->type() == QEvent::Leave){ | 1079 | else if(ev->type() == QEvent::Leave){ |
1075 | if(sb == highlightWidget && !sb->draggingSlider()){ | 1080 | if(sb == highlightWidget && !sb->draggingSlider()){ |
1076 | highlightWidget = NULL; | 1081 | highlightWidget = NULL; |
1077 | sb->repaint(false); | 1082 | sb->repaint(false); |
1078 | } | 1083 | } |
1079 | } | 1084 | } |
1080 | else if(ev->type() == QEvent::MouseButtonRelease){ | 1085 | else if(ev->type() == QEvent::MouseButtonRelease){ |
1081 | QMouseEvent *me = (QMouseEvent *)ev; | 1086 | QMouseEvent *me = (QMouseEvent *)ev; |
1082 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ | 1087 | if(sb == highlightWidget && !sb->rect().contains(me->pos())){ |
1083 | highlightWidget = NULL; | 1088 | highlightWidget = NULL; |
1084 | sb->repaint(false); | 1089 | sb->repaint(false); |
1085 | } | 1090 | } |
1086 | } | 1091 | } |
1087 | } | 1092 | } |
1088 | else if(obj->inherits("QLineEdit")){ | 1093 | else if(obj->inherits("QLineEdit")){ |
1089 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ | 1094 | if(obj->parent() && obj->parent()->inherits("QComboBox")){ |
1090 | QWidget *btn = (QComboBox *)obj->parent(); | 1095 | QWidget *btn = (QComboBox *)obj->parent(); |
1091 | if(ev->type() == QEvent::Enter){ | 1096 | if(ev->type() == QEvent::Enter){ |
1092 | if (btn->isEnabled()){ | 1097 | if (btn->isEnabled()){ |
1093 | highlightWidget = btn; | 1098 | highlightWidget = btn; |
1094 | btn->repaint(false); | 1099 | btn->repaint(false); |
1095 | } | 1100 | } |
1096 | } | 1101 | } |
1097 | else if(ev->type() == QEvent::Leave){ | 1102 | else if(ev->type() == QEvent::Leave){ |
1098 | if (btn == highlightWidget) | 1103 | if (btn == highlightWidget) |
1099 | highlightWidget = NULL; | 1104 | highlightWidget = NULL; |
1100 | btn->repaint(false); | 1105 | btn->repaint(false); |
1101 | } | 1106 | } |
1102 | } | 1107 | } |
1103 | } | 1108 | } |
1104 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ | 1109 | else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){ |
1105 | QButton *btn = (QButton *)obj; | 1110 | QButton *btn = (QButton *)obj; |
1106 | bool isRadio = obj->inherits("QRadioButton"); | 1111 | bool isRadio = obj->inherits("QRadioButton"); |
1107 | if(ev->type() == QEvent::Paint){ | 1112 | if(ev->type() == QEvent::Paint){ |
1108 | //if(btn->autoMask()) | 1113 | //if(btn->autoMask()) |
1109 | btn->erase(); | 1114 | btn->erase(); |
1110 | QPainter p; | 1115 | QPainter p; |
1111 | p.begin(btn); | 1116 | p.begin(btn); |
1112 | QFontMetrics fm = btn->fontMetrics(); | 1117 | QFontMetrics fm = btn->fontMetrics(); |
1113 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1118 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1114 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1119 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1115 | : indicatorSize(); | 1120 | : indicatorSize(); |
1116 | 1121 | ||
1117 | if(btn->hasFocus()){ | 1122 | if(btn->hasFocus()){ |
1118 | QRect r = QRect(0, 0, btn->width(), btn->height()); | 1123 | QRect r = QRect(0, 0, btn->width(), btn->height()); |
1119 | p.setPen(btn->colorGroup().button().dark(140)); | 1124 | p.setPen(btn->colorGroup().button().dark(140)); |
1120 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); | 1125 | p.drawLine(r.x()+1, r.y(), r.right()-1, r.y()); |
1121 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); | 1126 | p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1); |
1122 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); | 1127 | p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1); |
1123 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); | 1128 | p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom()); |
1124 | } | 1129 | } |
1125 | int x = 0; | 1130 | int x = 0; |
1126 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1131 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1127 | if(isRadio) | 1132 | if(isRadio) |
1128 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1133 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1129 | btn->colorGroup(), btn->isOn(), | 1134 | btn->colorGroup(), btn->isOn(), |
1130 | btn->isDown(), btn->isEnabled()); | 1135 | btn->isDown(), btn->isEnabled()); |
1131 | else | 1136 | else |
1132 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1137 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1133 | btn->colorGroup(), btn->state(), btn->isDown(), | 1138 | btn->colorGroup(), btn->state(), btn->isDown(), |
1134 | btn->isEnabled()); | 1139 | btn->isEnabled()); |
1135 | x = sz.width() + 6; | 1140 | x = sz.width() + 6; |
1136 | y = 0; | 1141 | y = 0; |
1137 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), | 1142 | drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1), |
1138 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, | 1143 | btn->height(), AlignLeft|AlignVCenter|ShowPrefix, |
1139 | btn->colorGroup(), btn->isEnabled(), | 1144 | btn->colorGroup(), btn->isEnabled(), |
1140 | btn->pixmap(), btn->text()); | 1145 | btn->pixmap(), btn->text()); |
1141 | p.end(); | 1146 | p.end(); |
1142 | return(true); | 1147 | return(true); |
1143 | } | 1148 | } |
1144 | // for hover, just redraw the indicator (not the text) | 1149 | // for hover, just redraw the indicator (not the text) |
1145 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || | 1150 | else if((ev->type() == QEvent::Enter && btn->isEnabled()) || |
1146 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ | 1151 | (ev->type() == QEvent::Leave && btn == highlightWidget)){ |
1147 | QButton *btn = (QButton *)obj; | 1152 | QButton *btn = (QButton *)obj; |
1148 | bool isRadio = obj->inherits("QRadioButton"); | 1153 | bool isRadio = obj->inherits("QRadioButton"); |
1149 | 1154 | ||
1150 | if(ev->type() == QEvent::Enter) | 1155 | if(ev->type() == QEvent::Enter) |
1151 | highlightWidget = btn; | 1156 | highlightWidget = btn; |
1152 | else | 1157 | else |
1153 | highlightWidget = NULL; | 1158 | highlightWidget = NULL; |
1154 | QFontMetrics fm = btn->fontMetrics(); | 1159 | QFontMetrics fm = btn->fontMetrics(); |
1155 | QSize lsz = fm.size(ShowPrefix, btn->text()); | 1160 | QSize lsz = fm.size(ShowPrefix, btn->text()); |
1156 | QSize sz = isRadio ? exclusiveIndicatorSize() | 1161 | QSize sz = isRadio ? exclusiveIndicatorSize() |
1157 | : indicatorSize(); | 1162 | : indicatorSize(); |
1158 | int x = 0; | 1163 | int x = 0; |
1159 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; | 1164 | int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2; |
1160 | //if(btn->autoMask()) | 1165 | //if(btn->autoMask()) |
1161 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); | 1166 | // btn->erase(x+1, y+1, sz.width()-2, sz.height()-2); |
1162 | QPainter p; | 1167 | QPainter p; |
1163 | p.begin(btn); | 1168 | p.begin(btn); |
1164 | if(isRadio) | 1169 | if(isRadio) |
1165 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), | 1170 | drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(), |
1166 | btn->colorGroup(), btn->isOn(), | 1171 | btn->colorGroup(), btn->isOn(), |
1167 | btn->isDown(), btn->isEnabled()); | 1172 | btn->isDown(), btn->isEnabled()); |
1168 | else | 1173 | else |
1169 | drawIndicator(&p, x, y, sz.width(), sz.height(), | 1174 | drawIndicator(&p, x, y, sz.width(), sz.height(), |
1170 | btn->colorGroup(), btn->state(), btn->isDown(), | 1175 | btn->colorGroup(), btn->state(), btn->isDown(), |
1171 | btn->isEnabled()); | 1176 | btn->isEnabled()); |
1172 | p.end(); | 1177 | p.end(); |
1173 | } | 1178 | } |
1174 | } | 1179 | } |
1175 | else if(obj->inherits("QHeader")){ | 1180 | else if(obj->inherits("QHeader")){ |
1176 | QHeader *hw = (QHeader *)obj; | 1181 | QHeader *hw = (QHeader *)obj; |
1177 | if(ev->type() == QEvent::Enter){ | 1182 | if(ev->type() == QEvent::Enter){ |
1178 | currentHeader = hw; | 1183 | currentHeader = hw; |
1179 | headerHoverID = -1; | 1184 | headerHoverID = -1; |
1180 | } | 1185 | } |
1181 | else if(ev->type() == QEvent::Leave){ | 1186 | else if(ev->type() == QEvent::Leave){ |
1182 | currentHeader = NULL; | 1187 | currentHeader = NULL; |
1183 | if(headerHoverID != -1){ | 1188 | if(headerHoverID != -1){ |
1184 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1189 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1185 | hw->sectionSize(headerHoverID), hw->height()); | 1190 | hw->sectionSize(headerHoverID), hw->height()); |
1186 | } | 1191 | } |
1187 | headerHoverID = -1; | 1192 | headerHoverID = -1; |
1188 | } | 1193 | } |
1189 | else if(ev->type() == QEvent::MouseMove){ | 1194 | else if(ev->type() == QEvent::MouseMove){ |
1190 | QMouseEvent *me = (QMouseEvent *)ev; | 1195 | QMouseEvent *me = (QMouseEvent *)ev; |
1191 | int oldHeader = headerHoverID; | 1196 | int oldHeader = headerHoverID; |
1192 | headerHoverID = hw->sectionAt(me->x()); | 1197 | headerHoverID = hw->sectionAt(me->x()); |
1193 | if(oldHeader != headerHoverID){ | 1198 | if(oldHeader != headerHoverID){ |
1194 | // reset old header | 1199 | // reset old header |
1195 | if(oldHeader != -1){ | 1200 | if(oldHeader != -1){ |
1196 | hw->repaint(hw->sectionPos(oldHeader), 0, | 1201 | hw->repaint(hw->sectionPos(oldHeader), 0, |
1197 | hw->sectionSize(oldHeader), hw->height()); | 1202 | hw->sectionSize(oldHeader), hw->height()); |
1198 | } | 1203 | } |
1199 | if(headerHoverID != -1){ | 1204 | if(headerHoverID != -1){ |
1200 | hw->repaint(hw->sectionPos(headerHoverID), 0, | 1205 | hw->repaint(hw->sectionPos(headerHoverID), 0, |
1201 | hw->sectionSize(headerHoverID), hw->height()); | 1206 | hw->sectionSize(headerHoverID), hw->height()); |
1202 | } | 1207 | } |
1203 | } | 1208 | } |
1204 | } | 1209 | } |
1205 | } | 1210 | } |
1206 | return(false); | 1211 | return(false); |
1207 | } | 1212 | } |
1208 | 1213 | ||
1209 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, | 1214 | void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h, |
1210 | const QColorGroup &g, bool sunken, | 1215 | const QColorGroup &g, bool sunken, |
1211 | const QBrush *) | 1216 | const QBrush *) |
1212 | { | 1217 | { |
1213 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), | 1218 | drawRoundButton(p, sunken ? g.background() : g.button(), g.background(), |
1214 | x, y, w, h); | 1219 | x, y, w, h); |
1215 | } | 1220 | } |
1216 | 1221 | ||
1217 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, | 1222 | void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h, |
1218 | const QColorGroup &g, bool sunken, | 1223 | const QColorGroup &g, bool sunken, |
1219 | const QBrush *) | 1224 | const QBrush *) |
1220 | { | 1225 | { |
1221 | if(p->device()->devType() != QInternal::Widget){ | 1226 | if(p->device()->devType() != QInternal::Widget){ |
1222 | // drawing into a temp pixmap, don't use mask | 1227 | // drawing into a temp pixmap, don't use mask |
1223 | QColor c = sunken ? g.button() : g.background(); | 1228 | QColor c = sunken ? g.button() : g.background(); |
1224 | p->setPen(c.dark(130)); | 1229 | p->setPen(c.dark(130)); |
1225 | p->drawRect(x, y, w, h); | 1230 | p->drawRect(x, y, w, h); |
1226 | p->setPen(c.light(105)); | 1231 | p->setPen(c.light(105)); |
1227 | p->drawRect(x+1, y+1, w-2, h-2); | 1232 | p->drawRect(x+1, y+1, w-2, h-2); |
1228 | 1233 | ||
1229 | 1234 | ||
1230 | // fill | 1235 | // fill |
1231 | QPixmap *pix = bevelFillDict.find(c.rgb()); | 1236 | QPixmap *pix = bevelFillDict.find(c.rgb()); |
1232 | if(!pix){ | 1237 | if(!pix){ |
1233 | int h, s, v; | 1238 | int h, s, v; |
1234 | c.hsv(&h, &s, &v); | 1239 | c.hsv(&h, &s, &v); |
1235 | pix = new QPixmap(*bevelFillPix); | 1240 | pix = new QPixmap(*bevelFillPix); |
1236 | adjustHSV(*pix, h, s, v); | 1241 | adjustHSV(*pix, h, s, v); |
1237 | bevelFillDict.insert(c.rgb(), pix); | 1242 | bevelFillDict.insert(c.rgb(), pix); |
1238 | } | 1243 | } |
1239 | 1244 | ||
1240 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); | 1245 | p->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix); |
1241 | } | 1246 | } |
1242 | else{ | 1247 | else{ |
1243 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : | 1248 | drawClearBevel(p, x, y, w, h, sunken ? g.button() : |
1244 | highlightWidget == p->device() ? g.button().light(110) : | 1249 | highlightWidget == p->device() ? g.button().light(110) : |
1245 | g.background(), g.background()); | 1250 | g.background(), g.background()); |
1246 | } | 1251 | } |
1247 | } | 1252 | } |
1248 | 1253 | ||
1249 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) | 1254 | void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p) |
1250 | { | 1255 | { |
1251 | QRect r = btn->rect(); | 1256 | QRect r = btn->rect(); |
1252 | bool sunken = btn->isOn() || btn->isDown(); | 1257 | bool sunken = btn->isOn() || btn->isDown(); |
1253 | QColorGroup g = btn->colorGroup(); | 1258 | QColorGroup g = btn->colorGroup(); |
1254 | 1259 | ||
diff --git a/noncore/styles/liquid/liquid.pro b/noncore/styles/liquid/liquid.pro index 8689d3d..23dce09 100644 --- a/noncore/styles/liquid/liquid.pro +++ b/noncore/styles/liquid/liquid.pro | |||
@@ -1,28 +1,30 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG = qt embedded release warn_on | 2 | CONFIG = qt embedded release warn_on |
3 | SOURCES = liquid.cpp \ | 3 | SOURCES = liquid.cpp \ |
4 | liquiddeco.cpp \ | ||
4 | effects.cpp \ | 5 | effects.cpp \ |
5 | plugin.cpp | 6 | plugin.cpp |
6 | 7 | ||
7 | HEADERS = liquid.h \ | 8 | HEADERS = liquid.h \ |
9 | liquiddeco.h \ | ||
8 | effects.h | 10 | effects.h |
9 | LIBS += -lqpe | 11 | LIBS += -lqpe |
10 | INCLUDEPATH += $(OPIEDIR)/include | 12 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DESTDIR = $(OPIEDIR)/plugins/styles | 13 | DESTDIR = $(OPIEDIR)/plugins/styles |
12 | TARGET = liquid | 14 | TARGET = liquid |
13 | VERSION = 1.0.0 | 15 | VERSION = 1.0.0 |
14 | 16 | ||
15 | TRANSLATIONS = ../../../i18n/de/libliquid.ts \ | 17 | TRANSLATIONS = ../../../i18n/de/libliquid.ts \ |
16 | ../../../i18n/en/libliquid.ts \ | 18 | ../../../i18n/en/libliquid.ts \ |
17 | ../../../i18n/es/libliquid.ts \ | 19 | ../../../i18n/es/libliquid.ts \ |
18 | ../../../i18n/fr/libliquid.ts \ | 20 | ../../../i18n/fr/libliquid.ts \ |
19 | ../../../i18n/hu/libliquid.ts \ | 21 | ../../../i18n/hu/libliquid.ts \ |
20 | ../../../i18n/ja/libliquid.ts \ | 22 | ../../../i18n/ja/libliquid.ts \ |
21 | ../../../i18n/ko/libliquid.ts \ | 23 | ../../../i18n/ko/libliquid.ts \ |
22 | ../../../i18n/no/libliquid.ts \ | 24 | ../../../i18n/no/libliquid.ts \ |
23 | ../../../i18n/pl/libliquid.ts \ | 25 | ../../../i18n/pl/libliquid.ts \ |
24 | ../../../i18n/pt/libliquid.ts \ | 26 | ../../../i18n/pt/libliquid.ts \ |
25 | ../../../i18n/pt_BR/libliquid.ts \ | 27 | ../../../i18n/pt_BR/libliquid.ts \ |
26 | ../../../i18n/sl/libliquid.ts \ | 28 | ../../../i18n/sl/libliquid.ts \ |
27 | ../../../i18n/zh_CN/libliquid.ts \ | 29 | ../../../i18n/zh_CN/libliquid.ts \ |
28 | ../../../i18n/zh_TW/libliquid.ts | 30 | ../../../i18n/zh_TW/libliquid.ts |
diff --git a/noncore/styles/liquid/liquiddeco.cpp b/noncore/styles/liquid/liquiddeco.cpp new file mode 100644 index 0000000..8eee1b1 --- a/dev/null +++ b/noncore/styles/liquid/liquiddeco.cpp | |||
@@ -0,0 +1,183 @@ | |||
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 <qapplication.h> | ||
22 | #include <qstyle.h> | ||
23 | #include <qwidget.h> | ||
24 | #include <qpainter.h> | ||
25 | #include <qtimer.h> | ||
26 | #include <qwhatsthis.h> | ||
27 | #include <qpe/qcopenvelope_qws.h> | ||
28 | #include <qpe/qpedecoration_qws.h> | ||
29 | #include <qdialog.h> | ||
30 | #include <qdrawutil.h> | ||
31 | #include <qgfx_qws.h> | ||
32 | #include <qpe/qpeapplication.h> | ||
33 | #include <qpe/resource.h> | ||
34 | #include <qpe/global.h> | ||
35 | #include <qfile.h> | ||
36 | #include <qsignal.h> | ||
37 | |||
38 | #include "liquiddeco.h" | ||
39 | |||
40 | #include <stdlib.h> | ||
41 | |||
42 | extern QRect qt_maxWindowRect; | ||
43 | |||
44 | class HackWidget : public QWidget | ||
45 | { | ||
46 | public: | ||
47 | bool needsOk() | ||
48 | { | ||
49 | return ( getWState() & WState_Reserved1 ); | ||
50 | } | ||
51 | }; | ||
52 | |||
53 | |||
54 | LiquidDecoration::LiquidDecoration() | ||
55 | : QPEDecoration() | ||
56 | {} | ||
57 | |||
58 | LiquidDecoration::~LiquidDecoration() | ||
59 | {} | ||
60 | |||
61 | int LiquidDecoration::getTitleHeight( const QWidget * ) | ||
62 | { | ||
63 | return 15; | ||
64 | } | ||
65 | |||
66 | |||
67 | void LiquidDecoration::paint( QPainter *painter, const QWidget *widget ) | ||
68 | { | ||
69 | int titleWidth = getTitleWidth( widget ); | ||
70 | int titleHeight = getTitleHeight( widget ); | ||
71 | |||
72 | QRect rect( widget->rect() ); | ||
73 | |||
74 | // Border rect | ||
75 | QRect br( rect.left() - BORDER_WIDTH, | ||
76 | rect.top() - BORDER_WIDTH - titleHeight, | ||
77 | rect.width() + 2 * BORDER_WIDTH, | ||
78 | rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight ); | ||
79 | |||
80 | // title bar rect | ||
81 | QRect tr; | ||
82 | |||
83 | tr = QRect( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | ||
84 | |||
85 | QRegion oldClip = painter->clipRegion(); | ||
86 | painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker | ||
87 | |||
88 | bool isActive = ( widget == qApp->activeWindow() ); | ||
89 | |||
90 | QColorGroup cg = QApplication::palette().active(); | ||
91 | if ( isActive ) | ||
92 | cg. setBrush ( QColorGroup::Button, cg. brush ( QColorGroup::Highlight ) ); | ||
93 | |||
94 | qDrawWinPanel( painter, br.x(), br.y(), br.width(), | ||
95 | br.height() - 4, cg, FALSE, | ||
96 | &cg.brush( QColorGroup::Background ) ); | ||
97 | |||
98 | painter->setClipRegion( oldClip ); | ||
99 | |||
100 | if ( titleWidth > 0 ) { | ||
101 | QBrush titleBrush; | ||
102 | QPen titlePen; | ||
103 | QPen titleLines; | ||
104 | int titleLeft = titleHeight + 4; | ||
105 | |||
106 | titleLeft = rect.left() + 5; | ||
107 | painter->setPen( cg.midlight() ); | ||
108 | painter->drawLine( rect.left() - BORDER_WIDTH + 2, | ||
109 | rect.bottom() + 1, rect.right() + BORDER_WIDTH - 2, | ||
110 | rect.bottom() + 1 ); | ||
111 | |||
112 | QRect t ( rect.left() - 2, rect.top() - titleHeight - 2, rect.width() + 3, titleHeight + 2 ); | ||
113 | |||
114 | |||
115 | |||
116 | QApplication::style().drawBevelButton( painter, t.x(), t.y(), t.width(), t.height(), cg, isActive ); | ||
117 | |||
118 | t.setLeft( t.left() + 4 ); | ||
119 | t.setRight( t.right() - 2 ); | ||
120 | |||
121 | QFont f( QApplication::font() ); | ||
122 | f.setWeight( QFont::Bold ); | ||
123 | |||
124 | painter-> setFont( f ); | ||
125 | |||
126 | QColor textcol = cg.color( isActive ? QColorGroup::HighlightedText : QColorGroup::Text ); | ||
127 | QColor shadecol = ( qGray ( textcol. rgb ( ) ) > 128 ) ? textcol. dark ( 130 ) : textcol.light( 200 ); | ||
128 | |||
129 | if ( textcol == shadecol ) { | ||
130 | if ( qGray ( shadecol. rgb ( ) ) < 128 ) | ||
131 | shadecol = QColor ( 225, 225, 225 ); | ||
132 | else | ||
133 | shadecol = QColor ( 30, 30, 30 ); | ||
134 | } | ||
135 | |||
136 | painter-> setPen( shadecol ); | ||
137 | painter-> drawText( t.x() + 1, t.y() + 1, t.width(), t.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, widget->caption() ); | ||
138 | painter-> setPen( textcol ); | ||
139 | painter-> drawText( t.x(), t.y(), t.width(), t.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, widget->caption() ); | ||
140 | } | ||
141 | |||
142 | #ifndef MINIMIZE_HELP_HACK | ||
143 | paintButton( painter, widget, ( QWSDecoration::Region ) Help, 0 ); | ||
144 | #endif | ||
145 | } | ||
146 | |||
147 | void LiquidDecoration::paintButton( QPainter *painter, const QWidget *w, | ||
148 | QWSDecoration::Region type, int state ) | ||
149 | { | ||
150 | const QColorGroup & cg = w->palette().active(); | ||
151 | |||
152 | QRect brect( region( w, w->rect(), type ).boundingRect() ); | ||
153 | |||
154 | const QImage *img = 0; | ||
155 | |||
156 | switch ( ( int ) type ) { | ||
157 | case Close: | ||
158 | img = &imageClose; | ||
159 | break; | ||
160 | case Minimize: | ||
161 | if ( ( ( HackWidget * ) w ) ->needsOk() || | ||
162 | ( w->inherits( "QDialog" ) && !w->inherits( "QMessageBox" ) ) ) | ||
163 | img = &imageOk; | ||
164 | else if ( helpExists ) | ||
165 | img = &imageHelp; | ||
166 | break; | ||
167 | case Help: | ||
168 | img = &imageHelp; | ||
169 | break; | ||
170 | default: | ||
171 | return ; | ||
172 | } | ||
173 | |||
174 | if ( img ) { | ||
175 | if ( ( state & QWSButton::MouseOver ) && ( state & QWSButton::Clicked ) ) | ||
176 | painter->drawImage( brect.x() + 1, brect.y() + 3, *img ); | ||
177 | else | ||
178 | painter->drawImage( brect.x(), brect.y() + 2, *img ); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | |||
183 | |||
diff --git a/noncore/styles/liquid/liquiddeco.h b/noncore/styles/liquid/liquiddeco.h new file mode 100644 index 0000000..d975fe5 --- a/dev/null +++ b/noncore/styles/liquid/liquiddeco.h | |||
@@ -0,0 +1,41 @@ | |||
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 | #ifndef OPIE_LIQUIDDECO_H__ | ||
21 | #define OPIE_LIQUIDDECO_H__ | ||
22 | |||
23 | #include <qpe/qpedecoration_qws.h> | ||
24 | |||
25 | |||
26 | class LiquidDecoration : public QPEDecoration | ||
27 | { | ||
28 | public: | ||
29 | LiquidDecoration(); | ||
30 | virtual ~LiquidDecoration(); | ||
31 | |||
32 | virtual void paint(QPainter *, const QWidget *); | ||
33 | virtual void paintButton(QPainter *, const QWidget *, Region, int state); | ||
34 | |||
35 | protected: | ||
36 | virtual int getTitleHeight(const QWidget *); | ||
37 | }; | ||
38 | |||
39 | |||
40 | |||
41 | #endif // OPIE_LIQUIDDECO_H__ | ||