Debian Codegraph @

src/imports/Components/1.1/Button.qml

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 * Copyright 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 1.1
19
20 /*!
21 \qmltype Button
22 \inqmlmodule Lomiri.Components
23 \ingroup lomiri
24 \brief Standard Lomiri button.
25
26 \l {http://design.lomiri.com/apps/building-blocks/buttons}{See also the Design Guidelines on Buttons}.
27
28 Examples:
29 \qml
30 Column {
31 Button {
32 text: "Send"
33 onClicked: print("clicked text-only Button")
34 }
35 Button {
36 iconName: "compose"
37 gradient: LomiriColors.greyGradient
38 onClicked: print("clicked icon-only Button")
39 }
40 Button {
41 iconName: "compose"
42 text: "Icon on left"
43 iconPosition: "left"
44 onClicked: print("clicked text and icon Button")
45 }
46 }
47 \endqml
48 An \l Action can be used to specify \b clicked, iconSource and text. Example:
49 \qml
50 Item {
51 Action {
52 id: action1
53 text: "Click me"
54 onTriggered: print("action!")
55 iconName: "compose"
56 }
57 Button {
58 anchors.centerIn: parent
59 action: action1
60 color: LomiriColors.warmGrey
61 }
62 }
63 \endqml*/
64 AbstractButton {
65 id: button
66 /*!
67 \since Lomiri.Components 1.1
68 If set to a color, the button has a stroke border instead of a filled shape.
69 */
70 property color strokeColor: Qt.rgba(0.0, 0.0, 0.0, 0.0)
71
72 /*!
73 \qmlproperty url Button::iconSource
74 The source URL of the icon to display inside the button.
75 Leave this value blank for a text-only button.
76 If \l action is set, the default iconSource is that of the action.
77 */
78
79 /*!
80 The text to display in the button. If an icon was defined,
81 the text will be shown next to the icon, otherwise it will
82 be centered. Leave blank for an icon-only button.
83 If \l action is set, the default text is that of the action.
84 \qmlproperty string Button::text
85 */
86
87 /*!
88 The background color of the button.
89
90 \sa gradient
91 */
92 property color color: __styleInstance.defaultColor
93
94 /*!
95 The gradient used to fill the background of the button.
96
97 Standard Lomiri gradients are defined in \l LomiriColors.
98
99 If both a gradient and a color are specified, the gradient will be used.
100
101 \sa color
102 */
103 property Gradient gradient: __styleInstance.defaultGradient
104
105 /*!
106 The font used for the button's text.
107 */
108 property font font: __styleInstance ? __styleInstance.defaultFont : Qt.font({family: "Ubuntu", pixelSize: FontUtils.sizeToPixels("medium")})
109
110 /*!
111 The position of the icon relative to the text. Options
112 are "left" and "right". The default value is "left".
113
114 If only text or only an icon is defined, this
115 property is ignored and the text or icon is
116 centered horizontally and vertically in the button.
117
118 Currently this is a string value. We are waiting for
119 support for enums:
120 https://bugreports.qt-project.org/browse/QTBUG-14861
121 */
122 property string iconPosition: "left"
123
124 style: Theme.createStyleComponent("ButtonStyle.qml", button)
125 }