summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-02-16 08:54:58 +0100
committerLiang Qi <liang.qi@qt.io>2018-02-16 08:54:58 +0100
commit942ab490724fcc9544e786e5783718e1a07aa50b (patch)
treefeb7d3ff716edb37b2ca60e33c05adf8777bd964 /src/widgets/styles
parent0fb8271a467202990c90321066e40faed640a7a8 (diff)
parent24adaa9a742e6f95ff897d0eb9a2bce0527dd042 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/corelib/tools/tools.pri Change-Id: I705630f9cecbf0ce51a22fc6116b8c49611259e9
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qfusionstyle.cpp33
-rw-r--r--src/widgets/styles/qstylehelper.cpp8
-rw-r--r--src/widgets/styles/qstylehelper_p.h1
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp5
4 files changed, 21 insertions, 26 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 26f651906a..6873ca876e 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -763,7 +763,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
painter->drawRect(rect);
QColor checkMarkColor = option->palette.text().color().darker(120);
- const int checkMarkPadding = 1 + rect.width() * 0.2; // at least one pixel padding
+ const qreal checkMarkPadding = 1 + rect.width() * 0.13; // at least one pixel padding
if (checkbox->state & State_NoChange) {
gradient = QLinearGradient(rect.topLeft(), rect.bottomLeft());
@@ -776,21 +776,22 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
painter->setBrush(gradient);
painter->drawRect(rect.adjusted(checkMarkPadding, checkMarkPadding, -checkMarkPadding, -checkMarkPadding));
- } else if (checkbox->state & (State_On)) {
- qreal penWidth = QStyleHelper::dpiScaled(1.8);
- penWidth = qMax(penWidth , 0.18 * rect.height());
- penWidth = qMin(penWidth , 0.30 * rect.height());
+ } else if (checkbox->state & State_On) {
+ qreal penWidth = QStyleHelper::dpiScaled(1.5);
+ penWidth = qMax(penWidth , 0.13 * rect.height());
+ penWidth = qMin(penWidth , 0.20 * rect.height());
QPen checkPen = QPen(checkMarkColor, penWidth);
checkMarkColor.setAlpha(210);
- painter->translate(-0.8, 0.5);
+ painter->translate(dpiScaled(-0.8), dpiScaled(0.5));
painter->setPen(checkPen);
painter->setBrush(Qt::NoBrush);
// Draw checkmark
QPainterPath path;
- path.moveTo(1.33 * checkMarkPadding, rect.height() / 2.0);
- path.lineTo(rect.width() / 2.0, rect.height() - checkMarkPadding);
- path.lineTo(rect.width() - checkMarkPadding * 0.92, checkMarkPadding);
+ const qreal rectHeight = rect.height(); // assuming height equals width
+ path.moveTo(checkMarkPadding + rectHeight * 0.11, rectHeight * 0.47);
+ path.lineTo(rectHeight * 0.5, rectHeight - checkMarkPadding);
+ path.lineTo(rectHeight - checkMarkPadding, checkMarkPadding);
painter->drawPath(path.translated(rect.topLeft()));
}
}
@@ -1561,8 +1562,8 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
bool ignoreCheckMark = false;
const int checkColHOffset = windowsItemHMargin + windowsItemFrame - 1;
- int checkcol = qMax(menuItem->rect.height() * 0.7,
- qMax(menuItem->maxIconWidth * 1.0, dpiScaled(17))); // icon checkbox's highlihgt column width
+ int checkcol = qMax(menuItem->rect.height() * 0.79,
+ qMax(menuItem->maxIconWidth * 1.0, dpiScaled(21))); // icon checkbox's highlihgt column width
if (
#if QT_CONFIG(combobox)
qobject_cast<const QComboBox*>(widget) ||
@@ -1571,10 +1572,12 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate
if (!ignoreCheckMark) {
- // Check
- const int boxMargin = dpiScaled(4);
- const int boxWidth = checkcol - 2 * boxMargin;
- QRect checkRect(option->rect.left() + boxMargin + checkColHOffset, option->rect.center().y() - boxWidth/2 + 1, boxWidth, boxWidth);
+ // Check, using qreal and QRectF to avoid error accumulation
+ const qreal boxMargin = dpiScaled(3.5);
+ const qreal boxWidth = checkcol - 2 * boxMargin;
+ QRectF checkRectF(option->rect.left() + boxMargin + checkColHOffset, option->rect.center().y() - boxWidth/2 + 1, boxWidth, boxWidth);
+ QRect checkRect = checkRectF.toRect();
+ checkRect.setWidth(checkRect.height()); // avoid .toRect() round error results in non-perfect square
checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
if (checkable) {
if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 373699a7aa..8679d96eda 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -411,14 +411,6 @@ QWindow *styleObjectWindow(QObject *so)
return 0;
}
-void setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy)
-{
- QWidget *wadget = const_cast<QWidget *>(widget);
- wadget->setAttribute(Qt::WA_MacNormalSize, policy == SizeLarge);
- wadget->setAttribute(Qt::WA_MacSmallSize, policy == SizeSmall);
- wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini);
-}
-
WidgetSizePolicy widgetSizePolicy(const QWidget *widget, const QStyleOption *opt)
{
while (widget) {
diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h
index bd263cea7b..260860bf4d 100644
--- a/src/widgets/styles/qstylehelper_p.h
+++ b/src/widgets/styles/qstylehelper_p.h
@@ -94,7 +94,6 @@ namespace QStyleHelper
enum WidgetSizePolicy { SizeLarge = 0, SizeSmall = 1, SizeMini = 2, SizeDefault = -1 };
- void setWidgetSizePolicy(const QWidget *w, WidgetSizePolicy policy);
Q_WIDGETS_EXPORT WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = 0);
}
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 9ce1a04d86..e12aeb900b 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3968,10 +3968,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
x += reverse ? -chunkWidth : chunkWidth;
--chunkCount;
};
- } else {
+ } else if (chunkWidth > 0) {
+ const int chunkCount = ceil(qreal(fillWidth)/chunkWidth);
int x = reverse ? r.left() + r.width() - chunkWidth : r.x();
- for (int i = 0; i < ceil(qreal(fillWidth)/chunkWidth); ++i) {
+ for (int i = 0; i < chunkCount; ++i) {
r.setRect(x, rect.y(), chunkWidth, rect.height());
r = m.mapRect(QRectF(r)).toRect();
subRule.drawRule(p, r);