| 1 |
/* |
| 2 |
* Copyright 2014-2015 Canonical Ltd. |
| 3 |
* |
| 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. |
| 7 |
* |
| 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. |
| 12 |
* |
| 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/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
/*! |
| 18 |
\qmltype PageHeadConfiguration |
| 19 |
\inqmlmodule Lomiri.Components |
| 20 |
\ingroup lomiri |
| 21 |
\since Lomiri.Components 1.1 |
| 22 |
\deprecated |
| 23 |
\brief Page.head is used to configure the header for a \l Page. |
| 24 |
|
| 25 |
For examples how to use Page.head, see \l Page. |
| 26 |
*/ |
| 27 |
|
| 28 |
/*! |
| 29 |
List of actions to show in the header. |
| 30 |
|
| 31 |
Example: |
| 32 |
\qml |
| 33 |
Page { |
| 34 |
title: "Custom header actions" |
| 35 |
head.actions: [ |
| 36 |
Action { |
| 37 |
iconName: "save" |
| 38 |
text: i18n.tr("Save") |
| 39 |
}, |
| 40 |
Action { |
| 41 |
iconName: "add" |
| 42 |
text: i18n.tr("Add") |
| 43 |
} |
| 44 |
] |
| 45 |
} |
| 46 |
\endqml |
| 47 |
\qmlproperty list<Action> PageHeadConfiguration::actions |
| 48 |
*/ |
| 49 |
|
| 50 |
/*! |
| 51 |
\qmlproperty Action PageHeadConfiguration::backAction |
| 52 |
Overrides the default \l PageStack back button and the |
| 53 |
\l Tabs drawer button in the header. |
| 54 |
|
| 55 |
Example: |
| 56 |
\qml |
| 57 |
Page { |
| 58 |
title: "Back Action Page" |
| 59 |
head.backAction: Action { |
| 60 |
iconName: "close" |
| 61 |
onTriggered: { |
| 62 |
console.log("Run custom back action") |
| 63 |
} |
| 64 |
} |
| 65 |
} |
| 66 |
\endqml |
| 67 |
*/ |
| 68 |
|
| 69 |
/*! |
| 70 |
\qmlproperty Item PageHeadConfiguration::contents |
| 71 |
Set this property to show this Item in the header instead of |
| 72 |
the title. Use a \l TextField here for implementing search in header. |
| 73 |
|
| 74 |
The parent of this Item will be binded while the \l Page is active. |
| 75 |
The header contents will automatically be anchored to the left and |
| 76 |
vertically centered inside the header. |
| 77 |
|
| 78 |
Example: |
| 79 |
\qml |
| 80 |
Page { |
| 81 |
title: "Invisible title" |
| 82 |
head.contents: Rectangle { |
| 83 |
color: LomiriColors.orange |
| 84 |
height: units.gu(5) |
| 85 |
width: parent ? parent.width - units.gu(2) : undefined |
| 86 |
} |
| 87 |
} |
| 88 |
\endqml |
| 89 |
|
| 90 |
See \l PageHeadState for an example that shows how search mode can |
| 91 |
be implemented. |
| 92 |
*/ |
| 93 |
|
| 94 |
// FIXME: The example below can be much simplified using PageHeadState |
| 95 |
// when bug #1345775 has been fixed. |
| 96 |
/*! |
| 97 |
\qmlproperty string PageHeadConfiguration::preset |
| 98 |
Choose a preset for the header visuals and behavior. |
| 99 |
The default is an empty string "". |
| 100 |
By setting this to "select", title will be hidden and |
| 101 |
actions will be represented by icons with a label. |
| 102 |
|
| 103 |
Example: |
| 104 |
\qml |
| 105 |
import QtQuick 2.4 |
| 106 |
import Lomiri.Components 1.2 |
| 107 |
|
| 108 |
MainView { |
| 109 |
id: mainView |
| 110 |
width: units.gu(40) |
| 111 |
height: units.gu(50) |
| 112 |
|
| 113 |
Page { |
| 114 |
id: page |
| 115 |
title: "Demo" |
| 116 |
|
| 117 |
state: "default" |
| 118 |
states: [ |
| 119 |
PageHeadState { |
| 120 |
name: "default" |
| 121 |
head: page.head |
| 122 |
actions: [ |
| 123 |
Action { |
| 124 |
iconName: "contact" |
| 125 |
text: "Contact" |
| 126 |
} |
| 127 |
] |
| 128 |
}, |
| 129 |
State { |
| 130 |
id: selectState |
| 131 |
name: "select" |
| 132 |
|
| 133 |
property Action leaveSelect: Action { |
| 134 |
iconName: "back" |
| 135 |
text: "Back" |
| 136 |
onTriggered: page.state = "default" |
| 137 |
} |
| 138 |
property list<Action> actions: [ |
| 139 |
Action { |
| 140 |
iconName: "select" |
| 141 |
text: "Select All" |
| 142 |
}, |
| 143 |
Action { |
| 144 |
iconName: "delete" |
| 145 |
text: "Delete" |
| 146 |
} |
| 147 |
] |
| 148 |
PropertyChanges { |
| 149 |
target: page.head |
| 150 |
backAction: selectState.leaveSelect |
| 151 |
actions: selectState.actions |
| 152 |
preset: "select" |
| 153 |
} |
| 154 |
} |
| 155 |
] |
| 156 |
|
| 157 |
Label { |
| 158 |
anchors.centerIn: parent |
| 159 |
text: "Use back button to leave selection mode." |
| 160 |
visible: page.state == "select" |
| 161 |
} |
| 162 |
|
| 163 |
Button { |
| 164 |
anchors.centerIn: parent |
| 165 |
onClicked: page.state = "select" |
| 166 |
visible: page.state != "select" |
| 167 |
text: "selection mode" |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
\endqml |
| 172 |
*/ |
| 173 |
|
| 174 |
/*! |
| 175 |
\qmlproperty PageHeadSections PageHeadConfiguration::sections |
| 176 |
Defines the sections in the page header divider. |
| 177 |
*/ |
| 178 |
|
| 179 |
/*! |
| 180 |
\qmlproperty color PageHeadConfiguration::foregroundColor |
| 181 |
The color of the text and icons. |
| 182 |
*/ |
| 183 |
|
| 184 |
/*! |
| 185 |
\qmlproperty bool PageHeadConfiguration::locked |
| 186 |
\since 1.3 |
| 187 |
When the \l Page is active, the locked property controls the behavior |
| 188 |
of the header. A locked header stays visible or invisible, depending |
| 189 |
on the value of the \l visible property. An unlocked header automatically |
| 190 |
shows and hides if the \l Page has a flickable in which the user |
| 191 |
scrolls up or down. |
| 192 |
Default value: false |
| 193 |
*/ |
| 194 |
|
| 195 |
/*! |
| 196 |
\qmlproperty bool PageHeadConfiguration::visible |
| 197 |
\since 1.3 |
| 198 |
Update the value of the visible property to show or hide the header. |
| 199 |
This works both when the header is \l locked and unlocked. An unlocked |
| 200 |
header can also become visible or hidden when the user scrolls the |
| 201 |
active \l Page's flickable. The value of the visible property will be |
| 202 |
updated at the end of the showing/hiding animation of the header. |
| 203 |
*/ |
| 204 |
|
| 205 |
/*! |
| 206 |
\qmlproperty string PageHeadConfiguration::title |
| 207 |
\since 1.3 |
| 208 |
The title to show in the header. This is automatically copied from |
| 209 |
the \l Page title. |
| 210 |
*/ |