diff options
author | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2012-11-26 14:13:25 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-26 17:33:37 +0100 |
commit | 7c3fa5a292b36a058fec2d241f5eda2c350a29e9 (patch) | |
tree | ec1d7dd6af2aae5ca4adbace339608a5df2bbf41 /src/widgets/styles | |
parent | c00d4373c5d55b3bf4d23b3610a52a3a207780d1 (diff) |
Moving code for PE_IndicatorArrow* from windows to common style
If QCommonStyle is taking the place of a common base style,
it should support PE_IndicatorArrow*.
Change-Id: Iec08a37bf3a501bcca61751b11e907999f538e34
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 74 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 74 |
2 files changed, 74 insertions, 74 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 96a2078905..f25f035382 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -684,6 +684,80 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q const QBrush brush(opt->palette.brush(QPalette::Window)); p->fillRect(opt->rect, brush); } break; + case PE_IndicatorArrowUp: + case PE_IndicatorArrowDown: + case PE_IndicatorArrowRight: + case PE_IndicatorArrowLeft: + { + if (opt->rect.width() <= 1 || opt->rect.height() <= 1) + break; + QRect r = opt->rect; + int size = qMin(r.height(), r.width()); + QPixmap pixmap; + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + % QLatin1String(metaObject()->className()), opt, QSize(size, size)) + % HexString<uint>(pe); + if (!QPixmapCache::find(pixmapName, pixmap)) { + int border = size/5; + int sqsize = 2*(size/2); + QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied); + image.fill(0); + QPainter imagePainter(&image); + + QPolygon a; + switch (pe) { + case PE_IndicatorArrowUp: + a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2); + break; + case PE_IndicatorArrowDown: + a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2); + break; + case PE_IndicatorArrowRight: + a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border); + break; + case PE_IndicatorArrowLeft: + a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border); + break; + default: + break; + } + + int bsx = 0; + int bsy = 0; + + if (opt->state & State_Sunken) { + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget); + } + + QRect bounds = a.boundingRect(); + int sx = sqsize / 2 - bounds.center().x() - 1; + int sy = sqsize / 2 - bounds.center().y() - 1; + imagePainter.translate(sx + bsx, sy + bsy); + imagePainter.setPen(opt->palette.buttonText().color()); + imagePainter.setBrush(opt->palette.buttonText()); + imagePainter.setRenderHint(QPainter::Qt4CompatiblePainting); + + if (!(opt->state & State_Enabled)) { + imagePainter.translate(1, 1); + imagePainter.setBrush(opt->palette.light().color()); + imagePainter.setPen(opt->palette.light().color()); + imagePainter.drawPolygon(a); + imagePainter.translate(-1, -1); + imagePainter.setBrush(opt->palette.mid().color()); + imagePainter.setPen(opt->palette.mid().color()); + } + + imagePainter.drawPolygon(a); + imagePainter.end(); + pixmap = QPixmap::fromImage(image); + QPixmapCache::insert(pixmapName, pixmap); + } + int xOffset = r.x() + (r.width() - size)/2; + int yOffset = r.y() + (r.height() - size)/2; + p->drawPixmap(xOffset, yOffset, pixmap); + } + break; default: break; } diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 6a20f5e9d3..d1cd1f6d91 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -786,80 +786,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->setPen(oldPen); break; } - case PE_IndicatorArrowUp: - case PE_IndicatorArrowDown: - case PE_IndicatorArrowRight: - case PE_IndicatorArrowLeft: - { - if (opt->rect.width() <= 1 || opt->rect.height() <= 1) - break; - QRect r = opt->rect; - int size = qMin(r.height(), r.width()); - QPixmap pixmap; - QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") - % QLatin1String(metaObject()->className()), opt, QSize(size, size)) - % HexString<uint>(pe); - if (!QPixmapCache::find(pixmapName, pixmap)) { - int border = size/5; - int sqsize = 2*(size/2); - QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied); - image.fill(0); - QPainter imagePainter(&image); - - QPolygon a; - switch (pe) { - case PE_IndicatorArrowUp: - a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2); - break; - case PE_IndicatorArrowDown: - a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2); - break; - case PE_IndicatorArrowRight: - a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border); - break; - case PE_IndicatorArrowLeft: - a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border); - break; - default: - break; - } - - int bsx = 0; - int bsy = 0; - - if (opt->state & State_Sunken) { - bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w); - bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w); - } - - QRect bounds = a.boundingRect(); - int sx = sqsize / 2 - bounds.center().x() - 1; - int sy = sqsize / 2 - bounds.center().y() - 1; - imagePainter.translate(sx + bsx, sy + bsy); - imagePainter.setPen(opt->palette.buttonText().color()); - imagePainter.setBrush(opt->palette.buttonText()); - imagePainter.setRenderHint(QPainter::Qt4CompatiblePainting); - - if (!(opt->state & State_Enabled)) { - imagePainter.translate(1, 1); - imagePainter.setBrush(opt->palette.light().color()); - imagePainter.setPen(opt->palette.light().color()); - imagePainter.drawPolygon(a); - imagePainter.translate(-1, -1); - imagePainter.setBrush(opt->palette.mid().color()); - imagePainter.setPen(opt->palette.mid().color()); - } - - imagePainter.drawPolygon(a); - imagePainter.end(); - pixmap = QPixmap::fromImage(image); - QPixmapCache::insert(pixmapName, pixmap); - } - int xOffset = r.x() + (r.width() - size)/2; - int yOffset = r.y() + (r.height() - size)/2; - p->drawPixmap(xOffset, yOffset, pixmap); - } - break; case PE_IndicatorCheckBox: { QBrush fill; if (opt->state & State_NoChange) |