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