Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezestyle.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4457 Lines • ▼ Show 20 Line(s) | 4455 | if (!cb->currentIcon.isNull()) { | |||
---|---|---|---|---|---|
4458 | if ((cb->state & QStyle::State_Selected) && (cb->state & QStyle::State_Active)) { | 4458 | if ((cb->state & QStyle::State_Selected) && (cb->state & QStyle::State_Active)) { | ||
4459 | mode = QIcon::Selected; | 4459 | mode = QIcon::Selected; | ||
4460 | } else if (cb->state & QStyle::State_Enabled) { | 4460 | } else if (cb->state & QStyle::State_Enabled) { | ||
4461 | mode = QIcon::Normal; | 4461 | mode = QIcon::Normal; | ||
4462 | } else { | 4462 | } else { | ||
4463 | mode = QIcon::Disabled; | 4463 | mode = QIcon::Disabled; | ||
4464 | } | 4464 | } | ||
4465 | 4465 | | |||
4466 | QWindow *window = nullptr; | 4466 | const QPixmap pixmap = _helper->coloredIcon(cb->currentIcon,cb->palette, cb->iconSize, mode); | ||
4467 | if (widget && widget->window()) { | | |||
4468 | window = widget->window()->windowHandle(); | | |||
4469 | #if BREEZE_HAVE_QTQUICK | | |||
4470 | } else if (QQuickItem *quickItem = qobject_cast<QQuickItem *>(option->styleObject)) { | | |||
4471 | window = quickItem->window(); | | |||
4472 | #endif | | |||
4473 | } | | |||
4474 | | ||||
4475 | auto pixmap = _helper->coloredIcon(cb->currentIcon,cb->palette, cb->iconSize * window->devicePixelRatio(), mode); | | |||
4476 | pixmap.setDevicePixelRatio(window->devicePixelRatio()); | | |||
4477 | auto iconRect(editRect); | 4467 | auto iconRect(editRect); | ||
4478 | iconRect.setWidth(cb->iconSize.width() + 4); | 4468 | iconRect.setWidth(cb->iconSize.width() + 4); | ||
4479 | iconRect = alignedRect(cb->direction, | 4469 | iconRect = alignedRect(cb->direction, | ||
4480 | Qt::AlignLeft | Qt::AlignVCenter, | 4470 | Qt::AlignLeft | Qt::AlignVCenter, | ||
4481 | iconRect.size(), editRect); | 4471 | iconRect.size(), editRect); | ||
4482 | if (cb->editable) | 4472 | if (cb->editable) | ||
4483 | painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); | 4473 | painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); | ||
4484 | proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); | 4474 | proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); | ||
davidedmundson: ```
QPixmap Helper::coloredIcon(const QIcon& icon, const QPalette& palette, const QSize… | |||||
4485 | 4475 | | |||
4486 | if (cb->direction == Qt::RightToLeft) | 4476 | if (cb->direction == Qt::RightToLeft) | ||
4487 | editRect.translate(-4 - cb->iconSize.width(), 0); | 4477 | editRect.translate(-4 - cb->iconSize.width(), 0); | ||
4488 | else | 4478 | else | ||
4489 | editRect.translate(cb->iconSize.width() + 4, 0); | 4479 | editRect.translate(cb->iconSize.width() + 4, 0); | ||
4490 | } | 4480 | } | ||
4491 | if (!cb->currentText.isEmpty() && !cb->editable) { | 4481 | if (!cb->currentText.isEmpty() && !cb->editable) { | ||
4492 | proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), | 4482 | proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), | ||
▲ Show 20 Lines • Show All 2650 Lines • Show Last 20 Lines |
this takes a logical size, so this is indeed wrong.