author | eckhart.koppen@nokia.com |
Wed, 31 Mar 2010 11:06:36 +0300 | |
changeset 7 | f7bc934e204c |
parent 3 | 41300fa6a67c |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
0 | 8 |
** |
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qs60style.h" |
|
43 |
#include "qs60style_p.h" |
|
44 |
#include "qfile.h" |
|
45 |
#include "qhash.h" |
|
46 |
#include "qapplication.h" |
|
47 |
#include "qpainter.h" |
|
48 |
#include "qpicture.h" |
|
49 |
#include "qstyleoption.h" |
|
50 |
#include "qtransform.h" |
|
51 |
#include "qlayout.h" |
|
52 |
#include "qpixmapcache.h" |
|
53 |
#include "qmetaobject.h" |
|
54 |
#include "qdebug.h" |
|
55 |
#include "qbuffer.h" |
|
56 |
#include "qdesktopwidget.h" |
|
57 |
||
58 |
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) |
|
59 |
||
60 |
QT_BEGIN_NAMESPACE |
|
61 |
||
62 |
static const quint32 blobVersion = 1; |
|
63 |
static const int pictureSize = 256; |
|
64 |
||
65 |
#if defined(Q_CC_GNU) |
|
66 |
#if __GNUC__ >= 2 |
|
67 |
#define __FUNCTION__ __func__ |
|
68 |
#endif |
|
69 |
#endif |
|
70 |
||
71 |
||
72 |
bool saveThemeToBlob(const QString &themeBlob, |
|
73 |
const QHash<QString, QPicture> &partPictures, |
|
74 |
const QHash<QPair<QString, int>, QColor> &colors) |
|
75 |
{ |
|
76 |
QFile blob(themeBlob); |
|
77 |
if (!blob.open(QIODevice::WriteOnly)) { |
|
78 |
qWarning() << __FUNCTION__ << ": Could not create blob: " << themeBlob; |
|
79 |
return false; |
|
80 |
} |
|
81 |
||
82 |
QByteArray data; |
|
83 |
QBuffer dataBuffer(&data); |
|
84 |
dataBuffer.open(QIODevice::WriteOnly); |
|
85 |
QDataStream dataOut(&dataBuffer); |
|
86 |
||
87 |
const int colorsCount = colors.count(); |
|
88 |
dataOut << colorsCount; |
|
89 |
const QList<QPair<QString, int> > colorKeys = colors.keys(); |
|
90 |
for (int i = 0; i < colorsCount; ++i) { |
|
91 |
const QPair<QString, int> &key = colorKeys.at(i); |
|
92 |
dataOut << key; |
|
93 |
const QColor color = colors.value(key); |
|
94 |
dataOut << color; |
|
95 |
} |
|
96 |
||
97 |
const int picturesCount = partPictures.count(); |
|
98 |
dataOut << picturesCount; |
|
99 |
foreach (const QString &key, partPictures.keys()) { |
|
100 |
const QPicture picture = partPictures.value(key); |
|
101 |
dataOut << key; |
|
102 |
dataOut << picture; |
|
103 |
} |
|
104 |
||
105 |
QDataStream blobOut(&blob); |
|
106 |
blobOut << blobVersion; |
|
107 |
blobOut << qCompress(data); |
|
108 |
return blobOut.status() == QDataStream::Ok; |
|
109 |
} |
|
110 |
||
111 |
bool loadThemeFromBlob(const QString &themeBlob, |
|
112 |
QHash<QString, QPicture> &partPictures, |
|
113 |
QHash<QPair<QString, int>, QColor> &colors) |
|
114 |
{ |
|
115 |
QFile blob(themeBlob); |
|
116 |
if (!blob.open(QIODevice::ReadOnly)) { |
|
117 |
qWarning() << __FUNCTION__ << ": Could not read blob: " << themeBlob; |
|
118 |
return false; |
|
119 |
} |
|
120 |
QDataStream blobIn(&blob); |
|
121 |
||
122 |
quint32 version; |
|
123 |
blobIn >> version; |
|
124 |
||
125 |
if (version != blobVersion) { |
|
126 |
qWarning() << __FUNCTION__ << ": Invalid blob version: " << version << " ...expected: " << blobVersion; |
|
127 |
return false; |
|
128 |
} |
|
129 |
||
130 |
QByteArray data; |
|
131 |
blobIn >> data; |
|
132 |
data = qUncompress(data); |
|
133 |
QBuffer dataBuffer(&data); |
|
134 |
dataBuffer.open(QIODevice::ReadOnly); |
|
135 |
QDataStream dataIn(&dataBuffer); |
|
136 |
||
137 |
int colorsCount; |
|
138 |
dataIn >> colorsCount; |
|
139 |
for (int i = 0; i < colorsCount; ++i) { |
|
140 |
QPair<QString, int> key; |
|
141 |
dataIn >> key; |
|
142 |
QColor value; |
|
143 |
dataIn >> value; |
|
144 |
colors.insert(key, value); |
|
145 |
} |
|
146 |
||
147 |
int picturesCount; |
|
148 |
dataIn >> picturesCount; |
|
149 |
for (int i = 0; i < picturesCount; ++i) { |
|
150 |
QString key; |
|
151 |
dataIn >> key; |
|
152 |
QPicture value; |
|
153 |
dataIn >> value; |
|
154 |
value.setBoundingRect(QRect(0, 0, pictureSize, pictureSize)); // Bug? The forced bounding rect was not deserialized. |
|
155 |
partPictures.insert(key, value); |
|
156 |
} |
|
157 |
||
158 |
if (dataIn.status() != QDataStream::Ok) { |
|
159 |
qWarning() << __FUNCTION__ << ": Invalid data blob: " << themeBlob; |
|
160 |
return false; |
|
161 |
} |
|
162 |
return true; |
|
163 |
} |
|
164 |
||
165 |
class QS60StyleModeSpecifics |
|
166 |
{ |
|
167 |
public: |
|
168 |
static QPixmap skinnedGraphics(QS60StyleEnums::SkinParts stylepart, |
|
169 |
const QSize &size, QS60StylePrivate::SkinElementFlags flags); |
|
170 |
static QHash<QString, QPicture> m_partPictures; |
|
171 |
static QHash<QPair<QString , int>, QColor> m_colors; |
|
172 |
}; |
|
173 |
QHash<QString, QPicture> QS60StyleModeSpecifics::m_partPictures; |
|
174 |
QHash<QPair<QString , int>, QColor> QS60StyleModeSpecifics::m_colors; |
|
175 |
||
176 |
QS60StylePrivate::QS60StylePrivate() |
|
177 |
{ |
|
178 |
setCurrentLayout(0); |
|
179 |
} |
|
180 |
||
181 |
QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list, |
|
182 |
int index, const QStyleOption *option) |
|
183 |
{ |
|
184 |
const QString listKey = QS60Style::colorListKeys().at(list); |
|
185 |
return QS60StylePrivate::stateColor( |
|
186 |
QS60StyleModeSpecifics::m_colors.value(QPair<QString, int>(listKey, index)), |
|
187 |
option |
|
188 |
); |
|
189 |
} |
|
190 |
||
191 |
QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, const QSize &size, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
QPainter *painter, QS60StylePrivate::SkinElementFlags flags) |
0 | 193 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
Q_UNUSED(painter); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
|
0 | 196 |
const QString partKey = QS60Style::partKeys().at(part); |
197 |
const QPicture partPicture = QS60StyleModeSpecifics::m_partPictures.value(partKey); |
|
198 |
QSize partSize(partPicture.boundingRect().size()); |
|
199 |
if (flags & (SF_PointEast | SF_PointWest)) { |
|
200 |
const int temp = partSize.width(); |
|
201 |
partSize.setWidth(partSize.height()); |
|
202 |
partSize.setHeight(temp); |
|
203 |
} |
|
204 |
const qreal scaleX = size.width() / (qreal)partSize.width(); |
|
205 |
const qreal scaleY = size.height() / (qreal)partSize.height(); |
|
206 |
||
207 |
QImage partImage(size, QImage::Format_ARGB32); |
|
208 |
partImage.fill(Qt::transparent); |
|
209 |
QPainter resultPainter(&partImage); |
|
210 |
QTransform t; |
|
211 |
||
212 |
if (flags & SF_PointEast) |
|
213 |
t.translate(size.width(), 0); |
|
214 |
else if (flags & SF_PointSouth) |
|
215 |
t.translate(size.width(), size.height()); |
|
216 |
else if (flags & SF_PointWest) |
|
217 |
t.translate(0, size.height()); |
|
218 |
||
219 |
t.scale(scaleX, scaleY); |
|
220 |
||
221 |
if (flags & SF_PointEast) |
|
222 |
t.rotate(90); |
|
223 |
else if (flags & SF_PointSouth) |
|
224 |
t.rotate(180); |
|
225 |
else if (flags & SF_PointWest) |
|
226 |
t.rotate(270); |
|
227 |
||
228 |
resultPainter.setTransform(t, true); |
|
229 |
const_cast<QPicture *>(&partPicture)->play(&resultPainter); |
|
230 |
resultPainter.end(); |
|
231 |
||
232 |
QPixmap result = QPixmap::fromImage(partImage); |
|
233 |
if (flags & SF_StateDisabled) { |
|
234 |
QStyleOption opt; |
|
235 |
QPalette *themePalette = QS60StylePrivate::themePalette(); |
|
236 |
if (themePalette) |
|
237 |
opt.palette = *themePalette; |
|
238 |
result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt); |
|
239 |
} |
|
240 |
||
241 |
return result; |
|
242 |
} |
|
243 |
||
244 |
QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, |
|
245 |
SkinElementFlags flags) |
|
246 |
{ |
|
247 |
const QS60StyleEnums::SkinParts center = m_frameElementsData[frame].center; |
|
248 |
const QS60StyleEnums::SkinParts topLeft = QS60StyleEnums::SkinParts(center - 8); |
|
249 |
const QS60StyleEnums::SkinParts topRight = QS60StyleEnums::SkinParts(center - 7); |
|
250 |
const QS60StyleEnums::SkinParts bottomLeft = QS60StyleEnums::SkinParts(center - 6); |
|
251 |
const QS60StyleEnums::SkinParts bottomRight = QS60StyleEnums::SkinParts(center - 5); |
|
252 |
const QS60StyleEnums::SkinParts top = QS60StyleEnums::SkinParts(center - 4); |
|
253 |
const QS60StyleEnums::SkinParts bottom = QS60StyleEnums::SkinParts(center - 3); |
|
254 |
const QS60StyleEnums::SkinParts left = QS60StyleEnums::SkinParts(center - 2); |
|
255 |
const QS60StyleEnums::SkinParts right = QS60StyleEnums::SkinParts(center - 1); |
|
256 |
||
257 |
// The size of topLeft defines all other sizes |
|
258 |
const QSize cornerSize(partSize(topLeft)); |
|
259 |
// if frame is so small that corners would cover it completely, draw only center piece |
|
260 |
const bool drawOnlyCenter = |
|
261 |
2 * cornerSize.width() + 1 >= size.width() || 2 * cornerSize.height() + 1 >= size.height(); |
|
262 |
||
263 |
const int cornerWidth = cornerSize.width(); |
|
264 |
const int cornerHeight = cornerSize.height(); |
|
265 |
const int rectWidth = size.width(); |
|
266 |
const int rectHeight = size.height(); |
|
267 |
const QRect rect(QPoint(), size); |
|
268 |
||
269 |
const QRect topLeftRect = QRect(rect.topLeft(), cornerSize); |
|
270 |
const QRect topRect = rect.adjusted(cornerWidth, 0, -cornerWidth, -(rectHeight - cornerHeight)); |
|
271 |
const QRect topRightRect = topLeftRect.translated(rectWidth - cornerWidth, 0); |
|
272 |
const QRect rightRect = rect.adjusted(rectWidth - cornerWidth, cornerHeight, 0, -cornerHeight); |
|
273 |
const QRect bottomRightRect = topRightRect.translated(0, rectHeight - cornerHeight); |
|
274 |
const QRect bottomRect = topRect.translated(0, rectHeight - cornerHeight); |
|
275 |
const QRect bottomLeftRect = topLeftRect.translated(0, rectHeight - cornerHeight); |
|
276 |
const QRect leftRect = rightRect.translated(cornerWidth - rectWidth, 0); |
|
277 |
const QRect centerRect = drawOnlyCenter ? rect : rect.adjusted(cornerWidth, cornerWidth, -cornerWidth, -cornerWidth); |
|
278 |
||
279 |
QPixmap result(size); |
|
280 |
result.fill(Qt::transparent); |
|
281 |
QPainter painter(&result); |
|
282 |
||
283 |
#if 0 |
|
284 |
painter.save(); |
|
285 |
painter.setOpacity(.3); |
|
286 |
painter.fillRect(topLeftRect, Qt::red); |
|
287 |
painter.fillRect(topRect, Qt::green); |
|
288 |
painter.fillRect(topRightRect, Qt::blue); |
|
289 |
painter.fillRect(rightRect, Qt::green); |
|
290 |
painter.fillRect(bottomRightRect, Qt::red); |
|
291 |
painter.fillRect(bottomRect, Qt::blue); |
|
292 |
painter.fillRect(bottomLeftRect, Qt::green); |
|
293 |
painter.fillRect(leftRect, Qt::blue); |
|
294 |
painter.fillRect(centerRect, Qt::red); |
|
295 |
painter.restore(); |
|
296 |
#else |
|
297 |
drawPart(topLeft, &painter, topLeftRect, flags); |
|
298 |
drawPart(top, &painter, topRect, flags); |
|
299 |
drawPart(topRight, &painter, topRightRect, flags); |
|
300 |
drawPart(right, &painter, rightRect, flags); |
|
301 |
drawPart(bottomRight, &painter, bottomRightRect, flags); |
|
302 |
drawPart(bottom, &painter, bottomRect, flags); |
|
303 |
drawPart(bottomLeft, &painter, bottomLeftRect, flags); |
|
304 |
drawPart(left, &painter, leftRect, flags); |
|
305 |
drawPart(center, &painter, centerRect, flags); |
|
306 |
#endif |
|
307 |
||
308 |
return result; |
|
309 |
} |
|
310 |
||
311 |
QPixmap QS60StylePrivate::backgroundTexture() |
|
312 |
{ |
|
313 |
if (!m_background) { |
|
314 |
const QSize size = QApplication::desktop()->screen()->size(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
315 |
QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size, 0); |
0 | 316 |
m_background = new QPixmap(background); |
317 |
} |
|
318 |
return *m_background; |
|
319 |
} |
|
320 |
||
321 |
QSize QS60StylePrivate::naviPaneSize() |
|
322 |
{ |
|
323 |
return QSize(0, 0); |
|
324 |
} |
|
325 |
||
326 |
bool QS60StylePrivate::isTouchSupported() |
|
327 |
{ |
|
328 |
#ifdef QT_KEYPAD_NAVIGATION |
|
329 |
return !QApplication::keypadNavigationEnabled(); |
|
330 |
#else |
|
331 |
return true; |
|
332 |
#endif |
|
333 |
} |
|
334 |
||
335 |
bool QS60StylePrivate::isToolBarBackground() |
|
336 |
{ |
|
337 |
return true; |
|
338 |
} |
|
339 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
bool QS60StylePrivate::hasSliderGrooveGraphic() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
343 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
345 |
bool QS60StylePrivate::isSingleClickUi() |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
346 |
{ |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
347 |
return false; |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
348 |
} |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
349 |
|
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
350 |
QFont QS60StylePrivate::s60Font_specific( |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
351 |
QS60StyleEnums::FontCategories fontCategory, |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
352 |
int pointSize, bool resolveFontSize) |
0 | 353 |
{ |
354 |
QFont result; |
|
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
355 |
if (resolveFontSize) |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
356 |
result.setPointSize(pointSize); |
0 | 357 |
switch (fontCategory) { |
358 |
case QS60StyleEnums::FC_Primary: |
|
359 |
result.setBold(true); |
|
360 |
break; |
|
361 |
case QS60StyleEnums::FC_Secondary: |
|
362 |
case QS60StyleEnums::FC_Title: |
|
363 |
case QS60StyleEnums::FC_PrimarySmall: |
|
364 |
case QS60StyleEnums::FC_Digital: |
|
365 |
case QS60StyleEnums::FC_Undefined: |
|
366 |
default: |
|
367 |
break; |
|
368 |
} |
|
369 |
return result; |
|
370 |
} |
|
371 |
||
7
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
372 |
int QS60StylePrivate::currentAnimationFrame(QS60StyleEnums::SkinParts part) |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
373 |
{ |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
374 |
return 0; |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
375 |
} |
f7bc934e204c
5cabc75a39ca2f064f70b40f72ed93c74c4dc19b
eckhart.koppen@nokia.com
parents:
3
diff
changeset
|
376 |
|
0 | 377 |
/*! |
378 |
Constructs a QS60Style object. |
|
379 |
*/ |
|
380 |
QS60Style::QS60Style() |
|
381 |
: QCommonStyle(*new QS60StylePrivate) |
|
382 |
{ |
|
383 |
const QString defaultBlob = QString::fromLatin1(":/trolltech/styles/s60style/images/defaults60theme.blob"); |
|
384 |
if (QFile::exists(defaultBlob)) |
|
385 |
loadS60ThemeFromBlob(defaultBlob); |
|
386 |
} |
|
387 |
||
388 |
Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, enumPartKeys, { |
|
389 |
const int enumIndex = QS60StyleEnums::staticMetaObject.indexOfEnumerator("SkinParts"); |
|
390 |
Q_ASSERT(enumIndex >= 0); |
|
391 |
const QMetaEnum metaEnum = QS60StyleEnums::staticMetaObject.enumerator(enumIndex); |
|
392 |
for (int i = 0; i < metaEnum.keyCount(); ++i) { |
|
393 |
const QString enumKey = QString::fromLatin1(metaEnum.key(i)); |
|
394 |
QString partKey; |
|
395 |
// Following loop does following conversions: "SP_QgnNoteInfo" to "qgn_note_info"... |
|
396 |
for (int charPosition = 3; charPosition < enumKey.length(); charPosition++) { |
|
397 |
if (charPosition > 3 && enumKey[charPosition].isUpper()) |
|
398 |
partKey.append(QChar::fromLatin1('_')); |
|
399 |
partKey.append(enumKey[charPosition].toLower()); |
|
400 |
} |
|
401 |
x->append(partKey); |
|
402 |
} |
|
403 |
}) |
|
404 |
||
405 |
QStringList QS60Style::partKeys() |
|
406 |
{ |
|
407 |
return *enumPartKeys(); |
|
408 |
} |
|
409 |
||
410 |
Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, enumColorListKeys, { |
|
411 |
const int enumIndex = QS60StyleEnums::staticMetaObject.indexOfEnumerator("ColorLists"); |
|
412 |
Q_ASSERT(enumIndex >= 0); |
|
413 |
const QMetaEnum metaEnum = QS60StyleEnums::staticMetaObject.enumerator(enumIndex); |
|
414 |
for (int i = 0; i < metaEnum.keyCount(); i++) { |
|
415 |
const QString enumKey = QString::fromLatin1(metaEnum.key(i)); |
|
416 |
// Following line does following conversions: CL_QsnTextColors to "text"... |
|
417 |
x->append(enumKey.mid(6, enumKey.length() - 12).toLower()); |
|
418 |
} |
|
419 |
}) |
|
420 |
||
421 |
QStringList QS60Style::colorListKeys() |
|
422 |
{ |
|
423 |
return *enumColorListKeys(); |
|
424 |
} |
|
425 |
||
426 |
void QS60Style::setS60Theme(const QHash<QString, QPicture> &parts, |
|
427 |
const QHash<QPair<QString , int>, QColor> &colors) |
|
428 |
{ |
|
429 |
Q_D(QS60Style); |
|
430 |
QS60StyleModeSpecifics::m_partPictures = parts; |
|
431 |
QS60StyleModeSpecifics::m_colors = colors; |
|
432 |
d->clearCaches(QS60StylePrivate::CC_ThemeChange); |
|
433 |
d->setBackgroundTexture(qApp); |
|
434 |
d->setThemePalette(qApp); |
|
435 |
} |
|
436 |
||
437 |
bool QS60Style::loadS60ThemeFromBlob(const QString &blobFile) |
|
438 |
{ |
|
439 |
QHash<QString, QPicture> partPictures; |
|
440 |
QHash<QPair<QString, int>, QColor> colors; |
|
441 |
||
442 |
if (!loadThemeFromBlob(blobFile, partPictures, colors)) |
|
443 |
return false; |
|
444 |
setS60Theme(partPictures, colors); |
|
445 |
return true; |
|
446 |
} |
|
447 |
||
448 |
bool QS60Style::saveS60ThemeToBlob(const QString &blobFile) const |
|
449 |
{ |
|
450 |
return saveThemeToBlob(blobFile, |
|
451 |
QS60StyleModeSpecifics::m_partPictures, QS60StyleModeSpecifics::m_colors); |
|
452 |
} |
|
453 |
||
454 |
QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) |
|
455 |
{ |
|
456 |
Q_UNUSED(targetWidget) |
|
457 |
return QPoint(); |
|
458 |
} |
|
459 |
||
460 |
QT_END_NAMESPACE |
|
461 |
||
462 |
#endif // QT_NO_STYLE_S60 || QT_PLUGIN |