summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/theme/ogfxeffect.cpp72
-rw-r--r--noncore/styles/theme/othemebase.cpp1985
2 files changed, 1033 insertions, 1024 deletions
diff --git a/noncore/styles/theme/ogfxeffect.cpp b/noncore/styles/theme/ogfxeffect.cpp
index 90b45fe..ab63c98 100644
--- a/noncore/styles/theme/ogfxeffect.cpp
+++ b/noncore/styles/theme/ogfxeffect.cpp
@@ -7,13 +7,17 @@
7 7
8// $Id$ 8// $Id$
9 9
10#include <qimage.h> 10#include "ogfxeffect.h"
11#include <qpainter.h>
12 11
12/* OPIE */
13#include <opie2/odebug.h>
13#include <qpe/qmath.h> 14#include <qpe/qmath.h>
14 15
15#include "ogfxeffect.h" 16/* QT */
17#include <qimage.h>
18#include <qpainter.h>
16 19
20/* STD */
17#include <cstdlib> 21#include <cstdlib>
18#include <cmath> 22#include <cmath>
19 23
@@ -25,27 +29,27 @@
25 29
26 30
27QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, 31QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca,
28 const QColor &cb, GradientType eff, int ncols) 32 const QColor &cb, GradientType eff, int ncols)
29{ 33{
30 if ( !pixmap. isNull ( )) { 34 if ( !pixmap. isNull ( )) {
31 QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); 35 QImage image = gradient(pixmap.size(), ca, cb, eff, ncols);
32 pixmap.convertFromImage(image); 36 pixmap.convertFromImage(image);
33 } 37 }
34 return pixmap; 38 return pixmap;
35} 39}
36 40
37QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, 41QImage OGfxEffect::gradient(const QSize &size, const QColor &ca,
38 const QColor &cb, GradientType eff, int /*ncols*/) 42 const QColor &cb, GradientType eff, int /*ncols*/)
39{ 43{
40 int rDiff, gDiff, bDiff; 44 int rDiff, gDiff, bDiff;
41 int rca, gca, bca, rcb, gcb, bcb; 45 int rca, gca, bca, rcb, gcb, bcb;
42
43 QImage image(size, 32);
44 46
45 if (size.width() == 0 || size.height() == 0) { 47 QImage image(size, 32);
46 qDebug ( "WARNING: OGfxEffect::gradient: invalid image" ); 48
47 return image; 49 if (size.width() == 0 || size.height() == 0) {
48 } 50 odebug << "WARNING: OGfxEffect::gradient: invalid image" << oendl;
51 return image;
52 }
49 53
50 register int x, y; 54 register int x, y;
51 55
@@ -278,19 +282,19 @@ QImage OGfxEffect::gradient(const QSize &size, const QColor &ca,
278 282
279 283
280QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, 284QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity,
281 const QColor &bgnd, GradientType eff, 285 const QColor &bgnd, GradientType eff,
282 bool anti_dir, int /*ncols*/) 286 bool anti_dir, int /*ncols*/)
283{ 287{
284 if ( !pixmap. isNull ( )) { 288 if ( !pixmap. isNull ( )) {
285 QImage image = pixmap.convertToImage(); 289 QImage image = pixmap.convertToImage();
286 OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); 290 OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir);
287 291
288 if ( pixmap. depth ( ) <= 8 ) 292 if ( pixmap. depth ( ) <= 8 )
289 image. convertDepth ( pixmap. depth ( )); 293 image. convertDepth ( pixmap. depth ( ));
290 294
291 pixmap.convertFromImage(image); 295 pixmap.convertFromImage(image);
292 } 296 }
293 return pixmap; 297 return pixmap;
294} 298}
295 299
296 300
@@ -299,7 +303,7 @@ QImage& OGfxEffect::blend(QImage &image, float initial_intensity,
299 bool anti_dir) 303 bool anti_dir)
300{ 304{
301 if (image.width() == 0 || image.height() == 0) { 305 if (image.width() == 0 || image.height() == 0) {
302 qDebug ( "Invalid image\n" ); 306 odebug << "Invalid image" << oendl;
303 return image; 307 return image;
304 } 308 }
305 309
@@ -484,8 +488,8 @@ QImage& OGfxEffect::blend(QImage &image, float initial_intensity,
484 } 488 }
485 } 489 }
486 490
487 else 491 else
488 qDebug ( "not implemented\n" ); 492 odebug << "not implemented" << oendl;
489 493
490 return image; 494 return image;
491} 495}
@@ -494,7 +498,7 @@ QImage& OGfxEffect::blend(QImage &image, float initial_intensity,
494// Not very efficient as we create a third big image... 498// Not very efficient as we create a third big image...
495// 499//
496QImage& KQGfxEffect::blend(QImage &image1, QImage &image2, 500QImage& KQGfxEffect::blend(QImage &image1, QImage &image2,
497 GradientType gt, int xf, int yf) 501 GradientType gt, int xf, int yf)
498{ 502{
499 if (image1.width() == 0 || image1.height() == 0 || 503 if (image1.width() == 0 || image1.height() == 0 ||
500 image2.width() == 0 || image2.height() == 0) 504 image2.width() == 0 || image2.height() == 0)
@@ -503,8 +507,8 @@ QImage& KQGfxEffect::blend(QImage &image1, QImage &image2,
503 QImage image3; 507 QImage image3;
504 508
505 image3 = KQGfxEffect::unbalancedGradient(image1.size(), 509 image3 = KQGfxEffect::unbalancedGradient(image1.size(),
506 QColor(0,0,0), QColor(255,255,255), 510 QColor(0,0,0), QColor(255,255,255),
507 gt, xf, yf, 0); 511 gt, xf, yf, 0);
508 512
509 return blend(image1,image2,image3, Red); // Channel to use is arbitrary 513 return blend(image1,image2,image3, Red); // Channel to use is arbitrary
510} 514}
diff --git a/noncore/styles/theme/othemebase.cpp b/noncore/styles/theme/othemebase.cpp
index 7ce4e5a..d2226e6 100644
--- a/noncore/styles/theme/othemebase.cpp
+++ b/noncore/styles/theme/othemebase.cpp
@@ -21,7 +21,7 @@
21 21
22/* OPIE */ 22/* OPIE */
23#include <opie2/odebug.h> 23#include <opie2/odebug.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26using namespace Opie::Core; 26using namespace Opie::Core;
27 27
@@ -67,779 +67,781 @@ static const char *widgetEntries[] =
67struct kthemeKeyData 67struct kthemeKeyData
68{ 68{
69unsigned int id : 69unsigned int id :
70 6; 70 6;
71unsigned int width : 71unsigned int width :
72 12; 72 12;
73unsigned int height : 73unsigned int height :
74 12; 74 12;
75unsigned int border : 75unsigned int border :
76 1; 76 1;
77unsigned int mask : 77unsigned int mask :
78 1; 78 1;
79}; 79};
80 80
81union kthemeKey{ 81union kthemeKey{
82 kthemeKeyData data; 82 kthemeKeyData data;
83 unsigned int cacheKey; 83 unsigned int cacheKey;
84}; 84};
85 85
86 86
87void OThemeBase::generateBorderPix( int i ) 87void OThemeBase::generateBorderPix( int i )
88{ 88{
89 // separate pixmap into separate components 89 // separate pixmap into separate components
90 if ( pbPixmaps[ i ] ) { 90 if ( pbPixmaps[ i ] ) {
91 // evidently I have to do masks manually... 91 // evidently I have to do masks manually...
92 const QBitmap * srcMask = pbPixmaps[ i ] ->mask(); 92 const QBitmap * srcMask = pbPixmaps[ i ] ->mask();
93 QBitmap destMask( pbWidth[ i ], pbWidth[ i ] ); 93 QBitmap destMask( pbWidth[ i ], pbWidth[ i ] );
94 QPixmap tmp( pbWidth[ i ], pbWidth[ i ] ); 94 QPixmap tmp( pbWidth[ i ], pbWidth[ i ] );
95 95
96 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], 0, 0, pbWidth[ i ], pbWidth[ i ], 96 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], 0, 0, pbWidth[ i ], pbWidth[ i ],
97 Qt::CopyROP, false ); 97 Qt::CopyROP, false );
98 if ( srcMask ) { 98 if ( srcMask ) {
99 bitBlt( &destMask, 0, 0, srcMask, 0, 0, pbWidth[ i ], pbWidth[ i ], 99 bitBlt( &destMask, 0, 0, srcMask, 0, 0, pbWidth[ i ], pbWidth[ i ],
100 Qt::CopyROP, false ); 100 Qt::CopyROP, false );
101 tmp.setMask( destMask ); 101 tmp.setMask( destMask );
102 } 102 }
103 pbPixmaps[ i ] ->setBorder( OThemePixmap::TopLeft, tmp ); 103 pbPixmaps[ i ] ->setBorder( OThemePixmap::TopLeft, tmp );
104 104
105 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbPixmaps[ i ] ->width() - pbWidth[ i ], 0, 105 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbPixmaps[ i ] ->width() - pbWidth[ i ], 0,
106 pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false ); 106 pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false );
107 if ( srcMask ) { 107 if ( srcMask ) {
108 bitBlt( &destMask, 0, 0, srcMask, pbPixmaps[ i ] ->width() - pbWidth[ i ], 108 bitBlt( &destMask, 0, 0, srcMask, pbPixmaps[ i ] ->width() - pbWidth[ i ],
109 0, pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false ); 109 0, pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false );
110 tmp.setMask( destMask ); 110 tmp.setMask( destMask );
111 } 111 }
112 pbPixmaps[ i ] ->setBorder( OThemePixmap::TopRight, tmp ); 112 pbPixmaps[ i ] ->setBorder( OThemePixmap::TopRight, tmp );
113 113
114 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], 0, pbPixmaps[ i ] ->height() - pbWidth[ i ], 114 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], 0, pbPixmaps[ i ] ->height() - pbWidth[ i ],
115 pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false ); 115 pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false );
116 if ( srcMask ) { 116 if ( srcMask ) {
117 bitBlt( &destMask, 0, 0, srcMask, 0, pbPixmaps[ i ] ->height() - pbWidth[ i ], 117 bitBlt( &destMask, 0, 0, srcMask, 0, pbPixmaps[ i ] ->height() - pbWidth[ i ],
118 pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false ); 118 pbWidth[ i ], pbWidth[ i ], Qt::CopyROP, false );
119 tmp.setMask( destMask ); 119 tmp.setMask( destMask );
120 } 120 }
121 pbPixmaps[ i ] ->setBorder( OThemePixmap::BottomLeft, tmp ); 121 pbPixmaps[ i ] ->setBorder( OThemePixmap::BottomLeft, tmp );
122 122
123 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbPixmaps[ i ] ->width() - pbWidth[ i ], 123 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbPixmaps[ i ] ->width() - pbWidth[ i ],
124 pbPixmaps[ i ] ->height() - pbWidth[ i ], pbWidth[ i ], pbWidth[ i ], 124 pbPixmaps[ i ] ->height() - pbWidth[ i ], pbWidth[ i ], pbWidth[ i ],
125 Qt::CopyROP, false ); 125 Qt::CopyROP, false );
126 if ( srcMask ) { 126 if ( srcMask ) {
127 bitBlt( &destMask, 0, 0, srcMask, pbPixmaps[ i ] ->width() - pbWidth[ i ], 127 bitBlt( &destMask, 0, 0, srcMask, pbPixmaps[ i ] ->width() - pbWidth[ i ],
128 pbPixmaps[ i ] ->height() - pbWidth[ i ], pbWidth[ i ], pbWidth[ i ], 128 pbPixmaps[ i ] ->height() - pbWidth[ i ], pbWidth[ i ], pbWidth[ i ],
129 Qt::CopyROP, false ); 129 Qt::CopyROP, false );
130 tmp.setMask( destMask ); 130 tmp.setMask( destMask );
131 } 131 }
132 pbPixmaps[ i ] ->setBorder( OThemePixmap::BottomRight, tmp ); 132 pbPixmaps[ i ] ->setBorder( OThemePixmap::BottomRight, tmp );
133 133
134 tmp.resize( pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ] ); 134 tmp.resize( pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ] );
135 destMask.resize( pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ] ); 135 destMask.resize( pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ] );
136 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbWidth[ i ], 0, 136 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbWidth[ i ], 0,
137 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ], Qt::CopyROP, false ); 137 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ], Qt::CopyROP, false );
138 if ( srcMask ) { 138 if ( srcMask ) {
139 bitBlt( &destMask, 0, 0, srcMask, pbWidth[ i ], 0, 139 bitBlt( &destMask, 0, 0, srcMask, pbWidth[ i ], 0,
140 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ], 140 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ],
141 Qt::CopyROP, false ); 141 Qt::CopyROP, false );
142 tmp.setMask( destMask ); 142 tmp.setMask( destMask );
143 } 143 }
144 pbPixmaps[ i ] ->setBorder( OThemePixmap::Top, tmp ); 144 pbPixmaps[ i ] ->setBorder( OThemePixmap::Top, tmp );
145 145
146 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbWidth[ i ], 146 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbWidth[ i ],
147 pbPixmaps[ i ] ->height() - pbWidth[ i ], 147 pbPixmaps[ i ] ->height() - pbWidth[ i ],
148 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ], Qt::CopyROP, false ); 148 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ], Qt::CopyROP, false );
149 if ( srcMask ) { 149 if ( srcMask ) {
150 bitBlt( &destMask, 0, 0, srcMask, pbWidth[ i ], 150 bitBlt( &destMask, 0, 0, srcMask, pbWidth[ i ],
151 pbPixmaps[ i ] ->height() - pbWidth[ i ], 151 pbPixmaps[ i ] ->height() - pbWidth[ i ],
152 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ], Qt::CopyROP, false ); 152 pbPixmaps[ i ] ->width() - pbWidth[ i ] * 2, pbWidth[ i ], Qt::CopyROP, false );
153 tmp.setMask( destMask ); 153 tmp.setMask( destMask );
154 } 154 }
155 pbPixmaps[ i ] ->setBorder( OThemePixmap::Bottom, tmp ); 155 pbPixmaps[ i ] ->setBorder( OThemePixmap::Bottom, tmp );
156 156
157 tmp.resize( pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2 ); 157 tmp.resize( pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2 );
158 destMask.resize( pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2 ); 158 destMask.resize( pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2 );
159 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], 0, pbWidth[ i ], pbWidth[ i ], 159 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], 0, pbWidth[ i ], pbWidth[ i ],
160 pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2, Qt::CopyROP, false ); 160 pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2, Qt::CopyROP, false );
161 if ( srcMask ) { 161 if ( srcMask ) {
162 bitBlt( &destMask, 0, 0, srcMask, 0, pbWidth[ i ], pbWidth[ i ], 162 bitBlt( &destMask, 0, 0, srcMask, 0, pbWidth[ i ], pbWidth[ i ],
163 pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2, Qt::CopyROP, false ); 163 pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2, Qt::CopyROP, false );
164 tmp.setMask( destMask ); 164 tmp.setMask( destMask );
165 } 165 }
166 166
167 pbPixmaps[ i ] ->setBorder( OThemePixmap::Left, tmp ); 167 pbPixmaps[ i ] ->setBorder( OThemePixmap::Left, tmp );
168 168
169 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbPixmaps[ i ] ->width() - pbWidth[ i ], 169 bitBlt( &tmp, 0, 0, pbPixmaps[ i ], pbPixmaps[ i ] ->width() - pbWidth[ i ],
170 pbWidth[ i ], pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2, 170 pbWidth[ i ], pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2,
171 Qt::CopyROP, false ); 171 Qt::CopyROP, false );
172 if ( srcMask ) { 172 if ( srcMask ) {
173 bitBlt( &destMask, 0, 0, srcMask, pbPixmaps[ i ] ->width() - pbWidth[ i ], 173 bitBlt( &destMask, 0, 0, srcMask, pbPixmaps[ i ] ->width() - pbWidth[ i ],
174 pbWidth[ i ], pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2, 174 pbWidth[ i ], pbWidth[ i ], pbPixmaps[ i ] ->height() - pbWidth[ i ] * 2,
175 Qt::CopyROP, false ); 175 Qt::CopyROP, false );
176 tmp.setMask( destMask ); 176 tmp.setMask( destMask );
177 } 177 }
178 pbPixmaps[ i ] ->setBorder( OThemePixmap::Right, tmp ); 178 pbPixmaps[ i ] ->setBorder( OThemePixmap::Right, tmp );
179 } 179 }
180 else 180 else
181 qDebug ( "OThemeBase: Tried making border from empty pixmap" ); 181 odebug << "OThemeBase: Tried making border from empty pixmap" << oendl;
182} 182}
183 183
184 184
185void OThemeBase::copyWidgetConfig( int sourceID, int destID, QString *pixnames, 185void OThemeBase::copyWidgetConfig( int sourceID, int destID, QString *pixnames,
186 QString *brdnames ) 186 QString *brdnames )
187{ 187{
188 scaleHints[ destID ] = scaleHints[ sourceID ]; 188 scaleHints[ destID ] = scaleHints[ sourceID ];
189 gradients[ destID ] = gradients[ sourceID ]; 189 gradients[ destID ] = gradients[ sourceID ];
190 blends[ destID ] = blends[ sourceID ]; 190 blends[ destID ] = blends[ sourceID ];
191 bContrasts[ destID ] = bContrasts[ sourceID ]; 191 bContrasts[ destID ] = bContrasts[ sourceID ];
192 borders[ destID ] = borders[ sourceID ]; 192 borders[ destID ] = borders[ sourceID ];
193 highlights[ destID ] = highlights[ sourceID ]; 193 highlights[ destID ] = highlights[ sourceID ];
194 194
195 if ( grLowColors[ sourceID ] ) 195 if ( grLowColors[ sourceID ] )
196 grLowColors[ destID ] = new QColor( *grLowColors[ sourceID ] ); 196 grLowColors[ destID ] = new QColor( *grLowColors[ sourceID ] );
197 else 197 else
198 grLowColors[ destID ] = NULL; 198 grLowColors[ destID ] = NULL;
199 199
200 if ( grHighColors[ sourceID ] ) 200 if ( grHighColors[ sourceID ] )
201 grHighColors[ destID ] = new QColor( *grHighColors[ sourceID ] ); 201 grHighColors[ destID ] = new QColor( *grHighColors[ sourceID ] );
202 else 202 else
203 grHighColors[ destID ] = NULL; 203 grHighColors[ destID ] = NULL;
204 204
205 if ( colors[ sourceID ] ) 205 if ( colors[ sourceID ] )
206 colors[ destID ] = new QColorGroup( *colors[ sourceID ] ); 206 colors[ destID ] = new QColorGroup( *colors[ sourceID ] );
207 else 207 else
208 colors[ destID ] = NULL; 208 colors[ destID ] = NULL;
209 209
210 // pixmap 210 // pixmap
211 pixnames[ destID ] = pixnames[ sourceID ]; 211 pixnames[ destID ] = pixnames[ sourceID ];
212 duplicate[ destID ] = false; 212 duplicate[ destID ] = false;
213 pixmaps[ destID ] = NULL; 213 pixmaps[ destID ] = NULL;
214 images[ destID ] = NULL; 214 images[ destID ] = NULL;
215 if ( !pixnames[ destID ].isEmpty() ) { 215 if ( !pixnames[ destID ].isEmpty() ) {
216 if ( scaleHints[ sourceID ] == TileScale && blends[ sourceID ] == 0.0 ) { 216 if ( scaleHints[ sourceID ] == TileScale && blends[ sourceID ] == 0.0 ) {
217 pixmaps[ destID ] = pixmaps[ sourceID ]; 217 pixmaps[ destID ] = pixmaps[ sourceID ];
218 duplicate[ destID ] = true; 218 duplicate[ destID ] = true;
219 } 219 }
220 if ( !duplicate[ destID ] ) { 220 if ( !duplicate[ destID ] ) {
221 pixmaps[ destID ] = loadPixmap( pixnames[ destID ] ); 221 pixmaps[ destID ] = loadPixmap( pixnames[ destID ] );
222 if ( scaleHints[ destID ] == TileScale && blends[ destID ] == 0.0 ) 222 if ( scaleHints[ destID ] == TileScale && blends[ destID ] == 0.0 )
223 images[ destID ] = NULL; 223 images[ destID ] = NULL;
224 else 224 else
225 images[ destID ] = loadImage( pixnames[ destID ] ); 225 images[ destID ] = loadImage( pixnames[ destID ] );
226 } 226 }
227 } 227 }
228 228
229 // border pixmap 229 // border pixmap
230 pbDuplicate[ destID ] = false; 230 pbDuplicate[ destID ] = false;
231 pbPixmaps[ destID ] = NULL; 231 pbPixmaps[ destID ] = NULL;
232 pbWidth[ destID ] = pbWidth[ sourceID ]; 232 pbWidth[ destID ] = pbWidth[ sourceID ];
233 brdnames[ destID ] = brdnames[ sourceID ]; 233 brdnames[ destID ] = brdnames[ sourceID ];
234 if ( !brdnames[ destID ].isEmpty() ) { 234 if ( !brdnames[ destID ].isEmpty() ) {
235 pbPixmaps[ destID ] = pbPixmaps[ sourceID ]; 235 pbPixmaps[ destID ] = pbPixmaps[ sourceID ];
236 pbDuplicate[ destID ] = true; 236 pbDuplicate[ destID ] = true;
237 } 237 }
238 238
239 if ( sourceID == ActiveTab && destID == InactiveTab ) 239 if ( sourceID == ActiveTab && destID == InactiveTab )
240 aTabLine = iTabLine; 240 aTabLine = iTabLine;
241 else if ( sourceID == InactiveTab && destID == ActiveTab ) 241 else if ( sourceID == InactiveTab && destID == ActiveTab )
242 iTabLine = aTabLine; 242 iTabLine = aTabLine;
243} 243}
244 244
245void OThemeBase::readConfig( Qt::GUIStyle /*style*/ ) 245void OThemeBase::readConfig( Qt::GUIStyle /*style*/ )
246{ 246{
247#define PREBLEND_ITEMS 12 247#define PREBLEND_ITEMS 12
248 static WidgetType preBlend[] = {Slider, IndicatorOn, IndicatorOff, 248 static WidgetType preBlend[] = {Slider, IndicatorOn, IndicatorOff,
249 ExIndicatorOn, ExIndicatorOff, HScrollDeco, VScrollDeco, HScrollDecoDown, 249 ExIndicatorOn, ExIndicatorOff, HScrollDeco, VScrollDeco, HScrollDecoDown,
250 VScrollDecoDown, ComboDeco, ComboDecoDown, CheckMark}; 250 VScrollDecoDown, ComboDeco, ComboDecoDown, CheckMark};
251 251
252 int i; 252 int i;
253 QString tmpStr; 253 QString tmpStr;
254 QString copyfrom[ WIDGETS ]; 254 QString copyfrom[ WIDGETS ];
255 QString pixnames[ WIDGETS ]; // used for duplicate check 255 QString pixnames[ WIDGETS ]; // used for duplicate check
256 QString brdnames[ WIDGETS ]; 256 QString brdnames[ WIDGETS ];
257 bool loaded[ WIDGETS ]; // used for preloading for CopyWidget 257 bool loaded[ WIDGETS ]; // used for preloading for CopyWidget
258 258
259 if ( configFileName.isEmpty() ) { 259 if ( configFileName.isEmpty() ) {
260 Config cfg ( "qpe" ); 260 Config cfg ( "qpe" );
261 cfg. setGroup ( "Appearance" ); 261 cfg. setGroup ( "Appearance" );
262 262
263 configFileName = cfg. readEntry ( "Theme", "default" ); 263 configFileName = cfg. readEntry ( "Theme", "default" );
264 } 264 }
265 Config config( configFilePath + "/themes/" + configFileName + ".themerc" , Config::File ); 265 Config config( configFilePath + "/themes/" + configFileName + ".themerc" , Config::File );
266 266
267 // Are we initalized? 267 // Are we initalized?
268 applyMiscResourceGroup( &config ); 268 applyMiscResourceGroup( &config );
269 for ( i = 0; i < INHERIT_ITEMS; ++i ) { 269 for ( i = 0; i < INHERIT_ITEMS; ++i ) {
270 applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); 270 applyResourceGroup( &config, i, copyfrom, pixnames, brdnames );
271 } 271 }
272 for ( ; i < INHERIT_ITEMS*2; ++i ) { 272 for ( ; i < INHERIT_ITEMS*2; ++i ) {
273 if ( config.hasGroup( QString( widgetEntries[ i ] ) ) ) { 273 if ( config.hasGroup( QString( widgetEntries[ i ] ) ) ) {
274 applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); 274 applyResourceGroup( &config, i, copyfrom, pixnames, brdnames );
275 } 275 }
276 else { 276 else {
277 copyfrom [ i ] = widgetEntries[ i - INHERIT_ITEMS ]; 277 copyfrom [ i ] = widgetEntries[ i - INHERIT_ITEMS ];
278 } 278 }
279 } 279 }
280 for ( ; i < WIDGETS; ++i ) { 280 for ( ; i < WIDGETS; ++i ) {
281 applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); 281 applyResourceGroup( &config, i, copyfrom, pixnames, brdnames );
282 } 282 }
283 283
284 // initalize defaults that may not be read 284 // initalize defaults that may not be read
285 for ( i = 0; i < WIDGETS; ++i ) 285 for ( i = 0; i < WIDGETS; ++i )
286 loaded[ i ] = false; 286 loaded[ i ] = false;
287 btnXShift = btnYShift = focus3DOffset = 0; 287 btnXShift = btnYShift = focus3DOffset = 0;
288 aTabLine = iTabLine = true; 288 aTabLine = iTabLine = true;
289 roundedButton = roundedCombo = roundedSlider = focus3D = false; 289 roundedButton = roundedCombo = roundedSlider = focus3D = false;
290 splitterWidth = 10; 290 splitterWidth = 10;
291 291
292 for ( i = 0; i < WIDGETS; ++i ) { 292 for ( i = 0; i < WIDGETS; ++i ) {
293 readResourceGroup( i, copyfrom, pixnames, brdnames, loaded ); 293 readResourceGroup( i, copyfrom, pixnames, brdnames, loaded );
294 } 294 }
295 295
296 // misc items 296 // misc items
297 readMiscResourceGroup(); 297 readMiscResourceGroup();
298 298
299 // Handle preblend items 299 // Handle preblend items
300 for ( i = 0; i < PREBLEND_ITEMS; ++i ) { 300 for ( i = 0; i < PREBLEND_ITEMS; ++i ) {
301 if ( pixmaps[ preBlend[ i ] ] != NULL && blends[ preBlend[ i ] ] != 0.0 ) 301 if ( pixmaps[ preBlend[ i ] ] != NULL && blends[ preBlend[ i ] ] != 0.0 )
302 blend( preBlend[ i ] ); 302 blend( preBlend[ i ] );
303 } 303 }
304} 304}
305 305
306OThemeBase::OThemeBase( const QString & configFile ) 306OThemeBase::OThemeBase( const QString & configFile )
307 : QWindowsStyle() 307 : QWindowsStyle()
308{ 308{
309 configFilePath = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 309 configFilePath = QPEApplication::qpeDir ( ) + "/plugins/styles/";
310 configFileName = configFile; 310 configFileName = configFile;
311 311
312 readConfig( Qt::WindowsStyle ); 312 readConfig( Qt::WindowsStyle );
313 cache = new OThemeCache( cacheSize ); 313 cache = new OThemeCache( cacheSize );
314} 314}
315 315
316void OThemeBase::applyConfigFile( const QString &/*file*/ ) 316void OThemeBase::applyConfigFile( const QString &/*file*/ )
317{ 317{
318#if 0 318#if 0
319 // handle std color scheme 319 // handle std color scheme
320 Config inConfig( file, Config::File ); 320 Config inConfig( file, Config::File );
321 Config globalConfig ( "qpe" ); 321 Config globalConfig ( "qpe" );
322 322
323 globalConfig. setGroup ( "Apperance" ); 323 globalConfig. setGroup ( "Apperance" );
324 inConfig. setGroup( "General" ); 324 inConfig. setGroup( "General" );
325 325
326 if ( inConfig.hasKey( "foreground" ) ) 326 if ( inConfig.hasKey( "foreground" ) )
327 globalConfig.writeEntry( "Text", inConfig.readEntry( "foreground", " " ) ); 327 globalConfig.writeEntry( "Text", inConfig.readEntry( "foreground", " " ) );
328 if ( inConfig.hasKey( "background" ) ) 328 if ( inConfig.hasKey( "background" ) )
329 globalConfig.writeEntry( "Background", inConfig.readEntry( "background", " " ) ); 329 globalConfig.writeEntry( "Background", inConfig.readEntry( "background", " " ) );
330 if ( inConfig.hasKey( "selectForeground" ) ) 330 if ( inConfig.hasKey( "selectForeground" ) )
331 globalConfig.writeEntry( "HighlightedText", inConfig.readEntry( "selectForeground", " " ) ); 331 globalConfig.writeEntry( "HighlightedText", inConfig.readEntry( "selectForeground", " " ) );
332 if ( inConfig.hasKey( "selectBackground" ) ) 332 if ( inConfig.hasKey( "selectBackground" ) )
333 globalConfig.writeEntry( "Highlight", inConfig.readEntry( "selectBackground", " " ) ); 333 globalConfig.writeEntry( "Highlight", inConfig.readEntry( "selectBackground", " " ) );
334 if ( inConfig.hasKey( "windowForeground" ) ) 334 if ( inConfig.hasKey( "windowForeground" ) )
335 globalConfig.writeEntry( "Text", inConfig.readEntry( "windowForeground", " " ) ); 335 globalConfig.writeEntry( "Text", inConfig.readEntry( "windowForeground", " " ) );
336 if ( inConfig.hasKey( "windowBackground" ) ) 336 if ( inConfig.hasKey( "windowBackground" ) )
337 globalConfig.writeEntry( "Base", inConfig.readEntry( "windowBackground", " " ) ); 337 globalConfig.writeEntry( "Base", inConfig.readEntry( "windowBackground", " " ) );
338 338
339 // Keep track of the current theme so that we can select the right one 339 // Keep track of the current theme so that we can select the right one
340 // in the KControl module. 340 // in the KControl module.
341 globalConfig.writeEntry ( "CurrentTheme", file ); 341 globalConfig.writeEntry ( "CurrentTheme", file );
342 342
343 globalConfig.write(); 343 globalConfig.write();
344#endif 344#endif
345} 345}
346 346
347OThemeBase::~OThemeBase() 347OThemeBase::~OThemeBase()
348{ 348{
349 int i; 349 int i;
350 for ( i = 0; i < WIDGETS; ++i ) { 350 for ( i = 0; i < WIDGETS; ++i ) {
351 if ( !duplicate[ i ] ) { 351 if ( !duplicate[ i ] ) {
352 if ( images[ i ] ) 352 if ( images[ i ] )
353 delete images[ i ]; 353 delete images[ i ];
354 if ( pixmaps[ i ] ) 354 if ( pixmaps[ i ] )
355 delete pixmaps[ i ]; 355 delete pixmaps[ i ];
356 } 356 }
357 if ( !pbDuplicate[ i ] && pbPixmaps[ i ] ) 357 if ( !pbDuplicate[ i ] && pbPixmaps[ i ] )
358 delete pbPixmaps[ i ]; 358 delete pbPixmaps[ i ];
359 if ( colors[ i ] ) 359 if ( colors[ i ] )
360 delete( colors[ i ] ); 360 delete( colors[ i ] );
361 if ( grLowColors[ i ] ) 361 if ( grLowColors[ i ] )
362 delete( grLowColors[ i ] ); 362 delete( grLowColors[ i ] );
363 if ( grHighColors[ i ] ) 363 if ( grHighColors[ i ] )
364 delete( grHighColors[ i ] ); 364 delete( grHighColors[ i ] );
365 } 365 }
366 delete cache; 366 delete cache;
367} 367}
368 368
369QImage* OThemeBase::loadImage( QString &name ) 369QImage* OThemeBase::loadImage( QString &name )
370{ 370{
371 QImage * image = new QImage; 371 QImage * image = new QImage;
372 QString path = configFilePath + "/pixmaps/" + name; 372 QString path = configFilePath + "/pixmaps/" + name;
373 image->load( path ); 373 image->load( path );
374 if ( !image->isNull() ) 374 if ( !image->isNull() )
375 return ( image ); 375 return ( image );
376 qDebug ( "OThemeBase: Unable to load image %s\n", name.ascii ( ) ); 376 odebug << "OThemeBase: Unable to load image " << name.ascii ( ) << oendl;
377 delete image; 377 delete image;
378 return ( NULL ); 378 return ( NULL );
379} 379}
380 380
381OThemePixmap* OThemeBase::loadPixmap( QString &name ) 381OThemePixmap* OThemeBase::loadPixmap( QString &name )
382{ 382{
383 OThemePixmap * pixmap = new OThemePixmap( false ); 383 OThemePixmap * pixmap = new OThemePixmap( false );
384 QString path = configFilePath + "/pixmaps/" + name; 384 QString path = configFilePath + "/pixmaps/" + name;
385 pixmap->load( path ); 385 pixmap->load( path );
386 if ( !pixmap->isNull() ) 386 if ( !pixmap->isNull() )
387 return pixmap; 387 return pixmap;
388 qDebug ( "OThemeBase: Unable to load pixmap %s\n", name.ascii() ); 388 odebug << "OThemeBase: Unable to load pixmap " << name.ascii() << oendl;
389 delete pixmap; 389 delete pixmap;
390 return ( NULL ); 390 return ( NULL );
391} 391}
392 392
393OThemePixmap* OThemeBase::scale( int w, int h, WidgetType widget ) 393OThemePixmap* OThemeBase::scale( int w, int h, WidgetType widget )
394{ 394{
395 if ( scaleHints[ widget ] == FullScale ) { 395 if ( scaleHints[ widget ] == FullScale ) {
396 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || 396 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ||
397 pixmaps[ widget ] ->height() != h ) { 397 pixmaps[ widget ] ->height() != h ) {
398 OThemePixmap * cachePix = cache->pixmap( w, h, widget ); 398 OThemePixmap * cachePix = cache->pixmap( w, h, widget );
399 if ( cachePix ) { 399 if ( cachePix ) {
400 cachePix = new OThemePixmap( *cachePix ); 400 cachePix = new OThemePixmap( *cachePix );
401 if ( pixmaps[ widget ] ) 401 if ( pixmaps[ widget ] )
402 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 402 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
403 widget ); 403 widget );
404 else 404 else
405 odebug << "We would have inserted a null pixmap!\n" << oendl; 405 odebug << "We would have inserted a null pixmap!\n" << oendl;
406 pixmaps[ widget ] = cachePix; 406 pixmaps[ widget ] = cachePix;
407 } 407 }
408 else { 408 else {
409 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, widget ); 409 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, widget );
410 QImage tmpImg = images[ widget ] ->smoothScale( w, h ); 410 QImage tmpImg = images[ widget ] ->smoothScale( w, h );
411 pixmaps[ widget ] = new OThemePixmap; 411 pixmaps[ widget ] = new OThemePixmap;
412 pixmaps[ widget ] ->convertFromImage( tmpImg ); 412 pixmaps[ widget ] ->convertFromImage( tmpImg );
413 if ( blends[ widget ] != 0.0 ) 413 if ( blends[ widget ] != 0.0 )
414 blend( widget ); 414 blend( widget );
415 } 415 }
416 } 416 }
417 } 417 }
418 else if ( scaleHints[ widget ] == HorizontalScale ) { 418 else if ( scaleHints[ widget ] == HorizontalScale ) {
419 if ( pixmaps[ widget ] ->width() != w ) { 419 if ( pixmaps[ widget ] ->width() != w ) {
420 OThemePixmap * cachePix = cache->horizontalPixmap( w, widget ); 420 OThemePixmap * cachePix = cache->horizontalPixmap( w, widget );
421 if ( cachePix ) { 421 if ( cachePix ) {
422 cachePix = new OThemePixmap( *cachePix ); 422 cachePix = new OThemePixmap( *cachePix );
423 if ( pixmaps[ widget ] ) 423 if ( pixmaps[ widget ] )
424 cache->insert( pixmaps[ widget ], OThemeCache::HorizontalScale, widget ); 424 cache->insert( pixmaps[ widget ], OThemeCache::HorizontalScale, widget );
425 else 425 else
426 qDebug ( "We would have inserted a null pixmap!\n" ); 426 odebug << "We would have inserted a null pixmap!" << oendl;
427 pixmaps[ widget ] = cachePix; 427 pixmaps[ widget ] = cachePix;
428 } 428 }
429 else { 429 else {
430 cache->insert( pixmaps[ widget ], OThemeCache::HorizontalScale, widget ); 430 cache->insert( pixmaps[ widget ], OThemeCache::HorizontalScale, widget );
431 QImage tmpImg = images[ widget ] -> 431 QImage tmpImg = images[ widget ] ->
432 smoothScale( w, images[ widget ] ->height() ); 432 smoothScale( w, images[ widget ] ->height() );
433 pixmaps[ widget ] = new OThemePixmap; 433 pixmaps[ widget ] = new OThemePixmap;
434 pixmaps[ widget ] ->convertFromImage( tmpImg ); 434 pixmaps[ widget ] ->convertFromImage( tmpImg );
435 if ( blends[ widget ] != 0.0 ) 435 if ( blends[ widget ] != 0.0 )
436 blend( widget ); 436 blend( widget );
437 } 437 }
438 } 438 }
439 } 439 }
440 else if ( scaleHints[ widget ] == VerticalScale ) { 440 else if ( scaleHints[ widget ] == VerticalScale ) {
441 if ( pixmaps[ widget ] ->height() != h ) { 441 if ( pixmaps[ widget ] ->height() != h ) {
442 OThemePixmap * cachePix = cache->verticalPixmap( w, widget ); 442 OThemePixmap * cachePix = cache->verticalPixmap( w, widget );
443 if ( cachePix ) { 443 if ( cachePix ) {
444 cachePix = new OThemePixmap( *cachePix ); 444 cachePix = new OThemePixmap( *cachePix );
445 if ( pixmaps[ widget ] ) 445 if ( pixmaps[ widget ] )
446 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, widget ); 446 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, widget );
447 else 447 else
448 qDebug ( "We would have inserted a null pixmap!\n" ); 448 odebug << "We would have inserted a null pixmap!" << oendl;
449 pixmaps[ widget ] = cachePix; 449 pixmaps[ widget ] = cachePix;
450 } 450 }
451 else { 451 else {
452 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, widget ); 452 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, widget );
453 QImage tmpImg = 453 QImage tmpImg =
454 images[ widget ] ->smoothScale( images[ widget ] ->width(), h ); 454 images[ widget ] ->smoothScale( images[ widget ] ->width(), h );
455 pixmaps[ widget ] = new OThemePixmap; 455 pixmaps[ widget ] = new OThemePixmap;
456 pixmaps[ widget ] ->convertFromImage( tmpImg ); 456 pixmaps[ widget ] ->convertFromImage( tmpImg );
457 if ( blends[ widget ] != 0.0 ) 457 if ( blends[ widget ] != 0.0 )
458 blend( widget ); 458 blend( widget );
459 } 459 }
460 } 460 }
461 } 461 }
462 // If blended tile here so the blend is scaled properly 462 // If blended tile here so the blend is scaled properly
463 else if ( scaleHints[ widget ] == TileScale && blends[ widget ] != 0.0 ) { 463 else if ( scaleHints[ widget ] == TileScale && blends[ widget ] != 0.0 ) {
464 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || 464 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ||
465 pixmaps[ widget ] ->height() != h ) { 465 pixmaps[ widget ] ->height() != h ) {
466 OThemePixmap * cachePix = cache->pixmap( w, h, widget ); 466 OThemePixmap * cachePix = cache->pixmap( w, h, widget );
467 if ( cachePix ) { 467 if ( cachePix ) {
468 cachePix = new OThemePixmap( *cachePix ); 468 cachePix = new OThemePixmap( *cachePix );
469 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, widget ); 469 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, widget );
470 pixmaps[ widget ] = cachePix; 470 pixmaps[ widget ] = cachePix;
471 } 471 }
472 else { 472 else {
473 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, widget ); 473 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, widget );
474 QPixmap tile; 474 QPixmap tile;
475 tile.convertFromImage( *images[ widget ] ); 475 tile.convertFromImage( *images[ widget ] );
476 pixmaps[ widget ] = new OThemePixmap; 476 pixmaps[ widget ] = new OThemePixmap;
477 pixmaps[ widget ] ->resize( w, h ); 477 pixmaps[ widget ] ->resize( w, h );
478 QPainter p( pixmaps[ widget ] ); 478 QPainter p( pixmaps[ widget ] );
479 p.drawTiledPixmap( 0, 0, w, h, tile ); 479 p.drawTiledPixmap( 0, 0, w, h, tile );
480 if ( blends[ widget ] != 0.0 ) 480 if ( blends[ widget ] != 0.0 )
481 blend( widget ); 481 blend( widget );
482 } 482 }
483 } 483 }
484 } 484 }
485 return ( pixmaps[ widget ] ); 485 return ( pixmaps[ widget ] );
486} 486}
487 487
488OThemePixmap* OThemeBase::scaleBorder( int w, int h, WidgetType widget ) 488OThemePixmap* OThemeBase::scaleBorder( int w, int h, WidgetType widget )
489{ 489{
490 OThemePixmap * pixmap = NULL; 490 OThemePixmap * pixmap = NULL;
491 if ( !pbPixmaps[ widget ] && !pbWidth[ widget ] ) 491 if ( !pbPixmaps[ widget ] && !pbWidth[ widget ] )
492 return ( NULL ); 492 return ( NULL );
493 pixmap = cache->pixmap( w, h, widget, true ); 493 pixmap = cache->pixmap( w, h, widget, true );
494 if ( pixmap ) { 494 if ( pixmap ) {
495 pixmap = new OThemePixmap( *pixmap ); 495 pixmap = new OThemePixmap( *pixmap );
496 } 496 }
497 else { 497 else {
498 pixmap = new OThemePixmap(); 498 pixmap = new OThemePixmap();
499 pixmap->resize( w, h ); 499 pixmap->resize( w, h );
500 QBitmap mask; 500 QBitmap mask;
501 mask.resize( w, h ); 501 mask.resize( w, h );
502 mask.fill( color0 ); 502 mask.fill( color0 );
503 QPainter mPainter; 503 QPainter mPainter;
504 mPainter.begin( &mask ); 504 mPainter.begin( &mask );
505 505
506 QPixmap *tmp = borderPixmap( widget ) ->border( OThemePixmap::TopLeft ); 506 QPixmap *tmp = borderPixmap( widget ) ->border( OThemePixmap::TopLeft );
507 const QBitmap *srcMask = tmp->mask(); 507 const QBitmap *srcMask = tmp->mask();
508 int bdWidth = tmp->width(); 508 int bdWidth = tmp->width();
509 509
510 bitBlt( pixmap, 0, 0, tmp, 0, 0, bdWidth, bdWidth, 510 bitBlt( pixmap, 0, 0, tmp, 0, 0, bdWidth, bdWidth,
511 Qt::CopyROP, false ); 511 Qt::CopyROP, false );
512 if ( srcMask ) 512 if ( srcMask )
513 bitBlt( &mask, 0, 0, srcMask, 0, 0, bdWidth, bdWidth, 513 bitBlt( &mask, 0, 0, srcMask, 0, 0, bdWidth, bdWidth,
514 Qt::CopyROP, false ); 514 Qt::CopyROP, false );
515 else 515 else
516 mPainter.fillRect( 0, 0, bdWidth, bdWidth, color1 ); 516 mPainter.fillRect( 0, 0, bdWidth, bdWidth, color1 );
517 517
518 518
519 tmp = borderPixmap( widget ) ->border( OThemePixmap::TopRight ); 519 tmp = borderPixmap( widget ) ->border( OThemePixmap::TopRight );
520 srcMask = tmp->mask(); 520 srcMask = tmp->mask();
521 bitBlt( pixmap, w - bdWidth, 0, tmp, 0, 0, bdWidth, 521 bitBlt( pixmap, w - bdWidth, 0, tmp, 0, 0, bdWidth,
522 bdWidth, Qt::CopyROP, false ); 522 bdWidth, Qt::CopyROP, false );
523 if ( srcMask ) 523 if ( srcMask )
524 bitBlt( &mask, w - bdWidth, 0, srcMask, 0, 0, bdWidth, 524 bitBlt( &mask, w - bdWidth, 0, srcMask, 0, 0, bdWidth,
525 bdWidth, Qt::CopyROP, false ); 525 bdWidth, Qt::CopyROP, false );
526 else 526 else
527 mPainter.fillRect( w - bdWidth, 0, bdWidth, bdWidth, color1 ); 527 mPainter.fillRect( w - bdWidth, 0, bdWidth, bdWidth, color1 );
528 528
529 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomLeft ); 529 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomLeft );
530 srcMask = tmp->mask(); 530 srcMask = tmp->mask();
531 bitBlt( pixmap, 0, h - bdWidth, tmp, 0, 0, bdWidth, 531 bitBlt( pixmap, 0, h - bdWidth, tmp, 0, 0, bdWidth,
532 bdWidth, Qt::CopyROP, false ); 532 bdWidth, Qt::CopyROP, false );
533 if ( srcMask ) 533 if ( srcMask )
534 bitBlt( &mask, 0, h - bdWidth, srcMask, 0, 0, bdWidth, 534 bitBlt( &mask, 0, h - bdWidth, srcMask, 0, 0, bdWidth,
535 bdWidth, Qt::CopyROP, false ); 535 bdWidth, Qt::CopyROP, false );
536 else 536 else
537 mPainter.fillRect( 0, h - bdWidth, bdWidth, bdWidth, color1 ); 537 mPainter.fillRect( 0, h - bdWidth, bdWidth, bdWidth, color1 );
538 538
539 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomRight ); 539 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomRight );
540 srcMask = tmp->mask(); 540 srcMask = tmp->mask();
541 bitBlt( pixmap, w - bdWidth, h - bdWidth, tmp, 0, 0, 541 bitBlt( pixmap, w - bdWidth, h - bdWidth, tmp, 0, 0,
542 bdWidth, bdWidth, Qt::CopyROP, false ); 542 bdWidth, bdWidth, Qt::CopyROP, false );
543 if ( srcMask ) 543 if ( srcMask )
544 bitBlt( &mask, w - bdWidth, h - bdWidth, srcMask, 0, 0, 544 bitBlt( &mask, w - bdWidth, h - bdWidth, srcMask, 0, 0,
545 bdWidth, bdWidth, Qt::CopyROP, false ); 545 bdWidth, bdWidth, Qt::CopyROP, false );
546 else 546 else
547 mPainter.fillRect( w - bdWidth, h - bdWidth, bdWidth, bdWidth, color1 ); 547 mPainter.fillRect( w - bdWidth, h - bdWidth, bdWidth, bdWidth, color1 );
548 548
549 QPainter p; 549 QPainter p;
550 p.begin( pixmap ); 550 p.begin( pixmap );
551 if ( w - bdWidth * 2 > 0 ) { 551 if ( w - bdWidth * 2 > 0 ) {
552 tmp = borderPixmap( widget ) ->border( OThemePixmap::Top ); 552 tmp = borderPixmap( widget ) ->border( OThemePixmap::Top );
553 srcMask = tmp->mask(); 553 srcMask = tmp->mask();
554 p.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *tmp ); 554 p.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *tmp );
555 if ( srcMask ) 555 if ( srcMask )
556 mPainter.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *srcMask ); 556 mPainter.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *srcMask );
557 else 557 else
558 mPainter.fillRect( bdWidth, 0, w - bdWidth * 2, bdWidth, color1 ); 558 mPainter.fillRect( bdWidth, 0, w - bdWidth * 2, bdWidth, color1 );
559 559
560 tmp = borderPixmap( widget ) ->border( OThemePixmap::Bottom ); 560 tmp = borderPixmap( widget ) ->border( OThemePixmap::Bottom );
561 srcMask = tmp->mask(); 561 srcMask = tmp->mask();
562 p.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, 562 p.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth,
563 *tmp ); 563 *tmp );
564 if ( srcMask ) 564 if ( srcMask )
565 mPainter.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, *srcMask ); 565 mPainter.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, *srcMask );
566 else 566 else
567 mPainter.fillRect( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, 567 mPainter.fillRect( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth,
568 color1 ); 568 color1 );
569 } 569 }
570 if ( h - bdWidth * 2 > 0 ) { 570 if ( h - bdWidth * 2 > 0 ) {
571 tmp = borderPixmap( widget ) ->border( OThemePixmap::Left ); 571 tmp = borderPixmap( widget ) ->border( OThemePixmap::Left );
572 srcMask = tmp->mask(); 572 srcMask = tmp->mask();
573 p.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *tmp ); 573 p.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *tmp );
574 if ( srcMask ) 574 if ( srcMask )
575 mPainter.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *srcMask ); 575 mPainter.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *srcMask );
576 else 576 else
577 mPainter.fillRect( 0, bdWidth, bdWidth, h - bdWidth * 2, color1 ); 577 mPainter.fillRect( 0, bdWidth, bdWidth, h - bdWidth * 2, color1 );
578 578
579 tmp = borderPixmap( widget ) ->border( OThemePixmap::Right ); 579 tmp = borderPixmap( widget ) ->border( OThemePixmap::Right );
580 srcMask = tmp->mask(); 580 srcMask = tmp->mask();
581 p.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, 581 p.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2,
582 *tmp ); 582 *tmp );
583 if ( srcMask ) 583 if ( srcMask )
584 mPainter.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, *srcMask ); 584 mPainter.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, *srcMask );
585 else 585 else
586 mPainter.fillRect( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, color1 ); 586 mPainter.fillRect( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, color1 );
587 } 587 }
588 p.end(); 588 p.end();
589 mPainter.end(); 589 mPainter.end();
590 pixmap->setMask( mask ); 590 pixmap->setMask( mask );
591 cache->insert( pixmap, OThemeCache::FullScale, widget, true ); 591 cache->insert( pixmap, OThemeCache::FullScale, widget, true );
592 if ( !pixmap->mask() ) 592 if ( !pixmap->mask() )
593 qDebug ( "No mask for border pixmap!\n" ); 593 odebug << "No mask for border pixmap!" << oendl;
594 } 594 }
595 return ( pixmap ); 595 return ( pixmap );
596} 596}
597 597
598 598
599OThemePixmap* OThemeBase::blend( WidgetType widget ) 599OThemePixmap* OThemeBase::blend( WidgetType widget )
600{ 600{
601 OGfxEffect::GradientType g; 601 OGfxEffect::GradientType g;
602 switch ( gradients[ widget ] ) { 602 switch ( gradients[ widget ] ) {
603 case GrHorizontal: 603 case GrHorizontal:
604 g = OGfxEffect::HorizontalGradient; 604 g = OGfxEffect::HorizontalGradient;
605 break; 605 break;
606 case GrVertical: 606 case GrVertical:
607 g = OGfxEffect::VerticalGradient; 607 g = OGfxEffect::VerticalGradient;
608 break; 608 break;
609 case GrPyramid: 609 case GrPyramid:
610 g = OGfxEffect::PyramidGradient; 610 g = OGfxEffect::PyramidGradient;
611 break; 611 break;
612 case GrRectangle: 612 case GrRectangle:
613 g = OGfxEffect::RectangleGradient; 613 g = OGfxEffect::RectangleGradient;
614 break; 614 break;
615 case GrElliptic: 615 case GrElliptic:
616 g = OGfxEffect::EllipticGradient; 616 g = OGfxEffect::EllipticGradient;
617 break; 617 break;
618 default: 618 default:
619 g = OGfxEffect::DiagonalGradient; 619 g = OGfxEffect::DiagonalGradient;
620 break; 620 break;
621 } 621 }
622 OGfxEffect::blend( *pixmaps[ widget ], blends[ widget ], *grLowColors[ widget ], 622 OGfxEffect::blend( *pixmaps[ widget ], blends[ widget ], *grLowColors[ widget ],
623 g, false ); 623 g, false );
624 return ( pixmaps[ widget ] ); 624 return ( pixmaps[ widget ] );
625} 625}
626 626
627OThemePixmap* OThemeBase::gradient( int w, int h, WidgetType widget ) 627OThemePixmap* OThemeBase::gradient( int w, int h, WidgetType widget )
628{ 628{
629 if ( gradients[ widget ] == GrVertical ) { 629 if ( gradients[ widget ] == GrVertical ) {
630 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->height() != h ) { 630 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->height() != h ) {
631 OThemePixmap * cachePix = cache->verticalPixmap( h, widget ); 631 OThemePixmap * cachePix = cache->verticalPixmap( h, widget );
632 if ( cachePix ) { 632 if ( cachePix ) {
633 cachePix = new OThemePixmap( *cachePix ); 633 cachePix = new OThemePixmap( *cachePix );
634 if ( pixmaps[ widget ] ) 634 if ( pixmaps[ widget ] )
635 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, 635 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale,
636 widget ); 636 widget );
637 pixmaps[ widget ] = cachePix; 637 pixmaps[ widget ] = cachePix;
638 } 638 }
639 else { 639 else {
640 if ( pixmaps[ widget ] ) 640 if ( pixmaps[ widget ] )
641 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, 641 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale,
642 widget ); 642 widget );
643 pixmaps[ widget ] = new OThemePixmap; 643 pixmaps[ widget ] = new OThemePixmap;
644 pixmaps[ widget ] ->resize( w, h ); 644 pixmaps[ widget ] ->resize( w, h );
645 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ], 645 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ],
646 *grLowColors[ widget ], 646 *grLowColors[ widget ],
647 OGfxEffect::VerticalGradient ); 647 OGfxEffect::VerticalGradient );
648 } 648 }
649 } 649 }
650 } 650 }
651 else if ( gradients[ widget ] == GrHorizontal ) { 651 else if ( gradients[ widget ] == GrHorizontal ) {
652 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ) { 652 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ) {
653 OThemePixmap * cachePix = cache->horizontalPixmap( w, widget ); 653 OThemePixmap * cachePix = cache->horizontalPixmap( w, widget );
654 if ( cachePix ) { 654 if ( cachePix ) {
655 cachePix = new OThemePixmap( *cachePix ); 655 cachePix = new OThemePixmap( *cachePix );
656 if ( pixmaps[ widget ] ) 656 if ( pixmaps[ widget ] )
657 cache->insert( pixmaps[ widget ], 657 cache->insert( pixmaps[ widget ],
658 OThemeCache::HorizontalScale, widget ); 658 OThemeCache::HorizontalScale, widget );
659 pixmaps[ widget ] = cachePix; 659 pixmaps[ widget ] = cachePix;
660 } 660 }
661 else { 661 else {
662 if ( pixmaps[ widget ] ) 662 if ( pixmaps[ widget ] )
663 cache->insert( pixmaps[ widget ], 663 cache->insert( pixmaps[ widget ],
664 OThemeCache::HorizontalScale, widget ); 664 OThemeCache::HorizontalScale, widget );
665 pixmaps[ widget ] = new OThemePixmap; 665 pixmaps[ widget ] = new OThemePixmap;
666 pixmaps[ widget ] ->resize( w, h ); 666 pixmaps[ widget ] ->resize( w, h );
667 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ], 667 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ],
668 *grLowColors[ widget ], 668 *grLowColors[ widget ],
669 OGfxEffect::HorizontalGradient ); 669 OGfxEffect::HorizontalGradient );
670 } 670 }
671 } 671 }
672 } 672 }
673 else if ( gradients[ widget ] == GrReverseBevel ) { 673 else if ( gradients[ widget ] == GrReverseBevel ) {
674 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || 674 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ||
675 pixmaps[ widget ] ->height() != h ) { 675 pixmaps[ widget ] ->height() != h ) {
676 OThemePixmap * cachePix = cache->pixmap( w, h, widget ); 676 OThemePixmap * cachePix = cache->pixmap( w, h, widget );
677 if ( cachePix ) { 677 if ( cachePix ) {
678 cachePix = new OThemePixmap( *cachePix ); 678 cachePix = new OThemePixmap( *cachePix );
679 if ( pixmaps[ widget ] ) 679 if ( pixmaps[ widget ] )
680 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 680 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
681 widget ); 681 widget );
682 pixmaps[ widget ] = cachePix; 682 pixmaps[ widget ] = cachePix;
683 } 683 }
684 else { 684 else {
685 if ( pixmaps[ widget ] ) 685 if ( pixmaps[ widget ] )
686 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 686 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
687 widget ); 687 widget );
688 pixmaps[ widget ] = new OThemePixmap; 688 pixmaps[ widget ] = new OThemePixmap;
689 pixmaps[ widget ] ->resize( w, h ); 689 pixmaps[ widget ] ->resize( w, h );
690 690
691 QPixmap s; 691 QPixmap s;
692 int offset = decoWidth( widget ); 692 int offset = decoWidth( widget );
693 s.resize( w - offset * 2, h - offset * 2 ); 693 s.resize( w - offset * 2, h - offset * 2 );
694 QColor lc( *grLowColors[ widget ] ); 694 QColor lc( *grLowColors[ widget ] );
695 QColor hc( *grHighColors[ widget ] ); 695 QColor hc( *grHighColors[ widget ] );
696 if ( bevelContrast( widget ) ) { 696 if ( bevelContrast( widget ) ) {
697 int bc = bevelContrast( widget ); 697 int bc = bevelContrast( widget );
698 // want single increments, not factors like light()/dark() 698 // want single increments, not factors like light()/dark()
699 lc.setRgb( lc.red() - bc, lc.green() - bc, lc.blue() - bc ); 699 lc.setRgb( lc.red() - bc, lc.green() - bc, lc.blue() - bc );
700 hc.setRgb( hc.red() + bc, hc.green() + bc, hc.blue() + bc ); 700 hc.setRgb( hc.red() + bc, hc.green() + bc, hc.blue() + bc );
701 } 701 }
702 OGfxEffect::gradient( *pixmaps[ widget ], 702 OGfxEffect::gradient( *pixmaps[ widget ],
703 lc, hc, 703 lc, hc,
704 OGfxEffect::DiagonalGradient ); 704 OGfxEffect::DiagonalGradient );
705 OGfxEffect::gradient( s, *grHighColors[ widget ], 705 OGfxEffect::gradient( s, *grHighColors[ widget ],
706 *grLowColors[ widget ], 706 *grLowColors[ widget ],
707 OGfxEffect::DiagonalGradient ); 707 OGfxEffect::DiagonalGradient );
708 bitBlt( pixmaps[ widget ], offset, offset, &s, 0, 0, w - offset * 2, 708 bitBlt( pixmaps[ widget ], offset, offset, &s, 0, 0, w - offset * 2,
709 h - offset * 2, Qt::CopyROP ); 709 h - offset * 2, Qt::CopyROP );
710 } 710 }
711 } 711 }
712 } 712 }
713 else { 713 else {
714 OGfxEffect::GradientType g; 714 OGfxEffect::GradientType g;
715 switch ( gradients[ widget ] ) { 715 switch ( gradients[ widget ] ) {
716 case GrPyramid: 716 case GrPyramid:
717 g = OGfxEffect::PyramidGradient; 717 g = OGfxEffect::PyramidGradient;
718 break; 718 break;
719 case GrRectangle: 719 case GrRectangle:
720 g = OGfxEffect::RectangleGradient; 720 g = OGfxEffect::RectangleGradient;
721 break; 721 break;
722 case GrElliptic: 722 case GrElliptic:
723 g = OGfxEffect::EllipticGradient; 723 g = OGfxEffect::EllipticGradient;
724 break; 724 break;
725 default: 725 default:
726 g = OGfxEffect::DiagonalGradient; 726 g = OGfxEffect::DiagonalGradient;
727 break; 727 break;
728 } 728 }
729 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || 729 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ||
730 pixmaps[ widget ] ->height() != h ) { 730 pixmaps[ widget ] ->height() != h ) {
731 OThemePixmap * cachePix = cache->pixmap( w, h, widget ); 731 OThemePixmap * cachePix = cache->pixmap( w, h, widget );
732 if ( cachePix ) { 732 if ( cachePix ) {
733 cachePix = new OThemePixmap( *cachePix ); 733 cachePix = new OThemePixmap( *cachePix );
734 if ( pixmaps[ widget ] ) 734 if ( pixmaps[ widget ] )
735 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 735 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
736 widget ); 736 widget );
737 pixmaps[ widget ] = cachePix; 737 pixmaps[ widget ] = cachePix;
738 } 738 }
739 else { 739 else {
740 if ( pixmaps[ widget ] ) 740 if ( pixmaps[ widget ] )
741 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 741 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
742 widget ); 742 widget );
743 pixmaps[ widget ] = new OThemePixmap; 743 pixmaps[ widget ] = new OThemePixmap;
744 pixmaps[ widget ] ->resize( w, h ); 744 pixmaps[ widget ] ->resize( w, h );
745 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ], 745 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ],
746 *grLowColors[ widget ], g ); 746 *grLowColors[ widget ], g );
747 } 747 }
748 } 748 }
749 } 749 }
750 return ( pixmaps[ widget ] ); 750 return ( pixmaps[ widget ] );
751} 751}
752 752
753OThemePixmap* OThemeBase::scalePixmap( int w, int h, WidgetType widget ) 753OThemePixmap* OThemeBase::scalePixmap( int w, int h, WidgetType widget )
754{ 754{
755 755
756 if ( gradients[ widget ] && blends[ widget ] == 0.0 ) 756 if ( gradients[ widget ] && blends[ widget ] == 0.0 )
757 return ( gradient( w, h, widget ) ); 757 return ( gradient( w, h, widget ) );
758 758
759 return ( scale( w, h, widget ) ); 759 return ( scale( w, h, widget ) );
760} 760}
761 761
762QColorGroup* OThemeBase::makeColorGroup( QColor &fg, QColor &bg, 762QColorGroup* OThemeBase::makeColorGroup( QColor &fg, QColor &bg,
763 Qt::GUIStyle ) 763 Qt::GUIStyle )
764{ 764{
765 if ( shading == Motif ) { 765 if ( shading == Motif ) {
766 int highlightVal, lowlightVal; 766 int highlightVal, lowlightVal;
767 highlightVal = 100 + ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 16 / 10; 767 highlightVal = 100 + ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 16 / 10;
768 lowlightVal = 100 + ( ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 10 ); 768 lowlightVal = 100 + ( ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 10 );
769 return ( new QColorGroup( fg, bg, bg.light( highlightVal ), 769 return ( new QColorGroup( fg, bg, bg.light( highlightVal ),
770 bg.dark( lowlightVal ), bg.dark( 120 ), 770 bg.dark( lowlightVal ), bg.dark( 120 ),
771 fg, qApp->palette().normal().base() ) ); 771 fg, qApp->palette().normal().base() ) );
772 } 772 }
773 else 773 else
774 return ( new QColorGroup( fg, bg, bg.light( 150 ), bg.dark(), 774 return ( new QColorGroup( fg, bg, bg.light( 150 ), bg.dark(),
775 bg.dark( 120 ), fg, 775 bg.dark( 120 ), fg,
776 qApp->palette().normal().base() ) ); 776 qApp->palette().normal().base() ) );
777} 777}
778 778
779static QColor strToColor ( const QString &str ) 779static QColor strToColor ( const QString &str )
780{ 780{
781 QString str2 = str. stripWhiteSpace ( ); 781 QString str2 = str. stripWhiteSpace ( );
782 782
783 if ( str2 [0] == '#' ) 783 if ( str2 [0] == '#' )
784 return QColor ( str2 ); 784 return QColor ( str2 );
785 else { 785 else {
786 QStringList sl = QStringList::split ( ',', str2 ); 786 QStringList sl = QStringList::split ( ',', str2 );
787 787
788 if ( sl. count ( ) >= 3 ) 788 if ( sl. count ( ) >= 3 )
789 return QColor ( sl [0]. toInt ( ), sl [1]. toInt ( ), sl [2]. toInt ( )); 789 return QColor ( sl [0]. toInt ( ), sl [1]. toInt ( ), sl [2]. toInt ( ));
790 } 790 }
791 return QColor ( 0, 0, 0 ); 791 return QColor ( 0, 0, 0 );
792} 792}
793 793
794 794
795 795
796void OThemeBase::applyMiscResourceGroup( Config *config ) 796void OThemeBase::applyMiscResourceGroup( Config *config )
797{ 797{
798 config-> setGroup ( "Misc" ); 798 config-> setGroup ( "Misc" );
799 QString tmpStr; 799 QString tmpStr;
800 800
801 tmpStr = config->readEntry( "SButtonPosition" ); 801 tmpStr = config->readEntry( "SButtonPosition" );
802 if ( tmpStr == "BottomLeft" ) 802 if ( tmpStr == "BottomLeft" )
803 sbPlacement = SBBottomLeft; 803 sbPlacement = SBBottomLeft;
804 else if ( tmpStr == "BottomRight" ) 804 else if ( tmpStr == "BottomRight" )
805 sbPlacement = SBBottomRight; 805 sbPlacement = SBBottomRight;
806 else { 806 else {
807 if ( tmpStr != "Opposite" && !tmpStr.isEmpty() ) 807 if ( tmpStr != "Opposite" && !tmpStr.isEmpty() )
808 qDebug ( "OThemeBase: Unrecognized sb button option %s, using Opposite.\n", tmpStr.ascii() ); 808 odebug << "OThemeBase: Unrecognized sb button option " << tmpStr.ascii()
809 sbPlacement = SBOpposite; 809 << ", using Opposite." << oendl;
810 } 810 sbPlacement = SBOpposite;
811 tmpStr = config->readEntry( "ArrowType" ); 811 }
812 if ( tmpStr == "Small" ) 812 tmpStr = config->readEntry( "ArrowType" );
813 arrowStyle = SmallArrow; 813 if ( tmpStr == "Small" )
814 else if ( tmpStr == "3D" ) 814 arrowStyle = SmallArrow;
815 arrowStyle = MotifArrow; 815 else if ( tmpStr == "3D" )
816 else { 816 arrowStyle = MotifArrow;
817 if ( tmpStr != "Normal" && !tmpStr.isEmpty() ) 817 else {
818 qDebug ( "OThemeBase: Unrecognized arrow option %s, using Normal.\n", tmpStr.ascii() ); 818 if ( tmpStr != "Normal" && !tmpStr.isEmpty() )
819 arrowStyle = LargeArrow; 819 odebug << "OThemeBase: Unrecognized arrow option " << tmpStr.ascii()
820 } 820 << ", using Normal." << oendl;
821 tmpStr = config->readEntry( "ShadeStyle" ); 821 arrowStyle = LargeArrow;
822 if ( tmpStr == "Motif" ) 822 }
823 shading = Motif; 823 tmpStr = config->readEntry( "ShadeStyle" );
824 else if ( tmpStr == "Next" ) 824 if ( tmpStr == "Motif" )
825 shading = Next; 825 shading = Motif;
826 else if ( tmpStr == "KDE" ) 826 else if ( tmpStr == "Next" )
827 shading = KDE; 827 shading = Next;
828 else 828 else if ( tmpStr == "KDE" )
829 shading = Windows; 829 shading = KDE;
830 830 else
831 defaultFrame = config->readNumEntry( "FrameWidth", 2 ); 831 shading = Windows;
832 cacheSize = config->readNumEntry( "Cache", 1024 ); 832
833 sbExtent = config->readNumEntry( "ScrollBarExtent", 16 ); 833 defaultFrame = config->readNumEntry( "FrameWidth", 2 );
834 834 cacheSize = config->readNumEntry( "Cache", 1024 );
835 config-> setGroup ( "General" ); 835 sbExtent = config->readNumEntry( "ScrollBarExtent", 16 );
836 836
837 if ( config-> hasKey ( "foreground" )) fgcolor = strToColor ( config-> readEntry ( "foreground" )); 837 config-> setGroup ( "General" );
838 if ( config-> hasKey ( "background" )) bgcolor = strToColor ( config-> readEntry ( "background" )); 838
839 if ( config-> hasKey ( "selectForeground" )) selfgcolor = strToColor ( config-> readEntry ( "selectForeground" )); 839 if ( config-> hasKey ( "foreground" )) fgcolor = strToColor ( config-> readEntry ( "foreground" ));
840 if ( config-> hasKey ( "selectBackground" )) selbgcolor = strToColor ( config-> readEntry ( "selectBackground" )); 840 if ( config-> hasKey ( "background" )) bgcolor = strToColor ( config-> readEntry ( "background" ));
841 if ( config-> hasKey ( "windowForeground" )) winfgcolor = strToColor ( config-> readEntry ( "windowForeground" )); 841 if ( config-> hasKey ( "selectForeground" )) selfgcolor = strToColor ( config-> readEntry ( "selectForeground" ));
842 if ( config-> hasKey ( "windowBackground" )) winbgcolor = strToColor ( config-> readEntry ( "windowBackground" )); 842 if ( config-> hasKey ( "selectBackground" )) selbgcolor = strToColor ( config-> readEntry ( "selectBackground" ));
843 if ( config-> hasKey ( "windowForeground" )) winfgcolor = strToColor ( config-> readEntry ( "windowForeground" ));
844 if ( config-> hasKey ( "windowBackground" )) winbgcolor = strToColor ( config-> readEntry ( "windowBackground" ));
843} 845}
844 846
845void OThemeBase::readMiscResourceGroup() 847void OThemeBase::readMiscResourceGroup()
@@ -847,354 +849,357 @@ void OThemeBase::readMiscResourceGroup()
847 849
848void OThemeBase::applyResourceGroup( Config *config, int i, QString *copyfrom, QString *pixnames, QString *brdnames ) 850void OThemeBase::applyResourceGroup( Config *config, int i, QString *copyfrom, QString *pixnames, QString *brdnames )
849{ 851{
850 QString tmpStr; 852 QString tmpStr;
851 853
852 config-> setGroup ( widgetEntries [ i ] ); 854 config-> setGroup ( widgetEntries [ i ] );
853 855
854 tmpStr = config->readEntry( "CopyWidget", "" ); 856 tmpStr = config->readEntry( "CopyWidget", "" );
855 copyfrom [ i ] = tmpStr; 857 copyfrom [ i ] = tmpStr;
856 if ( !tmpStr.isEmpty() ) 858 if ( !tmpStr.isEmpty() )
857 return ; 859 return ;
858 860
859 // Scale hint 861 // Scale hint
860 tmpStr = config->readEntry( "Scale" ); 862 tmpStr = config->readEntry( "Scale" );
861 if ( tmpStr == "Full" ) 863 if ( tmpStr == "Full" )
862 scaleHints [ i ] = FullScale; 864 scaleHints [ i ] = FullScale;
863 else if ( tmpStr == "Horizontal" ) 865 else if ( tmpStr == "Horizontal" )
864 scaleHints [ i ] = HorizontalScale; 866 scaleHints [ i ] = HorizontalScale;
865 else if ( tmpStr == "Vertical" ) 867 else if ( tmpStr == "Vertical" )
866 scaleHints [ i ] = VerticalScale; 868 scaleHints [ i ] = VerticalScale;
867 else { 869 else {
868 if ( tmpStr != "Tile" && !tmpStr.isEmpty() ) 870 if ( tmpStr != "Tile" && !tmpStr.isEmpty() )
869 qDebug ( "OThemeBase: Unrecognized scale option %s, using Tile.\n", tmpStr.ascii() ); 871 odebug << "OThemeBase: Unrecognized scale option " << tmpStr.ascii()
870 scaleHints [ i ] = TileScale; 872 << ", using Tile." << oendl;
871 } 873 scaleHints [ i ] = TileScale;
872 874 }
873 875
874 // Gradient type 876
875 tmpStr = config->readEntry( "Gradient" ); 877 // Gradient type
876 if ( tmpStr == "Diagonal" ) 878 tmpStr = config->readEntry( "Gradient" );
877 gradients [ i ] = GrDiagonal; 879 if ( tmpStr == "Diagonal" )
878 else if ( tmpStr == "Horizontal" ) 880 gradients [ i ] = GrDiagonal;
879 gradients [ i ] = GrHorizontal; 881 else if ( tmpStr == "Horizontal" )
880 else if ( tmpStr == "Vertical" ) 882 gradients [ i ] = GrHorizontal;
881 gradients [ i ] = GrVertical; 883 else if ( tmpStr == "Vertical" )
882 else if ( tmpStr == "Pyramid" ) 884 gradients [ i ] = GrVertical;
883 gradients [ i ] = GrPyramid; 885 else if ( tmpStr == "Pyramid" )
884 else if ( tmpStr == "Rectangle" ) 886 gradients [ i ] = GrPyramid;
885 gradients [ i ] = GrRectangle; 887 else if ( tmpStr == "Rectangle" )
886 else if ( tmpStr == "Elliptic" ) 888 gradients [ i ] = GrRectangle;
887 gradients [ i ] = GrElliptic; 889 else if ( tmpStr == "Elliptic" )
888 else if ( tmpStr == "ReverseBevel" ) 890 gradients [ i ] = GrElliptic;
889 gradients [ i ] = GrReverseBevel; 891 else if ( tmpStr == "ReverseBevel" )
890 else { 892 gradients [ i ] = GrReverseBevel;
891 if ( tmpStr != "None" && !tmpStr.isEmpty() ) 893 else {
892 qDebug ( "OThemeBase: Unrecognized gradient option %s, using None.\n", tmpStr.ascii() ); 894 if ( tmpStr != "None" && !tmpStr.isEmpty() )
893 gradients [ i ] = GrNone; 895 odebug << "OThemeBase: Unrecognized gradient option " << tmpStr.ascii()
894 } 896 << ", using None." << oendl;
895 897 gradients [ i ] = GrNone;
896 // Blend intensity 898 }
897 blends[ i ] = config->readEntry( "BlendIntensity", "0.0" ).toDouble(); 899
898 900 // Blend intensity
899 // Bevel contrast 901 blends[ i ] = config->readEntry( "BlendIntensity", "0.0" ).toDouble();
900 bContrasts[ i ] = config->readNumEntry( "BevelContrast", 0 ); 902
901 903 // Bevel contrast
902 // Border width 904 bContrasts[ i ] = config->readNumEntry( "BevelContrast", 0 );
903 borders [ i ] = config->readNumEntry( "Border", 1 ); 905
904 906 // Border width
905 // Highlight width 907 borders [ i ] = config->readNumEntry( "Border", 1 );
906 highlights [ i ] = config->readNumEntry( "Highlight", 1 ); 908
907 909 // Highlight width
908 // Gradient low color or blend background 910 highlights [ i ] = config->readNumEntry( "Highlight", 1 );
909 if ( config->hasKey( "GradientLow" ) && ( gradients[ i ] != GrNone || blends[ i ] != 0.0 )) 911
910 grLowColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientLow", qApp->palette().normal().background().name() ))); 912 // Gradient low color or blend background
911 else 913 if ( config->hasKey( "GradientLow" ) && ( gradients[ i ] != GrNone || blends[ i ] != 0.0 ))
912 grLowColors[ i ] = NULL; 914 grLowColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientLow", qApp->palette().normal().background().name() )));
913 915 else
914 916 grLowColors[ i ] = NULL;
915 // Gradient high color 917
916 if ( config->hasKey( "GradientHigh" ) && ( gradients[ i ] != GrNone )) 918
917 grHighColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientHigh", qApp->palette().normal().background().name() ))); 919 // Gradient high color
918 else 920 if ( config->hasKey( "GradientHigh" ) && ( gradients[ i ] != GrNone ))
919 grHighColors[ i ] = NULL; 921 grHighColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientHigh", qApp->palette().normal().background().name() )));
920 922 else
921 // Extended color attributes 923 grHighColors[ i ] = NULL;
922 if ( config->hasKey( "Foreground" ) || config->hasKey( "Background" ) ) { 924
923 QColor bg = strToColor( config->readEntry( "Background", qApp->palette().normal().background().name() )); 925 // Extended color attributes
924 QColor fg = strToColor( config->readEntry( "Foreground", qApp->palette().normal().foreground().name() )); 926 if ( config->hasKey( "Foreground" ) || config->hasKey( "Background" ) ) {
925 927 QColor bg = strToColor( config->readEntry( "Background", qApp->palette().normal().background().name() ));
926 colors[ i ] = makeColorGroup( fg, bg, Qt::WindowsStyle ); 928 QColor fg = strToColor( config->readEntry( "Foreground", qApp->palette().normal().foreground().name() ));
927 } 929
928 else 930 colors[ i ] = makeColorGroup( fg, bg, Qt::WindowsStyle );
929 colors[ i ] = NULL; 931 }
930 932 else
931 // Pixmap 933 colors[ i ] = NULL;
932 tmpStr = config->readEntry( "Pixmap", "" ); 934
933 pixnames[ i ] = tmpStr; 935 // Pixmap
934 duplicate[ i ] = false; 936 tmpStr = config->readEntry( "Pixmap", "" );
935 pixmaps[ i ] = NULL; 937 pixnames[ i ] = tmpStr;
936 images[ i ] = NULL; 938 duplicate[ i ] = false;
937 939 pixmaps[ i ] = NULL;
938 940 images[ i ] = NULL;
939 // Pixmap border 941
940 tmpStr = config->readEntry( "PixmapBorder", "" ); 942
941 brdnames[ i ] = tmpStr; 943 // Pixmap border
942 pbDuplicate[ i ] = false; 944 tmpStr = config->readEntry( "PixmapBorder", "" );
943 pbPixmaps[ i ] = NULL; 945 brdnames[ i ] = tmpStr;
944 pbWidth[ i ] = 0; 946 pbDuplicate[ i ] = false;
945 if ( !tmpStr.isEmpty() ) { 947 pbPixmaps[ i ] = NULL;
946 pbWidth[ i ] = config->readNumEntry( "PixmapBWidth", 0 ); 948 pbWidth[ i ] = 0;
947 if ( pbWidth[ i ] == 0 ) { 949 if ( !tmpStr.isEmpty() ) {
948 qDebug ( "OThemeBase: No border width specified for pixmapped border widget %s\n", widgetEntries[ i ] ); 950 pbWidth[ i ] = config->readNumEntry( "PixmapBWidth", 0 );
949 qDebug ( "OThemeBase: Using default of 2.\n" ); 951 if ( pbWidth[ i ] == 0 ) {
950 pbWidth[ i ] = 2; 952 odebug << "OThemeBase: No border width specified for pixmapped border widget "
951 } 953 << widgetEntries[ i ] << oendl;
952 } 954 odebug << "OThemeBase: Using default of 2." << oendl;
953 955 pbWidth[ i ] = 2;
954 956 }
955 // Various widget specific settings. This was more efficent when bunched 957 }
956 // together in the misc group, but this makes an easier to read config. 958
957 if ( i == SliderGroove ) 959
958 roundedSlider = config->readBoolEntry( "SmallGroove", false ); 960 // Various widget specific settings. This was more efficent when bunched
959 else if ( i == ActiveTab ) { 961 // together in the misc group, but this makes an easier to read config.
960 aTabLine = config->readBoolEntry( "BottomLine", true ); 962 if ( i == SliderGroove )
961 } 963 roundedSlider = config->readBoolEntry( "SmallGroove", false );
962 else if ( i == InactiveTab ) { 964 else if ( i == ActiveTab ) {
963 iTabLine = config->readBoolEntry( "BottomLine", true ); 965 aTabLine = config->readBoolEntry( "BottomLine", true );
964 } 966 }
965 else if ( i == Splitter ) 967 else if ( i == InactiveTab ) {
966 splitterWidth = config->readNumEntry( "Width", 10 ); 968 iTabLine = config->readBoolEntry( "BottomLine", true );
967 else if ( i == ComboBox || i == ComboBoxDown ) { 969 }
968 roundedCombo = config->readBoolEntry( "Round", false ); 970 else if ( i == Splitter )
969 } 971 splitterWidth = config->readNumEntry( "Width", 10 );
970 else if ( i == PushButton || i == PushButtonDown ) { 972 else if ( i == ComboBox || i == ComboBoxDown ) {
971 btnXShift = config->readNumEntry( "XShift", 0 ); 973 roundedCombo = config->readBoolEntry( "Round", false );
972 btnYShift = config->readNumEntry( "YShift", 0 ); 974 }
973 focus3D = config->readBoolEntry( "3DFocusRect", false ); 975 else if ( i == PushButton || i == PushButtonDown ) {
974 focus3DOffset = config->readBoolEntry( "3DFocusOffset", 0 ); 976 btnXShift = config->readNumEntry( "XShift", 0 );
975 roundedButton = config->readBoolEntry( "Round", false ); 977 btnYShift = config->readNumEntry( "YShift", 0 );
976 } 978 focus3D = config->readBoolEntry( "3DFocusRect", false );
979 focus3DOffset = config->readBoolEntry( "3DFocusOffset", 0 );
980 roundedButton = config->readBoolEntry( "Round", false );
981 }
977} 982}
978 983
979 984
980void OThemeBase::readResourceGroup( int i, QString *copyfrom, QString *pixnames, QString *brdnames, 985void OThemeBase::readResourceGroup( int i, QString *copyfrom, QString *pixnames, QString *brdnames,
981 bool *loadArray ) 986 bool *loadArray )
982{ 987{
983 if ( loadArray[ i ] == true ) { 988 if ( loadArray[ i ] == true ) {
984 return ; // already been preloaded. 989 return ; // already been preloaded.
985 } 990 }
986 991
987 int tmpVal; 992 int tmpVal;
988 QString tmpStr; 993 QString tmpStr;
989 994
990 tmpStr = copyfrom [ i ]; 995 tmpStr = copyfrom [ i ];
991 if ( !tmpStr.isEmpty() ) { // Duplicate another widget's config 996 if ( !tmpStr.isEmpty() ) { // Duplicate another widget's config
992 int sIndex; 997 int sIndex;
993 loadArray[ i ] = true; 998 loadArray[ i ] = true;
994 for ( sIndex = 0; sIndex < WIDGETS; ++sIndex ) { 999 for ( sIndex = 0; sIndex < WIDGETS; ++sIndex ) {
995 if ( tmpStr == widgetEntries[ sIndex ] ) { 1000 if ( tmpStr == widgetEntries[ sIndex ] ) {
996 if ( !loadArray[ sIndex ] ) // hasn't been loaded yet 1001 if ( !loadArray[ sIndex ] ) // hasn't been loaded yet
997 readResourceGroup( sIndex, copyfrom, pixnames, brdnames, 1002 readResourceGroup( sIndex, copyfrom, pixnames, brdnames,
998 loadArray ); 1003 loadArray );
999 break; 1004 break;
1000 } 1005 }
1001 } 1006 }
1002 if ( loadArray[ sIndex ] ) { 1007 if ( loadArray[ sIndex ] ) {
1003 copyWidgetConfig( sIndex, i, pixnames, brdnames ); 1008 copyWidgetConfig( sIndex, i, pixnames, brdnames );
1004 } 1009 }
1005 else 1010 else
1006 qDebug ( "OThemeBase: Unable to identify source widget for %s\n", widgetEntries[ i ] ); 1011 odebug << "OThemeBase: Unable to identify source widget for " << widgetEntries[ i ] << oendl;
1007 return ; 1012 return ;
1008 } 1013 }
1009 // special inheritance for disabled arrows (these are tri-state unlike 1014 // special inheritance for disabled arrows (these are tri-state unlike
1010 // the rest of what we handle). 1015 // the rest of what we handle).
1011 for ( tmpVal = DisArrowUp; tmpVal <= DisArrowRight; ++tmpVal ) { 1016 for ( tmpVal = DisArrowUp; tmpVal <= DisArrowRight; ++tmpVal ) {
1012 if ( tmpVal == i ) { 1017 if ( tmpVal == i ) {
1013 tmpStr = pixnames [ i ]; 1018 tmpStr = pixnames [ i ];
1014 if ( tmpStr.isEmpty() ) { 1019 if ( tmpStr.isEmpty() ) {
1015 copyWidgetConfig( ArrowUp + ( tmpVal - DisArrowUp ), i, pixnames, 1020 copyWidgetConfig( ArrowUp + ( tmpVal - DisArrowUp ), i, pixnames,
1016 brdnames ); 1021 brdnames );
1017 return ; 1022 return ;
1018 } 1023 }
1019 } 1024 }
1020 } 1025 }
1021 1026
1022 // Pixmap 1027 // Pixmap
1023 int existing; 1028 int existing;
1024 // Scan for duplicate pixmaps(two identical pixmaps, tile scale, no blend, 1029 // Scan for duplicate pixmaps(two identical pixmaps, tile scale, no blend,
1025 // no pixmapped border) 1030 // no pixmapped border)
1026 if ( !pixnames [ i ].isEmpty() ) { 1031 if ( !pixnames [ i ].isEmpty() ) {
1027 for ( existing = 0; existing < i; ++existing ) { 1032 for ( existing = 0; existing < i; ++existing ) {
1028 if ( pixnames[ i ] == pixnames[ existing ] && scaleHints[ i ] == TileScale && 1033 if ( pixnames[ i ] == pixnames[ existing ] && scaleHints[ i ] == TileScale &&
1029 scaleHints[ existing ] == TileScale && blends[ existing ] == 0.0 && 1034 scaleHints[ existing ] == TileScale && blends[ existing ] == 0.0 &&
1030 blends[ i ] == 0.0 ) { 1035 blends[ i ] == 0.0 ) {
1031 pixmaps[ i ] = pixmaps[ existing ]; 1036 pixmaps[ i ] = pixmaps[ existing ];
1032 duplicate[ i ] = true; 1037 duplicate[ i ] = true;
1033 break; 1038 break;
1034 } 1039 }
1035 } 1040 }
1036 } 1041 }
1037 // load 1042 // load
1038 if ( !duplicate[ i ] && !pixnames[ i ].isEmpty() ) { 1043 if ( !duplicate[ i ] && !pixnames[ i ].isEmpty() ) {
1039 pixmaps[ i ] = loadPixmap( pixnames[ i ] ); 1044 pixmaps[ i ] = loadPixmap( pixnames[ i ] );
1040 // load and save images for scaled/blended widgets for speed. 1045 // load and save images for scaled/blended widgets for speed.
1041 if ( scaleHints[ i ] == TileScale && blends[ i ] == 0.0 ) 1046 if ( scaleHints[ i ] == TileScale && blends[ i ] == 0.0 )
1042 images[ i ] = NULL; 1047 images[ i ] = NULL;
1043 else 1048 else
1044 images[ i ] = loadImage( pixnames[ i ] ); 1049 images[ i ] = loadImage( pixnames[ i ] );
1045 } 1050 }
1046 1051
1047 // Pixmap border 1052 // Pixmap border
1048 if ( !brdnames [ i ]. isEmpty () ) { 1053 if ( !brdnames [ i ]. isEmpty () ) {
1049 // duplicate check 1054 // duplicate check
1050 for ( existing = 0; existing < i; ++existing ) { 1055 for ( existing = 0; existing < i; ++existing ) {
1051 if ( brdnames [i] == brdnames[ existing ] ) { 1056 if ( brdnames [i] == brdnames[ existing ] ) {
1052 pbPixmaps[ i ] = pbPixmaps[ existing ]; 1057 pbPixmaps[ i ] = pbPixmaps[ existing ];
1053 pbDuplicate[ i ] = true; 1058 pbDuplicate[ i ] = true;
1054 break; 1059 break;
1055 } 1060 }
1056 } 1061 }
1057 } 1062 }
1058 // load 1063 // load
1059 if ( !pbDuplicate[ i ] && !brdnames[ i ].isEmpty() ) 1064 if ( !pbDuplicate[ i ] && !brdnames[ i ].isEmpty() )
1060 pbPixmaps[ i ] = loadPixmap( brdnames[ i ] ); 1065 pbPixmaps[ i ] = loadPixmap( brdnames[ i ] );
1061 1066
1062 if ( pbPixmaps[ i ] && !pbDuplicate[ i ] ) 1067 if ( pbPixmaps[ i ] && !pbDuplicate[ i ] )
1063 generateBorderPix( i ); 1068 generateBorderPix( i );
1064 1069
1065 loadArray[ i ] = true; 1070 loadArray[ i ] = true;
1066} 1071}
1067 1072
1068 1073
1069OThemePixmap::OThemePixmap( bool timer ) 1074OThemePixmap::OThemePixmap( bool timer )
1070 : QPixmap() 1075 : QPixmap()
1071{ 1076{
1072 if(timer){ 1077 if(timer){
1073 t = new QTime; 1078 t = new QTime;
1074 t->start(); 1079 t->start();
1075 } 1080 }
1076 else 1081 else
1077 t = NULL; 1082 t = NULL;
1078 int i; 1083 int i;
1079 for ( i = 0; i < 8; ++i ) 1084 for ( i = 0; i < 8; ++i )
1080 b[ i ] = NULL; 1085 b[ i ] = NULL;
1081} 1086}
1082 1087
1083OThemePixmap::OThemePixmap( const OThemePixmap &p ) 1088OThemePixmap::OThemePixmap( const OThemePixmap &p )
1084 : QPixmap( p ) 1089 : QPixmap( p )
1085{ 1090{
1086 if(p.t){ 1091 if(p.t){
1087 t = new QTime; 1092 t = new QTime;
1088 t->start(); 1093 t->start();
1089 } 1094 }
1090 else 1095 else
1091 t = NULL; 1096 t = NULL;
1092 int i; 1097 int i;
1093 for ( i = 0; i < 8; ++i ) 1098 for ( i = 0; i < 8; ++i )
1094 if ( p.b[ i ] ) 1099 if ( p.b[ i ] )
1095 b[ i ] = new QPixmap( *p.b[ i ] ); 1100 b[ i ] = new QPixmap( *p.b[ i ] );
1096 else 1101 else
1097 b[ i ] = NULL; 1102 b[ i ] = NULL;
1098} 1103}
1099 1104
1100 1105
1101 1106
1102OThemePixmap::~OThemePixmap() 1107OThemePixmap::~OThemePixmap()
1103{ 1108{
1104 if(t) 1109 if(t)
1105 delete t; 1110 delete t;
1106 int i; 1111 int i;
1107 for ( i = 0; i < 8; ++i ) 1112 for ( i = 0; i < 8; ++i )
1108 if ( b[ i ] ) 1113 if ( b[ i ] )
1109 delete b[ i ]; 1114 delete b[ i ];
1110} 1115}
1111 1116
1112OThemeCache::OThemeCache( int maxSize, QObject *parent, const char *name ) 1117OThemeCache::OThemeCache( int maxSize, QObject *parent, const char *name )
1113 : QObject( parent, name ) 1118 : QObject( parent, name )
1114{ 1119{
1115 cache.setMaxCost( maxSize * 1024 ); 1120 cache.setMaxCost( maxSize * 1024 );
1116 cache.setAutoDelete( true ); 1121 cache.setAutoDelete( true );
1117 flushTimer.start(300000); // 5 minutes 1122 flushTimer.start(300000); // 5 minutes
1118 connect(&flushTimer, SIGNAL(timeout()), SLOT(flushTimeout())); 1123 connect(&flushTimer, SIGNAL(timeout()), SLOT(flushTimeout()));
1119} 1124}
1120 1125
1121void OThemeCache::flushTimeout() 1126void OThemeCache::flushTimeout()
1122{ 1127{
1123 QIntCacheIterator<OThemePixmap> it( cache ); 1128 QIntCacheIterator<OThemePixmap> it( cache );
1124 while ( it.current() ) { 1129 while ( it.current() ) {
1125 if ( it.current() ->isOld() ) 1130 if ( it.current() ->isOld() )
1126 cache.remove( it.currentKey() ); 1131 cache.remove( it.currentKey() );
1127 else 1132 else
1128 ++it; 1133 ++it;
1129 } 1134 }
1130} 1135}
1131 1136
1132OThemePixmap* OThemeCache::pixmap( int w, int h, int widgetID, bool border, 1137OThemePixmap* OThemeCache::pixmap( int w, int h, int widgetID, bool border,
1133 bool mask ) 1138 bool mask )
1134{ 1139{
1135 1140
1136 kthemeKey key; 1141 kthemeKey key;
1137 key.cacheKey = 0; // shut up, gcc 1142 key.cacheKey = 0; // shut up, gcc
1138 key.data.id = widgetID; 1143 key.data.id = widgetID;
1139 key.data.width = w; 1144 key.data.width = w;
1140 key.data.height = h; 1145 key.data.height = h;
1141 key.data.border = border; 1146 key.data.border = border;
1142 key.data.mask = mask; 1147 key.data.mask = mask;
1143 1148
1144 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey ); 1149 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey );
1145 if ( pix ) 1150 if ( pix )
1146 pix->updateAccessed(); 1151 pix->updateAccessed();
1147 return ( pix ); 1152 return ( pix );
1148} 1153}
1149 1154
1150OThemePixmap* OThemeCache::horizontalPixmap( int w, int widgetID ) 1155OThemePixmap* OThemeCache::horizontalPixmap( int w, int widgetID )
1151{ 1156{
1152 kthemeKey key; 1157 kthemeKey key;
1153 key.cacheKey = 0; // shut up, gcc 1158 key.cacheKey = 0; // shut up, gcc
1154 key.data.id = widgetID; 1159 key.data.id = widgetID;
1155 key.data.width = w; 1160 key.data.width = w;
1156 key.data.height = 0; 1161 key.data.height = 0;
1157 key.data.border = false; 1162 key.data.border = false;
1158 key.data.mask = false; 1163 key.data.mask = false;
1159 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey ); 1164 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey );
1160 if ( pix ) 1165 if ( pix )
1161 pix->updateAccessed(); 1166 pix->updateAccessed();
1162 return ( pix ); 1167 return ( pix );
1163} 1168}
1164 1169
1165OThemePixmap* OThemeCache::verticalPixmap( int h, int widgetID ) 1170OThemePixmap* OThemeCache::verticalPixmap( int h, int widgetID )
1166{ 1171{
1167 kthemeKey key; 1172 kthemeKey key;
1168 key.cacheKey = 0; // shut up, gcc 1173 key.cacheKey = 0; // shut up, gcc
1169 key.data.id = widgetID; 1174 key.data.id = widgetID;
1170 key.data.width = 0; 1175 key.data.width = 0;
1171 key.data.height = h; 1176 key.data.height = h;
1172 key.data.border = false; 1177 key.data.border = false;
1173 key.data.mask = false; 1178 key.data.mask = false;
1174 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey ); 1179 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey );
1175 if ( pix ) 1180 if ( pix )
1176 pix->updateAccessed(); 1181 pix->updateAccessed();
1177 return ( pix ); 1182 return ( pix );
1178} 1183}
1179 1184
1180bool OThemeCache::insert( OThemePixmap *pixmap, ScaleHint scale, int widgetID, 1185bool OThemeCache::insert( OThemePixmap *pixmap, ScaleHint scale, int widgetID,
1181 bool border, bool mask ) 1186 bool border, bool mask )
1182{ 1187{
1183 kthemeKey key; 1188 kthemeKey key;
1184 key.cacheKey = 0; // shut up, gcc 1189 key.cacheKey = 0; // shut up, gcc
1185 key.data.id = widgetID; 1190 key.data.id = widgetID;
1186 key.data.width = ( scale == FullScale || scale == HorizontalScale ) ? 1191 key.data.width = ( scale == FullScale || scale == HorizontalScale ) ?
1187 pixmap->width() : 0; 1192 pixmap->width() : 0;
1188 key.data.height = ( scale == FullScale || scale == VerticalScale ) ? 1193 key.data.height = ( scale == FullScale || scale == VerticalScale ) ?
1189 pixmap->height() : 0; 1194 pixmap->height() : 0;
1190 key.data.border = border; 1195 key.data.border = border;
1191 key.data.mask = mask; 1196 key.data.mask = mask;
1192 1197
1193 if ( cache.find( ( unsigned long ) key.cacheKey, true ) != NULL ) { 1198 if ( cache.find( ( unsigned long ) key.cacheKey, true ) != NULL ) {
1194 return ( true ); // a pixmap of this scale is already in there 1199 return ( true ); // a pixmap of this scale is already in there
1195 } 1200 }
1196 return ( cache.insert( ( unsigned long ) key.cacheKey, pixmap, 1201 return ( cache.insert( ( unsigned long ) key.cacheKey, pixmap,
1197 pixmap->width() * pixmap->height() * pixmap->depth() / 8 ) ); 1202 pixmap->width() * pixmap->height() * pixmap->depth() / 8 ) );
1198} 1203}
1199 1204
1200//#include "kthemebase.moc" 1205//#include "kthemebase.moc"