1- // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
1+ // SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
22//
33// SPDX-License-Identifier: LGPL-3.0-or-later
44
@@ -14,6 +14,21 @@ Control {
1414 readonly property int direction: parent .parent .tickDirection
1515 readonly property bool horizontal: parent .parent .children [0 ].horizontal
1616 property bool highlight
17+ readonly property bool isFirst: {
18+ var ticks = parent .parent .ticks || []
19+ return ticks .indexOf (control) === 0
20+ }
21+ readonly property bool isLast: {
22+ var ticks = parent .parent .ticks || []
23+ return ticks .indexOf (control) === ticks .length - 1
24+ }
25+ // Align first/last tick labels outward to prevent text overflow at slider edges
26+ readonly property int effectiveHorizontalAlignment: {
27+ if (! horizontal) return textHorizontalAlignment
28+ if (isFirst) return Text .AlignLeft
29+ if (isLast) return Text .AlignRight
30+ return textHorizontalAlignment
31+ }
1732
1833 property D .Palette tickColor: DS .Style .slider .tick .background
1934 property D .Palette textColor: highlight ? DS .Style .checkedButton .text : DS .Style .button .text
@@ -36,16 +51,16 @@ Control {
3651 active: text .length !== 0
3752 anchors {
3853 top: horizontal ? (TipsSlider .TickDirection .Back === direction ? __rect .bottom : undefined ) : undefined
39- topMargin: horizontal && (TipsSlider .TickDirection .Back === direction) ? DS .Style .slider .tick .vPadding : undefined
54+ topMargin: horizontal && (TipsSlider .TickDirection .Back === direction) ? DS .Style .slider .tick .vPadding : - DS . Style . slider . tick . vPadding
4055 bottom: horizontal ? (TipsSlider .TickDirection .Front === direction ? __rect .top : undefined ) : undefined
41- bottomMargin: horizontal && (TipsSlider .TickDirection .Front === direction) ? DS .Style .slider .tick .vPadding : undefined
42- left: horizontal ? (Text .AlignLeft === textHorizontalAlignment ? __rect .left : undefined )
56+ bottomMargin: horizontal && (TipsSlider .TickDirection .Front === direction) ? DS .Style .slider .tick .vPadding : - DS . Style . slider . tick . vPadding
57+ left: horizontal ? (Text .AlignLeft === effectiveHorizontalAlignment ? __rect .left : undefined )
4358 : (TipsSlider .TickDirection .Back === direction ? __rect .right : undefined )
44- leftMargin: ! horizontal && TipsSlider .TickDirection .Back === direction ? DS .Style .slider .tick .hPadding : undefined
45- right: horizontal ? (Text .AlignRight === textHorizontalAlignment ? __rect .right : undefined )
59+ leftMargin: ! horizontal && TipsSlider .TickDirection .Back === direction ? DS .Style .slider .tick .hPadding : - DS . Style . slider . tick . hPadding
60+ right: horizontal ? (Text .AlignRight === effectiveHorizontalAlignment ? __rect .right : undefined )
4661 : (TipsSlider .TickDirection .Front === direction ? __rect .left : undefined )
47- rightMargin: ! horizontal && TipsSlider .TickDirection .Front === direction ? DS .Style .slider .tick .hPadding : undefined
48- horizontalCenter: horizontal && Text .AlignHCenter === textHorizontalAlignment ? __rect .horizontalCenter : undefined
62+ rightMargin: ! horizontal && TipsSlider .TickDirection .Front === direction ? DS .Style .slider .tick .hPadding : - DS . Style . slider . tick . hPadding
63+ horizontalCenter: horizontal && Text .AlignHCenter === effectiveHorizontalAlignment ? __rect .horizontalCenter : undefined
4964 verticalCenter: horizontal ? undefined : __rect .verticalCenter
5065 }
5166
@@ -55,7 +70,7 @@ Control {
5570 leftPadding: rightPadding
5671 topPadding: highlight ? DS .Style .slider .tick .vPadding : 0
5772 bottomPadding: topPadding
58- horizontalAlignment: textHorizontalAlignment
73+ horizontalAlignment: control . effectiveHorizontalAlignment
5974 verticalAlignment: Text .AlignVCenter
6075 palette .windowText : control .D .ColorSelector .textColor
6176 background: Loader {
0 commit comments