Debian Codegraph @

src/imports/Components/1.2/ToolbarButton.qml

raw
1 /*
2 * Copyright (C) 2013 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 1.2
19
20 /*!
21 \qmltype ToolbarButton
22 \inqmlmodule Lomiri.Components
23 \ingroup lomiri
24 \brief An \l ActionItem that represents a button in the toolbar.
25 ToolbarButtons should be included in \l ToolbarItems to define the tools of a \l Page.
26 The behavior and look of the toolbar button can be specified by setting an \l Action for
27 the button, or by setting the other properties inherited by the \l ActionItem.
28
29 Example of different ways to define the toolbar button:
30 \qml
31 import QtQuick 2.4
32 import Lomiri.Components 1.2
33
34 MainView {
35 width: units.gu(50)
36 height: units.gu(80)
37
38 Action {
39 id: action1
40 text: "action 1"
41 iconName: "compose"
42 onTriggered: print("one!")
43 }
44
45 Page {
46 title: "test page"
47
48 Label {
49 anchors.centerIn: parent
50 text: "Hello, world"
51 }
52
53 tools: ToolbarItems {
54 // reference to an action:
55 ToolbarButton {
56 action: action1
57 }
58
59 // define the action:
60 ToolbarButton {
61 action: Action {
62 text: "Second action"
63 iconName: "add"
64 onTriggered: print("two!")
65 }
66 // override the text of the action:
67 text: "action 2"
68 }
69
70 // no associated action:
71 ToolbarButton {
72 iconName: "cancel"
73 text: "button"
74 onTriggered: print("three!")
75 }
76 }
77 }
78 }
79 \endqml
80 See \l ToolbarItems for more information on how to use ToolbarButton.
81 */
82 ActionItem {
83 id: toolbarButton
84 height: parent ? parent.height : undefined
85 width: units.gu(5)
86
87 style: Theme.createStyleComponent("ToolbarButtonStyle.qml", toolbarButton)
88 }