diff options
Diffstat (limited to 'src/quickcontrols')
| -rw-r--r-- | src/quickcontrols/ios/Dial.qml | 55 | ||||
| -rw-r--r-- | src/quickcontrols/material/impl/qquickmaterialtextcontainer.cpp | 2 | ||||
| -rw-r--r-- | src/quickcontrols/material/qquickmaterialstyle.cpp | 8 |
3 files changed, 36 insertions, 29 deletions
diff --git a/src/quickcontrols/ios/Dial.qml b/src/quickcontrols/ios/Dial.qml index 41ce35caf2..303b791004 100644 --- a/src/quickcontrols/ios/Dial.qml +++ b/src/quickcontrols/ios/Dial.qml @@ -15,40 +15,41 @@ T.Dial { implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding) + // The handle extends outside background bounds, + // so we need to include that in the insets calculation leftInset: handle ? handle.width / 2 : 0 rightInset: handle ? handle.width / 2 : 0 topInset: handle ? handle.height / 2 : 0 bottomInset: handle ? handle.height / 2 : 0 background: Item { - implicitWidth: 104 - implicitHeight: 104 - x: control.leftInset + (control.availableWidth - width) / 2 - y: control.topInset + (control.availableHeight - height) / 2 + implicitWidth: _groove.implicitWidth + implicitHeight: _groove.implicitHeight - Rectangle { + readonly property int _strokeWidth: 4 + + readonly property Rectangle _groove: Rectangle { + parent: control.background x: (parent.width - width) / 2 y: (parent.height - height) / 2 - implicitWidth: parent.implicitWidth - implicitHeight: parent.implicitHeight - width: Math.max(50, Math.min(control.background.width, control.background.height)) + implicitWidth: 104 + implicitHeight: 104 + width: Math.min(parent.width, parent.height) height: width color: "transparent" border.color: control.palette.mid - border.width: 4 + border.width: control.background._strokeWidth radius: width * 0.5 z: -1 - - opacity: control.enabled? 1 : 0.5 + opacity: control.enabled ? 1 : 0.5 } - Shape { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - implicitWidth: parent.implicitWidth - implicitHeight: parent.implicitHeight - width: Math.max(50, Math.min(control.background.width, control.background.height)) - height: width + readonly property Shape _track: Shape { + parent: control.background + x: control.background._groove.x + y: control.background._groove.y + width: control.background._groove.width + height: control.background._groove.height layer.enabled: true layer.samples: 4 @@ -56,13 +57,12 @@ T.Dial { fillColor: "transparent" strokeColor: control.palette.button strokeWidth: 4 - capStyle: ShapePath.RoundCap PathAngleArc { - centerX: control.background.children[0].width / 2 - centerY: control.background.children[0].height / 2 - radiusX: control.background.children[0].width / 2 - 2 + centerX: control.background._track.width / 2 + centerY: control.background._track.height / 2 + radiusX: (control.background._track.width - control.background._strokeWidth) / 2 radiusY: radiusX startAngle: -230 sweepAngle: 140 + control.angle @@ -74,13 +74,16 @@ T.Dial { handle: Item { height: dialHandle.height - dialHandle.topInset - dialHandle.bottomInset width: dialHandle.width - dialHandle.rightInset - dialHandle.leftInset - x: control.background.x + control.background.width / 2 - width / 2 - y: control.background.y + control.background.height / 2 - height / 2 + x: control.background ? control.background.x + (control.background.width - width) / 2 : 0 + y: control.background ? control.background.y + (control.background.height - height) / 2 : 0 transform: [ Translate { - x: Math.cos((angle - 90) * Math.PI / 180) * Math.min(control.background.width, control.background.height) * 0.5; - y: Math.sin((angle - 90) * Math.PI / 180) * Math.min(control.background.width, control.background.height) * 0.5; + readonly property real radius: !control.background ? 0 + : (Math.min(control.background.width, control.background.height) + - control.background._strokeWidth) / 2 + x: Math.cos((angle - 90) * Math.PI / 180) * radius + y: Math.sin((angle - 90) * Math.PI / 180) * radius } ] diff --git a/src/quickcontrols/material/impl/qquickmaterialtextcontainer.cpp b/src/quickcontrols/material/impl/qquickmaterialtextcontainer.cpp index ab07c9d9b2..53f8fe8618 100644 --- a/src/quickcontrols/material/impl/qquickmaterialtextcontainer.cpp +++ b/src/quickcontrols/material/impl/qquickmaterialtextcontainer.cpp @@ -308,7 +308,7 @@ void QQuickMaterialTextContainer::paint(QPainter *painter) // Draw the focus line at the bottom for filled containers. if (m_filled) { - if (!qFuzzyCompare(m_focusAnimationProgress, 1.0)) { + if (!qFuzzyCompare(m_focusAnimationProgress, qreal(1.0))) { // Draw the enabled active indicator line (#10) that's at the bottom when it's not focused: // https://m3.material.io/components/text-fields/specs#6d654d1d-262e-4697-858c-9a75e8e7c81d // Don't bother drawing it when the animation has finished, as the focused active indicator diff --git a/src/quickcontrols/material/qquickmaterialstyle.cpp b/src/quickcontrols/material/qquickmaterialstyle.cpp index f8ced5821b..ffa877b2b3 100644 --- a/src/quickcontrols/material/qquickmaterialstyle.cpp +++ b/src/quickcontrols/material/qquickmaterialstyle.cpp @@ -10,6 +10,8 @@ #include <QtQml/qqmlinfo.h> #include <QtQuickControls2/private/qquickstyle_p.h> +#include <algorithm> + QT_BEGIN_NAMESPACE static const QRgb colors[][14] = { @@ -1184,14 +1186,16 @@ QColor QQuickMaterialStyle::color(QQuickMaterialStyle::Color color, QQuickMateri static QColor lighterShade(const QColor &color, qreal amount) { QColor hsl = color.toHsl(); - hsl.setHslF(hsl.hueF(), hsl.saturationF(), qBound<qreal>(0.0, hsl.lightnessF() + amount, 1.0), color.alphaF()); + hsl.setHslF(hsl.hueF(), hsl.saturationF(), + std::clamp(hsl.lightnessF() + amount, qreal(0.0), qreal(1.0)), color.alphaF()); return hsl.convertTo(color.spec()); } static QColor darkerShade(const QColor &color, qreal amount) { QColor hsl = color.toHsl(); - hsl.setHslF(hsl.hueF(), hsl.saturationF(), qBound<qreal>(0.0, hsl.lightnessF() - amount, 1.0), color.alphaF()); + hsl.setHslF(hsl.hueF(), hsl.saturationF(), + std::clamp(hsl.lightnessF() - amount, qreal(0.0), qreal(1.0)), color.alphaF()); return hsl.convertTo(color.spec()); } |
