Kirigami2

ItemViewHeader.qml
1 /*
2  * SPDX-FileCopyrightText: 2017 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.5
8 import QtQuick.Templates 2.0 as T2
9 import QtGraphicalEffects 1.0 as GE
10 import org.kde.kirigami 2.4 as Kirigami
11 import "private" as P
12 
13 /**
14  * An item that can be used as an header for a ListView.
15  * It will play nice with the margin policies of ScrollablePage and can
16  * automatically shrink when the list is scrolled, like the behavior
17  * of list headers in many mobile applications.
18  * It provides some default content: a title and an optional background image
19  * @since 2.1
20  * @inherit org::kde::kirigami::AbstractItemViewHeader
21  * @deprecated since 5.97; Don't use ItemViewHeader in your views anymore.
22  *
23  * TODO KF6 remove
24  */
25 Kirigami.AbstractItemViewHeader {
26  id: root
27  property alias title: heading.text
28  property alias color: heading.color
29 
30  property alias backgroundImage: image
31 
32  Component.onCompleted: console.warn( "ItemViewHeader is deprecated (since 5.97): No replacemant is available.", (new Error).stack)
33 
34  maximumHeight: (backgroundImage.hasImage ? 10 : 6) * Kirigami.Units.gridUnit - (applicationWindow().header ? applicationWindow().header.height : 0) - bottomPadding
35  bottomPadding: Kirigami.Units.smallSpacing
36  leftPadding: Kirigami.Units.smallSpacing
37 
38  background: Rectangle {
39  id: backgroundItem
40  color: Kirigami.Theme.backgroundColor
41  Image {
42  id: image
43  anchors.fill: parent
44  readonly property bool hasImage: backgroundImage.status === Image.Ready || backgroundImage.status === Image.Loading
45  fillMode: Image.PreserveAspectCrop
46  asynchronous: true
47  }
48  P.EdgeShadow {
49  edge: root.view.headerPositioning === ListView.InlineHeader ? Qt.BottomEdge : Qt.TopEdge
50  anchors {
51  right: parent.right
52  left: parent.left
53  top: root.view.headerPositioning === ListView.InlineHeader ? undefined : parent.bottom
54  bottom: root.view.headerPositioning === ListView.InlineHeader ? parent.top : undefined
55  }
56  }
57 
58  readonly property Page page: {
59  let obj = root.view;
60  while(obj && !obj.hasOwnProperty("title") && !obj.hasOwnProperty("isCurrentPage")) {
61  obj = obj.parent
62  }
63  return obj;
64  }
65  Rectangle {
66  id: rect
67  color: backgroundItem.page && backgroundItem.page.isCurrentPage ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
68  height: root.bottomPadding
69  anchors {
70  left: parent.left
71  right: parent.right
72  bottom: parent.bottom
73  }
74  }
75  }
76 
77  contentItem: Item {
78  Kirigami.Heading {
79  id: heading
80  anchors {
81  fill: parent
82  margins: Kirigami.Units.smallSpacing
83  }
84 
85  height: undefined
86  text: page.title
87  fontSizeMode: Text.Fit
88  minimumPointSize: 10
89  font.pointSize: 30
90  horizontalAlignment: Text.AlignRight
91  verticalAlignment: Text.AlignBottom
92  //with an image it needs to be white regardless of system palette
93  color: root.backgroundImage.hasImage ? "white" : Kirigami.Theme.highlightColor
94  opacity: 1
95  elide: Text.ElideRight
96 
97  layer.enabled: root.backgroundImage.hasImage
98  layer.effect: GE.DropShadow {
99  horizontalOffset: 0
100  verticalOffset: 2
101  radius: Kirigami.Units.smallSpacing*2
102  samples: 32
103  color: Qt.rgba(0, 0, 0, 0.7)
104  }
105  }
106  }
107 }
QTextStream & right(QTextStream &stream)
bool isCurrentPage
This property tells us if it is the currently active page.
Definition: Page.qml:193
QTextStream & left(QTextStream &stream)
QTextStream & left(QTextStream &s)
QTextStream & right(QTextStream &s)
Page is a container for all the app pages: everything pushed to the ApplicationWindow's pageStack sho...
Definition: Page.qml:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:14:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.