summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qcommonstyle.cpp17
-rw-r--r--src/gui/styles/qs60style.cpp20
-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, 37 insertions, 36 deletions
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 4c9541b..4d3272c 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_PI / 2;
+ a = Q_PI2;
else if (dial->dialWrapping)
- a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
+ a = Q_PI2 * 3 - (currentSliderPosition - dial->minimum) * Q_2PI
/ (dial->maximum - dial->minimum);
else
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
@@ -3087,12 +3087,13 @@ static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a)
int back = len / 2;
QPolygonF arrow(3);
- 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));
+ 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));
return arrow;
}
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index b5e92c7..eeaf7e8 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -579,7 +579,7 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
#if 0
painter->save();
- painter->setOpacity(.3);
+ painter->setOpacity(qreal(.3));
painter->fillRect(startRect, Qt::red);
painter->fillRect(middleRect, Qt::green);
painter->fillRect(endRect, Qt::blue);
@@ -1624,7 +1624,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) ? 1.0
+ const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? qreal(1.0)
: (qreal)optionProgressBar->progress / optionProgressBar->maximum;
if (optionProgressBar->orientation == Qt::Horizontal) {
progressRect.setWidth(int(progressRect.width() * progressFactor));
@@ -1749,7 +1749,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
optionMenuItem.palette.setColor(QPalette::Disabled, QPalette::Text, QS60StylePrivate::lighterColor(
optionMenuItem.palette.color(QPalette::Disabled, QPalette::Text)));
painter->save();
- painter->setOpacity(0.5);
+ painter->setOpacity(qreal(0.75));
}
QCommonStyle::drawItemText(painter, textRect, text_flags,
optionMenuItem.palette, enabled,
@@ -1855,7 +1855,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->save();
if (widget)
painter->setBrush(widget->palette().button());
- painter->setOpacity(0.3);
+ painter->setOpacity(qreal(0.3));
painter->fillRect(toolBar->rect, painter->brush());
painter->restore();
}
@@ -1912,12 +1912,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (focusFrame->widget() && focusFrame->widget()->hasEditFocus())
editFocus = true;
}
- const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve.
+ const qreal opacity = editFocus ? qreal(0.65) : qreal(0.45); // Trial and error factors. Feel free to improve.
#else
- const qreal opacity = 0.5;
+ const qreal opacity = qreal(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) ? -.5 : 0;
+ const qreal rectAdjustment = (penWidth % 2) ? qreal(-.5) : 0;
// Make sure that the pen stroke is inside the rect
const QRectF adjustedRect =
@@ -1941,7 +1941,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(0.5);
+ painter->setOpacity(qreal(0.5));
painter->setBrush(d->themePalette()->light());
painter->setRenderHint(QPainter::Antialiasing);
const qreal roundRectRadius = 4 * goldenRatio;
@@ -2019,8 +2019,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()/3.0;
- const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0;
+ const qreal reduceWidth = (qreal)buttonRect.width()/qreal(3.0);
+ const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : qreal(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 ec238a9..6733209 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) {
- double dpos = (double(p))/(double(range)/span);
+ qreal dpos = (qreal(p))/(qreal(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 af30f15..5b6f72f 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_PI / 2;
+ a = Q_PI2;
else if (dial->dialWrapping)
- a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI
+ a = Q_PI2 * 3 - (currentSliderPosition - dial->minimum) * Q_2PI
/ (dial->maximum - dial->minimum);
else
a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI
/ (dial->maximum - dial->minimum)) / 6;
- qreal xc = width / 2.0;
- qreal yc = height / 2.0;
+ const qreal xc = width * qreal(0.5);
+ const qreal yc = height * qreal(0.5);
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 = 180 / Q_PI;
+ static const qreal rad_factor = Q_PI180;
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_PI * 3 / 2 - i * 2 * Q_PI / notches
+ qreal angle = dial->dialWrapping ? Q_PI2 * 3 - i * Q_2PI / 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/20.0;
+ const qreal penSize = r/qreal(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 + 0.5, dy + 0.5,
+ QRectF br = QRectF(dx + qreal(0.5), dy + qreal(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
- qreal shadowSize = qMax(1.0, penSize/2.0);
+ const qreal shadowSize = qMax(qreal(1.0), penSize * qreal(0.5));
QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize,
2*shadowSize, 2*shadowSize);
QRadialGradient shadowGradient(shadowRect.center().x(),
- shadowRect.center().y(), shadowRect.width()/2.0,
+ shadowRect.center().y(), shadowRect.width() * qreal(0.5),
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()*1.3, br.center().x(),
+ br.width()*qreal(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, 2.0));
+ p->setPen(QPen(highlight, qreal(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 > 3.0) {
+ if (penSize > qreal(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 ce73fd8..1c24a03 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]/2.0;
+ qreal curY = rect.y() + borders[TopEdge]*qreal(0.5);
path.moveTo(rect.x() + tlr.width(), curY);
path.lineTo(rect.right() - trr.width(), curY);
- qreal curX = rect.right() - borders[RightEdge]/2.0;
+ qreal curX = rect.right() - borders[RightEdge]*qreal(0.5);
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]/2.0;
+ curY = rect.bottom() - borders[BottomEdge]*qreal(0.5);
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]/2.0;
+ curX = rect.left() + borders[LeftEdge]*qreal(0.5);
path.arcTo(curX, rect.bottom() - 2*blr.height() + borders[BottomEdge]/2,
blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90);