Debian Codegraph @

src/imports/Components/2.0/PageHeadState.qml

raw
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 import QtQuick 2.4
18 import Lomiri.Components // for Action
19
20 /*!
21 \qmltype PageHeadState
22 \inqmlmodule Lomiri.Components
23 \ingroup lomiri
24 \since Lomiri.Components 1.1
25 \deprecated
26 \brief PageHeadState is a helper component to make it easier to
27 configure the page header when changing states.
28
29 This example shows how to add an action to the header that
30 enables the user to enter search/input mode:
31 \qml
32 import QtQuick 2.4
33 import Lomiri.Components
34
35 MainView {
36 id: mainView
37 width: units.gu(40)
38 height: units.gu(50)
39
40 Page {
41 id: searchPage
42 title: "Click the icon"
43
44 Label {
45 anchors.centerIn: parent
46 text: searchPage.state == "search" ? "search mode" : "normal mode"
47 }
48
49 state: "default"
50 states: [
51 PageHeadState {
52 name: "default"
53 head: searchPage.head
54 actions: Action {
55 iconName: "toolkit_input-search"
56 onTriggered: searchPage.state = "search"
57 }
58 },
59 PageHeadState {
60 id: headerState
61 name: "search"
62 head: searchPage.head
63 actions: [
64 Action {
65 iconName: "contact"
66 }
67 ]
68 backAction: Action {
69 id: leaveSearchAction
70 text: "back"
71 iconName: "back"
72 onTriggered: searchPage.state = "default"
73 }
74 contents: TextField {
75 placeholderText: "search..."
76 }
77 }
78 ]
79 }
80 }
81 \endqml
82 */
83 State {
84 id: state
85
86 /*!
87 The head property of the \l Page which will be the target of
88 the property changes of this State. This property must always
89 be set before the State can be used.
90 */
91 property PageHeadConfiguration head
92
93 /*!
94 The actions to be shown in the header with this state.
95 */
96 property list<Action> actions
97
98 /*!
99 The back action for this state.
100 */
101 property Action backAction
102
103 /*!
104 The contents of the header when this state is active.
105 */
106 property Item contents
107
108 PropertyChanges {
109 target: state.head
110 backAction: state.backAction
111 actions: state.actions
112 contents: state.contents
113 }
114 }