Warning, /plasma/qqc2-breeze-style/style/impl/SpinBoxIndicator.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
0006 import org.kde.kirigami as Kirigami
0007 
0008 import "." as Impl
0009 
0010 Item {
0011     id: root
0012 
0013     property QtObject button // QQuickSpinButton is a QObject
0014     property bool mirrored: false
0015     property int alignment: Qt.AlignLeft
0016     property bool leftAligned: root.alignment == Qt.AlignLeft
0017     property bool rightAligned: root.alignment == Qt.AlignRight
0018     property real leftRadius: {
0019         if ((leftAligned && !mirrored)
0020             || (rightAligned && mirrored)) {
0021             return Impl.Units.smallRadius
0022         } else {
0023             return 0
0024         }
0025     }
0026     property real rightRadius: {
0027         if ((rightAligned && !mirrored)
0028             || (leftAligned && mirrored)) {
0029             return Impl.Units.smallRadius
0030         } else {
0031             return 0
0032         }
0033     }
0034 
0035     x: {
0036         if ((leftAligned && !mirrored)
0037             || (rightAligned && mirrored)) {
0038             return 0
0039         } else {
0040             return parent.width - width
0041         }
0042     }
0043     height: parent.height
0044 
0045     implicitWidth: implicitHeight
0046     implicitHeight: Impl.Units.mediumControlHeight
0047 
0048     Rectangle {
0049         id: separator
0050         width: Impl.Units.smallBorder
0051         x: {
0052             if ((leftAligned && !mirrored)
0053                 || (rightAligned && mirrored)) {
0054                 return parent.width - width
0055             } else {
0056                 return 0
0057             }
0058         }
0059         anchors {
0060             top: parent.top
0061             bottom: parent.bottom
0062             topMargin: Kirigami.Units.smallSpacing
0063             bottomMargin: Kirigami.Units.smallSpacing
0064         }
0065 
0066         color: button.pressed || button.hovered ? Kirigami.Theme.focusColor : Impl.Theme.separatorColor()
0067 
0068         Behavior on color {
0069             enabled: button.pressed || button.hovered
0070             ColorAnimation {
0071                 duration: Kirigami.Units.shortDuration
0072                 easing.type: Easing.OutCubic
0073             }
0074         }
0075     }
0076 
0077     Kirigami.ShadowedRectangle {
0078         id: pressedBg
0079         Kirigami.Theme.colorSet: Kirigami.Theme.Button
0080         Kirigami.Theme.inherit: false
0081         opacity: 0
0082         anchors.fill: parent
0083         color: Kirigami.Theme.alternateBackgroundColor
0084         corners {
0085             topLeftRadius: root.leftRadius
0086             topRightRadius: root.rightRadius
0087             bottomLeftRadius: root.leftRadius
0088             bottomRightRadius: root.rightRadius
0089         }
0090         border.color: Kirigami.Theme.focusColor
0091         border.width: Impl.Units.smallBorder
0092 
0093         states: State {
0094             name: "pressed"
0095             when: button.pressed
0096             PropertyChanges {
0097                 target: pressedBg
0098                 opacity: 1
0099                 visible: true
0100             }
0101         }
0102         transitions: Transition {
0103             from: "pressed"
0104             to: ""
0105             SequentialAnimation {
0106                 OpacityAnimator {
0107                     duration: Kirigami.Units.shortDuration
0108                     easing.type: Easing.OutCubic
0109                 }
0110                 PropertyAction {
0111                     target: pressedBg
0112                     property: "visible"
0113                     value: false
0114                 }
0115             }
0116         }
0117     }
0118 
0119     Kirigami.Icon {
0120         implicitHeight: Kirigami.Units.iconSizes.sizeForLabels
0121         implicitWidth: implicitHeight
0122         anchors {
0123             centerIn: parent
0124         }
0125         source: {
0126             // For some reason I don't need to use the fancier logic with this
0127             if (leftAligned) {
0128                 return "arrow-down"
0129             } else {
0130                 return "arrow-up"
0131             }
0132         }
0133     }
0134 }