author | sandman <sandman> | 2002-07-08 00:42:56 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-07-08 00:42:56 (UTC) |
commit | 923a6290c8cc93914d54e583f1d79a6bae638fab (patch) (unidiff) | |
tree | b2562e4dbf6d71631b358021f8c4ec29f36a6d12 | |
parent | 895f43bd1850b3e0c43edaaad18a7d7f2613033b (diff) | |
download | opie-923a6290c8cc93914d54e583f1d79a6bae638fab.zip opie-923a6290c8cc93914d54e583f1d79a6bae638fab.tar.gz opie-923a6290c8cc93914d54e583f1d79a6bae638fab.tar.bz2 |
- Fix a memory leak (bg pixmaps for taskbar applets were never freed)
- Try to be more intelligent about stipple alignment in child widgets
(in every app I tested the stipple is now always aligned right)
-rw-r--r-- | noncore/styles/liquid/liquid.cpp | 16 | ||||
-rw-r--r-- | noncore/styles/liquid/plugin.cpp | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp index 67e53e9..fc925b8 100644 --- a/noncore/styles/liquid/liquid.cpp +++ b/noncore/styles/liquid/liquid.cpp | |||
@@ -32,217 +32,216 @@ | |||
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | 33 | ||
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | #include "htmlmasks.h" | 37 | #include "htmlmasks.h" |
38 | #include "embeddata.h" | 38 | #include "embeddata.h" |
39 | 39 | ||
40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, | 40 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, |
41 | QColorGroup &, bool, bool); | 41 | QColorGroup &, bool, bool); |
42 | 42 | ||
43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); | 43 | QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); |
44 | 44 | ||
45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) | 45 | void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) |
46 | { | 46 | { |
47 | QImage img(pix.convertToImage()); | 47 | QImage img(pix.convertToImage()); |
48 | QImageEffect::fade(img, 0.9, color); | 48 | QImageEffect::fade(img, 0.9, color); |
49 | int x, y; | 49 | int x, y; |
50 | int r, g, b; | 50 | int r, g, b; |
51 | for(y=0; y < img.height(); y+=3){ | 51 | for(y=0; y < img.height(); y+=3){ |
52 | unsigned int *data = (unsigned int *) img.scanLine(y); | 52 | unsigned int *data = (unsigned int *) img.scanLine(y); |
53 | for(x=0; x < img.width(); ++x){ | 53 | for(x=0; x < img.width(); ++x){ |
54 | r = qRed(data[x]); | 54 | r = qRed(data[x]); |
55 | g = qGreen(data[x]); | 55 | g = qGreen(data[x]); |
56 | b = qBlue(data[x]); | 56 | b = qBlue(data[x]); |
57 | if(r-10) | 57 | if(r-10) |
58 | r-=10; | 58 | r-=10; |
59 | if(g-10) | 59 | if(g-10) |
60 | g-=10; | 60 | g-=10; |
61 | if(b-10) | 61 | if(b-10) |
62 | b-=10; | 62 | b-=10; |
63 | data[x] = qRgb(r, g, b); | 63 | data[x] = qRgb(r, g, b); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | pix.convertFromImage(img); | 66 | pix.convertFromImage(img); |
67 | } | 67 | } |
68 | 68 | ||
69 | TransMenuHandler::TransMenuHandler(QObject *parent) | 69 | TransMenuHandler::TransMenuHandler(QObject *parent) |
70 | : QObject(parent) | 70 | : QObject(parent) |
71 | { | 71 | { |
72 | pixDict.setAutoDelete(true); | 72 | pixDict.setAutoDelete(true); |
73 | reloadSettings(); | 73 | reloadSettings(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void TransMenuHandler::reloadSettings() | 76 | void TransMenuHandler::reloadSettings() |
77 | { | 77 | { |
78 | pixDict.clear(); | 78 | pixDict.clear(); |
79 | 79 | ||
80 | Config config ( "qpe" ); | 80 | Config config ( "qpe" ); |
81 | config. setGroup ( "Liquid-Style" ); | 81 | config. setGroup ( "Liquid-Style" ); |
82 | 82 | ||
83 | type = config. readNumEntry("Type", TransStippleBg); | 83 | type = config. readNumEntry("Type", TransStippleBg); |
84 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); | 84 | color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); |
85 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); | 85 | fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); |
86 | opacity = config. readNumEntry("Opacity", 10); | 86 | opacity = config. readNumEntry("Opacity", 10); |
87 | if ( opacity < -20 ) | 87 | if ( opacity < -20 ) |
88 | opacity = 20; | 88 | opacity = 20; |
89 | else if ( opacity > 20 ) | 89 | else if ( opacity > 20 ) |
90 | opacity = 20; | 90 | opacity = 20; |
91 | 91 | ||
92 | shadowText = config. readBoolEntry("ShadowText", true); | 92 | shadowText = config. readBoolEntry("ShadowText", true); |
93 | } | 93 | } |
94 | 94 | ||
95 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) | 95 | bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev) |
96 | { | 96 | { |
97 | QWidget *p = (QWidget *)obj; | 97 | QWidget *p = (QWidget *)obj; |
98 | 98 | ||
99 | if(ev->type() == QEvent::Show){ | 99 | if(ev->type() == QEvent::Show){ |
100 | if(type == TransStippleBg || type == TransStippleBtn || | 100 | if(type == TransStippleBg || type == TransStippleBtn || |
101 | type == Custom){ | 101 | type == Custom){ |
102 | QApplication::syncX(); | 102 | QApplication::syncX(); |
103 | QPixmap *pix = new QPixmap; | 103 | QPixmap *pix = new QPixmap; |
104 | if(p->testWFlags(Qt::WType_Popup)){ | 104 | if(p->testWFlags(Qt::WType_Popup)){ |
105 | QRect r(p->x(), p->y(), p->width(), p->height()); | 105 | QRect r(p->x(), p->y(), p->width(), p->height()); |
106 | QRect deskR = QApplication::desktop()->rect(); | 106 | QRect deskR = QApplication::desktop()->rect(); |
107 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ | 107 | if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){ |
108 | r.setBottom(deskR.bottom()); | 108 | r.setBottom(deskR.bottom()); |
109 | r.setRight(deskR.right()); | 109 | r.setRight(deskR.right()); |
110 | } | 110 | } |
111 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), | 111 | *pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(), |
112 | r.width(), r.height()); | 112 | r.width(), r.height()); |
113 | } | 113 | } |
114 | else{ // tear off menu | 114 | else{ // tear off menu |
115 | pix->resize(p->width(), p->height()); | 115 | pix->resize(p->width(), p->height()); |
116 | pix->fill(Qt::black.rgb()); | 116 | pix->fill(Qt::black.rgb()); |
117 | } | 117 | } |
118 | if(type == TransStippleBg){ | 118 | if(type == TransStippleBg){ |
119 | stripePixmap(*pix, p->colorGroup().background()); | 119 | stripePixmap(*pix, p->colorGroup().background()); |
120 | } | 120 | } |
121 | else if(type == TransStippleBtn){ | 121 | else if(type == TransStippleBtn){ |
122 | stripePixmap(*pix, p->colorGroup().button()); | 122 | stripePixmap(*pix, p->colorGroup().button()); |
123 | } | 123 | } |
124 | else{ | 124 | else{ |
125 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); | 125 | QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color); |
126 | } | 126 | } |
127 | 127 | ||
128 | if (p->inherits("QPopupMenu")) | 128 | pixDict.insert(p->winId(), pix); |
129 | pixDict.insert(p->winId(), pix); | 129 | |
130 | else { | 130 | if (!p->inherits("QPopupMenu")) { |
131 | p->setBackgroundPixmap(*pix); | 131 | p->setBackgroundPixmap(*pix); |
132 | 132 | ||
133 | QObjectList *ol = p-> queryList("QWidget"); | 133 | QObjectList *ol = p-> queryList("QWidget"); |
134 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 134 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
135 | QWidget *wid = (QWidget *) it.current ( ); | 135 | QWidget *wid = (QWidget *) it.current ( ); |
136 | 136 | ||
137 | wid-> setBackgroundPixmap(*pix); | 137 | wid-> setBackgroundPixmap(*pix); |
138 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); | 138 | wid-> setBackgroundOrigin(QWidget::ParentOrigin); |
139 | } | 139 | } |
140 | delete ol; | 140 | delete ol; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | } | 143 | } |
144 | else if(ev->type() == QEvent::Hide){ | 144 | else if(ev->type() == QEvent::Hide){ |
145 | if(type == TransStippleBg || type == TransStippleBtn || | 145 | if(type == TransStippleBg || type == TransStippleBtn || |
146 | type == Custom){ | 146 | type == Custom){ |
147 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); | 147 | // qWarning("Deleting menu pixmap, width %d", pixDict.find(p->winId())->width()); |
148 | 148 | ||
149 | if (p->inherits("QPopupMenu")) | 149 | pixDict.remove(p->winId()); |
150 | pixDict.remove(p->winId()); | 150 | if (!p->inherits("QPopupMenu")) { |
151 | else { | 151 | p->setBackgroundMode(QWidget::PaletteBackground); |
152 | p->setBackgroundMode(QWidget::PaletteBackground); | ||
153 | 152 | ||
154 | QObjectList *ol = p-> queryList("QWidget"); | 153 | QObjectList *ol = p-> queryList("QWidget"); |
155 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { | 154 | for ( QObjectListIt it( *ol ); it. current ( ); ++it ) { |
156 | QWidget *wid = (QWidget *) it.current ( ); | 155 | QWidget *wid = (QWidget *) it.current ( ); |
157 | 156 | ||
158 | wid-> setBackgroundMode( QWidget::PaletteBackground ); | 157 | wid-> setBackgroundMode( QWidget::PaletteBackground ); |
159 | } | 158 | } |
160 | delete ol; | 159 | delete ol; |
161 | } | 160 | } |
162 | } | 161 | } |
163 | } | 162 | } |
164 | return(false); | 163 | return(false); |
165 | } | 164 | } |
166 | 165 | ||
167 | 166 | ||
168 | LiquidStyle::LiquidStyle() | 167 | LiquidStyle::LiquidStyle() |
169 | :QWindowsStyle() | 168 | :QWindowsStyle() |
170 | { | 169 | { |
171 | setName ( "LiquidStyle" ); | 170 | setName ( "LiquidStyle" ); |
172 | 171 | ||
173 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); | 172 | btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true); |
174 | btnMaskBmp.setMask(btnMaskBmp); | 173 | btnMaskBmp.setMask(btnMaskBmp); |
175 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); | 174 | htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true); |
176 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); | 175 | htmlBtnMaskBmp.setMask(htmlBtnMaskBmp); |
177 | headerHoverID = -1; | 176 | headerHoverID = -1; |
178 | highlightWidget = NULL; | 177 | highlightWidget = NULL; |
179 | setButtonDefaultIndicatorWidth(0); | 178 | setButtonDefaultIndicatorWidth(0); |
180 | btnDict.setAutoDelete(true); | 179 | btnDict.setAutoDelete(true); |
181 | bevelFillDict.setAutoDelete(true); | 180 | bevelFillDict.setAutoDelete(true); |
182 | smallBevelFillDict.setAutoDelete(true); | 181 | smallBevelFillDict.setAutoDelete(true); |
183 | customBtnColorList.setAutoDelete(true); | 182 | customBtnColorList.setAutoDelete(true); |
184 | customBtnIconList.setAutoDelete(true); | 183 | customBtnIconList.setAutoDelete(true); |
185 | customBtnLabelList.setAutoDelete(true); | 184 | customBtnLabelList.setAutoDelete(true); |
186 | 185 | ||
187 | rMatrix.rotate(270.0); | 186 | rMatrix.rotate(270.0); |
188 | highcolor = QPixmap::defaultDepth() > 8; | 187 | highcolor = QPixmap::defaultDepth() > 8; |
189 | btnBorderPix = new QPixmap; | 188 | btnBorderPix = new QPixmap; |
190 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); | 189 | btnBorderPix->convertFromImage(qembed_findImage("buttonfill")); |
191 | btnBlendPix = new QPixmap; | 190 | btnBlendPix = new QPixmap; |
192 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); | 191 | btnBlendPix->convertFromImage(qembed_findImage("buttonborder")); |
193 | bevelFillPix = new QPixmap; | 192 | bevelFillPix = new QPixmap; |
194 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); | 193 | bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large")); |
195 | smallBevelFillPix = new QPixmap; | 194 | smallBevelFillPix = new QPixmap; |
196 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); | 195 | smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small")); |
197 | // new stuff | 196 | // new stuff |
198 | vsbSliderFillPix = menuPix = NULL; | 197 | vsbSliderFillPix = menuPix = NULL; |
199 | menuHandler = new TransMenuHandler(this); | 198 | menuHandler = new TransMenuHandler(this); |
200 | setScrollBarExtent(15, 15); | 199 | setScrollBarExtent(15, 15); |
201 | int i; | 200 | int i; |
202 | for(i=0; i < BITMAP_ITEMS; ++i){ | 201 | for(i=0; i < BITMAP_ITEMS; ++i){ |
203 | pixmaps[i] = NULL; | 202 | pixmaps[i] = NULL; |
204 | } | 203 | } |
205 | oldSliderThickness = sliderThickness(); | 204 | oldSliderThickness = sliderThickness(); |
206 | setSliderThickness(11); | 205 | setSliderThickness(11); |
207 | } | 206 | } |
208 | 207 | ||
209 | LiquidStyle::~LiquidStyle() | 208 | LiquidStyle::~LiquidStyle() |
210 | { | 209 | { |
211 | if(btnBorderPix) | 210 | if(btnBorderPix) |
212 | delete btnBorderPix; | 211 | delete btnBorderPix; |
213 | if(btnBlendPix) | 212 | if(btnBlendPix) |
214 | delete btnBlendPix; | 213 | delete btnBlendPix; |
215 | if(bevelFillPix) | 214 | if(bevelFillPix) |
216 | delete bevelFillPix; | 215 | delete bevelFillPix; |
217 | if(smallBevelFillPix) | 216 | if(smallBevelFillPix) |
218 | delete smallBevelFillPix; | 217 | delete smallBevelFillPix; |
219 | if(vsbSliderFillPix) | 218 | if(vsbSliderFillPix) |
220 | delete vsbSliderFillPix; | 219 | delete vsbSliderFillPix; |
221 | if(menuPix) | 220 | if(menuPix) |
222 | delete menuPix; | 221 | delete menuPix; |
223 | 222 | ||
224 | setScrollBarExtent(16, 16); | 223 | setScrollBarExtent(16, 16); |
225 | setSliderThickness(oldSliderThickness); | 224 | setSliderThickness(oldSliderThickness); |
226 | int i; | 225 | int i; |
227 | for(i=0; i < BITMAP_ITEMS; ++i){ | 226 | for(i=0; i < BITMAP_ITEMS; ++i){ |
228 | if(pixmaps[i]) | 227 | if(pixmaps[i]) |
229 | delete pixmaps[i]; | 228 | delete pixmaps[i]; |
230 | } | 229 | } |
231 | } | 230 | } |
232 | 231 | ||
233 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, | 232 | void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h, |
234 | const QColor &c, const QColor &bg) | 233 | const QColor &c, const QColor &bg) |
235 | { | 234 | { |
236 | 235 | ||
237 | QPen oldPen = p->pen(); // headers need this | 236 | QPen oldPen = p->pen(); // headers need this |
238 | int x2 = x+w-1; | 237 | int x2 = x+w-1; |
239 | int y2 = y+h-1; | 238 | int y2 = y+h-1; |
240 | // outer dark rect | 239 | // outer dark rect |
241 | p->setPen(c.dark(130)); | 240 | p->setPen(c.dark(130)); |
242 | p->drawLine(x, y+2, x, y2-2); // l | 241 | p->drawLine(x, y+2, x, y2-2); // l |
243 | p->drawLine(x2, y+2, x2, y2-2); // r | 242 | p->drawLine(x2, y+2, x2, y2-2); // r |
244 | p->drawLine(x+2, y, x2-2, y); // t | 243 | p->drawLine(x+2, y, x2-2, y); // t |
245 | p->drawLine(x+2, y2, x2-2, y2); // b | 244 | p->drawLine(x+2, y2, x2-2, y2); // b |
246 | p->drawPoint(x+1, y+1); // tl | 245 | p->drawPoint(x+1, y+1); // tl |
247 | p->drawPoint(x2-1, y+1); // tr | 246 | p->drawPoint(x2-1, y+1); // tr |
248 | p->drawPoint(x+1, y2-1); // bl | 247 | p->drawPoint(x+1, y2-1); // bl |
@@ -752,193 +751,194 @@ void LiquidStyle::polish(QPalette &appPal) | |||
752 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 751 | QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
753 | if(!pix){ | 752 | if(!pix){ |
754 | int h, s, v; | 753 | int h, s, v; |
755 | c.hsv(&h, &s, &v); | 754 | c.hsv(&h, &s, &v); |
756 | pix = new QPixmap(*smallBevelFillPix); | 755 | pix = new QPixmap(*smallBevelFillPix); |
757 | adjustHSV(*pix, h, s, v); | 756 | adjustHSV(*pix, h, s, v); |
758 | smallBevelFillDict.insert(c.rgb(), pix); | 757 | smallBevelFillDict.insert(c.rgb(), pix); |
759 | } | 758 | } |
760 | pagerHoverBrush.setColor(c); | 759 | pagerHoverBrush.setColor(c); |
761 | pagerHoverBrush.setPixmap(*pix); | 760 | pagerHoverBrush.setPixmap(*pix); |
762 | 761 | ||
763 | c = c.dark(120); | 762 | c = c.dark(120); |
764 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) | 763 | pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-) |
765 | if(!pix){ | 764 | if(!pix){ |
766 | int h, s, v; | 765 | int h, s, v; |
767 | c.hsv(&h, &s, &v); | 766 | c.hsv(&h, &s, &v); |
768 | pix = new QPixmap(*smallBevelFillPix); | 767 | pix = new QPixmap(*smallBevelFillPix); |
769 | adjustHSV(*pix, h, s, v); | 768 | adjustHSV(*pix, h, s, v); |
770 | smallBevelFillDict.insert(c.rgb(), pix); | 769 | smallBevelFillDict.insert(c.rgb(), pix); |
771 | } | 770 | } |
772 | pagerBrush.setColor(c); | 771 | pagerBrush.setColor(c); |
773 | pagerBrush.setPixmap(*pix); | 772 | pagerBrush.setPixmap(*pix); |
774 | 773 | ||
775 | // background color stuff | 774 | // background color stuff |
776 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); | 775 | c = QColor ( config. readEntry ( "Background", ( Qt::lightGray ).name ( ))); |
777 | c.hsv(&bH, &bS, &bV); | 776 | c.hsv(&bH, &bS, &bV); |
778 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); | 777 | c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV); |
779 | 778 | ||
780 | // FIXME? | 779 | // FIXME? |
781 | if(vsbSliderFillPix) | 780 | if(vsbSliderFillPix) |
782 | delete vsbSliderFillPix; | 781 | delete vsbSliderFillPix; |
783 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); | 782 | vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix)); |
784 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); | 783 | adjustHSV(*vsbSliderFillPix, bH, bS, bV); |
785 | 784 | ||
786 | // background brush | 785 | // background brush |
787 | QPixmap wallPaper(32, 32); | 786 | QPixmap wallPaper(32, 32); |
788 | wallPaper.fill(c.rgb()); | 787 | wallPaper.fill(c.rgb()); |
789 | painter.begin(&wallPaper); | 788 | painter.begin(&wallPaper); |
790 | for(i=0; i < 32; i+=4){ | 789 | for(i=0; i < 32; i+=4){ |
791 | painter.setPen(c.dark(100 + contrast)); | 790 | painter.setPen(c.dark(100 + contrast)); |
792 | painter.drawLine(0, i, 32, i); | 791 | painter.drawLine(0, i, 32, i); |
793 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); | 792 | painter.setPen(c.dark(100 + 3 * contrast / 5 ) ); |
794 | painter.drawLine(0, i+1, 32, i+1); | 793 | painter.drawLine(0, i+1, 32, i+1); |
795 | }; | 794 | }; |
796 | painter.end(); | 795 | painter.end(); |
797 | bgBrush.setColor(c); | 796 | bgBrush.setColor(c); |
798 | bgBrush.setPixmap(wallPaper); | 797 | bgBrush.setPixmap(wallPaper); |
799 | appPal.setBrush(QColorGroup::Background, bgBrush); | 798 | appPal.setBrush(QColorGroup::Background, bgBrush); |
800 | 799 | ||
801 | // lineedits | 800 | // lineedits |
802 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); | 801 | c = QColor ( config. readEntry("Base", ( Qt::white). name ( ))); |
803 | QPixmap basePix; | 802 | QPixmap basePix; |
804 | basePix.resize(32, 32); | 803 | basePix.resize(32, 32); |
805 | basePix.fill(c.rgb()); | 804 | basePix.fill(c.rgb()); |
806 | painter.begin(&basePix); | 805 | painter.begin(&basePix); |
807 | painter.setPen(c.dark(105)); | 806 | painter.setPen(c.dark(105)); |
808 | for(i=0; i < 32; i+=4){ | 807 | for(i=0; i < 32; i+=4){ |
809 | painter.drawLine(0, i, 32, i); | 808 | painter.drawLine(0, i, 32, i); |
810 | painter.drawLine(0, i+1, 32, i+1); | 809 | painter.drawLine(0, i+1, 32, i+1); |
811 | }; | 810 | }; |
812 | painter.end(); | 811 | painter.end(); |
813 | baseBrush.setColor(c); | 812 | baseBrush.setColor(c); |
814 | baseBrush.setPixmap(basePix); | 813 | baseBrush.setPixmap(basePix); |
815 | it.toFirst(); | 814 | it.toFirst(); |
816 | while ((w=it.current()) != 0 ){ | 815 | while ((w=it.current()) != 0 ){ |
817 | ++it; | 816 | ++it; |
818 | if(w->inherits("QLineEdit")){ | 817 | if(w->inherits("QLineEdit")){ |
819 | QPalette pal = w->palette(); | 818 | QPalette pal = w->palette(); |
820 | pal.setBrush(QColorGroup::Base, baseBrush); | 819 | pal.setBrush(QColorGroup::Base, baseBrush); |
821 | w->setPalette(pal); | 820 | w->setPalette(pal); |
822 | } | 821 | } |
823 | else if(w->inherits("QPushButton")){ | 822 | else if(w->inherits("QPushButton")){ |
824 | applyCustomAttributes((QPushButton *)w); | 823 | applyCustomAttributes((QPushButton *)w); |
825 | } | 824 | } |
826 | } | 825 | } |
827 | 826 | ||
828 | } | 827 | } |
829 | 828 | ||
830 | void LiquidStyle::polish(QWidget *w) | 829 | void LiquidStyle::polish(QWidget *w) |
831 | { | 830 | { |
832 | if(w->inherits("QMenuBar")){ | 831 | if(w->inherits("QMenuBar")){ |
833 | //((QFrame*)w)->setLineWidth(0); | 832 | //((QFrame*)w)->setLineWidth(0); |
834 | w->setBackgroundMode(QWidget::PaletteBackground); | 833 | w->setBackgroundMode(QWidget::PaletteBackground); |
835 | return; | 834 | return; |
836 | } | 835 | } |
837 | if(w->inherits("QPopupMenu")) | 836 | if(w->inherits("QPopupMenu")) |
838 | w->setBackgroundMode(QWidget::NoBackground); | 837 | w->setBackgroundMode(QWidget::NoBackground); |
839 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 838 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
840 | w->installEventFilter(menuHandler); | 839 | w->installEventFilter(menuHandler); |
841 | } | 840 | } |
842 | 841 | ||
843 | if(w->isTopLevel()){ | 842 | if(w->isTopLevel()){ |
844 | return; | 843 | return; |
845 | } | 844 | } |
846 | 845 | ||
847 | 846 | ||
848 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | 847 | if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame )) |
848 | w-> setBackgroundOrigin ( QWidget::ParentOrigin ); | ||
849 | 849 | ||
850 | if(w->inherits("QComboBox") || | 850 | if(w->inherits("QComboBox") || |
851 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || | 851 | w->inherits("QLineEdit") || w->inherits("QRadioButton") || |
852 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { | 852 | w->inherits("QCheckBox") || w->inherits("QScrollBar")) { |
853 | w->installEventFilter(this); | 853 | w->installEventFilter(this); |
854 | } | 854 | } |
855 | if(w->inherits("QLineEdit")){ | 855 | if(w->inherits("QLineEdit")){ |
856 | QPalette pal = w->palette(); | 856 | QPalette pal = w->palette(); |
857 | pal.setBrush(QColorGroup::Base, baseBrush); | 857 | pal.setBrush(QColorGroup::Base, baseBrush); |
858 | w->setPalette(pal); | 858 | w->setPalette(pal); |
859 | } | 859 | } |
860 | if(w->inherits("QPushButton")){ | 860 | if(w->inherits("QPushButton")){ |
861 | applyCustomAttributes((QPushButton *)w); | 861 | applyCustomAttributes((QPushButton *)w); |
862 | w->installEventFilter(this); | 862 | w->installEventFilter(this); |
863 | } | 863 | } |
864 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ | 864 | if(w->inherits("QButton") || w-> inherits("QComboBox")){ |
865 | w-> setBackgroundMode ( QWidget::PaletteBackground ); | 865 | w-> setBackgroundMode ( QWidget::PaletteBackground ); |
866 | } | 866 | } |
867 | 867 | ||
868 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || | 868 | bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 || |
869 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; | 869 | qstrcmp(w->name(), "qt_clipped_viewport") == 0; |
870 | bool isViewportChild = w->parent() && | 870 | bool isViewportChild = w->parent() && |
871 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 871 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
872 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 872 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
873 | 873 | ||
874 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ | 874 | if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){ |
875 | w->setBackgroundMode(QWidget::X11ParentRelative); | 875 | w->setBackgroundMode(QWidget::X11ParentRelative); |
876 | return; | 876 | return; |
877 | } | 877 | } |
878 | if(isViewportChild){ | 878 | if(isViewportChild){ |
879 | if(w->inherits("QButton") || w->inherits("QComboBox")){ | 879 | if(w->inherits("QButton") || w->inherits("QComboBox")){ |
880 | if(w->parent()){ // heh, only way to test for KHTML children ;-) | 880 | if(w->parent()){ // heh, only way to test for KHTML children ;-) |
881 | if(w->parent()->parent()){ | 881 | if(w->parent()->parent()){ |
882 | if(w->parent()->parent()->parent() && | 882 | if(w->parent()->parent()->parent() && |
883 | w->parent()->parent()->parent()->inherits("KHTMLView")){ | 883 | w->parent()->parent()->parent()->inherits("KHTMLView")){ |
884 | w->setAutoMask(true); | 884 | w->setAutoMask(true); |
885 | w->setBackgroundMode(QWidget::NoBackground); | 885 | w->setBackgroundMode(QWidget::NoBackground); |
886 | } | 886 | } |
887 | } | 887 | } |
888 | } | 888 | } |
889 | return; | 889 | return; |
890 | } | 890 | } |
891 | } | 891 | } |
892 | if(w->inherits("QHeader")){ | 892 | if(w->inherits("QHeader")){ |
893 | w->setMouseTracking(true); | 893 | w->setMouseTracking(true); |
894 | w->installEventFilter(this); | 894 | w->installEventFilter(this); |
895 | } | 895 | } |
896 | if(w-> inherits("QToolButton")) { | 896 | if(w-> inherits("QToolButton")) { |
897 | ((QToolButton*)w)->setAutoRaise (false); | 897 | ((QToolButton*)w)->setAutoRaise (false); |
898 | } | 898 | } |
899 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ | 899 | if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){ |
900 | return; | 900 | return; |
901 | } | 901 | } |
902 | 902 | ||
903 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> | 903 | if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())-> |
904 | palette().active().brush(QColorGroup::Background).pixmap()){ | 904 | palette().active().brush(QColorGroup::Background).pixmap()){ |
905 | qWarning("No parent pixmap for child widget %s", w->className()); | 905 | qWarning("No parent pixmap for child widget %s", w->className()); |
906 | return; | 906 | return; |
907 | } | 907 | } |
908 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && | 908 | if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) && |
909 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { | 909 | !( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) { |
910 | if(w->backgroundMode() == QWidget::PaletteBackground || | 910 | if(w->backgroundMode() == QWidget::PaletteBackground || |
911 | w->backgroundMode() == QWidget::PaletteButton){ | 911 | w->backgroundMode() == QWidget::PaletteButton){ |
912 | w->setBackgroundMode(QWidget::X11ParentRelative); | 912 | w->setBackgroundMode(QWidget::X11ParentRelative); |
913 | } | 913 | } |
914 | } | 914 | } |
915 | if(w->inherits("QToolBar")){ | 915 | if(w->inherits("QToolBar")){ |
916 | w->installEventFilter(this); | 916 | w->installEventFilter(this); |
917 | w->setBackgroundMode(QWidget::PaletteBackground); | 917 | w->setBackgroundMode(QWidget::PaletteBackground); |
918 | return; | 918 | return; |
919 | } | 919 | } |
920 | 920 | ||
921 | } | 921 | } |
922 | 922 | ||
923 | void LiquidStyle::unPolish(QWidget *w) | 923 | void LiquidStyle::unPolish(QWidget *w) |
924 | { | 924 | { |
925 | if(w->inherits("QMenuBar")){ | 925 | if(w->inherits("QMenuBar")){ |
926 | ((QFrame *)w)->setLineWidth(1); | 926 | ((QFrame *)w)->setLineWidth(1); |
927 | w->setBackgroundMode(QWidget::PaletteBackground); | 927 | w->setBackgroundMode(QWidget::PaletteBackground); |
928 | return; | 928 | return; |
929 | } | 929 | } |
930 | 930 | ||
931 | if(w->inherits("QPopupMenu")) | 931 | if(w->inherits("QPopupMenu")) |
932 | w->setBackgroundMode(QWidget::PaletteButton); | 932 | w->setBackgroundMode(QWidget::PaletteButton); |
933 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { | 933 | else if(w-> testWFlags(Qt::WType_Popup) && !w->inherits("QListBox")) { |
934 | w->removeEventFilter(menuHandler); | 934 | w->removeEventFilter(menuHandler); |
935 | } | 935 | } |
936 | 936 | ||
937 | if(w->isTopLevel()) | 937 | if(w->isTopLevel()) |
938 | return; | 938 | return; |
939 | 939 | ||
940 | // for viewport children, don't just check for NoBackground.... | 940 | // for viewport children, don't just check for NoBackground.... |
941 | bool isViewportChild = w->parent() && | 941 | bool isViewportChild = w->parent() && |
942 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || | 942 | ((qstrcmp(w->parent()->name(), "qt_viewport") == 0) || |
943 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); | 943 | (qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0)); |
944 | 944 | ||
diff --git a/noncore/styles/liquid/plugin.cpp b/noncore/styles/liquid/plugin.cpp index f149c29..5f4c8e5 100644 --- a/noncore/styles/liquid/plugin.cpp +++ b/noncore/styles/liquid/plugin.cpp | |||
@@ -16,96 +16,98 @@ QStyle *LiquidInterface::create ( ) | |||
16 | { | 16 | { |
17 | return new LiquidStyle ( ); | 17 | return new LiquidStyle ( ); |
18 | } | 18 | } |
19 | 19 | ||
20 | QString LiquidInterface::name ( ) | 20 | QString LiquidInterface::name ( ) |
21 | { | 21 | { |
22 | return QObject::tr( "Liquid", "name" ); | 22 | return QObject::tr( "Liquid", "name" ); |
23 | } | 23 | } |
24 | 24 | ||
25 | QString LiquidInterface::description ( ) | 25 | QString LiquidInterface::description ( ) |
26 | { | 26 | { |
27 | return QObject::tr( "High Performance Liquid style by Mosfet", "description" ); | 27 | return QObject::tr( "High Performance Liquid style by Mosfet", "description" ); |
28 | } | 28 | } |
29 | 29 | ||
30 | QCString LiquidInterface::key ( ) | 30 | QCString LiquidInterface::key ( ) |
31 | { | 31 | { |
32 | return QCString ( "liquid" ); | 32 | return QCString ( "liquid" ); |
33 | } | 33 | } |
34 | 34 | ||
35 | unsigned int LiquidInterface::version ( ) | 35 | unsigned int LiquidInterface::version ( ) |
36 | { | 36 | { |
37 | return 100; // 1.0.0 (\d+.\d.\d) | 37 | return 100; // 1.0.0 (\d+.\d.\d) |
38 | } | 38 | } |
39 | 39 | ||
40 | QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 40 | QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
41 | { | 41 | { |
42 | static LiquidSettingsInterface *setiface = 0; | 42 | static LiquidSettingsInterface *setiface = 0; |
43 | 43 | ||
44 | *iface = 0; | 44 | *iface = 0; |
45 | 45 | ||
46 | if ( uuid == IID_QUnknown ) | 46 | if ( uuid == IID_QUnknown ) |
47 | *iface = this; | 47 | *iface = this; |
48 | else if ( uuid == IID_Style ) | 48 | else if ( uuid == IID_Style ) |
49 | *iface = this; | 49 | *iface = this; |
50 | else if ( uuid == IID_StyleSettings ) { | 50 | else if ( uuid == IID_StyleSettings ) { |
51 | if ( !setiface ) | 51 | if ( !setiface ) |
52 | setiface = new LiquidSettingsInterface ( ); | 52 | setiface = new LiquidSettingsInterface ( ); |
53 | *iface = setiface; | 53 | *iface = setiface; |
54 | } | 54 | } |
55 | 55 | ||
56 | if ( *iface ) | 56 | if ( *iface ) |
57 | (*iface)-> addRef ( ); | 57 | (*iface)-> addRef ( ); |
58 | 58 | ||
59 | return QS_OK; | 59 | return QS_OK; |
60 | } | 60 | } |
61 | 61 | ||
62 | Q_EXPORT_INTERFACE() | 62 | Q_EXPORT_INTERFACE() |
63 | { | 63 | { |
64 | Q_CREATE_INSTANCE( LiquidInterface ) | 64 | Q_CREATE_INSTANCE( LiquidInterface ) |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | LiquidSettingsInterface::LiquidSettingsInterface ( ) : ref ( 0 ) | 68 | LiquidSettingsInterface::LiquidSettingsInterface ( ) : ref ( 0 ) |
69 | { | 69 | { |
70 | m_widget = 0; | 70 | m_widget = 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | LiquidSettingsInterface::~LiquidSettingsInterface ( ) | 73 | LiquidSettingsInterface::~LiquidSettingsInterface ( ) |
74 | { | 74 | { |
75 | } | 75 | } |
76 | 76 | ||
77 | QWidget *LiquidSettingsInterface::create ( QWidget *parent, const char *name ) | 77 | QWidget *LiquidSettingsInterface::create ( QWidget *parent, const char *name ) |
78 | { | 78 | { |
79 | m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); | 79 | m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" ); |
80 | 80 | ||
81 | return m_widget; | 81 | return m_widget; |
82 | } | 82 | } |
83 | 83 | ||
84 | bool LiquidSettingsInterface::accept ( ) | 84 | bool LiquidSettingsInterface::accept ( ) |
85 | { | 85 | { |
86 | if ( !m_widget ) | 86 | if ( !m_widget ) |
87 | return false; | 87 | return false; |
88 | 88 | ||
89 | return m_widget-> writeConfig ( ); | 89 | return m_widget-> writeConfig ( ); |
90 | } | 90 | } |
91 | 91 | ||
92 | void LiquidSettingsInterface::reject ( ) | 92 | void LiquidSettingsInterface::reject ( ) |
93 | { | 93 | { |
94 | } | 94 | } |
95 | 95 | ||
96 | QRESULT LiquidSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) | 96 | QRESULT LiquidSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) |
97 | { | 97 | { |
98 | *iface = 0; | 98 | *iface = 0; |
99 | 99 | ||
100 | 100 | ||
101 | if ( uuid == IID_QUnknown ) | 101 | if ( uuid == IID_QUnknown ) |
102 | *iface = this; | 102 | *iface = this; |
103 | else if ( uuid == IID_StyleSettings ) | 103 | else if ( uuid == IID_StyleSettings ) |
104 | *iface = this; | 104 | *iface = this; |
105 | 105 | ||
106 | if ( *iface ) | 106 | if ( *iface ) |
107 | (*iface)-> addRef ( ); | 107 | (*iface)-> addRef ( ); |
108 | 108 | ||
109 | return QS_OK; | 109 | return QS_OK; |
110 | } | 110 | } |
111 | 111 | ||
112 | // Hack for Retail Z experiments | ||
113 | extern "C" { QStyle *allocate ( ) { return new LiquidStyle ( ); } } | ||