2
* Copyright 2015 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 1.3
22
\inqmlmodule Ubuntu.Components 1.3
24
\brief The PageHeader shows a title with a leading and a trailing
25
\l ActionBar that add action buttons to the header.
27
The colors for foreground, background and the divider are configured
28
in the style, so they may be set using \l StyleHints:
33
foregroundColor: UbuntuColors.orange
34
backgroundColor: "black"
35
dividerColor: UbuntuColors.darkGrey
43
left: parent ? parent.left : undefined
44
right: parent ? parent.right : undefined
48
The title to display in the header.
49
Note that the title will be hidden if the \l contents Item is set.
54
The contents item to display in the header. By default the contents
55
is undefined, and setting it will disable showing of the title in
65
color: UbuntuColors.red
67
anchors.centerIn: parent
75
property Item contents
77
Component.onCompleted: holder.updateContents()
78
onContentsChanged: holder.updateContents()
86
leftMargin: leading.visible ? 0 : units.gu(1)
87
rightMargin: trailing.visible ? 0 : units.gu(1)
89
height: __styleInstance.contentHeight
94
property Item previousContents: null
95
property Item previousContentsParent: null
97
function updateContents() {
98
if (holder.previousContents) {
99
holder.previousContents.parent = holder.previousContentsParent;
102
titleLoader.sourceComponent = null;
103
holder.previousContents = header.contents;
104
holder.previousContentsParent = header.contents.parent;
105
header.contents.parent = holder;
107
holder.previousContents = null;
108
holder.previousContentsParent = null;
109
titleLoader.sourceComponent = __styleInstance.titleComponent;
113
// When the style changes, make sure that the titleLoader loads
114
// the new titleComponent.
115
property Item styleInstance: __styleInstance
116
onStyleInstanceChanged: updateContents()
120
The actions to be shown in the leading action bar.
121
This property is automatically set by the
122
\l AdaptivePageLayout and other navigation components to configure the
123
back action for the \l Page.
124
Application developers should not set this property, because the
125
value may be overridden by Ubuntu components that have navigation.
126
Instead, set \l leadingActionBar's actions property.
128
property list<Action> navigationActions
131
\qmlproperty ActionBar leadingActionBar
132
The \l ActionBar for the leading navigation actions.
136
leadingActionBar.actions: [
144
The default value of \l leadingActionBar actions is
145
\l navigationActions, but that value can be changed to show
146
different actions in front of the title.
149
readonly property alias leadingActionBar: leading
155
leftMargin: units.gu(1)
157
height: header.__styleInstance.contentHeight
159
delegate: header.__styleInstance.defaultActionDelegate
160
actions: header.navigationActions
161
visible: leading.width > 0 // at least 1 visible action
163
overflowIconName: "navigation-menu"
168
\qmlproperty ActionBar trailingActionBar
169
The \l ActionBar with trailing actions.
194
readonly property alias trailingActionBar: trailing
200
rightMargin: units.gu(1)
202
height: header.__styleInstance.contentHeight
204
delegate: header.__styleInstance.defaultActionDelegate
205
visible: trailing.width > 0 // at least 1 visible action
209
\qmlproperty Sections sections
210
Sections shown at the bottom of the header. By default,
211
the sections will only be visible if its actions or model
212
is set. See \l Sections.
214
readonly property alias sections: sectionsItem
219
leftMargin: units.gu(2)
222
visible: model && model.length > 0
223
height: visible ? implicitHeight : 0
226
styleName: "PageHeaderStyle"