summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-09-02 20:54:59 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-09-04 21:27:50 +0200
commit8478fc4e597101e183b94162a1e5b57de71820a1 (patch)
tree8026badd243ad6c3c5b89391e29f76f738027be5 /src/widgets/styles
parente192643c2dbc9228b4057661bf58945195836206 (diff)
QCommonStyle: replace a QPolygon with a QPoint[] (III)
No need to allocate dynamic memory for a fixed-size point array when QPainter has a (QPoint*,int) overload. Change-Id: Ie1eecd376a52b73572998ba253a032deaa0daaf9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 1657879852..5c0362b830 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1645,30 +1645,33 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
break;
case CE_ToolBoxTabShape:
if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
+ p->setPen(tb->palette.mid().color().darker(150));
+ bool oldQt4CompatiblePainting = p->testRenderHint(QPainter::Qt4CompatiblePainting);
+ p->setRenderHint(QPainter::Qt4CompatiblePainting);
int d = 20 + tb->rect.height() - 3;
- QPolygon a(7);
if (tb->direction != Qt::RightToLeft) {
- a.setPoint(0, -1, tb->rect.height() + 1);
- a.setPoint(1, -1, 1);
- a.setPoint(2, tb->rect.width() - d, 1);
- a.setPoint(3, tb->rect.width() - 20, tb->rect.height() - 2);
- a.setPoint(4, tb->rect.width() - 1, tb->rect.height() - 2);
- a.setPoint(5, tb->rect.width() - 1, tb->rect.height() + 1);
- a.setPoint(6, -1, tb->rect.height() + 1);
+ const QPoint points[] = {
+ QPoint(-1, tb->rect.height() + 1),
+ QPoint(-1, 1),
+ QPoint(tb->rect.width() - d, 1),
+ QPoint(tb->rect.width() - 20, tb->rect.height() - 2),
+ QPoint(tb->rect.width() - 1, tb->rect.height() - 2),
+ QPoint(tb->rect.width() - 1, tb->rect.height() + 1),
+ QPoint(-1, tb->rect.height() + 1),
+ };
+ p->drawPolygon(points, sizeof points / sizeof *points);
} else {
- a.setPoint(0, tb->rect.width(), tb->rect.height() + 1);
- a.setPoint(1, tb->rect.width(), 1);
- a.setPoint(2, d - 1, 1);
- a.setPoint(3, 20 - 1, tb->rect.height() - 2);
- a.setPoint(4, 0, tb->rect.height() - 2);
- a.setPoint(5, 0, tb->rect.height() + 1);
- a.setPoint(6, tb->rect.width(), tb->rect.height() + 1);
+ const QPoint points[] = {
+ QPoint(tb->rect.width(), tb->rect.height() + 1),
+ QPoint(tb->rect.width(), 1),
+ QPoint(d - 1, 1),
+ QPoint(20 - 1, tb->rect.height() - 2),
+ QPoint(0, tb->rect.height() - 2),
+ QPoint(0, tb->rect.height() + 1),
+ QPoint(tb->rect.width(), tb->rect.height() + 1),
+ };
+ p->drawPolygon(points, sizeof points / sizeof *points);
}
-
- p->setPen(tb->palette.mid().color().darker(150));
- bool oldQt4CompatiblePainting = p->testRenderHint(QPainter::Qt4CompatiblePainting);
- p->setRenderHint(QPainter::Qt4CompatiblePainting);
- p->drawPolygon(a);
p->setRenderHint(QPainter::Qt4CompatiblePainting, oldQt4CompatiblePainting);
p->setPen(tb->palette.light().color());
if (tb->direction != Qt::RightToLeft) {