Kirigami2

DefaultListItemBackground.qml
1 /*
2  * SPDX-FileCopyrightText: 2016 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.1
8 import org.kde.kirigami 2.12 as Kirigami
9 
10 Rectangle {
11  id: background
12  color: {
13  if (listItem.alternatingBackground && index % 2)
14  return listItem.alternateBackgroundColor
15  else if (listItem.checked || listItem.highlighted || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate))
16  return listItem.activeBackgroundColor
17  return listItem.backgroundColor
18  }
19 
20  visible: listItem.ListView.view === null || listItem.ListView.view.highlight === null
21  Rectangle {
22  id: internal
23  anchors.fill: parent
24  visible: !Kirigami.Settings.tabletMode && listItem.hoverEnabled
25  color: listItem.activeBackgroundColor
26  opacity: {
27  if ((listItem.highlighted || listItem.ListView.isCurrentItem) && !listItem.pressed) {
28  return .6
29  } else if (listItem.hovered && !listItem.pressed) {
30  return .3
31  } else {
32  return 0
33  }
34  }
35  }
36 
37  Kirigami.Separator {
38  anchors {
39  left: parent.left
40  right: parent.right
41  bottom: parent.bottom
42  leftMargin: Kirigami.Units.largeSpacing
43  rightMargin: Kirigami.Units.largeSpacing
44  }
45  visible: {
46  // Whether there is visual feedback (do not show the separator)
47  const visualFeedback = listItem.highlighted || listItem.pressed || listItem.checked || listItem.ListView.isCurrentItem
48 
49  // Show the separator when activeBackgroundColor is set to "transparent",
50  // when the item is hovered. Check commit 344aec26.
51  const bgTransparent = !listItem.hovered || listItem.activeBackgroundColor.a === 0
52 
53  // Whether the next item is a section delegate or is from another section (do not show the separator)
54  const anotherSection = listItem.ListView.view === null || listItem.ListView.nextSection === listItem.ListView.section
55 
56  // Whether this item is the last item in the view (do not show the separator)
57  const lastItem = listItem.ListView.view === null || listItem.ListView.count - 1 !== index
58 
59  return listItem.separatorVisible && !visualFeedback && bgTransparent
60  && !listItem.sectionDelegate && anotherSection && lastItem
61  }
62  weight: Kirigami.Separator.Weight.Light
63  }
64 }
65 
QTextStream & right(QTextStream &stream)
QTextStream & left(QTextStream &stream)
QTextStream & left(QTextStream &s)
QTextStream & right(QTextStream &s)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.