diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-11-28 06:40:59 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-11-28 08:10:29 +0200 |
commit | 5fde532408da5b6b3ddef13aff5e07f32015e7d9 (patch) | |
tree | 8a243126c37a92be3ca14734adc5074a9642c129 /src/datavisualization/utils | |
parent | 964897e316c0fd524cba3a3cbb3c32fad53f965a (diff) |
Visual properties moved to theme
Task-number: QTRD-2632
Change-Id: I91eaa8fa26e232de24fe89ef0c8a2fc53f31fb8c
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/utils')
-rw-r--r-- | src/datavisualization/utils/utils.cpp | 34 | ||||
-rw-r--r-- | src/datavisualization/utils/utils_p.h | 2 |
2 files changed, 6 insertions, 30 deletions
diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index ce033dc0..2adc9409 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -45,7 +45,7 @@ QVector3D Utils::vectorFromColor(const QColor &color) } QImage Utils::printTextToImage(const QFont &font, const QString &text, const QColor &bgrColor, - const QColor &txtColor, QDataVis::LabelStyle style, + const QColor &txtColor, bool labelBackground, bool borders, int maxLabelWidth) { GLuint paddingWidth = 20; @@ -55,7 +55,7 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo valueFont.setPointSize(textureFontSize); QFontMetrics valueFM(valueFont); int valueStrWidth = valueFM.width(text); - if (maxLabelWidth && QDataVis::LabelStyleTransparent != style) + if (maxLabelWidth && !labelBackground) valueStrWidth = maxLabelWidth; int valueStrHeight = valueFM.height(); valueStrWidth += paddingWidth / 2; // Fix clipping problem with skewed fonts (italic or italic-style) @@ -74,7 +74,7 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo labelSize.setHeight(getNearestPowerOfTwo(labelSize.height(), paddingHeight)); //qDebug() << "label size after padding" << labelSize << paddingWidth << paddingHeight; #else - if (QDataVis::LabelStyleTransparent == style) + if (!labelBackground) labelSize = QSize(valueStrWidth, valueStrHeight); else labelSize = QSize(valueStrWidth + paddingWidth * 2, valueStrHeight + paddingHeight * 2); @@ -90,8 +90,7 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo painter.setRenderHint(QPainter::Antialiasing, true); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.setFont(valueFont); - switch (style) { - case QDataVis::LabelStyleTransparent: { + if (!labelBackground) { painter.setPen(txtColor); #if defined(Q_OS_ANDROID) painter.drawText((labelSize.width() - valueStrWidth) / 2.0f, @@ -105,9 +104,7 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo Qt::AlignCenter | Qt::AlignVCenter, text); #endif - break; - } - case QDataVis::LabelStyleFromTheme: { + } else { painter.setBrush(QBrush(bgrColor)); if (borders) { painter.setPen(QPen(QBrush(txtColor), 5, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin)); @@ -123,27 +120,6 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo valueStrWidth, valueStrHeight, Qt::AlignCenter | Qt::AlignVCenter, text); - break; - } - case QDataVis::LabelStyleOpaque: { - QColor labelColor = QColor(bgrColor); - labelColor.setAlphaF(1.0); - painter.setBrush(QBrush(labelColor)); - if (borders) { - painter.setPen(QPen(QBrush(txtColor), 7, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin)); - painter.drawRect(7, 7, labelSize.width() - 14, labelSize.height() - 14); - } else { - painter.setPen(labelColor); - painter.drawRect(0, 0, labelSize.width(), labelSize.height()); - } - painter.setPen(txtColor); - painter.drawText((labelSize.width() - valueStrWidth) / 2.0f, - (labelSize.height() - valueStrHeight) / 2.0f, - valueStrWidth, valueStrHeight, - Qt::AlignCenter | Qt::AlignVCenter, - text); - break; - } } return image; } diff --git a/src/datavisualization/utils/utils_p.h b/src/datavisualization/utils/utils_p.h index 4d09a639..b713db94 100644 --- a/src/datavisualization/utils/utils_p.h +++ b/src/datavisualization/utils/utils_p.h @@ -59,7 +59,7 @@ public: const QString &text, const QColor &bgrColor, const QColor &txtColor, - QDataVis::LabelStyle style, + bool labelBackground, bool borders = false, int maxLabelWidth = 0); static QVector3D getSelection(QPoint mousepos, int height); |