fix(style): adjust slider groove offset when no ticks are displayed#304
fix(style): adjust slider groove offset when no ticks are displayed#30418202781743 merged 1 commit intolinuxdeepin:masterfrom
Conversation
| qreal rectWidth = rectHandle.width() / 2.0; | ||
| p->drawLine(QPointF(rectGroove.left() + rectWidth, rectHandle.center().y()), QPointF(rectHandle.center().x(), rectHandle.center().y())); | ||
| // 只有当不绘制刻度线的时候,就不要给滑槽两边弄缩进 | ||
| qreal leftOffset = (slider->tickPosition == QSlider::NoTicks) ? 0 : rectWidth; |
There was a problem hiding this comment.
(slider->tickPosition == QSlider::NoTicks)可以isNoticks去判断,
There was a problem hiding this comment.
Pull request overview
Adjusts Chameleon style slider groove rendering so that when a slider has no tick marks, the groove is not indented at the ends and instead spans the full available length (per PMS-299727).
Changes:
- Remove groove end indentation when
tickPosition == QSlider::NoTicksfor horizontal sliders. - Remove groove end indentation when
tickPosition == QSlider::NoTicksfor vertical sliders.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 只有当不绘制刻度线的时候,就不要给滑槽两边弄缩进 | ||
| qreal leftOffset = (slider->tickPosition == QSlider::NoTicks) ? 0 : rectWidth; | ||
| p->drawLine(QPointF(rectGroove.left() + leftOffset, rectHandle.center().y()), QPointF(rectHandle.center().x(), rectHandle.center().y())); | ||
| // 绘制滑块到最右的位置的滑槽 | ||
| pen.setColor(color); | ||
| p->setPen(pen); | ||
| p->drawLine(QPointF(rectGroove.right() - rectWidth, rectHandle.center().y()), QPointF(rectHandle.center().x(), rectHandle.center().y())); | ||
| qreal rightOffset = (slider->tickPosition == QSlider::NoTicks) ? 0 : rectWidth; | ||
| p->drawLine(QPointF(rectGroove.right() - rightOffset, rectHandle.center().y()), QPointF(rectHandle.center().x(), rectHandle.center().y())); |
There was a problem hiding this comment.
The new groove-offset logic keys off slider->tickPosition, but this file already treats DSlider as a special case where the effective tick position may come from dslider->tickPosition() (see e.g. the handle drawing/focus logic). This can make groove indentation inconsistent with handle shape/color decisions for DSlider. Consider computing a single effective TickPosition (or noTicks bool) using the same dslider ? dslider->tickPosition() : slider->tickPosition rule and reuse it for all offsets here.
| // 只有当不绘制刻度线的时候,就不要给滑槽两边弄缩进 | ||
| qreal bottomOffset = (slider->tickPosition == QSlider::NoTicks) ? 0 : rectWidth; | ||
| p->drawLine(QPointF(rectGroove.center().x(), rectGroove.bottom() - bottomOffset), QPointF(rectGroove.center().x(), rectHandle.center().y())); | ||
| // 绘制滑块到最下的位置的滑槽 | ||
| pen.setColor(color); | ||
| p->setPen(pen); | ||
| p->drawLine(QPointF(rectGroove.center().x(), rectGroove.top() + rectWidth), QPointF(rectGroove.center().x(), rectHandle.center().y())); | ||
| qreal topOffset = (slider->tickPosition == QSlider::NoTicks) ? 0 : rectWidth; | ||
| p->drawLine(QPointF(rectGroove.center().x(), rectGroove.top() + topOffset), QPointF(rectGroove.center().x(), rectHandle.center().y())); |
There was a problem hiding this comment.
Same as the horizontal case: bottomOffset/topOffset are derived from slider->tickPosition only. For DSlider, other parts of this style use dslider->tickPosition() as the source of truth, so the groove could still be indented even when the handle is rendered in the NoTicks style. Please use a single effective tick-position/noTicks value (including the DSlider override) for these offsets as well.
When a slider has no tick marks, the groove now extends to the full width/height of the slider area without indentation at the ends. log: adjust slider groove offset when no ticks are displayed bug: PMS-299727
deepin pr auto review这段代码是针对 Qt 自定义样式中 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与改进建议这段代码修改本身是优秀的,它解决了一个具体的 UI 细节问题(无刻度时滑槽的填充),且实现方式简洁。 改进建议:
结论: 该代码修改可以合并。逻辑清晰,修正了特定场景下的显示效果,没有引入明显的副作用或性能问题。只需确保调用处对 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, add-uos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
When a slider has no tick marks, the groove now extends to the full width/height of the slider area without indentation at the ends.
log: adjust slider groove offset when no ticks are displayed
bug: PMS-299727