Warning, /plasma/qqc2-breeze-style/style/impl/RadioIndicator.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com> 0002 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 */ 0004 0005 import QtQuick 2.15 0006 import QtQuick.Templates 2.15 as T 0007 import org.kde.kirigami 2.19 as Kirigami 0008 0009 import "." as Impl 0010 0011 // TODO: replace with ShadowedRectangle because it produces smoother circles. 0012 // Unfortunately I can't do it now because batching issues can cause all radio 0013 // buttons to show hover effects when only one is hovered 0014 Rectangle { 0015 id: root 0016 0017 property T.AbstractButton control: root.parent 0018 property bool mirrored: control.mirrored 0019 readonly property bool controlHasContent: control.contentItem && control.contentItem.width > 0 0020 0021 implicitWidth: implicitHeight 0022 implicitHeight: Impl.Units.inlineControlHeight 0023 0024 x: controlHasContent ? (root.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 0025 y: control.topPadding + (control.availableHeight - height) / 2 0026 0027 radius: width / 2 0028 0029 Kirigami.Theme.colorSet: Kirigami.Theme.Button 0030 Kirigami.Theme.inherit: false 0031 color: control.down || control.checked ? Kirigami.Theme.alternateBackgroundColor : Kirigami.Theme.backgroundColor 0032 0033 border { 0034 width: Impl.Units.smallBorder 0035 color: control.down || control.checked || control.visualFocus || control.hovered ? Kirigami.Theme.focusColor : Kirigami.Theme.separatorColor 0036 } 0037 0038 Behavior on color { 0039 enabled: control.down || control.checked 0040 ColorAnimation { 0041 duration: Kirigami.Units.shortDuration 0042 easing.type: Easing.OutCubic 0043 } 0044 } 0045 0046 Behavior on border.color { 0047 enabled: control.down || control.checked || control.visualFocus || control.hovered 0048 ColorAnimation { 0049 duration: Kirigami.Units.shortDuration 0050 easing.type: Easing.OutCubic 0051 } 0052 } 0053 0054 SmallBoxShadow { 0055 id: shadow 0056 opacity: control.down ? 0 : 1 0057 visible: control.enabled 0058 radius: parent.radius 0059 } 0060 0061 // Using Kirigami.ShadowedRectangle because Rectangle looks a bit jagged at 2x scaling even with antialiasing 0062 Kirigami.ShadowedRectangle { 0063 id: mark 0064 anchors.centerIn: parent 0065 implicitHeight: { 0066 let h = root.height/2 0067 h -= h % 2 0068 return h 0069 } 0070 implicitWidth: implicitHeight 0071 radius: height / 2 0072 color: Kirigami.Theme.textColor 0073 // slight glow gives subtle depth 0074 shadow { 0075 size: 2 0076 color: mark.color 0077 } 0078 visible: control.checked 0079 scale: 0.8 0080 } 0081 0082 FocusRect { 0083 baseRadius: root.radius 0084 visible: control.visualFocus 0085 } 0086 0087 states: [ 0088 State { 0089 when: !control.checked 0090 name: "unchecked" 0091 PropertyChanges { 0092 target: mark 0093 scale: 0.8 0094 } 0095 }, 0096 State { 0097 when: control.checked 0098 name: "checked" 0099 PropertyChanges { 0100 target: mark 0101 scale: 1 0102 } 0103 } 0104 ] 0105 0106 transitions: [ 0107 /* Using `from: "unchecked"` instead of `from: "*"` prevents the transition 0108 * from running when the parent control is created. 0109 * This can reduce resource usage spikes on pages that have way too many 0110 * controls with indicators. 0111 */ 0112 Transition { 0113 from: "unchecked" 0114 to: "checked" 0115 ScaleAnimator { 0116 duration: Kirigami.Units.shortDuration 0117 easing.type: Easing.OutQuad 0118 } 0119 } 0120 ] 0121 }