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 0006 import QtQuick.Templates as T 0007 import org.kde.kirigami as Kirigami 0008 0009 import "." as Impl 0010 0011 Rectangle { 0012 id: root 0013 property T.ItemDelegate control: root.parent 0014 0015 readonly property bool highlight: control.highlighted || control.down 0016 readonly property bool useAlternatingColors: { 0017 if (control.TableView.view?.alternatingRows && row % 2) { 0018 return true 0019 } else if (control.Kirigami.Theme.useAlternateBackgroundColor && index % 2) { 0020 return true 0021 } 0022 return false 0023 } 0024 0025 readonly property color hoverColor: Qt.alpha(Kirigami.Theme.hoverColor, 0.3) 0026 readonly property color highlightColor: Kirigami.Theme.highlightColor 0027 readonly property color normalColor: useAlternatingColors ? Kirigami.Theme.alternateBackgroundColor : Kirigami.Theme.backgroundColor 0028 // Workaround for QTBUG-113304 0029 readonly property bool reallyFocus: control.visualFocus || (control.activeFocus && control.focusReason === Qt.OtherFocusReason) 0030 0031 property real horizontalPadding: Kirigami.Units.smallSpacing 0032 property real verticalPadding: Kirigami.Units.smallSpacing 0033 property real cornerRadius: 3 0034 0035 color: normalColor 0036 0037 Rectangle { 0038 anchors { 0039 fill: parent 0040 leftMargin: background.horizontalPadding 0041 rightMargin: background.horizontalPadding 0042 // We want total spacing between consecutive list items to be 0043 // verticalPadding. So use half that as top/bottom margin, separately 0044 // ceiling/flooring them so that the total spacing is preserved. 0045 topMargin: Math.ceil(root.verticalPadding / 2) 0046 bottomMargin: Math.floor(root.verticalPadding / 2) 0047 } 0048 0049 radius: root.cornerRadius 0050 0051 color: { 0052 if (root.highlight) { 0053 return root.highlightColor 0054 } else { 0055 return (root.control.hovered || root.reallyFocus) ? root.hoverColor : root.normalColor 0056 } 0057 } 0058 0059 border.width: 1 0060 border.color: { 0061 if (root.highlight) { 0062 return root.highlightColor 0063 } else { 0064 return (root.control.hovered || root.reallyFocus) ? Kirigami.Theme.hoverColor : "transparent" 0065 } 0066 } 0067 } 0068 } 0069