Warning, /pim/itinerary/src/app/components/RadioSelector.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: LGPL-2.0-or-later 0002 // SPDX-FileCopyrightText: 2023 Mathis BrĂ¼chert <mbb@kaidan.im> 0003 0004 import QtQuick 0005 import QtQuick.Controls as QQC2 0006 import QtQuick.Layouts 0007 import org.kde.kirigami as Kirigami 0008 0009 Item{ 0010 id: container 0011 0012 property list<Kirigami.Action> actions 0013 property bool consistentWidth: false 0014 property int defaultIndex: 0 0015 readonly property int selectedIndex: marker.selectedIndex 0016 0017 Layout.minimumWidth: consistentWidth ? 0 : switchLayout.implicitWidth 0018 implicitHeight: switchLayout.implicitHeight 0019 Layout.fillWidth: consistentWidth 0020 0021 QQC2.ButtonGroup { 0022 buttons: switchLayout.children 0023 } 0024 0025 RowLayout { 0026 id: switchLayout 0027 anchors { 0028 top: container.top 0029 left: container.left 0030 right: container.right 0031 } 0032 Repeater{ 0033 id: repeater 0034 0035 model: actions 0036 delegate: QQC2.ToolButton { 0037 id: button 0038 0039 required property var modelData 0040 required property int index 0041 0042 Layout.fillWidth: true 0043 Layout.preferredWidth: consistentWidth ? (container.width/repeater.count)-(switchLayout.spacing/repeater.count-1) : button.implicitWidth 0044 Layout.minimumHeight: Math.round(Kirigami.Units.gridUnit * 1.5) 0045 0046 checkable: true 0047 text: modelData.text 0048 icon.name: modelData.icon.name 0049 0050 background: Rectangle{ 0051 anchors.fill: button 0052 0053 radius: height/2 0054 color: "transparent" 0055 border.color: Kirigami.Theme.disabledTextColor 0056 opacity: button.hovered ? 0.3 : 0 0057 0058 Behavior on opacity { 0059 PropertyAnimation { 0060 duration: Kirigami.Units.shortDuration 0061 easing.type: Easing.InOutCubic 0062 } 0063 } 0064 } 0065 0066 contentItem: RowLayout{ 0067 Item { 0068 Layout.leftMargin: icon.visible ? Kirigami.Units.smallSpacing : Kirigami.Units.largeSpacing 0069 Layout.fillWidth: true 0070 } 0071 0072 Kirigami.Icon { 0073 id: icon 0074 0075 Layout.alignment: Qt.AlignVCenter 0076 0077 color: button.checked ? Kirigami.Theme.hoverColor : Kirigami.Theme.textColor 0078 visible: button.icon.name 0079 source: button.icon.name 0080 implicitHeight: label.height 0081 implicitWidth: label.height 0082 Behavior on color { 0083 PropertyAnimation { 0084 duration: Kirigami.Units.longDuration 0085 easing.type: Easing.InOutCubic 0086 } 0087 } 0088 } 0089 Item{ 0090 Layout.alignment: Qt.AlignVCenter 0091 0092 implicitWidth: fakeLabel.implicitWidth 0093 implicitHeight: fakeLabel.implicitHeight 0094 QQC2.Label { 0095 id: fakeLabel 0096 0097 anchors.centerIn: parent 0098 font.bold: true 0099 color: Kirigami.Theme.hoverColor 0100 0101 opacity: button.checked ? 1 : 0 0102 text: button.text 0103 Behavior on opacity { 0104 PropertyAnimation { 0105 duration: Kirigami.Units.longDuration 0106 easing.type: Easing.InOutCubic 0107 } 0108 } 0109 Accessible.ignored: true 0110 } 0111 QQC2.Label { 0112 id: label 0113 0114 anchors.centerIn: parent 0115 color: Kirigami.Theme.textColor 0116 0117 opacity: button.checked ? 0 : 1 0118 text: button.text 0119 Behavior on opacity { 0120 PropertyAnimation { 0121 duration: Kirigami.Units.longDuration 0122 easing.type: Easing.InOutCubic 0123 } 0124 } 0125 Accessible.ignored: true 0126 } 0127 } 0128 0129 Item { 0130 Layout.fillWidth: true 0131 Layout.rightMargin: Kirigami.Units.largeSpacing 0132 } 0133 } 0134 0135 onClicked: { 0136 marker.width = Qt.binding(function() { return width }) 0137 marker.x = Qt.binding(function() { return x }) 0138 modelData.triggered() 0139 marker.selectedIndex = index 0140 0141 } 0142 Component.onCompleted: if (index === defaultIndex ) { 0143 marker.width = Qt.binding(function() { return width }) 0144 marker.x = Qt.binding(function() { return x }) 0145 button.checked = true 0146 } 0147 } 0148 } 0149 } 0150 0151 Rectangle { 0152 id: marker 0153 0154 property int selectedIndex: container.defaultIndex 0155 0156 y: switchLayout.y 0157 z: switchLayout.z - 1 0158 height: switchLayout.implicitHeight 0159 radius: height/2 0160 border.width: 1 0161 border.color: Kirigami.ColorUtils.linearInterpolation( 0162 Kirigami.Theme.hoverColor, 0163 "transparent", 0.4) 0164 color: Kirigami.ColorUtils.linearInterpolation( 0165 Kirigami.Theme.hoverColor, 0166 "transparent", 0.9) 0167 0168 Behavior on x { 0169 PropertyAnimation { 0170 id: x_anim 0171 0172 duration: Kirigami.Units.longDuration 0173 easing.type: Easing.InOutCubic 0174 } 0175 } 0176 0177 Behavior on width { 0178 PropertyAnimation { 0179 id: width_anim 0180 0181 duration: Kirigami.Units.longDuration 0182 easing.type: Easing.InOutCubic 0183 } 0184 } 0185 } 0186 }