author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 18 | 2f34d5167611 |
child 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@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 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
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 "qcommonstyle.h" |
|
43 |
#include "qcommonstyle_p.h" |
|
44 |
||
45 |
#include <qfile.h> |
|
46 |
#include <qapplication.h> |
|
47 |
#include <qbitmap.h> |
|
48 |
#include <qcache.h> |
|
49 |
#include <qdockwidget.h> |
|
50 |
#include <qdrawutil.h> |
|
51 |
#include <qdialogbuttonbox.h> |
|
52 |
#include <qformlayout.h> |
|
53 |
#include <qgroupbox.h> |
|
54 |
#include <qmath.h> |
|
55 |
#include <qmenu.h> |
|
56 |
#include <qpainter.h> |
|
57 |
#include <qpaintengine.h> |
|
58 |
#include <qpainterpath.h> |
|
59 |
#include <qslider.h> |
|
60 |
#include <qstyleoption.h> |
|
61 |
#include <qtabbar.h> |
|
62 |
#include <qtabwidget.h> |
|
63 |
#include <qtoolbar.h> |
|
64 |
#include <qtoolbutton.h> |
|
65 |
#include <qrubberband.h> |
|
66 |
#include <private/qcommonstylepixmaps_p.h> |
|
67 |
#include <private/qmath_p.h> |
|
68 |
#include <qdebug.h> |
|
69 |
#include <qtextformat.h> |
|
70 |
#include <qwizard.h> |
|
71 |
#include <qtabbar.h> |
|
72 |
#include <qfileinfo.h> |
|
73 |
#include <qdir.h> |
|
74 |
#include <qsettings.h> |
|
75 |
#include <qpixmapcache.h> |
|
76 |
#include <private/qguiplatformplugin_p.h> |
|
77 |
||
78 |
#include <limits.h> |
|
79 |
||
80 |
#ifndef QT_NO_ITEMVIEWS |
|
81 |
# include "private/qtextengine_p.h" |
|
82 |
#endif |
|
83 |
||
84 |
#ifdef Q_WS_X11 |
|
85 |
# include <private/qt_x11_p.h> |
|
86 |
#elif defined(Q_WS_MAC) |
|
87 |
# include <private/qt_cocoa_helpers_mac_p.h> |
|
88 |
#endif |
|
89 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
90 |
#include <private/qstylehelper_p.h> |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
91 |
|
0 | 92 |
QT_BEGIN_NAMESPACE |
93 |
||
94 |
/*! |
|
95 |
\class QCommonStyle |
|
96 |
\brief The QCommonStyle class encapsulates the common Look and Feel of a GUI. |
|
97 |
||
98 |
\ingroup appearance |
|
99 |
||
100 |
This abstract class implements some of the widget's look and feel |
|
101 |
that is common to all GUI styles provided and shipped as part of |
|
102 |
Qt. |
|
103 |
||
104 |
Since QCommonStyle inherits QStyle, all of its functions are fully documented |
|
105 |
in the QStyle documentation. |
|
106 |
\omit |
|
107 |
, although the |
|
108 |
extra functions that QCommonStyle provides, e.g. |
|
109 |
drawComplexControl(), drawControl(), drawPrimitive(), |
|
110 |
hitTestComplexControl(), subControlRect(), sizeFromContents(), and |
|
111 |
subElementRect() are documented here. |
|
112 |
\endomit |
|
113 |
||
114 |
\sa QStyle, QMotifStyle, QWindowsStyle |
|
115 |
*/ |
|
116 |
||
117 |
/*! |
|
118 |
Constructs a QCommonStyle. |
|
119 |
*/ |
|
120 |
QCommonStyle::QCommonStyle() |
|
121 |
: QStyle(*new QCommonStylePrivate) |
|
122 |
{ } |
|
123 |
||
124 |
/*! \internal |
|
125 |
*/ |
|
126 |
QCommonStyle::QCommonStyle(QCommonStylePrivate &dd) |
|
127 |
: QStyle(dd) |
|
128 |
{ } |
|
129 |
||
130 |
/*! |
|
131 |
Destroys the style. |
|
132 |
*/ |
|
133 |
QCommonStyle::~QCommonStyle() |
|
134 |
{ } |
|
135 |
||
136 |
||
137 |
/*! |
|
138 |
\reimp |
|
139 |
*/ |
|
140 |
void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, |
|
141 |
const QWidget *widget) const |
|
142 |
{ |
|
143 |
Q_D(const QCommonStyle); |
|
144 |
switch (pe) { |
|
145 |
case PE_FrameButtonBevel: |
|
146 |
case PE_FrameButtonTool: |
|
147 |
qDrawShadeRect(p, opt->rect, opt->palette, |
|
148 |
opt->state & (State_Sunken | State_On), 1, 0); |
|
149 |
break; |
|
150 |
case PE_PanelButtonCommand: |
|
151 |
case PE_PanelButtonBevel: |
|
152 |
case PE_PanelButtonTool: |
|
153 |
case PE_IndicatorButtonDropDown: |
|
154 |
qDrawShadePanel(p, opt->rect, opt->palette, |
|
155 |
opt->state & (State_Sunken | State_On), 1, |
|
156 |
&opt->palette.brush(QPalette::Button)); |
|
157 |
break; |
|
158 |
case PE_IndicatorViewItemCheck: |
|
159 |
proxy()->drawPrimitive(PE_IndicatorCheckBox, opt, p, widget); |
|
160 |
break; |
|
161 |
case PE_IndicatorCheckBox: |
|
162 |
if (opt->state & State_NoChange) { |
|
163 |
p->setPen(opt->palette.foreground().color()); |
|
164 |
p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); |
|
165 |
p->drawRect(opt->rect); |
|
166 |
p->drawLine(opt->rect.topLeft(), opt->rect.bottomRight()); |
|
167 |
} else { |
|
168 |
qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(), |
|
169 |
opt->palette, opt->state & (State_Sunken | State_On), 1, |
|
170 |
&opt->palette.brush(QPalette::Button)); |
|
171 |
} |
|
172 |
break; |
|
173 |
case PE_IndicatorRadioButton: { |
|
174 |
QRect ir = opt->rect; |
|
175 |
p->setPen(opt->palette.dark().color()); |
|
176 |
p->drawArc(opt->rect, 0, 5760); |
|
177 |
if (opt->state & (State_Sunken | State_On)) { |
|
178 |
ir.adjust(2, 2, -2, -2); |
|
179 |
p->setBrush(opt->palette.foreground()); |
|
180 |
p->drawEllipse(ir); |
|
181 |
} |
|
182 |
break; } |
|
183 |
case PE_FrameFocusRect: |
|
184 |
if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) { |
|
185 |
QColor bg = fropt->backgroundColor; |
|
186 |
QPen oldPen = p->pen(); |
|
187 |
if (bg.isValid()) { |
|
188 |
int h, s, v; |
|
189 |
bg.getHsv(&h, &s, &v); |
|
190 |
if (v >= 128) |
|
191 |
p->setPen(Qt::black); |
|
192 |
else |
|
193 |
p->setPen(Qt::white); |
|
194 |
} else { |
|
195 |
p->setPen(opt->palette.foreground().color()); |
|
196 |
} |
|
197 |
QRect focusRect = opt->rect.adjusted(1, 1, -1, -1); |
|
198 |
p->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive |
|
199 |
p->setPen(oldPen); |
|
200 |
} |
|
201 |
break; |
|
202 |
case PE_IndicatorMenuCheckMark: { |
|
203 |
const int markW = opt->rect.width() > 7 ? 7 : opt->rect.width(); |
|
204 |
const int markH = markW; |
|
205 |
int posX = opt->rect.x() + (opt->rect.width() - markW)/2 + 1; |
|
206 |
int posY = opt->rect.y() + (opt->rect.height() - markH)/2; |
|
207 |
||
208 |
QVector<QLineF> a; |
|
209 |
a.reserve(markH); |
|
210 |
||
211 |
int i, xx, yy; |
|
212 |
xx = posX; |
|
213 |
yy = 3 + posY; |
|
214 |
for (i = 0; i < markW/2; ++i) { |
|
215 |
a << QLineF(xx, yy, xx, yy + 2); |
|
216 |
++xx; |
|
217 |
++yy; |
|
218 |
} |
|
219 |
yy -= 2; |
|
220 |
for (; i < markH; ++i) { |
|
221 |
a << QLineF(xx, yy, xx, yy + 2); |
|
222 |
++xx; |
|
223 |
--yy; |
|
224 |
} |
|
225 |
if (!(opt->state & State_Enabled) && !(opt->state & State_On)) { |
|
226 |
int pnt; |
|
227 |
p->setPen(opt->palette.highlightedText().color()); |
|
228 |
QPoint offset(1, 1); |
|
229 |
for (pnt = 0; pnt < a.size(); ++pnt) |
|
230 |
a[pnt].translate(offset.x(), offset.y()); |
|
231 |
p->drawLines(a); |
|
232 |
for (pnt = 0; pnt < a.size(); ++pnt) |
|
233 |
a[pnt].translate(offset.x(), offset.y()); |
|
234 |
} |
|
235 |
p->setPen(opt->palette.text().color()); |
|
236 |
p->drawLines(a); |
|
237 |
break; } |
|
238 |
case PE_Frame: |
|
239 |
case PE_FrameMenu: |
|
240 |
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { |
|
241 |
if (pe == PE_FrameMenu || (frame->state & State_Sunken) || (frame->state & State_Raised)) { |
|
242 |
qDrawShadePanel(p, frame->rect, frame->palette, frame->state & State_Sunken, |
|
243 |
frame->lineWidth); |
|
244 |
} else { |
|
245 |
qDrawPlainRect(p, frame->rect, frame->palette.foreground().color(), frame->lineWidth); |
|
246 |
} |
|
247 |
} |
|
248 |
break; |
|
249 |
#ifndef QT_NO_TOOLBAR |
|
250 |
case PE_PanelMenuBar: |
|
251 |
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) |
|
252 |
break; |
|
253 |
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)){ |
|
254 |
qDrawShadePanel(p, frame->rect, frame->palette, false, frame->lineWidth, |
|
255 |
&frame->palette.brush(QPalette::Button)); |
|
256 |
||
257 |
} |
|
258 |
else if (const QStyleOptionToolBar *frame = qstyleoption_cast<const QStyleOptionToolBar *>(opt)){ |
|
259 |
qDrawShadePanel(p, frame->rect, frame->palette, false, frame->lineWidth, |
|
260 |
&frame->palette.brush(QPalette::Button)); |
|
261 |
} |
|
262 |
||
263 |
break; |
|
264 |
case PE_PanelMenu: |
|
265 |
break; |
|
266 |
case PE_PanelToolBar: |
|
267 |
break; |
|
268 |
#endif // QT_NO_TOOLBAR |
|
269 |
#ifndef QT_NO_PROGRESSBAR |
|
270 |
case PE_IndicatorProgressChunk: |
|
271 |
{ |
|
272 |
bool vertical = false; |
|
273 |
if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) |
|
274 |
vertical = (pb2->orientation == Qt::Vertical); |
|
275 |
if (!vertical) { |
|
276 |
p->fillRect(opt->rect.x(), opt->rect.y() + 3, opt->rect.width() -2, opt->rect.height() - 6, |
|
277 |
opt->palette.brush(QPalette::Highlight)); |
|
278 |
} else { |
|
279 |
p->fillRect(opt->rect.x() + 2, opt->rect.y(), opt->rect.width() -6, opt->rect.height() - 2, |
|
280 |
opt->palette.brush(QPalette::Highlight)); |
|
281 |
} |
|
282 |
} |
|
283 |
break; |
|
284 |
#endif // QT_NO_PROGRESSBAR |
|
285 |
#ifdef QT3_SUPPORT |
|
286 |
case PE_Q3CheckListController: |
|
287 |
#ifndef QT_NO_IMAGEFORMAT_XPM |
|
288 |
p->drawPixmap(opt->rect.topLeft(), QPixmap(check_list_controller_xpm)); |
|
289 |
#endif |
|
290 |
break; |
|
291 |
case PE_Q3CheckListExclusiveIndicator: |
|
292 |
if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { |
|
293 |
if (lv->items.isEmpty()) |
|
294 |
return; |
|
295 |
int x = lv->rect.x(), |
|
296 |
y = lv->rect.y(); |
|
297 |
#define INTARRLEN(x) sizeof(x)/(sizeof(int)*2) |
|
298 |
static const int pts1[] = { // dark lines |
|
299 |
1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; |
|
300 |
static const int pts2[] = { // black lines |
|
301 |
2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 }; |
|
302 |
static const int pts3[] = { // background lines |
|
303 |
2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 }; |
|
304 |
static const int pts4[] = { // white lines |
|
305 |
2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, |
|
306 |
11,4, 10,3, 10,2 }; |
|
307 |
// static const int pts5[] = { // inner fill |
|
308 |
// 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; |
|
309 |
//QPolygon a; |
|
310 |
||
311 |
if (lv->state & State_Enabled) |
|
312 |
p->setPen(lv->palette.text().color()); |
|
313 |
else |
|
314 |
p->setPen(QPen(lv->viewportPalette.color(QPalette::Disabled, QPalette::Text))); |
|
315 |
QPolygon a(INTARRLEN(pts1), pts1); |
|
316 |
a.translate(x, y); |
|
317 |
//p->setPen(pal.dark()); |
|
318 |
p->drawPolyline(a); |
|
319 |
a.setPoints(INTARRLEN(pts2), pts2); |
|
320 |
a.translate(x, y); |
|
321 |
p->drawPolyline(a); |
|
322 |
a.setPoints(INTARRLEN(pts3), pts3); |
|
323 |
a.translate(x, y); |
|
324 |
// p->setPen(black); |
|
325 |
p->drawPolyline(a); |
|
326 |
a.setPoints(INTARRLEN(pts4), pts4); |
|
327 |
a.translate(x, y); |
|
328 |
// p->setPen(blue); |
|
329 |
p->drawPolyline(a); |
|
330 |
// a.setPoints(INTARRLEN(pts5), pts5); |
|
331 |
// a.translate(x, y); |
|
332 |
// QColor fillColor = isDown() ? g.background() : g.base(); |
|
333 |
// p->setPen(fillColor); |
|
334 |
// p->setBrush(fillColor); |
|
335 |
// p->drawPolygon(a); |
|
336 |
if (opt->state & State_On) { |
|
337 |
p->setPen(Qt::NoPen); |
|
338 |
p->setBrush(opt->palette.text()); |
|
339 |
p->drawRect(x + 5, y + 4, 2, 4); |
|
340 |
p->drawRect(x + 4, y + 5, 4, 2); |
|
341 |
} |
|
342 |
#undef INTARRLEN |
|
343 |
} |
|
344 |
break; |
|
345 |
case PE_Q3CheckListIndicator: |
|
346 |
if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { |
|
347 |
if(lv->items.isEmpty()) |
|
348 |
break; |
|
349 |
QStyleOptionQ3ListViewItem item = lv->items.at(0); |
|
350 |
int x = lv->rect.x(), |
|
351 |
y = lv->rect.y(), |
|
352 |
w = lv->rect.width(), |
|
353 |
h = lv->rect.width(), |
|
354 |
marg = lv->itemMargin; |
|
355 |
||
356 |
if (lv->state & State_Enabled) |
|
357 |
p->setPen(QPen(lv->palette.text().color(), 2)); |
|
358 |
else |
|
359 |
p->setPen(QPen(lv->viewportPalette.color(QPalette::Disabled, QPalette::Text), 2)); |
|
360 |
if (opt->state & State_Selected && !lv->rootIsDecorated |
|
361 |
&& !(item.features & QStyleOptionQ3ListViewItem::ParentControl)) { |
|
362 |
p->fillRect(0, 0, x + marg + w + 4, item.height, |
|
363 |
lv->palette.brush(QPalette::Highlight)); |
|
364 |
if (item.state & State_Enabled) |
|
365 |
p->setPen(QPen(lv->palette.highlightedText().color(), 2)); |
|
366 |
} |
|
367 |
||
368 |
if (lv->state & State_NoChange) |
|
369 |
p->setBrush(lv->palette.brush(QPalette::Button)); |
|
370 |
p->drawRect(x + marg, y + 2, w - 4, h - 4); |
|
371 |
///////////////////// |
|
372 |
++x; |
|
373 |
++y; |
|
374 |
if (lv->state & State_On || lv->state & State_NoChange) { |
|
375 |
QLineF lines[7]; |
|
376 |
int i, |
|
377 |
xx = x + 1 + marg, |
|
378 |
yy = y + 5; |
|
379 |
for (i = 0; i < 3; ++i) { |
|
380 |
lines[i] = QLineF(xx, yy, xx, yy + 2); |
|
381 |
++xx; |
|
382 |
++yy; |
|
383 |
} |
|
384 |
yy -= 2; |
|
385 |
for (i = 3; i < 7; ++i) { |
|
386 |
lines[i] = QLineF(xx, yy, xx, yy + 2); |
|
387 |
++xx; |
|
388 |
--yy; |
|
389 |
} |
|
390 |
p->drawLines(lines, 7); |
|
391 |
} |
|
392 |
} |
|
393 |
break; |
|
394 |
#endif // QT3_SUPPORT |
|
395 |
case PE_IndicatorBranch: { |
|
396 |
int mid_h = opt->rect.x() + opt->rect.width() / 2; |
|
397 |
int mid_v = opt->rect.y() + opt->rect.height() / 2; |
|
398 |
int bef_h = mid_h; |
|
399 |
int bef_v = mid_v; |
|
400 |
int aft_h = mid_h; |
|
401 |
int aft_v = mid_v; |
|
402 |
#ifndef QT_NO_IMAGEFORMAT_XPM |
|
403 |
static const int decoration_size = 9; |
|
404 |
static QPixmap open(tree_branch_open_xpm); |
|
405 |
static QPixmap closed(tree_branch_closed_xpm); |
|
406 |
if (opt->state & State_Children) { |
|
407 |
int delta = decoration_size / 2; |
|
408 |
bef_h -= delta; |
|
409 |
bef_v -= delta; |
|
410 |
aft_h += delta; |
|
411 |
aft_v += delta; |
|
412 |
p->drawPixmap(bef_h, bef_v, opt->state & State_Open ? open : closed); |
|
413 |
} |
|
414 |
#endif // QT_NO_IMAGEFORMAT_XPM |
|
415 |
if (opt->state & State_Item) { |
|
416 |
if (opt->direction == Qt::RightToLeft) |
|
417 |
p->drawLine(opt->rect.left(), mid_v, bef_h, mid_v); |
|
418 |
else |
|
419 |
p->drawLine(aft_h, mid_v, opt->rect.right(), mid_v); |
|
420 |
} |
|
421 |
if (opt->state & State_Sibling) |
|
422 |
p->drawLine(mid_h, aft_v, mid_h, opt->rect.bottom()); |
|
423 |
if (opt->state & (State_Open | State_Children | State_Item | State_Sibling)) |
|
424 |
p->drawLine(mid_h, opt->rect.y(), mid_h, bef_v); |
|
425 |
break; } |
|
426 |
#ifdef QT3_SUPPORT |
|
427 |
case PE_Q3Separator: |
|
428 |
qDrawShadeLine(p, opt->rect.left(), opt->rect.top(), opt->rect.right(), opt->rect.bottom(), |
|
429 |
opt->palette, opt->state & State_Sunken, 1, 0); |
|
430 |
break; |
|
431 |
#endif // QT3_SUPPORT |
|
432 |
case PE_FrameStatusBarItem: |
|
433 |
qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0); |
|
434 |
break; |
|
435 |
case PE_IndicatorHeaderArrow: |
|
436 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
|
437 |
QPen oldPen = p->pen(); |
|
438 |
if (header->sortIndicator & QStyleOptionHeader::SortUp) { |
|
439 |
QPolygon pa(3); |
|
440 |
p->setPen(QPen(opt->palette.light(), 0)); |
|
441 |
p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(), |
|
442 |
opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()); |
|
443 |
p->setPen(QPen(opt->palette.dark(), 0)); |
|
444 |
pa.setPoint(0, opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()); |
|
445 |
pa.setPoint(1, opt->rect.x(), opt->rect.y()); |
|
446 |
pa.setPoint(2, opt->rect.x() + opt->rect.width(), opt->rect.y()); |
|
447 |
p->drawPolyline(pa); |
|
448 |
} else if (header->sortIndicator & QStyleOptionHeader::SortDown) { |
|
449 |
QPolygon pa(3); |
|
450 |
p->setPen(QPen(opt->palette.light(), 0)); |
|
451 |
pa.setPoint(0, opt->rect.x(), opt->rect.y() + opt->rect.height()); |
|
452 |
pa.setPoint(1, opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height()); |
|
453 |
pa.setPoint(2, opt->rect.x() + opt->rect.width() / 2, opt->rect.y()); |
|
454 |
p->drawPolyline(pa); |
|
455 |
p->setPen(QPen(opt->palette.dark(), 0)); |
|
456 |
p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(), |
|
457 |
opt->rect.x() + opt->rect.width() / 2, opt->rect.y()); |
|
458 |
} |
|
459 |
p->setPen(oldPen); |
|
460 |
} |
|
461 |
break; |
|
462 |
#ifndef QT_NO_TABBAR |
|
463 |
case PE_FrameTabBarBase: |
|
464 |
if (const QStyleOptionTabBarBase *tbb |
|
465 |
= qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) { |
|
466 |
p->save(); |
|
467 |
switch (tbb->shape) { |
|
468 |
case QTabBar::RoundedNorth: |
|
469 |
case QTabBar::TriangularNorth: |
|
470 |
p->setPen(QPen(tbb->palette.light(), 0)); |
|
471 |
p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight()); |
|
472 |
break; |
|
473 |
case QTabBar::RoundedWest: |
|
474 |
case QTabBar::TriangularWest: |
|
475 |
p->setPen(QPen(tbb->palette.light(), 0)); |
|
476 |
p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft()); |
|
477 |
break; |
|
478 |
case QTabBar::RoundedSouth: |
|
479 |
case QTabBar::TriangularSouth: |
|
480 |
p->setPen(QPen(tbb->palette.shadow(), 0)); |
|
481 |
p->drawLine(tbb->rect.left(), tbb->rect.bottom(), |
|
482 |
tbb->rect.right(), tbb->rect.bottom()); |
|
483 |
p->setPen(QPen(tbb->palette.dark(), 0)); |
|
484 |
p->drawLine(tbb->rect.left(), tbb->rect.bottom() - 1, |
|
485 |
tbb->rect.right() - 1, tbb->rect.bottom() - 1); |
|
486 |
break; |
|
487 |
case QTabBar::RoundedEast: |
|
488 |
case QTabBar::TriangularEast: |
|
489 |
p->setPen(QPen(tbb->palette.dark(), 0)); |
|
490 |
p->drawLine(tbb->rect.topRight(), tbb->rect.bottomRight()); |
|
491 |
break; |
|
492 |
} |
|
493 |
p->restore(); |
|
494 |
} |
|
495 |
break; |
|
496 |
case PE_IndicatorTabClose: { |
|
497 |
if (d->tabBarcloseButtonIcon.isNull()) { |
|
498 |
d->tabBarcloseButtonIcon.addPixmap(QPixmap( |
|
499 |
QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-closetab-16.png")), |
|
500 |
QIcon::Normal, QIcon::Off); |
|
501 |
d->tabBarcloseButtonIcon.addPixmap(QPixmap( |
|
502 |
QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-closetab-down-16.png")), |
|
503 |
QIcon::Normal, QIcon::On); |
|
504 |
d->tabBarcloseButtonIcon.addPixmap(QPixmap( |
|
505 |
QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-closetab-hover-16.png")), |
|
506 |
QIcon::Active, QIcon::Off); |
|
507 |
} |
|
508 |
||
509 |
int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize); |
|
510 |
QIcon::Mode mode = opt->state & State_Enabled ? |
|
511 |
(opt->state & State_Raised ? QIcon::Active : QIcon::Normal) |
|
512 |
: QIcon::Disabled; |
|
513 |
if (!(opt->state & State_Raised) |
|
514 |
&& !(opt->state & State_Sunken) |
|
515 |
&& !(opt->state & QStyle::State_Selected)) |
|
516 |
mode = QIcon::Disabled; |
|
517 |
||
518 |
QIcon::State state = opt->state & State_Sunken ? QIcon::On : QIcon::Off; |
|
519 |
QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(size, mode, state); |
|
520 |
proxy()->drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap); |
|
521 |
break; |
|
522 |
} |
|
523 |
#endif // QT_NO_TABBAR |
|
524 |
case PE_FrameTabWidget: |
|
525 |
case PE_FrameWindow: |
|
526 |
qDrawWinPanel(p, opt->rect, opt->palette, false, 0); |
|
527 |
break; |
|
528 |
case PE_FrameLineEdit: |
|
529 |
proxy()->drawPrimitive(PE_Frame, opt, p, widget); |
|
530 |
break; |
|
531 |
#ifndef QT_NO_GROUPBOX |
|
532 |
case PE_FrameGroupBox: |
|
533 |
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { |
|
534 |
const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt); |
|
535 |
if (frame2 && (frame2->features & QStyleOptionFrameV2::Flat)) { |
|
536 |
QRect fr = frame->rect; |
|
537 |
QPoint p1(fr.x(), fr.y() + 1); |
|
538 |
QPoint p2(fr.x() + fr.width(), p1.y()); |
|
539 |
qDrawShadeLine(p, p1, p2, frame->palette, true, |
|
540 |
frame->lineWidth, frame->midLineWidth); |
|
541 |
} else { |
|
542 |
qDrawShadeRect(p, frame->rect.x(), frame->rect.y(), frame->rect.width(), |
|
543 |
frame->rect.height(), frame->palette, true, |
|
544 |
frame->lineWidth, frame->midLineWidth); |
|
545 |
} |
|
546 |
} |
|
547 |
break; |
|
548 |
#endif // QT_NO_GROUPBOX |
|
549 |
#ifndef QT_NO_DOCKWIDGET |
|
550 |
case PE_FrameDockWidget: |
|
551 |
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { |
|
552 |
int lw = frame->lineWidth; |
|
553 |
if (lw <= 0) |
|
554 |
lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth); |
|
555 |
||
556 |
qDrawShadePanel(p, frame->rect, frame->palette, false, lw); |
|
557 |
} |
|
558 |
break; |
|
559 |
#endif // QT_NO_DOCKWIDGET |
|
560 |
#ifndef QT_NO_TOOLBAR |
|
561 |
case PE_IndicatorToolBarHandle: |
|
562 |
p->save(); |
|
563 |
p->translate(opt->rect.x(), opt->rect.y()); |
|
564 |
if (opt->state & State_Horizontal) { |
|
565 |
int x = opt->rect.width() / 3; |
|
566 |
if (opt->direction == Qt::RightToLeft) |
|
567 |
x -= 2; |
|
568 |
if (opt->rect.height() > 4) { |
|
569 |
qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, |
|
570 |
opt->palette, false, 1, 0); |
|
571 |
qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4, |
|
572 |
opt->palette, false, 1, 0); |
|
573 |
} |
|
574 |
} else { |
|
575 |
if (opt->rect.width() > 4) { |
|
576 |
int y = opt->rect.height() / 3; |
|
577 |
qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3, |
|
578 |
opt->palette, false, 1, 0); |
|
579 |
qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3, |
|
580 |
opt->palette, false, 1, 0); |
|
581 |
} |
|
582 |
} |
|
583 |
p->restore(); |
|
584 |
break; |
|
585 |
case PE_Q3DockWindowSeparator: |
|
586 |
proxy()->drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget); |
|
587 |
break; |
|
588 |
case PE_IndicatorToolBarSeparator: |
|
589 |
{ |
|
590 |
QPoint p1, p2; |
|
591 |
if (opt->state & State_Horizontal) { |
|
592 |
p1 = QPoint(opt->rect.width()/2, 0); |
|
593 |
p2 = QPoint(p1.x(), opt->rect.height()); |
|
594 |
} else { |
|
595 |
p1 = QPoint(0, opt->rect.height()/2); |
|
596 |
p2 = QPoint(opt->rect.width(), p1.y()); |
|
597 |
} |
|
598 |
qDrawShadeLine(p, p1, p2, opt->palette, 1, 1, 0); |
|
599 |
break; |
|
600 |
} |
|
601 |
#endif // QT_NO_TOOLBAR |
|
602 |
#ifndef QT_NO_SPINBOX |
|
603 |
case PE_IndicatorSpinPlus: |
|
604 |
case PE_IndicatorSpinMinus: { |
|
605 |
QRect r = opt->rect; |
|
606 |
int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); |
|
607 |
QRect br = r.adjusted(fw, fw, -fw, -fw); |
|
608 |
||
609 |
int offset = (opt->state & State_Sunken) ? 1 : 0; |
|
610 |
int step = (br.width() + 4) / 5; |
|
611 |
p->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2, |
|
612 |
br.width(), step, |
|
613 |
opt->palette.buttonText()); |
|
614 |
if (pe == PE_IndicatorSpinPlus) |
|
615 |
p->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset, |
|
616 |
step, br.height(), |
|
617 |
opt->palette.buttonText()); |
|
618 |
||
619 |
break; } |
|
620 |
case PE_IndicatorSpinUp: |
|
621 |
case PE_IndicatorSpinDown: { |
|
622 |
QRect r = opt->rect; |
|
623 |
int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); |
|
624 |
// QRect br = r.adjusted(fw, fw, -fw, -fw); |
|
625 |
int x = r.x(), y = r.y(), w = r.width(), h = r.height(); |
|
626 |
int sw = w-4; |
|
627 |
if (sw < 3) |
|
628 |
break; |
|
629 |
else if (!(sw & 1)) |
|
630 |
sw--; |
|
631 |
sw -= (sw / 7) * 2; // Empty border |
|
632 |
int sh = sw/2 + 2; // Must have empty row at foot of arrow |
|
633 |
||
634 |
int sx = x + w / 2 - sw / 2; |
|
635 |
int sy = y + h / 2 - sh / 2; |
|
636 |
||
637 |
if (pe == PE_IndicatorSpinUp && fw) |
|
638 |
--sy; |
|
639 |
||
640 |
QPolygon a; |
|
641 |
if (pe == PE_IndicatorSpinDown) |
|
642 |
a.setPoints(3, 0, 1, sw-1, 1, sh-2, sh-1); |
|
643 |
else |
|
644 |
a.setPoints(3, 0, sh-1, sw-1, sh-1, sh-2, 1); |
|
645 |
int bsx = 0; |
|
646 |
int bsy = 0; |
|
647 |
if (opt->state & State_Sunken) { |
|
648 |
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); |
|
649 |
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); |
|
650 |
} |
|
651 |
p->save(); |
|
652 |
p->translate(sx + bsx, sy + bsy); |
|
653 |
p->setPen(opt->palette.buttonText().color()); |
|
654 |
p->setBrush(opt->palette.buttonText()); |
|
655 |
p->drawPolygon(a); |
|
656 |
p->restore(); |
|
657 |
break; } |
|
658 |
#endif // QT_NO_SPINBOX |
|
659 |
case PE_PanelTipLabel: { |
|
660 |
QBrush oldBrush = p->brush(); |
|
661 |
QPen oldPen = p->pen(); |
|
662 |
p->setPen(QPen(opt->palette.toolTipText(), 0)); |
|
663 |
p->setBrush(opt->palette.toolTipBase()); |
|
664 |
p->drawRect(opt->rect.adjusted(0, 0, -1, -1)); |
|
665 |
p->setPen(oldPen); |
|
666 |
p->setBrush(oldBrush); |
|
667 |
break; |
|
668 |
} |
|
669 |
#ifndef QT_NO_TABBAR |
|
670 |
case PE_IndicatorTabTear: |
|
671 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { |
|
672 |
bool rtl = tab->direction == Qt::RightToLeft; |
|
673 |
QRect rect = tab->rect; |
|
674 |
QPainterPath path; |
|
675 |
||
676 |
rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3)); |
|
677 |
rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2)); |
|
678 |
||
679 |
path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top())); |
|
680 |
int count = 4; |
|
681 |
for(int jags = 1; jags <= count; ++jags, rtl = !rtl) |
|
682 |
path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count)); |
|
683 |
||
684 |
p->setPen(QPen(tab->palette.light(), qreal(.8))); |
|
685 |
p->setBrush(tab->palette.background()); |
|
686 |
p->setRenderHint(QPainter::Antialiasing); |
|
687 |
p->drawPath(path); |
|
688 |
} |
|
689 |
break; |
|
690 |
#endif // QT_NO_TABBAR |
|
691 |
#ifndef QT_NO_LINEEDIT |
|
692 |
case PE_PanelLineEdit: |
|
693 |
if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { |
|
694 |
p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth), |
|
695 |
panel->palette.brush(QPalette::Base)); |
|
696 |
||
697 |
if (panel->lineWidth > 0) |
|
698 |
proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget); |
|
699 |
} |
|
700 |
break; |
|
701 |
#endif // QT_NO_LINEEDIT |
|
702 |
#ifndef QT_NO_COLUMNVIEW |
|
703 |
case PE_IndicatorColumnViewArrow: { |
|
704 |
if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { |
|
705 |
bool reverse = (viewOpt->direction == Qt::RightToLeft); |
|
706 |
p->save(); |
|
707 |
QPainterPath path; |
|
708 |
int x = viewOpt->rect.x() + 1; |
|
709 |
int offset = (viewOpt->rect.height() / 3); |
|
710 |
int height = (viewOpt->rect.height()) - offset * 2; |
|
711 |
if (height % 2 == 1) |
|
712 |
--height; |
|
713 |
int x2 = x + height - 1; |
|
714 |
if (reverse) { |
|
715 |
x = viewOpt->rect.x() + viewOpt->rect.width() - 1; |
|
716 |
x2 = x - height + 1; |
|
717 |
} |
|
718 |
path.moveTo(x, viewOpt->rect.y() + offset); |
|
719 |
path.lineTo(x, viewOpt->rect.y() + offset + height); |
|
720 |
path.lineTo(x2, viewOpt->rect.y() + offset+height/2); |
|
721 |
path.closeSubpath(); |
|
722 |
if (viewOpt->state & QStyle::State_Selected ) { |
|
723 |
if (viewOpt->showDecorationSelected) { |
|
724 |
QColor color = viewOpt->palette.color(QPalette::Active, QPalette::HighlightedText); |
|
725 |
p->setPen(color); |
|
726 |
p->setBrush(color); |
|
727 |
} else { |
|
728 |
QColor color = viewOpt->palette.color(QPalette::Active, QPalette::WindowText); |
|
729 |
p->setPen(color); |
|
730 |
p->setBrush(color); |
|
731 |
} |
|
732 |
||
733 |
} else { |
|
734 |
QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Mid); |
|
735 |
p->setPen(color); |
|
736 |
p->setBrush(color); |
|
737 |
} |
|
738 |
p->drawPath(path); |
|
739 |
||
740 |
// draw the vertical and top triangle line |
|
741 |
if (!(viewOpt->state & QStyle::State_Selected)) { |
|
742 |
QPainterPath lines; |
|
743 |
lines.moveTo(x, viewOpt->rect.y() + offset); |
|
744 |
lines.lineTo(x, viewOpt->rect.y() + offset + height); |
|
745 |
lines.moveTo(x, viewOpt->rect.y() + offset); |
|
746 |
lines.lineTo(x2, viewOpt->rect.y() + offset+height/2); |
|
747 |
QColor color = viewOpt->palette.color(QPalette::Active, QPalette::Dark); |
|
748 |
p->setPen(color); |
|
749 |
p->drawPath(lines); |
|
750 |
} |
|
751 |
p->restore(); |
|
752 |
} |
|
753 |
break; } |
|
754 |
#endif //QT_NO_COLUMNVIEW |
|
755 |
case PE_IndicatorItemViewItemDrop: { |
|
756 |
QRect rect = opt->rect; |
|
757 |
if (opt->rect.height() == 0) |
|
758 |
p->drawLine(rect.topLeft(), rect.topRight()); |
|
759 |
else |
|
760 |
p->drawRect(rect); |
|
761 |
break; } |
|
762 |
#ifndef QT_NO_ITEMVIEWS |
|
763 |
case PE_PanelItemViewRow: |
|
764 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
765 |
QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled |
|
766 |
? QPalette::Normal : QPalette::Disabled; |
|
767 |
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) |
|
768 |
cg = QPalette::Inactive; |
|
769 |
||
770 |
if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt, widget)) |
|
771 |
p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight)); |
|
772 |
else if (vopt->features & QStyleOptionViewItemV2::Alternate) |
|
773 |
p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); |
|
774 |
} |
|
775 |
break; |
|
776 |
case PE_PanelItemViewItem: |
|
777 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
778 |
QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled |
|
779 |
? QPalette::Normal : QPalette::Disabled; |
|
780 |
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) |
|
781 |
cg = QPalette::Inactive; |
|
782 |
||
783 |
if (vopt->showDecorationSelected && (vopt->state & QStyle::State_Selected)) { |
|
784 |
p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight)); |
|
785 |
} else { |
|
786 |
if (vopt->backgroundBrush.style() != Qt::NoBrush) { |
|
787 |
QPointF oldBO = p->brushOrigin(); |
|
788 |
p->setBrushOrigin(vopt->rect.topLeft()); |
|
789 |
p->fillRect(vopt->rect, vopt->backgroundBrush); |
|
790 |
p->setBrushOrigin(oldBO); |
|
791 |
} |
|
792 |
||
793 |
if (vopt->state & QStyle::State_Selected) { |
|
794 |
QRect textRect = subElementRect(QStyle::SE_ItemViewItemText, opt, widget); |
|
795 |
p->fillRect(textRect, vopt->palette.brush(cg, QPalette::Highlight)); |
|
796 |
} |
|
797 |
} |
|
798 |
} |
|
799 |
break; |
|
800 |
#endif //QT_NO_ITEMVIEWS |
|
801 |
case PE_PanelScrollAreaCorner: { |
|
802 |
const QBrush brush(opt->palette.brush(QPalette::Window)); |
|
803 |
p->fillRect(opt->rect, brush); |
|
804 |
} break; |
|
805 |
default: |
|
806 |
break; |
|
807 |
} |
|
808 |
} |
|
809 |
||
810 |
#ifndef QT_NO_TOOLBUTTON |
|
811 |
static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbutton, |
|
812 |
const QRect &rect, QPainter *painter, const QWidget *widget = 0) |
|
813 |
{ |
|
814 |
QStyle::PrimitiveElement pe; |
|
815 |
switch (toolbutton->arrowType) { |
|
816 |
case Qt::LeftArrow: |
|
817 |
pe = QStyle::PE_IndicatorArrowLeft; |
|
818 |
break; |
|
819 |
case Qt::RightArrow: |
|
820 |
pe = QStyle::PE_IndicatorArrowRight; |
|
821 |
break; |
|
822 |
case Qt::UpArrow: |
|
823 |
pe = QStyle::PE_IndicatorArrowUp; |
|
824 |
break; |
|
825 |
case Qt::DownArrow: |
|
826 |
pe = QStyle::PE_IndicatorArrowDown; |
|
827 |
break; |
|
828 |
default: |
|
829 |
return; |
|
830 |
} |
|
831 |
QStyleOption arrowOpt; |
|
832 |
arrowOpt.rect = rect; |
|
833 |
arrowOpt.palette = toolbutton->palette; |
|
834 |
arrowOpt.state = toolbutton->state; |
|
835 |
style->drawPrimitive(pe, &arrowOpt, painter, widget); |
|
836 |
} |
|
837 |
#endif // QT_NO_TOOLBUTTON |
|
838 |
||
839 |
#ifndef QT_NO_ITEMVIEWS |
|
840 |
||
841 |
QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, int role) const |
|
842 |
{ |
|
843 |
Q_Q(const QCommonStyle); |
|
844 |
||
845 |
const QWidget *widget = option->widget; |
|
846 |
switch (role) { |
|
847 |
case Qt::CheckStateRole: |
|
848 |
if (option->features & QStyleOptionViewItemV2::HasCheckIndicator) |
|
849 |
return QSize(q->pixelMetric(QStyle::PM_IndicatorWidth, option, widget), |
|
850 |
q->pixelMetric(QStyle::PM_IndicatorHeight, option, widget)); |
|
851 |
break; |
|
852 |
case Qt::DisplayRole: |
|
853 |
if (option->features & QStyleOptionViewItemV2::HasDisplay) { |
|
854 |
QTextOption textOption; |
|
855 |
textOption.setWrapMode(QTextOption::WordWrap); |
|
856 |
QTextLayout textLayout; |
|
857 |
textLayout.setTextOption(textOption); |
|
858 |
textLayout.setFont(option->font); |
|
859 |
textLayout.setText(option->text); |
|
860 |
const bool wrapText = option->features & QStyleOptionViewItemV2::WrapText; |
|
861 |
const int textMargin = q->pixelMetric(QStyle::PM_FocusFrameHMargin, option, widget) + 1; |
|
862 |
QRect bounds = option->rect; |
|
863 |
switch (option->decorationPosition) { |
|
864 |
case QStyleOptionViewItem::Left: |
|
865 |
case QStyleOptionViewItem::Right: |
|
866 |
bounds.setWidth(wrapText && bounds.isValid() ? bounds.width() - 2 * textMargin : QFIXED_MAX); |
|
867 |
break; |
|
868 |
case QStyleOptionViewItem::Top: |
|
869 |
case QStyleOptionViewItem::Bottom: |
|
870 |
bounds.setWidth(wrapText ? option->decorationSize.width() : QFIXED_MAX); |
|
871 |
break; |
|
872 |
default: |
|
873 |
break; |
|
874 |
} |
|
875 |
||
876 |
qreal height = 0, widthUsed = 0; |
|
877 |
textLayout.beginLayout(); |
|
878 |
while (true) { |
|
879 |
QTextLine line = textLayout.createLine(); |
|
880 |
if (!line.isValid()) |
|
881 |
break; |
|
882 |
line.setLineWidth(bounds.width()); |
|
883 |
line.setPosition(QPointF(0, height)); |
|
884 |
height += line.height(); |
|
885 |
widthUsed = qMax(widthUsed, line.naturalTextWidth()); |
|
886 |
} |
|
887 |
textLayout.endLayout(); |
|
888 |
const QSize size(qCeil(widthUsed), qCeil(height)); |
|
889 |
return QSize(size.width() + 2 * textMargin, size.height()); |
|
890 |
} |
|
891 |
break; |
|
892 |
case Qt::DecorationRole: |
|
893 |
if (option->features & QStyleOptionViewItemV2::HasDecoration) { |
|
894 |
return option->decorationSize; |
|
895 |
} |
|
896 |
break; |
|
897 |
default: |
|
898 |
break; |
|
899 |
} |
|
900 |
||
901 |
return QSize(0, 0); |
|
902 |
} |
|
903 |
||
904 |
static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth) |
|
905 |
{ |
|
906 |
qreal height = 0; |
|
907 |
qreal widthUsed = 0; |
|
908 |
textLayout.beginLayout(); |
|
909 |
while (true) { |
|
910 |
QTextLine line = textLayout.createLine(); |
|
911 |
if (!line.isValid()) |
|
912 |
break; |
|
913 |
line.setLineWidth(lineWidth); |
|
914 |
line.setPosition(QPointF(0, height)); |
|
915 |
height += line.height(); |
|
916 |
widthUsed = qMax(widthUsed, line.naturalTextWidth()); |
|
917 |
} |
|
918 |
textLayout.endLayout(); |
|
919 |
return QSizeF(widthUsed, height); |
|
920 |
} |
|
921 |
||
922 |
void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItemV4 *option, const QRect &rect) const |
|
923 |
{ |
|
924 |
Q_Q(const QCommonStyle); |
|
925 |
const QWidget *widget = option->widget; |
|
926 |
const int textMargin = q->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1; |
|
927 |
||
928 |
QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding |
|
929 |
const bool wrapText = option->features & QStyleOptionViewItemV2::WrapText; |
|
930 |
QTextOption textOption; |
|
931 |
textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap); |
|
932 |
textOption.setTextDirection(option->direction); |
|
933 |
textOption.setAlignment(QStyle::visualAlignment(option->direction, option->displayAlignment)); |
|
934 |
QTextLayout textLayout; |
|
935 |
textLayout.setTextOption(textOption); |
|
936 |
textLayout.setFont(option->font); |
|
937 |
textLayout.setText(option->text); |
|
938 |
||
939 |
QSizeF textLayoutSize = viewItemTextLayout(textLayout, textRect.width()); |
|
940 |
||
941 |
QString elidedText; |
|
942 |
qreal height = 0; |
|
943 |
qreal width = 0; |
|
944 |
int elidedIndex = -1; |
|
945 |
const int lineCount = textLayout.lineCount(); |
|
946 |
for (int j = 0; j < lineCount; ++j) { |
|
947 |
const QTextLine line = textLayout.lineAt(j); |
|
948 |
if (j + 1 <= lineCount - 1) { |
|
949 |
const QTextLine nextLine = textLayout.lineAt(j + 1); |
|
950 |
if ((nextLine.y() + nextLine.height()) > textRect.height()) { |
|
951 |
int start = line.textStart(); |
|
952 |
int length = line.textLength() + nextLine.textLength(); |
|
953 |
const QStackTextEngine engine(textLayout.text().mid(start, length), option->font); |
|
954 |
elidedText = engine.elidedText(option->textElideMode, textRect.width()); |
|
955 |
height += line.height(); |
|
956 |
width = textRect.width(); |
|
957 |
elidedIndex = j; |
|
958 |
break; |
|
959 |
} |
|
960 |
} |
|
961 |
if (line.naturalTextWidth() > textRect.width()) { |
|
962 |
int start = line.textStart(); |
|
963 |
int length = line.textLength(); |
|
964 |
const QStackTextEngine engine(textLayout.text().mid(start, length), option->font); |
|
965 |
elidedText = engine.elidedText(option->textElideMode, textRect.width()); |
|
966 |
height += line.height(); |
|
967 |
width = textRect.width(); |
|
968 |
elidedIndex = j; |
|
969 |
break; |
|
970 |
} |
|
971 |
width = qMax<qreal>(width, line.width()); |
|
972 |
height += line.height(); |
|
973 |
} |
|
974 |
||
975 |
const QRect layoutRect = QStyle::alignedRect(option->direction, option->displayAlignment, |
|
976 |
QSize(int(width), int(height)), textRect); |
|
977 |
const QPointF position = layoutRect.topLeft(); |
|
978 |
for (int i = 0; i < lineCount; ++i) { |
|
979 |
const QTextLine line = textLayout.lineAt(i); |
|
980 |
if (i == elidedIndex) { |
|
981 |
qreal x = position.x() + line.x(); |
|
982 |
qreal y = position.y() + line.y() + line.ascent(); |
|
983 |
p->save(); |
|
984 |
p->setFont(option->font); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
985 |
p->drawText(QPointF(x, y), elidedText); |
0 | 986 |
p->restore(); |
987 |
break; |
|
988 |
} |
|
989 |
line.draw(p, position); |
|
990 |
} |
|
991 |
} |
|
992 |
||
993 |
/*! \internal |
|
994 |
compute the position for the different component of an item (pixmap, text, checkbox) |
|
995 |
||
996 |
Set sizehint to false to layout the elements inside opt->rect. Set sizehint to true to ignore |
|
997 |
opt->rect and return rectangles in infinite space |
|
998 |
||
999 |
Code duplicated in QItemDelegate::doLayout |
|
1000 |
*/ |
|
1001 |
void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRect *checkRect, |
|
1002 |
QRect *pixmapRect, QRect *textRect, bool sizehint) const |
|
1003 |
{ |
|
1004 |
Q_Q(const QCommonStyle); |
|
1005 |
Q_ASSERT(checkRect && pixmapRect && textRect); |
|
1006 |
*pixmapRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::DecorationRole)); |
|
1007 |
*textRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::DisplayRole)); |
|
1008 |
*checkRect = QRect(QPoint(0, 0), viewItemSize(opt, Qt::CheckStateRole)); |
|
1009 |
||
1010 |
const QWidget *widget = opt->widget; |
|
1011 |
const bool hasCheck = checkRect->isValid(); |
|
1012 |
const bool hasPixmap = pixmapRect->isValid(); |
|
1013 |
const bool hasText = textRect->isValid(); |
|
1014 |
const int textMargin = hasText ? q->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget) + 1 : 0; |
|
1015 |
const int pixmapMargin = hasPixmap ? q->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget) + 1 : 0; |
|
1016 |
const int checkMargin = hasCheck ? q->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget) + 1 : 0; |
|
1017 |
int x = opt->rect.left(); |
|
1018 |
int y = opt->rect.top(); |
|
1019 |
int w, h; |
|
1020 |
||
1021 |
if (textRect->height() == 0 && (!hasPixmap || !sizehint)) { |
|
1022 |
//if there is no text, we still want to have a decent height for the item sizeHint and the editor size |
|
1023 |
textRect->setHeight(opt->fontMetrics.height()); |
|
1024 |
} |
|
1025 |
||
1026 |
QSize pm(0, 0); |
|
1027 |
if (hasPixmap) { |
|
1028 |
pm = pixmapRect->size(); |
|
1029 |
pm.rwidth() += 2 * pixmapMargin; |
|
1030 |
} |
|
1031 |
if (sizehint) { |
|
1032 |
h = qMax(checkRect->height(), qMax(textRect->height(), pm.height())); |
|
1033 |
if (opt->decorationPosition == QStyleOptionViewItem::Left |
|
1034 |
|| opt->decorationPosition == QStyleOptionViewItem::Right) { |
|
1035 |
w = textRect->width() + pm.width(); |
|
1036 |
} else { |
|
1037 |
w = qMax(textRect->width(), pm.width()); |
|
1038 |
} |
|
1039 |
} else { |
|
1040 |
w = opt->rect.width(); |
|
1041 |
h = opt->rect.height(); |
|
1042 |
} |
|
1043 |
||
1044 |
int cw = 0; |
|
1045 |
QRect check; |
|
1046 |
if (hasCheck) { |
|
1047 |
cw = checkRect->width() + 2 * checkMargin; |
|
1048 |
if (sizehint) w += cw; |
|
1049 |
if (opt->direction == Qt::RightToLeft) { |
|
1050 |
check.setRect(x + w - cw, y, cw, h); |
|
1051 |
} else { |
|
1052 |
check.setRect(x, y, cw, h); |
|
1053 |
} |
|
1054 |
} |
|
1055 |
||
1056 |
QRect display; |
|
1057 |
QRect decoration; |
|
1058 |
switch (opt->decorationPosition) { |
|
1059 |
case QStyleOptionViewItem::Top: { |
|
1060 |
if (hasPixmap) |
|
1061 |
pm.setHeight(pm.height() + pixmapMargin); // add space |
|
1062 |
h = sizehint ? textRect->height() : h - pm.height(); |
|
1063 |
||
1064 |
if (opt->direction == Qt::RightToLeft) { |
|
1065 |
decoration.setRect(x, y, w - cw, pm.height()); |
|
1066 |
display.setRect(x, y + pm.height(), w - cw, h); |
|
1067 |
} else { |
|
1068 |
decoration.setRect(x + cw, y, w - cw, pm.height()); |
|
1069 |
display.setRect(x + cw, y + pm.height(), w - cw, h); |
|
1070 |
} |
|
1071 |
break; } |
|
1072 |
case QStyleOptionViewItem::Bottom: { |
|
1073 |
if (hasText) |
|
1074 |
textRect->setHeight(textRect->height() + textMargin); // add space |
|
1075 |
h = sizehint ? textRect->height() + pm.height() : h; |
|
1076 |
||
1077 |
if (opt->direction == Qt::RightToLeft) { |
|
1078 |
display.setRect(x, y, w - cw, textRect->height()); |
|
1079 |
decoration.setRect(x, y + textRect->height(), w - cw, h - textRect->height()); |
|
1080 |
} else { |
|
1081 |
display.setRect(x + cw, y, w - cw, textRect->height()); |
|
1082 |
decoration.setRect(x + cw, y + textRect->height(), w - cw, h - textRect->height()); |
|
1083 |
} |
|
1084 |
break; } |
|
1085 |
case QStyleOptionViewItem::Left: { |
|
1086 |
if (opt->direction == Qt::LeftToRight) { |
|
1087 |
decoration.setRect(x + cw, y, pm.width(), h); |
|
1088 |
display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h); |
|
1089 |
} else { |
|
1090 |
display.setRect(x, y, w - pm.width() - cw, h); |
|
1091 |
decoration.setRect(display.right() + 1, y, pm.width(), h); |
|
1092 |
} |
|
1093 |
break; } |
|
1094 |
case QStyleOptionViewItem::Right: { |
|
1095 |
if (opt->direction == Qt::LeftToRight) { |
|
1096 |
display.setRect(x + cw, y, w - pm.width() - cw, h); |
|
1097 |
decoration.setRect(display.right() + 1, y, pm.width(), h); |
|
1098 |
} else { |
|
1099 |
decoration.setRect(x, y, pm.width(), h); |
|
1100 |
display.setRect(decoration.right() + 1, y, w - pm.width() - cw, h); |
|
1101 |
} |
|
1102 |
break; } |
|
1103 |
default: |
|
1104 |
qWarning("doLayout: decoration position is invalid"); |
|
1105 |
decoration = *pixmapRect; |
|
1106 |
break; |
|
1107 |
} |
|
1108 |
||
1109 |
if (!sizehint) { // we only need to do the internal layout if we are going to paint |
|
1110 |
*checkRect = QStyle::alignedRect(opt->direction, Qt::AlignCenter, |
|
1111 |
checkRect->size(), check); |
|
1112 |
*pixmapRect = QStyle::alignedRect(opt->direction, opt->decorationAlignment, |
|
1113 |
pixmapRect->size(), decoration); |
|
1114 |
// the text takes up all available space, unless the decoration is not shown as selected |
|
1115 |
if (opt->showDecorationSelected) |
|
1116 |
*textRect = display; |
|
1117 |
else |
|
1118 |
*textRect = QStyle::alignedRect(opt->direction, opt->displayAlignment, |
|
1119 |
textRect->size().boundedTo(display.size()), display); |
|
1120 |
} else { |
|
1121 |
*checkRect = check; |
|
1122 |
*pixmapRect = decoration; |
|
1123 |
*textRect = display; |
|
1124 |
} |
|
1125 |
} |
|
1126 |
#endif // QT_NO_ITEMVIEWS |
|
1127 |
||
1128 |
||
1129 |
#ifndef QT_NO_TABBAR |
|
1130 |
/*! \internal |
|
1131 |
Compute the textRect and the pixmapRect from the opt rect |
|
1132 |
||
1133 |
Uses the same computation than in QTabBar::tabSizeHint |
|
1134 |
*/ |
|
1135 |
void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const |
|
1136 |
{ |
|
1137 |
Q_ASSERT(textRect); |
|
1138 |
Q_ASSERT(iconRect); |
|
1139 |
QRect tr = opt->rect; |
|
1140 |
bool verticalTabs = opt->shape == QTabBar::RoundedEast |
|
1141 |
|| opt->shape == QTabBar::RoundedWest |
|
1142 |
|| opt->shape == QTabBar::TriangularEast |
|
1143 |
|| opt->shape == QTabBar::TriangularWest; |
|
1144 |
if (verticalTabs) |
|
1145 |
tr.setRect(0, 0, tr.height(), tr.width()); //0, 0 as we will have a translate transform |
|
1146 |
||
1147 |
int verticalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftVertical, opt, widget); |
|
1148 |
int horizontalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, opt, widget); |
|
1149 |
int hpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; |
|
1150 |
int vpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabVSpace, opt, widget) / 2; |
|
1151 |
if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth) |
|
1152 |
verticalShift = -verticalShift; |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1153 |
tr.adjust(hpadding, verticalShift - vpadding, horizontalShift - hpadding, vpadding); |
0 | 1154 |
bool selected = opt->state & QStyle::State_Selected; |
1155 |
if (selected) { |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1156 |
tr.setTop(tr.top() - verticalShift); |
0 | 1157 |
tr.setRight(tr.right() - horizontalShift); |
1158 |
} |
|
1159 |
||
1160 |
// left widget |
|
1161 |
if (!opt->leftButtonSize.isEmpty()) { |
|
1162 |
tr.setLeft(tr.left() + 4 + |
|
1163 |
(verticalTabs ? opt->leftButtonSize.height() : opt->leftButtonSize.width())); |
|
1164 |
} |
|
1165 |
// right widget |
|
1166 |
if (!opt->rightButtonSize.isEmpty()) { |
|
1167 |
tr.setRight(tr.right() - 4 - |
|
1168 |
(verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width())); |
|
1169 |
} |
|
1170 |
||
1171 |
// icon |
|
1172 |
if (!opt->icon.isNull()) { |
|
1173 |
QSize iconSize = opt->iconSize; |
|
1174 |
if (!iconSize.isValid()) { |
|
1175 |
int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize); |
|
1176 |
iconSize = QSize(iconExtent, iconExtent); |
|
1177 |
} |
|
1178 |
QSize tabIconSize = opt->icon.actualSize(iconSize, |
|
1179 |
(opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled, |
|
1180 |
(opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off ); |
|
1181 |
||
1182 |
*iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2, |
|
1183 |
tabIconSize.width(), tabIconSize .height()); |
|
1184 |
if (!verticalTabs) |
|
1185 |
*iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); |
|
1186 |
tr.setLeft(tr.left() + tabIconSize.width() + 4); |
|
1187 |
} |
|
1188 |
||
1189 |
if (!verticalTabs) |
|
1190 |
tr = proxyStyle->visualRect(opt->direction, opt->rect, tr); |
|
1191 |
||
1192 |
*textRect = tr; |
|
1193 |
} |
|
1194 |
#endif //QT_NO_TABBAR |
|
1195 |
||
1196 |
||
1197 |
/*! |
|
1198 |
\reimp |
|
1199 |
*/ |
|
1200 |
void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, |
|
1201 |
QPainter *p, const QWidget *widget) const |
|
1202 |
{ |
|
1203 |
Q_D(const QCommonStyle); |
|
1204 |
switch (element) { |
|
1205 |
||
1206 |
case CE_PushButton: |
|
1207 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
1208 |
proxy()->drawControl(CE_PushButtonBevel, btn, p, widget); |
|
1209 |
QStyleOptionButton subopt = *btn; |
|
1210 |
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); |
|
1211 |
proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget); |
|
1212 |
if (btn->state & State_HasFocus) { |
|
1213 |
QStyleOptionFocusRect fropt; |
|
1214 |
fropt.QStyleOption::operator=(*btn); |
|
1215 |
fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); |
|
1216 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); |
|
1217 |
} |
|
1218 |
} |
|
1219 |
break; |
|
1220 |
case CE_PushButtonBevel: |
|
1221 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
1222 |
QRect br = btn->rect; |
|
1223 |
int dbi = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); |
|
1224 |
if (btn->features & QStyleOptionButton::DefaultButton) |
|
1225 |
proxy()->drawPrimitive(PE_FrameDefaultButton, opt, p, widget); |
|
1226 |
if (btn->features & QStyleOptionButton::AutoDefaultButton) |
|
1227 |
br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi); |
|
1228 |
if (!(btn->features & (QStyleOptionButton::Flat | QStyleOptionButton::CommandLinkButton)) |
|
1229 |
|| btn->state & (State_Sunken | State_On) |
|
1230 |
|| (btn->features & QStyleOptionButton::CommandLinkButton && btn->state & State_MouseOver)) { |
|
1231 |
QStyleOptionButton tmpBtn = *btn; |
|
1232 |
tmpBtn.rect = br; |
|
1233 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p, widget); |
|
1234 |
} |
|
1235 |
if (btn->features & QStyleOptionButton::HasMenu) { |
|
1236 |
int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget); |
|
1237 |
QRect ir = btn->rect; |
|
1238 |
QStyleOptionButton newBtn = *btn; |
|
1239 |
newBtn.rect = QRect(ir.right() - mbi + 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6); |
|
1240 |
proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); |
|
1241 |
} |
|
1242 |
} |
|
1243 |
break; |
|
1244 |
case CE_PushButtonLabel: |
|
1245 |
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
1246 |
QRect textRect = button->rect; |
|
1247 |
uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; |
|
1248 |
if (!proxy()->styleHint(SH_UnderlineShortcut, button, widget)) |
|
1249 |
tf |= Qt::TextHideMnemonic; |
|
1250 |
||
1251 |
if (!button->icon.isNull()) { |
|
1252 |
//Center both icon and text |
|
1253 |
QRect iconRect; |
|
1254 |
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; |
|
1255 |
if (mode == QIcon::Normal && button->state & State_HasFocus) |
|
1256 |
mode = QIcon::Active; |
|
1257 |
QIcon::State state = QIcon::Off; |
|
1258 |
if (button->state & State_On) |
|
1259 |
state = QIcon::On; |
|
1260 |
||
1261 |
QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); |
|
1262 |
int labelWidth = pixmap.width(); |
|
1263 |
int labelHeight = pixmap.height(); |
|
1264 |
int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint() |
|
1265 |
int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); |
|
1266 |
if (!button->text.isEmpty()) |
|
1267 |
labelWidth += (textWidth + iconSpacing); |
|
1268 |
||
1269 |
iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, |
|
1270 |
textRect.y() + (textRect.height() - labelHeight) / 2, |
|
1271 |
pixmap.width(), pixmap.height()); |
|
1272 |
||
1273 |
iconRect = visualRect(button->direction, textRect, iconRect); |
|
1274 |
||
1275 |
tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead |
|
1276 |
||
1277 |
if (button->direction == Qt::RightToLeft) |
|
1278 |
textRect.setRight(iconRect.left() - iconSpacing); |
|
1279 |
else |
|
1280 |
textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing); |
|
1281 |
||
1282 |
if (button->state & (State_On | State_Sunken)) |
|
1283 |
iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget), |
|
1284 |
proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget)); |
|
1285 |
p->drawPixmap(iconRect, pixmap); |
|
1286 |
} else { |
|
1287 |
tf |= Qt::AlignHCenter; |
|
1288 |
} |
|
1289 |
if (button->state & (State_On | State_Sunken)) |
|
1290 |
textRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget), |
|
1291 |
proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget)); |
|
1292 |
||
1293 |
if (button->features & QStyleOptionButton::HasMenu) { |
|
1294 |
int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget); |
|
1295 |
if (button->direction == Qt::LeftToRight) |
|
1296 |
textRect = textRect.adjusted(0, 0, -indicatorSize, 0); |
|
1297 |
else |
|
1298 |
textRect = textRect.adjusted(indicatorSize, 0, 0, 0); |
|
1299 |
} |
|
1300 |
proxy()->drawItemText(p, textRect, tf, button->palette, (button->state & State_Enabled), |
|
1301 |
button->text, QPalette::ButtonText); |
|
1302 |
} |
|
1303 |
break; |
|
1304 |
case CE_RadioButton: |
|
1305 |
case CE_CheckBox: |
|
1306 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
1307 |
bool isRadio = (element == CE_RadioButton); |
|
1308 |
QStyleOptionButton subopt = *btn; |
|
1309 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator |
|
1310 |
: SE_CheckBoxIndicator, btn, widget); |
|
1311 |
proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, |
|
1312 |
&subopt, p, widget); |
|
1313 |
subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents |
|
1314 |
: SE_CheckBoxContents, btn, widget); |
|
1315 |
proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); |
|
1316 |
if (btn->state & State_HasFocus) { |
|
1317 |
QStyleOptionFocusRect fropt; |
|
1318 |
fropt.QStyleOption::operator=(*btn); |
|
1319 |
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect |
|
1320 |
: SE_CheckBoxFocusRect, btn, widget); |
|
1321 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); |
|
1322 |
} |
|
1323 |
} |
|
1324 |
break; |
|
1325 |
case CE_RadioButtonLabel: |
|
1326 |
case CE_CheckBoxLabel: |
|
1327 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
1328 |
uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter); |
|
1329 |
||
1330 |
if (!proxy()->styleHint(SH_UnderlineShortcut, btn, widget)) |
|
1331 |
alignment |= Qt::TextHideMnemonic; |
|
1332 |
QPixmap pix; |
|
1333 |
QRect textRect = btn->rect; |
|
1334 |
if (!btn->icon.isNull()) { |
|
1335 |
pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled); |
|
1336 |
proxy()->drawItemPixmap(p, btn->rect, alignment, pix); |
|
1337 |
if (btn->direction == Qt::RightToLeft) |
|
1338 |
textRect.setRight(textRect.right() - btn->iconSize.width() - 4); |
|
1339 |
else |
|
1340 |
textRect.setLeft(textRect.left() + btn->iconSize.width() + 4); |
|
1341 |
} |
|
1342 |
if (!btn->text.isEmpty()){ |
|
1343 |
proxy()->drawItemText(p, textRect, alignment | Qt::TextShowMnemonic, |
|
1344 |
btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText); |
|
1345 |
} |
|
1346 |
} |
|
1347 |
break; |
|
1348 |
#ifndef QT_NO_MENU |
|
1349 |
case CE_MenuScroller: { |
|
1350 |
p->fillRect(opt->rect, opt->palette.background()); |
|
1351 |
QStyleOption arrowOpt = *opt; |
|
1352 |
arrowOpt.state |= State_Enabled; |
|
1353 |
proxy()->drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp), |
|
1354 |
&arrowOpt, p, widget); |
|
1355 |
break; } |
|
1356 |
case CE_MenuTearoff: |
|
1357 |
if (opt->state & State_Selected) |
|
1358 |
p->fillRect(opt->rect, opt->palette.brush(QPalette::Highlight)); |
|
1359 |
else |
|
1360 |
p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); |
|
1361 |
p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine)); |
|
1362 |
p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2 - 1, |
|
1363 |
opt->rect.x() + opt->rect.width() - 4, |
|
1364 |
opt->rect.y() + opt->rect.height() / 2 - 1); |
|
1365 |
p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine)); |
|
1366 |
p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2, |
|
1367 |
opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2); |
|
1368 |
break; |
|
1369 |
#endif // QT_NO_MENU |
|
1370 |
#ifndef QT_NO_MENUBAR |
|
1371 |
case CE_MenuBarItem: |
|
1372 |
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
|
1373 |
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip |
|
1374 |
| Qt::TextSingleLine; |
|
1375 |
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) |
|
1376 |
alignment |= Qt::TextHideMnemonic; |
|
1377 |
QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
|
1378 |
if (!pix.isNull()) |
|
1379 |
proxy()->drawItemPixmap(p,mbi->rect, alignment, pix); |
|
1380 |
else |
|
1381 |
proxy()->drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, |
|
1382 |
mbi->text, QPalette::ButtonText); |
|
1383 |
} |
|
1384 |
break; |
|
1385 |
case CE_MenuBarEmptyArea: |
|
1386 |
if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground)) |
|
1387 |
p->eraseRect(opt->rect); |
|
1388 |
break; |
|
1389 |
#endif // QT_NO_MENUBAR |
|
1390 |
#ifndef QT_NO_PROGRESSBAR |
|
1391 |
case CE_ProgressBar: |
|
1392 |
if (const QStyleOptionProgressBar *pb |
|
1393 |
= qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { |
|
1394 |
QStyleOptionProgressBarV2 subopt = *pb; |
|
1395 |
subopt.rect = subElementRect(SE_ProgressBarGroove, pb, widget); |
|
1396 |
proxy()->drawControl(CE_ProgressBarGroove, &subopt, p, widget); |
|
1397 |
subopt.rect = subElementRect(SE_ProgressBarContents, pb, widget); |
|
1398 |
proxy()->drawControl(CE_ProgressBarContents, &subopt, p, widget); |
|
1399 |
if (pb->textVisible) { |
|
1400 |
subopt.rect = subElementRect(SE_ProgressBarLabel, pb, widget); |
|
1401 |
proxy()->drawControl(CE_ProgressBarLabel, &subopt, p, widget); |
|
1402 |
} |
|
1403 |
} |
|
1404 |
break; |
|
1405 |
case CE_ProgressBarGroove: |
|
1406 |
qDrawShadePanel(p, opt->rect, opt->palette, true, 1, |
|
1407 |
&opt->palette.brush(QPalette::Window)); |
|
1408 |
break; |
|
1409 |
case CE_ProgressBarLabel: |
|
1410 |
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { |
|
1411 |
bool vertical = false; |
|
1412 |
if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) { |
|
1413 |
vertical = (pb2->orientation == Qt::Vertical); |
|
1414 |
} |
|
1415 |
if (!vertical) { |
|
1416 |
QPalette::ColorRole textRole = QPalette::NoRole; |
|
1417 |
if ((pb->textAlignment & Qt::AlignCenter) && pb->textVisible |
|
1418 |
&& ((qint64(pb->progress) - qint64(pb->minimum)) * 2 >= (qint64(pb->maximum) - qint64(pb->minimum)))) { |
|
1419 |
textRole = QPalette::HighlightedText; |
|
1420 |
//Draw text shadow, This will increase readability when the background of same color |
|
1421 |
QRect shadowRect(pb->rect); |
|
1422 |
shadowRect.translate(1,1); |
|
1423 |
QColor shadowColor = (pb->palette.color(textRole).value() <= 128) |
|
1424 |
? QColor(255,255,255,160) : QColor(0,0,0,160); |
|
1425 |
QPalette shadowPalette = pb->palette; |
|
1426 |
shadowPalette.setColor(textRole, shadowColor); |
|
1427 |
proxy()->drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette, |
|
1428 |
pb->state & State_Enabled, pb->text, textRole); |
|
1429 |
} |
|
1430 |
proxy()->drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette, |
|
1431 |
pb->state & State_Enabled, pb->text, textRole); |
|
1432 |
} |
|
1433 |
} |
|
1434 |
break; |
|
1435 |
case CE_ProgressBarContents: |
|
1436 |
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { |
|
1437 |
||
1438 |
QRect rect = pb->rect; |
|
1439 |
bool vertical = false; |
|
1440 |
bool inverted = false; |
|
1441 |
qint64 minimum = qint64(pb->minimum); |
|
1442 |
qint64 maximum = qint64(pb->maximum); |
|
1443 |
qint64 progress = qint64(pb->progress); |
|
1444 |
||
1445 |
// Get extra style options if version 2 |
|
1446 |
const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt); |
|
1447 |
if (pb2) { |
|
1448 |
vertical = (pb2->orientation == Qt::Vertical); |
|
1449 |
inverted = pb2->invertedAppearance; |
|
1450 |
} |
|
1451 |
QMatrix m; |
|
1452 |
||
1453 |
if (vertical) { |
|
1454 |
rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height |
|
1455 |
m.rotate(90); |
|
1456 |
m.translate(0, -(rect.height() + rect.y()*2)); |
|
1457 |
} |
|
1458 |
||
1459 |
QPalette pal2 = pb->palette; |
|
1460 |
// Correct the highlight color if it is the same as the background |
|
1461 |
if (pal2.highlight() == pal2.background()) |
|
1462 |
pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active, |
|
1463 |
QPalette::Highlight)); |
|
1464 |
bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical); |
|
1465 |
if (inverted) |
|
1466 |
reverse = !reverse; |
|
1467 |
int w = rect.width(); |
|
1468 |
if (pb->minimum == 0 && pb->maximum == 0) { |
|
1469 |
// draw busy indicator |
|
1470 |
int x = (progress - minimum) % (w * 2); |
|
1471 |
if (x > w) |
|
1472 |
x = 2 * w - x; |
|
1473 |
x = reverse ? rect.right() - x : x + rect.x(); |
|
1474 |
p->setPen(QPen(pal2.highlight().color(), 4)); |
|
1475 |
p->drawLine(x, rect.y(), x, rect.height()); |
|
1476 |
} else { |
|
1477 |
const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget); |
|
1478 |
if (!unit_width) |
|
1479 |
return; |
|
1480 |
||
1481 |
int u; |
|
1482 |
if (unit_width > 1) |
|
1483 |
u = ((rect.width() + unit_width) / unit_width); |
|
1484 |
else |
|
1485 |
u = w / unit_width; |
|
1486 |
qint64 p_v = progress - minimum; |
|
1487 |
qint64 t_s = (maximum - minimum) ? (maximum - minimum) : qint64(1); |
|
1488 |
||
1489 |
if (u > 0 && p_v >= INT_MAX / u && t_s >= u) { |
|
1490 |
// scale down to something usable. |
|
1491 |
p_v /= u; |
|
1492 |
t_s /= u; |
|
1493 |
} |
|
1494 |
||
1495 |
// nu < tnu, if last chunk is only a partial chunk |
|
1496 |
int tnu, nu; |
|
1497 |
tnu = nu = p_v * u / t_s; |
|
1498 |
||
1499 |
if (nu * unit_width > w) |
|
1500 |
--nu; |
|
1501 |
||
1502 |
// Draw nu units out of a possible u of unit_width |
|
1503 |
// width, each a rectangle bordered by background |
|
1504 |
// color, all in a sunken panel with a percentage text |
|
1505 |
// display at the end. |
|
1506 |
int x = 0; |
|
1507 |
int x0 = reverse ? rect.right() - ((unit_width > 1) ? unit_width : 0) |
|
1508 |
: rect.x(); |
|
1509 |
||
1510 |
QStyleOptionProgressBarV2 pbBits = *pb; |
|
1511 |
pbBits.rect = rect; |
|
1512 |
pbBits.palette = pal2; |
|
1513 |
int myY = pbBits.rect.y(); |
|
1514 |
int myHeight = pbBits.rect.height(); |
|
1515 |
pbBits.state = State_None; |
|
1516 |
for (int i = 0; i < nu; ++i) { |
|
1517 |
pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); |
|
1518 |
pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); |
|
1519 |
proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); |
|
1520 |
x += reverse ? -unit_width : unit_width; |
|
1521 |
} |
|
1522 |
||
1523 |
// Draw the last partial chunk to fill up the |
|
1524 |
// progress bar entirely |
|
1525 |
if (nu < tnu) { |
|
1526 |
int pixels_left = w - (nu * unit_width); |
|
1527 |
int offset = reverse ? x0 + x + unit_width-pixels_left : x0 + x; |
|
1528 |
pbBits.rect.setRect(offset, myY, pixels_left, myHeight); |
|
1529 |
pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); |
|
1530 |
proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); |
|
1531 |
} |
|
1532 |
} |
|
1533 |
} |
|
1534 |
break; |
|
1535 |
#endif // QT_NO_PROGRESSBAR |
|
1536 |
case CE_HeaderLabel: |
|
1537 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
|
1538 |
QRect rect = header->rect; |
|
1539 |
if (!header->icon.isNull()) { |
|
1540 |
QPixmap pixmap |
|
1541 |
= header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); |
|
1542 |
int pixw = pixmap.width(); |
|
1543 |
||
1544 |
QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size(), rect); |
|
1545 |
QRect inter = aligned.intersected(rect); |
|
1546 |
p->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height()); |
|
1547 |
||
1548 |
if (header->direction == Qt::LeftToRight) |
|
1549 |
rect.setLeft(rect.left() + pixw + 2); |
|
1550 |
else |
|
1551 |
rect.setRight(rect.right() - pixw - 2); |
|
1552 |
} |
|
1553 |
if (header->state & QStyle::State_On) { |
|
1554 |
QFont fnt = p->font(); |
|
1555 |
fnt.setBold(true); |
|
1556 |
p->setFont(fnt); |
|
1557 |
} |
|
1558 |
proxy()->drawItemText(p, rect, header->textAlignment, header->palette, |
|
1559 |
(header->state & State_Enabled), header->text, QPalette::ButtonText); |
|
1560 |
} |
|
1561 |
break; |
|
1562 |
#ifndef QT_NO_TOOLBUTTON |
|
1563 |
case CE_ToolButtonLabel: |
|
1564 |
if (const QStyleOptionToolButton *toolbutton |
|
1565 |
= qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { |
|
1566 |
QRect rect = toolbutton->rect; |
|
1567 |
int shiftX = 0; |
|
1568 |
int shiftY = 0; |
|
1569 |
if (toolbutton->state & (State_Sunken | State_On)) { |
|
1570 |
shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget); |
|
1571 |
shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget); |
|
1572 |
} |
|
1573 |
// Arrow type always overrules and is always shown |
|
1574 |
bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow; |
|
1575 |
if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty()) |
|
1576 |
|| toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) { |
|
1577 |
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; |
|
1578 |
if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) |
|
1579 |
alignment |= Qt::TextHideMnemonic; |
|
1580 |
rect.translate(shiftX, shiftY); |
|
1581 |
p->setFont(toolbutton->font); |
|
1582 |
proxy()->drawItemText(p, rect, alignment, toolbutton->palette, |
|
1583 |
opt->state & State_Enabled, toolbutton->text, |
|
1584 |
QPalette::ButtonText); |
|
1585 |
} else { |
|
1586 |
QPixmap pm; |
|
1587 |
QSize pmSize = toolbutton->iconSize; |
|
1588 |
if (!toolbutton->icon.isNull()) { |
|
1589 |
QIcon::State state = toolbutton->state & State_On ? QIcon::On : QIcon::Off; |
|
1590 |
QIcon::Mode mode; |
|
1591 |
if (!(toolbutton->state & State_Enabled)) |
|
1592 |
mode = QIcon::Disabled; |
|
1593 |
else if ((opt->state & State_MouseOver) && (opt->state & State_AutoRaise)) |
|
1594 |
mode = QIcon::Active; |
|
1595 |
else |
|
1596 |
mode = QIcon::Normal; |
|
1597 |
pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize), |
|
1598 |
mode, state); |
|
1599 |
pmSize = pm.size(); |
|
1600 |
} |
|
1601 |
||
1602 |
if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) { |
|
1603 |
p->setFont(toolbutton->font); |
|
1604 |
QRect pr = rect, |
|
1605 |
tr = rect; |
|
1606 |
int alignment = Qt::TextShowMnemonic; |
|
1607 |
if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) |
|
1608 |
alignment |= Qt::TextHideMnemonic; |
|
1609 |
||
1610 |
if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { |
|
1611 |
pr.setHeight(pmSize.height() + 6); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1612 |
tr.adjust(0, pr.height() - 1, 0, -2); |
0 | 1613 |
pr.translate(shiftX, shiftY); |
1614 |
if (!hasArrow) { |
|
1615 |
proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pm); |
|
1616 |
} else { |
|
1617 |
drawArrow(this, toolbutton, pr, p, widget); |
|
1618 |
} |
|
1619 |
alignment |= Qt::AlignCenter; |
|
1620 |
} else { |
|
1621 |
pr.setWidth(pmSize.width() + 8); |
|
1622 |
tr.adjust(pr.width(), 0, 0, 0); |
|
1623 |
pr.translate(shiftX, shiftY); |
|
1624 |
if (!hasArrow) { |
|
1625 |
proxy()->drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm); |
|
1626 |
} else { |
|
1627 |
drawArrow(this, toolbutton, pr, p, widget); |
|
1628 |
} |
|
1629 |
alignment |= Qt::AlignLeft | Qt::AlignVCenter; |
|
1630 |
} |
|
1631 |
tr.translate(shiftX, shiftY); |
|
1632 |
proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette, |
|
1633 |
toolbutton->state & State_Enabled, toolbutton->text, |
|
1634 |
QPalette::ButtonText); |
|
1635 |
} else { |
|
1636 |
rect.translate(shiftX, shiftY); |
|
1637 |
if (hasArrow) { |
|
1638 |
drawArrow(this, toolbutton, rect, p, widget); |
|
1639 |
} else { |
|
1640 |
proxy()->drawItemPixmap(p, rect, Qt::AlignCenter, pm); |
|
1641 |
} |
|
1642 |
} |
|
1643 |
} |
|
1644 |
} |
|
1645 |
break; |
|
1646 |
#endif // QT_NO_TOOLBUTTON |
|
1647 |
#ifndef QT_NO_TOOLBOX |
|
1648 |
case CE_ToolBoxTab: |
|
1649 |
if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { |
|
1650 |
proxy()->drawControl(CE_ToolBoxTabShape, tb, p, widget); |
|
1651 |
proxy()->drawControl(CE_ToolBoxTabLabel, tb, p, widget); |
|
1652 |
} |
|
1653 |
break; |
|
1654 |
case CE_ToolBoxTabShape: |
|
1655 |
if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { |
|
1656 |
int d = 20 + tb->rect.height() - 3; |
|
1657 |
QPolygon a(7); |
|
1658 |
if (tb->direction != Qt::RightToLeft) { |
|
1659 |
a.setPoint(0, -1, tb->rect.height() + 1); |
|
1660 |
a.setPoint(1, -1, 1); |
|
1661 |
a.setPoint(2, tb->rect.width() - d, 1); |
|
1662 |
a.setPoint(3, tb->rect.width() - 20, tb->rect.height() - 2); |
|
1663 |
a.setPoint(4, tb->rect.width() - 1, tb->rect.height() - 2); |
|
1664 |
a.setPoint(5, tb->rect.width() - 1, tb->rect.height() + 1); |
|
1665 |
a.setPoint(6, -1, tb->rect.height() + 1); |
|
1666 |
} else { |
|
1667 |
a.setPoint(0, tb->rect.width(), tb->rect.height() + 1); |
|
1668 |
a.setPoint(1, tb->rect.width(), 1); |
|
1669 |
a.setPoint(2, d - 1, 1); |
|
1670 |
a.setPoint(3, 20 - 1, tb->rect.height() - 2); |
|
1671 |
a.setPoint(4, 0, tb->rect.height() - 2); |
|
1672 |
a.setPoint(5, 0, tb->rect.height() + 1); |
|
1673 |
a.setPoint(6, tb->rect.width(), tb->rect.height() + 1); |
|
1674 |
} |
|
1675 |
||
1676 |
p->setPen(tb->palette.mid().color().darker(150)); |
|
1677 |
p->drawPolygon(a); |
|
1678 |
p->setPen(tb->palette.light().color()); |
|
1679 |
if (tb->direction != Qt::RightToLeft) { |
|
1680 |
p->drawLine(0, 2, tb->rect.width() - d, 2); |
|
1681 |
p->drawLine(tb->rect.width() - d - 1, 2, tb->rect.width() - 21, tb->rect.height() - 1); |
|
1682 |
p->drawLine(tb->rect.width() - 20, tb->rect.height() - 1, |
|
1683 |
tb->rect.width(), tb->rect.height() - 1); |
|
1684 |
} else { |
|
1685 |
p->drawLine(tb->rect.width() - 1, 2, d - 1, 2); |
|
1686 |
p->drawLine(d, 2, 20, tb->rect.height() - 1); |
|
1687 |
p->drawLine(19, tb->rect.height() - 1, |
|
1688 |
-1, tb->rect.height() - 1); |
|
1689 |
} |
|
1690 |
p->setBrush(Qt::NoBrush); |
|
1691 |
} |
|
1692 |
break; |
|
1693 |
#endif // QT_NO_TOOLBOX |
|
1694 |
#ifndef QT_NO_TABBAR |
|
1695 |
case CE_TabBarTab: |
|
1696 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { |
|
1697 |
proxy()->drawControl(CE_TabBarTabShape, tab, p, widget); |
|
1698 |
proxy()->drawControl(CE_TabBarTabLabel, tab, p, widget); |
|
1699 |
} |
|
1700 |
break; |
|
1701 |
case CE_TabBarTabShape: |
|
1702 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { |
|
1703 |
p->save(); |
|
1704 |
||
1705 |
QRect rect(tab->rect); |
|
1706 |
bool selected = tab->state & State_Selected; |
|
1707 |
bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; |
|
1708 |
int tabOverlap = onlyOne ? 0 : proxy()->pixelMetric(PM_TabBarTabOverlap, opt, widget); |
|
1709 |
||
1710 |
if (!selected) { |
|
1711 |
switch (tab->shape) { |
|
1712 |
case QTabBar::TriangularNorth: |
|
1713 |
rect.adjust(0, 0, 0, -tabOverlap); |
|
1714 |
if(!selected) |
|
1715 |
rect.adjust(1, 1, -1, 0); |
|
1716 |
break; |
|
1717 |
case QTabBar::TriangularSouth: |
|
1718 |
rect.adjust(0, tabOverlap, 0, 0); |
|
1719 |
if(!selected) |
|
1720 |
rect.adjust(1, 0, -1, -1); |
|
1721 |
break; |
|
1722 |
case QTabBar::TriangularEast: |
|
1723 |
rect.adjust(tabOverlap, 0, 0, 0); |
|
1724 |
if(!selected) |
|
1725 |
rect.adjust(0, 1, -1, -1); |
|
1726 |
break; |
|
1727 |
case QTabBar::TriangularWest: |
|
1728 |
rect.adjust(0, 0, -tabOverlap, 0); |
|
1729 |
if(!selected) |
|
1730 |
rect.adjust(1, 1, 0, -1); |
|
1731 |
break; |
|
1732 |
default: |
|
1733 |
break; |
|
1734 |
} |
|
1735 |
} |
|
1736 |
||
1737 |
p->setPen(QPen(tab->palette.foreground(), 0)); |
|
1738 |
if (selected) { |
|
1739 |
p->setBrush(tab->palette.base()); |
|
1740 |
} else { |
|
1741 |
if (widget && widget->parentWidget()) |
|
1742 |
p->setBrush(widget->parentWidget()->palette().background()); |
|
1743 |
else |
|
1744 |
p->setBrush(tab->palette.background()); |
|
1745 |
} |
|
1746 |
||
1747 |
int y; |
|
1748 |
int x; |
|
1749 |
QPolygon a(10); |
|
1750 |
switch (tab->shape) { |
|
1751 |
case QTabBar::TriangularNorth: |
|
1752 |
case QTabBar::TriangularSouth: { |
|
1753 |
a.setPoint(0, 0, -1); |
|
1754 |
a.setPoint(1, 0, 0); |
|
1755 |
y = rect.height() - 2; |
|
1756 |
x = y / 3; |
|
1757 |
a.setPoint(2, x++, y - 1); |
|
1758 |
++x; |
|
1759 |
a.setPoint(3, x++, y++); |
|
1760 |
a.setPoint(4, x, y); |
|
1761 |
||
1762 |
int i; |
|
1763 |
int right = rect.width() - 1; |
|
1764 |
for (i = 0; i < 5; ++i) |
|
1765 |
a.setPoint(9 - i, right - a.point(i).x(), a.point(i).y()); |
|
1766 |
if (tab->shape == QTabBar::TriangularNorth) |
|
1767 |
for (i = 0; i < 10; ++i) |
|
1768 |
a.setPoint(i, a.point(i).x(), rect.height() - 1 - a.point(i).y()); |
|
1769 |
||
1770 |
a.translate(rect.left(), rect.top()); |
|
1771 |
p->setRenderHint(QPainter::Antialiasing); |
|
1772 |
p->translate(0, 0.5); |
|
1773 |
||
1774 |
QPainterPath path; |
|
1775 |
path.addPolygon(a); |
|
1776 |
p->drawPath(path); |
|
1777 |
break; } |
|
1778 |
case QTabBar::TriangularEast: |
|
1779 |
case QTabBar::TriangularWest: { |
|
1780 |
a.setPoint(0, -1, 0); |
|
1781 |
a.setPoint(1, 0, 0); |
|
1782 |
x = rect.width() - 2; |
|
1783 |
y = x / 3; |
|
1784 |
a.setPoint(2, x - 1, y++); |
|
1785 |
++y; |
|
1786 |
a.setPoint(3, x++, y++); |
|
1787 |
a.setPoint(4, x, y); |
|
1788 |
int i; |
|
1789 |
int bottom = rect.height() - 1; |
|
1790 |
for (i = 0; i < 5; ++i) |
|
1791 |
a.setPoint(9 - i, a.point(i).x(), bottom - a.point(i).y()); |
|
1792 |
if (tab->shape == QTabBar::TriangularWest) |
|
1793 |
for (i = 0; i < 10; ++i) |
|
1794 |
a.setPoint(i, rect.width() - 1 - a.point(i).x(), a.point(i).y()); |
|
1795 |
a.translate(rect.left(), rect.top()); |
|
1796 |
p->setRenderHint(QPainter::Antialiasing); |
|
1797 |
p->translate(0.5, 0); |
|
1798 |
QPainterPath path; |
|
1799 |
path.addPolygon(a); |
|
1800 |
p->drawPath(path); |
|
1801 |
break; } |
|
1802 |
default: |
|
1803 |
break; |
|
1804 |
} |
|
1805 |
p->restore(); |
|
1806 |
} |
|
1807 |
break; |
|
1808 |
case CE_ToolBoxTabLabel: |
|
1809 |
if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { |
|
1810 |
bool enabled = tb->state & State_Enabled; |
|
1811 |
bool selected = tb->state & State_Selected; |
|
1812 |
QPixmap pm = tb->icon.pixmap(proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget), |
|
1813 |
enabled ? QIcon::Normal : QIcon::Disabled); |
|
1814 |
||
1815 |
QRect cr = subElementRect(QStyle::SE_ToolBoxTabContents, tb, widget); |
|
1816 |
QRect tr, ir; |
|
1817 |
int ih = 0; |
|
1818 |
if (pm.isNull()) { |
|
1819 |
tr = cr; |
|
1820 |
tr.adjust(4, 0, -8, 0); |
|
1821 |
} else { |
|
1822 |
int iw = pm.width() + 4; |
|
1823 |
ih = pm.height(); |
|
1824 |
ir = QRect(cr.left() + 4, cr.top(), iw + 2, ih); |
|
1825 |
tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height()); |
|
1826 |
} |
|
1827 |
||
1828 |
if (selected && proxy()->styleHint(QStyle::SH_ToolBox_SelectedPageTitleBold, tb, widget)) { |
|
1829 |
QFont f(p->font()); |
|
1830 |
f.setBold(true); |
|
1831 |
p->setFont(f); |
|
1832 |
} |
|
1833 |
||
1834 |
QString txt = tb->fontMetrics.elidedText(tb->text, Qt::ElideRight, tr.width()); |
|
1835 |
||
1836 |
if (ih) |
|
1837 |
p->drawPixmap(ir.left(), (tb->rect.height() - ih) / 2, pm); |
|
1838 |
||
1839 |
int alignment = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic; |
|
1840 |
if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, tb, widget)) |
|
1841 |
alignment |= Qt::TextHideMnemonic; |
|
1842 |
proxy()->drawItemText(p, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText); |
|
1843 |
||
1844 |
if (!txt.isEmpty() && opt->state & State_HasFocus) { |
|
1845 |
QStyleOptionFocusRect opt; |
|
1846 |
opt.rect = tr; |
|
1847 |
opt.palette = tb->palette; |
|
1848 |
opt.state = QStyle::State_None; |
|
1849 |
proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, widget); |
|
1850 |
} |
|
1851 |
} |
|
1852 |
break; |
|
1853 |
case CE_TabBarTabLabel: |
|
1854 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { |
|
1855 |
QStyleOptionTabV3 tabV2(*tab); |
|
1856 |
QRect tr = tabV2.rect; |
|
1857 |
bool verticalTabs = tabV2.shape == QTabBar::RoundedEast |
|
1858 |
|| tabV2.shape == QTabBar::RoundedWest |
|
1859 |
|| tabV2.shape == QTabBar::TriangularEast |
|
1860 |
|| tabV2.shape == QTabBar::TriangularWest; |
|
1861 |
||
1862 |
int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; |
|
1863 |
if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) |
|
1864 |
alignment |= Qt::TextHideMnemonic; |
|
1865 |
||
1866 |
if (verticalTabs) { |
|
1867 |
p->save(); |
|
1868 |
int newX, newY, newRot; |
|
1869 |
if (tabV2.shape == QTabBar::RoundedEast || tabV2.shape == QTabBar::TriangularEast) { |
|
1870 |
newX = tr.width() + tr.x(); |
|
1871 |
newY = tr.y(); |
|
1872 |
newRot = 90; |
|
1873 |
} else { |
|
1874 |
newX = tr.x(); |
|
1875 |
newY = tr.y() + tr.height(); |
|
1876 |
newRot = -90; |
|
1877 |
} |
|
1878 |
QTransform m = QTransform::fromTranslate(newX, newY); |
|
1879 |
m.rotate(newRot); |
|
1880 |
p->setTransform(m, true); |
|
1881 |
} |
|
1882 |
QRect iconRect; |
|
1883 |
d->tabLayout(&tabV2, widget, &tr, &iconRect); |
|
1884 |
tr = proxy()->subElementRect(SE_TabBarTabText, opt, widget); //we compute tr twice because the style may override subElementRect |
|
1885 |
||
1886 |
if (!tabV2.icon.isNull()) { |
|
1887 |
QPixmap tabIcon = tabV2.icon.pixmap(tabV2.iconSize, |
|
1888 |
(tabV2.state & State_Enabled) ? QIcon::Normal |
|
1889 |
: QIcon::Disabled, |
|
1890 |
(tabV2.state & State_Selected) ? QIcon::On |
|
1891 |
: QIcon::Off); |
|
1892 |
p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon); |
|
1893 |
} |
|
1894 |
||
1895 |
proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); |
|
1896 |
if (verticalTabs) |
|
1897 |
p->restore(); |
|
1898 |
||
1899 |
if (tabV2.state & State_HasFocus) { |
|
1900 |
const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth); |
|
1901 |
||
1902 |
int x1, x2; |
|
1903 |
x1 = tabV2.rect.left(); |
|
1904 |
x2 = tabV2.rect.right() - 1; |
|
1905 |
||
1906 |
QStyleOptionFocusRect fropt; |
|
1907 |
fropt.QStyleOption::operator=(*tab); |
|
1908 |
fropt.rect.setRect(x1 + 1 + OFFSET, tabV2.rect.y() + OFFSET, |
|
1909 |
x2 - x1 - 2*OFFSET, tabV2.rect.height() - 2*OFFSET); |
|
1910 |
drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); |
|
1911 |
} |
|
1912 |
} |
|
1913 |
break; |
|
1914 |
#endif // QT_NO_TABBAR |
|
1915 |
#ifndef QT_NO_SIZEGRIP |
|
1916 |
case CE_SizeGrip: { |
|
1917 |
p->save(); |
|
1918 |
int x, y, w, h; |
|
1919 |
opt->rect.getRect(&x, &y, &w, &h); |
|
1920 |
||
1921 |
int sw = qMin(h, w); |
|
1922 |
if (h > w) |
|
1923 |
p->translate(0, h - w); |
|
1924 |
else |
|
1925 |
p->translate(w - h, 0); |
|
1926 |
||
1927 |
int sx = x; |
|
1928 |
int sy = y; |
|
1929 |
int s = sw / 3; |
|
1930 |
||
1931 |
Qt::Corner corner; |
|
1932 |
if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt)) |
|
1933 |
corner = sgOpt->corner; |
|
1934 |
else if (opt->direction == Qt::RightToLeft) |
|
1935 |
corner = Qt::BottomLeftCorner; |
|
1936 |
else |
|
1937 |
corner = Qt::BottomRightCorner; |
|
1938 |
||
1939 |
if (corner == Qt::BottomLeftCorner) { |
|
1940 |
sx = x + sw; |
|
1941 |
for (int i = 0; i < 4; ++i) { |
|
1942 |
p->setPen(QPen(opt->palette.light().color(), 1)); |
|
1943 |
p->drawLine(x, sy - 1 , sx + 1, sw); |
|
1944 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1945 |
p->drawLine(x, sy, sx, sw); |
|
1946 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1947 |
p->drawLine(x, sy + 1, sx - 1, sw); |
|
1948 |
sx -= s; |
|
1949 |
sy += s; |
|
1950 |
} |
|
1951 |
} else if (corner == Qt::BottomRightCorner) { |
|
1952 |
for (int i = 0; i < 4; ++i) { |
|
1953 |
p->setPen(QPen(opt->palette.light().color(), 1)); |
|
1954 |
p->drawLine(sx - 1, sw, sw, sy - 1); |
|
1955 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1956 |
p->drawLine(sx, sw, sw, sy); |
|
1957 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1958 |
p->drawLine(sx + 1, sw, sw, sy + 1); |
|
1959 |
sx += s; |
|
1960 |
sy += s; |
|
1961 |
} |
|
1962 |
} else if (corner == Qt::TopRightCorner) { |
|
1963 |
sy = y + sw; |
|
1964 |
for (int i = 0; i < 4; ++i) { |
|
1965 |
p->setPen(QPen(opt->palette.light().color(), 1)); |
|
1966 |
p->drawLine(sx - 1, y, sw, sy + 1); |
|
1967 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1968 |
p->drawLine(sx, y, sw, sy); |
|
1969 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1970 |
p->drawLine(sx + 1, y, sw, sy - 1); |
|
1971 |
sx += s; |
|
1972 |
sy -= s; |
|
1973 |
} |
|
1974 |
} else if (corner == Qt::TopLeftCorner) { |
|
1975 |
for (int i = 0; i < 4; ++i) { |
|
1976 |
p->setPen(QPen(opt->palette.light().color(), 1)); |
|
1977 |
p->drawLine(x, sy - 1, sx - 1, y); |
|
1978 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1979 |
p->drawLine(x, sy, sx, y); |
|
1980 |
p->setPen(QPen(opt->palette.dark().color(), 1)); |
|
1981 |
p->drawLine(x, sy + 1, sx + 1, y); |
|
1982 |
sx += s; |
|
1983 |
sy += s; |
|
1984 |
} |
|
1985 |
} |
|
1986 |
p->restore(); |
|
1987 |
break; } |
|
1988 |
#endif // QT_NO_SIZEGRIP |
|
1989 |
#ifndef QT_NO_RUBBERBAND |
|
1990 |
case CE_RubberBand: { |
|
1991 |
if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) { |
|
1992 |
QPixmap tiledPixmap(16, 16); |
|
1993 |
QPainter pixmapPainter(&tiledPixmap); |
|
1994 |
pixmapPainter.setPen(Qt::NoPen); |
|
1995 |
pixmapPainter.setBrush(Qt::Dense4Pattern); |
|
1996 |
pixmapPainter.setBackground(QBrush(opt->palette.base())); |
|
1997 |
pixmapPainter.setBackgroundMode(Qt::OpaqueMode); |
|
1998 |
pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height()); |
|
1999 |
pixmapPainter.end(); |
|
2000 |
// ### workaround for borked XRENDER |
|
2001 |
tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage()); |
|
2002 |
||
2003 |
p->save(); |
|
2004 |
QRect r = opt->rect; |
|
2005 |
QStyleHintReturnMask mask; |
|
2006 |
if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) |
|
2007 |
p->setClipRegion(mask.region); |
|
2008 |
p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); |
|
2009 |
p->setPen(opt->palette.color(QPalette::Active, QPalette::WindowText)); |
|
2010 |
p->setBrush(Qt::NoBrush); |
|
2011 |
p->drawRect(r.adjusted(0, 0, -1, -1)); |
|
2012 |
if (rbOpt->shape == QRubberBand::Rectangle) |
|
2013 |
p->drawRect(r.adjusted(3, 3, -4, -4)); |
|
2014 |
p->restore(); |
|
2015 |
} |
|
2016 |
break; } |
|
2017 |
#endif // QT_NO_RUBBERBAND |
|
2018 |
#ifndef QT_NO_DOCKWIDGET |
|
2019 |
case CE_DockWidgetTitle: |
|
2020 |
if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) { |
|
2021 |
QRect r = dwOpt->rect.adjusted(0, 0, -1, -1); |
|
2022 |
if (dwOpt->movable) { |
|
2023 |
p->setPen(dwOpt->palette.color(QPalette::Dark)); |
|
2024 |
p->drawRect(r); |
|
2025 |
} |
|
2026 |
||
2027 |
if (!dwOpt->title.isEmpty()) { |
|
2028 |
const QStyleOptionDockWidgetV2 *v2 |
|
2029 |
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt); |
|
2030 |
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; |
|
2031 |
||
2032 |
if (verticalTitleBar) { |
|
2033 |
QSize s = r.size(); |
|
2034 |
s.transpose(); |
|
2035 |
r.setSize(s); |
|
2036 |
||
2037 |
p->save(); |
|
2038 |
p->translate(r.left(), r.top() + r.width()); |
|
2039 |
p->rotate(-90); |
|
2040 |
p->translate(-r.left(), -r.top()); |
|
2041 |
} |
|
2042 |
||
2043 |
const int indent = p->fontMetrics().descent(); |
|
2044 |
proxy()->drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1), |
|
2045 |
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, |
|
2046 |
dwOpt->state & State_Enabled, dwOpt->title, |
|
2047 |
QPalette::WindowText); |
|
2048 |
||
2049 |
if (verticalTitleBar) |
|
2050 |
p->restore(); |
|
2051 |
} |
|
2052 |
} |
|
2053 |
break; |
|
2054 |
#endif // QT_NO_DOCKWIDGET |
|
2055 |
case CE_Header: |
|
2056 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
|
2057 |
QRegion clipRegion = p->clipRegion(); |
|
2058 |
p->setClipRect(opt->rect); |
|
2059 |
proxy()->drawControl(CE_HeaderSection, header, p, widget); |
|
2060 |
QStyleOptionHeader subopt = *header; |
|
2061 |
subopt.rect = subElementRect(SE_HeaderLabel, header, widget); |
|
2062 |
if (subopt.rect.isValid()) |
|
2063 |
proxy()->drawControl(CE_HeaderLabel, &subopt, p, widget); |
|
2064 |
if (header->sortIndicator != QStyleOptionHeader::None) { |
|
2065 |
subopt.rect = subElementRect(SE_HeaderArrow, opt, widget); |
|
2066 |
proxy()->drawPrimitive(PE_IndicatorHeaderArrow, &subopt, p, widget); |
|
2067 |
} |
|
2068 |
p->setClipRegion(clipRegion); |
|
2069 |
} |
|
2070 |
break; |
|
2071 |
case CE_FocusFrame: |
|
2072 |
p->fillRect(opt->rect, opt->palette.foreground()); |
|
2073 |
break; |
|
2074 |
case CE_HeaderSection: |
|
2075 |
qDrawShadePanel(p, opt->rect, opt->palette, |
|
2076 |
opt->state & State_Sunken, 1, |
|
2077 |
&opt->palette.brush(QPalette::Button)); |
|
2078 |
break; |
|
2079 |
case CE_HeaderEmptyArea: |
|
2080 |
p->fillRect(opt->rect, opt->palette.background()); |
|
2081 |
break; |
|
2082 |
#ifndef QT_NO_COMBOBOX |
|
2083 |
case CE_ComboBoxLabel: |
|
2084 |
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { |
|
2085 |
QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); |
|
2086 |
p->save(); |
|
2087 |
p->setClipRect(editRect); |
|
2088 |
if (!cb->currentIcon.isNull()) { |
|
2089 |
QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal |
|
2090 |
: QIcon::Disabled; |
|
2091 |
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); |
|
2092 |
QRect iconRect(editRect); |
|
2093 |
iconRect.setWidth(cb->iconSize.width() + 4); |
|
2094 |
iconRect = alignedRect(cb->direction, |
|
2095 |
Qt::AlignLeft | Qt::AlignVCenter, |
|
2096 |
iconRect.size(), editRect); |
|
2097 |
if (cb->editable) |
|
2098 |
p->fillRect(iconRect, opt->palette.brush(QPalette::Base)); |
|
2099 |
proxy()->drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); |
|
2100 |
||
2101 |
if (cb->direction == Qt::RightToLeft) |
|
2102 |
editRect.translate(-4 - cb->iconSize.width(), 0); |
|
2103 |
else |
|
2104 |
editRect.translate(cb->iconSize.width() + 4, 0); |
|
2105 |
} |
|
2106 |
if (!cb->currentText.isEmpty() && !cb->editable) { |
|
2107 |
proxy()->drawItemText(p, editRect.adjusted(1, 0, -1, 0), |
|
2108 |
visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), |
|
2109 |
cb->palette, cb->state & State_Enabled, cb->currentText); |
|
2110 |
} |
|
2111 |
p->restore(); |
|
2112 |
} |
|
2113 |
break; |
|
2114 |
#endif // QT_NO_COMBOBOX |
|
2115 |
#ifndef QT_NO_TOOLBAR |
|
2116 |
case CE_ToolBar: |
|
2117 |
if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) { |
|
2118 |
// Compatibility with styles that use PE_PanelToolBar |
|
2119 |
QStyleOptionFrame frame; |
|
2120 |
frame.QStyleOption::operator=(*toolBar); |
|
2121 |
frame.lineWidth = toolBar->lineWidth; |
|
2122 |
frame.midLineWidth = toolBar->midLineWidth; |
|
2123 |
proxy()->drawPrimitive(PE_PanelToolBar, opt, p, widget); |
|
2124 |
||
2125 |
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) |
|
2126 |
break; |
|
2127 |
qDrawShadePanel(p, toolBar->rect, toolBar->palette, false, toolBar->lineWidth, |
|
2128 |
&toolBar->palette.brush(QPalette::Button)); |
|
2129 |
} |
|
2130 |
break; |
|
2131 |
#endif // QT_NO_TOOLBAR |
|
2132 |
case CE_ColumnViewGrip: { |
|
2133 |
// draw background gradients |
|
2134 |
QLinearGradient g(0, 0, opt->rect.width(), 0); |
|
2135 |
g.setColorAt(0, opt->palette.color(QPalette::Active, QPalette::Mid)); |
|
2136 |
g.setColorAt(0.5, Qt::white); |
|
2137 |
p->fillRect(QRect(0, 0, opt->rect.width(), opt->rect.height()), g); |
|
2138 |
||
2139 |
// draw the two lines |
|
2140 |
QPen pen(p->pen()); |
|
2141 |
pen.setWidth(opt->rect.width()/20); |
|
2142 |
pen.setColor(opt->palette.color(QPalette::Active, QPalette::Dark)); |
|
2143 |
p->setPen(pen); |
|
2144 |
||
2145 |
int line1starting = opt->rect.width()*8 / 20; |
|
2146 |
int line2starting = opt->rect.width()*13 / 20; |
|
2147 |
int top = opt->rect.height()*20/75; |
|
2148 |
int bottom = opt->rect.height() - 1 - top; |
|
2149 |
p->drawLine(line1starting, top, line1starting, bottom); |
|
2150 |
p->drawLine(line2starting, top, line2starting, bottom); |
|
2151 |
} |
|
2152 |
break; |
|
2153 |
||
2154 |
#ifndef QT_NO_ITEMVIEWS |
|
2155 |
case CE_ItemViewItem: |
|
2156 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
2157 |
p->save(); |
|
2158 |
p->setClipRect(opt->rect); |
|
2159 |
||
2160 |
QRect checkRect = subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget); |
|
2161 |
QRect iconRect = subElementRect(SE_ItemViewItemDecoration, vopt, widget); |
|
2162 |
QRect textRect = subElementRect(SE_ItemViewItemText, vopt, widget); |
|
2163 |
||
2164 |
// draw the background |
|
2165 |
proxy()->drawPrimitive(PE_PanelItemViewItem, opt, p, widget); |
|
2166 |
||
2167 |
// draw the check mark |
|
2168 |
if (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) { |
|
2169 |
QStyleOptionViewItemV4 option(*vopt); |
|
2170 |
option.rect = checkRect; |
|
2171 |
option.state = option.state & ~QStyle::State_HasFocus; |
|
2172 |
||
2173 |
switch (vopt->checkState) { |
|
2174 |
case Qt::Unchecked: |
|
2175 |
option.state |= QStyle::State_Off; |
|
2176 |
break; |
|
2177 |
case Qt::PartiallyChecked: |
|
2178 |
option.state |= QStyle::State_NoChange; |
|
2179 |
break; |
|
2180 |
case Qt::Checked: |
|
2181 |
option.state |= QStyle::State_On; |
|
2182 |
break; |
|
2183 |
} |
|
2184 |
proxy()->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, p, widget); |
|
2185 |
} |
|
2186 |
||
2187 |
// draw the icon |
|
2188 |
QIcon::Mode mode = QIcon::Normal; |
|
2189 |
if (!(vopt->state & QStyle::State_Enabled)) |
|
2190 |
mode = QIcon::Disabled; |
|
2191 |
else if (vopt->state & QStyle::State_Selected) |
|
2192 |
mode = QIcon::Selected; |
|
2193 |
QIcon::State state = vopt->state & QStyle::State_Open ? QIcon::On : QIcon::Off; |
|
2194 |
vopt->icon.paint(p, iconRect, vopt->decorationAlignment, mode, state); |
|
2195 |
||
2196 |
// draw the text |
|
2197 |
if (!vopt->text.isEmpty()) { |
|
2198 |
QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled |
|
2199 |
? QPalette::Normal : QPalette::Disabled; |
|
2200 |
if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) |
|
2201 |
cg = QPalette::Inactive; |
|
2202 |
||
2203 |
if (vopt->state & QStyle::State_Selected) { |
|
2204 |
p->setPen(vopt->palette.color(cg, QPalette::HighlightedText)); |
|
2205 |
} else { |
|
2206 |
p->setPen(vopt->palette.color(cg, QPalette::Text)); |
|
2207 |
} |
|
2208 |
if (vopt->state & QStyle::State_Editing) { |
|
2209 |
p->setPen(vopt->palette.color(cg, QPalette::Text)); |
|
2210 |
p->drawRect(textRect.adjusted(0, 0, -1, -1)); |
|
2211 |
} |
|
2212 |
||
2213 |
d->viewItemDrawText(p, vopt, textRect); |
|
2214 |
} |
|
2215 |
||
2216 |
// draw the focus rect |
|
2217 |
if (vopt->state & QStyle::State_HasFocus) { |
|
2218 |
QStyleOptionFocusRect o; |
|
2219 |
o.QStyleOption::operator=(*vopt); |
|
2220 |
o.rect = subElementRect(SE_ItemViewItemFocusRect, vopt, widget); |
|
2221 |
o.state |= QStyle::State_KeyboardFocusChange; |
|
2222 |
o.state |= QStyle::State_Item; |
|
2223 |
QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled) |
|
2224 |
? QPalette::Normal : QPalette::Disabled; |
|
2225 |
o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected) |
|
2226 |
? QPalette::Highlight : QPalette::Window); |
|
2227 |
proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, p, widget); |
|
2228 |
} |
|
2229 |
||
2230 |
p->restore(); |
|
2231 |
} |
|
2232 |
break; |
|
2233 |
||
2234 |
#endif // QT_NO_ITEMVIEWS |
|
2235 |
#ifndef QT_NO_FRAME |
|
2236 |
case CE_ShapedFrame: |
|
2237 |
if (const QStyleOptionFrameV3 *f = qstyleoption_cast<const QStyleOptionFrameV3 *>(opt)) { |
|
2238 |
int frameShape = f->frameShape; |
|
2239 |
int frameShadow = QFrame::Plain; |
|
2240 |
if (f->state & QStyle::State_Sunken) { |
|
2241 |
frameShadow = QFrame::Sunken; |
|
2242 |
} else if (f->state & QStyle::State_Raised) { |
|
2243 |
frameShadow = QFrame::Raised; |
|
2244 |
} |
|
2245 |
||
2246 |
int lw = f->lineWidth; |
|
2247 |
int mlw = f->midLineWidth; |
|
2248 |
QPalette::ColorRole foregroundRole = QPalette::WindowText; |
|
2249 |
if (widget) |
|
2250 |
foregroundRole = widget->foregroundRole(); |
|
2251 |
||
2252 |
switch (frameShape) { |
|
2253 |
case QFrame::Box: |
|
2254 |
if (frameShadow == QFrame::Plain) { |
|
2255 |
qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw); |
|
2256 |
} else { |
|
2257 |
qDrawShadeRect(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw, mlw); |
|
2258 |
} |
|
2259 |
break; |
|
2260 |
case QFrame::StyledPanel: |
|
2261 |
//keep the compatibility with Qt 4.4 if there is a proxy style. |
|
2262 |
//be sure to call drawPrimitive(QStyle::PE_Frame) on the proxy style |
|
2263 |
if (widget) { |
|
2264 |
widget->style()->drawPrimitive(QStyle::PE_Frame, opt, p, widget); |
|
2265 |
} else { |
|
2266 |
proxy()->drawPrimitive(QStyle::PE_Frame, opt, p, widget); |
|
2267 |
} |
|
2268 |
break; |
|
2269 |
case QFrame::Panel: |
|
2270 |
if (frameShadow == QFrame::Plain) { |
|
2271 |
qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw); |
|
2272 |
} else { |
|
2273 |
qDrawShadePanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken, lw); |
|
2274 |
} |
|
2275 |
break; |
|
2276 |
case QFrame::WinPanel: |
|
2277 |
if (frameShadow == QFrame::Plain) { |
|
2278 |
qDrawPlainRect(p, f->rect, f->palette.color(foregroundRole), lw); |
|
2279 |
} else { |
|
2280 |
qDrawWinPanel(p, f->rect, f->palette, frameShadow == QFrame::Sunken); |
|
2281 |
} |
|
2282 |
break; |
|
2283 |
case QFrame::HLine: |
|
2284 |
case QFrame::VLine: { |
|
2285 |
QPoint p1, p2; |
|
2286 |
if (frameShape == QFrame::HLine) { |
|
2287 |
p1 = QPoint(opt->rect.x(), opt->rect.height() / 2); |
|
2288 |
p2 = QPoint(opt->rect.x() + opt->rect.width(), p1.y()); |
|
2289 |
} else { |
|
2290 |
p1 = QPoint(opt->rect.x()+opt->rect.width() / 2, 0); |
|
2291 |
p2 = QPoint(p1.x(), opt->rect.height()); |
|
2292 |
} |
|
2293 |
if (frameShadow == QFrame::Plain) { |
|
2294 |
QPen oldPen = p->pen(); |
|
2295 |
p->setPen(QPen(opt->palette.brush(foregroundRole), lw)); |
|
2296 |
p->drawLine(p1, p2); |
|
2297 |
p->setPen(oldPen); |
|
2298 |
} else { |
|
2299 |
qDrawShadeLine(p, p1, p2, f->palette, frameShadow == QFrame::Sunken, lw, mlw); |
|
2300 |
} |
|
2301 |
break; |
|
2302 |
} |
|
2303 |
} |
|
2304 |
} |
|
2305 |
break; |
|
2306 |
#endif |
|
2307 |
default: |
|
2308 |
break; |
|
2309 |
} |
|
2310 |
} |
|
2311 |
||
2312 |
/*! |
|
2313 |
\reimp |
|
2314 |
*/ |
|
2315 |
QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, |
|
2316 |
const QWidget *widget) const |
|
2317 |
{ |
|
2318 |
Q_D(const QCommonStyle); |
|
2319 |
QRect r; |
|
2320 |
switch (sr) { |
|
2321 |
case SE_PushButtonContents: |
|
2322 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
2323 |
int dx1, dx2; |
|
2324 |
dx1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); |
|
2325 |
if (btn->features & QStyleOptionButton::AutoDefaultButton) |
|
2326 |
dx1 += proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); |
|
2327 |
dx2 = dx1 * 2; |
|
2328 |
r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2, |
|
2329 |
opt->rect.height() - dx2); |
|
2330 |
r = visualRect(opt->direction, opt->rect, r); |
|
2331 |
} |
|
2332 |
break; |
|
2333 |
case SE_PushButtonFocusRect: |
|
2334 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
2335 |
int dbw1 = 0, dbw2 = 0; |
|
2336 |
if (btn->features & QStyleOptionButton::AutoDefaultButton){ |
|
2337 |
dbw1 = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); |
|
2338 |
dbw2 = dbw1 * 2; |
|
2339 |
} |
|
2340 |
||
2341 |
int dfw1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1, |
|
2342 |
dfw2 = dfw1 * 2; |
|
2343 |
||
2344 |
r.setRect(btn->rect.x() + dfw1 + dbw1, btn->rect.y() + dfw1 + dbw1, |
|
2345 |
btn->rect.width() - dfw2 - dbw2, btn->rect.height()- dfw2 - dbw2); |
|
2346 |
r = visualRect(opt->direction, opt->rect, r); |
|
2347 |
} |
|
2348 |
break; |
|
2349 |
case SE_CheckBoxIndicator: |
|
2350 |
{ |
|
2351 |
int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); |
|
2352 |
r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), |
|
2353 |
proxy()->pixelMetric(PM_IndicatorWidth, opt, widget), h); |
|
2354 |
r = visualRect(opt->direction, opt->rect, r); |
|
2355 |
} |
|
2356 |
break; |
|
2357 |
||
2358 |
case SE_CheckBoxContents: |
|
2359 |
{ |
|
2360 |
// Deal with the logical first, then convert it back to screen coords. |
|
2361 |
QRect ir = visualRect(opt->direction, opt->rect, |
|
2362 |
subElementRect(SE_CheckBoxIndicator, opt, widget)); |
|
2363 |
int spacing = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget); |
|
2364 |
r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing, |
|
2365 |
opt->rect.height()); |
|
2366 |
r = visualRect(opt->direction, opt->rect, r); |
|
2367 |
} |
|
2368 |
break; |
|
2369 |
||
2370 |
case SE_CheckBoxFocusRect: |
|
2371 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
2372 |
if (btn->icon.isNull() && btn->text.isEmpty()) { |
|
2373 |
r = subElementRect(SE_CheckBoxIndicator, opt, widget); |
|
2374 |
r.adjust(1, 1, -1, -1); |
|
2375 |
break; |
|
2376 |
} |
|
2377 |
// As above, deal with the logical first, then convert it back to screen coords. |
|
2378 |
QRect cr = visualRect(btn->direction, btn->rect, |
|
2379 |
subElementRect(SE_CheckBoxContents, btn, widget)); |
|
2380 |
||
2381 |
QRect iconRect, textRect; |
|
2382 |
if (!btn->text.isEmpty()) { |
|
2383 |
textRect = itemTextRect(opt->fontMetrics, cr, Qt::AlignAbsolute | Qt::AlignLeft |
|
2384 |
| Qt::AlignVCenter | Qt::TextShowMnemonic, |
|
2385 |
btn->state & State_Enabled, btn->text); |
|
2386 |
} |
|
2387 |
if (!btn->icon.isNull()) { |
|
2388 |
iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter |
|
2389 |
| Qt::TextShowMnemonic, |
|
2390 |
btn->icon.pixmap(btn->iconSize, QIcon::Normal)); |
|
2391 |
if (!textRect.isEmpty()) |
|
2392 |
textRect.translate(iconRect.right() + 4, 0); |
|
2393 |
} |
|
2394 |
r = iconRect | textRect; |
|
2395 |
r.adjust(-3, -2, 3, 2); |
|
2396 |
r = r.intersected(btn->rect); |
|
2397 |
r = visualRect(btn->direction, btn->rect, r); |
|
2398 |
} |
|
2399 |
break; |
|
2400 |
||
2401 |
case SE_RadioButtonIndicator: |
|
2402 |
{ |
|
2403 |
int h = proxy()->pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); |
|
2404 |
r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), |
|
2405 |
proxy()->pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), h); |
|
2406 |
r = visualRect(opt->direction, opt->rect, r); |
|
2407 |
} |
|
2408 |
break; |
|
2409 |
||
2410 |
case SE_RadioButtonContents: |
|
2411 |
{ |
|
2412 |
QRect ir = visualRect(opt->direction, opt->rect, |
|
2413 |
subElementRect(SE_RadioButtonIndicator, opt, widget)); |
|
2414 |
int spacing = proxy()->pixelMetric(PM_RadioButtonLabelSpacing, opt, widget); |
|
2415 |
r.setRect(ir.left() + ir.width() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing, |
|
2416 |
opt->rect.height()); |
|
2417 |
r = visualRect(opt->direction, opt->rect, r); |
|
2418 |
break; |
|
2419 |
} |
|
2420 |
||
2421 |
case SE_RadioButtonFocusRect: |
|
2422 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
2423 |
if (btn->icon.isNull() && btn->text.isEmpty()) { |
|
2424 |
r = subElementRect(SE_RadioButtonIndicator, opt, widget); |
|
2425 |
r.adjust(1, 1, -1, -1); |
|
2426 |
break; |
|
2427 |
} |
|
2428 |
QRect cr = visualRect(btn->direction, btn->rect, |
|
2429 |
subElementRect(SE_RadioButtonContents, opt, widget)); |
|
2430 |
||
2431 |
QRect iconRect, textRect; |
|
2432 |
if (!btn->text.isEmpty()){ |
|
2433 |
textRect = itemTextRect(opt->fontMetrics, cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter |
|
2434 |
| Qt::TextShowMnemonic, btn->state & State_Enabled, btn->text); |
|
2435 |
} |
|
2436 |
if (!btn->icon.isNull()) { |
|
2437 |
iconRect = itemPixmapRect(cr, Qt::AlignAbsolute | Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, |
|
2438 |
btn->icon.pixmap(btn->iconSize, QIcon::Normal)); |
|
2439 |
if (!textRect.isEmpty()) |
|
2440 |
textRect.translate(iconRect.right() + 4, 0); |
|
2441 |
} |
|
2442 |
r = iconRect | textRect; |
|
2443 |
r.adjust(-3, -2, 3, 2); |
|
2444 |
r = r.intersected(btn->rect); |
|
2445 |
r = visualRect(btn->direction, btn->rect, r); |
|
2446 |
} |
|
2447 |
break; |
|
2448 |
#ifndef QT_NO_SLIDER |
|
2449 |
case SE_SliderFocusRect: |
|
2450 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
2451 |
int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); |
|
2452 |
int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); |
|
2453 |
if (slider->orientation == Qt::Horizontal) |
|
2454 |
r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2); |
|
2455 |
else |
|
2456 |
r.setRect(tickOffset - 1, 0, thickness + 2, slider->rect.height()); |
|
2457 |
r = r.intersected(slider->rect); |
|
2458 |
r = visualRect(opt->direction, opt->rect, r); |
|
2459 |
} |
|
2460 |
break; |
|
2461 |
#endif // QT_NO_SLIDER |
|
2462 |
#ifndef QT_NO_PROGRESSBAR |
|
2463 |
case SE_ProgressBarGroove: |
|
2464 |
case SE_ProgressBarContents: |
|
2465 |
case SE_ProgressBarLabel: |
|
2466 |
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { |
|
2467 |
int textw = 0; |
|
2468 |
bool vertical = false; |
|
2469 |
if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) { |
|
2470 |
vertical = (pb2->orientation == Qt::Vertical); |
|
2471 |
} |
|
2472 |
if (!vertical) { |
|
2473 |
if (pb->textVisible) |
|
2474 |
textw = qMax(pb->fontMetrics.width(pb->text), pb->fontMetrics.width(QLatin1String("100%"))) + 6; |
|
2475 |
} |
|
2476 |
||
2477 |
if ((pb->textAlignment & Qt::AlignCenter) == 0) { |
|
2478 |
if (sr != SE_ProgressBarLabel) |
|
2479 |
r.setCoords(pb->rect.left(), pb->rect.top(), |
|
2480 |
pb->rect.right() - textw, pb->rect.bottom()); |
|
2481 |
else |
|
2482 |
r.setCoords(pb->rect.right() - textw, pb->rect.top(), |
|
2483 |
pb->rect.right(), pb->rect.bottom()); |
|
2484 |
} else { |
|
2485 |
r = pb->rect; |
|
2486 |
} |
|
2487 |
r = visualRect(pb->direction, pb->rect, r); |
|
2488 |
} |
|
2489 |
break; |
|
2490 |
#endif // QT_NO_PROGRESSBAR |
|
2491 |
#ifdef QT3_SUPPORT |
|
2492 |
case SE_Q3DockWindowHandleRect: |
|
2493 |
if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) { |
|
2494 |
if (!dw->docked || !dw->closeEnabled) |
|
2495 |
r.setRect(0, 0, dw->rect.width(), dw->rect.height()); |
|
2496 |
else { |
|
2497 |
if (dw->state & State_Horizontal) |
|
2498 |
r.setRect(0, 15, dw->rect.width(), dw->rect.height() - 15); |
|
2499 |
else |
|
2500 |
r.setRect(0, 1, dw->rect.width() - 15, dw->rect.height() - 1); |
|
2501 |
} |
|
2502 |
r = visualRect(opt->direction, opt->rect, r); |
|
2503 |
} |
|
2504 |
break; |
|
2505 |
#endif // QT3_SUPPORT |
|
2506 |
#ifndef QT_NO_COMBOBOX |
|
2507 |
case SE_ComboBoxFocusRect: |
|
2508 |
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { |
|
2509 |
int margin = cb->frame ? 3 : 0; |
|
2510 |
r.setRect(opt->rect.left() + margin, opt->rect.top() + margin, |
|
2511 |
opt->rect.width() - 2*margin - 16, opt->rect.height() - 2*margin); |
|
2512 |
r = visualRect(opt->direction, opt->rect, r); |
|
2513 |
} |
|
2514 |
break; |
|
2515 |
#endif // QT_NO_COMBOBOX |
|
2516 |
#ifndef QT_NO_TOOLBOX |
|
2517 |
case SE_ToolBoxTabContents: |
|
2518 |
r = opt->rect; |
|
2519 |
r.adjust(0, 0, -30, 0); |
|
2520 |
break; |
|
2521 |
#endif // QT_NO_TOOLBOX |
|
2522 |
case SE_HeaderLabel: { |
|
2523 |
int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget); |
|
2524 |
r.setRect(opt->rect.x() + margin, opt->rect.y() + margin, |
|
2525 |
opt->rect.width() - margin * 2, opt->rect.height() - margin * 2); |
|
2526 |
||
2527 |
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
|
2528 |
// Subtract width needed for arrow, if there is one |
|
2529 |
if (header->sortIndicator != QStyleOptionHeader::None) { |
|
2530 |
if (opt->state & State_Horizontal) |
|
2531 |
r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2)); |
|
2532 |
else |
|
2533 |
r.setHeight(r.height() - (opt->rect.width() / 2) - (margin * 2)); |
|
2534 |
} |
|
2535 |
} |
|
2536 |
r = visualRect(opt->direction, opt->rect, r); |
|
2537 |
break; } |
|
2538 |
case SE_HeaderArrow: { |
|
2539 |
int h = opt->rect.height(); |
|
2540 |
int w = opt->rect.width(); |
|
2541 |
int x = opt->rect.x(); |
|
2542 |
int y = opt->rect.y(); |
|
2543 |
int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget); |
|
2544 |
||
2545 |
if (opt->state & State_Horizontal) { |
|
2546 |
int horiz_size = h / 2; |
|
2547 |
r.setRect(x + w - margin * 2 - horiz_size, y + 5, |
|
2548 |
horiz_size, h - margin * 2 - 5); |
|
2549 |
} else { |
|
2550 |
int vert_size = w / 2; |
|
2551 |
r.setRect(x + 5, y + h - margin * 2 - vert_size, |
|
2552 |
w - margin * 2 - 5, vert_size); |
|
2553 |
} |
|
2554 |
r = visualRect(opt->direction, opt->rect, r); |
|
2555 |
break; } |
|
2556 |
||
2557 |
case SE_RadioButtonClickRect: |
|
2558 |
r = subElementRect(SE_RadioButtonFocusRect, opt, widget); |
|
2559 |
r |= subElementRect(SE_RadioButtonIndicator, opt, widget); |
|
2560 |
break; |
|
2561 |
case SE_CheckBoxClickRect: |
|
2562 |
r = subElementRect(SE_CheckBoxFocusRect, opt, widget); |
|
2563 |
r |= subElementRect(SE_CheckBoxIndicator, opt, widget); |
|
2564 |
break; |
|
2565 |
#ifndef QT_NO_TABWIDGET |
|
2566 |
case SE_TabWidgetTabBar: |
|
2567 |
if (const QStyleOptionTabWidgetFrame *twf |
|
2568 |
= qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2569 |
r.setSize(twf->tabBarSize); |
|
2570 |
const uint alingMask = Qt::AlignLeft | Qt::AlignRight | Qt::AlignHCenter; |
|
2571 |
switch (twf->shape) { |
|
2572 |
case QTabBar::RoundedNorth: |
|
2573 |
case QTabBar::TriangularNorth: |
|
2574 |
// Constrain the size now, otherwise, center could get off the page |
|
2575 |
// This of course repeated for all the other directions |
|
2576 |
r.setWidth(qMin(r.width(), twf->rect.width() |
|
2577 |
- twf->leftCornerWidgetSize.width() |
|
2578 |
- twf->rightCornerWidgetSize.width())); |
|
2579 |
switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { |
|
2580 |
default: |
|
2581 |
case Qt::AlignLeft: |
|
2582 |
r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), 0)); |
|
2583 |
break; |
|
2584 |
case Qt::AlignHCenter: |
|
2585 |
r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f) |
|
2586 |
+ (twf->leftCornerWidgetSize.width() / 2) |
|
2587 |
- (twf->rightCornerWidgetSize.width() / 2), 0)); |
|
2588 |
break; |
|
2589 |
case Qt::AlignRight: |
|
2590 |
r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width() |
|
2591 |
- twf->rightCornerWidgetSize.width(), 0)); |
|
2592 |
break; |
|
2593 |
} |
|
2594 |
r = visualRect(twf->direction, twf->rect, r); |
|
2595 |
break; |
|
2596 |
case QTabBar::RoundedSouth: |
|
2597 |
case QTabBar::TriangularSouth: |
|
2598 |
r.setWidth(qMin(r.width(), twf->rect.width() |
|
2599 |
- twf->leftCornerWidgetSize.width() |
|
2600 |
- twf->rightCornerWidgetSize.width())); |
|
2601 |
switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { |
|
2602 |
default: |
|
2603 |
case Qt::AlignLeft: |
|
2604 |
r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), |
|
2605 |
twf->rect.height() - twf->tabBarSize.height())); |
|
2606 |
break; |
|
2607 |
case Qt::AlignHCenter: |
|
2608 |
r.moveTopLeft(QPoint(twf->rect.center().x() - qRound(r.width() / 2.0f) |
|
2609 |
+ (twf->leftCornerWidgetSize.width() / 2) |
|
2610 |
- (twf->rightCornerWidgetSize.width() / 2), |
|
2611 |
twf->rect.height() - twf->tabBarSize.height())); |
|
2612 |
break; |
|
2613 |
case Qt::AlignRight: |
|
2614 |
r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width() |
|
2615 |
- twf->rightCornerWidgetSize.width(), |
|
2616 |
twf->rect.height() - twf->tabBarSize.height())); |
|
2617 |
break; |
|
2618 |
} |
|
2619 |
r = visualRect(twf->direction, twf->rect, r); |
|
2620 |
break; |
|
2621 |
case QTabBar::RoundedEast: |
|
2622 |
case QTabBar::TriangularEast: |
|
2623 |
r.setHeight(qMin(r.height(), twf->rect.height() |
|
2624 |
- twf->leftCornerWidgetSize.height() |
|
2625 |
- twf->rightCornerWidgetSize.height())); |
|
2626 |
switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { |
|
2627 |
default: |
|
2628 |
case Qt::AlignLeft: |
|
2629 |
r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(), |
|
2630 |
twf->leftCornerWidgetSize.height())); |
|
2631 |
break; |
|
2632 |
case Qt::AlignHCenter: |
|
2633 |
r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(), |
|
2634 |
twf->rect.center().y() - r.height() / 2)); |
|
2635 |
break; |
|
2636 |
case Qt::AlignRight: |
|
2637 |
r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(), |
|
2638 |
twf->rect.height() - twf->tabBarSize.height() |
|
2639 |
- twf->rightCornerWidgetSize.height())); |
|
2640 |
break; |
|
2641 |
} |
|
2642 |
break; |
|
2643 |
case QTabBar::RoundedWest: |
|
2644 |
case QTabBar::TriangularWest: |
|
2645 |
r.setHeight(qMin(r.height(), twf->rect.height() |
|
2646 |
- twf->leftCornerWidgetSize.height() |
|
2647 |
- twf->rightCornerWidgetSize.height())); |
|
2648 |
switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { |
|
2649 |
default: |
|
2650 |
case Qt::AlignLeft: |
|
2651 |
r.moveTopLeft(QPoint(0, twf->leftCornerWidgetSize.height())); |
|
2652 |
break; |
|
2653 |
case Qt::AlignHCenter: |
|
2654 |
r.moveTopLeft(QPoint(0, twf->rect.center().y() - r.height() / 2)); |
|
2655 |
break; |
|
2656 |
case Qt::AlignRight: |
|
2657 |
r.moveTopLeft(QPoint(0, twf->rect.height() - twf->tabBarSize.height() |
|
2658 |
- twf->rightCornerWidgetSize.height())); |
|
2659 |
break; |
|
2660 |
} |
|
2661 |
break; |
|
2662 |
} |
|
2663 |
} |
|
2664 |
break; |
|
2665 |
case SE_TabWidgetTabPane: |
|
2666 |
case SE_TabWidgetTabContents: |
|
2667 |
if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2668 |
QStyleOptionTab tabopt; |
|
2669 |
tabopt.shape = twf->shape; |
|
2670 |
int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget); |
|
2671 |
if (twf->lineWidth == 0) |
|
2672 |
overlap = 0; |
|
2673 |
switch (twf->shape) { |
|
2674 |
case QTabBar::RoundedNorth: |
|
2675 |
case QTabBar::TriangularNorth: |
|
2676 |
r = QRect(QPoint(0,qMax(twf->tabBarSize.height() - overlap, 0)), |
|
2677 |
QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height()))); |
|
2678 |
break; |
|
2679 |
case QTabBar::RoundedSouth: |
|
2680 |
case QTabBar::TriangularSouth: |
|
2681 |
r = QRect(QPoint(0,0), QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height()))); |
|
2682 |
break; |
|
2683 |
case QTabBar::RoundedEast: |
|
2684 |
case QTabBar::TriangularEast: |
|
2685 |
r = QRect(QPoint(0, 0), QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height())); |
|
2686 |
break; |
|
2687 |
case QTabBar::RoundedWest: |
|
2688 |
case QTabBar::TriangularWest: |
|
2689 |
r = QRect(QPoint(qMax(twf->tabBarSize.width() - overlap, 0), 0), |
|
2690 |
QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height())); |
|
2691 |
break; |
|
2692 |
} |
|
2693 |
if (sr == SE_TabWidgetTabContents && twf->lineWidth > 0) |
|
2694 |
r.adjust(2, 2, -2, -2); |
|
2695 |
} |
|
2696 |
break; |
|
2697 |
case SE_TabWidgetLeftCorner: |
|
2698 |
if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2699 |
QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf, widget); |
|
2700 |
switch (twf->shape) { |
|
2701 |
case QTabBar::RoundedNorth: |
|
2702 |
case QTabBar::TriangularNorth: |
|
2703 |
r = QRect(QPoint(paneRect.x(), paneRect.y() - twf->leftCornerWidgetSize.height()), |
|
2704 |
twf->leftCornerWidgetSize); |
|
2705 |
break; |
|
2706 |
case QTabBar::RoundedSouth: |
|
2707 |
case QTabBar::TriangularSouth: |
|
2708 |
r = QRect(QPoint(paneRect.x(), paneRect.height()), twf->leftCornerWidgetSize); |
|
2709 |
break; |
|
2710 |
default: |
|
2711 |
break; |
|
2712 |
} |
|
2713 |
r = visualRect(twf->direction, twf->rect, r); |
|
2714 |
} |
|
2715 |
break; |
|
2716 |
case SE_TabWidgetRightCorner: |
|
2717 |
if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { |
|
2718 |
QRect paneRect = subElementRect(SE_TabWidgetTabPane, twf, widget); |
|
2719 |
switch (twf->shape) { |
|
2720 |
case QTabBar::RoundedNorth: |
|
2721 |
case QTabBar::TriangularNorth: |
|
2722 |
r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(), |
|
2723 |
paneRect.y() - twf->rightCornerWidgetSize.height()), |
|
2724 |
twf->rightCornerWidgetSize); |
|
2725 |
break; |
|
2726 |
case QTabBar::RoundedSouth: |
|
2727 |
case QTabBar::TriangularSouth: |
|
2728 |
r = QRect(QPoint(paneRect.width() - twf->rightCornerWidgetSize.width(), |
|
2729 |
paneRect.height()), twf->rightCornerWidgetSize); |
|
2730 |
break; |
|
2731 |
default: |
|
2732 |
break; |
|
2733 |
} |
|
2734 |
r = visualRect(twf->direction, twf->rect, r); |
|
2735 |
} |
|
2736 |
break; |
|
2737 |
case SE_TabBarTabText: |
|
2738 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { |
|
2739 |
QStyleOptionTabV3 tabV3(*tab); |
|
2740 |
QRect dummyIconRect; |
|
2741 |
d->tabLayout(&tabV3, widget, &r, &dummyIconRect); |
|
2742 |
} |
|
2743 |
break; |
|
2744 |
case SE_TabBarTabLeftButton: |
|
2745 |
case SE_TabBarTabRightButton: |
|
2746 |
if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) { |
|
2747 |
bool selected = tab->state & State_Selected; |
|
2748 |
int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); |
|
2749 |
int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); |
|
2750 |
int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; |
|
2751 |
hpadding = qMax(hpadding, 4); //workaround KStyle returning 0 because they workaround an old bug in Qt |
|
2752 |
||
2753 |
bool verticalTabs = tab->shape == QTabBar::RoundedEast |
|
2754 |
|| tab->shape == QTabBar::RoundedWest |
|
2755 |
|| tab->shape == QTabBar::TriangularEast |
|
2756 |
|| tab->shape == QTabBar::TriangularWest; |
|
2757 |
||
2758 |
QRect tr = tab->rect; |
|
2759 |
if (tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::TriangularSouth) |
|
2760 |
verticalShift = -verticalShift; |
|
2761 |
if (verticalTabs) { |
|
2762 |
qSwap(horizontalShift, verticalShift); |
|
2763 |
horizontalShift *= -1; |
|
2764 |
verticalShift *= -1; |
|
2765 |
} |
|
2766 |
if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest) |
|
2767 |
horizontalShift = -horizontalShift; |
|
2768 |
||
2769 |
tr.adjust(0, 0, horizontalShift, verticalShift); |
|
2770 |
if (selected) |
|
2771 |
{ |
|
2772 |
tr.setBottom(tr.bottom() - verticalShift); |
|
2773 |
tr.setRight(tr.right() - horizontalShift); |
|
2774 |
} |
|
2775 |
||
2776 |
QSize size = (sr == SE_TabBarTabLeftButton) ? tab->leftButtonSize : tab->rightButtonSize; |
|
2777 |
int w = size.width(); |
|
2778 |
int h = size.height(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2779 |
int midHeight = static_cast<int>(qCeil(float(tr.height() - h) / 2)); |
0 | 2780 |
int midWidth = ((tr.width() - w) / 2); |
2781 |
||
2782 |
bool atTheTop = true; |
|
2783 |
switch (tab->shape) { |
|
2784 |
case QTabBar::RoundedWest: |
|
2785 |
case QTabBar::TriangularWest: |
|
2786 |
atTheTop = (sr == SE_TabBarTabLeftButton); |
|
2787 |
break; |
|
2788 |
case QTabBar::RoundedEast: |
|
2789 |
case QTabBar::TriangularEast: |
|
2790 |
atTheTop = (sr == SE_TabBarTabRightButton); |
|
2791 |
break; |
|
2792 |
default: |
|
2793 |
if (sr == SE_TabBarTabLeftButton) |
|
2794 |
r = QRect(tab->rect.x() + hpadding, midHeight, w, h); |
|
2795 |
else |
|
2796 |
r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h); |
|
2797 |
r = visualRect(tab->direction, tab->rect, r); |
|
2798 |
} |
|
2799 |
if (verticalTabs) { |
|
2800 |
if (atTheTop) |
|
2801 |
r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h); |
|
2802 |
else |
|
2803 |
r = QRect(midWidth, tr.y() + hpadding, w, h); |
|
2804 |
} |
|
2805 |
} |
|
2806 |
||
2807 |
break; |
|
2808 |
#endif // QT_NO_TABWIDGET |
|
2809 |
#ifndef QT_NO_TABBAR |
|
2810 |
case SE_TabBarTearIndicator: |
|
2811 |
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { |
|
2812 |
switch (tab->shape) { |
|
2813 |
case QTabBar::RoundedNorth: |
|
2814 |
case QTabBar::TriangularNorth: |
|
2815 |
case QTabBar::RoundedSouth: |
|
2816 |
case QTabBar::TriangularSouth: |
|
2817 |
r.setRect(tab->rect.left(), tab->rect.top(), 4, opt->rect.height()); |
|
2818 |
break; |
|
2819 |
case QTabBar::RoundedWest: |
|
2820 |
case QTabBar::TriangularWest: |
|
2821 |
case QTabBar::RoundedEast: |
|
2822 |
case QTabBar::TriangularEast: |
|
2823 |
r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 4); |
|
2824 |
break; |
|
2825 |
default: |
|
2826 |
break; |
|
2827 |
} |
|
2828 |
r = visualRect(opt->direction, opt->rect, r); |
|
2829 |
} |
|
2830 |
break; |
|
2831 |
#endif |
|
2832 |
case SE_TreeViewDisclosureItem: |
|
2833 |
r = opt->rect; |
|
2834 |
break; |
|
2835 |
case SE_LineEditContents: |
|
2836 |
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { |
|
2837 |
r = f->rect.adjusted(f->lineWidth, f->lineWidth, -f->lineWidth, -f->lineWidth); |
|
2838 |
r = visualRect(opt->direction, opt->rect, r); |
|
2839 |
} |
|
2840 |
break; |
|
2841 |
case SE_FrameContents: |
|
2842 |
if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) { |
|
2843 |
int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, f, widget); |
|
2844 |
r = opt->rect.adjusted(fw, fw, -fw, -fw); |
|
2845 |
r = visualRect(opt->direction, opt->rect, r); |
|
2846 |
} |
|
2847 |
break; |
|
2848 |
case SE_ShapedFrameContents: |
|
2849 |
if (const QStyleOptionFrameV3 *f = qstyleoption_cast<const QStyleOptionFrameV3 *>(opt)) { |
|
2850 |
int frameShape = f->frameShape; |
|
2851 |
int frameShadow = QFrame::Plain; |
|
2852 |
if (f->state & QStyle::State_Sunken) { |
|
2853 |
frameShadow = QFrame::Sunken; |
|
2854 |
} else if (f->state & QStyle::State_Raised) { |
|
2855 |
frameShadow = QFrame::Raised; |
|
2856 |
} |
|
2857 |
||
2858 |
int frameWidth = 0; |
|
2859 |
||
2860 |
switch (frameShape) { |
|
2861 |
case QFrame::NoFrame: |
|
2862 |
frameWidth = 0; |
|
2863 |
break; |
|
2864 |
||
2865 |
case QFrame::Box: |
|
2866 |
case QFrame::HLine: |
|
2867 |
case QFrame::VLine: |
|
2868 |
switch (frameShadow) { |
|
2869 |
case QFrame::Plain: |
|
2870 |
frameWidth = f->lineWidth; |
|
2871 |
break; |
|
2872 |
case QFrame::Raised: |
|
2873 |
case QFrame::Sunken: |
|
2874 |
frameWidth = (short)(f->lineWidth*2 + f->midLineWidth); |
|
2875 |
break; |
|
2876 |
} |
|
2877 |
break; |
|
2878 |
||
2879 |
case QFrame::StyledPanel: |
|
2880 |
//keep the compatibility with Qt 4.4 if there is a proxy style. |
|
2881 |
//be sure to call drawPrimitive(QStyle::SE_FrameContents) on the proxy style |
|
2882 |
if (widget) |
|
2883 |
return widget->style()->subElementRect(QStyle::SE_FrameContents, opt, widget); |
|
2884 |
else |
|
2885 |
return subElementRect(QStyle::SE_FrameContents, opt, widget); |
|
2886 |
break; |
|
2887 |
||
2888 |
case QFrame::WinPanel: |
|
2889 |
frameWidth = 2; |
|
2890 |
break; |
|
2891 |
||
2892 |
case QFrame::Panel: |
|
2893 |
switch (frameShadow) { |
|
2894 |
case QFrame::Plain: |
|
2895 |
case QFrame::Raised: |
|
2896 |
case QFrame::Sunken: |
|
2897 |
frameWidth = f->lineWidth; |
|
2898 |
break; |
|
2899 |
} |
|
2900 |
break; |
|
2901 |
} |
|
2902 |
r = f->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth); |
|
2903 |
} |
|
2904 |
break; |
|
2905 |
#ifndef QT_NO_DOCKWIDGET |
|
2906 |
case SE_DockWidgetCloseButton: |
|
2907 |
case SE_DockWidgetFloatButton: |
|
2908 |
case SE_DockWidgetTitleBarText: |
|
2909 |
case SE_DockWidgetIcon: { |
|
2910 |
int iconSize = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); |
|
2911 |
int buttonMargin = proxy()->pixelMetric(PM_DockWidgetTitleBarButtonMargin, opt, widget); |
|
2912 |
int margin = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, opt, widget); |
|
2913 |
QRect rect = opt->rect; |
|
2914 |
||
2915 |
const QStyleOptionDockWidget *dwOpt |
|
2916 |
= qstyleoption_cast<const QStyleOptionDockWidget*>(opt); |
|
2917 |
bool canClose = dwOpt == 0 ? true : dwOpt->closable; |
|
2918 |
bool canFloat = dwOpt == 0 ? false : dwOpt->floatable; |
|
2919 |
const QStyleOptionDockWidgetV2 *v2 |
|
2920 |
= qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt); |
|
2921 |
bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; |
|
2922 |
||
2923 |
// If this is a vertical titlebar, we transpose and work as if it was |
|
2924 |
// horizontal, then transpose again. |
|
2925 |
||
2926 |
if (verticalTitleBar) { |
|
2927 |
QSize size = rect.size(); |
|
2928 |
size.transpose(); |
|
2929 |
rect.setSize(size); |
|
2930 |
} |
|
2931 |
||
2932 |
do { |
|
2933 |
||
2934 |
int right = rect.right(); |
|
2935 |
int left = rect.left(); |
|
2936 |
||
2937 |
QRect closeRect; |
|
2938 |
if (canClose) { |
|
2939 |
QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton, |
|
2940 |
opt, widget).actualSize(QSize(iconSize, iconSize)); |
|
2941 |
sz += QSize(buttonMargin, buttonMargin); |
|
2942 |
if (verticalTitleBar) |
|
2943 |
sz.transpose(); |
|
2944 |
closeRect = QRect(right - sz.width(), |
|
2945 |
rect.center().y() - sz.height()/2, |
|
2946 |
sz.width(), sz.height()); |
|
2947 |
right = closeRect.left() - 1; |
|
2948 |
} |
|
2949 |
if (sr == SE_DockWidgetCloseButton) { |
|
2950 |
r = closeRect; |
|
2951 |
break; |
|
2952 |
} |
|
2953 |
||
2954 |
QRect floatRect; |
|
2955 |
if (canFloat) { |
|
2956 |
QSize sz = standardIcon(QStyle::SP_TitleBarNormalButton, |
|
2957 |
opt, widget).actualSize(QSize(iconSize, iconSize)); |
|
2958 |
sz += QSize(buttonMargin, buttonMargin); |
|
2959 |
if (verticalTitleBar) |
|
2960 |
sz.transpose(); |
|
2961 |
floatRect = QRect(right - sz.width(), |
|
2962 |
rect.center().y() - sz.height()/2, |
|
2963 |
sz.width(), sz.height()); |
|
2964 |
right = floatRect.left() - 1; |
|
2965 |
} |
|
2966 |
if (sr == SE_DockWidgetFloatButton) { |
|
2967 |
r = floatRect; |
|
2968 |
break; |
|
2969 |
} |
|
2970 |
||
2971 |
QRect iconRect; |
|
2972 |
if (const QDockWidget *dw = qobject_cast<const QDockWidget*>(widget)) { |
|
2973 |
QIcon icon; |
|
2974 |
if (dw->isFloating()) |
|
2975 |
icon = dw->windowIcon(); |
|
2976 |
if (!icon.isNull() |
|
2977 |
&& icon.cacheKey() != QApplication::windowIcon().cacheKey()) { |
|
2978 |
QSize sz = icon.actualSize(QSize(r.height(), r.height())); |
|
2979 |
if (verticalTitleBar) |
|
2980 |
sz.transpose(); |
|
2981 |
iconRect = QRect(left, rect.center().y() - sz.height()/2, |
|
2982 |
sz.width(), sz.height()); |
|
2983 |
left = iconRect.right() + margin; |
|
2984 |
} |
|
2985 |
} |
|
2986 |
if (sr == SE_DockWidgetIcon) { |
|
2987 |
r = iconRect; |
|
2988 |
break; |
|
2989 |
} |
|
2990 |
||
2991 |
QRect textRect = QRect(left, rect.top(), |
|
2992 |
right - left, rect.height()); |
|
2993 |
if (sr == SE_DockWidgetTitleBarText) { |
|
2994 |
r = textRect; |
|
2995 |
break; |
|
2996 |
} |
|
2997 |
||
2998 |
} while (false); |
|
2999 |
||
3000 |
if (verticalTitleBar) { |
|
3001 |
r = QRect(rect.left() + r.top() - rect.top(), |
|
3002 |
rect.top() + rect.right() - r.right(), |
|
3003 |
r.height(), r.width()); |
|
3004 |
} else { |
|
3005 |
r = visualRect(opt->direction, rect, r); |
|
3006 |
} |
|
3007 |
break; |
|
3008 |
} |
|
3009 |
#endif |
|
3010 |
#ifndef QT_NO_ITEMVIEWS |
|
3011 |
case SE_ItemViewItemCheckIndicator: |
|
3012 |
if (!qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
3013 |
r = subElementRect(SE_CheckBoxIndicator, opt, widget); |
|
3014 |
break; |
|
3015 |
} |
|
3016 |
case SE_ItemViewItemDecoration: |
|
3017 |
case SE_ItemViewItemText: |
|
3018 |
case SE_ItemViewItemFocusRect: |
|
3019 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
3020 |
if (!d->isViewItemCached(*vopt)) { |
|
3021 |
d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false); |
|
3022 |
if (d->cachedOption) { |
|
3023 |
delete d->cachedOption; |
|
3024 |
d->cachedOption = 0; |
|
3025 |
} |
|
3026 |
d->cachedOption = new QStyleOptionViewItemV4(*vopt); |
|
3027 |
} |
|
3028 |
if (sr == SE_ViewItemCheckIndicator) |
|
3029 |
r = d->checkRect; |
|
3030 |
else if (sr == SE_ItemViewItemDecoration) |
|
3031 |
r = d->decorationRect; |
|
3032 |
else if (sr == SE_ItemViewItemText || sr == SE_ItemViewItemFocusRect) |
|
3033 |
r = d->displayRect; |
|
3034 |
} |
|
3035 |
break; |
|
3036 |
#endif //QT_NO_ITEMVIEWS |
|
3037 |
#ifndef QT_NO_TOOLBAR |
|
3038 |
case SE_ToolBarHandle: |
|
3039 |
if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) { |
|
3040 |
if (tbopt->features & QStyleOptionToolBar::Movable) { |
|
3041 |
///we need to access the widget here because the style option doesn't |
|
3042 |
//have all the information we need (ie. the layout's margin) |
|
3043 |
const QToolBar *tb = qobject_cast<const QToolBar*>(widget); |
|
3044 |
const int margin = tb && tb->layout() ? tb->layout()->margin() : 2; |
|
3045 |
const int handleExtent = pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb); |
|
3046 |
if (tbopt->state & QStyle::State_Horizontal) { |
|
3047 |
r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin); |
|
3048 |
r = QStyle::visualRect(tbopt->direction, tbopt->rect, r); |
|
3049 |
} else { |
|
3050 |
r = QRect(margin, margin, tbopt->rect.width() - 2*margin, handleExtent); |
|
3051 |
} |
|
3052 |
} |
|
3053 |
} |
|
3054 |
break; |
|
3055 |
#endif //QT_NO_TOOLBAR |
|
3056 |
default: |
|
3057 |
break; |
|
3058 |
} |
|
3059 |
return r; |
|
3060 |
} |
|
3061 |
||
3062 |
#ifndef QT_NO_DIAL |
|
3063 |
||
3064 |
static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a) |
|
3065 |
{ |
|
3066 |
int width = dial->rect.width(); |
|
3067 |
int height = dial->rect.height(); |
|
3068 |
int r = qMin(width, height) / 2; |
|
3069 |
int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition); |
|
3070 |
||
3071 |
if (dial->maximum == dial->minimum) |
|
3072 |
a = Q_PI / 2; |
|
3073 |
else if (dial->dialWrapping) |
|
3074 |
a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI |
|
3075 |
/ (dial->maximum - dial->minimum); |
|
3076 |
else |
|
3077 |
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI |
|
3078 |
/ (dial->maximum - dial->minimum)) / 6; |
|
3079 |
||
3080 |
int xc = width / 2; |
|
3081 |
int yc = height / 2; |
|
3082 |
||
3083 |
int len = r - QStyleHelper::calcBigLineSize(r) - 5; |
|
3084 |
if (len < 5) |
|
3085 |
len = 5; |
|
3086 |
int back = len / 2; |
|
3087 |
||
3088 |
QPolygonF arrow(3); |
|
3089 |
arrow[0] = QPointF(0.5 + xc + len * qCos(a), |
|
3090 |
0.5 + yc - len * qSin(a)); |
|
3091 |
arrow[1] = QPointF(0.5 + xc + back * qCos(a + Q_PI * 5 / 6), |
|
3092 |
0.5 + yc - back * qSin(a + Q_PI * 5 / 6)); |
|
3093 |
arrow[2] = QPointF(0.5 + xc + back * qCos(a - Q_PI * 5 / 6), |
|
3094 |
0.5 + yc - back * qSin(a - Q_PI * 5 / 6)); |
|
3095 |
return arrow; |
|
3096 |
} |
|
3097 |
||
3098 |
#endif // QT_NO_DIAL |
|
3099 |
||
3100 |
/*! |
|
3101 |
\reimp |
|
3102 |
*/ |
|
3103 |
void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, |
|
3104 |
QPainter *p, const QWidget *widget) const |
|
3105 |
{ |
|
3106 |
switch (cc) { |
|
3107 |
#ifndef QT_NO_SLIDER |
|
3108 |
case CC_Slider: |
|
3109 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
3110 |
if (slider->subControls == SC_SliderTickmarks) { |
|
3111 |
int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); |
|
3112 |
int ticks = slider->tickPosition; |
|
3113 |
int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); |
|
3114 |
int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); |
|
3115 |
int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); |
|
3116 |
int interval = slider->tickInterval; |
|
3117 |
if (interval <= 0) { |
|
3118 |
interval = slider->singleStep; |
|
3119 |
if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval, |
|
3120 |
available) |
|
3121 |
- QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, |
|
3122 |
0, available) < 3) |
|
3123 |
interval = slider->pageStep; |
|
3124 |
} |
|
3125 |
if (!interval) |
|
3126 |
interval = 1; |
|
3127 |
int fudge = len / 2; |
|
3128 |
int pos; |
|
3129 |
// Since there is no subrect for tickmarks do a translation here. |
|
3130 |
p->save(); |
|
3131 |
p->translate(slider->rect.x(), slider->rect.y()); |
|
3132 |
p->setPen(slider->palette.foreground().color()); |
|
3133 |
int v = slider->minimum; |
|
3134 |
while (v <= slider->maximum + 1) { |
|
3135 |
if (v == slider->maximum + 1 && interval == 1) |
|
3136 |
break; |
|
3137 |
const int v_ = qMin(v, slider->maximum); |
|
3138 |
pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, |
|
3139 |
v_, available) + fudge; |
|
3140 |
if (slider->orientation == Qt::Horizontal) { |
|
3141 |
if (ticks & QSlider::TicksAbove) |
|
3142 |
p->drawLine(pos, 0, pos, tickOffset - 2); |
|
3143 |
if (ticks & QSlider::TicksBelow) |
|
3144 |
p->drawLine(pos, tickOffset + thickness + 1, pos, |
|
3145 |
slider->rect.height()-1); |
|
3146 |
} else { |
|
3147 |
if (ticks & QSlider::TicksAbove) |
|
3148 |
p->drawLine(0, pos, tickOffset - 2, pos); |
|
3149 |
if (ticks & QSlider::TicksBelow) |
|
3150 |
p->drawLine(tickOffset + thickness + 1, pos, |
|
3151 |
slider->rect.width()-1, pos); |
|
3152 |
} |
|
3153 |
// in the case where maximum is max int |
|
3154 |
int nextInterval = v + interval; |
|
3155 |
if (nextInterval < v) |
|
3156 |
break; |
|
3157 |
v = nextInterval; |
|
3158 |
} |
|
3159 |
p->restore(); |
|
3160 |
} |
|
3161 |
} |
|
3162 |
break; |
|
3163 |
#endif // QT_NO_SLIDER |
|
3164 |
#ifndef QT_NO_SCROLLBAR |
|
3165 |
case CC_ScrollBar: |
|
3166 |
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
3167 |
// Make a copy here and reset it for each primitive. |
|
3168 |
QStyleOptionSlider newScrollbar = *scrollbar; |
|
3169 |
State saveFlags = scrollbar->state; |
|
3170 |
||
3171 |
if (scrollbar->subControls & SC_ScrollBarSubLine) { |
|
3172 |
newScrollbar.state = saveFlags; |
|
3173 |
newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget); |
|
3174 |
if (newScrollbar.rect.isValid()) { |
|
3175 |
if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine)) |
|
3176 |
newScrollbar.state &= ~(State_Sunken | State_MouseOver); |
|
3177 |
proxy()->drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget); |
|
3178 |
} |
|
3179 |
} |
|
3180 |
if (scrollbar->subControls & SC_ScrollBarAddLine) { |
|
3181 |
newScrollbar.rect = scrollbar->rect; |
|
3182 |
newScrollbar.state = saveFlags; |
|
3183 |
newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget); |
|
3184 |
if (newScrollbar.rect.isValid()) { |
|
3185 |
if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine)) |
|
3186 |
newScrollbar.state &= ~(State_Sunken | State_MouseOver); |
|
3187 |
proxy()->drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget); |
|
3188 |
} |
|
3189 |
} |
|
3190 |
if (scrollbar->subControls & SC_ScrollBarSubPage) { |
|
3191 |
newScrollbar.rect = scrollbar->rect; |
|
3192 |
newScrollbar.state = saveFlags; |
|
3193 |
newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget); |
|
3194 |
if (newScrollbar.rect.isValid()) { |
|
3195 |
if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage)) |
|
3196 |
newScrollbar.state &= ~(State_Sunken | State_MouseOver); |
|
3197 |
proxy()->drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget); |
|
3198 |
} |
|
3199 |
} |
|
3200 |
if (scrollbar->subControls & SC_ScrollBarAddPage) { |
|
3201 |
newScrollbar.rect = scrollbar->rect; |
|
3202 |
newScrollbar.state = saveFlags; |
|
3203 |
newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget); |
|
3204 |
if (newScrollbar.rect.isValid()) { |
|
3205 |
if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage)) |
|
3206 |
newScrollbar.state &= ~(State_Sunken | State_MouseOver); |
|
3207 |
proxy()->drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget); |
|
3208 |
} |
|
3209 |
} |
|
3210 |
if (scrollbar->subControls & SC_ScrollBarFirst) { |
|
3211 |
newScrollbar.rect = scrollbar->rect; |
|
3212 |
newScrollbar.state = saveFlags; |
|
3213 |
newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget); |
|
3214 |
if (newScrollbar.rect.isValid()) { |
|
3215 |
if (!(scrollbar->activeSubControls & SC_ScrollBarFirst)) |
|
3216 |
newScrollbar.state &= ~(State_Sunken | State_MouseOver); |
|
3217 |
proxy()->drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget); |
|
3218 |
} |
|
3219 |
} |
|
3220 |
if (scrollbar->subControls & SC_ScrollBarLast) { |
|
3221 |
newScrollbar.rect = scrollbar->rect; |
|
3222 |
newScrollbar.state = saveFlags; |
|
3223 |
newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget); |
|
3224 |
if (newScrollbar.rect.isValid()) { |
|
3225 |
if (!(scrollbar->activeSubControls & SC_ScrollBarLast)) |
|
3226 |
newScrollbar.state &= ~(State_Sunken | State_MouseOver); |
|
3227 |
proxy()->drawControl(CE_ScrollBarLast, &newScrollbar, p, widget); |
|
3228 |
} |
|
3229 |
} |
|
3230 |
if (scrollbar->subControls & SC_ScrollBarSlider) { |
|
3231 |
newScrollbar.rect = scrollbar->rect; |
|
3232 |
newScrollbar.state = saveFlags; |
|
3233 |
newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget); |
|
3234 |
if (newScrollbar.rect.isValid()) { |
|
3235 |
if (!(scrollbar->activeSubControls & SC_ScrollBarSlider)) |
|
3236 |
newScrollbar.state &= ~(State_Sunken | State_MouseOver); |
|
3237 |
proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget); |
|
3238 |
||
3239 |
if (scrollbar->state & State_HasFocus) { |
|
3240 |
QStyleOptionFocusRect fropt; |
|
3241 |
fropt.QStyleOption::operator=(newScrollbar); |
|
3242 |
fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2, |
|
3243 |
newScrollbar.rect.width() - 5, |
|
3244 |
newScrollbar.rect.height() - 5); |
|
3245 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); |
|
3246 |
} |
|
3247 |
} |
|
3248 |
} |
|
3249 |
} |
|
3250 |
break; |
|
3251 |
#endif // QT_NO_SCROLLBAR |
|
3252 |
#ifdef QT3_SUPPORT |
|
3253 |
case CC_Q3ListView: |
|
3254 |
if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { |
|
3255 |
if (lv->subControls & SC_Q3ListView) |
|
3256 |
p->fillRect(lv->rect, lv->viewportPalette.brush(lv->viewportBGRole)); |
|
3257 |
} |
|
3258 |
break; |
|
3259 |
#endif // QT3_SUPPORT |
|
3260 |
#ifndef QT_NO_SPINBOX |
|
3261 |
case CC_SpinBox: |
|
3262 |
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { |
|
3263 |
QStyleOptionSpinBox copy = *sb; |
|
3264 |
PrimitiveElement pe; |
|
3265 |
||
3266 |
if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { |
|
3267 |
QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); |
|
3268 |
qDrawWinPanel(p, r, sb->palette, true); |
|
3269 |
} |
|
3270 |
||
3271 |
if (sb->subControls & SC_SpinBoxUp) { |
|
3272 |
copy.subControls = SC_SpinBoxUp; |
|
3273 |
QPalette pal2 = sb->palette; |
|
3274 |
if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) { |
|
3275 |
pal2.setCurrentColorGroup(QPalette::Disabled); |
|
3276 |
copy.state &= ~State_Enabled; |
|
3277 |
} |
|
3278 |
||
3279 |
copy.palette = pal2; |
|
3280 |
||
3281 |
if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) { |
|
3282 |
copy.state |= State_On; |
|
3283 |
copy.state |= State_Sunken; |
|
3284 |
} else { |
|
3285 |
copy.state |= State_Raised; |
|
3286 |
copy.state &= ~State_Sunken; |
|
3287 |
} |
|
3288 |
pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus |
|
3289 |
: PE_IndicatorSpinUp); |
|
3290 |
||
3291 |
copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); |
|
3292 |
proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p, widget); |
|
3293 |
copy.rect.adjust(3, 0, -4, 0); |
|
3294 |
proxy()->drawPrimitive(pe, ©, p, widget); |
|
3295 |
} |
|
3296 |
||
3297 |
if (sb->subControls & SC_SpinBoxDown) { |
|
3298 |
copy.subControls = SC_SpinBoxDown; |
|
3299 |
copy.state = sb->state; |
|
3300 |
QPalette pal2 = sb->palette; |
|
3301 |
if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) { |
|
3302 |
pal2.setCurrentColorGroup(QPalette::Disabled); |
|
3303 |
copy.state &= ~State_Enabled; |
|
3304 |
} |
|
3305 |
copy.palette = pal2; |
|
3306 |
||
3307 |
if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) { |
|
3308 |
copy.state |= State_On; |
|
3309 |
copy.state |= State_Sunken; |
|
3310 |
} else { |
|
3311 |
copy.state |= State_Raised; |
|
3312 |
copy.state &= ~State_Sunken; |
|
3313 |
} |
|
3314 |
pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus |
|
3315 |
: PE_IndicatorSpinDown); |
|
3316 |
||
3317 |
copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); |
|
3318 |
proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p, widget); |
|
3319 |
copy.rect.adjust(3, 0, -4, 0); |
|
3320 |
proxy()->drawPrimitive(pe, ©, p, widget); |
|
3321 |
} |
|
3322 |
} |
|
3323 |
break; |
|
3324 |
#endif // QT_NO_SPINBOX |
|
3325 |
#ifndef QT_NO_TOOLBUTTON |
|
3326 |
case CC_ToolButton: |
|
3327 |
if (const QStyleOptionToolButton *toolbutton |
|
3328 |
= qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { |
|
3329 |
QRect button, menuarea; |
|
3330 |
button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); |
|
3331 |
menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); |
|
3332 |
||
3333 |
State bflags = toolbutton->state & ~State_Sunken; |
|
3334 |
||
3335 |
if (bflags & State_AutoRaise) { |
|
3336 |
if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { |
|
3337 |
bflags &= ~State_Raised; |
|
3338 |
} |
|
3339 |
} |
|
3340 |
State mflags = bflags; |
|
3341 |
if (toolbutton->state & State_Sunken) { |
|
3342 |
if (toolbutton->activeSubControls & SC_ToolButton) |
|
3343 |
bflags |= State_Sunken; |
|
3344 |
mflags |= State_Sunken; |
|
3345 |
} |
|
3346 |
||
3347 |
QStyleOption tool(0); |
|
3348 |
tool.palette = toolbutton->palette; |
|
3349 |
if (toolbutton->subControls & SC_ToolButton) { |
|
3350 |
if (bflags & (State_Sunken | State_On | State_Raised)) { |
|
3351 |
tool.rect = button; |
|
3352 |
tool.state = bflags; |
|
3353 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3354 |
} |
|
3355 |
} |
|
3356 |
||
3357 |
if (toolbutton->state & State_HasFocus) { |
|
3358 |
QStyleOptionFocusRect fr; |
|
3359 |
fr.QStyleOption::operator=(*toolbutton); |
|
3360 |
fr.rect.adjust(3, 3, -3, -3); |
|
3361 |
if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) |
|
3362 |
fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, |
|
3363 |
toolbutton, widget), 0); |
|
3364 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); |
|
3365 |
} |
|
3366 |
QStyleOptionToolButton label = *toolbutton; |
|
3367 |
label.state = bflags; |
|
3368 |
int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); |
|
3369 |
label.rect = button.adjusted(fw, fw, -fw, -fw); |
|
3370 |
proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); |
|
3371 |
||
3372 |
if (toolbutton->subControls & SC_ToolButtonMenu) { |
|
3373 |
tool.rect = menuarea; |
|
3374 |
tool.state = mflags; |
|
3375 |
if (mflags & (State_Sunken | State_On | State_Raised)) |
|
3376 |
proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); |
|
3377 |
proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); |
|
3378 |
} else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { |
|
3379 |
int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); |
|
3380 |
QRect ir = toolbutton->rect; |
|
3381 |
QStyleOptionToolButton newBtn = *toolbutton; |
|
3382 |
newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6); |
|
3383 |
proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); |
|
3384 |
} |
|
3385 |
} |
|
3386 |
break; |
|
3387 |
#endif // QT_NO_TOOLBUTTON |
|
3388 |
case CC_TitleBar: |
|
3389 |
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { |
|
3390 |
QRect ir; |
|
3391 |
if (opt->subControls & SC_TitleBarLabel) { |
|
3392 |
QColor left = tb->palette.highlight().color(); |
|
3393 |
QColor right = tb->palette.base().color(); |
|
3394 |
||
3395 |
QBrush fillBrush(left); |
|
3396 |
if (left != right) { |
|
3397 |
QPoint p1(tb->rect.x(), tb->rect.top() + tb->rect.height()/2); |
|
3398 |
QPoint p2(tb->rect.right(), tb->rect.top() + tb->rect.height()/2); |
|
3399 |
QLinearGradient lg(p1, p2); |
|
3400 |
lg.setColorAt(0, left); |
|
3401 |
lg.setColorAt(1, right); |
|
3402 |
fillBrush = lg; |
|
3403 |
} |
|
3404 |
||
3405 |
p->fillRect(opt->rect, fillBrush); |
|
3406 |
||
3407 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget); |
|
3408 |
||
3409 |
p->setPen(tb->palette.highlightedText().color()); |
|
3410 |
p->drawText(ir.x() + 2, ir.y(), ir.width() - 2, ir.height(), |
|
3411 |
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text); |
|
3412 |
} |
|
3413 |
||
3414 |
bool down = false; |
|
3415 |
QPixmap pm; |
|
3416 |
||
3417 |
QStyleOption tool(0); |
|
3418 |
tool.palette = tb->palette; |
|
3419 |
if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) { |
|
3420 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton, widget); |
|
3421 |
down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken); |
|
3422 |
if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool |
|
3423 |
#ifndef QT_NO_DOCKWIDGET |
|
3424 |
|| qobject_cast<const QDockWidget *>(widget) |
|
3425 |
#endif |
|
3426 |
) |
|
3427 |
pm = standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(10, 10); |
|
3428 |
else |
|
3429 |
pm = standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(10, 10); |
|
3430 |
tool.rect = ir; |
|
3431 |
tool.state = down ? State_Sunken : State_Raised; |
|
3432 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3433 |
||
3434 |
p->save(); |
|
3435 |
if (down) |
|
3436 |
p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), |
|
3437 |
proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); |
|
3438 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3439 |
p->restore(); |
|
3440 |
} |
|
3441 |
||
3442 |
if (tb->subControls & SC_TitleBarMaxButton |
|
3443 |
&& tb->titleBarFlags & Qt::WindowMaximizeButtonHint |
|
3444 |
&& !(tb->titleBarState & Qt::WindowMaximized)) { |
|
3445 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, widget); |
|
3446 |
||
3447 |
down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken); |
|
3448 |
pm = standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(10, 10); |
|
3449 |
tool.rect = ir; |
|
3450 |
tool.state = down ? State_Sunken : State_Raised; |
|
3451 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3452 |
||
3453 |
p->save(); |
|
3454 |
if (down) |
|
3455 |
p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), |
|
3456 |
proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); |
|
3457 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3458 |
p->restore(); |
|
3459 |
} |
|
3460 |
||
3461 |
if (tb->subControls & SC_TitleBarMinButton |
|
3462 |
&& tb->titleBarFlags & Qt::WindowMinimizeButtonHint |
|
3463 |
&& !(tb->titleBarState & Qt::WindowMinimized)) { |
|
3464 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, widget); |
|
3465 |
down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken); |
|
3466 |
pm = standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(10, 10); |
|
3467 |
tool.rect = ir; |
|
3468 |
tool.state = down ? State_Sunken : State_Raised; |
|
3469 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3470 |
||
3471 |
p->save(); |
|
3472 |
if (down) |
|
3473 |
p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), |
|
3474 |
proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); |
|
3475 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3476 |
p->restore(); |
|
3477 |
} |
|
3478 |
||
3479 |
bool drawNormalButton = (tb->subControls & SC_TitleBarNormalButton) |
|
3480 |
&& (((tb->titleBarFlags & Qt::WindowMinimizeButtonHint) |
|
3481 |
&& (tb->titleBarState & Qt::WindowMinimized)) |
|
3482 |
|| ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint) |
|
3483 |
&& (tb->titleBarState & Qt::WindowMaximized))); |
|
3484 |
||
3485 |
if (drawNormalButton) { |
|
3486 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, widget); |
|
3487 |
down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken); |
|
3488 |
pm = standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(10, 10); |
|
3489 |
tool.rect = ir; |
|
3490 |
tool.state = down ? State_Sunken : State_Raised; |
|
3491 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3492 |
||
3493 |
p->save(); |
|
3494 |
if (down) |
|
3495 |
p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), |
|
3496 |
proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); |
|
3497 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3498 |
p->restore(); |
|
3499 |
} |
|
3500 |
||
3501 |
if (tb->subControls & SC_TitleBarShadeButton |
|
3502 |
&& tb->titleBarFlags & Qt::WindowShadeButtonHint |
|
3503 |
&& !(tb->titleBarState & Qt::WindowMinimized)) { |
|
3504 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, widget); |
|
3505 |
down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken)); |
|
3506 |
pm = standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(10, 10); |
|
3507 |
tool.rect = ir; |
|
3508 |
tool.state = down ? State_Sunken : State_Raised; |
|
3509 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3510 |
p->save(); |
|
3511 |
if (down) |
|
3512 |
p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), |
|
3513 |
proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); |
|
3514 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3515 |
p->restore(); |
|
3516 |
} |
|
3517 |
||
3518 |
if (tb->subControls & SC_TitleBarUnshadeButton |
|
3519 |
&& tb->titleBarFlags & Qt::WindowShadeButtonHint |
|
3520 |
&& tb->titleBarState & Qt::WindowMinimized) { |
|
3521 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, widget); |
|
3522 |
||
3523 |
down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken); |
|
3524 |
pm = standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(10, 10); |
|
3525 |
tool.rect = ir; |
|
3526 |
tool.state = down ? State_Sunken : State_Raised; |
|
3527 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3528 |
p->save(); |
|
3529 |
if (down) |
|
3530 |
p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), |
|
3531 |
proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); |
|
3532 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3533 |
p->restore(); |
|
3534 |
} |
|
3535 |
if (tb->subControls & SC_TitleBarContextHelpButton |
|
3536 |
&& tb->titleBarFlags & Qt::WindowContextHelpButtonHint) { |
|
3537 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, widget); |
|
3538 |
||
3539 |
down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken); |
|
3540 |
pm = standardIcon(SP_TitleBarContextHelpButton, &tool, widget).pixmap(10, 10); |
|
3541 |
tool.rect = ir; |
|
3542 |
tool.state = down ? State_Sunken : State_Raised; |
|
3543 |
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); |
|
3544 |
p->save(); |
|
3545 |
if (down) |
|
3546 |
p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), |
|
3547 |
proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); |
|
3548 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3549 |
p->restore(); |
|
3550 |
} |
|
3551 |
if (tb->subControls & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) { |
|
3552 |
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarSysMenu, widget); |
|
3553 |
if (!tb->icon.isNull()) { |
|
3554 |
tb->icon.paint(p, ir); |
|
3555 |
} else { |
|
3556 |
int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget); |
|
3557 |
pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(iconSize, iconSize); |
|
3558 |
tool.rect = ir; |
|
3559 |
p->save(); |
|
3560 |
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); |
|
3561 |
p->restore(); |
|
3562 |
} |
|
3563 |
} |
|
3564 |
} |
|
3565 |
break; |
|
3566 |
#ifndef QT_NO_DIAL |
|
3567 |
case CC_Dial: |
|
3568 |
if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
3569 |
// OK, this is more a port of things over |
|
3570 |
p->save(); |
|
3571 |
||
3572 |
// avoid dithering |
|
3573 |
if (p->paintEngine()->hasFeature(QPaintEngine::Antialiasing)) |
|
3574 |
p->setRenderHint(QPainter::Antialiasing); |
|
3575 |
||
3576 |
int width = dial->rect.width(); |
|
3577 |
int height = dial->rect.height(); |
|
3578 |
qreal r = qMin(width, height) / 2; |
|
3579 |
qreal d_ = r / 6; |
|
3580 |
qreal dx = dial->rect.x() + d_ + (width - 2 * r) / 2 + 1; |
|
3581 |
qreal dy = dial->rect.y() + d_ + (height - 2 * r) / 2 + 1; |
|
3582 |
QRect br = QRect(int(dx), int(dy), int(r * 2 - 2 * d_ - 2), int(r * 2 - 2 * d_ - 2)); |
|
3583 |
||
3584 |
QPalette pal = opt->palette; |
|
3585 |
// draw notches |
|
3586 |
if (dial->subControls & QStyle::SC_DialTickmarks) { |
|
3587 |
p->setPen(pal.foreground().color()); |
|
3588 |
p->drawLines(QStyleHelper::calcLines(dial)); |
|
3589 |
} |
|
3590 |
||
3591 |
if (dial->state & State_Enabled) { |
|
3592 |
p->setBrush(pal.brush(QPalette::ColorRole(proxy()->styleHint(SH_Dial_BackgroundRole, |
|
3593 |
dial, widget)))); |
|
3594 |
p->setPen(Qt::NoPen); |
|
3595 |
p->drawEllipse(br); |
|
3596 |
p->setBrush(Qt::NoBrush); |
|
3597 |
} |
|
3598 |
p->setPen(QPen(pal.dark().color())); |
|
3599 |
p->drawArc(br, 60 * 16, 180 * 16); |
|
3600 |
p->setPen(QPen(pal.light().color())); |
|
3601 |
p->drawArc(br, 240 * 16, 180 * 16); |
|
3602 |
||
3603 |
qreal a; |
|
3604 |
QPolygonF arrow(calcArrow(dial, a)); |
|
3605 |
||
3606 |
p->setPen(Qt::NoPen); |
|
3607 |
p->setBrush(pal.button()); |
|
3608 |
p->drawPolygon(arrow); |
|
3609 |
||
3610 |
a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]); |
|
3611 |
p->setBrush(Qt::NoBrush); |
|
3612 |
||
3613 |
if (a <= 0 || a > 200) { |
|
3614 |
p->setPen(pal.light().color()); |
|
3615 |
p->drawLine(arrow[2], arrow[0]); |
|
3616 |
p->drawLine(arrow[1], arrow[2]); |
|
3617 |
p->setPen(pal.dark().color()); |
|
3618 |
p->drawLine(arrow[0], arrow[1]); |
|
3619 |
} else if (a > 0 && a < 45) { |
|
3620 |
p->setPen(pal.light().color()); |
|
3621 |
p->drawLine(arrow[2], arrow[0]); |
|
3622 |
p->setPen(pal.dark().color()); |
|
3623 |
p->drawLine(arrow[1], arrow[2]); |
|
3624 |
p->drawLine(arrow[0], arrow[1]); |
|
3625 |
} else if (a >= 45 && a < 135) { |
|
3626 |
p->setPen(pal.dark().color()); |
|
3627 |
p->drawLine(arrow[2], arrow[0]); |
|
3628 |
p->drawLine(arrow[1], arrow[2]); |
|
3629 |
p->setPen(pal.light().color()); |
|
3630 |
p->drawLine(arrow[0], arrow[1]); |
|
3631 |
} else if (a >= 135 && a < 200) { |
|
3632 |
p->setPen(pal.dark().color()); |
|
3633 |
p->drawLine(arrow[2], arrow[0]); |
|
3634 |
p->setPen(pal.light().color()); |
|
3635 |
p->drawLine(arrow[0], arrow[1]); |
|
3636 |
p->drawLine(arrow[1], arrow[2]); |
|
3637 |
} |
|
3638 |
||
3639 |
// draw focus rect around the dial |
|
3640 |
QStyleOptionFocusRect fropt; |
|
3641 |
fropt.rect = dial->rect; |
|
3642 |
fropt.state = dial->state; |
|
3643 |
fropt.palette = dial->palette; |
|
3644 |
if (fropt.state & QStyle::State_HasFocus) { |
|
3645 |
br.adjust(0, 0, 2, 2); |
|
3646 |
if (dial->subControls & SC_DialTickmarks) { |
|
3647 |
int r = qMin(width, height) / 2; |
|
3648 |
br.translate(-r / 6, - r / 6); |
|
3649 |
br.setWidth(br.width() + r / 3); |
|
3650 |
br.setHeight(br.height() + r / 3); |
|
3651 |
} |
|
3652 |
fropt.rect = br.adjusted(-2, -2, 2, 2); |
|
3653 |
proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &fropt, p, widget); |
|
3654 |
} |
|
3655 |
p->restore(); |
|
3656 |
} |
|
3657 |
break; |
|
3658 |
#endif // QT_NO_DIAL |
|
3659 |
#ifndef QT_NO_GROUPBOX |
|
3660 |
case CC_GroupBox: |
|
3661 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) { |
|
3662 |
// Draw frame |
|
3663 |
QRect textRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, widget); |
|
3664 |
QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget); |
|
3665 |
if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { |
|
3666 |
QStyleOptionFrameV2 frame; |
|
3667 |
frame.QStyleOption::operator=(*groupBox); |
|
3668 |
frame.features = groupBox->features; |
|
3669 |
frame.lineWidth = groupBox->lineWidth; |
|
3670 |
frame.midLineWidth = groupBox->midLineWidth; |
|
3671 |
frame.rect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, widget); |
|
3672 |
p->save(); |
|
3673 |
QRegion region(groupBox->rect); |
|
3674 |
if (!groupBox->text.isEmpty()) { |
|
3675 |
bool ltr = groupBox->direction == Qt::LeftToRight; |
|
3676 |
QRect finalRect; |
|
3677 |
if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) { |
|
3678 |
finalRect = checkBoxRect.united(textRect); |
|
3679 |
finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0); |
|
3680 |
} else { |
|
3681 |
finalRect = textRect; |
|
3682 |
} |
|
3683 |
region -= finalRect; |
|
3684 |
} |
|
3685 |
p->setClipRegion(region); |
|
3686 |
proxy()->drawPrimitive(PE_FrameGroupBox, &frame, p, widget); |
|
3687 |
p->restore(); |
|
3688 |
} |
|
3689 |
||
3690 |
// Draw title |
|
3691 |
if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { |
|
3692 |
QColor textColor = groupBox->textColor; |
|
3693 |
if (textColor.isValid()) |
|
3694 |
p->setPen(textColor); |
|
3695 |
int alignment = int(groupBox->textAlignment); |
|
3696 |
if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, opt, widget)) |
|
3697 |
alignment |= Qt::TextHideMnemonic; |
|
3698 |
||
3699 |
proxy()->drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment, |
|
3700 |
groupBox->palette, groupBox->state & State_Enabled, groupBox->text, |
|
3701 |
textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); |
|
3702 |
||
3703 |
if (groupBox->state & State_HasFocus) { |
|
3704 |
QStyleOptionFocusRect fropt; |
|
3705 |
fropt.QStyleOption::operator=(*groupBox); |
|
3706 |
fropt.rect = textRect; |
|
3707 |
proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); |
|
3708 |
} |
|
3709 |
} |
|
3710 |
||
3711 |
// Draw checkbox |
|
3712 |
if (groupBox->subControls & SC_GroupBoxCheckBox) { |
|
3713 |
QStyleOptionButton box; |
|
3714 |
box.QStyleOption::operator=(*groupBox); |
|
3715 |
box.rect = checkBoxRect; |
|
3716 |
proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, p, widget); |
|
3717 |
} |
|
3718 |
} |
|
3719 |
break; |
|
3720 |
#endif // QT_NO_GROUPBOX |
|
3721 |
#ifndef QT_NO_WORKSPACE |
|
3722 |
case CC_MdiControls: |
|
3723 |
{ |
|
3724 |
QStyleOptionButton btnOpt; |
|
3725 |
btnOpt.QStyleOption::operator=(*opt); |
|
3726 |
btnOpt.state &= ~State_MouseOver; |
|
3727 |
int bsx = 0; |
|
3728 |
int bsy = 0; |
|
3729 |
if (opt->subControls & QStyle::SC_MdiCloseButton) { |
|
3730 |
if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) { |
|
3731 |
btnOpt.state |= State_Sunken; |
|
3732 |
btnOpt.state &= ~State_Raised; |
|
3733 |
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); |
|
3734 |
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); |
|
3735 |
} else { |
|
3736 |
btnOpt.state |= State_Raised; |
|
3737 |
btnOpt.state &= ~State_Sunken; |
|
3738 |
bsx = 0; |
|
3739 |
bsy = 0; |
|
3740 |
} |
|
3741 |
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget); |
|
3742 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); |
|
3743 |
QPixmap pm = standardIcon(SP_TitleBarCloseButton).pixmap(16, 16); |
|
3744 |
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); |
|
3745 |
} |
|
3746 |
if (opt->subControls & QStyle::SC_MdiNormalButton) { |
|
3747 |
if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) { |
|
3748 |
btnOpt.state |= State_Sunken; |
|
3749 |
btnOpt.state &= ~State_Raised; |
|
3750 |
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); |
|
3751 |
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); |
|
3752 |
} else { |
|
3753 |
btnOpt.state |= State_Raised; |
|
3754 |
btnOpt.state &= ~State_Sunken; |
|
3755 |
bsx = 0; |
|
3756 |
bsy = 0; |
|
3757 |
} |
|
3758 |
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget); |
|
3759 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); |
|
3760 |
QPixmap pm = standardIcon(SP_TitleBarNormalButton).pixmap(16, 16); |
|
3761 |
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); |
|
3762 |
} |
|
3763 |
if (opt->subControls & QStyle::SC_MdiMinButton) { |
|
3764 |
if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) { |
|
3765 |
btnOpt.state |= State_Sunken; |
|
3766 |
btnOpt.state &= ~State_Raised; |
|
3767 |
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); |
|
3768 |
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); |
|
3769 |
} else { |
|
3770 |
btnOpt.state |= State_Raised; |
|
3771 |
btnOpt.state &= ~State_Sunken; |
|
3772 |
bsx = 0; |
|
3773 |
bsy = 0; |
|
3774 |
} |
|
3775 |
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget); |
|
3776 |
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); |
|
3777 |
QPixmap pm = standardIcon(SP_TitleBarMinButton).pixmap(16, 16); |
|
3778 |
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); |
|
3779 |
} |
|
3780 |
} |
|
3781 |
break; |
|
3782 |
#endif // QT_NO_WORKSPACE |
|
3783 |
||
3784 |
default: |
|
3785 |
qWarning("QCommonStyle::drawComplexControl: Control %d not handled", cc); |
|
3786 |
} |
|
3787 |
} |
|
3788 |
||
3789 |
/*! |
|
3790 |
\reimp |
|
3791 |
*/ |
|
3792 |
QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, |
|
3793 |
const QPoint &pt, const QWidget *widget) const |
|
3794 |
{ |
|
3795 |
SubControl sc = SC_None; |
|
3796 |
switch (cc) { |
|
3797 |
#ifndef QT_NO_SLIDER |
|
3798 |
case CC_Slider: |
|
3799 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
3800 |
QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget); |
|
3801 |
if (r.isValid() && r.contains(pt)) { |
|
3802 |
sc = SC_SliderHandle; |
|
3803 |
} else { |
|
3804 |
r = proxy()->subControlRect(cc, slider, SC_SliderGroove ,widget); |
|
3805 |
if (r.isValid() && r.contains(pt)) |
|
3806 |
sc = SC_SliderGroove; |
|
3807 |
} |
|
3808 |
} |
|
3809 |
break; |
|
3810 |
#endif // QT_NO_SLIDER |
|
3811 |
#ifndef QT_NO_SCROLLBAR |
|
3812 |
case CC_ScrollBar: |
|
3813 |
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
3814 |
QRect r; |
|
3815 |
uint ctrl = SC_ScrollBarAddLine; |
|
3816 |
while (ctrl <= SC_ScrollBarGroove) { |
|
3817 |
r = proxy()->subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget); |
|
3818 |
if (r.isValid() && r.contains(pt)) { |
|
3819 |
sc = QStyle::SubControl(ctrl); |
|
3820 |
break; |
|
3821 |
} |
|
3822 |
ctrl <<= 1; |
|
3823 |
} |
|
3824 |
} |
|
3825 |
break; |
|
3826 |
#endif // QT_NO_SCROLLBAR |
|
3827 |
#ifndef QT_NO_TOOLBUTTON |
|
3828 |
case CC_ToolButton: |
|
3829 |
if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { |
|
3830 |
QRect r; |
|
3831 |
uint ctrl = SC_ToolButton; |
|
3832 |
while (ctrl <= SC_ToolButtonMenu) { |
|
3833 |
r = proxy()->subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget); |
|
3834 |
if (r.isValid() && r.contains(pt)) { |
|
3835 |
sc = QStyle::SubControl(ctrl); |
|
3836 |
break; |
|
3837 |
} |
|
3838 |
ctrl <<= 1; |
|
3839 |
} |
|
3840 |
} |
|
3841 |
break; |
|
3842 |
#endif // QT_NO_TOOLBUTTON |
|
3843 |
#ifdef QT3_SUPPORT |
|
3844 |
case CC_Q3ListView: |
|
3845 |
if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) { |
|
3846 |
if (pt.x() >= 0 && pt.x() < lv->treeStepSize) |
|
3847 |
sc = SC_Q3ListViewExpand; |
|
3848 |
} |
|
3849 |
break; |
|
3850 |
#endif // QT3_SUPPORT |
|
3851 |
#ifndef QT_NO_SPINBOX |
|
3852 |
case CC_SpinBox: |
|
3853 |
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { |
|
3854 |
QRect r; |
|
3855 |
uint ctrl = SC_SpinBoxUp; |
|
3856 |
while (ctrl <= SC_SpinBoxEditField) { |
|
3857 |
r = proxy()->subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget); |
|
3858 |
if (r.isValid() && r.contains(pt)) { |
|
3859 |
sc = QStyle::SubControl(ctrl); |
|
3860 |
break; |
|
3861 |
} |
|
3862 |
ctrl <<= 1; |
|
3863 |
} |
|
3864 |
} |
|
3865 |
break; |
|
3866 |
#endif // QT_NO_SPINBOX |
|
3867 |
case CC_TitleBar: |
|
3868 |
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { |
|
3869 |
QRect r; |
|
3870 |
uint ctrl = SC_TitleBarSysMenu; |
|
3871 |
||
3872 |
while (ctrl <= SC_TitleBarLabel) { |
|
3873 |
r = proxy()->subControlRect(cc, tb, QStyle::SubControl(ctrl), widget); |
|
3874 |
if (r.isValid() && r.contains(pt)) { |
|
3875 |
sc = QStyle::SubControl(ctrl); |
|
3876 |
break; |
|
3877 |
} |
|
3878 |
ctrl <<= 1; |
|
3879 |
} |
|
3880 |
} |
|
3881 |
break; |
|
3882 |
#ifndef QT_NO_COMBOBOX |
|
3883 |
case CC_ComboBox: |
|
3884 |
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { |
|
3885 |
QRect r; |
|
3886 |
uint ctrl = SC_ComboBoxArrow; // Start here and go down. |
|
3887 |
while (ctrl > 0) { |
|
3888 |
r = proxy()->subControlRect(cc, cb, QStyle::SubControl(ctrl), widget); |
|
3889 |
if (r.isValid() && r.contains(pt)) { |
|
3890 |
sc = QStyle::SubControl(ctrl); |
|
3891 |
break; |
|
3892 |
} |
|
3893 |
ctrl >>= 1; |
|
3894 |
} |
|
3895 |
} |
|
3896 |
break; |
|
3897 |
#endif // QT_NO_COMBOBOX |
|
3898 |
#ifndef QT_NO_GROUPBOX |
|
3899 |
case CC_GroupBox: |
|
3900 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) { |
|
3901 |
QRect r; |
|
3902 |
uint ctrl = SC_GroupBoxCheckBox; |
|
3903 |
while (ctrl <= SC_GroupBoxFrame) { |
|
3904 |
r = proxy()->subControlRect(cc, groupBox, QStyle::SubControl(ctrl), widget); |
|
3905 |
if (r.isValid() && r.contains(pt)) { |
|
3906 |
sc = QStyle::SubControl(ctrl); |
|
3907 |
break; |
|
3908 |
} |
|
3909 |
ctrl <<= 1; |
|
3910 |
} |
|
3911 |
} |
|
3912 |
break; |
|
3913 |
#endif // QT_NO_GROUPBOX |
|
3914 |
case CC_MdiControls: |
|
3915 |
{ |
|
3916 |
QRect r; |
|
3917 |
uint ctrl = SC_MdiMinButton; |
|
3918 |
while (ctrl <= SC_MdiCloseButton) { |
|
3919 |
r = proxy()->subControlRect(CC_MdiControls, opt, QStyle::SubControl(ctrl), widget); |
|
3920 |
if (r.isValid() && r.contains(pt) && (opt->subControls & ctrl)) { |
|
3921 |
sc = QStyle::SubControl(ctrl); |
|
3922 |
return sc; |
|
3923 |
} |
|
3924 |
ctrl <<= 1; |
|
3925 |
} |
|
3926 |
} |
|
3927 |
break; |
|
3928 |
default: |
|
3929 |
qWarning("QCommonStyle::hitTestComplexControl: Case %d not handled", cc); |
|
3930 |
} |
|
3931 |
return sc; |
|
3932 |
} |
|
3933 |
||
3934 |
/*! |
|
3935 |
\reimp |
|
3936 |
*/ |
|
3937 |
QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, |
|
3938 |
SubControl sc, const QWidget *widget) const |
|
3939 |
{ |
|
3940 |
QRect ret; |
|
3941 |
switch (cc) { |
|
3942 |
#ifndef QT_NO_SLIDER |
|
3943 |
case CC_Slider: |
|
3944 |
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
3945 |
int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); |
|
3946 |
int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); |
|
3947 |
||
3948 |
switch (sc) { |
|
3949 |
case SC_SliderHandle: { |
|
3950 |
int sliderPos = 0; |
|
3951 |
int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); |
|
3952 |
bool horizontal = slider->orientation == Qt::Horizontal; |
|
3953 |
sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, |
|
3954 |
slider->sliderPosition, |
|
3955 |
(horizontal ? slider->rect.width() |
|
3956 |
: slider->rect.height()) - len, |
|
3957 |
slider->upsideDown); |
|
3958 |
if (horizontal) |
|
3959 |
ret.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness); |
|
3960 |
else |
|
3961 |
ret.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len); |
|
3962 |
break; } |
|
3963 |
case SC_SliderGroove: |
|
3964 |
if (slider->orientation == Qt::Horizontal) |
|
3965 |
ret.setRect(slider->rect.x(), slider->rect.y() + tickOffset, |
|
3966 |
slider->rect.width(), thickness); |
|
3967 |
else |
|
3968 |
ret.setRect(slider->rect.x() + tickOffset, slider->rect.y(), |
|
3969 |
thickness, slider->rect.height()); |
|
3970 |
break; |
|
3971 |
default: |
|
3972 |
break; |
|
3973 |
} |
|
3974 |
ret = visualRect(slider->direction, slider->rect, ret); |
|
3975 |
} |
|
3976 |
break; |
|
3977 |
#endif // QT_NO_SLIDER |
|
3978 |
#ifndef QT_NO_SCROLLBAR |
|
3979 |
case CC_ScrollBar: |
|
3980 |
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
3981 |
const QRect scrollBarRect = scrollbar->rect; |
|
3982 |
int sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget); |
|
3983 |
int maxlen = ((scrollbar->orientation == Qt::Horizontal) ? |
|
3984 |
scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2); |
|
3985 |
int sliderlen; |
|
3986 |
||
3987 |
// calculate slider length |
|
3988 |
if (scrollbar->maximum != scrollbar->minimum) { |
|
3989 |
uint range = scrollbar->maximum - scrollbar->minimum; |
|
3990 |
sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep); |
|
3991 |
||
3992 |
int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget); |
|
3993 |
if (sliderlen < slidermin || range > INT_MAX / 2) |
|
3994 |
sliderlen = slidermin; |
|
3995 |
if (sliderlen > maxlen) |
|
3996 |
sliderlen = maxlen; |
|
3997 |
} else { |
|
3998 |
sliderlen = maxlen; |
|
3999 |
} |
|
4000 |
||
4001 |
int sliderstart = sbextent + sliderPositionFromValue(scrollbar->minimum, |
|
4002 |
scrollbar->maximum, |
|
4003 |
scrollbar->sliderPosition, |
|
4004 |
maxlen - sliderlen, |
|
4005 |
scrollbar->upsideDown); |
|
4006 |
||
4007 |
switch (sc) { |
|
4008 |
case SC_ScrollBarSubLine: // top/left button |
|
4009 |
if (scrollbar->orientation == Qt::Horizontal) { |
|
4010 |
int buttonWidth = qMin(scrollBarRect.width() / 2, sbextent); |
|
4011 |
ret.setRect(0, 0, buttonWidth, scrollBarRect.height()); |
|
4012 |
} else { |
|
4013 |
int buttonHeight = qMin(scrollBarRect.height() / 2, sbextent); |
|
4014 |
ret.setRect(0, 0, scrollBarRect.width(), buttonHeight); |
|
4015 |
} |
|
4016 |
break; |
|
4017 |
case SC_ScrollBarAddLine: // bottom/right button |
|
4018 |
if (scrollbar->orientation == Qt::Horizontal) { |
|
4019 |
int buttonWidth = qMin(scrollBarRect.width()/2, sbextent); |
|
4020 |
ret.setRect(scrollBarRect.width() - buttonWidth, 0, buttonWidth, scrollBarRect.height()); |
|
4021 |
} else { |
|
4022 |
int buttonHeight = qMin(scrollBarRect.height()/2, sbextent); |
|
4023 |
ret.setRect(0, scrollBarRect.height() - buttonHeight, scrollBarRect.width(), buttonHeight); |
|
4024 |
} |
|
4025 |
break; |
|
4026 |
case SC_ScrollBarSubPage: // between top/left button and slider |
|
4027 |
if (scrollbar->orientation == Qt::Horizontal) |
|
4028 |
ret.setRect(sbextent, 0, sliderstart - sbextent, scrollBarRect.height()); |
|
4029 |
else |
|
4030 |
ret.setRect(0, sbextent, scrollBarRect.width(), sliderstart - sbextent); |
|
4031 |
break; |
|
4032 |
case SC_ScrollBarAddPage: // between bottom/right button and slider |
|
4033 |
if (scrollbar->orientation == Qt::Horizontal) |
|
4034 |
ret.setRect(sliderstart + sliderlen, 0, |
|
4035 |
maxlen - sliderstart - sliderlen + sbextent, scrollBarRect.height()); |
|
4036 |
else |
|
4037 |
ret.setRect(0, sliderstart + sliderlen, scrollBarRect.width(), |
|
4038 |
maxlen - sliderstart - sliderlen + sbextent); |
|
4039 |
break; |
|
4040 |
case SC_ScrollBarGroove: |
|
4041 |
if (scrollbar->orientation == Qt::Horizontal) |
|
4042 |
ret.setRect(sbextent, 0, scrollBarRect.width() - sbextent * 2, |
|
4043 |
scrollBarRect.height()); |
|
4044 |
else |
|
4045 |
ret.setRect(0, sbextent, scrollBarRect.width(), |
|
4046 |
scrollBarRect.height() - sbextent * 2); |
|
4047 |
break; |
|
4048 |
case SC_ScrollBarSlider: |
|
4049 |
if (scrollbar->orientation == Qt::Horizontal) |
|
4050 |
ret.setRect(sliderstart, 0, sliderlen, scrollBarRect.height()); |
|
4051 |
else |
|
4052 |
ret.setRect(0, sliderstart, scrollBarRect.width(), sliderlen); |
|
4053 |
break; |
|
4054 |
default: |
|
4055 |
break; |
|
4056 |
} |
|
4057 |
ret = visualRect(scrollbar->direction, scrollBarRect, ret); |
|
4058 |
} |
|
4059 |
break; |
|
4060 |
#endif // QT_NO_SCROLLBAR |
|
4061 |
#ifndef QT_NO_SPINBOX |
|
4062 |
case CC_SpinBox: |
|
4063 |
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { |
|
4064 |
QSize bs; |
|
4065 |
int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; |
|
4066 |
bs.setHeight(qMax(8, spinbox->rect.height()/2 - fw)); |
|
4067 |
// 1.6 -approximate golden mean |
|
4068 |
bs.setWidth(qMax(16, qMin(bs.height() * 8 / 5, spinbox->rect.width() / 4))); |
|
4069 |
bs = bs.expandedTo(QApplication::globalStrut()); |
|
4070 |
int y = fw + spinbox->rect.y(); |
|
4071 |
int x, lx, rx; |
|
4072 |
x = spinbox->rect.x() + spinbox->rect.width() - fw - bs.width(); |
|
4073 |
lx = fw; |
|
4074 |
rx = x - fw; |
|
4075 |
switch (sc) { |
|
4076 |
case SC_SpinBoxUp: |
|
4077 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
4078 |
return QRect(); |
|
4079 |
ret = QRect(x, y, bs.width(), bs.height()); |
|
4080 |
break; |
|
4081 |
case SC_SpinBoxDown: |
|
4082 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) |
|
4083 |
return QRect(); |
|
4084 |
||
4085 |
ret = QRect(x, y + bs.height(), bs.width(), bs.height()); |
|
4086 |
break; |
|
4087 |
case SC_SpinBoxEditField: |
|
4088 |
if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) { |
|
4089 |
ret = QRect(lx, fw, spinbox->rect.width() - 2*fw, spinbox->rect.height() - 2*fw); |
|
4090 |
} else { |
|
4091 |
ret = QRect(lx, fw, rx, spinbox->rect.height() - 2*fw); |
|
4092 |
} |
|
4093 |
break; |
|
4094 |
case SC_SpinBoxFrame: |
|
4095 |
ret = spinbox->rect; |
|
4096 |
default: |
|
4097 |
break; |
|
4098 |
} |
|
4099 |
ret = visualRect(spinbox->direction, spinbox->rect, ret); |
|
4100 |
} |
|
4101 |
break; |
|
4102 |
#endif // Qt_NO_SPINBOX |
|
4103 |
#ifndef QT_NO_TOOLBUTTON |
|
4104 |
case CC_ToolButton: |
|
4105 |
if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { |
|
4106 |
int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb, widget); |
|
4107 |
ret = tb->rect; |
|
4108 |
switch (sc) { |
|
4109 |
case SC_ToolButton: |
|
4110 |
if ((tb->features |
|
4111 |
& (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) |
|
4112 |
== QStyleOptionToolButton::MenuButtonPopup) |
|
4113 |
ret.adjust(0, 0, -mbi, 0); |
|
4114 |
break; |
|
4115 |
case SC_ToolButtonMenu: |
|
4116 |
if ((tb->features |
|
4117 |
& (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) |
|
4118 |
== QStyleOptionToolButton::MenuButtonPopup) |
|
4119 |
ret.adjust(ret.width() - mbi, 0, 0, 0); |
|
4120 |
break; |
|
4121 |
default: |
|
4122 |
break; |
|
4123 |
} |
|
4124 |
ret = visualRect(tb->direction, tb->rect, ret); |
|
4125 |
} |
|
4126 |
break; |
|
4127 |
#endif // QT_NO_TOOLBUTTON |
|
4128 |
#ifndef QT_NO_COMBOBOX |
|
4129 |
case CC_ComboBox: |
|
4130 |
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { |
|
4131 |
int x = cb->rect.x(), |
|
4132 |
y = cb->rect.y(), |
|
4133 |
wi = cb->rect.width(), |
|
4134 |
he = cb->rect.height(); |
|
4135 |
int xpos = x; |
|
4136 |
int margin = cb->frame ? 3 : 0; |
|
4137 |
int bmarg = cb->frame ? 2 : 0; |
|
4138 |
xpos += wi - bmarg - 16; |
|
4139 |
||
4140 |
||
4141 |
switch (sc) { |
|
4142 |
case SC_ComboBoxFrame: |
|
4143 |
ret = cb->rect; |
|
4144 |
break; |
|
4145 |
case SC_ComboBoxArrow: |
|
4146 |
ret.setRect(xpos, y + bmarg, 16, he - 2*bmarg); |
|
4147 |
break; |
|
4148 |
case SC_ComboBoxEditField: |
|
4149 |
ret.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin); |
|
4150 |
break; |
|
4151 |
case SC_ComboBoxListBoxPopup: |
|
4152 |
ret = cb->rect; |
|
4153 |
break; |
|
4154 |
default: |
|
4155 |
break; |
|
4156 |
} |
|
4157 |
ret = visualRect(cb->direction, cb->rect, ret); |
|
4158 |
} |
|
4159 |
break; |
|
4160 |
#endif // QT_NO_COMBOBOX |
|
4161 |
case CC_TitleBar: |
|
4162 |
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { |
|
4163 |
const int controlMargin = 2; |
|
4164 |
const int controlHeight = tb->rect.height() - controlMargin *2; |
|
4165 |
const int delta = controlHeight + controlMargin; |
|
4166 |
int offset = 0; |
|
4167 |
||
4168 |
bool isMinimized = tb->titleBarState & Qt::WindowMinimized; |
|
4169 |
bool isMaximized = tb->titleBarState & Qt::WindowMaximized; |
|
4170 |
||
4171 |
switch (sc) { |
|
4172 |
case SC_TitleBarLabel: |
|
4173 |
if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) { |
|
4174 |
ret = tb->rect; |
|
4175 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint) |
|
4176 |
ret.adjust(delta, 0, -delta, 0); |
|
4177 |
if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) |
|
4178 |
ret.adjust(0, 0, -delta, 0); |
|
4179 |
if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) |
|
4180 |
ret.adjust(0, 0, -delta, 0); |
|
4181 |
if (tb->titleBarFlags & Qt::WindowShadeButtonHint) |
|
4182 |
ret.adjust(0, 0, -delta, 0); |
|
4183 |
if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) |
|
4184 |
ret.adjust(0, 0, -delta, 0); |
|
4185 |
} |
|
4186 |
break; |
|
4187 |
case SC_TitleBarContextHelpButton: |
|
4188 |
if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) |
|
4189 |
offset += delta; |
|
4190 |
case SC_TitleBarMinButton: |
|
4191 |
if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) |
|
4192 |
offset += delta; |
|
4193 |
else if (sc == SC_TitleBarMinButton) |
|
4194 |
break; |
|
4195 |
case SC_TitleBarNormalButton: |
|
4196 |
if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) |
|
4197 |
offset += delta; |
|
4198 |
else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) |
|
4199 |
offset += delta; |
|
4200 |
else if (sc == SC_TitleBarNormalButton) |
|
4201 |
break; |
|
4202 |
case SC_TitleBarMaxButton: |
|
4203 |
if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) |
|
4204 |
offset += delta; |
|
4205 |
else if (sc == SC_TitleBarMaxButton) |
|
4206 |
break; |
|
4207 |
case SC_TitleBarShadeButton: |
|
4208 |
if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) |
|
4209 |
offset += delta; |
|
4210 |
else if (sc == SC_TitleBarShadeButton) |
|
4211 |
break; |
|
4212 |
case SC_TitleBarUnshadeButton: |
|
4213 |
if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) |
|
4214 |
offset += delta; |
|
4215 |
else if (sc == SC_TitleBarUnshadeButton) |
|
4216 |
break; |
|
4217 |
case SC_TitleBarCloseButton: |
|
4218 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint) |
|
4219 |
offset += delta; |
|
4220 |
else if (sc == SC_TitleBarCloseButton) |
|
4221 |
break; |
|
4222 |
ret.setRect(tb->rect.right() - offset, tb->rect.top() + controlMargin, |
|
4223 |
controlHeight, controlHeight); |
|
4224 |
break; |
|
4225 |
case SC_TitleBarSysMenu: |
|
4226 |
if (tb->titleBarFlags & Qt::WindowSystemMenuHint) { |
|
4227 |
ret.setRect(tb->rect.left() + controlMargin, tb->rect.top() + controlMargin, |
|
4228 |
controlHeight, controlHeight); |
|
4229 |
} |
|
4230 |
break; |
|
4231 |
default: |
|
4232 |
break; |
|
4233 |
} |
|
4234 |
ret = visualRect(tb->direction, tb->rect, ret); |
|
4235 |
} |
|
4236 |
break; |
|
4237 |
#ifndef QT_NO_GROUPBOX |
|
4238 |
case CC_GroupBox: { |
|
4239 |
if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) { |
|
4240 |
switch (sc) { |
|
4241 |
case SC_GroupBoxFrame: |
|
4242 |
// FALL THROUGH |
|
4243 |
case SC_GroupBoxContents: { |
|
4244 |
int topMargin = 0; |
|
4245 |
int topHeight = 0; |
|
4246 |
int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); |
|
4247 |
if (groupBox->text.size() || (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)) { |
|
4248 |
topHeight = groupBox->fontMetrics.height(); |
|
4249 |
if (verticalAlignment & Qt::AlignVCenter) |
|
4250 |
topMargin = topHeight / 2; |
|
4251 |
else if (verticalAlignment & Qt::AlignTop) |
|
4252 |
topMargin = topHeight; |
|
4253 |
} |
|
4254 |
||
4255 |
QRect frameRect = groupBox->rect; |
|
4256 |
frameRect.setTop(topMargin); |
|
4257 |
||
4258 |
if (sc == SC_GroupBoxFrame) { |
|
4259 |
ret = frameRect; |
|
4260 |
break; |
|
4261 |
} |
|
4262 |
||
4263 |
int frameWidth = 0; |
|
4264 |
if (!(widget && widget->inherits("Q3GroupBox")) |
|
4265 |
&& ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)) { |
|
4266 |
frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, groupBox, widget); |
|
4267 |
} |
|
4268 |
ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin, |
|
4269 |
-frameWidth, -frameWidth); |
|
4270 |
break; |
|
4271 |
} |
|
4272 |
case SC_GroupBoxCheckBox: |
|
4273 |
// FALL THROUGH |
|
4274 |
case SC_GroupBoxLabel: { |
|
4275 |
QFontMetrics fontMetrics = groupBox->fontMetrics; |
|
4276 |
int h = fontMetrics.height(); |
|
4277 |
int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width(); |
|
4278 |
int marg = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 8; |
|
4279 |
ret = groupBox->rect.adjusted(marg, 0, -marg, 0); |
|
4280 |
ret.setHeight(h); |
|
4281 |
||
4282 |
int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget); |
|
4283 |
int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1; |
|
4284 |
bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox; |
|
4285 |
int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0; |
|
4286 |
||
4287 |
// Adjusted rect for label + indicatorWidth + indicatorSpace |
|
4288 |
QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment, |
|
4289 |
QSize(tw + checkBoxSize, h), ret); |
|
4290 |
||
4291 |
// Adjust totalRect if checkbox is set |
|
4292 |
if (hasCheckBox) { |
|
4293 |
bool ltr = groupBox->direction == Qt::LeftToRight; |
|
4294 |
int left = 0; |
|
4295 |
// Adjust for check box |
|
4296 |
if (sc == SC_GroupBoxCheckBox) { |
|
4297 |
int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); |
|
4298 |
left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth); |
|
4299 |
int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2; |
|
4300 |
totalRect.setRect(left, top, indicatorWidth, indicatorHeight); |
|
4301 |
// Adjust for label |
|
4302 |
} else { |
|
4303 |
left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left(); |
|
4304 |
totalRect.setRect(left, totalRect.top(), |
|
4305 |
totalRect.width() - checkBoxSize, totalRect.height()); |
|
4306 |
} |
|
4307 |
} |
|
4308 |
ret = totalRect; |
|
4309 |
break; |
|
4310 |
} |
|
4311 |
default: |
|
4312 |
break; |
|
4313 |
} |
|
4314 |
} |
|
4315 |
break; |
|
4316 |
} |
|
4317 |
#endif // QT_NO_GROUPBOX |
|
4318 |
#ifndef QT_NO_WORKSPACE |
|
4319 |
case CC_MdiControls: |
|
4320 |
{ |
|
4321 |
int numSubControls = 0; |
|
4322 |
if (opt->subControls & SC_MdiCloseButton) |
|
4323 |
++numSubControls; |
|
4324 |
if (opt->subControls & SC_MdiMinButton) |
|
4325 |
++numSubControls; |
|
4326 |
if (opt->subControls & SC_MdiNormalButton) |
|
4327 |
++numSubControls; |
|
4328 |
if (numSubControls == 0) |
|
4329 |
break; |
|
4330 |
||
4331 |
int buttonWidth = opt->rect.width()/ numSubControls - 1; |
|
4332 |
int offset = 0; |
|
4333 |
switch (sc) { |
|
4334 |
case SC_MdiCloseButton: |
|
4335 |
// Only one sub control, no offset needed. |
|
4336 |
if (numSubControls == 1) |
|
4337 |
break; |
|
4338 |
offset += buttonWidth + 2; |
|
4339 |
//FALL THROUGH |
|
4340 |
case SC_MdiNormalButton: |
|
4341 |
// No offset needed if |
|
4342 |
// 1) There's only one sub control |
|
4343 |
// 2) We have a close button and a normal button (offset already added in SC_MdiClose) |
|
4344 |
if (numSubControls == 1 || (numSubControls == 2 && !(opt->subControls & SC_MdiMinButton))) |
|
4345 |
break; |
|
4346 |
if (opt->subControls & SC_MdiNormalButton) |
|
4347 |
offset += buttonWidth; |
|
4348 |
break; |
|
4349 |
default: |
|
4350 |
break; |
|
4351 |
} |
|
4352 |
||
4353 |
// Subtract one pixel if we only have one sub control. At this point |
|
4354 |
// buttonWidth is the actual width + 1 pixel margin, but we don't want the |
|
4355 |
// margin when there are no other controllers. |
|
4356 |
if (numSubControls == 1) |
|
4357 |
--buttonWidth; |
|
4358 |
ret = QRect(offset, 0, buttonWidth, opt->rect.height()); |
|
4359 |
break; |
|
4360 |
} |
|
4361 |
#endif // QT_NO_WORKSPACE |
|
4362 |
default: |
|
4363 |
qWarning("QCommonStyle::subControlRect: Case %d not handled", cc); |
|
4364 |
} |
|
4365 |
return ret; |
|
4366 |
} |
|
4367 |
||
4368 |
/*! \reimp */ |
|
4369 |
int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const |
|
4370 |
{ |
|
4371 |
int ret; |
|
4372 |
||
4373 |
switch (m) { |
|
4374 |
case PM_FocusFrameVMargin: |
|
4375 |
case PM_FocusFrameHMargin: |
|
4376 |
ret = 2; |
|
4377 |
break; |
|
4378 |
case PM_MenuBarVMargin: |
|
4379 |
case PM_MenuBarHMargin: |
|
4380 |
ret = 0; |
|
4381 |
break; |
|
4382 |
case PM_DialogButtonsSeparator: |
|
4383 |
ret = int(QStyleHelper::dpiScaled(5.)); |
|
4384 |
break; |
|
4385 |
case PM_DialogButtonsButtonWidth: |
|
4386 |
ret = int(QStyleHelper::dpiScaled(70.)); |
|
4387 |
break; |
|
4388 |
case PM_DialogButtonsButtonHeight: |
|
4389 |
ret = int(QStyleHelper::dpiScaled(30.)); |
|
4390 |
break; |
|
4391 |
case PM_CheckListControllerSize: |
|
4392 |
case PM_CheckListButtonSize: |
|
4393 |
ret = int(QStyleHelper::dpiScaled(16.)); |
|
4394 |
break; |
|
4395 |
case PM_TitleBarHeight: { |
|
4396 |
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { |
|
4397 |
if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4398 |
ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 16); |
0 | 4399 |
#ifndef QT_NO_DOCKWIDGET |
4400 |
} else if (qobject_cast<const QDockWidget*>(widget)) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4401 |
ret = qMax(widget->fontMetrics().height(), int(QStyleHelper::dpiScaled(13))); |
0 | 4402 |
#endif |
4403 |
} else { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4404 |
ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 18); |
0 | 4405 |
} |
4406 |
} else { |
|
4407 |
ret = int(QStyleHelper::dpiScaled(18.)); |
|
4408 |
} |
|
4409 |
||
4410 |
break; } |
|
4411 |
case PM_ScrollBarSliderMin: |
|
4412 |
ret = int(QStyleHelper::dpiScaled(9.)); |
|
4413 |
break; |
|
4414 |
||
4415 |
case PM_ButtonMargin: |
|
4416 |
ret = int(QStyleHelper::dpiScaled(6.)); |
|
4417 |
break; |
|
4418 |
||
4419 |
case PM_DockWidgetTitleBarButtonMargin: |
|
4420 |
ret = int(QStyleHelper::dpiScaled(2.)); |
|
4421 |
break; |
|
4422 |
||
4423 |
case PM_ButtonDefaultIndicator: |
|
4424 |
ret = 0; |
|
4425 |
break; |
|
4426 |
||
4427 |
case PM_MenuButtonIndicator: |
|
4428 |
ret = int(QStyleHelper::dpiScaled(12.)); |
|
4429 |
break; |
|
4430 |
||
4431 |
case PM_ButtonShiftHorizontal: |
|
4432 |
case PM_ButtonShiftVertical: |
|
4433 |
||
4434 |
case PM_DefaultFrameWidth: |
|
4435 |
ret = 2; |
|
4436 |
break; |
|
4437 |
||
4438 |
case PM_ComboBoxFrameWidth: |
|
4439 |
case PM_SpinBoxFrameWidth: |
|
4440 |
case PM_MenuPanelWidth: |
|
4441 |
case PM_TabBarBaseOverlap: |
|
4442 |
case PM_TabBarBaseHeight: |
|
4443 |
ret = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); |
|
4444 |
break; |
|
4445 |
||
4446 |
case PM_MdiSubWindowFrameWidth: |
|
4447 |
ret = int(QStyleHelper::dpiScaled(4.)); |
|
4448 |
break; |
|
4449 |
||
4450 |
case PM_MdiSubWindowMinimizedWidth: |
|
4451 |
ret = int(QStyleHelper::dpiScaled(196.)); |
|
4452 |
break; |
|
4453 |
||
4454 |
#ifndef QT_NO_SCROLLBAR |
|
4455 |
case PM_ScrollBarExtent: |
|
4456 |
if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
4457 |
int s = sb->orientation == Qt::Horizontal ? |
|
4458 |
QApplication::globalStrut().height() |
|
4459 |
: QApplication::globalStrut().width(); |
|
4460 |
ret = qMax(16, s); |
|
4461 |
} else { |
|
4462 |
ret = int(QStyleHelper::dpiScaled(16.)); |
|
4463 |
} |
|
4464 |
break; |
|
4465 |
#endif |
|
4466 |
case PM_MaximumDragDistance: |
|
4467 |
ret = -1; |
|
4468 |
break; |
|
4469 |
||
4470 |
#ifndef QT_NO_SLIDER |
|
4471 |
case PM_SliderThickness: |
|
4472 |
ret = int(QStyleHelper::dpiScaled(16.)); |
|
4473 |
break; |
|
4474 |
||
4475 |
case PM_SliderTickmarkOffset: |
|
4476 |
if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
4477 |
int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() |
|
4478 |
: sl->rect.width(); |
|
4479 |
int thickness = proxy()->pixelMetric(PM_SliderControlThickness, sl, widget); |
|
4480 |
int ticks = sl->tickPosition; |
|
4481 |
||
4482 |
if (ticks == QSlider::TicksBothSides) |
|
4483 |
ret = (space - thickness) / 2; |
|
4484 |
else if (ticks == QSlider::TicksAbove) |
|
4485 |
ret = space - thickness; |
|
4486 |
else |
|
4487 |
ret = 0; |
|
4488 |
} else { |
|
4489 |
ret = 0; |
|
4490 |
} |
|
4491 |
break; |
|
4492 |
||
4493 |
case PM_SliderSpaceAvailable: |
|
4494 |
if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { |
|
4495 |
if (sl->orientation == Qt::Horizontal) |
|
4496 |
ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, sl, widget); |
|
4497 |
else |
|
4498 |
ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, sl, widget); |
|
4499 |
} else { |
|
4500 |
ret = 0; |
|
4501 |
} |
|
4502 |
break; |
|
4503 |
#endif // QT_NO_SLIDER |
|
4504 |
#ifndef QT_NO_DOCKWIDGET |
|
4505 |
case PM_DockWidgetSeparatorExtent: |
|
4506 |
ret = int(QStyleHelper::dpiScaled(6.)); |
|
4507 |
break; |
|
4508 |
||
4509 |
case PM_DockWidgetHandleExtent: |
|
4510 |
ret = int(QStyleHelper::dpiScaled(8.)); |
|
4511 |
break; |
|
4512 |
case PM_DockWidgetTitleMargin: |
|
4513 |
ret = 0; |
|
4514 |
break; |
|
4515 |
case PM_DockWidgetFrameWidth: |
|
4516 |
ret = 1; |
|
4517 |
break; |
|
4518 |
#endif // QT_NO_DOCKWIDGET |
|
4519 |
||
4520 |
case PM_SpinBoxSliderHeight: |
|
4521 |
case PM_MenuBarPanelWidth: |
|
4522 |
ret = 2; |
|
4523 |
break; |
|
4524 |
||
4525 |
case PM_MenuBarItemSpacing: |
|
4526 |
ret = 0; |
|
4527 |
break; |
|
4528 |
||
4529 |
#ifndef QT_NO_TOOLBAR |
|
4530 |
case PM_ToolBarFrameWidth: |
|
4531 |
ret = 1; |
|
4532 |
break; |
|
4533 |
||
4534 |
case PM_ToolBarItemMargin: |
|
4535 |
ret = 0; |
|
4536 |
break; |
|
4537 |
||
4538 |
case PM_ToolBarItemSpacing: |
|
4539 |
ret = int(QStyleHelper::dpiScaled(4.)); |
|
4540 |
break; |
|
4541 |
||
4542 |
case PM_ToolBarHandleExtent: |
|
4543 |
ret = int(QStyleHelper::dpiScaled(8.)); |
|
4544 |
break; |
|
4545 |
||
4546 |
case PM_ToolBarSeparatorExtent: |
|
4547 |
ret = int(QStyleHelper::dpiScaled(6.)); |
|
4548 |
break; |
|
4549 |
||
4550 |
case PM_ToolBarExtensionExtent: |
|
4551 |
ret = int(QStyleHelper::dpiScaled(12.)); |
|
4552 |
break; |
|
4553 |
#endif // QT_NO_TOOLBAR |
|
4554 |
||
4555 |
#ifndef QT_NO_TABBAR |
|
4556 |
case PM_TabBarTabOverlap: |
|
4557 |
ret = 3; |
|
4558 |
break; |
|
4559 |
||
4560 |
case PM_TabBarTabHSpace: |
|
4561 |
ret = int(QStyleHelper::dpiScaled(24.)); |
|
4562 |
break; |
|
4563 |
||
4564 |
case PM_TabBarTabShiftHorizontal: |
|
4565 |
ret = 0; |
|
4566 |
break; |
|
4567 |
||
4568 |
case PM_TabBarTabShiftVertical: |
|
4569 |
ret = 2; |
|
4570 |
break; |
|
4571 |
||
4572 |
case PM_TabBarTabVSpace: { |
|
4573 |
const QStyleOptionTab *tb = qstyleoption_cast<const QStyleOptionTab *>(opt); |
|
4574 |
if (tb && (tb->shape == QTabBar::RoundedNorth || tb->shape == QTabBar::RoundedSouth |
|
4575 |
|| tb->shape == QTabBar::RoundedWest || tb->shape == QTabBar::RoundedEast)) |
|
4576 |
ret = 8; |
|
4577 |
else |
|
4578 |
if(tb && (tb->shape == QTabBar::TriangularWest || tb->shape == QTabBar::TriangularEast)) |
|
4579 |
ret = 3; |
|
4580 |
else |
|
4581 |
ret = 2; |
|
4582 |
break; } |
|
4583 |
#endif |
|
4584 |
||
4585 |
case PM_ProgressBarChunkWidth: |
|
4586 |
ret = 9; |
|
4587 |
break; |
|
4588 |
||
4589 |
case PM_IndicatorWidth: |
|
4590 |
ret = int(QStyleHelper::dpiScaled(13.)); |
|
4591 |
break; |
|
4592 |
||
4593 |
case PM_IndicatorHeight: |
|
4594 |
ret = int(QStyleHelper::dpiScaled(13.)); |
|
4595 |
break; |
|
4596 |
||
4597 |
case PM_ExclusiveIndicatorWidth: |
|
4598 |
ret = int(QStyleHelper::dpiScaled(12.)); |
|
4599 |
break; |
|
4600 |
||
4601 |
case PM_ExclusiveIndicatorHeight: |
|
4602 |
ret = int(QStyleHelper::dpiScaled(12.)); |
|
4603 |
break; |
|
4604 |
||
4605 |
case PM_MenuTearoffHeight: |
|
4606 |
ret = int(QStyleHelper::dpiScaled(10.)); |
|
4607 |
break; |
|
4608 |
||
4609 |
case PM_MenuScrollerHeight: |
|
4610 |
ret = int(QStyleHelper::dpiScaled(10.)); |
|
4611 |
break; |
|
4612 |
||
4613 |
case PM_MenuDesktopFrameWidth: |
|
4614 |
case PM_MenuHMargin: |
|
4615 |
case PM_MenuVMargin: |
|
4616 |
ret = 0; |
|
4617 |
break; |
|
4618 |
||
4619 |
case PM_HeaderMargin: |
|
4620 |
ret = int(QStyleHelper::dpiScaled(4.)); |
|
4621 |
break; |
|
4622 |
case PM_HeaderMarkSize: |
|
4623 |
ret = int(QStyleHelper::dpiScaled(32.)); |
|
4624 |
break; |
|
4625 |
case PM_HeaderGripMargin: |
|
4626 |
ret = int(QStyleHelper::dpiScaled(4.)); |
|
4627 |
break; |
|
4628 |
case PM_TabBarScrollButtonWidth: |
|
4629 |
ret = int(QStyleHelper::dpiScaled(16.)); |
|
4630 |
break; |
|
4631 |
case PM_LayoutLeftMargin: |
|
4632 |
case PM_LayoutTopMargin: |
|
4633 |
case PM_LayoutRightMargin: |
|
4634 |
case PM_LayoutBottomMargin: |
|
4635 |
{ |
|
4636 |
bool isWindow = false; |
|
4637 |
if (opt) { |
|
4638 |
isWindow = (opt->state & State_Window); |
|
4639 |
} else if (widget) { |
|
4640 |
isWindow = widget->isWindow(); |
|
4641 |
} |
|
4642 |
ret = proxy()->pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin); |
|
4643 |
} |
|
4644 |
break; |
|
4645 |
case PM_LayoutHorizontalSpacing: |
|
4646 |
case PM_LayoutVerticalSpacing: |
|
4647 |
ret = proxy()->pixelMetric(PM_DefaultLayoutSpacing); |
|
4648 |
break; |
|
4649 |
||
4650 |
case PM_DefaultTopLevelMargin: |
|
4651 |
ret = int(QStyleHelper::dpiScaled(11.)); |
|
4652 |
break; |
|
4653 |
case PM_DefaultChildMargin: |
|
4654 |
ret = int(QStyleHelper::dpiScaled(9.)); |
|
4655 |
break; |
|
4656 |
case PM_DefaultLayoutSpacing: |
|
4657 |
ret = int(QStyleHelper::dpiScaled(6.)); |
|
4658 |
break; |
|
4659 |
||
4660 |
case PM_ToolBarIconSize: |
|
4661 |
ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ToolBarIconSize); |
|
4662 |
if (!ret) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4663 |
ret = int(QStyleHelper::dpiScaled(24.)); |
0 | 4664 |
break; |
4665 |
||
4666 |
case PM_TabBarIconSize: |
|
4667 |
case PM_ListViewIconSize: |
|
4668 |
ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); |
|
4669 |
break; |
|
4670 |
||
4671 |
case PM_ButtonIconSize: |
|
4672 |
case PM_SmallIconSize: |
|
4673 |
ret = int(QStyleHelper::dpiScaled(16.)); |
|
4674 |
break; |
|
4675 |
case PM_IconViewIconSize: |
|
4676 |
ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); |
|
4677 |
break; |
|
4678 |
||
4679 |
case PM_LargeIconSize: |
|
4680 |
ret = int(QStyleHelper::dpiScaled(32.)); |
|
4681 |
break; |
|
4682 |
||
4683 |
case PM_ToolTipLabelFrameWidth: |
|
4684 |
ret = 1; |
|
4685 |
break; |
|
4686 |
case PM_CheckBoxLabelSpacing: |
|
4687 |
case PM_RadioButtonLabelSpacing: |
|
4688 |
ret = int(QStyleHelper::dpiScaled(6.)); |
|
4689 |
break; |
|
4690 |
case PM_SizeGripSize: |
|
4691 |
ret = int(QStyleHelper::dpiScaled(13.)); |
|
4692 |
break; |
|
4693 |
case PM_MessageBoxIconSize: |
|
4694 |
#ifdef Q_WS_MAC |
|
4695 |
if (QApplication::desktopSettingsAware()) { |
|
4696 |
ret = 64; // No DPI scaling, it's handled elsewhere. |
|
4697 |
} else |
|
4698 |
#endif |
|
4699 |
{ |
|
4700 |
ret = int(QStyleHelper::dpiScaled(32.)); |
|
4701 |
} |
|
4702 |
break; |
|
4703 |
case PM_TextCursorWidth: |
|
4704 |
ret = 1; |
|
4705 |
break; |
|
4706 |
case PM_TabBar_ScrollButtonOverlap: |
|
4707 |
ret = 1; |
|
4708 |
break; |
|
4709 |
case PM_TabCloseIndicatorWidth: |
|
4710 |
case PM_TabCloseIndicatorHeight: |
|
4711 |
ret = int(QStyleHelper::dpiScaled(16.)); |
|
4712 |
break; |
|
4713 |
case PM_ScrollView_ScrollBarSpacing: |
|
4714 |
ret = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); |
|
4715 |
break; |
|
4716 |
case PM_SubMenuOverlap: |
|
4717 |
ret = -proxy()->pixelMetric(QStyle::PM_MenuPanelWidth, opt, widget); |
|
4718 |
break; |
|
4719 |
default: |
|
4720 |
ret = 0; |
|
4721 |
break; |
|
4722 |
} |
|
4723 |
||
4724 |
return ret; |
|
4725 |
} |
|
4726 |
||
4727 |
/*! |
|
4728 |
\reimp |
|
4729 |
*/ |
|
4730 |
QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, |
|
4731 |
const QSize &csz, const QWidget *widget) const |
|
4732 |
{ |
|
4733 |
Q_D(const QCommonStyle); |
|
4734 |
QSize sz(csz); |
|
4735 |
switch (ct) { |
|
4736 |
case CT_PushButton: |
|
4737 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
4738 |
int w = csz.width(), |
|
4739 |
h = csz.height(), |
|
4740 |
bm = proxy()->pixelMetric(PM_ButtonMargin, btn, widget), |
|
4741 |
fw = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) * 2; |
|
4742 |
w += bm + fw; |
|
4743 |
h += bm + fw; |
|
4744 |
if (btn->features & QStyleOptionButton::AutoDefaultButton){ |
|
4745 |
int dbw = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget) * 2; |
|
4746 |
w += dbw; |
|
4747 |
h += dbw; |
|
4748 |
} |
|
4749 |
sz = QSize(w, h); |
|
4750 |
} |
|
4751 |
break; |
|
4752 |
case CT_RadioButton: |
|
4753 |
case CT_CheckBox: |
|
4754 |
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { |
|
4755 |
bool isRadio = (ct == CT_RadioButton); |
|
4756 |
||
4757 |
int w = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth |
|
4758 |
: PM_IndicatorWidth, btn, widget); |
|
4759 |
int h = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight |
|
4760 |
: PM_IndicatorHeight, btn, widget); |
|
4761 |
||
4762 |
int margins = 0; |
|
4763 |
// we add 4 pixels for label margins |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
4764 |
if (!btn->icon.isNull() || !btn->text.isEmpty()) |
0 | 4765 |
margins = 4 + proxy()->pixelMetric(isRadio ? PM_RadioButtonLabelSpacing |
4766 |
: PM_CheckBoxLabelSpacing, opt, widget); |
|
4767 |
sz += QSize(w + margins, 4); |
|
4768 |
sz.setHeight(qMax(sz.height(), h)); |
|
4769 |
} |
|
4770 |
break; |
|
4771 |
#ifndef QT_NO_MENU |
|
4772 |
case CT_MenuItem: |
|
4773 |
if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { |
|
4774 |
bool checkable = mi->menuHasCheckableItems; |
|
4775 |
int maxpmw = mi->maxIconWidth; |
|
4776 |
int w = sz.width(), h = sz.height(); |
|
4777 |
if (mi->menuItemType == QStyleOptionMenuItem::Separator) { |
|
4778 |
w = 10; |
|
4779 |
h = 2; |
|
4780 |
} else { |
|
4781 |
h = mi->fontMetrics.height() + 8; |
|
4782 |
if (!mi->icon.isNull()) { |
|
4783 |
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); |
|
4784 |
h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4); |
|
4785 |
} |
|
4786 |
} |
|
4787 |
if (mi->text.contains(QLatin1Char('\t'))) |
|
4788 |
w += 12; |
|
4789 |
if (maxpmw > 0) |
|
4790 |
w += maxpmw + 6; |
|
4791 |
if (checkable && maxpmw < 20) |
|
4792 |
w += 20 - maxpmw; |
|
4793 |
if (checkable || maxpmw > 0) |
|
4794 |
w += 2; |
|
4795 |
w += 12; |
|
4796 |
sz = QSize(w, h); |
|
4797 |
} |
|
4798 |
break; |
|
4799 |
#endif // QT_NO_MENU |
|
4800 |
#ifndef QT_NO_TOOLBUTTON |
|
4801 |
case CT_ToolButton: |
|
4802 |
sz = QSize(sz.width() + 6, sz.height() + 5); |
|
4803 |
break; |
|
4804 |
#endif // QT_NO_TOOLBUTTON |
|
4805 |
#ifndef QT_NO_COMBOBOX |
|
4806 |
case CT_ComboBox: |
|
4807 |
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { |
|
4808 |
int fw = cmb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0; |
|
4809 |
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1); |
|
4810 |
// QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins... |
|
4811 |
int other = qMax(23, 2*textMargins + proxy()->pixelMetric(QStyle::PM_ScrollBarExtent, opt, widget)); |
|
4812 |
sz = QSize(sz.width() + fw + other, sz.height() + fw); |
|
4813 |
} |
|
4814 |
break; |
|
4815 |
#endif // QT_NO_COMBOBOX |
|
4816 |
case CT_HeaderSection: |
|
4817 |
if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { |
|
4818 |
bool nullIcon = hdr->icon.isNull(); |
|
4819 |
int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, hdr, widget); |
|
4820 |
int iconSize = nullIcon ? 0 : proxy()->pixelMetric(QStyle::PM_SmallIconSize, hdr, widget); |
|
4821 |
QSize txt = hdr->fontMetrics.size(0, hdr->text); |
|
4822 |
sz.setHeight(margin + qMax(iconSize, txt.height()) + margin); |
|
4823 |
sz.setWidth((nullIcon ? 0 : margin) + iconSize |
|
4824 |
+ (hdr->text.isNull() ? 0 : margin) + txt.width() + margin); |
|
4825 |
} |
|
4826 |
break; |
|
4827 |
case CT_TabWidget: |
|
4828 |
sz += QSize(4, 4); |
|
4829 |
break; |
|
4830 |
case CT_LineEdit: |
|
4831 |
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) |
|
4832 |
sz += QSize(2*f->lineWidth, 2*f->lineWidth); |
|
4833 |
break; |
|
4834 |
#ifndef QT_NO_GROUPBOX |
|
4835 |
case CT_GroupBox: |
|
4836 |
if (const QGroupBox *grb = static_cast<const QGroupBox *>(widget)) |
|
4837 |
sz += QSize(!grb->isFlat() ? 16 : 0, 0); |
|
4838 |
break; |
|
4839 |
#endif // QT_NO_GROUPBOX |
|
4840 |
case CT_MdiControls: |
|
4841 |
if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) { |
|
4842 |
int width = 1; |
|
4843 |
if (styleOpt->subControls & SC_MdiMinButton) |
|
4844 |
width += 16 + 1; |
|
4845 |
if (styleOpt->subControls & SC_MdiNormalButton) |
|
4846 |
width += 16 + 1; |
|
4847 |
if (styleOpt->subControls & SC_MdiCloseButton) |
|
4848 |
width += 16 + 1; |
|
4849 |
sz = QSize(width, 16); |
|
4850 |
} else { |
|
4851 |
sz = QSize(52, 16); |
|
4852 |
} |
|
4853 |
break; |
|
4854 |
#ifndef QT_NO_ITEMVIEWS |
|
4855 |
case CT_ItemViewItem: |
|
4856 |
if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) { |
|
4857 |
QRect decorationRect, displayRect, checkRect; |
|
4858 |
d->viewItemLayout(vopt, &checkRect, &decorationRect, &displayRect, true); |
|
4859 |
sz = (decorationRect|displayRect|checkRect).size(); |
|
4860 |
} |
|
4861 |
break; |
|
4862 |
#endif // QT_NO_ITEMVIEWS |
|
4863 |
case CT_ScrollBar: |
|
4864 |
case CT_MenuBar: |
|
4865 |
case CT_Menu: |
|
4866 |
case CT_MenuBarItem: |
|
4867 |
case CT_Q3Header: |
|
4868 |
case CT_Slider: |
|
4869 |
case CT_ProgressBar: |
|
4870 |
case CT_TabBarTab: |
|
4871 |
// just return the contentsSize for now |
|
4872 |
// fall through intended |
|
4873 |
default: |
|
4874 |
break; |
|
4875 |
} |
|
4876 |
return sz; |
|
4877 |
} |
|
4878 |
||
4879 |
||
4880 |
/*! \reimp */ |
|
4881 |
int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *widget, |
|
4882 |
QStyleHintReturn *hret) const |
|
4883 |
{ |
|
4884 |
int ret = 0; |
|
4885 |
||
4886 |
switch (sh) { |
|
4887 |
case SH_Menu_KeyboardSearch: |
|
4888 |
ret = false; |
|
4889 |
break; |
|
4890 |
case SH_Slider_AbsoluteSetButtons: |
|
4891 |
ret = Qt::MidButton; |
|
4892 |
break; |
|
4893 |
case SH_Slider_PageSetButtons: |
|
4894 |
ret = Qt::LeftButton; |
|
4895 |
break; |
|
4896 |
case SH_ScrollBar_ContextMenu: |
|
4897 |
ret = true; |
|
4898 |
break; |
|
4899 |
case SH_DialogButtons_DefaultButton: // This value not used anywhere. |
|
4900 |
ret = QDialogButtonBox::AcceptRole; |
|
4901 |
break; |
|
4902 |
#ifndef QT_NO_GROUPBOX |
|
4903 |
case SH_GroupBox_TextLabelVerticalAlignment: |
|
4904 |
ret = Qt::AlignVCenter; |
|
4905 |
break; |
|
4906 |
||
4907 |
case SH_GroupBox_TextLabelColor: |
|
4908 |
ret = opt ? int(opt->palette.color(QPalette::Text).rgba()) : 0; |
|
4909 |
break; |
|
4910 |
#endif // QT_NO_GROUPBOX |
|
4911 |
||
4912 |
case SH_Q3ListViewExpand_SelectMouseType: |
|
4913 |
case SH_TabBar_SelectMouseType: |
|
4914 |
ret = QEvent::MouseButtonPress; |
|
4915 |
break; |
|
4916 |
||
4917 |
#ifdef QT3_SUPPORT |
|
4918 |
case SH_GUIStyle: |
|
4919 |
ret = Qt::WindowsStyle; |
|
4920 |
break; |
|
4921 |
#endif |
|
4922 |
||
4923 |
case SH_TabBar_Alignment: |
|
4924 |
case SH_Header_ArrowAlignment: |
|
4925 |
ret = Qt::AlignLeft; |
|
4926 |
break; |
|
4927 |
||
4928 |
case SH_TitleBar_AutoRaise: |
|
4929 |
ret = false; |
|
4930 |
break; |
|
4931 |
||
4932 |
case SH_Menu_SubMenuPopupDelay: |
|
4933 |
ret = 256; |
|
4934 |
break; |
|
4935 |
||
4936 |
case SH_ProgressDialog_TextLabelAlignment: |
|
4937 |
ret = Qt::AlignCenter; |
|
4938 |
break; |
|
4939 |
||
4940 |
case SH_BlinkCursorWhenTextSelected: |
|
4941 |
ret = 1; |
|
4942 |
break; |
|
4943 |
||
4944 |
case SH_Table_GridLineColor: |
|
4945 |
if (opt) |
|
4946 |
ret = opt->palette.color(QPalette::Mid).rgb(); |
|
4947 |
else |
|
4948 |
ret = -1; |
|
4949 |
break; |
|
4950 |
case SH_LineEdit_PasswordCharacter: { |
|
4951 |
const QFontMetrics &fm = opt ? opt->fontMetrics |
|
4952 |
: (widget ? widget->fontMetrics() : QFontMetrics(QFont())); |
|
4953 |
ret = 0; |
|
4954 |
if (fm.inFont(QChar(0x25CF))) { |
|
4955 |
ret = 0x25CF; |
|
4956 |
} else if (fm.inFont(QChar(0x2022))) { |
|
4957 |
ret = 0x2022; |
|
4958 |
} else { |
|
4959 |
ret = '*'; |
|
4960 |
} |
|
4961 |
break; |
|
4962 |
} |
|
4963 |
||
4964 |
||
4965 |
case SH_ToolBox_SelectedPageTitleBold: |
|
4966 |
ret = 1; |
|
4967 |
break; |
|
4968 |
||
4969 |
case SH_UnderlineShortcut: |
|
4970 |
ret = 1; |
|
4971 |
break; |
|
4972 |
||
4973 |
case SH_SpinBox_ClickAutoRepeatRate: |
|
4974 |
ret = 150; |
|
4975 |
break; |
|
4976 |
||
4977 |
case SH_SpinBox_ClickAutoRepeatThreshold: |
|
4978 |
ret = 500; |
|
4979 |
break; |
|
4980 |
||
4981 |
case SH_SpinBox_KeyPressAutoRepeatRate: |
|
4982 |
ret = 75; |
|
4983 |
break; |
|
4984 |
||
4985 |
case SH_Menu_SelectionWrap: |
|
4986 |
ret = true; |
|
4987 |
break; |
|
4988 |
||
4989 |
case SH_Menu_FillScreenWithScroll: |
|
4990 |
ret = true; |
|
4991 |
break; |
|
4992 |
||
4993 |
case SH_ToolTipLabel_Opacity: |
|
4994 |
ret = 255; |
|
4995 |
break; |
|
4996 |
||
4997 |
case SH_Button_FocusPolicy: |
|
4998 |
ret = Qt::StrongFocus; |
|
4999 |
break; |
|
5000 |
||
5001 |
case SH_MenuBar_DismissOnSecondClick: |
|
5002 |
ret = 1; |
|
5003 |
break; |
|
5004 |
||
5005 |
case SH_MessageBox_UseBorderForButtonSpacing: |
|
5006 |
ret = 0; |
|
5007 |
break; |
|
5008 |
||
5009 |
case SH_ToolButton_PopupDelay: |
|
5010 |
ret = 600; |
|
5011 |
break; |
|
5012 |
||
5013 |
case SH_FocusFrame_Mask: |
|
5014 |
ret = 1; |
|
5015 |
if (widget) { |
|
5016 |
if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) { |
|
5017 |
mask->region = widget->rect(); |
|
5018 |
int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin), |
|
5019 |
hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin); |
|
5020 |
mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin)); |
|
5021 |
} |
|
5022 |
} |
|
5023 |
break; |
|
5024 |
#ifndef QT_NO_RUBBERBAND |
|
5025 |
case SH_RubberBand_Mask: |
|
5026 |
if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) { |
|
5027 |
ret = 0; |
|
5028 |
if (rbOpt->shape == QRubberBand::Rectangle) { |
|
5029 |
ret = true; |
|
5030 |
if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) { |
|
5031 |
mask->region = opt->rect; |
|
5032 |
int margin = proxy()->pixelMetric(PM_DefaultFrameWidth) * 2; |
|
5033 |
mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin); |
|
5034 |
} |
|
5035 |
} |
|
5036 |
} |
|
5037 |
break; |
|
5038 |
#endif // QT_NO_RUBBERBAND |
|
5039 |
case SH_SpinControls_DisableOnBounds: |
|
5040 |
ret = 1; |
|
5041 |
break; |
|
5042 |
||
5043 |
case SH_Dial_BackgroundRole: |
|
5044 |
ret = QPalette::Window; |
|
5045 |
break; |
|
5046 |
||
5047 |
case SH_ComboBox_LayoutDirection: |
|
5048 |
ret = opt ? opt->direction : Qt::LeftToRight; |
|
5049 |
break; |
|
5050 |
||
5051 |
case SH_ItemView_EllipsisLocation: |
|
5052 |
ret = Qt::AlignTrailing; |
|
5053 |
break; |
|
5054 |
||
5055 |
case SH_ItemView_ShowDecorationSelected: |
|
5056 |
ret = false; |
|
5057 |
break; |
|
5058 |
||
5059 |
case SH_ItemView_ActivateItemOnSingleClick: |
|
5060 |
ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ItemView_ActivateItemOnSingleClick); |
|
5061 |
break; |
|
5062 |
||
5063 |
case SH_TitleBar_ModifyNotification: |
|
5064 |
ret = true; |
|
5065 |
break; |
|
5066 |
case SH_ScrollBar_RollBetweenButtons: |
|
5067 |
ret = false; |
|
5068 |
break; |
|
5069 |
case SH_TabBar_ElideMode: |
|
5070 |
ret = Qt::ElideNone; |
|
5071 |
break; |
|
5072 |
case SH_DialogButtonLayout: |
|
5073 |
ret = QDialogButtonBox::WinLayout; |
|
5074 |
#ifdef Q_WS_X11 |
|
5075 |
if (X11->desktopEnvironment == DE_KDE) |
|
5076 |
ret = QDialogButtonBox::KdeLayout; |
|
5077 |
else if (X11->desktopEnvironment == DE_GNOME) |
|
5078 |
ret = QDialogButtonBox::GnomeLayout; |
|
5079 |
#endif |
|
5080 |
break; |
|
5081 |
case SH_ComboBox_PopupFrameStyle: |
|
5082 |
ret = QFrame::StyledPanel | QFrame::Plain; |
|
5083 |
break; |
|
5084 |
case SH_MessageBox_TextInteractionFlags: |
|
5085 |
ret = Qt::LinksAccessibleByMouse; |
|
5086 |
break; |
|
5087 |
case SH_DialogButtonBox_ButtonsHaveIcons: |
|
5088 |
#ifdef Q_WS_X11 |
|
5089 |
return true; |
|
5090 |
#endif |
|
5091 |
ret = 0; |
|
5092 |
break; |
|
5093 |
case SH_SpellCheckUnderlineStyle: |
|
5094 |
ret = QTextCharFormat::WaveUnderline; |
|
5095 |
break; |
|
5096 |
case SH_MessageBox_CenterButtons: |
|
5097 |
ret = true; |
|
5098 |
break; |
|
5099 |
case SH_ItemView_MovementWithoutUpdatingSelection: |
|
5100 |
ret = true; |
|
5101 |
break; |
|
5102 |
case SH_FocusFrame_AboveWidget: |
|
5103 |
ret = false; |
|
5104 |
break; |
|
5105 |
#ifndef QT_NO_TABWIDGET |
|
5106 |
case SH_TabWidget_DefaultTabPosition: |
|
5107 |
ret = QTabWidget::North; |
|
5108 |
break; |
|
5109 |
#endif |
|
5110 |
case SH_ToolBar_Movable: |
|
5111 |
ret = true; |
|
5112 |
break; |
|
5113 |
case SH_TextControl_FocusIndicatorTextCharFormat: |
|
5114 |
ret = true; |
|
5115 |
if (QStyleHintReturnVariant *vret = qstyleoption_cast<QStyleHintReturnVariant*>(hret)) { |
|
5116 |
QPen outline(opt->palette.color(QPalette::Text), 1, Qt::DotLine); |
|
5117 |
QTextCharFormat fmt; |
|
5118 |
fmt.setProperty(QTextFormat::OutlinePen, outline); |
|
5119 |
vret->variant = fmt; |
|
5120 |
} |
|
5121 |
break; |
|
5122 |
#ifndef QT_NO_WIZARD |
|
5123 |
case SH_WizardStyle: |
|
5124 |
ret = QWizard::ClassicStyle; |
|
5125 |
break; |
|
5126 |
#endif |
|
5127 |
case SH_FormLayoutWrapPolicy: |
|
5128 |
ret = QFormLayout::DontWrapRows; |
|
5129 |
break; |
|
5130 |
case SH_FormLayoutFieldGrowthPolicy: |
|
5131 |
ret = QFormLayout::AllNonFixedFieldsGrow; |
|
5132 |
break; |
|
5133 |
case SH_FormLayoutFormAlignment: |
|
5134 |
ret = Qt::AlignLeft | Qt::AlignTop; |
|
5135 |
break; |
|
5136 |
case SH_FormLayoutLabelAlignment: |
|
5137 |
ret = Qt::AlignLeft; |
|
5138 |
break; |
|
5139 |
case SH_ItemView_ArrowKeysNavigateIntoChildren: |
|
5140 |
ret = false; |
|
5141 |
break; |
|
5142 |
case SH_ItemView_DrawDelegateFrame: |
|
5143 |
ret = 0; |
|
5144 |
break; |
|
5145 |
#ifndef QT_NO_TABBAR |
|
5146 |
case SH_TabBar_CloseButtonPosition: |
|
5147 |
ret = QTabBar::RightSide; |
|
5148 |
break; |
|
5149 |
#endif |
|
5150 |
case SH_DockWidget_ButtonsHaveFrame: |
|
5151 |
ret = true; |
|
5152 |
break; |
|
5153 |
case SH_ToolButtonStyle: |
|
5154 |
ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ToolButtonStyle); |
|
5155 |
break; |
|
5156 |
case SH_RequestSoftwareInputPanel: |
|
5157 |
ret = RSIP_OnMouseClickAndAlreadyFocused; |
|
5158 |
break; |
|
5159 |
default: |
|
5160 |
ret = 0; |
|
5161 |
break; |
|
5162 |
} |
|
5163 |
||
5164 |
return ret; |
|
5165 |
} |
|
5166 |
||
5167 |
/*! \reimp */ |
|
5168 |
QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option, |
|
5169 |
const QWidget *widget) const |
|
5170 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5171 |
const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); |
0 | 5172 |
#ifdef QT_NO_IMAGEFORMAT_PNG |
5173 |
Q_UNUSED(widget); |
|
5174 |
Q_UNUSED(sp); |
|
5175 |
#else |
|
5176 |
QPixmap pixmap; |
|
5177 |
||
5178 |
if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { |
|
5179 |
switch (sp) { |
|
5180 |
case SP_DialogYesButton: |
|
5181 |
case SP_DialogOkButton: |
|
5182 |
pixmap = QIcon::fromTheme(QLatin1String("dialog-ok")).pixmap(16); |
|
5183 |
break; |
|
5184 |
case SP_DialogApplyButton: |
|
5185 |
pixmap = QIcon::fromTheme(QLatin1String("dialog-ok-apply")).pixmap(16); |
|
5186 |
break; |
|
5187 |
case SP_DialogDiscardButton: |
|
5188 |
pixmap = QIcon::fromTheme(QLatin1String("edit-delete")).pixmap(16); |
|
5189 |
break; |
|
5190 |
case SP_DialogCloseButton: |
|
5191 |
pixmap = QIcon::fromTheme(QLatin1String("dialog-close")).pixmap(16); |
|
5192 |
break; |
|
5193 |
case SP_DirHomeIcon: |
|
5194 |
pixmap = QIcon::fromTheme(QLatin1String("user-home")).pixmap(16); |
|
5195 |
break; |
|
5196 |
case SP_MessageBoxInformation: |
|
5197 |
pixmap = QIcon::fromTheme(QLatin1String("messagebox_info")).pixmap(16); |
|
5198 |
break; |
|
5199 |
case SP_MessageBoxWarning: |
|
5200 |
pixmap = QIcon::fromTheme(QLatin1String("messagebox_warning")).pixmap(16); |
|
5201 |
break; |
|
5202 |
case SP_MessageBoxCritical: |
|
5203 |
pixmap = QIcon::fromTheme(QLatin1String("messagebox_critical")).pixmap(16); |
|
5204 |
break; |
|
5205 |
case SP_MessageBoxQuestion: |
|
5206 |
pixmap = QIcon::fromTheme(QLatin1String("help")).pixmap(16); |
|
5207 |
break; |
|
5208 |
case SP_DialogOpenButton: |
|
5209 |
case SP_DirOpenIcon: |
|
5210 |
pixmap = QIcon::fromTheme(QLatin1String("folder-open")).pixmap(16); |
|
5211 |
break; |
|
5212 |
case SP_FileIcon: |
|
5213 |
pixmap = QIcon::fromTheme(QLatin1String("text-x-generic"), |
|
5214 |
QIcon::fromTheme(QLatin1String("empty"))).pixmap(16); |
|
5215 |
break; |
|
5216 |
case SP_DirClosedIcon: |
|
5217 |
case SP_DirIcon: |
|
5218 |
pixmap = QIcon::fromTheme(QLatin1String("folder")).pixmap(16); |
|
5219 |
break; |
|
5220 |
case SP_DriveFDIcon: |
|
5221 |
pixmap = QIcon::fromTheme(QLatin1String("media-floppy"), |
|
5222 |
QIcon::fromTheme(QLatin1String("3floppy_unmount"))).pixmap(16); |
|
5223 |
break; |
|
5224 |
case SP_ComputerIcon: |
|
5225 |
pixmap = QIcon::fromTheme(QLatin1String("computer"), |
|
5226 |
QIcon::fromTheme(QLatin1String("system"))).pixmap(16); |
|
5227 |
break; |
|
5228 |
case SP_DesktopIcon: |
|
5229 |
pixmap = QIcon::fromTheme(QLatin1String("user-desktop"), |
|
5230 |
QIcon::fromTheme(QLatin1String("desktop"))).pixmap(16); |
|
5231 |
break; |
|
5232 |
case SP_TrashIcon: |
|
5233 |
pixmap = QIcon::fromTheme(QLatin1String("user-trash"), |
|
5234 |
QIcon::fromTheme(QLatin1String("trashcan_empty"))).pixmap(16); |
|
5235 |
break; |
|
5236 |
case SP_DriveCDIcon: |
|
5237 |
case SP_DriveDVDIcon: |
|
5238 |
pixmap = QIcon::fromTheme(QLatin1String("media-optical"), |
|
5239 |
QIcon::fromTheme(QLatin1String("cdrom_unmount"))).pixmap(16); |
|
5240 |
break; |
|
5241 |
case SP_DriveHDIcon: |
|
5242 |
pixmap = QIcon::fromTheme(QLatin1String("drive-harddisk"), |
|
5243 |
QIcon::fromTheme(QLatin1String("hdd_unmount"))).pixmap(16); |
|
5244 |
break; |
|
5245 |
case SP_FileDialogToParent: |
|
5246 |
pixmap = QIcon::fromTheme(QLatin1String("go-up"), |
|
5247 |
QIcon::fromTheme(QLatin1String("up"))).pixmap(16); |
|
5248 |
break; |
|
5249 |
case SP_FileDialogNewFolder: |
|
5250 |
pixmap = QIcon::fromTheme(QLatin1String("folder_new")).pixmap(16); |
|
5251 |
break; |
|
5252 |
case SP_ArrowUp: |
|
5253 |
pixmap = QIcon::fromTheme(QLatin1String("go-up"), |
|
5254 |
QIcon::fromTheme(QLatin1String("up"))).pixmap(16); |
|
5255 |
break; |
|
5256 |
case SP_ArrowDown: |
|
5257 |
pixmap = QIcon::fromTheme(QLatin1String("go-down"), |
|
5258 |
QIcon::fromTheme(QLatin1String("down"))).pixmap(16); |
|
5259 |
break; |
|
5260 |
case SP_ArrowRight: |
|
5261 |
pixmap = QIcon::fromTheme(QLatin1String("go-next"), |
|
5262 |
QIcon::fromTheme(QLatin1String("forward"))).pixmap(16); |
|
5263 |
break; |
|
5264 |
case SP_ArrowLeft: |
|
5265 |
pixmap = QIcon::fromTheme(QLatin1String("go-previous"), |
|
5266 |
QIcon::fromTheme(QLatin1String("back"))).pixmap(16); |
|
5267 |
break; |
|
5268 |
case SP_FileDialogDetailedView: |
|
5269 |
pixmap = QIcon::fromTheme(QLatin1String("view_detailed")).pixmap(16); |
|
5270 |
break; |
|
5271 |
case SP_FileDialogListView: |
|
5272 |
pixmap = QIcon::fromTheme(QLatin1String("view_icon")).pixmap(16); |
|
5273 |
break; |
|
5274 |
case SP_BrowserReload: |
|
5275 |
pixmap = QIcon::fromTheme(QLatin1String("reload")).pixmap(16); |
|
5276 |
break; |
|
5277 |
case SP_BrowserStop: |
|
5278 |
pixmap = QIcon::fromTheme(QLatin1String("process-stop")).pixmap(16); |
|
5279 |
break; |
|
5280 |
case SP_MediaPlay: |
|
5281 |
pixmap = QIcon::fromTheme(QLatin1String("media-playback-start")).pixmap(16); |
|
5282 |
break; |
|
5283 |
case SP_MediaPause: |
|
5284 |
pixmap = QIcon::fromTheme(QLatin1String("media-playback-pause")).pixmap(16); |
|
5285 |
break; |
|
5286 |
case SP_MediaStop: |
|
5287 |
pixmap = QIcon::fromTheme(QLatin1String("media-playback-stop")).pixmap(16); |
|
5288 |
break; |
|
5289 |
case SP_MediaSeekForward: |
|
5290 |
pixmap = QIcon::fromTheme(QLatin1String("media-seek-forward")).pixmap(16); |
|
5291 |
break; |
|
5292 |
case SP_MediaSeekBackward: |
|
5293 |
pixmap = QIcon::fromTheme(QLatin1String("media-seek-backward")).pixmap(16); |
|
5294 |
break; |
|
5295 |
case SP_MediaSkipForward: |
|
5296 |
pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); |
|
5297 |
break; |
|
5298 |
case SP_MediaSkipBackward: |
|
5299 |
pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); |
|
5300 |
break; |
|
5301 |
case SP_DialogResetButton: |
|
5302 |
pixmap = QIcon::fromTheme(QLatin1String("edit-clear")).pixmap(24); |
|
5303 |
break; |
|
5304 |
case SP_DialogHelpButton: |
|
5305 |
pixmap = QIcon::fromTheme(QLatin1String("help-contents")).pixmap(24); |
|
5306 |
break; |
|
5307 |
case SP_DialogNoButton: |
|
5308 |
case SP_DialogCancelButton: |
|
5309 |
pixmap = QIcon::fromTheme(QLatin1String("dialog-cancel"), |
|
5310 |
QIcon::fromTheme(QLatin1String("process-stop"))).pixmap(24); |
|
5311 |
break; |
|
5312 |
case SP_DialogSaveButton: |
|
5313 |
pixmap = QIcon::fromTheme(QLatin1String("document-save")).pixmap(24); |
|
5314 |
break; |
|
5315 |
case SP_FileLinkIcon: |
|
5316 |
pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16); |
|
5317 |
if (!pixmap.isNull()) { |
|
5318 |
QPixmap fileIcon = QIcon::fromTheme(QLatin1String("text-x-generic")).pixmap(16); |
|
5319 |
if (fileIcon.isNull()) |
|
5320 |
fileIcon = QIcon::fromTheme(QLatin1String("empty")).pixmap(16); |
|
5321 |
if (!fileIcon.isNull()) { |
|
5322 |
QPainter painter(&fileIcon); |
|
5323 |
painter.drawPixmap(0, 0, 16, 16, pixmap); |
|
5324 |
return fileIcon; |
|
5325 |
} |
|
5326 |
} |
|
5327 |
break; |
|
5328 |
case SP_DirLinkIcon: |
|
5329 |
pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16); |
|
5330 |
if (!pixmap.isNull()) { |
|
5331 |
QPixmap dirIcon = QIcon::fromTheme(QLatin1String("folder")).pixmap(16); |
|
5332 |
if (!dirIcon.isNull()) { |
|
5333 |
QPainter painter(&dirIcon); |
|
5334 |
painter.drawPixmap(0, 0, 16, 16, pixmap); |
|
5335 |
return dirIcon; |
|
5336 |
} |
|
5337 |
} |
|
5338 |
break; |
|
5339 |
default: |
|
5340 |
break; |
|
5341 |
} |
|
5342 |
} |
|
5343 |
||
5344 |
if (!pixmap.isNull()) |
|
5345 |
return pixmap; |
|
5346 |
#endif //QT_NO_IMAGEFORMAT_PNG |
|
5347 |
switch (sp) { |
|
5348 |
#ifndef QT_NO_IMAGEFORMAT_XPM |
|
5349 |
case SP_ToolBarHorizontalExtensionButton: |
|
5350 |
if (rtl) { |
|
5351 |
QImage im(tb_extension_arrow_h_xpm); |
|
5352 |
im = im.convertToFormat(QImage::Format_ARGB32).mirrored(true, false); |
|
5353 |
return QPixmap::fromImage(im); |
|
5354 |
} |
|
5355 |
return QPixmap(tb_extension_arrow_h_xpm); |
|
5356 |
case SP_ToolBarVerticalExtensionButton: |
|
5357 |
return QPixmap(tb_extension_arrow_v_xpm); |
|
5358 |
case SP_FileDialogStart: |
|
5359 |
return QPixmap(filedialog_start_xpm); |
|
5360 |
case SP_FileDialogEnd: |
|
5361 |
return QPixmap(filedialog_end_xpm); |
|
5362 |
#endif |
|
5363 |
#ifndef QT_NO_IMAGEFORMAT_PNG |
|
5364 |
case SP_CommandLink: |
|
5365 |
case SP_ArrowForward: |
|
5366 |
if (rtl) |
|
5367 |
return proxy()->standardPixmap(SP_ArrowLeft, option, widget); |
|
5368 |
return proxy()->standardPixmap(SP_ArrowRight, option, widget); |
|
5369 |
case SP_ArrowBack: |
|
5370 |
if (rtl) |
|
5371 |
return proxy()->standardPixmap(SP_ArrowRight, option, widget); |
|
5372 |
return proxy()->standardPixmap(SP_ArrowLeft, option, widget); |
|
5373 |
case SP_ArrowLeft: |
|
5374 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png")); |
|
5375 |
case SP_ArrowRight: |
|
5376 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/right-16.png")); |
|
5377 |
case SP_ArrowUp: |
|
5378 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/up-16.png")); |
|
5379 |
case SP_ArrowDown: |
|
5380 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png")); |
|
5381 |
case SP_FileDialogToParent: |
|
5382 |
return proxy()->standardPixmap(SP_ArrowUp, option, widget); |
|
5383 |
case SP_FileDialogNewFolder: |
|
5384 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png")); |
|
5385 |
case SP_FileDialogDetailedView: |
|
5386 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-16.png")); |
|
5387 |
case SP_FileDialogInfoView: |
|
5388 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-16.png")); |
|
5389 |
case SP_FileDialogContentsView: |
|
5390 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-16.png")); |
|
5391 |
case SP_FileDialogListView: |
|
5392 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png")); |
|
5393 |
case SP_FileDialogBack: |
|
5394 |
return proxy()->standardPixmap(SP_ArrowBack, option, widget); |
|
5395 |
case SP_DriveHDIcon: |
|
5396 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/harddrive-16.png")); |
|
5397 |
case SP_TrashIcon: |
|
5398 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/trash-16.png")); |
|
5399 |
case SP_DriveFDIcon: |
|
5400 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/floppy-16.png")); |
|
5401 |
case SP_DriveNetIcon: |
|
5402 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/networkdrive-16.png")); |
|
5403 |
case SP_DesktopIcon: |
|
5404 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/desktop-16.png")); |
|
5405 |
case SP_ComputerIcon: |
|
5406 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/computer-16.png")); |
|
5407 |
case SP_DriveCDIcon: |
|
5408 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-16.png")); |
|
5409 |
case SP_DriveDVDIcon: |
|
5410 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-16.png")); |
|
5411 |
case SP_DirHomeIcon: |
|
5412 |
case SP_DirOpenIcon: |
|
5413 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-16.png")); |
|
5414 |
case SP_DirIcon: |
|
5415 |
case SP_DirClosedIcon: |
|
5416 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-16.png")); |
|
5417 |
case SP_DirLinkIcon: |
|
5418 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dirlink-16.png")); |
|
5419 |
case SP_FileIcon: |
|
5420 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/file-16.png")); |
|
5421 |
case SP_FileLinkIcon: |
|
5422 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-16.png")); |
|
5423 |
case SP_DialogOkButton: |
|
5424 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-16.png")); |
|
5425 |
case SP_DialogCancelButton: |
|
5426 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-16.png")); |
|
5427 |
case SP_DialogHelpButton: |
|
5428 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-16.png")); |
|
5429 |
case SP_DialogOpenButton: |
|
5430 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); |
|
5431 |
case SP_DialogSaveButton: |
|
5432 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")); |
|
5433 |
case SP_DialogCloseButton: |
|
5434 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-16.png")); |
|
5435 |
case SP_DialogApplyButton: |
|
5436 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-16.png")); |
|
5437 |
case SP_DialogResetButton: |
|
5438 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-16.png")); |
|
5439 |
case SP_DialogDiscardButton: |
|
5440 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-16.png")); |
|
5441 |
case SP_DialogYesButton: |
|
5442 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-16.png")); |
|
5443 |
case SP_DialogNoButton: |
|
5444 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-16.png")); |
|
5445 |
case SP_BrowserReload: |
|
5446 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/refresh-24.png")); |
|
5447 |
case SP_BrowserStop: |
|
5448 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/stop-24.png")); |
|
5449 |
case SP_MediaPlay: |
|
5450 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-play-32.png")); |
|
5451 |
case SP_MediaPause: |
|
5452 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-pause-32.png")); |
|
5453 |
case SP_MediaStop: |
|
5454 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-stop-32.png")); |
|
5455 |
case SP_MediaSeekForward: |
|
5456 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-forward-32.png")); |
|
5457 |
case SP_MediaSeekBackward: |
|
5458 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-backward-32.png")); |
|
5459 |
case SP_MediaSkipForward: |
|
5460 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-forward-32.png")); |
|
5461 |
case SP_MediaSkipBackward: |
|
5462 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-backward-32.png")); |
|
5463 |
case SP_MediaVolume: |
|
5464 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-16.png")); |
|
5465 |
case SP_MediaVolumeMuted: |
|
5466 |
return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-muted-16.png")); |
|
5467 |
#endif // QT_NO_IMAGEFORMAT_PNG |
|
5468 |
default: |
|
5469 |
break; |
|
5470 |
} |
|
5471 |
return QPixmap(); |
|
5472 |
} |
|
5473 |
||
5474 |
/*! |
|
5475 |
\internal |
|
5476 |
*/ |
|
5477 |
QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, |
|
5478 |
const QWidget *widget) const |
|
5479 |
{ |
|
5480 |
QIcon icon; |
|
5481 |
const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); |
|
5482 |
if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { |
|
5483 |
switch (standardIcon) { |
|
5484 |
case SP_DirHomeIcon: |
|
5485 |
icon = QIcon::fromTheme(QLatin1String("user-home")); |
|
5486 |
break; |
|
5487 |
case SP_MessageBoxInformation: |
|
5488 |
icon = QIcon::fromTheme(QLatin1String("dialog-information")); |
|
5489 |
break; |
|
5490 |
case SP_MessageBoxWarning: |
|
5491 |
icon = QIcon::fromTheme(QLatin1String("dialog-warning")); |
|
5492 |
break; |
|
5493 |
case SP_MessageBoxCritical: |
|
5494 |
icon = QIcon::fromTheme(QLatin1String("dialog-error")); |
|
5495 |
break; |
|
5496 |
case SP_MessageBoxQuestion: |
|
5497 |
icon = QIcon::fromTheme(QLatin1String("dialog-question")); |
|
5498 |
break; |
|
5499 |
case SP_DialogOpenButton: |
|
5500 |
case SP_DirOpenIcon: |
|
5501 |
icon = QIcon::fromTheme(QLatin1String("folder-open")); |
|
5502 |
break; |
|
5503 |
case SP_DialogSaveButton: |
|
5504 |
icon = QIcon::fromTheme(QLatin1String("document-save")); |
|
5505 |
break; |
|
5506 |
case SP_DialogApplyButton: |
|
5507 |
icon = QIcon::fromTheme(QLatin1String("dialog-ok-apply")); |
|
5508 |
break; |
|
5509 |
case SP_DialogYesButton: |
|
5510 |
case SP_DialogOkButton: |
|
5511 |
icon = QIcon::fromTheme(QLatin1String("dialog-ok")); |
|
5512 |
break; |
|
5513 |
case SP_DialogDiscardButton: |
|
5514 |
icon = QIcon::fromTheme(QLatin1String("edit-delete")); |
|
5515 |
break; |
|
5516 |
case SP_DialogResetButton: |
|
5517 |
icon = QIcon::fromTheme(QLatin1String("edit-clear")); |
|
5518 |
break; |
|
5519 |
case SP_DialogHelpButton: |
|
5520 |
icon = QIcon::fromTheme(QLatin1String("help-contents")); |
|
5521 |
break; |
|
5522 |
case SP_FileIcon: |
|
5523 |
icon = QIcon::fromTheme(QLatin1String("text-x-generic")); |
|
5524 |
break; |
|
5525 |
case SP_DirClosedIcon: |
|
5526 |
case SP_DirIcon: |
|
5527 |
icon = QIcon::fromTheme(QLatin1String("folder")); |
|
5528 |
break; |
|
5529 |
case SP_DriveFDIcon: |
|
5530 |
icon = QIcon::fromTheme(QLatin1String("floppy_unmount")); |
|
5531 |
break; |
|
5532 |
case SP_ComputerIcon: |
|
5533 |
icon = QIcon::fromTheme(QLatin1String("computer"), |
|
5534 |
QIcon::fromTheme(QLatin1String("system"))); |
|
5535 |
break; |
|
5536 |
case SP_DesktopIcon: |
|
5537 |
icon = QIcon::fromTheme(QLatin1String("user-desktop")); |
|
5538 |
break; |
|
5539 |
case SP_TrashIcon: |
|
5540 |
icon = QIcon::fromTheme(QLatin1String("user-trash")); |
|
5541 |
break; |
|
5542 |
case SP_DriveCDIcon: |
|
5543 |
case SP_DriveDVDIcon: |
|
5544 |
icon = QIcon::fromTheme(QLatin1String("media-optical")); |
|
5545 |
break; |
|
5546 |
case SP_DriveHDIcon: |
|
5547 |
icon = QIcon::fromTheme(QLatin1String("drive-harddisk")); |
|
5548 |
break; |
|
5549 |
case SP_FileDialogToParent: |
|
5550 |
icon = QIcon::fromTheme(QLatin1String("go-up")); |
|
5551 |
break; |
|
5552 |
case SP_FileDialogNewFolder: |
|
5553 |
icon = QIcon::fromTheme(QLatin1String("folder-new")); |
|
5554 |
break; |
|
5555 |
case SP_ArrowUp: |
|
5556 |
icon = QIcon::fromTheme(QLatin1String("go-up")); |
|
5557 |
break; |
|
5558 |
case SP_ArrowDown: |
|
5559 |
icon = QIcon::fromTheme(QLatin1String("go-down")); |
|
5560 |
break; |
|
5561 |
case SP_ArrowRight: |
|
5562 |
icon = QIcon::fromTheme(QLatin1String("go-next")); |
|
5563 |
break; |
|
5564 |
case SP_ArrowLeft: |
|
5565 |
icon = QIcon::fromTheme(QLatin1String("go-previous")); |
|
5566 |
break; |
|
5567 |
case SP_DialogCancelButton: |
|
5568 |
icon = QIcon::fromTheme(QLatin1String("dialog-cancel"), |
|
5569 |
QIcon::fromTheme(QLatin1String("process-stop"))); |
|
5570 |
break; |
|
5571 |
case SP_DialogCloseButton: |
|
5572 |
icon = QIcon::fromTheme(QLatin1String("window-close")); |
|
5573 |
break; |
|
5574 |
case SP_FileDialogDetailedView: |
|
5575 |
icon = QIcon::fromTheme(QLatin1String("view-list-details")); |
|
5576 |
break; |
|
5577 |
case SP_FileDialogListView: |
|
5578 |
icon = QIcon::fromTheme(QLatin1String("view-list-icons")); |
|
5579 |
break; |
|
5580 |
case SP_BrowserReload: |
|
5581 |
icon = QIcon::fromTheme(QLatin1String("view-refresh")); |
|
5582 |
break; |
|
5583 |
case SP_BrowserStop: |
|
5584 |
icon = QIcon::fromTheme(QLatin1String("process-stop")); |
|
5585 |
break; |
|
5586 |
case SP_MediaPlay: |
|
5587 |
icon = QIcon::fromTheme(QLatin1String("media-playback-start")); |
|
5588 |
break; |
|
5589 |
case SP_MediaPause: |
|
5590 |
icon = QIcon::fromTheme(QLatin1String("media-playback-pause")); |
|
5591 |
break; |
|
5592 |
case SP_MediaStop: |
|
5593 |
icon = QIcon::fromTheme(QLatin1String("media-playback-stop")); |
|
5594 |
break; |
|
5595 |
case SP_MediaSeekForward: |
|
5596 |
icon = QIcon::fromTheme(QLatin1String("media-seek-forward")); |
|
5597 |
break; |
|
5598 |
case SP_MediaSeekBackward: |
|
5599 |
icon = QIcon::fromTheme(QLatin1String("media-seek-backward")); |
|
5600 |
break; |
|
5601 |
case SP_MediaSkipForward: |
|
5602 |
icon = QIcon::fromTheme(QLatin1String("media-skip-forward")); |
|
5603 |
break; |
|
5604 |
case SP_MediaSkipBackward: |
|
5605 |
icon = QIcon::fromTheme(QLatin1String("media-skip-backward")); |
|
5606 |
break; |
|
5607 |
case SP_MediaVolume: |
|
5608 |
icon = QIcon::fromTheme(QLatin1String("audio-volume-medium")); |
|
5609 |
break; |
|
5610 |
case SP_MediaVolumeMuted: |
|
5611 |
icon = QIcon::fromTheme(QLatin1String("audio-volume-muted")); |
|
5612 |
break; |
|
5613 |
case SP_ArrowForward: |
|
5614 |
if (rtl) |
|
5615 |
return standardIconImplementation(SP_ArrowLeft, option, widget); |
|
5616 |
return standardIconImplementation(SP_ArrowRight, option, widget); |
|
5617 |
case SP_ArrowBack: |
|
5618 |
if (rtl) |
|
5619 |
return standardIconImplementation(SP_ArrowRight, option, widget); |
|
5620 |
return standardIconImplementation(SP_ArrowLeft, option, widget); |
|
5621 |
case SP_FileLinkIcon: |
|
5622 |
{ |
|
5623 |
QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")); |
|
5624 |
if (!linkIcon.isNull()) { |
|
5625 |
QIcon baseIcon = standardIconImplementation(SP_FileIcon, option, widget); |
|
5626 |
const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off); |
|
5627 |
for (int i = 0 ; i < sizes.size() ; ++i) { |
|
5628 |
int size = sizes[i].width(); |
|
5629 |
QPixmap basePixmap = baseIcon.pixmap(size); |
|
5630 |
QPixmap linkPixmap = linkIcon.pixmap(size/2); |
|
5631 |
QPainter painter(&basePixmap); |
|
5632 |
painter.drawPixmap(size/2, size/2, linkPixmap); |
|
5633 |
icon.addPixmap(basePixmap); |
|
5634 |
} |
|
5635 |
} |
|
5636 |
} |
|
5637 |
break; |
|
5638 |
case SP_DirLinkIcon: |
|
5639 |
{ |
|
5640 |
QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")); |
|
5641 |
if (!linkIcon.isNull()) { |
|
5642 |
QIcon baseIcon = standardIconImplementation(SP_DirIcon, option, widget); |
|
5643 |
const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off); |
|
5644 |
for (int i = 0 ; i < sizes.size() ; ++i) { |
|
5645 |
int size = sizes[i].width(); |
|
5646 |
QPixmap basePixmap = baseIcon.pixmap(size); |
|
5647 |
QPixmap linkPixmap = linkIcon.pixmap(size/2); |
|
5648 |
QPainter painter(&basePixmap); |
|
5649 |
painter.drawPixmap(size/2, size/2, linkPixmap); |
|
5650 |
icon.addPixmap(basePixmap); |
|
5651 |
} |
|
5652 |
} |
|
5653 |
} |
|
5654 |
break; |
|
5655 |
default: |
|
5656 |
break; |
|
5657 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5658 |
} // if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) |
0 | 5659 |
if (!icon.isNull()) |
5660 |
return icon; |
|
5661 |
#if defined(Q_WS_MAC) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5662 |
if (QApplication::desktopSettingsAware()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5663 |
OSType iconType = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5664 |
switch (standardIcon) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5665 |
case QStyle::SP_MessageBoxQuestion: |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5666 |
iconType = kQuestionMarkIcon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5667 |
break; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5668 |
case QStyle::SP_MessageBoxInformation: |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5669 |
iconType = kAlertNoteIcon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5670 |
break; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5671 |
case QStyle::SP_MessageBoxWarning: |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5672 |
iconType = kAlertCautionIcon; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5673 |
break; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5674 |
case QStyle::SP_MessageBoxCritical: |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5675 |
iconType = kAlertStopIcon; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5676 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5677 |
case SP_DesktopIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5678 |
iconType = kDesktopIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5679 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5680 |
case SP_TrashIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5681 |
iconType = kTrashIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5682 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5683 |
case SP_ComputerIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5684 |
iconType = kComputerIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5685 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5686 |
case SP_DriveFDIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5687 |
iconType = kGenericFloppyIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5688 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5689 |
case SP_DriveHDIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5690 |
iconType = kGenericHardDiskIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5691 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5692 |
case SP_DriveCDIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5693 |
case SP_DriveDVDIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5694 |
iconType = kGenericCDROMIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5695 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5696 |
case SP_DriveNetIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5697 |
iconType = kGenericNetworkIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5698 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5699 |
case SP_DirOpenIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5700 |
iconType = kOpenFolderIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5701 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5702 |
case SP_DirClosedIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5703 |
case SP_DirLinkIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5704 |
iconType = kGenericFolderIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5705 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5706 |
case SP_FileLinkIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5707 |
case SP_FileIcon: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5708 |
iconType = kGenericDocumentIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5709 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5710 |
case SP_DirIcon: { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5711 |
// A rather special case |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5712 |
QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, option, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5713 |
QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, option, widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5714 |
closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5715 |
closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5716 |
closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5717 |
closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5718 |
return closeIcon; |
0 | 5719 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5720 |
case SP_TitleBarNormalButton: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5721 |
case SP_TitleBarCloseButton: { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5722 |
QIcon titleBarIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5723 |
if (standardIcon == SP_TitleBarCloseButton) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5724 |
titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5725 |
titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5726 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5727 |
titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5728 |
titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); |
0 | 5729 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5730 |
return titleBarIcon; |
0 | 5731 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5732 |
default: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5733 |
break; |
0 | 5734 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5735 |
if (iconType != 0) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5736 |
QIcon retIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5737 |
IconRef icon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5738 |
IconRef overlayIcon = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5739 |
if (iconType != kGenericApplicationIcon) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5740 |
GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5741 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5742 |
FSRef fsRef; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5743 |
ProcessSerialNumber psn = { 0, kCurrentProcess }; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5744 |
GetProcessBundleLocation(&psn, &fsRef); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5745 |
GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5746 |
if (standardIcon == SP_MessageBoxCritical) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5747 |
overlayIcon = icon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5748 |
GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5749 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5750 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5751 |
if (icon) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5752 |
qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5753 |
ReleaseIconRef(icon); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5754 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5755 |
if (overlayIcon) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5756 |
ReleaseIconRef(overlayIcon); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5757 |
return retIcon; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5758 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5759 |
} // if (QApplication::desktopSettingsAware()) |
0 | 5760 |
#endif // Q_WS_MAC |
5761 |
||
5762 |
switch (standardIcon) { |
|
5763 |
#ifndef QT_NO_IMAGEFORMAT_PNG |
|
5764 |
case SP_FileDialogNewFolder: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5765 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5766 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5767 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-128.png"), QSize(128, 128)); |
0 | 5768 |
break; |
5769 |
case SP_FileDialogBack: |
|
5770 |
return standardIconImplementation(SP_ArrowBack, option, widget); |
|
5771 |
case SP_FileDialogToParent: |
|
5772 |
return standardIconImplementation(SP_ArrowUp, option, widget); |
|
5773 |
case SP_FileDialogDetailedView: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5774 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5775 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5776 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-128.png"), QSize(128, 128)); |
0 | 5777 |
break; |
5778 |
case SP_FileDialogInfoView: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5779 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5780 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5781 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-128.png"), QSize(128, 128)); |
0 | 5782 |
break; |
5783 |
case SP_FileDialogContentsView: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5784 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5785 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5786 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-128.png"), QSize(128, 128)); |
0 | 5787 |
break; |
5788 |
case SP_FileDialogListView: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5789 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5790 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5791 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-128.png"), QSize(128, 128)); |
0 | 5792 |
break; |
5793 |
case SP_DialogOkButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5794 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5795 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5796 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-128.png"), QSize(128, 128)); |
0 | 5797 |
break; |
5798 |
case SP_DialogCancelButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5799 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5800 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5801 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-128.png"), QSize(128, 128)); |
0 | 5802 |
break; |
5803 |
case SP_DialogHelpButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5804 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5805 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5806 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-128.png"), QSize(128, 128)); |
0 | 5807 |
break; |
5808 |
case SP_DialogOpenButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5809 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5810 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5811 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png"), QSize(128, 128)); |
0 | 5812 |
break; |
5813 |
case SP_DialogSaveButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5814 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5815 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5816 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png"), QSize(128, 128)); |
0 | 5817 |
break; |
5818 |
case SP_DialogCloseButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5819 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5820 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5821 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-128.png"), QSize(128, 128)); |
0 | 5822 |
break; |
5823 |
case SP_DialogApplyButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5824 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5825 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5826 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-128.png"), QSize(128, 128)); |
0 | 5827 |
break; |
5828 |
case SP_DialogResetButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5829 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5830 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5831 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-clear-128.png"), QSize(128, 128)); |
0 | 5832 |
break; |
5833 |
case SP_DialogDiscardButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5834 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5835 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5836 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-delete-128.png"), QSize(128, 128)); |
0 | 5837 |
break; |
5838 |
case SP_DialogYesButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5839 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5840 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5841 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-128.png"), QSize(128, 128)); |
0 | 5842 |
break; |
5843 |
case SP_DialogNoButton: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5844 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5845 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5846 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-128.png"), QSize(128, 128)); |
0 | 5847 |
break; |
5848 |
case SP_ArrowForward: |
|
5849 |
if (rtl) |
|
5850 |
return standardIconImplementation(SP_ArrowLeft, option, widget); |
|
5851 |
return standardIconImplementation(SP_ArrowRight, option, widget); |
|
5852 |
case SP_ArrowBack: |
|
5853 |
if (rtl) |
|
5854 |
return standardIconImplementation(SP_ArrowRight, option, widget); |
|
5855 |
return standardIconImplementation(SP_ArrowLeft, option, widget); |
|
5856 |
case SP_ArrowLeft: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5857 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5858 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5859 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-128.png"), QSize(128, 128)); |
0 | 5860 |
break; |
5861 |
case SP_ArrowRight: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5862 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5863 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5864 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-128.png"), QSize(128, 128)); |
0 | 5865 |
break; |
5866 |
case SP_ArrowUp: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5867 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5868 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5869 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-128.png"), QSize(128, 128)); |
0 | 5870 |
break; |
5871 |
case SP_ArrowDown: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5872 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5873 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5874 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-128.png"), QSize(128, 128)); |
0 | 5875 |
break; |
5876 |
case SP_DirHomeIcon: |
|
5877 |
case SP_DirIcon: |
|
5878 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-16.png"), |
|
5879 |
QSize(), QIcon::Normal, QIcon::Off); |
|
5880 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-16.png"), |
|
5881 |
QSize(), QIcon::Normal, QIcon::On); |
|
5882 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-32.png"), |
|
5883 |
QSize(32, 32), QIcon::Normal, QIcon::Off); |
|
5884 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-32.png"), |
|
5885 |
QSize(32, 32), QIcon::Normal, QIcon::On); |
|
5886 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-128.png"), |
|
5887 |
QSize(128, 128), QIcon::Normal, QIcon::Off); |
|
5888 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-128.png"), |
|
5889 |
QSize(128, 128), QIcon::Normal, QIcon::On); |
|
5890 |
break; |
|
5891 |
case SP_DriveCDIcon: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5892 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5893 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5894 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/cdr-128.png"), QSize(128, 128)); |
0 | 5895 |
break; |
5896 |
case SP_DriveDVDIcon: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5897 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5898 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5899 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-128.png"), QSize(128, 128)); |
0 | 5900 |
break; |
5901 |
case SP_FileIcon: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5902 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/file-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5903 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/file-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5904 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/file-128.png"), QSize(128, 128)); |
0 | 5905 |
break; |
5906 |
case SP_FileLinkIcon: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5907 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5908 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5909 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-128.png"), QSize(128, 128)); |
0 | 5910 |
break; |
5911 |
case SP_TrashIcon: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5912 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/trash-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5913 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/trash-32.png"), QSize(32, 32)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5914 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/trash-128.png"), QSize(128, 128)); |
0 | 5915 |
break; |
5916 |
case SP_BrowserReload: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5917 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/refresh-24.png"), QSize(24, 24)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5918 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/refresh-32.png"), QSize(32, 32)); |
0 | 5919 |
break; |
5920 |
case SP_BrowserStop: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5921 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/stop-24.png"), QSize(24, 24)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5922 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/stop-32.png"), QSize(32, 32)); |
0 | 5923 |
break; |
5924 |
case SP_MediaPlay: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5925 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-play-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5926 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-play-32.png"), QSize(32, 32)); |
0 | 5927 |
break; |
5928 |
case SP_MediaPause: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5929 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-pause-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5930 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-pause-32.png"), QSize(32, 32)); |
0 | 5931 |
break; |
5932 |
case SP_MediaStop: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5933 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-stop-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5934 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-stop-32.png"), QSize(32, 32)); |
0 | 5935 |
break; |
5936 |
case SP_MediaSeekForward: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5937 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-forward-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5938 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-forward-32.png"), QSize(32, 32)); |
0 | 5939 |
break; |
5940 |
case SP_MediaSeekBackward: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5941 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-backward-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5942 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-seek-backward-32.png"), QSize(32, 32)); |
0 | 5943 |
break; |
5944 |
case SP_MediaSkipForward: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5945 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-forward-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5946 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-forward-32.png"), QSize(32, 32)); |
0 | 5947 |
break; |
5948 |
case SP_MediaSkipBackward: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5949 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-backward-16.png"), QSize(16, 16)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5950 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-skip-backward-32.png"), QSize(32, 32)); |
0 | 5951 |
break; |
5952 |
case SP_MediaVolume: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5953 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-16.png"), QSize(16, 16)); |
0 | 5954 |
break; |
5955 |
case SP_MediaVolumeMuted: |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
5956 |
icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/media-volume-muted-16.png"), QSize(16, 16)); |
0 | 5957 |
break; |
5958 |
#endif // QT_NO_IMAGEFORMAT_PNG |
|
5959 |
default: |
|
5960 |
icon.addPixmap(proxy()->standardPixmap(standardIcon, option, widget)); |
|
5961 |
break; |
|
5962 |
} |
|
5963 |
return icon; |
|
5964 |
} |
|
5965 |
||
5966 |
static inline uint qt_intensity(uint r, uint g, uint b) |
|
5967 |
{ |
|
5968 |
// 30% red, 59% green, 11% blue |
|
5969 |
return (77 * r + 150 * g + 28 * b) / 255; |
|
5970 |
} |
|
5971 |
||
5972 |
/*! \reimp */ |
|
5973 |
QPixmap QCommonStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, |
|
5974 |
const QStyleOption *opt) const |
|
5975 |
{ |
|
5976 |
switch (iconMode) { |
|
5977 |
case QIcon::Disabled: { |
|
5978 |
QImage im = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); |
|
5979 |
||
5980 |
// Create a colortable based on the background (black -> bg -> white) |
|
5981 |
QColor bg = opt->palette.color(QPalette::Disabled, QPalette::Window); |
|
5982 |
int red = bg.red(); |
|
5983 |
int green = bg.green(); |
|
5984 |
int blue = bg.blue(); |
|
5985 |
uchar reds[256], greens[256], blues[256]; |
|
5986 |
for (int i=0; i<128; ++i) { |
|
5987 |
reds[i] = uchar((red * (i<<1)) >> 8); |
|
5988 |
greens[i] = uchar((green * (i<<1)) >> 8); |
|
5989 |
blues[i] = uchar((blue * (i<<1)) >> 8); |
|
5990 |
} |
|
5991 |
for (int i=0; i<128; ++i) { |
|
5992 |
reds[i+128] = uchar(qMin(red + (i << 1), 255)); |
|
5993 |
greens[i+128] = uchar(qMin(green + (i << 1), 255)); |
|
5994 |
blues[i+128] = uchar(qMin(blue + (i << 1), 255)); |
|
5995 |
} |
|
5996 |
||
5997 |
int intensity = qt_intensity(red, green, blue); |
|
5998 |
const int factor = 191; |
|
5999 |
||
6000 |
// High intensity colors needs dark shifting in the color table, while |
|
6001 |
// low intensity colors needs light shifting. This is to increase the |
|
6002 |
// percieved contrast. |
|
6003 |
if ((red - factor > green && red - factor > blue) |
|
6004 |
|| (green - factor > red && green - factor > blue) |
|
6005 |
|| (blue - factor > red && blue - factor > green)) |
|
6006 |
intensity = qMin(255, intensity + 91); |
|
6007 |
else if (intensity <= 128) |
|
6008 |
intensity -= 51; |
|
6009 |
||
6010 |
for (int y=0; y<im.height(); ++y) { |
|
6011 |
QRgb *scanLine = (QRgb*)im.scanLine(y); |
|
6012 |
for (int x=0; x<im.width(); ++x) { |
|
6013 |
QRgb pixel = *scanLine; |
|
6014 |
// Calculate color table index, taking intensity adjustment |
|
6015 |
// and a magic offset into account. |
|
6016 |
uint ci = uint(qGray(pixel)/3 + (130 - intensity / 3)); |
|
6017 |
*scanLine = qRgba(reds[ci], greens[ci], blues[ci], qAlpha(pixel)); |
|
6018 |
++scanLine; |
|
6019 |
} |
|
6020 |
} |
|
6021 |
||
6022 |
return QPixmap::fromImage(im); |
|
6023 |
} |
|
6024 |
case QIcon::Selected: { |
|
6025 |
QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied); |
|
6026 |
QColor color = opt->palette.color(QPalette::Normal, QPalette::Highlight); |
|
6027 |
color.setAlphaF(qreal(0.3)); |
|
6028 |
QPainter painter(&img); |
|
6029 |
painter.setCompositionMode(QPainter::CompositionMode_SourceAtop); |
|
6030 |
painter.fillRect(0, 0, img.width(), img.height(), color); |
|
6031 |
painter.end(); |
|
6032 |
return QPixmap::fromImage(img); } |
|
6033 |
case QIcon::Active: |
|
6034 |
return pixmap; |
|
6035 |
default: |
|
6036 |
break; |
|
6037 |
} |
|
6038 |
return pixmap; |
|
6039 |
} |
|
6040 |
||
6041 |
/*! |
|
6042 |
\reimp |
|
6043 |
*/ |
|
6044 |
void QCommonStyle::polish(QPalette &pal) |
|
6045 |
{ |
|
6046 |
QStyle::polish(pal); |
|
6047 |
} |
|
6048 |
||
6049 |
/*! |
|
6050 |
\reimp |
|
6051 |
*/ |
|
6052 |
void QCommonStyle::polish(QWidget *widget) |
|
6053 |
{ |
|
6054 |
QStyle::polish(widget); |
|
6055 |
} |
|
6056 |
||
6057 |
/*! |
|
6058 |
\reimp |
|
6059 |
*/ |
|
6060 |
void QCommonStyle::unpolish(QWidget *widget) |
|
6061 |
{ |
|
6062 |
QStyle::unpolish(widget); |
|
6063 |
} |
|
6064 |
||
6065 |
/*! |
|
6066 |
\reimp |
|
6067 |
*/ |
|
6068 |
void QCommonStyle::polish(QApplication *app) |
|
6069 |
{ |
|
6070 |
QStyle::polish(app); |
|
6071 |
} |
|
6072 |
||
6073 |
/*! |
|
6074 |
\reimp |
|
6075 |
*/ |
|
6076 |
void QCommonStyle::unpolish(QApplication *application) |
|
6077 |
{ |
|
6078 |
Q_D(const QCommonStyle); |
|
6079 |
d->tabBarcloseButtonIcon = QIcon(); |
|
6080 |
QStyle::unpolish(application); |
|
6081 |
} |
|
6082 |
||
6083 |
||
6084 |
QT_END_NAMESPACE |