Warning, /plasma/qqc2-breeze-style/style/impl/DelegateBackground.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: I'm currently unsatisfied with the appearance of this
0012 Loader {
0013     id: root
0014     property T.ItemDelegate control: root.parent
0015 
0016     property color normalColor: control instanceof T.SwipeDelegate ? Kirigami.Theme.backgroundColor
0017         : Qt.rgba(
0018             Kirigami.Theme.backgroundColor.r,
0019             Kirigami.Theme.backgroundColor.g,
0020             Kirigami.Theme.backgroundColor.b,
0021             0
0022         )
0023     property bool highlightBorder: control.hovered || control.visualFocus || control.down || control.highlighted
0024 
0025     // Rectangle compatibility properties. 3rd party devs might assume that these properties are available.
0026     property color color: {
0027         if (control.down || control.highlighted) {
0028             return Kirigami.Theme.alternateBackgroundColor
0029         } else {
0030             return normalColor
0031         }
0032     }
0033     property real radius: Impl.Units.smallRadius
0034     property QtObject border: QtObject {
0035         property real width: highlightBorder ? Impl.Units.smallBorder : 0
0036         property color color: Kirigami.Theme.focusColor
0037     }
0038 
0039     property bool backgroundAnimationRunning: false
0040     property bool borderAnimationRunning: false
0041 
0042     visible: (highlightBorder || backgroundAnimationRunning || borderAnimationRunning || control instanceof T.SwipeDelegate)
0043     active: visible
0044     sourceComponent: Component {
0045         Kirigami.ShadowedRectangle {
0046             id: mainBackground
0047 
0048             implicitHeight: Impl.Units.mediumControlHeight
0049 
0050             radius: root.radius
0051 
0052             color: root.color
0053 
0054             border {
0055                 width: root.border.width
0056                 color: root.border.color
0057             }
0058 
0059             Behavior on color {
0060                 enabled: control.down
0061                 ColorAnimation {
0062                     duration: Kirigami.Units.shortDuration
0063                     easing.type: Easing.OutCubic
0064                     onRunningChanged: root.backgroundAnimationRunning = running
0065                 }
0066             }
0067             Behavior on border.color {
0068                 enabled: highlightBorder
0069                 ColorAnimation {
0070                     duration: Kirigami.Units.shortDuration
0071                     easing.type: Easing.OutCubic
0072                     onRunningChanged: root.borderAnimationRunning = running
0073                 }
0074             }
0075         }
0076     }
0077 }
0078