summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-11-10 20:04:41 (GMT)
committerAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-11-11 12:47:42 (GMT)
commit72c170b64056a59dce9f849a5789d2968071f7b9 (patch)
tree0fe45271f034f845b3f3cf7ceeeb856c1b52f3bd /src/gui/styles
parentc327076817dad875bd057bf28eab36b1d4e732ef (diff)
downloadQt-72c170b64056a59dce9f849a5789d2968071f7b9.zip
Qt-72c170b64056a59dce9f849a5789d2968071f7b9.tar.gz
Qt-72c170b64056a59dce9f849a5789d2968071f7b9.tar.bz2
Revert "Using qreal more consistently in code (prevent misuse of double)"
This reverts commit 676780d515cedca85829ae962e4f501c5e5b6581. Conflicts: src/gui/painting/qblendfunctions.cpp
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qcommonstyle.cpp17
-rw-r--r--src/gui/styles/qs60style.cpp16
-rw-r--r--src/gui/styles/qstyle.cpp2
-rw-r--r--src/gui/styles/qstylehelper.cpp26
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp8
5 files changed, 34 insertions, 35 deletions
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 4d3272c..4c9541b 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -3070,9 +3070,9 @@ static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a)
int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
if (dial->maximum == dial->minimum)
- a = Q_PI2;
+ a = Q_PI / 2;
else if (dial->dialWrapping)
- a = Q_PI2 * 3 - (currentSliderPosition - dial->minimum) * Q_2PI
+ a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
/ (dial->maximum - dial->minimum);
else
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
@@ -3087,13 +3087,12 @@ static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a)
int back = len / 2;
QPolygonF arrow(3);
- const qreal five_div_by_six = 5 / 6;
- arrow[0] = QPointF(qreal(0.5) + xc + len * qCos(a),
- qreal(0.5) + yc - len * qSin(a));
- arrow[1] = QPointF(qreal(0.5) + xc + back * qCos(a + Q_PI * five_div_by_six),
- qreal(0.5) + yc - back * qSin(a + Q_PI * five_div_by_six));
- arrow[2] = QPointF(qreal(0.5) + xc + back * qCos(a - Q_PI * five_div_by_six),
- qreal(0.5) + yc - back * qSin(a - Q_PI * five_div_by_six));
+ arrow[0] = QPointF(0.5 + xc + len * qCos(a),
+ 0.5 + yc - len * qSin(a));
+ arrow[1] = QPointF(0.5 + xc + back * qCos(a + Q_PI * 5 / 6),
+ 0.5 + yc - back * qSin(a + Q_PI * 5 / 6));
+ arrow[2] = QPointF(0.5 + xc + back * qCos(a - Q_PI * 5 / 6),
+ 0.5 + yc - back * qSin(a - Q_PI * 5 / 6));
return arrow;
}
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 16a81b3..a1dab86 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -553,7 +553,7 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
#if 0
painter->save();
- painter->setOpacity(qreal(.3));
+ painter->setOpacity(.3);
painter->fillRect(startRect, Qt::red);
painter->fillRect(middleRect, Qt::green);
painter->fillRect(endRect, Qt::blue);
@@ -1598,7 +1598,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointWest;
QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWait, painter, progressRect, flags | orientationFlag);
} else {
- const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? qreal(1.0)
+ const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0
: (qreal)optionProgressBar->progress / optionProgressBar->maximum;
if (optionProgressBar->orientation == Qt::Horizontal) {
progressRect.setWidth(int(progressRect.width() * progressFactor));
@@ -1886,12 +1886,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (focusFrame->widget() && focusFrame->widget()->hasEditFocus())
editFocus = true;
}
- const qreal opacity = editFocus ? qreal(0.65) : qreal(0.45); // Trial and error factors. Feel free to improve.
+ const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve.
#else
- const qreal opacity = qreal(0.5);
+ const qreal opacity = 0.5;
#endif
// Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred.
- const qreal rectAdjustment = (penWidth % 2) ? qreal(-.5) : 0;
+ const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0;
// Make sure that the pen stroke is inside the rect
const QRectF adjustedRect =
@@ -1915,7 +1915,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
case CE_Splitter:
if (option->state & State_Sunken && option->state & State_Enabled) {
painter->save();
- painter->setOpacity(qreal(0.5));
+ painter->setOpacity(0.5);
painter->setBrush(d->themePalette()->light());
painter->setRenderHint(QPainter::Antialiasing);
const qreal roundRectRadius = 4 * goldenRatio;
@@ -1993,8 +1993,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorRadioButton: {
QRect buttonRect = option->rect;
//there is empty (a. 33%) space in svg graphics for radiobutton
- const qreal reduceWidth = (qreal)buttonRect.width()/qreal(3.0);
- const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : qreal(1.0);
+ const qreal reduceWidth = (qreal)buttonRect.width()/3.0;
+ const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0;
// Try to occupy the full area
const qreal scaler = 1 + (reduceWidth/rectWidth);
buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler));
diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp
index 6733209..ec238a9 100644
--- a/src/gui/styles/qstyle.cpp
+++ b/src/gui/styles/qstyle.cpp
@@ -2132,7 +2132,7 @@ int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span
uint p = upsideDown ? max - logicalValue : logicalValue - min;
if (range > (uint)INT_MAX/4096) {
- qreal dpos = (qreal(p))/(qreal(range)/span);
+ double dpos = (double(p))/(double(range)/span);
return int(dpos);
} else if (range > (uint)span) {
return (2 * p * span + range) / (2*range);
diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp
index 5b6f72f..af30f15 100644
--- a/src/gui/styles/qstylehelper.cpp
+++ b/src/gui/styles/qstylehelper.cpp
@@ -117,15 +117,15 @@ static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
const int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition);
qreal a = 0;
if (dial->maximum == dial->minimum)
- a = Q_PI2;
+ a = Q_PI / 2;
else if (dial->dialWrapping)
- a = Q_PI2 * 3 - (currentSliderPosition - dial->minimum) * Q_2PI
+ a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
/ (dial->maximum - dial->minimum);
else
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
/ (dial->maximum - dial->minimum)) / 6;
- const qreal xc = width * qreal(0.5);
- const qreal yc = height * qreal(0.5);
+ qreal xc = width / 2.0;
+ qreal yc = height / 2.0;
qreal len = r - QStyleHelper::calcBigLineSize(r) - 3;
qreal back = offset * len;
QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a)));
@@ -134,7 +134,7 @@ static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset)
qreal angle(const QPointF &p1, const QPointF &p2)
{
- static const qreal rad_factor = Q_PI180;
+ static const qreal rad_factor = 180 / Q_PI;
qreal _angle = 0;
if (p1.x() == p2.x()) {
@@ -186,7 +186,7 @@ QPolygonF calcLines(const QStyleOptionSlider *dial)
poly.resize(2 + 2 * notches);
int smallLineSize = bigLineSize / 2;
for (int i = 0; i <= notches; ++i) {
- qreal angle = dial->dialWrapping ? Q_PI2 * 3 - i * Q_2PI / notches
+ qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches
: (Q_PI * 8 - i * 10 * Q_PI / notches) / 6;
qreal s = qSin(angle);
qreal c = qCos(angle);
@@ -215,7 +215,7 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
const bool enabled = option->state & QStyle::State_Enabled;
qreal r = qMin(width, height) / 2;
r -= r/50;
- const qreal penSize = r/qreal(20.0);
+ const qreal penSize = r/20.0;
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
@@ -234,7 +234,7 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1;
const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1;
- QRectF br = QRectF(dx + qreal(0.5), dy + qreal(0.5),
+ QRectF br = QRectF(dx + 0.5, dy + 0.5,
int(r * 2 - 2 * d_ - 2),
int(r * 2 - 2 * d_ - 2));
buttonColor.setHsv(buttonColor .hue(),
@@ -244,11 +244,11 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
if (enabled) {
// Drop shadow
- const qreal shadowSize = qMax(qreal(1.0), penSize * qreal(0.5));
+ qreal shadowSize = qMax(1.0, penSize/2.0);
QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
2*shadowSize, 2*shadowSize);
QRadialGradient shadowGradient(shadowRect.center().x(),
- shadowRect.center().y(), shadowRect.width() * qreal(0.5),
+ shadowRect.center().y(), shadowRect.width()/2.0,
shadowRect.center().x(), shadowRect.center().y());
shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40));
shadowGradient.setColorAt(qreal(1.0), Qt::transparent);
@@ -260,7 +260,7 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
// Main gradient
QRadialGradient gradient(br.center().x() - br.width()/3, dy,
- br.width()*qreal(1.3), br.center().x(),
+ br.width()*1.3, br.center().x(),
br.center().y() - br.height()/2);
gradient.setColorAt(0, buttonColor.lighter(110));
gradient.setColorAt(qreal(0.5), buttonColor);
@@ -283,7 +283,7 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
qMin(160, highlight.saturation()),
qMax(230, highlight.value()));
highlight.setAlpha(127);
- p->setPen(QPen(highlight, qreal(2.0)));
+ p->setPen(QPen(highlight, 2.0));
p->setBrush(Qt::NoBrush);
p->drawEllipse(br.adjusted(-1, -1, 1, 1));
}
@@ -302,7 +302,7 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
dialGradient.setColorAt(1, buttonColor.darker(140));
dialGradient.setColorAt(qreal(0.4), buttonColor.darker(120));
dialGradient.setColorAt(0, buttonColor.darker(110));
- if (penSize > qreal(3.0)) {
+ if (penSize > 3.0) {
painter->setPen(QPen(QColor(0, 0, 0, 25), penSize));
painter->drawLine(calcRadialPos(option, qreal(0.90)), calcRadialPos(option, qreal(0.96)));
}
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 1c24a03..ce73fd8 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1252,20 +1252,20 @@ QPainterPath QRenderRule::borderClip(QRect r)
const QRectF rect(r);
const int *borders = border()->borders;
QPainterPath path;
- qreal curY = rect.y() + borders[TopEdge]*qreal(0.5);
+ qreal curY = rect.y() + borders[TopEdge]/2.0;
path.moveTo(rect.x() + tlr.width(), curY);
path.lineTo(rect.right() - trr.width(), curY);
- qreal curX = rect.right() - borders[RightEdge]*qreal(0.5);
+ qreal curX = rect.right() - borders[RightEdge]/2.0;
path.arcTo(curX - 2*trr.width() + borders[RightEdge], curY,
trr.width()*2 - borders[RightEdge], trr.height()*2 - borders[TopEdge], 90, -90);
path.lineTo(curX, rect.bottom() - brr.height());
- curY = rect.bottom() - borders[BottomEdge]*qreal(0.5);
+ curY = rect.bottom() - borders[BottomEdge]/2.0;
path.arcTo(curX - 2*brr.width() + borders[RightEdge], curY - 2*brr.height() + borders[BottomEdge],
brr.width()*2 - borders[RightEdge], brr.height()*2 - borders[BottomEdge], 0, -90);
path.lineTo(rect.x() + blr.width(), curY);
- curX = rect.left() + borders[LeftEdge]*qreal(0.5);
+ curX = rect.left() + borders[LeftEdge]/2.0;
path.arcTo(curX, rect.bottom() - 2*blr.height() + borders[BottomEdge]/2,
blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90);