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 documentation 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 <QtGui>
|
|
43 |
|
|
44 |
#include "javastyle.h"
|
|
45 |
#include <math.h>
|
|
46 |
|
|
47 |
static const int windowsItemFrame = 2;
|
|
48 |
static const int windowsSepHeight = 2;
|
|
49 |
static const int windowsItemHMargin = 3;
|
|
50 |
static const int windowsItemVMargin = 2;
|
|
51 |
static const int windowsArrowHMargin = 6;
|
|
52 |
static const int windowsTabSpacing = 12;
|
|
53 |
static const int windowsCheckMarkHMargin = 2;
|
|
54 |
static const int windowsRightBorder = 15;
|
|
55 |
static const int windowsCheckMarkWidth = 12;
|
|
56 |
|
|
57 |
JavaStyle::JavaStyle()
|
|
58 |
{
|
|
59 |
qApp->setPalette(standardPalette());
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
inline QPoint JavaStyle::adjustScrollPoint(const QPoint &point,
|
|
64 |
Qt::Orientation orientation,
|
|
65 |
bool add) const
|
|
66 |
{
|
|
67 |
int adder = add ? -1 : 1;
|
|
68 |
QPoint retPoint;
|
|
69 |
|
|
70 |
if (orientation == Qt::Horizontal) {
|
|
71 |
retPoint = QPoint(point.y() * adder, point.x());
|
|
72 |
} else {
|
|
73 |
retPoint = QPoint(point.x(), point.y() * adder);
|
|
74 |
}
|
|
75 |
|
|
76 |
return retPoint;
|
|
77 |
}
|
|
78 |
|
|
79 |
QPalette JavaStyle::standardPalette() const
|
|
80 |
{
|
|
81 |
QPalette palette = QWindowsStyle::standardPalette();
|
|
82 |
|
|
83 |
palette.setBrush(QPalette::Active, QPalette::Button,
|
|
84 |
QColor(184, 207, 229));
|
|
85 |
palette.setBrush(QPalette::Active, QPalette::WindowText,
|
|
86 |
Qt::black);
|
|
87 |
palette.setBrush(QPalette::Active, QPalette::Background,
|
|
88 |
QColor(238, 238, 238));
|
|
89 |
palette.setBrush(QPalette::Active, QPalette::Window,
|
|
90 |
QColor(238 ,238, 238));
|
|
91 |
palette.setBrush(QPalette::Active, QPalette::Base, Qt::white);
|
|
92 |
palette.setBrush(QPalette::Active, QPalette::AlternateBase, QColor(238, 238, 238));
|
|
93 |
palette.setBrush(QPalette::Active, QPalette::Text, Qt::black);
|
|
94 |
palette.setBrush(QPalette::Active, QPalette::BrightText, Qt::white);
|
|
95 |
|
|
96 |
palette.setBrush(QPalette::Active, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
|
|
97 |
palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
|
|
98 |
palette.setBrush(QPalette::Active, QPalette::Dark, QColor(106, 104, 100));
|
|
99 |
palette.setBrush(QPalette::Active, QPalette::Mid, QColor(122, 138, 153)); //defaultFrameColor
|
|
100 |
palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
|
|
101 |
|
|
102 |
palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(184, 207, 229));
|
|
103 |
palette.setBrush(QPalette::Active, QPalette::HighlightedText, Qt::black);
|
|
104 |
|
|
105 |
palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(184, 207, 229));
|
|
106 |
palette.setBrush(QPalette::Inactive, QPalette::HighlightedText, Qt::black);
|
|
107 |
|
|
108 |
palette.setBrush(QPalette::Disabled, QPalette::Button,
|
|
109 |
QColor(238, 238, 238));
|
|
110 |
palette.setBrush(QPalette::Disabled, QPalette::WindowText,
|
|
111 |
QColor(153, 153, 153));
|
|
112 |
palette.setBrush(QPalette::Disabled, QPalette::Background, QColor(238, 238, 238));
|
|
113 |
|
|
114 |
palette.setBrush(QPalette::Inactive, QPalette::Button,
|
|
115 |
QColor(184, 207, 229));
|
|
116 |
palette.setBrush(QPalette::Inactive, QPalette::Background,
|
|
117 |
QColor(238, 238, 238));
|
|
118 |
palette.setBrush(QPalette::Inactive, QPalette::Window,
|
|
119 |
QColor(238 ,238, 238));
|
|
120 |
palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
|
|
121 |
palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
|
|
122 |
palette.setBrush(QPalette::Inactive, QPalette::Dark,QColor(106, 104, 100));
|
|
123 |
palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(122, 138, 153)); //defaultFrame
|
|
124 |
palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
|
|
125 |
|
|
126 |
return palette;
|
|
127 |
}
|
|
128 |
|
|
129 |
inline void JavaStyle::drawScrollBarArrow(const QRect &rect, QPainter *painter,
|
|
130 |
const QStyleOptionSlider *option,
|
|
131 |
bool add) const
|
|
132 |
{
|
|
133 |
|
|
134 |
painter->save();
|
|
135 |
|
|
136 |
Qt::Orientation orient = option->orientation;
|
|
137 |
QPoint offset;
|
|
138 |
|
|
139 |
if (add) {
|
|
140 |
if (orient == Qt::Vertical) {
|
|
141 |
offset = rect.bottomLeft();
|
|
142 |
} else {
|
|
143 |
offset = rect.topRight();
|
|
144 |
}
|
|
145 |
} else {
|
|
146 |
offset = rect.topLeft();
|
|
147 |
}
|
|
148 |
|
|
149 |
QPainterPath arrow;
|
|
150 |
arrow.moveTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
|
|
151 |
arrow.lineTo(offset + adjustScrollPoint(QPoint(7, 5), orient, add));
|
|
152 |
arrow.lineTo(offset + adjustScrollPoint(QPoint(8, 5), orient, add));
|
|
153 |
arrow.lineTo(offset + adjustScrollPoint(QPoint(11, 8), orient, add));
|
|
154 |
arrow.lineTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
|
|
155 |
|
|
156 |
QColor fillColor;
|
|
157 |
if (option->state & State_Sunken)
|
|
158 |
fillColor = QColor(option->palette.color(QPalette::Button));
|
|
159 |
else
|
|
160 |
fillColor = option->palette.color(QPalette::Background);
|
|
161 |
|
|
162 |
painter->fillRect(rect, fillColor);
|
|
163 |
|
|
164 |
painter->setPen(option->palette.color(QPalette::Base));
|
|
165 |
int adjust = option->state & State_Sunken ? 0 : 1;
|
|
166 |
painter->drawRect(rect.adjusted(adjust, adjust, -1, -1));
|
|
167 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
168 |
painter->drawRect(rect.adjusted(0, 0, -1, -1));
|
|
169 |
|
|
170 |
painter->setPen(option->palette.color(QPalette::WindowText));
|
|
171 |
painter->setBrush(option->palette.color(QPalette::WindowText));
|
|
172 |
painter->drawPath(arrow);
|
|
173 |
|
|
174 |
painter->restore();
|
|
175 |
}
|
|
176 |
|
|
177 |
inline QPoint JavaStyle::adjustScrollHandlePoint(Qt::Orientation orig,
|
|
178 |
const QPoint &point) const
|
|
179 |
{
|
|
180 |
QPoint retPoint;
|
|
181 |
|
|
182 |
if (orig == Qt::Vertical)
|
|
183 |
retPoint = point;
|
|
184 |
else
|
|
185 |
retPoint = QPoint(point.y(), point.x());
|
|
186 |
|
|
187 |
return retPoint;
|
|
188 |
}
|
|
189 |
|
|
190 |
void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
|
|
191 |
QPainter *painter, const QWidget *widget) const
|
|
192 |
{
|
|
193 |
|
|
194 |
painter->save();
|
|
195 |
|
|
196 |
switch (control) {
|
|
197 |
case CE_ToolBoxTabShape: {
|
|
198 |
const QStyleOptionToolBox *box =
|
|
199 |
qstyleoption_cast<const QStyleOptionToolBox *>(option);
|
|
200 |
|
|
201 |
painter->save();
|
|
202 |
|
|
203 |
if (box->direction == Qt::RightToLeft) {
|
|
204 |
painter->rotate(1);
|
|
205 |
painter->translate(box->rect.width(), -box->rect.height());
|
|
206 |
}
|
|
207 |
|
|
208 |
int textWidth = box->fontMetrics.width(box->text) + 20;
|
|
209 |
|
|
210 |
QPolygon innerLine;
|
|
211 |
innerLine << (box->rect.topLeft() + QPoint(0, 1)) <<
|
|
212 |
(box->rect.topLeft() + QPoint(textWidth, 1)) <<
|
|
213 |
(box->rect.bottomLeft() + QPoint(textWidth + 15, -3)) <<
|
|
214 |
(box->rect.bottomRight() + QPoint(0, -3)) <<
|
|
215 |
box->rect.bottomRight() <<
|
|
216 |
box->rect.bottomLeft() <<
|
|
217 |
box->rect.topLeft();
|
|
218 |
|
|
219 |
painter->setPen(box->palette.color(QPalette::Base));
|
|
220 |
painter->setBrush(QColor(200, 221, 242));
|
|
221 |
painter->drawPolygon(innerLine);
|
|
222 |
|
|
223 |
QPolygon outerLine;
|
|
224 |
outerLine << (box->rect.bottomRight() + QPoint(0, -3)) <<
|
|
225 |
box->rect.bottomRight() <<
|
|
226 |
box->rect.bottomLeft() <<
|
|
227 |
box->rect.topLeft() <<
|
|
228 |
(box->rect.topLeft() + QPoint(textWidth, 0)) <<
|
|
229 |
(box->rect.bottomLeft() + QPoint(textWidth + 15, -4)) <<
|
|
230 |
(box->rect.bottomRight() + QPoint(0, -4));
|
|
231 |
|
|
232 |
painter->setPen(box->palette.color(QPalette::Midlight));
|
|
233 |
painter->setBrush(Qt::NoBrush);
|
|
234 |
painter->drawPolyline(outerLine);
|
|
235 |
|
|
236 |
painter->restore();
|
|
237 |
break;
|
|
238 |
}
|
|
239 |
case CE_DockWidgetTitle: {
|
|
240 |
const QStyleOptionDockWidgetV2 *docker =
|
|
241 |
new QStyleOptionDockWidgetV2(
|
|
242 |
*qstyleoption_cast<const QStyleOptionDockWidget *>(option));
|
|
243 |
|
|
244 |
QRect rect = docker->rect;
|
|
245 |
QRect titleRect = rect;
|
|
246 |
if (docker->verticalTitleBar) {
|
|
247 |
QRect r = rect;
|
|
248 |
QSize s = r.size();
|
|
249 |
s.transpose();
|
|
250 |
r.setSize(s);
|
|
251 |
|
|
252 |
titleRect = QRect(r.left() + rect.bottom()
|
|
253 |
- titleRect.bottom(),
|
|
254 |
r.top() + titleRect.left() - rect.left(),
|
|
255 |
titleRect.height(), titleRect.width());
|
|
256 |
|
|
257 |
painter->translate(r.left(), r.top() + r.width());
|
|
258 |
painter->rotate(-90);
|
|
259 |
painter->translate(-r.left(), -r.top());
|
|
260 |
|
|
261 |
rect = r;
|
|
262 |
}
|
|
263 |
|
|
264 |
QLinearGradient gradient(rect.topLeft(),
|
|
265 |
rect.bottomLeft());
|
|
266 |
gradient.setColorAt(1.0, QColor(191, 212, 231));
|
|
267 |
gradient.setColorAt(0.3, Qt::white);
|
|
268 |
gradient.setColorAt(0.0, QColor(221, 232, 243));
|
|
269 |
|
|
270 |
painter->setPen(Qt::NoPen);
|
|
271 |
painter->setBrush(gradient);
|
|
272 |
painter->drawRect(rect.adjusted(0, 0, -1, -1));
|
|
273 |
|
|
274 |
if (!docker->title.isEmpty()) {
|
|
275 |
QRect textRect = docker->fontMetrics.boundingRect(docker->title);
|
|
276 |
textRect.moveCenter(rect.center());
|
|
277 |
|
|
278 |
QFont font = painter->font();
|
|
279 |
font.setPointSize(font.pointSize() - 1);
|
|
280 |
painter->setFont(font);
|
|
281 |
painter->setPen(docker->palette.text().color());
|
|
282 |
painter->drawText(textRect, docker->title,
|
|
283 |
QTextOption(Qt::AlignHCenter |
|
|
284 |
Qt::AlignVCenter));
|
|
285 |
}
|
|
286 |
break;
|
|
287 |
}
|
|
288 |
case CE_RubberBand: {
|
|
289 |
painter->setPen(option->palette.color(QPalette::Active,
|
|
290 |
QPalette::WindowText));
|
|
291 |
painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
|
292 |
break;
|
|
293 |
}
|
|
294 |
case CE_SizeGrip: {
|
|
295 |
break;
|
|
296 |
}
|
|
297 |
case CE_HeaderSection: {
|
|
298 |
const QStyleOptionHeader *header =
|
|
299 |
qstyleoption_cast<const QStyleOptionHeader *>(option);
|
|
300 |
|
|
301 |
painter->setPen(Qt::NoPen);
|
|
302 |
painter->setBrush(option->palette.color(QPalette::Active,
|
|
303 |
QPalette::Background));
|
|
304 |
painter->drawRect(option->rect);
|
|
305 |
|
|
306 |
painter->setPen(header->palette.color(QPalette::Mid));
|
|
307 |
if (header->orientation == Qt::Horizontal) {
|
|
308 |
if (header->position == QStyleOptionHeader::Beginning ||
|
|
309 |
header->position == QStyleOptionHeader::OnlyOneSection) {
|
|
310 |
painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
|
|
311 |
painter->setPen(header->palette.color(QPalette::Base));
|
|
312 |
painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
|
|
313 |
header->rect.topLeft() + QPoint(1, 1));
|
|
314 |
painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
|
|
315 |
header->rect.topRight() + QPoint(-1, 1));
|
|
316 |
} else {
|
|
317 |
painter->drawLine(header->rect.bottomRight(),
|
|
318 |
header->rect.topRight());
|
|
319 |
painter->drawLine(header->rect.topLeft(),
|
|
320 |
header->rect.topRight());
|
|
321 |
painter->drawLine(header->rect.bottomLeft(),
|
|
322 |
header->rect.bottomRight());
|
|
323 |
painter->setPen(option->palette.color(QPalette::Base));
|
|
324 |
painter->drawLine(header->rect.bottomLeft() + QPoint(0, -1),
|
|
325 |
header->rect.topLeft() + QPoint(0, 1));
|
|
326 |
painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
|
|
327 |
header->rect.topRight() + QPoint(-1, 1));
|
|
328 |
}
|
|
329 |
} else { // Vertical
|
|
330 |
if (header->position == QStyleOptionHeader::Beginning ||
|
|
331 |
header->position == QStyleOptionHeader::OnlyOneSection) {
|
|
332 |
painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
|
|
333 |
painter->setPen(header->palette.color(QPalette::Base));
|
|
334 |
painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
|
|
335 |
header->rect.topLeft() + QPoint(1, 1));
|
|
336 |
painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
|
|
337 |
header->rect.topRight() + QPoint(-1, 1));
|
|
338 |
} else {
|
|
339 |
painter->drawLine(header->rect.bottomLeft(),
|
|
340 |
header->rect.bottomRight());
|
|
341 |
painter->drawLine(header->rect.topLeft(),
|
|
342 |
header->rect.bottomLeft());
|
|
343 |
painter->drawLine(header->rect.topRight(),
|
|
344 |
header->rect.bottomRight());
|
|
345 |
painter->setPen(header->palette.color(QPalette::Base));
|
|
346 |
painter->drawLine(header->rect.topLeft(),
|
|
347 |
header->rect.topRight() + QPoint(-1, 0));
|
|
348 |
painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
|
|
349 |
header->rect.topLeft() + QPoint(1, 0));
|
|
350 |
}
|
|
351 |
}
|
|
352 |
break;
|
|
353 |
}
|
|
354 |
case CE_ToolBar: {
|
|
355 |
QRect rect = option->rect;
|
|
356 |
|
|
357 |
QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
|
|
358 |
gradient.setColorAt(1.0, QColor(221, 221, 221));
|
|
359 |
gradient.setColorAt(0.0, QColor(241, 241, 241));
|
|
360 |
|
|
361 |
if (option->state & State_Horizontal) {
|
|
362 |
painter->setPen(QColor(204, 204, 204));
|
|
363 |
painter->setBrush(gradient);
|
|
364 |
} else {
|
|
365 |
painter->setPen(Qt::NoPen);
|
|
366 |
painter->setBrush(option->palette.color(QPalette::Background));
|
|
367 |
}
|
|
368 |
painter->drawRect(rect.adjusted(0, 0, -1, -1));
|
|
369 |
break;
|
|
370 |
}
|
|
371 |
case CE_ProgressBar: {
|
|
372 |
const QStyleOptionProgressBar *bar1 =
|
|
373 |
qstyleoption_cast<const QStyleOptionProgressBar *>(option);
|
|
374 |
|
|
375 |
QStyleOptionProgressBarV2 *bar = new QStyleOptionProgressBarV2(*bar1);
|
|
376 |
|
|
377 |
QRect rect = bar->rect;
|
|
378 |
if (bar->orientation == Qt::Vertical) {
|
|
379 |
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width());
|
|
380 |
QMatrix m;
|
|
381 |
m.translate(rect.height()-1, 0);
|
|
382 |
m.rotate(90.0);
|
|
383 |
painter->setMatrix(m);
|
|
384 |
}
|
|
385 |
|
|
386 |
painter->setPen(bar->palette.color(QPalette::Mid));
|
|
387 |
painter->drawRect(rect.adjusted(0, 0, -1, -1));
|
|
388 |
|
|
389 |
QRect grooveRect = subElementRect(SE_ProgressBarGroove, bar,
|
|
390 |
widget);
|
|
391 |
if (bar->orientation == Qt::Vertical) {
|
|
392 |
grooveRect = QRect(grooveRect.left(), grooveRect.top(),
|
|
393 |
grooveRect.height(), grooveRect.width());
|
|
394 |
}
|
|
395 |
|
|
396 |
QStyleOptionProgressBar grooveBar = *bar;
|
|
397 |
grooveBar.rect = grooveRect;
|
|
398 |
|
|
399 |
drawControl(CE_ProgressBarGroove, &grooveBar, painter, widget);
|
|
400 |
|
|
401 |
QRect progressRect = subElementRect(SE_ProgressBarContents, bar,
|
|
402 |
widget);
|
|
403 |
if (bar->orientation == Qt::Vertical) {
|
|
404 |
progressRect = QRect(progressRect.left(), progressRect.top(),
|
|
405 |
progressRect.height(), progressRect.width());
|
|
406 |
progressRect.adjust(0, 0, 0, -1);
|
|
407 |
}
|
|
408 |
QStyleOptionProgressBar progressOpt = *bar;
|
|
409 |
progressOpt.rect = progressRect;
|
|
410 |
drawControl(CE_ProgressBarContents, &progressOpt, painter, widget);
|
|
411 |
|
|
412 |
QRect labelRect = subElementRect(SE_ProgressBarLabel, bar, widget);
|
|
413 |
if (bar->orientation == Qt::Vertical) {
|
|
414 |
labelRect = QRect(labelRect.left(), labelRect.top(),
|
|
415 |
labelRect.height(), labelRect.width());
|
|
416 |
}
|
|
417 |
QStyleOptionProgressBar subBar = *bar;
|
|
418 |
subBar.rect = labelRect;
|
|
419 |
if (bar->textVisible)
|
|
420 |
drawControl(CE_ProgressBarLabel, &subBar, painter, widget);
|
|
421 |
|
|
422 |
delete bar;
|
|
423 |
break;
|
|
424 |
}
|
|
425 |
case CE_ProgressBarGroove: {
|
|
426 |
painter->setBrush(option->palette.color(QPalette::Background));
|
|
427 |
painter->setPen(Qt::NoPen);
|
|
428 |
painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
|
429 |
|
|
430 |
painter->setPen(option->palette.color(QPalette::Button));
|
|
431 |
painter->drawLine(option->rect.topLeft() + QPoint(0, 0),
|
|
432 |
option->rect.topRight() + QPoint(0, 0));
|
|
433 |
break;
|
|
434 |
}
|
|
435 |
case CE_ProgressBarContents: {
|
|
436 |
const QStyleOptionProgressBar *bar =
|
|
437 |
qstyleoption_cast<const QStyleOptionProgressBar *>(option);
|
|
438 |
int progress = int((double(bar->progress) /
|
|
439 |
double(bar->maximum - bar->minimum)) *
|
|
440 |
bar->rect.width());
|
|
441 |
|
|
442 |
painter->setBrush(bar->palette.color(QPalette::Light));
|
|
443 |
painter->setPen(Qt::NoPen);
|
|
444 |
QRect progressRect = QRect(bar->rect.topLeft(), QPoint(progress,
|
|
445 |
bar->rect.bottom()));
|
|
446 |
painter->drawRect(progressRect);
|
|
447 |
|
|
448 |
painter->setPen(bar->palette.color(QPalette::Midlight));
|
|
449 |
painter->setBrush(Qt::NoBrush);
|
|
450 |
|
|
451 |
painter->drawLine(bar->rect.bottomLeft(), bar->rect.topLeft());
|
|
452 |
painter->drawLine(bar->rect.topLeft(), QPoint(progress,
|
|
453 |
bar->rect.top()));
|
|
454 |
break;
|
|
455 |
}
|
|
456 |
case CE_ProgressBarLabel: {
|
|
457 |
painter->save();
|
|
458 |
const QStyleOptionProgressBar *bar =
|
|
459 |
qstyleoption_cast<const QStyleOptionProgressBar *>(option);
|
|
460 |
|
|
461 |
QRect rect = bar->rect;
|
|
462 |
QRect leftRect;
|
|
463 |
|
|
464 |
int progressIndicatorPos = int((double(bar->progress) /
|
|
465 |
double(bar->maximum - bar->minimum)) *
|
|
466 |
bar->rect.width());
|
|
467 |
|
|
468 |
QFont font;
|
|
469 |
font.setBold(true);
|
|
470 |
painter->setFont(font);
|
|
471 |
painter->setPen(bar->palette.color(QPalette::Midlight));
|
|
472 |
|
|
473 |
if (progressIndicatorPos >= 0 &&
|
|
474 |
progressIndicatorPos <= rect.width()) {
|
|
475 |
leftRect = QRect(bar->rect.topLeft(),
|
|
476 |
QPoint(progressIndicatorPos,
|
|
477 |
bar->rect.bottom()));
|
|
478 |
} else if (progressIndicatorPos > rect.width()) {
|
|
479 |
painter->setPen(bar->palette.color(QPalette::Base));
|
|
480 |
} else {
|
|
481 |
painter->setPen(bar->palette.color(QPalette::Midlight));
|
|
482 |
}
|
|
483 |
|
|
484 |
QRect textRect = QFontMetrics(font).boundingRect(bar->text);
|
|
485 |
textRect.moveCenter(option->rect.center());
|
|
486 |
painter->drawText(textRect, bar->text,
|
|
487 |
QTextOption(Qt::AlignCenter));
|
|
488 |
if (!leftRect.isNull()) {
|
|
489 |
painter->setPen(bar->palette.color(QPalette::Base));
|
|
490 |
painter->setClipRect(leftRect, Qt::IntersectClip);
|
|
491 |
painter->drawText(textRect, bar->text,
|
|
492 |
QTextOption(Qt::AlignCenter));
|
|
493 |
}
|
|
494 |
|
|
495 |
painter->restore();
|
|
496 |
break;
|
|
497 |
}
|
|
498 |
case CE_MenuBarEmptyArea: {
|
|
499 |
QRect emptyArea = option->rect.adjusted(0, 0, -1, -1);
|
|
500 |
QLinearGradient gradient(emptyArea.topLeft(), emptyArea.bottomLeft()
|
|
501 |
- QPoint(0, 1));
|
|
502 |
gradient.setColorAt(0.0, option->palette.color(QPalette::Base));
|
|
503 |
gradient.setColorAt(1.0, QColor(223, 223, 223));
|
|
504 |
|
|
505 |
painter->setPen(QColor(238, 238, 238));
|
|
506 |
painter->setBrush(gradient);
|
|
507 |
painter->drawRect(emptyArea.adjusted(0, 0, 0, -1));
|
|
508 |
break;
|
|
509 |
}
|
|
510 |
case CE_MenuBarItem: {
|
|
511 |
if (!(option->state & State_Sunken)) {
|
|
512 |
QLinearGradient gradient(option->rect.topLeft(),
|
|
513 |
option->rect.bottomLeft());
|
|
514 |
gradient.setColorAt(0.0, Qt::white);
|
|
515 |
gradient.setColorAt(1.0, QColor(223, 223, 223));
|
|
516 |
|
|
517 |
painter->setPen(Qt::NoPen);
|
|
518 |
painter->setBrush(gradient);
|
|
519 |
} else {
|
|
520 |
painter->setBrush(option->palette.color(QPalette::Light));
|
|
521 |
}
|
|
522 |
|
|
523 |
painter->drawRect(option->rect);
|
|
524 |
if (option->state & State_Sunken) {
|
|
525 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
526 |
painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
|
527 |
painter->setPen(option->palette.color(QPalette::Base));
|
|
528 |
painter->setBrush(Qt::NoBrush);
|
|
529 |
painter->drawLine(option->rect.bottomRight() + QPoint(0, -1),
|
|
530 |
option->rect.topRight() + QPoint(0, -1));
|
|
531 |
}
|
|
532 |
QCommonStyle::drawControl(control, option, painter, widget);
|
|
533 |
break;
|
|
534 |
}
|
|
535 |
case CE_MenuItem: {
|
|
536 |
const QStyleOptionMenuItem *menuItem =
|
|
537 |
qstyleoption_cast<const QStyleOptionMenuItem *>(option);
|
|
538 |
|
|
539 |
bool selected = menuItem->state & State_Selected;
|
|
540 |
bool checkable = menuItem->checkType !=
|
|
541 |
QStyleOptionMenuItem::NotCheckable;
|
|
542 |
bool checked = menuItem->checked;
|
|
543 |
|
|
544 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
|
|
545 |
QPoint center = menuItem->rect.center();
|
|
546 |
|
|
547 |
painter->setPen(menuItem->palette.color(QPalette::Midlight));
|
|
548 |
painter->drawLine(QPoint(menuItem->rect.left() - 2, center.y()),
|
|
549 |
QPoint(menuItem->rect.right(), center.y()));
|
|
550 |
painter->setPen(menuItem->palette.color(QPalette::Base));
|
|
551 |
painter->drawLine(QPoint(menuItem->rect.left() - 2,
|
|
552 |
center.y() + 1),
|
|
553 |
QPoint(menuItem->rect.right(),
|
|
554 |
center.y() + 1));
|
|
555 |
|
|
556 |
break;
|
|
557 |
}
|
|
558 |
|
|
559 |
if (selected) {
|
|
560 |
painter->setBrush(menuItem->palette.color(QPalette::Light));
|
|
561 |
painter->setPen(Qt::NoPen);
|
|
562 |
painter->drawRect(menuItem->rect);
|
|
563 |
painter->setPen(menuItem->palette.color(QPalette::Midlight));
|
|
564 |
painter->drawLine(menuItem->rect.topLeft(),
|
|
565 |
menuItem->rect.topRight());
|
|
566 |
painter->setPen(menuItem->palette.color(QPalette::Base));
|
|
567 |
painter->drawLine(menuItem->rect.bottomLeft(),
|
|
568 |
menuItem->rect.bottomRight());
|
|
569 |
}
|
|
570 |
|
|
571 |
if (checkable) {
|
|
572 |
QRect checkRect(option->rect.left() + 5,
|
|
573 |
option->rect.center().y() - 5, 10, 10);
|
|
574 |
if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
|
|
575 |
QStyleOptionButton button;
|
|
576 |
button.rect = checkRect;
|
|
577 |
button.state = menuItem->state;
|
|
578 |
if (button.state & State_Sunken)
|
|
579 |
button.state ^= State_Sunken;
|
|
580 |
if (checked)
|
|
581 |
button.state |= State_On;
|
|
582 |
button.palette = menuItem->palette;
|
|
583 |
drawPrimitive(PE_IndicatorRadioButton, &button, painter,
|
|
584 |
widget);
|
|
585 |
} else {
|
|
586 |
QBrush buttonBrush = gradientBrush(option->rect);
|
|
587 |
painter->setBrush(buttonBrush);
|
|
588 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
589 |
|
|
590 |
painter->drawRect(checkRect);
|
|
591 |
|
|
592 |
if (checked) {
|
|
593 |
QImage image(":/images/checkboxchecked.png");
|
|
594 |
painter->drawImage(QPoint(option->rect.left() + 5,
|
|
595 |
option->rect.center().y() - 8), image);
|
|
596 |
}
|
|
597 |
}
|
|
598 |
}
|
|
599 |
|
|
600 |
bool dis = !(menuItem->state & State_Enabled);
|
|
601 |
bool act = menuItem->state & State_Selected;
|
|
602 |
const QStyleOption *opt = option;
|
|
603 |
const QStyleOptionMenuItem *menuitem = menuItem;
|
|
604 |
int checkcol = qMax(menuitem->maxIconWidth, 20);
|
|
605 |
if (menuItem->icon.isNull())
|
|
606 |
checkcol = 0;
|
|
607 |
|
|
608 |
QPainter *p = painter;
|
|
609 |
QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
|
|
610 |
QRect(menuitem->rect.x(),
|
|
611 |
menuitem->rect.y(),
|
|
612 |
checkcol, menuitem->rect.height()));
|
|
613 |
if (!menuItem->icon.isNull()) {
|
|
614 |
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
|
|
615 |
if (act && !dis)
|
|
616 |
mode = QIcon::Active;
|
|
617 |
QPixmap pixmap;
|
|
618 |
if (checked)
|
|
619 |
pixmap = menuItem->icon.pixmap(
|
|
620 |
pixelMetric(PM_SmallIconSize), mode, QIcon::On);
|
|
621 |
else
|
|
622 |
pixmap = menuItem->icon.pixmap(
|
|
623 |
pixelMetric(PM_SmallIconSize), mode);
|
|
624 |
int pixw = pixmap.width();
|
|
625 |
int pixh = pixmap.height();
|
|
626 |
|
|
627 |
int adjustedIcon = checkable ? 15 : 0;
|
|
628 |
QRect pmr(0, 0, pixw, pixh);
|
|
629 |
pmr.moveCenter(vCheckRect.center());
|
|
630 |
painter->setPen(menuItem->palette.text().color());
|
|
631 |
if (checkable && checked)
|
|
632 |
painter->drawPixmap(QPoint(pmr.left() +
|
|
633 |
adjustedIcon, pmr.top() + 1), pixmap);
|
|
634 |
else
|
|
635 |
painter->drawPixmap(pmr.topLeft() +
|
|
636 |
QPoint(adjustedIcon, 0), pixmap);
|
|
637 |
}
|
|
638 |
|
|
639 |
if (selected) {
|
|
640 |
painter->setPen(menuItem->palette.highlightedText().color());
|
|
641 |
} else {
|
|
642 |
painter->setPen(menuItem->palette.text().color());
|
|
643 |
}
|
|
644 |
int x, y, w, h;
|
|
645 |
menuitem->rect.getRect(&x, &y, &w, &h);
|
|
646 |
int tab = menuitem->tabWidth;
|
|
647 |
QColor discol;
|
|
648 |
if (dis) {
|
|
649 |
discol = menuitem->palette.text().color();
|
|
650 |
p->setPen(discol);
|
|
651 |
}
|
|
652 |
int xm = windowsItemFrame + checkcol + windowsItemHMargin;
|
|
653 |
int xpos = menuitem->rect.x() + xm;
|
|
654 |
QRect textRect;
|
|
655 |
if (!menuItem->icon.isNull())
|
|
656 |
textRect.setRect(xpos, y + windowsItemVMargin, w - xm -
|
|
657 |
windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
|
|
658 |
else
|
|
659 |
textRect.setRect(menuItem->rect.left() + 9,
|
|
660 |
y + windowsItemVMargin,
|
|
661 |
w - xm - windowsRightBorder - tab,
|
|
662 |
h - 2 * windowsItemVMargin);
|
|
663 |
|
|
664 |
if (checkable)
|
|
665 |
textRect.adjust(10, 0, 10, 0);
|
|
666 |
|
|
667 |
QRect vTextRect = visualRect(opt->direction, menuitem->rect,
|
|
668 |
textRect);
|
|
669 |
QString s = menuitem->text;
|
|
670 |
if (!s.isEmpty()) {
|
|
671 |
int t = s.indexOf(QLatin1Char('\t'));
|
|
672 |
int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic |
|
|
673 |
Qt::TextDontClip | Qt::TextSingleLine;
|
|
674 |
if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
|
|
675 |
text_flags |= Qt::TextHideMnemonic;
|
|
676 |
text_flags |= Qt::AlignLeft;
|
|
677 |
if (t >= 0) {
|
|
678 |
QRect vShortcutRect = visualRect(opt->direction,
|
|
679 |
menuitem->rect,
|
|
680 |
QRect(textRect.topRight(),
|
|
681 |
QPoint(menuitem->rect.right(), textRect.bottom())));
|
|
682 |
if (dis && !act) {
|
|
683 |
p->setPen(menuitem->palette.light().color());
|
|
684 |
p->drawText(vShortcutRect.adjusted(1, 1, 1, 1),
|
|
685 |
text_flags,
|
|
686 |
s.mid(t + 1));
|
|
687 |
p->setPen(discol);
|
|
688 |
}
|
|
689 |
p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
|
|
690 |
s = s.left(t);
|
|
691 |
}
|
|
692 |
QFont font = menuitem->font;
|
|
693 |
if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
|
|
694 |
font.setBold(true);
|
|
695 |
p->setFont(font);
|
|
696 |
if (dis && !act) {
|
|
697 |
p->setPen(menuitem->palette.light().color());
|
|
698 |
p->drawText(vTextRect.adjusted(1,1,1,1), text_flags,
|
|
699 |
s.left(t));
|
|
700 |
p->setPen(discol);
|
|
701 |
}
|
|
702 |
p->drawText(vTextRect, text_flags, s.left(t));
|
|
703 |
}
|
|
704 |
|
|
705 |
if (menuItem->menuItemType & QStyleOptionMenuItem::SubMenu) {
|
|
706 |
QPoint center = menuItem->rect.center();
|
|
707 |
QPoint drawStart(menuItem->rect.right() - 6, center.y() + 4);
|
|
708 |
|
|
709 |
QPainterPath arrow;
|
|
710 |
arrow.moveTo(drawStart);
|
|
711 |
arrow.lineTo(drawStart + QPoint(0, -8));
|
|
712 |
arrow.lineTo(drawStart + QPoint(4, -5));
|
|
713 |
arrow.lineTo(drawStart + QPoint(4, -4));
|
|
714 |
arrow.lineTo(drawStart + QPoint(0, 0));
|
|
715 |
|
|
716 |
painter->save();
|
|
717 |
painter->setBrush(menuItem->palette.color(QPalette::Text));
|
|
718 |
painter->setPen(Qt::NoPen);
|
|
719 |
painter->drawPath(arrow);
|
|
720 |
painter->restore();
|
|
721 |
}
|
|
722 |
|
|
723 |
break;
|
|
724 |
}
|
|
725 |
case CE_MenuVMargin: {
|
|
726 |
break;
|
|
727 |
}
|
|
728 |
case CE_MenuHMargin: {
|
|
729 |
break;
|
|
730 |
}
|
|
731 |
case CE_Splitter: {
|
|
732 |
drawSplitter(option, painter, option->state & State_Horizontal);
|
|
733 |
break;
|
|
734 |
}
|
|
735 |
case CE_ScrollBarAddPage: {
|
|
736 |
case CE_ScrollBarSubPage:
|
|
737 |
const QStyleOptionSlider *scrollBar =
|
|
738 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
739 |
QRect myRect;
|
|
740 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
741 |
myRect = QRect(option->rect.topLeft(),
|
|
742 |
option->rect.bottomRight()).adjusted(0, 0, 1, -1);
|
|
743 |
} else {
|
|
744 |
myRect = option->rect;
|
|
745 |
}
|
|
746 |
|
|
747 |
painter->setPen(Qt::NoPen);
|
|
748 |
painter->setBrush(option->palette.color(QPalette::Background));
|
|
749 |
painter->drawRect(myRect);
|
|
750 |
|
|
751 |
painter->setBrush(Qt::NoBrush);
|
|
752 |
painter->setPen(scrollBar->palette.color(QPalette::Mid));
|
|
753 |
painter->drawRect(myRect.adjusted(0, 0, -1, 0));
|
|
754 |
painter->setPen(scrollBar->palette.color(QPalette::Button));
|
|
755 |
painter->drawLine(myRect.bottomLeft() + QPoint(1, 0),
|
|
756 |
myRect.topLeft() + QPoint(1, 1));
|
|
757 |
painter->drawLine(myRect.topLeft() + QPoint(1, 1),
|
|
758 |
myRect.topRight() + QPoint(-1, 1));
|
|
759 |
break;
|
|
760 |
}
|
|
761 |
case CE_ScrollBarSubLine: {
|
|
762 |
const QStyleOptionSlider *scrollBar =
|
|
763 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
764 |
int scrollBarExtent = pixelMetric(PM_ScrollBarExtent);
|
|
765 |
QRect scrollBarSubLine = option->rect;
|
|
766 |
|
|
767 |
QRect button1;
|
|
768 |
QRect button2;
|
|
769 |
|
|
770 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
771 |
button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
|
|
772 |
16, scrollBarExtent);
|
|
773 |
button2.setRect(scrollBarSubLine.right() - 15,
|
|
774 |
scrollBarSubLine.top(), 16, scrollBarExtent);
|
|
775 |
} else {
|
|
776 |
button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
|
|
777 |
scrollBarExtent, 16);
|
|
778 |
button2.setRect(scrollBarSubLine.left(),
|
|
779 |
scrollBarSubLine.bottom() - 15, scrollBarExtent, 16);
|
|
780 |
}
|
|
781 |
|
|
782 |
painter->fillRect(button2, Qt::blue);
|
|
783 |
|
|
784 |
drawScrollBarArrow(button1, painter, scrollBar);
|
|
785 |
drawScrollBarArrow(button2, painter, scrollBar);
|
|
786 |
break;
|
|
787 |
}
|
|
788 |
case CE_ScrollBarAddLine: {
|
|
789 |
const QStyleOptionSlider *scrollBar =
|
|
790 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
791 |
QRect button(option->rect.left(), option->rect.top(), 16, 16);
|
|
792 |
drawScrollBarArrow(button, painter, scrollBar, true);
|
|
793 |
break;
|
|
794 |
}
|
|
795 |
case CE_ScrollBarSlider: {
|
|
796 |
const QStyleOptionSlider *scrollBar =
|
|
797 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
798 |
|
|
799 |
painter->setPen(scrollBar->palette.color(QPalette::Midlight));
|
|
800 |
painter->drawRect(scrollBar->rect.adjusted(-1, 0, -3, -1));
|
|
801 |
|
|
802 |
QPoint g1, g2;
|
|
803 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
804 |
g1 = option->rect.topLeft();
|
|
805 |
g2 = option->rect.bottomLeft();
|
|
806 |
} else {
|
|
807 |
g1 = option->rect.topLeft();
|
|
808 |
g2 = option->rect.topRight();
|
|
809 |
}
|
|
810 |
|
|
811 |
if (scrollBar->state & State_Enabled) {
|
|
812 |
QLinearGradient gradient(g1, g2);
|
|
813 |
gradient.setColorAt(1.0, QColor(188, 210, 230));
|
|
814 |
gradient.setColorAt(0.3, Qt::white);
|
|
815 |
gradient.setColorAt(0.0, QColor(223, 233, 243));
|
|
816 |
painter->setBrush(gradient);
|
|
817 |
} else {
|
|
818 |
painter->setPen(scrollBar->palette.buttonText().color());
|
|
819 |
painter->setBrush(scrollBar->palette.button());
|
|
820 |
}
|
|
821 |
painter->drawRect(scrollBar->rect.adjusted(0, 0, -1, -1));
|
|
822 |
|
|
823 |
int sliderLength = option->rect.height();
|
|
824 |
int drawPos = scrollBar->orientation == Qt::Vertical ?
|
|
825 |
(sliderLength / 2) + 1 : 1 - ((option->rect.width() / 2));
|
|
826 |
|
|
827 |
QPoint origin;
|
|
828 |
if (scrollBar->orientation == Qt::Vertical)
|
|
829 |
origin = option->rect.bottomLeft();
|
|
830 |
else
|
|
831 |
origin = option->rect.topLeft();
|
|
832 |
|
|
833 |
painter->setPen(scrollBar->palette.color(QPalette::Base));
|
|
834 |
painter->drawLine(origin + adjustScrollHandlePoint(
|
|
835 |
scrollBar->orientation,
|
|
836 |
QPoint(4, -drawPos)),
|
|
837 |
origin + adjustScrollHandlePoint(
|
|
838 |
scrollBar->orientation,
|
|
839 |
QPoint(13, -drawPos)));
|
|
840 |
painter->drawLine(origin + adjustScrollHandlePoint(
|
|
841 |
scrollBar->orientation,
|
|
842 |
QPoint(4, 2 - drawPos)),
|
|
843 |
origin + adjustScrollHandlePoint(
|
|
844 |
scrollBar->orientation,
|
|
845 |
QPoint(13, 2 - drawPos)));
|
|
846 |
painter->drawLine(origin + adjustScrollHandlePoint(
|
|
847 |
scrollBar->orientation,
|
|
848 |
QPoint(4, 4 - drawPos)),
|
|
849 |
origin + adjustScrollHandlePoint(
|
|
850 |
scrollBar->orientation,
|
|
851 |
QPoint(13, 4 - drawPos)));
|
|
852 |
|
|
853 |
painter->setPen(option->palette.color(QPalette::Midlight));
|
|
854 |
painter->drawLine(origin + adjustScrollHandlePoint(
|
|
855 |
scrollBar->orientation,
|
|
856 |
QPoint(3, -(drawPos + 1))),
|
|
857 |
origin + adjustScrollHandlePoint(
|
|
858 |
scrollBar->orientation,
|
|
859 |
QPoint(12, -(drawPos + 1))));
|
|
860 |
painter->drawLine(origin + adjustScrollHandlePoint(
|
|
861 |
scrollBar->orientation,
|
|
862 |
QPoint(3, 1 - drawPos)),
|
|
863 |
origin + adjustScrollHandlePoint(
|
|
864 |
scrollBar->orientation,
|
|
865 |
QPoint(12, 1 - drawPos)));
|
|
866 |
painter->drawLine(origin + adjustScrollHandlePoint(
|
|
867 |
scrollBar->orientation,
|
|
868 |
QPoint(3, 3 - drawPos)),
|
|
869 |
origin + adjustScrollHandlePoint(
|
|
870 |
scrollBar->orientation,
|
|
871 |
QPoint(12, 3 - drawPos)));
|
|
872 |
|
|
873 |
break;
|
|
874 |
}
|
|
875 |
case CE_TabBarTabLabel: {
|
|
876 |
QStyleOptionTab copy =
|
|
877 |
*qstyleoption_cast<const QStyleOptionTab *>(option);
|
|
878 |
if (copy.state & State_HasFocus)
|
|
879 |
copy.state ^= State_HasFocus;
|
|
880 |
painter->setBrush(Qt::NoBrush);
|
|
881 |
QWindowsStyle::drawControl(CE_TabBarTabLabel, ©, painter,
|
|
882 |
widget);
|
|
883 |
break;
|
|
884 |
}
|
|
885 |
case CE_TabBarTabShape: {
|
|
886 |
const QStyleOptionTab *tab =
|
|
887 |
qstyleoption_cast<const QStyleOptionTab *>(option);
|
|
888 |
QRect myRect = option->rect;
|
|
889 |
QPoint bottomLeft, bottomRight, topLeft, topRight;
|
|
890 |
|
|
891 |
if ((tab->position == QStyleOptionTab::Beginning) ||
|
|
892 |
(tab->position == QStyleOptionTab::OnlyOneTab)) {
|
|
893 |
if (tab->shape == QTabBar::RoundedSouth ||
|
|
894 |
tab->shape == QTabBar::RoundedNorth) {
|
|
895 |
myRect = myRect.adjusted(2, 0, 0, 0);
|
|
896 |
} else {
|
|
897 |
myRect = myRect.adjusted(0, 2, 0, 0);
|
|
898 |
}
|
|
899 |
}
|
|
900 |
|
|
901 |
switch (tab->shape) {
|
|
902 |
case QTabBar::RoundedNorth:
|
|
903 |
topLeft = myRect.topLeft();
|
|
904 |
topRight = myRect.topRight();
|
|
905 |
bottomLeft = myRect.bottomLeft();
|
|
906 |
bottomRight = myRect.bottomRight();
|
|
907 |
break;
|
|
908 |
case QTabBar::RoundedSouth:
|
|
909 |
topLeft = myRect.bottomLeft();
|
|
910 |
topRight = myRect.bottomRight();
|
|
911 |
bottomLeft = myRect.topLeft();
|
|
912 |
bottomRight = myRect.topRight();
|
|
913 |
break;
|
|
914 |
case QTabBar::RoundedWest:
|
|
915 |
topLeft = myRect.topLeft();
|
|
916 |
topRight = myRect.bottomLeft();
|
|
917 |
bottomLeft = myRect.topRight();
|
|
918 |
bottomRight = myRect.bottomRight();
|
|
919 |
break;
|
|
920 |
case QTabBar::RoundedEast:
|
|
921 |
topLeft = myRect.topRight();
|
|
922 |
topRight = myRect.bottomRight();
|
|
923 |
bottomLeft = myRect.topLeft();
|
|
924 |
bottomRight = myRect.bottomLeft();
|
|
925 |
break;
|
|
926 |
default:
|
|
927 |
;
|
|
928 |
}
|
|
929 |
|
|
930 |
QPainterPath outerPath;
|
|
931 |
outerPath.moveTo(bottomLeft + adjustTabPoint(QPoint(0, -2),
|
|
932 |
tab->shape));
|
|
933 |
outerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(0, -14),
|
|
934 |
tab->shape));
|
|
935 |
outerPath.lineTo(topLeft + adjustTabPoint(QPoint(6 , 0),
|
|
936 |
tab->shape));
|
|
937 |
outerPath.lineTo(topRight + adjustTabPoint(QPoint(0, 0),
|
|
938 |
tab->shape));
|
|
939 |
outerPath.lineTo(bottomRight + adjustTabPoint(QPoint(0, -2),
|
|
940 |
tab->shape));
|
|
941 |
|
|
942 |
if (tab->state & State_Selected ||
|
|
943 |
tab->position == QStyleOptionTab::OnlyOneTab) {
|
|
944 |
QPainterPath innerPath;
|
|
945 |
innerPath.moveTo(topLeft + adjustTabPoint(QPoint(6, 2),
|
|
946 |
tab->shape));
|
|
947 |
innerPath.lineTo(topRight + adjustTabPoint(QPoint(-1, 2),
|
|
948 |
tab->shape));
|
|
949 |
innerPath.lineTo(bottomRight + adjustTabPoint(QPoint(-1 , -2),
|
|
950 |
tab->shape));
|
|
951 |
innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -2),
|
|
952 |
tab->shape));
|
|
953 |
innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -14),
|
|
954 |
tab->shape));
|
|
955 |
innerPath.lineTo(topLeft + adjustTabPoint(QPoint(6, 2),
|
|
956 |
tab->shape));
|
|
957 |
|
|
958 |
QPainterPath whitePath;
|
|
959 |
whitePath.moveTo(bottomLeft + adjustTabPoint(QPoint(1, -2),
|
|
960 |
tab->shape));
|
|
961 |
whitePath.lineTo(bottomLeft + adjustTabPoint(QPoint(1, -14),
|
|
962 |
tab->shape));
|
|
963 |
whitePath.lineTo(topLeft + adjustTabPoint(QPoint(6, 1),
|
|
964 |
tab->shape));
|
|
965 |
whitePath.lineTo(topRight + adjustTabPoint(QPoint(-1, 1),
|
|
966 |
tab->shape));
|
|
967 |
|
|
968 |
painter->setPen(tab->palette.color(QPalette::Midlight));
|
|
969 |
painter->setBrush(QColor(200, 221, 242));
|
|
970 |
painter->drawPath(outerPath);
|
|
971 |
painter->setPen(QColor(200, 221, 242));
|
|
972 |
painter->drawRect(QRect(bottomLeft + adjustTabPoint(
|
|
973 |
QPoint(2, -3), tab->shape),
|
|
974 |
bottomRight + adjustTabPoint(
|
|
975 |
QPoint(-2, 0), tab->shape)));
|
|
976 |
painter->setPen(tab->palette.color(QPalette::Base));
|
|
977 |
painter->setBrush(Qt::NoBrush);
|
|
978 |
painter->drawPath(whitePath);
|
|
979 |
|
|
980 |
if (option->state & State_HasFocus) {
|
|
981 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
982 |
painter->drawPath(innerPath);
|
|
983 |
}
|
|
984 |
} else {
|
|
985 |
painter->setPen(tab->palette.color(QPalette::Mid));
|
|
986 |
painter->drawPath(outerPath);
|
|
987 |
}
|
|
988 |
break;
|
|
989 |
}
|
|
990 |
case CE_PushButtonLabel:
|
|
991 |
painter->save();
|
|
992 |
|
|
993 |
if (const QStyleOptionButton *button =
|
|
994 |
qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|
995 |
QRect ir = button->rect;
|
|
996 |
uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
|
|
997 |
if (!styleHint(SH_UnderlineShortcut, button, widget))
|
|
998 |
tf |= Qt::TextHideMnemonic;
|
|
999 |
|
|
1000 |
if (!button->icon.isNull()) {
|
|
1001 |
QPoint point;
|
|
1002 |
|
|
1003 |
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
|
|
1004 |
: QIcon::Disabled;
|
|
1005 |
if (mode == QIcon::Normal && button->state & State_HasFocus)
|
|
1006 |
mode = QIcon::Active;
|
|
1007 |
QIcon::State state = QIcon::Off;
|
|
1008 |
if (button->state & State_On)
|
|
1009 |
state = QIcon::On;
|
|
1010 |
|
|
1011 |
QPixmap pixmap = button->icon.pixmap(button->iconSize, mode,
|
|
1012 |
state);
|
|
1013 |
int w = pixmap.width();
|
|
1014 |
int h = pixmap.height();
|
|
1015 |
|
|
1016 |
if (!button->text.isEmpty())
|
|
1017 |
w += button->fontMetrics.width(button->text) + 2;
|
|
1018 |
|
|
1019 |
point = QPoint(ir.x() + ir.width() / 2 - w / 2,
|
|
1020 |
ir.y() + ir.height() / 2 - h / 2);
|
|
1021 |
|
|
1022 |
if (button->direction == Qt::RightToLeft)
|
|
1023 |
point.rx() += pixmap.width();
|
|
1024 |
|
|
1025 |
painter->drawPixmap(visualPos(button->direction, button->rect,
|
|
1026 |
point), pixmap);
|
|
1027 |
|
|
1028 |
if (button->direction == Qt::RightToLeft)
|
|
1029 |
ir.translate(-point.x() - 2, 0);
|
|
1030 |
else
|
|
1031 |
ir.translate(point.x() + pixmap.width(), 0);
|
|
1032 |
|
|
1033 |
if (!button->text.isEmpty())
|
|
1034 |
tf |= Qt::AlignLeft;
|
|
1035 |
|
|
1036 |
} else {
|
|
1037 |
tf |= Qt::AlignHCenter;
|
|
1038 |
}
|
|
1039 |
|
|
1040 |
if (button->fontMetrics.height() > 14)
|
|
1041 |
ir.translate(0, 1);
|
|
1042 |
|
|
1043 |
drawItemText(painter, ir, tf, button->palette, (button->state &
|
|
1044 |
State_Enabled),
|
|
1045 |
button->text, QPalette::ButtonText);
|
|
1046 |
}
|
|
1047 |
|
|
1048 |
painter->restore();
|
|
1049 |
break;
|
|
1050 |
|
|
1051 |
default:
|
|
1052 |
QWindowsStyle::drawControl(control, option, painter, widget);
|
|
1053 |
}
|
|
1054 |
painter->restore();
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
inline QPoint JavaStyle::adjustTabPoint(const QPoint &point,
|
|
1058 |
QTabBar::Shape shape) const
|
|
1059 |
{
|
|
1060 |
QPoint rPoint;
|
|
1061 |
|
|
1062 |
switch (shape) {
|
|
1063 |
case QTabBar::RoundedWest:
|
|
1064 |
rPoint = QPoint(point.y(), point.x());
|
|
1065 |
break;
|
|
1066 |
case QTabBar::RoundedSouth:
|
|
1067 |
rPoint = QPoint(point.x(), point.y() * -1);
|
|
1068 |
break;
|
|
1069 |
case QTabBar::RoundedEast:
|
|
1070 |
rPoint = QPoint(point.y() * -1, point.x());
|
|
1071 |
break;
|
|
1072 |
default:
|
|
1073 |
rPoint = point;
|
|
1074 |
}
|
|
1075 |
return rPoint;
|
|
1076 |
}
|
|
1077 |
|
|
1078 |
QRect JavaStyle::subControlRect(ComplexControl control,
|
|
1079 |
const QStyleOptionComplex *option,
|
|
1080 |
SubControl subControl,
|
|
1081 |
const QWidget *widget) const
|
|
1082 |
{
|
|
1083 |
QRect rect = QWindowsStyle::subControlRect(control, option, subControl,
|
|
1084 |
widget);
|
|
1085 |
|
|
1086 |
switch (control) {
|
|
1087 |
case CC_TitleBar: {
|
|
1088 |
const QStyleOptionTitleBar *bar =
|
|
1089 |
qstyleoption_cast<const QStyleOptionTitleBar *>(option);
|
|
1090 |
|
|
1091 |
switch (subControl) {
|
|
1092 |
case SC_TitleBarMinButton: {
|
|
1093 |
rect = QRect(bar->rect.topRight() + QPoint(-68, 2),
|
|
1094 |
QSize(15, 15));
|
|
1095 |
break;
|
|
1096 |
}
|
|
1097 |
case SC_TitleBarMaxButton: {
|
|
1098 |
rect = QRect(bar->rect.topRight() + QPoint(-43, 3),
|
|
1099 |
QSize(15, 15));
|
|
1100 |
break;
|
|
1101 |
}
|
|
1102 |
case SC_TitleBarCloseButton: {
|
|
1103 |
rect = QRect(bar->rect.topRight() + QPoint(-18, 3),
|
|
1104 |
QSize(15, 15));
|
|
1105 |
break;
|
|
1106 |
}
|
|
1107 |
case SC_TitleBarLabel: {
|
|
1108 |
QRect labelRect = bar->fontMetrics.boundingRect(bar->text);
|
|
1109 |
rect = labelRect;
|
|
1110 |
rect.translate(bar->rect.left() + 30, 0);
|
|
1111 |
rect.moveTop(bar->rect.top());
|
|
1112 |
rect.adjust(0, 2, 2, 2);
|
|
1113 |
break;
|
|
1114 |
}
|
|
1115 |
case SC_TitleBarSysMenu: {
|
|
1116 |
rect = QRect(bar->rect.topLeft() + QPoint(6, 3),
|
|
1117 |
QSize(16, 16));
|
|
1118 |
break;
|
|
1119 |
}
|
|
1120 |
default:
|
|
1121 |
;
|
|
1122 |
}
|
|
1123 |
break;
|
|
1124 |
}
|
|
1125 |
case CC_GroupBox: {
|
|
1126 |
const QStyleOptionGroupBox *box =
|
|
1127 |
qstyleoption_cast<const QStyleOptionGroupBox *>(option);
|
|
1128 |
bool hasCheckbox = box->subControls & SC_GroupBoxCheckBox;
|
|
1129 |
int checkAdjust = 13;
|
|
1130 |
|
|
1131 |
QRect textRect = box->fontMetrics.boundingRect(box->text);
|
|
1132 |
|
|
1133 |
switch (subControl) {
|
|
1134 |
case SC_GroupBoxFrame: {
|
|
1135 |
rect = box->rect;
|
|
1136 |
break;
|
|
1137 |
}
|
|
1138 |
case SC_GroupBoxCheckBox: {
|
|
1139 |
if (hasCheckbox) {
|
|
1140 |
rect = QRect(box->rect.topLeft() + QPoint(7, 4 +
|
|
1141 |
(textRect.height() / 2 - checkAdjust / 2)),
|
|
1142 |
QSize(checkAdjust, checkAdjust));
|
|
1143 |
}
|
|
1144 |
else {
|
|
1145 |
rect = QRect();
|
|
1146 |
}
|
|
1147 |
break;
|
|
1148 |
}
|
|
1149 |
case SC_GroupBoxLabel: {
|
|
1150 |
rect = QRect(box->rect.topLeft() + QPoint(7 + (hasCheckbox ?
|
|
1151 |
checkAdjust + 2 : 0), 4), textRect.size());
|
|
1152 |
break;
|
|
1153 |
}
|
|
1154 |
case SC_GroupBoxContents: {
|
|
1155 |
rect = box->rect.adjusted(10, 10 + textRect.height(), -10,
|
|
1156 |
-10);
|
|
1157 |
break;
|
|
1158 |
}
|
|
1159 |
default:
|
|
1160 |
;
|
|
1161 |
}
|
|
1162 |
break;
|
|
1163 |
}
|
|
1164 |
case CC_SpinBox: {
|
|
1165 |
const QStyleOptionSpinBox *spinBox =
|
|
1166 |
qstyleoption_cast<const QStyleOptionSpinBox *>(option);
|
|
1167 |
int spinnerWidth = 16;
|
|
1168 |
QRect myRect = spinBox->rect;
|
|
1169 |
QPoint center = myRect.center();
|
|
1170 |
int frameWidth = pixelMetric(PM_SpinBoxFrameWidth, spinBox, widget);
|
|
1171 |
|
|
1172 |
switch (subControl) {
|
|
1173 |
case SC_SpinBoxUp: {
|
|
1174 |
rect = QRect(myRect.topRight() + QPoint(-16, 0),
|
|
1175 |
QSize(16, center.y() - myRect.topRight().y()));
|
|
1176 |
break;
|
|
1177 |
}
|
|
1178 |
case SC_SpinBoxDown: {
|
|
1179 |
rect = QRect(QPoint(myRect.bottomRight().x() - 16,
|
|
1180 |
center.y() + 1),
|
|
1181 |
QSize(16, myRect.bottomRight().y() -
|
|
1182 |
center.y() - 1));
|
|
1183 |
break;
|
|
1184 |
}
|
|
1185 |
case SC_SpinBoxFrame: {
|
|
1186 |
rect = QRect(myRect.topLeft(), myRect.bottomRight() +
|
|
1187 |
QPoint(-16, 0));
|
|
1188 |
break;
|
|
1189 |
}
|
|
1190 |
case SC_SpinBoxEditField: {
|
|
1191 |
rect = QRect(myRect.topLeft() + QPoint(2, 2),
|
|
1192 |
myRect.bottomRight() + QPoint(-15 - frameWidth, -2));
|
|
1193 |
break;
|
|
1194 |
}
|
|
1195 |
default:
|
|
1196 |
;
|
|
1197 |
}
|
|
1198 |
break;
|
|
1199 |
}
|
|
1200 |
case CC_ToolButton: {
|
|
1201 |
const QStyleOptionToolButton *button =
|
|
1202 |
qstyleoption_cast<const QStyleOptionToolButton *>(option);
|
|
1203 |
|
|
1204 |
switch (subControl) {
|
|
1205 |
case SC_ToolButton: {
|
|
1206 |
rect = option->rect.adjusted(1, 1, -1, -1);
|
|
1207 |
break;
|
|
1208 |
}
|
|
1209 |
case SC_ToolButtonMenu: {
|
|
1210 |
rect = QRect(option->rect.bottomRight() +
|
|
1211 |
QPoint(-11, -11), QSize(10, 10));
|
|
1212 |
break;
|
|
1213 |
}
|
|
1214 |
}
|
|
1215 |
break;
|
|
1216 |
}
|
|
1217 |
case CC_ComboBox: {
|
|
1218 |
const QStyleOptionComboBox *combo =
|
|
1219 |
qstyleoption_cast<const QStyleOptionComboBox *>(option);
|
|
1220 |
|
|
1221 |
bool reverse = combo->direction == Qt::RightToLeft;
|
|
1222 |
|
|
1223 |
switch (subControl) {
|
|
1224 |
case SC_ComboBoxFrame:
|
|
1225 |
rect = combo->rect;
|
|
1226 |
break;
|
|
1227 |
case SC_ComboBoxArrow:
|
|
1228 |
if (reverse) {
|
|
1229 |
rect = QRect(combo->rect.topLeft(),
|
|
1230 |
combo->rect.bottomLeft() + QPoint(17, 0));
|
|
1231 |
} else {
|
|
1232 |
rect = QRect(combo->rect.topRight() + QPoint(-17, 0),
|
|
1233 |
combo->rect.bottomRight());
|
|
1234 |
}
|
|
1235 |
break;
|
|
1236 |
case SC_ComboBoxEditField:
|
|
1237 |
if (reverse) {
|
|
1238 |
rect = QRect(combo->rect.topLeft() + QPoint(19, 2),
|
|
1239 |
combo->rect.bottomRight() + QPoint(-2, 2));
|
|
1240 |
} else {
|
|
1241 |
rect = QRect(combo->rect.topLeft() + QPoint(2, 2),
|
|
1242 |
combo->rect.bottomRight() + QPoint(-19, -2));
|
|
1243 |
}
|
|
1244 |
break;
|
|
1245 |
case SC_ComboBoxListBoxPopup:
|
|
1246 |
rect = combo->rect;
|
|
1247 |
break;
|
|
1248 |
}
|
|
1249 |
break;
|
|
1250 |
}
|
|
1251 |
case CC_ScrollBar: {
|
|
1252 |
const QStyleOptionSlider *scrollBar =
|
|
1253 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
1254 |
int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, scrollBar,
|
|
1255 |
widget);
|
|
1256 |
int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ?
|
|
1257 |
scrollBar->rect.width() :
|
|
1258 |
scrollBar->rect.height()) - (16 * 3);
|
|
1259 |
int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar,
|
|
1260 |
widget);
|
|
1261 |
int sliderLength;
|
|
1262 |
|
|
1263 |
if (scrollBar->maximum != scrollBar->minimum) {
|
|
1264 |
uint valueRange = scrollBar->maximum - scrollBar->minimum;
|
|
1265 |
sliderLength = (scrollBar->pageStep * sliderMaxLength) /
|
|
1266 |
(valueRange + scrollBar->pageStep);
|
|
1267 |
|
|
1268 |
if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2)
|
|
1269 |
sliderLength = sliderMinLength;
|
|
1270 |
if (sliderLength > sliderMaxLength)
|
|
1271 |
sliderLength = sliderMaxLength;
|
|
1272 |
} else {
|
|
1273 |
sliderLength = sliderMaxLength;
|
|
1274 |
}
|
|
1275 |
int sliderStart = 16 + sliderPositionFromValue(scrollBar->minimum,
|
|
1276 |
scrollBar->maximum,
|
|
1277 |
scrollBar->sliderPosition,
|
|
1278 |
sliderMaxLength - sliderLength,
|
|
1279 |
scrollBar->upsideDown);
|
|
1280 |
QRect scrollBarRect = scrollBar->rect;
|
|
1281 |
|
|
1282 |
switch (subControl) {
|
|
1283 |
case SC_ScrollBarSubLine:
|
|
1284 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
1285 |
rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
|
|
1286 |
scrollBarRect.width() - 16, scrollBarExtent);
|
|
1287 |
} else {
|
|
1288 |
rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
|
|
1289 |
scrollBarExtent, scrollBarRect.height() - 16);
|
|
1290 |
}
|
|
1291 |
break;
|
|
1292 |
case SC_ScrollBarAddLine:
|
|
1293 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
1294 |
rect.setRect(scrollBarRect.right() - 15,
|
|
1295 |
scrollBarRect.top(), 16, scrollBarExtent);
|
|
1296 |
} else {
|
|
1297 |
rect.setRect(scrollBarRect.left(), scrollBarRect.bottom()
|
|
1298 |
- 15, scrollBarExtent, 16);
|
|
1299 |
}
|
|
1300 |
break;
|
|
1301 |
case SC_ScrollBarSubPage:
|
|
1302 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
1303 |
rect.setRect(scrollBarRect.left() + 16, scrollBarRect.top(),
|
|
1304 |
sliderStart - (scrollBarRect.left() + 16),
|
|
1305 |
scrollBarExtent);
|
|
1306 |
} else {
|
|
1307 |
rect.setRect(scrollBarRect.left(), scrollBarRect.top() + 16,
|
|
1308 |
scrollBarExtent,
|
|
1309 |
sliderStart - (scrollBarRect.left() + 16));
|
|
1310 |
}
|
|
1311 |
break;
|
|
1312 |
case SC_ScrollBarAddPage:
|
|
1313 |
if (scrollBar->orientation == Qt::Horizontal)
|
|
1314 |
rect.setRect(sliderStart + sliderLength, 0,
|
|
1315 |
sliderMaxLength - sliderStart -
|
|
1316 |
sliderLength + 16, scrollBarExtent);
|
|
1317 |
else
|
|
1318 |
rect.setRect(0, sliderStart + sliderLength,
|
|
1319 |
scrollBarExtent, sliderMaxLength -
|
|
1320 |
sliderStart - sliderLength + 16);
|
|
1321 |
break;
|
|
1322 |
case SC_ScrollBarGroove:
|
|
1323 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
1324 |
rect = scrollBarRect.adjusted(16, 0, -32, 0);
|
|
1325 |
} else {
|
|
1326 |
rect = scrollBarRect.adjusted(0, 16, 0, -32);
|
|
1327 |
}
|
|
1328 |
break;
|
|
1329 |
case SC_ScrollBarSlider:
|
|
1330 |
if (scrollBar->orientation == Qt::Horizontal) {
|
|
1331 |
rect.setRect(sliderStart, 0, sliderLength,
|
|
1332 |
scrollBarExtent);
|
|
1333 |
} else {
|
|
1334 |
rect.setRect(0, sliderStart, scrollBarExtent,
|
|
1335 |
sliderLength);
|
|
1336 |
}
|
|
1337 |
break;
|
|
1338 |
default:
|
|
1339 |
return QWindowsStyle::subControlRect(control, option,
|
|
1340 |
subControl, widget);
|
|
1341 |
}
|
|
1342 |
break;
|
|
1343 |
}
|
|
1344 |
case CC_Slider: {
|
|
1345 |
const QStyleOptionSlider *slider =
|
|
1346 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
1347 |
rect = slider->rect;
|
|
1348 |
int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
|
|
1349 |
int handleSize = pixelMetric(PM_SliderControlThickness, option,
|
|
1350 |
widget);
|
|
1351 |
|
|
1352 |
int dist = slider->orientation == Qt::Vertical ? slider->rect.height() :
|
|
1353 |
slider->rect.width();
|
|
1354 |
int pos = QStyle::sliderPositionFromValue(slider->minimum,
|
|
1355 |
slider->maximum, slider->sliderValue, dist - handleSize);
|
|
1356 |
|
|
1357 |
switch (subControl) {
|
|
1358 |
case SC_SliderGroove: {
|
|
1359 |
QPoint center = rect.center();
|
|
1360 |
|
|
1361 |
if (slider->orientation == Qt::Horizontal) {
|
|
1362 |
rect.setHeight(handleSize);
|
|
1363 |
if (slider->tickPosition == QSlider::TicksBelow) {
|
|
1364 |
center.ry() -= tickSize;
|
|
1365 |
}
|
|
1366 |
} else {
|
|
1367 |
rect.adjust(0, 0, 0, 0);
|
|
1368 |
rect.setWidth(handleSize);
|
|
1369 |
if (slider->tickPosition == QSlider::TicksBelow) {
|
|
1370 |
center.rx() -= tickSize;
|
|
1371 |
}
|
|
1372 |
}
|
|
1373 |
rect.moveCenter(center);
|
|
1374 |
break;
|
|
1375 |
}
|
|
1376 |
case SC_SliderHandle: {
|
|
1377 |
QPoint center = rect.center();
|
|
1378 |
|
|
1379 |
if (slider->orientation == Qt::Horizontal) {
|
|
1380 |
rect.setHeight(handleSize);
|
|
1381 |
if (slider->tickPosition == QSlider::TicksBelow) {
|
|
1382 |
center.ry() -= tickSize;
|
|
1383 |
}
|
|
1384 |
|
|
1385 |
rect.moveCenter(center);
|
|
1386 |
|
|
1387 |
if (slider->upsideDown)
|
|
1388 |
rect.setLeft(slider->rect.right() -
|
|
1389 |
pos - (handleSize - 1));
|
|
1390 |
else
|
|
1391 |
rect.setLeft(pos);
|
|
1392 |
|
|
1393 |
rect.setWidth(handleSize - 1);
|
|
1394 |
} else {
|
|
1395 |
rect.setWidth(handleSize);
|
|
1396 |
if (slider->tickPosition == QSlider::TicksBelow) {
|
|
1397 |
center.rx() -= tickSize;
|
|
1398 |
}
|
|
1399 |
|
|
1400 |
rect.moveCenter(center);
|
|
1401 |
|
|
1402 |
if (slider->upsideDown)
|
|
1403 |
rect.setTop(slider->rect.bottom() -
|
|
1404 |
((pos + handleSize) - 2));
|
|
1405 |
else
|
|
1406 |
rect.setTop(slider->rect.top() + pos);
|
|
1407 |
|
|
1408 |
rect.setHeight(handleSize);
|
|
1409 |
}
|
|
1410 |
break;
|
|
1411 |
}
|
|
1412 |
case SC_SliderTickmarks: {
|
|
1413 |
QPoint center = slider->rect.center();
|
|
1414 |
|
|
1415 |
if (slider->tickPosition & QSlider::TicksBelow) {
|
|
1416 |
if (slider->orientation == Qt::Horizontal) {
|
|
1417 |
rect.setHeight(tickSize);
|
|
1418 |
center.ry() += tickSize / 2;
|
|
1419 |
rect.adjust(6, 0, -10, 0);
|
|
1420 |
} else {
|
|
1421 |
rect.setWidth(tickSize);
|
|
1422 |
center.rx() += tickSize / 2;
|
|
1423 |
rect.adjust(0, 6, 0, -10);
|
|
1424 |
}
|
|
1425 |
} else {
|
|
1426 |
rect = QRect();
|
|
1427 |
}
|
|
1428 |
rect.moveCenter(center);
|
|
1429 |
break;
|
|
1430 |
}
|
|
1431 |
default:
|
|
1432 |
;
|
|
1433 |
}
|
|
1434 |
break;
|
|
1435 |
}
|
|
1436 |
default:
|
|
1437 |
return QWindowsStyle::subControlRect(control, option, subControl,
|
|
1438 |
widget);
|
|
1439 |
}
|
|
1440 |
return rect;
|
|
1441 |
}
|
|
1442 |
|
|
1443 |
static const char * const sliderHandleImage[] = {
|
|
1444 |
"15 16 7 1",
|
|
1445 |
" c None",
|
|
1446 |
"+ c #FFFFFF",
|
|
1447 |
"@ c #FFFFFF",
|
|
1448 |
"$ c #FFFFFF",
|
|
1449 |
"( c #E5EDF5",
|
|
1450 |
") c #F2F6FA",
|
|
1451 |
"[ c #FFFFFF",
|
|
1452 |
" +++++++++++++ ",
|
|
1453 |
"+@@@@@@@@@@@@@+",
|
|
1454 |
"+@(((((((((((@+",
|
|
1455 |
"+@(((((((((((@+",
|
|
1456 |
"+@)))))))))))@+",
|
|
1457 |
"+@[[[[[[[[[[[@+",
|
|
1458 |
"+@[[[[[[[[[[[@+",
|
|
1459 |
"+@)))))))))))@+",
|
|
1460 |
"+@)))))))))))@+",
|
|
1461 |
" +@)))))))))@+ ",
|
|
1462 |
" +@(((((((@+ ",
|
|
1463 |
" +@(((((@+ ",
|
|
1464 |
" +@(((@+ ",
|
|
1465 |
" +@(@+ ",
|
|
1466 |
" +@+ ",
|
|
1467 |
" + "};
|
|
1468 |
|
|
1469 |
|
|
1470 |
void JavaStyle::drawComplexControl(ComplexControl control,
|
|
1471 |
const QStyleOptionComplex *option,
|
|
1472 |
QPainter *painter,
|
|
1473 |
const QWidget *widget) const
|
|
1474 |
{
|
|
1475 |
painter->save();
|
|
1476 |
|
|
1477 |
switch (control) {
|
|
1478 |
case CC_TitleBar: {
|
|
1479 |
const QStyleOptionTitleBar *bar =
|
|
1480 |
qstyleoption_cast<const QStyleOptionTitleBar *>(option);
|
|
1481 |
|
|
1482 |
bool sunken = bar->state & State_Sunken;
|
|
1483 |
|
|
1484 |
QLinearGradient gradient(bar->rect.bottomLeft(),
|
|
1485 |
bar->rect.topLeft());
|
|
1486 |
gradient.setColorAt(0.0, QColor(191, 212, 231));
|
|
1487 |
gradient.setColorAt(0.7, Qt::white);
|
|
1488 |
gradient.setColorAt(1.0, QColor(221, 232, 243));
|
|
1489 |
|
|
1490 |
painter->setPen(Qt::NoPen);
|
|
1491 |
if (bar->titleBarState & State_Active) {
|
|
1492 |
painter->setBrush(gradient);
|
|
1493 |
}
|
|
1494 |
else
|
|
1495 |
painter->setBrush(bar->palette.color(QPalette::Active,
|
|
1496 |
QPalette::Background));
|
|
1497 |
|
|
1498 |
painter->drawRect(bar->rect.adjusted(0, 0, -1, -1));
|
|
1499 |
|
|
1500 |
painter->setBrush(QColor(233, 233, 233));
|
|
1501 |
painter->drawRect(QRect(bar->rect.bottomLeft() + QPoint(0, 1),
|
|
1502 |
bar->rect.bottomRight() + QPoint(0, 2)));
|
|
1503 |
|
|
1504 |
QRect minButtonRect = subControlRect(control, bar,
|
|
1505 |
SC_TitleBarMinButton);
|
|
1506 |
QRect maxButtonRect = subControlRect(control, bar,
|
|
1507 |
SC_TitleBarMaxButton);
|
|
1508 |
QRect closeButtonRect = subControlRect(control, bar,
|
|
1509 |
SC_TitleBarCloseButton);
|
|
1510 |
QRect systemButtonRect = subControlRect(control, bar,
|
|
1511 |
SC_TitleBarSysMenu);
|
|
1512 |
QRect labelRect = subControlRect(control, bar, SC_TitleBarLabel);
|
|
1513 |
QRect gripRect = QRect(QPoint(labelRect.right() + 5, bar->rect.top() + 5),
|
|
1514 |
QPoint(minButtonRect.left() - 5,
|
|
1515 |
bar->rect.bottom() - 4));
|
|
1516 |
|
|
1517 |
QColor textColor = option->palette.color(QPalette::Text);
|
|
1518 |
painter->setPen(textColor);
|
|
1519 |
painter->setBrush(Qt::NoBrush);
|
|
1520 |
|
|
1521 |
drawItemText(painter, labelRect, Qt::TextShowMnemonic |
|
|
1522 |
Qt::AlignHCenter | Qt::AlignCenter,
|
|
1523 |
bar->palette, bar->state & State_Enabled, bar->text,
|
|
1524 |
textColor.isValid() ? QPalette::NoRole :
|
|
1525 |
QPalette::WindowText);
|
|
1526 |
|
|
1527 |
for (int i = 0; i < gripRect.width(); ++i) {
|
|
1528 |
painter->setPen(i % 2 ? bar->palette.color(QPalette::Midlight)
|
|
1529 |
: Qt::white);
|
|
1530 |
|
|
1531 |
for (int j = 0; j < 4; ++j) {
|
|
1532 |
painter->drawPoint(i + gripRect.left(),
|
|
1533 |
gripRect.top() - 2 + i % 4 + 4 * j);
|
|
1534 |
}
|
|
1535 |
}
|
|
1536 |
|
|
1537 |
QPixmap maximizePixmap(":/images/internalmaximize.png");
|
|
1538 |
QPixmap minimizePixmap(":/images/internalminimize.png");
|
|
1539 |
QPixmap closePixmap(":/images/internalclose.png");
|
|
1540 |
QPixmap internalPixmap(":/images/internalsystem.png");
|
|
1541 |
QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
|
|
1542 |
QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
|
|
1543 |
QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
|
|
1544 |
|
|
1545 |
if (bar->activeSubControls & SC_TitleBarCloseButton &&
|
|
1546 |
bar->state & State_Sunken)
|
|
1547 |
painter->drawPixmap(closeButtonRect.topLeft(),
|
|
1548 |
internalCloseDownPixmap);
|
|
1549 |
else
|
|
1550 |
painter->drawPixmap(closeButtonRect.topLeft(), closePixmap);
|
|
1551 |
|
|
1552 |
if (bar->activeSubControls & SC_TitleBarMinButton &&
|
|
1553 |
bar->state & State_Sunken)
|
|
1554 |
painter->drawPixmap(minButtonRect.topLeft(),
|
|
1555 |
minimizeDownPixmap);
|
|
1556 |
else
|
|
1557 |
painter->drawPixmap(minButtonRect.topLeft(), minimizePixmap);
|
|
1558 |
|
|
1559 |
if (bar->activeSubControls & SC_TitleBarMaxButton &&
|
|
1560 |
bar->state & State_Sunken)
|
|
1561 |
painter->drawPixmap(maxButtonRect.topLeft(),
|
|
1562 |
maximizeDownPixmap);
|
|
1563 |
else
|
|
1564 |
painter->drawPixmap(maxButtonRect.topLeft(), maximizePixmap);
|
|
1565 |
|
|
1566 |
painter->drawPixmap(systemButtonRect.topLeft(), internalPixmap);
|
|
1567 |
|
|
1568 |
break;
|
|
1569 |
}
|
|
1570 |
case CC_GroupBox: {
|
|
1571 |
const QStyleOptionGroupBox *box =
|
|
1572 |
qstyleoption_cast<const QStyleOptionGroupBox *>(option);
|
|
1573 |
|
|
1574 |
QRect frameRect = subControlRect(control, box, SC_GroupBoxFrame);
|
|
1575 |
QRect labelRect = subControlRect(control, box, SC_GroupBoxLabel);
|
|
1576 |
QRect contentsRect = subControlRect(control, box,
|
|
1577 |
SC_GroupBoxContents);
|
|
1578 |
QRect checkerRect = subControlRect(control, box,
|
|
1579 |
SC_GroupBoxCheckBox);
|
|
1580 |
|
|
1581 |
int y = labelRect.center().y();
|
|
1582 |
|
|
1583 |
painter->setPen(box->palette.color(QPalette::Button));
|
|
1584 |
painter->drawRect(frameRect.adjusted(2, y - frameRect.top(), -2,
|
|
1585 |
-2));
|
|
1586 |
|
|
1587 |
painter->setPen(box->palette.color(QPalette::Background));
|
|
1588 |
|
|
1589 |
if (box->subControls & SC_GroupBoxCheckBox) {
|
|
1590 |
painter->drawLine(checkerRect.left() - 1, y,
|
|
1591 |
checkerRect.right() + 2, y);
|
|
1592 |
QStyleOptionButton checker;
|
|
1593 |
checker.QStyleOption::operator=(*box);
|
|
1594 |
checker.rect = checkerRect;
|
|
1595 |
drawPrimitive(PE_IndicatorCheckBox, &checker, painter, widget);
|
|
1596 |
}
|
|
1597 |
|
|
1598 |
if (box->subControls & SC_GroupBoxLabel && !box->text.isEmpty()) {
|
|
1599 |
painter->drawLine(labelRect.left() - 1, y,
|
|
1600 |
labelRect.right() +1, y);
|
|
1601 |
|
|
1602 |
QColor textColor = box->textColor;
|
|
1603 |
if (textColor.isValid())
|
|
1604 |
painter->setPen(textColor);
|
|
1605 |
|
|
1606 |
drawItemText(painter, labelRect, Qt::TextShowMnemonic |
|
|
1607 |
Qt::AlignHCenter | int(box->textAlignment),
|
|
1608 |
box->palette, box->state & State_Enabled,
|
|
1609 |
box->text, textColor.isValid() ? QPalette::NoRole :
|
|
1610 |
QPalette::WindowText);
|
|
1611 |
}
|
|
1612 |
break;
|
|
1613 |
}
|
|
1614 |
case CC_SpinBox: {
|
|
1615 |
const QStyleOptionSpinBox *spinner =
|
|
1616 |
qstyleoption_cast<const QStyleOptionSpinBox *>(option);
|
|
1617 |
|
|
1618 |
QRect frameRect = subControlRect(control, spinner, SC_SpinBoxFrame);
|
|
1619 |
QRect upRect = subControlRect(control, spinner, SC_SpinBoxUp);
|
|
1620 |
QRect downRect = subControlRect(control, spinner, SC_SpinBoxDown);
|
|
1621 |
|
|
1622 |
painter->setPen(Qt::white);
|
|
1623 |
painter->drawRect(frameRect.adjusted(1, 1, -1, -1));
|
|
1624 |
painter->drawPoint(frameRect.bottomLeft());
|
|
1625 |
|
|
1626 |
painter->setPen(spinner->palette.color(QPalette::Mid));
|
|
1627 |
painter->drawRect(frameRect.adjusted(0, 0, -1, -2));
|
|
1628 |
|
|
1629 |
bool isEnabled = (spinner->state & State_Enabled);
|
|
1630 |
bool hover = isEnabled && (spinner->state & State_MouseOver);
|
|
1631 |
bool sunken = (spinner->state & State_Sunken);
|
|
1632 |
bool upIsActive = (spinner->activeSubControls == SC_SpinBoxUp);
|
|
1633 |
bool downIsActive = (spinner->activeSubControls == SC_SpinBoxDown);
|
|
1634 |
bool stepUpEnabled = spinner->stepEnabled &
|
|
1635 |
QAbstractSpinBox::StepUpEnabled;
|
|
1636 |
bool stepDownEnabled = spinner->stepEnabled &
|
|
1637 |
QAbstractSpinBox::StepDownEnabled;
|
|
1638 |
|
|
1639 |
painter->setBrush(spinner->palette.color(QPalette::Background));
|
|
1640 |
|
|
1641 |
painter->drawRect(upRect);
|
|
1642 |
if (upIsActive && stepUpEnabled) {
|
|
1643 |
if (sunken) {
|
|
1644 |
drawSunkenButtonShadow(painter, upRect,
|
|
1645 |
spinner->palette.color(QPalette::Mid));
|
|
1646 |
} else if (hover) {
|
|
1647 |
drawButtonHoverFrame(painter, upRect,
|
|
1648 |
spinner->palette.color(QPalette::Mid),
|
|
1649 |
spinner->palette.color(QPalette::Button));
|
|
1650 |
}
|
|
1651 |
}
|
|
1652 |
|
|
1653 |
QStyleOptionSpinBox upSpin = *spinner;
|
|
1654 |
upSpin.rect = upRect;
|
|
1655 |
drawPrimitive(PE_IndicatorSpinUp, &upSpin, painter, widget);
|
|
1656 |
|
|
1657 |
painter->drawRect(downRect);
|
|
1658 |
if (downIsActive && stepDownEnabled) {
|
|
1659 |
if (sunken) {
|
|
1660 |
drawSunkenButtonShadow(painter, downRect,
|
|
1661 |
spinner->palette.color(QPalette::Mid));
|
|
1662 |
} else if (hover) {
|
|
1663 |
drawButtonHoverFrame(painter, downRect,
|
|
1664 |
spinner->palette.color(QPalette::Mid),
|
|
1665 |
spinner->palette.color(QPalette::Button));
|
|
1666 |
}
|
|
1667 |
}
|
|
1668 |
|
|
1669 |
QStyleOptionSpinBox downSpin = *spinner;
|
|
1670 |
downSpin.rect = downRect;
|
|
1671 |
drawPrimitive(PE_IndicatorSpinDown, &downSpin, painter, widget);
|
|
1672 |
|
|
1673 |
break;
|
|
1674 |
}
|
|
1675 |
case CC_ToolButton: {
|
|
1676 |
const QStyleOptionToolButton *button =
|
|
1677 |
qstyleoption_cast<const QStyleOptionToolButton *>(option);
|
|
1678 |
|
|
1679 |
painter->setPen(Qt::white);
|
|
1680 |
painter->drawRect(button->rect.adjusted(1, 1, -1, -1));
|
|
1681 |
|
|
1682 |
QStyleOptionToolButton panelOption = *button;
|
|
1683 |
QRect panelRect;
|
|
1684 |
if (!(button->state & State_MouseOver) &&
|
|
1685 |
!(button->state & State_On)) {
|
|
1686 |
painter->setPen(QColor(153, 153, 153));
|
|
1687 |
painter->drawRect(button->rect.adjusted(0, 0, -2, -2));
|
|
1688 |
|
|
1689 |
panelRect = subControlRect(control, option, SC_ToolButton);
|
|
1690 |
panelOption.rect = panelRect;
|
|
1691 |
} else {
|
|
1692 |
panelOption.rect.adjust(0, 0, -1, -1);
|
|
1693 |
}
|
|
1694 |
|
|
1695 |
QRect menuRect = subControlRect(control, option, SC_ToolButtonMenu);
|
|
1696 |
|
|
1697 |
drawPrimitive(PE_PanelButtonTool, &panelOption, painter, widget);
|
|
1698 |
|
|
1699 |
QStyleOptionToolButton menuOption = *button;
|
|
1700 |
menuOption.rect = menuRect;
|
|
1701 |
|
|
1702 |
QStyleOptionToolButton label = *button;
|
|
1703 |
int fw = 5;
|
|
1704 |
|
|
1705 |
drawControl(CE_ToolButtonLabel, &label, painter, widget);
|
|
1706 |
if (button->subControls & SC_ToolButtonMenu) {
|
|
1707 |
painter->setPen(button->palette.color(QPalette::WindowText));
|
|
1708 |
drawPrimitive(PE_IndicatorArrowDown, &menuOption, painter, widget);
|
|
1709 |
}
|
|
1710 |
|
|
1711 |
if (button->state & State_HasFocus) {
|
|
1712 |
QStyleOptionToolButton focusOption = *button;
|
|
1713 |
focusOption.rect = label.rect.adjusted(-1, -1, 1, 1);
|
|
1714 |
|
|
1715 |
drawPrimitive(PE_FrameFocusRect, &focusOption, painter, widget);
|
|
1716 |
}
|
|
1717 |
|
|
1718 |
break;
|
|
1719 |
}
|
|
1720 |
case CC_ComboBox: {
|
|
1721 |
const QStyleOptionComboBox *combo =
|
|
1722 |
qstyleoption_cast<const QStyleOptionComboBox *>(option);
|
|
1723 |
|
|
1724 |
QRect frameRect = subControlRect(control, option, SC_ComboBoxFrame,
|
|
1725 |
widget);
|
|
1726 |
painter->setPen(combo->palette.color(QPalette::Mid));
|
|
1727 |
|
|
1728 |
if (option->state & State_HasFocus)
|
|
1729 |
painter->setBrush(option->palette.color(QPalette::Light));
|
|
1730 |
else
|
|
1731 |
painter->setBrush(combo->palette.color(QPalette::Background));
|
|
1732 |
|
|
1733 |
painter->drawRect(frameRect.adjusted(0, 0, -1, -1));
|
|
1734 |
|
|
1735 |
QRect arrowRect = subControlRect(control, option, SC_ComboBoxArrow,
|
|
1736 |
widget);
|
|
1737 |
painter->setPen(combo->palette.color(QPalette::Button));
|
|
1738 |
painter->setBrush(Qt::NoBrush);
|
|
1739 |
|
|
1740 |
if (combo->direction == Qt::LeftToRight) {
|
|
1741 |
painter->drawRect(QRect(frameRect.topLeft() + QPoint(1, 1),
|
|
1742 |
arrowRect.bottomLeft() + QPoint(-2, -2)));
|
|
1743 |
} else {
|
|
1744 |
painter->drawRect(QRect(arrowRect.topLeft() + QPoint(1, 1),
|
|
1745 |
frameRect.bottomRight() + QPoint(-2, -2)));
|
|
1746 |
}
|
|
1747 |
|
|
1748 |
QStyleOptionButton button;
|
|
1749 |
button.rect = arrowRect;
|
|
1750 |
button.state = combo->state;
|
|
1751 |
button.palette = combo->palette;
|
|
1752 |
|
|
1753 |
if (button.state & State_On)
|
|
1754 |
button.state ^= State_On;
|
|
1755 |
|
|
1756 |
painter->save();
|
|
1757 |
drawButtonBackground(&button, painter, false);
|
|
1758 |
painter->restore();
|
|
1759 |
|
|
1760 |
QPoint center = arrowRect.center();
|
|
1761 |
QPoint offset = QPoint(arrowRect.bottomLeft().x() + 1,
|
|
1762 |
center.y() + 7);
|
|
1763 |
QPainterPath arrow;
|
|
1764 |
arrow.moveTo(offset + QPoint(4, -8));
|
|
1765 |
arrow.lineTo(offset + QPoint(7, -5));
|
|
1766 |
arrow.lineTo(offset + QPoint(8, -5));
|
|
1767 |
arrow.lineTo(offset + QPoint(11, -8));
|
|
1768 |
arrow.lineTo(offset + QPoint(4, -8));
|
|
1769 |
|
|
1770 |
painter->setBrush(combo->palette.color(QPalette::WindowText));
|
|
1771 |
painter->setPen(combo->palette.color(QPalette::WindowText));
|
|
1772 |
|
|
1773 |
painter->drawPath(arrow);
|
|
1774 |
|
|
1775 |
QRect fieldRect = subControlRect(control, option,
|
|
1776 |
SC_ComboBoxEditField, widget);
|
|
1777 |
|
|
1778 |
break;
|
|
1779 |
}
|
|
1780 |
case CC_Slider: {
|
|
1781 |
const QStyleOptionSlider *slider =
|
|
1782 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
1783 |
|
|
1784 |
bool horizontal = slider->orientation == Qt::Horizontal;
|
|
1785 |
|
|
1786 |
QRect groove = subControlRect(control, option, SC_SliderGroove,
|
|
1787 |
widget);
|
|
1788 |
QRect ticks = subControlRect(control, option, SC_SliderTickmarks,
|
|
1789 |
widget);
|
|
1790 |
QRect handle = subControlRect(control, option, SC_SliderHandle,
|
|
1791 |
widget);
|
|
1792 |
|
|
1793 |
QRect afterHandle = QRect(handle.topLeft() + xySwitch(QPoint(4, 6), horizontal),
|
|
1794 |
groove.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
|
|
1795 |
QRect beforeHandle = QRect(groove.topLeft() + xySwitch(QPoint(4, 6), horizontal),
|
|
1796 |
handle.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
|
|
1797 |
|
|
1798 |
if (slider->upsideDown || !horizontal) {
|
|
1799 |
QRect remember;
|
|
1800 |
remember = afterHandle;
|
|
1801 |
afterHandle = beforeHandle;
|
|
1802 |
beforeHandle = remember;
|
|
1803 |
}
|
|
1804 |
|
|
1805 |
painter->setPen(slider->palette.color(QPalette::Mid));
|
|
1806 |
painter->setBrush(option->palette.color(QPalette::Background));
|
|
1807 |
painter->drawRect(afterHandle);
|
|
1808 |
painter->setPen(slider->palette.color(QPalette::Light));
|
|
1809 |
painter->drawLine(afterHandle.topLeft() + xySwitch(QPoint(0, 1), horizontal),
|
|
1810 |
afterHandle.topRight() + xySwitch(QPoint(0, 1), horizontal));
|
|
1811 |
painter->setPen(option->palette.color(QPalette::Midlight));
|
|
1812 |
|
|
1813 |
if (horizontal) {
|
|
1814 |
painter->setBrush(gradientBrush(QRect(QPoint(groove.x(),
|
|
1815 |
handle.y() + 1),
|
|
1816 |
QSize(groove.width(),
|
|
1817 |
handle.height() + 1))));
|
|
1818 |
} else {
|
|
1819 |
QRect rect = QRect(QPoint(groove.x(),
|
|
1820 |
handle.x() - 1),
|
|
1821 |
QSize(groove.height(),
|
|
1822 |
handle.width() + 1));
|
|
1823 |
QLinearGradient gradient(groove.bottomLeft(),
|
|
1824 |
groove.bottomRight());
|
|
1825 |
gradient.setColorAt(1.0, QColor(188, 210, 230));
|
|
1826 |
gradient.setColorAt(0.3, Qt::white);
|
|
1827 |
gradient.setColorAt(0.0, QColor(223, 233, 243));
|
|
1828 |
|
|
1829 |
painter->setBrush(gradient);
|
|
1830 |
}
|
|
1831 |
|
|
1832 |
painter->drawRect(beforeHandle);
|
|
1833 |
|
|
1834 |
QPainterPath handlePath;
|
|
1835 |
QPainterPath innerPath;
|
|
1836 |
QPoint topLeft, topRight, bottomLeft;
|
|
1837 |
if (horizontal) {
|
|
1838 |
topLeft = handle.topLeft();
|
|
1839 |
topRight = handle.topRight();
|
|
1840 |
bottomLeft = handle.bottomLeft();
|
|
1841 |
} else {
|
|
1842 |
topLeft = handle.bottomLeft();
|
|
1843 |
topRight = handle.topLeft();
|
|
1844 |
bottomLeft = handle.topRight();
|
|
1845 |
}
|
|
1846 |
|
|
1847 |
if (horizontal) {
|
|
1848 |
QImage image(sliderHandleImage);
|
|
1849 |
|
|
1850 |
image.setColor(1,
|
|
1851 |
option->palette.color(QPalette::Midlight).rgb());
|
|
1852 |
image.setColor(2,
|
|
1853 |
option->palette.color(QPalette::Button).rgb());
|
|
1854 |
|
|
1855 |
if (!(slider->state & State_Enabled)) {
|
|
1856 |
image.setColor(4, slider->palette.color(QPalette::Background).rgb());
|
|
1857 |
image.setColor(5, slider->palette.color(QPalette::Background).rgb());
|
|
1858 |
image.setColor(6, slider->palette.color(QPalette::Background).rgb());
|
|
1859 |
}
|
|
1860 |
|
|
1861 |
painter->drawImage(handle.topLeft(), image);
|
|
1862 |
} else {
|
|
1863 |
QImage image(":/images/verticalsliderhandle.png");
|
|
1864 |
painter->drawImage(handle.topLeft(), image);
|
|
1865 |
}
|
|
1866 |
|
|
1867 |
if (slider->tickPosition & QSlider::TicksBelow) {
|
|
1868 |
painter->setPen(slider->palette.color(QPalette::Light));
|
|
1869 |
int tickInterval = slider->tickInterval ? slider->tickInterval :
|
|
1870 |
slider->pageStep;
|
|
1871 |
|
|
1872 |
for (int i = 0; i <= slider->maximum; i += tickInterval) {
|
|
1873 |
if (horizontal) {
|
|
1874 |
int pos = int(((i / double(slider->maximum)) *
|
|
1875 |
ticks.width()) - 1);
|
|
1876 |
painter->drawLine(QPoint(ticks.left() + pos,
|
|
1877 |
ticks.top() + 2), QPoint(ticks.left() + pos, ticks.top() + 8));
|
|
1878 |
} else {
|
|
1879 |
int pos = int(((i / double(slider->maximum)) *
|
|
1880 |
ticks.height()) - 1);
|
|
1881 |
painter->drawLine(QPoint(ticks.left() + 2, ticks.bottom() - pos),
|
|
1882 |
QPoint(ticks.right() - 2, ticks.bottom() - pos));
|
|
1883 |
}
|
|
1884 |
}
|
|
1885 |
if (horizontal) {
|
|
1886 |
painter->drawLine(QPoint(ticks.right(), ticks.top() + 2),
|
|
1887 |
QPoint(ticks.right(), ticks.top() + 8));
|
|
1888 |
} else {
|
|
1889 |
painter->drawLine(QPoint(ticks.left() + 2, ticks.top()),
|
|
1890 |
QPoint(ticks.right() - 2, ticks.top()));
|
|
1891 |
}
|
|
1892 |
}
|
|
1893 |
break;
|
|
1894 |
}
|
|
1895 |
default:
|
|
1896 |
QWindowsStyle::drawComplexControl(control, option, painter, widget);
|
|
1897 |
}
|
|
1898 |
painter->restore();
|
|
1899 |
}
|
|
1900 |
|
|
1901 |
inline void JavaStyle::drawSunkenButtonShadow(QPainter *painter,
|
|
1902 |
QRect rect,
|
|
1903 |
const QColor &frameColor,
|
|
1904 |
bool reverse) const
|
|
1905 |
{
|
|
1906 |
painter->save();
|
|
1907 |
|
|
1908 |
painter->setPen(frameColor);
|
|
1909 |
|
|
1910 |
if (!reverse) {
|
|
1911 |
painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y() + 1),
|
|
1912 |
QPoint(rect.x() + rect.width() - 1, rect.y() + 1)));
|
|
1913 |
painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y()),
|
|
1914 |
QPoint(rect.x() + 1, rect.y() + rect.height())));
|
|
1915 |
} else {
|
|
1916 |
painter->drawLine(QLine(QPoint(rect.right(), rect.bottom()),
|
|
1917 |
QPoint(rect.right(), rect.top())));
|
|
1918 |
painter->drawLine(QLine(QPoint(rect.left(), rect.top() + 1),
|
|
1919 |
QPoint(rect.right(), rect.top() + 1)));
|
|
1920 |
}
|
|
1921 |
painter->restore();
|
|
1922 |
}
|
|
1923 |
|
|
1924 |
inline void JavaStyle::drawButtonHoverFrame(QPainter *painter, QRect rect,
|
|
1925 |
const QColor &frameColor,
|
|
1926 |
const QColor &activeFrame) const
|
|
1927 |
{
|
|
1928 |
painter->save();
|
|
1929 |
|
|
1930 |
painter->setPen(activeFrame);
|
|
1931 |
painter->drawRect(rect);
|
|
1932 |
rect.adjust(1, 1, -1, -1);
|
|
1933 |
painter->setPen(frameColor);
|
|
1934 |
painter->drawRect(rect);
|
|
1935 |
rect.adjust(1, 1, -1, -1);
|
|
1936 |
painter->setPen(activeFrame);
|
|
1937 |
painter->drawRect(rect);
|
|
1938 |
|
|
1939 |
painter->restore();
|
|
1940 |
}
|
|
1941 |
|
|
1942 |
QStyle::SubControl JavaStyle::hitTestComplexControl(ComplexControl control,
|
|
1943 |
const QStyleOptionComplex *option,
|
|
1944 |
const QPoint &pos,
|
|
1945 |
const QWidget *widget) const
|
|
1946 |
{
|
|
1947 |
SubControl ret = SC_None;
|
|
1948 |
|
|
1949 |
switch (control) {
|
|
1950 |
case CC_TitleBar: {
|
|
1951 |
const QStyleOptionTitleBar *bar =
|
|
1952 |
qstyleoption_cast<const QStyleOptionTitleBar *>(option);
|
|
1953 |
|
|
1954 |
QRect maximize = subControlRect(control, bar, SC_TitleBarMaxButton);
|
|
1955 |
if (maximize.contains(pos)) {
|
|
1956 |
ret = SC_TitleBarMaxButton;
|
|
1957 |
break;
|
|
1958 |
}
|
|
1959 |
QRect minimize = subControlRect(control, bar, SC_TitleBarMinButton);
|
|
1960 |
if (minimize.contains(pos)) {
|
|
1961 |
ret = SC_TitleBarMinButton;
|
|
1962 |
break;
|
|
1963 |
}
|
|
1964 |
QRect close = subControlRect(control, bar, SC_TitleBarCloseButton);
|
|
1965 |
if (close.contains(pos)) {
|
|
1966 |
ret = SC_TitleBarCloseButton;
|
|
1967 |
break;
|
|
1968 |
}
|
|
1969 |
QRect system = subControlRect(control, bar, SC_TitleBarSysMenu);
|
|
1970 |
if (system.contains(pos)) {
|
|
1971 |
ret = SC_TitleBarSysMenu;
|
|
1972 |
break;
|
|
1973 |
}
|
|
1974 |
ret = SC_TitleBarLabel;
|
|
1975 |
break;
|
|
1976 |
}
|
|
1977 |
case CC_ScrollBar:
|
|
1978 |
if (const QStyleOptionSlider *scrollBar =
|
|
1979 |
qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|
1980 |
QRect slider = subControlRect(control, scrollBar,
|
|
1981 |
SC_ScrollBarSlider, widget);
|
|
1982 |
if (slider.contains(pos)) {
|
|
1983 |
ret = SC_ScrollBarSlider;
|
|
1984 |
break;
|
|
1985 |
}
|
|
1986 |
|
|
1987 |
QRect scrollBarAddLine = subControlRect(control, scrollBar,
|
|
1988 |
SC_ScrollBarAddLine, widget);
|
|
1989 |
if (scrollBarAddLine.contains(pos)) {
|
|
1990 |
ret = SC_ScrollBarAddLine;
|
|
1991 |
break;
|
|
1992 |
}
|
|
1993 |
|
|
1994 |
QRect scrollBarSubPage = subControlRect(control, scrollBar,
|
|
1995 |
SC_ScrollBarSubPage, widget);
|
|
1996 |
if (scrollBarSubPage.contains(pos)) {
|
|
1997 |
ret = SC_ScrollBarSubPage;
|
|
1998 |
break;
|
|
1999 |
}
|
|
2000 |
|
|
2001 |
QRect scrollBarAddPage = subControlRect(control, scrollBar,
|
|
2002 |
SC_ScrollBarAddPage, widget);
|
|
2003 |
if (scrollBarAddPage.contains(pos)) {
|
|
2004 |
ret = SC_ScrollBarAddPage;
|
|
2005 |
break;
|
|
2006 |
}
|
|
2007 |
|
|
2008 |
QRect scrollBarSubLine = subControlRect(control, scrollBar,
|
|
2009 |
SC_ScrollBarSubLine, widget);
|
|
2010 |
if (scrollBarSubLine.contains(pos)) {
|
|
2011 |
ret = SC_ScrollBarSubLine;
|
|
2012 |
break;
|
|
2013 |
}
|
|
2014 |
}
|
|
2015 |
break;
|
|
2016 |
|
|
2017 |
default:
|
|
2018 |
ret = QWindowsStyle::hitTestComplexControl(control, option, pos,
|
|
2019 |
widget);
|
|
2020 |
}
|
|
2021 |
return ret;
|
|
2022 |
}
|
|
2023 |
|
|
2024 |
void JavaStyle::polish(QWidget *widget)
|
|
2025 |
{
|
|
2026 |
if (qobject_cast<QCheckBox *>(widget) ||
|
|
2027 |
qobject_cast<QRadioButton *>(widget) ||
|
|
2028 |
qobject_cast<QPushButton *>(widget) ||
|
|
2029 |
qobject_cast<QToolButton *>(widget) ||
|
|
2030 |
qobject_cast<QSpinBox *>(widget) ||
|
|
2031 |
qobject_cast<QGroupBox *>(widget))
|
|
2032 |
widget->setAttribute(Qt::WA_Hover, true);
|
|
2033 |
}
|
|
2034 |
|
|
2035 |
void JavaStyle::unpolish(QWidget *widget)
|
|
2036 |
{
|
|
2037 |
if (qobject_cast<QPushButton *>(widget) ||
|
|
2038 |
qobject_cast<QCheckBox *>(widget) ||
|
|
2039 |
qobject_cast<QRadioButton *>(widget) ||
|
|
2040 |
qobject_cast<QToolButton *>(widget) ||
|
|
2041 |
qobject_cast<QSpinBox *>(widget) ||
|
|
2042 |
qobject_cast<QGroupBox *>(widget))
|
|
2043 |
widget->setAttribute(Qt::WA_Hover, false);
|
|
2044 |
}
|
|
2045 |
|
|
2046 |
void JavaStyle::drawSplitter(const QStyleOption *option, QPainter *painter,
|
|
2047 |
bool horizontal) const
|
|
2048 |
{
|
|
2049 |
QRect rect = option->rect;
|
|
2050 |
|
|
2051 |
painter->setPen(Qt::NoPen);
|
|
2052 |
painter->setBrush(option->palette.color(QPalette::Background));
|
|
2053 |
|
|
2054 |
painter->drawRect(rect);
|
|
2055 |
|
|
2056 |
QColor colors[] = { Qt::white, option->palette.color(QPalette::Mid) };
|
|
2057 |
int iterations = horizontal ? rect.height() - 1 : rect.width() - 1;
|
|
2058 |
for (int i = 0; i < iterations; ++i) {
|
|
2059 |
painter->setPen(colors[i % 2]);
|
|
2060 |
painter->drawPoint(xySwitch(QPoint(rect.x() + 0 + (i % 4),
|
|
2061 |
rect.y() + i), horizontal));
|
|
2062 |
}
|
|
2063 |
}
|
|
2064 |
|
|
2065 |
inline QPoint JavaStyle::xySwitch(const QPoint &point, bool horizontal) const
|
|
2066 |
{
|
|
2067 |
QPoint retPoint = point;
|
|
2068 |
|
|
2069 |
if (!horizontal) {
|
|
2070 |
retPoint = QPoint(point.y(), point.x());
|
|
2071 |
}
|
|
2072 |
|
|
2073 |
return retPoint;
|
|
2074 |
}
|
|
2075 |
|
|
2076 |
void JavaStyle::drawPrimitive(PrimitiveElement element,
|
|
2077 |
const QStyleOption *option,
|
|
2078 |
QPainter *painter,
|
|
2079 |
const QWidget *widget) const
|
|
2080 |
{
|
|
2081 |
painter->save();
|
|
2082 |
|
|
2083 |
switch (element) {
|
|
2084 |
case PE_PanelButtonBevel:
|
|
2085 |
case PE_FrameButtonBevel: {
|
|
2086 |
painter->save();
|
|
2087 |
painter->setBrush(option->palette.background());
|
|
2088 |
painter->setPen(Qt::NoPen);
|
|
2089 |
painter->drawRect(option->rect);
|
|
2090 |
painter->restore();
|
|
2091 |
break;
|
|
2092 |
}
|
|
2093 |
case PE_IndicatorBranch: {
|
|
2094 |
painter->save();
|
|
2095 |
QColor lineColor(204, 204, 255);
|
|
2096 |
QPixmap openPixmap(":/images/jtreeopen.png");
|
|
2097 |
QPixmap closedPixmap(":/images/jtreeclosed.png");
|
|
2098 |
QRect pixmapRect(QPoint(0, 0), QSize(12, 12));
|
|
2099 |
pixmapRect.moveCenter(option->rect.center());
|
|
2100 |
pixmapRect.translate(2, 0);
|
|
2101 |
QPoint center = option->rect.center();
|
|
2102 |
|
|
2103 |
painter->setPen(lineColor);
|
|
2104 |
painter->setBrush(Qt::NoBrush);
|
|
2105 |
|
|
2106 |
if (option->state & State_Item) {
|
|
2107 |
painter->drawLine(center,
|
|
2108 |
QPoint(option->rect.right(), center.y()));
|
|
2109 |
|
|
2110 |
painter->drawLine(center, QPoint(center.x(),
|
|
2111 |
option->rect.top()));
|
|
2112 |
|
|
2113 |
if (option->state & State_Sibling) {
|
|
2114 |
painter->drawLine(center, QPoint(center.x(),
|
|
2115 |
option->rect.bottom()));
|
|
2116 |
}
|
|
2117 |
|
|
2118 |
if (option->state & State_Children)
|
|
2119 |
if (option->state & State_Open)
|
|
2120 |
painter->drawPixmap(pixmapRect.topLeft(), closedPixmap);
|
|
2121 |
else
|
|
2122 |
painter->drawPixmap(pixmapRect.topLeft(), openPixmap);
|
|
2123 |
} else if (option->state & State_Sibling) {
|
|
2124 |
painter->drawLine(center.x(), option->rect.top(), center.x(),
|
|
2125 |
option->rect.bottom());
|
|
2126 |
}
|
|
2127 |
|
|
2128 |
painter->restore();
|
|
2129 |
break;
|
|
2130 |
}
|
|
2131 |
case PE_IndicatorViewItemCheck: {
|
|
2132 |
break;
|
|
2133 |
}
|
|
2134 |
case PE_FrameWindow: {
|
|
2135 |
painter->save();
|
|
2136 |
bool active = option->state & State_Active;
|
|
2137 |
|
|
2138 |
painter->setPen(Qt::NoPen);
|
|
2139 |
painter->setBrush(active ? option->palette.color(QPalette::Midlight)
|
|
2140 |
: option->palette.color(QPalette::Mid));
|
|
2141 |
|
|
2142 |
painter->drawRect(QRect(option->rect.topLeft(), option->rect.bottomLeft() + QPoint(5, 0)));
|
|
2143 |
painter->drawRect(QRect(option->rect.bottomLeft(), option->rect.bottomRight() + QPoint(0, -5)));
|
|
2144 |
painter->drawRect(QRect(option->rect.bottomRight() + QPoint(-5, 0), option->rect.topRight()));
|
|
2145 |
painter->drawRect(QRect(option->rect.topLeft(), option->rect.topRight() + QPoint(0, 4)));
|
|
2146 |
|
|
2147 |
painter->setBrush(Qt::NoBrush);
|
|
2148 |
painter->setPen(option->palette.color(QPalette::Active, QPalette::WindowText));
|
|
2149 |
painter->drawLine(option->rect.topLeft() + QPoint(2, 14),
|
|
2150 |
option->rect.bottomLeft() + QPoint(2, -14));
|
|
2151 |
|
|
2152 |
painter->drawLine(option->rect.topRight() + QPoint(-2, 14),
|
|
2153 |
option->rect.bottomRight() + QPoint(-2, -14));
|
|
2154 |
|
|
2155 |
painter->drawLine(option->rect.topLeft() + QPoint(14, 2),
|
|
2156 |
option->rect.topRight() + QPoint(-14, 2));
|
|
2157 |
|
|
2158 |
painter->drawLine(option->rect.bottomLeft() + QPoint(14, -2),
|
|
2159 |
option->rect.bottomRight() + QPoint(-14, -2));
|
|
2160 |
|
|
2161 |
painter->setPen(active ? option->palette.color(QPalette::Light) :
|
|
2162 |
option->palette.color(QPalette::Button));
|
|
2163 |
painter->drawLine(option->rect.topLeft() + QPoint(3, 15),
|
|
2164 |
option->rect.bottomLeft() + QPoint(3, -13));
|
|
2165 |
|
|
2166 |
painter->drawLine(option->rect.topRight() + QPoint(-1, 15),
|
|
2167 |
option->rect.bottomRight() + QPoint(-1, -13));
|
|
2168 |
|
|
2169 |
painter->drawLine(option->rect.topLeft() + QPoint(15, 3),
|
|
2170 |
option->rect.topRight() + QPoint(-13, 3));
|
|
2171 |
|
|
2172 |
painter->drawLine(option->rect.bottomLeft() + QPoint(15, -1),
|
|
2173 |
option->rect.bottomRight() + QPoint(-13, -1));
|
|
2174 |
|
|
2175 |
painter->restore();
|
|
2176 |
break;
|
|
2177 |
}
|
|
2178 |
case PE_IndicatorSpinUp: {
|
|
2179 |
const QStyleOptionSpinBox *spinner =
|
|
2180 |
qstyleoption_cast<const QStyleOptionSpinBox *>(option);
|
|
2181 |
int add = spinner->state & State_Sunken &&
|
|
2182 |
spinner->activeSubControls & SC_SpinBoxUp ? 1 : 0;
|
|
2183 |
|
|
2184 |
QPoint center = option->rect.center();
|
|
2185 |
painter->drawLine(center.x() + add, center.y() + 1 + add,
|
|
2186 |
center.x() + 2 + add, center.y() + 1 + add);
|
|
2187 |
painter->drawPoint(center.x() + 1 + add, center.y() + add);
|
|
2188 |
break;
|
|
2189 |
}
|
|
2190 |
case PE_IndicatorSpinDown: {
|
|
2191 |
const QStyleOptionSpinBox *spinner =
|
|
2192 |
qstyleoption_cast<const QStyleOptionSpinBox *>(option);
|
|
2193 |
|
|
2194 |
int add = spinner->state & State_Sunken &&
|
|
2195 |
spinner->activeSubControls & SC_SpinBoxDown ? 1 : 0;
|
|
2196 |
QPoint center = option->rect.center();
|
|
2197 |
painter->drawLine(center.x() + add, center.y() + add,
|
|
2198 |
center.x() + 2 + add, center.y() + add);
|
|
2199 |
painter->drawPoint(center.x() + 1 + add, center.y() + 1 + add);
|
|
2200 |
break;
|
|
2201 |
}
|
|
2202 |
case PE_FrameDockWidget: {
|
|
2203 |
drawPrimitive(PE_FrameWindow, option, painter, widget);
|
|
2204 |
break;
|
|
2205 |
}
|
|
2206 |
case PE_IndicatorToolBarHandle: {
|
|
2207 |
QPoint offset;
|
|
2208 |
bool horizontal = option->state & State_Horizontal;
|
|
2209 |
|
|
2210 |
if (horizontal)
|
|
2211 |
offset = option->rect.topLeft();
|
|
2212 |
else
|
|
2213 |
offset = option->rect.topLeft();
|
|
2214 |
|
|
2215 |
int iterations = horizontal ? option->rect.height() :
|
|
2216 |
option->rect.width();
|
|
2217 |
|
|
2218 |
for (int i = 0; i < iterations; ++i) {
|
|
2219 |
painter->setPen(i % 2 ? Qt::white :
|
|
2220 |
option->palette.color(QPalette::Mid));
|
|
2221 |
int add = i % 4;
|
|
2222 |
painter->drawPoint(offset + xySwitch(QPoint(add, i),
|
|
2223 |
horizontal));
|
|
2224 |
painter->drawPoint(offset + xySwitch(QPoint(add + 4, i),
|
|
2225 |
horizontal));
|
|
2226 |
if (add + 8 < 10)
|
|
2227 |
painter->drawPoint(offset + xySwitch(QPoint(add + 8, i),
|
|
2228 |
horizontal));
|
|
2229 |
}
|
|
2230 |
|
|
2231 |
break;
|
|
2232 |
}
|
|
2233 |
case PE_IndicatorToolBarSeparator: {
|
|
2234 |
break;
|
|
2235 |
}
|
|
2236 |
case PE_PanelButtonTool: {
|
|
2237 |
const QStyleOptionToolButton *button =
|
|
2238 |
qstyleoption_cast<const QStyleOptionToolButton *>(option);
|
|
2239 |
|
|
2240 |
if (!button) {
|
|
2241 |
painter->setPen(Qt::red);
|
|
2242 |
if (!(option->state & State_Enabled))
|
|
2243 |
painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
|
2244 |
drawButtonBackground(option, painter, false);
|
|
2245 |
break;
|
|
2246 |
}
|
|
2247 |
|
|
2248 |
if (button->state & State_MouseOver || button->state & State_On) {
|
|
2249 |
QStyleOptionButton bevel;
|
|
2250 |
bevel.state = button->state;
|
|
2251 |
bevel.rect = button->rect;
|
|
2252 |
bevel.palette = button->palette;
|
|
2253 |
|
|
2254 |
drawButtonBackground(&bevel, painter, false);
|
|
2255 |
} else {
|
|
2256 |
painter->setPen(Qt::NoPen);
|
|
2257 |
painter->setBrush(button->palette.color(QPalette::Background));
|
|
2258 |
|
|
2259 |
painter->drawRect(button->rect.adjusted(0, 0, -1, -1));
|
|
2260 |
}
|
|
2261 |
break;
|
|
2262 |
}
|
|
2263 |
case PE_FrameMenu: {
|
|
2264 |
painter->setPen(option->palette.color(QPalette::Midlight));
|
|
2265 |
painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
|
2266 |
break;
|
|
2267 |
}
|
|
2268 |
case PE_PanelButtonCommand: {
|
|
2269 |
const QStyleOptionButton *btn =
|
|
2270 |
qstyleoption_cast<const QStyleOptionButton *>(option);
|
|
2271 |
bool hover = (btn->state & State_Enabled) &&
|
|
2272 |
(btn->state & State_MouseOver);
|
|
2273 |
bool sunken = btn->state & State_Sunken;
|
|
2274 |
bool isDefault = btn->features & QStyleOptionButton::DefaultButton;
|
|
2275 |
bool on = option->state & State_On;
|
|
2276 |
|
|
2277 |
drawButtonBackground(option, painter, false);
|
|
2278 |
|
|
2279 |
QRect rect = option->rect.adjusted(0, 0, -1, -1);
|
|
2280 |
if (hover && !sunken && !isDefault && !on) {
|
|
2281 |
drawButtonHoverFrame(painter, rect,
|
|
2282 |
btn->palette.color(QPalette::Mid),
|
|
2283 |
btn->palette.color(QPalette::Button));
|
|
2284 |
} else if (isDefault) {
|
|
2285 |
drawPrimitive(PE_FrameDefaultButton, option, painter, widget);
|
|
2286 |
}
|
|
2287 |
break;
|
|
2288 |
}
|
|
2289 |
case PE_FrameDefaultButton: {
|
|
2290 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
2291 |
QRect rect = option->rect.adjusted(0, 0, -1, -1);
|
|
2292 |
painter->drawRect(rect);
|
|
2293 |
painter->drawRect(rect.adjusted(1, 1, -1, -1));
|
|
2294 |
break;
|
|
2295 |
}
|
|
2296 |
//! [0]
|
|
2297 |
case PE_IndicatorCheckBox: {
|
|
2298 |
painter->save();
|
|
2299 |
drawButtonBackground(option, painter, true);
|
|
2300 |
|
|
2301 |
if (option->state & State_Enabled &&
|
|
2302 |
option->state & State_MouseOver &&
|
|
2303 |
!(option->state & State_Sunken)) {
|
|
2304 |
painter->setPen(option->palette.color(QPalette::Button));
|
|
2305 |
QRect rect = option->rect.adjusted(1, 1, -2, -2);
|
|
2306 |
painter->drawRect(rect);
|
|
2307 |
rect = rect.adjusted(1, 1, -1, -1);
|
|
2308 |
painter->drawRect(rect);
|
|
2309 |
}
|
|
2310 |
|
|
2311 |
if (option->state & State_On) {
|
|
2312 |
QImage image(":/images/checkboxchecked.png");
|
|
2313 |
painter->drawImage(option->rect.topLeft(), image);
|
|
2314 |
}
|
|
2315 |
painter->restore();
|
|
2316 |
break;
|
|
2317 |
//! [0]
|
|
2318 |
}
|
|
2319 |
case PE_IndicatorRadioButton: {
|
|
2320 |
painter->save();
|
|
2321 |
QBrush radioBrush = option->palette.button();
|
|
2322 |
|
|
2323 |
if (!(option->state & State_Sunken) &&
|
|
2324 |
option->state & State_Enabled)
|
|
2325 |
radioBrush = gradientBrush(option->rect);
|
|
2326 |
|
|
2327 |
painter->setBrush(radioBrush);
|
|
2328 |
if (option->state & State_Enabled)
|
|
2329 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
2330 |
else
|
|
2331 |
painter->setPen(option->palette.color(QPalette::Disabled,
|
|
2332 |
QPalette::WindowText));
|
|
2333 |
painter->drawEllipse(option->rect.adjusted(0, 0, -1, -1));
|
|
2334 |
|
|
2335 |
if (option->state & State_MouseOver &&
|
|
2336 |
option->state & State_Enabled &&
|
|
2337 |
!(option->state & State_Sunken)) {
|
|
2338 |
gradientBrush(option->rect);
|
|
2339 |
painter->setPen(option->palette.color(QPalette::Button));
|
|
2340 |
painter->setBrush(Qt::NoBrush);
|
|
2341 |
QRect rect = option->rect.adjusted(1, 1, -2, -2);
|
|
2342 |
painter->drawEllipse(rect);
|
|
2343 |
rect = rect.adjusted(1, 1, -1, -1);
|
|
2344 |
painter->drawEllipse(rect);
|
|
2345 |
}
|
|
2346 |
|
|
2347 |
if (option->state & State_On) {
|
|
2348 |
painter->setBrush(option->palette.color(QPalette::Text));
|
|
2349 |
painter->setPen(Qt::NoPen);
|
|
2350 |
painter->drawEllipse(option->rect.adjusted(3, 3, -3, -3));
|
|
2351 |
}
|
|
2352 |
if (option->state & State_Sunken &&
|
|
2353 |
option->state & State_Enabled) {
|
|
2354 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
2355 |
painter->drawArc(option->rect.adjusted(1, 1, -2, -2), 80 * 16,
|
|
2356 |
100 * 16);
|
|
2357 |
}
|
|
2358 |
painter->restore();
|
|
2359 |
break;
|
|
2360 |
}
|
|
2361 |
case PE_FrameTabWidget: {
|
|
2362 |
painter->setPen(option->palette.color(QPalette::Midlight));
|
|
2363 |
painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
|
|
2364 |
painter->setPen(Qt::white);
|
|
2365 |
painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
|
|
2366 |
break;
|
|
2367 |
}
|
|
2368 |
case PE_Frame:
|
|
2369 |
case PE_FrameLineEdit: {
|
|
2370 |
const QStyleOptionFrame *frame =
|
|
2371 |
qstyleoption_cast<const QStyleOptionFrame *>(option);
|
|
2372 |
const QStyleOptionFrameV2 frameV2(*frame);
|
|
2373 |
|
|
2374 |
painter->setPen(frame->palette.color(QPalette::Mid));
|
|
2375 |
painter->drawRect(frameV2.rect.adjusted(0, 0, -2, -2));
|
|
2376 |
painter->setPen(Qt::white);
|
|
2377 |
painter->drawRect(frameV2.rect.adjusted(1, 1, -1, -1));
|
|
2378 |
painter->setPen(frameV2.palette.color(QPalette::Active,
|
|
2379 |
QPalette::Background));
|
|
2380 |
painter->drawLine(frameV2.rect.bottomLeft(),
|
|
2381 |
frameV2.rect.bottomLeft() + QPoint(1, -1));
|
|
2382 |
painter->drawLine(frameV2.rect.topRight(),
|
|
2383 |
frameV2.rect.topRight() + QPoint(-1, 1));
|
|
2384 |
break;
|
|
2385 |
}
|
|
2386 |
case PE_FrameFocusRect: {
|
|
2387 |
painter->setPen(option->palette.color(QPalette::Light));
|
|
2388 |
painter->setBrush(Qt::NoBrush);
|
|
2389 |
QRect rect = option->rect;
|
|
2390 |
rect = rect.adjusted(0,0, -1, -1);
|
|
2391 |
painter->drawRect(rect);
|
|
2392 |
break;
|
|
2393 |
}
|
|
2394 |
default:
|
|
2395 |
QWindowsStyle::drawPrimitive(element, option, painter, widget);
|
|
2396 |
}
|
|
2397 |
painter->restore();
|
|
2398 |
}
|
|
2399 |
|
|
2400 |
//! [1]
|
|
2401 |
void JavaStyle::drawButtonBackground(const QStyleOption *option,
|
|
2402 |
QPainter *painter, bool isCheckbox) const
|
|
2403 |
{
|
|
2404 |
QBrush buttonBrush = option->palette.button();
|
|
2405 |
bool sunken = option->state & State_Sunken;
|
|
2406 |
bool disabled = !(option->state & State_Enabled);
|
|
2407 |
bool on = option->state & State_On;
|
|
2408 |
|
|
2409 |
if (!sunken && !disabled && (!on || isCheckbox))
|
|
2410 |
buttonBrush = gradientBrush(option->rect);
|
|
2411 |
|
|
2412 |
painter->fillRect(option->rect, buttonBrush);
|
|
2413 |
|
|
2414 |
QRect rect = option->rect.adjusted(0, 0, -1, -1);
|
|
2415 |
|
|
2416 |
if (disabled)
|
|
2417 |
painter->setPen(option->palette.color(QPalette::Disabled,
|
|
2418 |
QPalette::WindowText));
|
|
2419 |
else
|
|
2420 |
painter->setPen(option->palette.color(QPalette::Mid));
|
|
2421 |
|
|
2422 |
painter->drawRect(rect);
|
|
2423 |
|
|
2424 |
if (sunken && !disabled) {
|
|
2425 |
drawSunkenButtonShadow(painter, rect,
|
|
2426 |
option->palette.color(QPalette::Mid),
|
|
2427 |
option->direction == Qt::RightToLeft);
|
|
2428 |
}
|
|
2429 |
}
|
|
2430 |
//! [1]
|
|
2431 |
|
|
2432 |
QBrush JavaStyle::gradientBrush(const QRect &rect) const
|
|
2433 |
{
|
|
2434 |
QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
|
|
2435 |
gradient.setColorAt(1.0, QColor(188, 210, 230));
|
|
2436 |
gradient.setColorAt(0.3, Qt::white);
|
|
2437 |
gradient.setColorAt(0.0, QColor(223, 233, 243));
|
|
2438 |
|
|
2439 |
return QBrush(gradient);
|
|
2440 |
}
|
|
2441 |
|
|
2442 |
QRect JavaStyle::subElementRect(SubElement element,
|
|
2443 |
const QStyleOption *option,
|
|
2444 |
const QWidget *widget) const
|
|
2445 |
{
|
|
2446 |
QRect rect;
|
|
2447 |
|
|
2448 |
switch (element) {
|
|
2449 |
case SE_ToolBoxTabContents: {
|
|
2450 |
const QStyleOptionToolBox *box =
|
|
2451 |
qstyleoption_cast<const QStyleOptionToolBox *>(option);
|
|
2452 |
|
|
2453 |
rect.moveTopLeft(box->rect.topLeft() + QPoint(0, 2));
|
|
2454 |
rect.setHeight(box->rect.height() - 4);
|
|
2455 |
rect.setWidth(box->fontMetrics.width(box->text) + 15);
|
|
2456 |
break;
|
|
2457 |
}
|
|
2458 |
case SE_ProgressBarLabel:
|
|
2459 |
case SE_ProgressBarGroove:
|
|
2460 |
case SE_ProgressBarContents: {
|
|
2461 |
rect = option->rect.adjusted(1, 1, -1, -1);
|
|
2462 |
break;
|
|
2463 |
}
|
|
2464 |
case SE_PushButtonFocusRect: {
|
|
2465 |
const QStyleOptionButton *btn =
|
|
2466 |
qstyleoption_cast<const QStyleOptionButton *>(option);
|
|
2467 |
|
|
2468 |
rect = btn->fontMetrics.boundingRect(btn->text);
|
|
2469 |
rect = QRect(0, 0, btn->fontMetrics.width(btn->text),
|
|
2470 |
rect.height());
|
|
2471 |
|
|
2472 |
if (!btn->icon.isNull()) {
|
|
2473 |
rect.adjust(0, 0, btn->iconSize.width(), btn->iconSize.height()
|
|
2474 |
> rect.height() ? btn->iconSize.height() - rect.height() : 0);
|
|
2475 |
rect.translate(-btn->iconSize.width(), 0);
|
|
2476 |
rect.adjust(-1, -1, 1, 1);
|
|
2477 |
}
|
|
2478 |
rect = QRect(int(ceil((btn->rect.width() - rect.width()) / 2.0)),
|
|
2479 |
int(ceil((btn->rect.height() - rect.height()) / 2.0)),
|
|
2480 |
rect.width() - 1, rect.height());
|
|
2481 |
rect.adjust(-1, 0, 1, 0);
|
|
2482 |
|
|
2483 |
break;
|
|
2484 |
}
|
|
2485 |
default:
|
|
2486 |
rect = QWindowsStyle::subElementRect(element, option, widget);
|
|
2487 |
}
|
|
2488 |
return rect;
|
|
2489 |
}
|
|
2490 |
|
|
2491 |
int JavaStyle::pixelMetric(PixelMetric metric,
|
|
2492 |
const QStyleOption* /* option */,
|
|
2493 |
const QWidget* /*widget*/) const
|
|
2494 |
{
|
|
2495 |
int value = 0;
|
|
2496 |
|
|
2497 |
switch (metric) {
|
|
2498 |
case PM_ButtonShiftHorizontal:
|
|
2499 |
case PM_ButtonShiftVertical:
|
|
2500 |
case PM_TabBarTabShiftHorizontal:
|
|
2501 |
case PM_ButtonDefaultIndicator:
|
|
2502 |
case PM_TabBarTabShiftVertical:
|
|
2503 |
value = 0;
|
|
2504 |
break;
|
|
2505 |
case PM_TabBarBaseOverlap:
|
|
2506 |
case PM_DefaultFrameWidth:
|
|
2507 |
value = 2;
|
|
2508 |
break;
|
|
2509 |
case PM_TabBarTabVSpace:
|
|
2510 |
value = 4;
|
|
2511 |
break;
|
|
2512 |
case PM_ScrollBarExtent:
|
|
2513 |
value = 16;
|
|
2514 |
break;
|
|
2515 |
case PM_ScrollBarSliderMin:
|
|
2516 |
value = 26;
|
|
2517 |
break;
|
|
2518 |
case PM_SplitterWidth:
|
|
2519 |
value = 8;
|
|
2520 |
break;
|
|
2521 |
case PM_SliderThickness:
|
|
2522 |
value = 16;
|
|
2523 |
break;
|
|
2524 |
case PM_SliderControlThickness:
|
|
2525 |
value = 16;
|
|
2526 |
break;
|
|
2527 |
case PM_SliderTickmarkOffset:
|
|
2528 |
value = 10;
|
|
2529 |
break;
|
|
2530 |
case PM_SliderSpaceAvailable:
|
|
2531 |
break;
|
|
2532 |
case PM_MenuPanelWidth:
|
|
2533 |
value = 1;
|
|
2534 |
break;
|
|
2535 |
case PM_MenuVMargin:
|
|
2536 |
value = 2;
|
|
2537 |
break;
|
|
2538 |
case PM_MenuBarPanelWidth:
|
|
2539 |
value = 1;
|
|
2540 |
break;
|
|
2541 |
case PM_MenuBarItemSpacing:
|
|
2542 |
value = 0;
|
|
2543 |
break;
|
|
2544 |
case PM_MenuBarHMargin:
|
|
2545 |
value = 3;
|
|
2546 |
break;
|
|
2547 |
case PM_MenuBarVMargin:
|
|
2548 |
value = 0;
|
|
2549 |
break;
|
|
2550 |
case PM_ComboBoxFrameWidth:
|
|
2551 |
value = 1;
|
|
2552 |
break;
|
|
2553 |
case PM_MenuButtonIndicator:
|
|
2554 |
value = 15;
|
|
2555 |
break;
|
|
2556 |
case PM_ToolBarItemMargin:
|
|
2557 |
value = 3;
|
|
2558 |
break;
|
|
2559 |
case PM_ToolBarHandleExtent:
|
|
2560 |
value = 13;
|
|
2561 |
break;
|
|
2562 |
case PM_SpinBoxFrameWidth:
|
|
2563 |
value = 2;
|
|
2564 |
break;
|
|
2565 |
case PM_TitleBarHeight: {
|
|
2566 |
value = 21;
|
|
2567 |
break;
|
|
2568 |
case PM_MDIFrameWidth:
|
|
2569 |
value = 6;
|
|
2570 |
break;
|
|
2571 |
}
|
|
2572 |
case PM_DockWidgetFrameWidth: {
|
|
2573 |
value = 5;
|
|
2574 |
break;
|
|
2575 |
}
|
|
2576 |
default:
|
|
2577 |
value = QWindowsStyle::pixelMetric(metric);
|
|
2578 |
}
|
|
2579 |
return value;
|
|
2580 |
}
|
|
2581 |
|
|
2582 |
|
|
2583 |
int JavaStyle::styleHint(StyleHint hint, const QStyleOption *option,
|
|
2584 |
const QWidget *widget,
|
|
2585 |
QStyleHintReturn *returnData) const
|
|
2586 |
{
|
|
2587 |
int ret;
|
|
2588 |
|
|
2589 |
switch (hint) {
|
|
2590 |
case SH_Table_GridLineColor: {
|
|
2591 |
ret = static_cast<int>(option->palette.color(QPalette::Mid).rgb());
|
|
2592 |
break;
|
|
2593 |
}
|
|
2594 |
case QStyle::SH_Menu_Scrollable:
|
|
2595 |
ret = 1;
|
|
2596 |
break;
|
|
2597 |
default:
|
|
2598 |
ret = QWindowsStyle::styleHint(hint, option, widget, returnData);
|
|
2599 |
}
|
|
2600 |
return ret;
|
|
2601 |
}
|
|
2602 |
|
|
2603 |
QPixmap JavaStyle::standardPixmap(StandardPixmap standardPixmap,
|
|
2604 |
const QStyleOption *option,
|
|
2605 |
const QWidget *widget) const
|
|
2606 |
{
|
|
2607 |
QPixmap pixmap = QWindowsStyle::standardPixmap(standardPixmap, option,
|
|
2608 |
widget);
|
|
2609 |
|
|
2610 |
QPixmap maximizePixmap(":/images/internalmaximize.png");
|
|
2611 |
QPixmap minimizePixmap(":/images/internalminimize.png");
|
|
2612 |
QPixmap closePixmap(":/images/internalclose.png");
|
|
2613 |
QPixmap internalPixmap(":/images/internalsystem.png");
|
|
2614 |
QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
|
|
2615 |
QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
|
|
2616 |
QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
|
|
2617 |
QPixmap dirOpenPixmap(":/images/open24.png");
|
|
2618 |
QPixmap filePixmap(":/images/file.png");
|
|
2619 |
|
|
2620 |
switch (standardPixmap) {
|
|
2621 |
case SP_DirLinkIcon:
|
|
2622 |
case SP_DirClosedIcon:
|
|
2623 |
case SP_DirIcon:
|
|
2624 |
case SP_DirOpenIcon: {
|
|
2625 |
pixmap = closePixmap;
|
|
2626 |
break;
|
|
2627 |
}
|
|
2628 |
case SP_FileIcon: {
|
|
2629 |
pixmap = filePixmap;
|
|
2630 |
break;
|
|
2631 |
}
|
|
2632 |
case SP_FileDialogBack: {
|
|
2633 |
pixmap = QPixmap(":/images/fileback.png");
|
|
2634 |
break;
|
|
2635 |
}
|
|
2636 |
case SP_FileDialogToParent: {
|
|
2637 |
pixmap = QPixmap(":/images/fileparent.png");
|
|
2638 |
break;
|
|
2639 |
}
|
|
2640 |
case SP_FileDialogNewFolder: {
|
|
2641 |
pixmap = QPixmap(":/images/open24.png");
|
|
2642 |
break;
|
|
2643 |
}
|
|
2644 |
case SP_FileDialogListView: {
|
|
2645 |
pixmap = QPixmap(":/images/filelist.png");
|
|
2646 |
break;
|
|
2647 |
}
|
|
2648 |
case SP_FileDialogDetailedView: {
|
|
2649 |
pixmap = QPixmap(":/images/filedetail.png");
|
|
2650 |
break;
|
|
2651 |
}
|
|
2652 |
case SP_MessageBoxInformation: {
|
|
2653 |
pixmap = QPixmap(":/images/information.png");
|
|
2654 |
break;
|
|
2655 |
}
|
|
2656 |
case SP_MessageBoxWarning: {
|
|
2657 |
pixmap = QPixmap(":/images/warning.png");
|
|
2658 |
}
|
|
2659 |
case SP_MessageBoxCritical: {
|
|
2660 |
pixmap = QPixmap(":/images/critical.png");
|
|
2661 |
break;
|
|
2662 |
}
|
|
2663 |
case SP_MessageBoxQuestion: {
|
|
2664 |
pixmap = QPixmap(":/images/question.png");
|
|
2665 |
break;
|
|
2666 |
}
|
|
2667 |
case SP_TitleBarNormalButton:
|
|
2668 |
pixmap = maximizePixmap;
|
|
2669 |
break;
|
|
2670 |
case SP_TitleBarCloseButton:
|
|
2671 |
pixmap = closePixmap;
|
|
2672 |
break;
|
|
2673 |
default:
|
|
2674 |
;
|
|
2675 |
}
|
|
2676 |
|
|
2677 |
return pixmap;
|
|
2678 |
}
|
|
2679 |
|
|
2680 |
QSize JavaStyle::sizeFromContents(ContentsType type,
|
|
2681 |
const QStyleOption *option,
|
|
2682 |
const QSize &contentsSize,
|
|
2683 |
const QWidget *widget) const
|
|
2684 |
{
|
|
2685 |
switch (type) {
|
|
2686 |
case CT_ComboBox: {
|
|
2687 |
return QSize(contentsSize.width() + 27, contentsSize.height());
|
|
2688 |
}
|
|
2689 |
case CT_Slider: {
|
|
2690 |
const QStyleOptionSlider *slider =
|
|
2691 |
qstyleoption_cast<const QStyleOptionSlider *>(option);
|
|
2692 |
if (slider->tickPosition == QSlider::TicksBelow) {
|
|
2693 |
return QSize(contentsSize.width(), contentsSize.height() + 15);
|
|
2694 |
} else {
|
|
2695 |
return contentsSize;
|
|
2696 |
}
|
|
2697 |
}
|
|
2698 |
case CT_MenuBarItem: {
|
|
2699 |
const QStyleOptionMenuItem *menuItem =
|
|
2700 |
qstyleoption_cast<const QStyleOptionMenuItem *>(option);
|
|
2701 |
QFontMetrics metrics(menuItem->font);
|
|
2702 |
QRect boundingRect = metrics.boundingRect(menuItem->text);
|
|
2703 |
int width = boundingRect.width() + 14;
|
|
2704 |
int height = boundingRect.height() + 3;
|
|
2705 |
if (height < 20)
|
|
2706 |
height = 20;
|
|
2707 |
|
|
2708 |
return QSize(width, height);
|
|
2709 |
}
|
|
2710 |
case CT_MenuItem: {
|
|
2711 |
const QStyleOptionMenuItem *menuItem =
|
|
2712 |
qstyleoption_cast<const QStyleOptionMenuItem *>(option);
|
|
2713 |
QSize defaultSize = QWindowsStyle::sizeFromContents(type, option,
|
|
2714 |
contentsSize, widget);
|
|
2715 |
|
|
2716 |
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator)
|
|
2717 |
return defaultSize;
|
|
2718 |
|
|
2719 |
int width = 30;
|
|
2720 |
int height = 0;
|
|
2721 |
|
|
2722 |
if (!menuItem->icon.isNull()) {
|
|
2723 |
width += 20;
|
|
2724 |
height += 20;
|
|
2725 |
}
|
|
2726 |
if (!menuItem->text.isEmpty()) {
|
|
2727 |
QFontMetrics metrics(menuItem->font);
|
|
2728 |
QString text = menuItem->text;
|
|
2729 |
text.remove(QLatin1Char('\t'));
|
|
2730 |
QRect textRect = metrics.boundingRect(text);
|
|
2731 |
width += textRect.width();
|
|
2732 |
if (height < textRect.height())
|
|
2733 |
height += textRect.height();
|
|
2734 |
}
|
|
2735 |
if (menuItem->checkType != QStyleOptionMenuItem::NotCheckable) {
|
|
2736 |
width += 10;
|
|
2737 |
if (height < 10)
|
|
2738 |
height = 10;
|
|
2739 |
}
|
|
2740 |
return QSize(width, height);
|
|
2741 |
}
|
|
2742 |
default:
|
|
2743 |
return QWindowsStyle::sizeFromContents(type, option, contentsSize,
|
|
2744 |
widget);
|
|
2745 |
}
|
|
2746 |
}
|