Debian Codegraph @

src/app/qml/components/TextualButtonStyle.qml

raw
1 /*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU 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.3
19
20 Component {
21 id: textualButton
22 AbstractButton {
23 id: button
24 property bool smallText: action.hasOwnProperty("smallText")
25 property bool showText: action.hasOwnProperty("showText")
26 action: modelData
27 width: layout.width + units.gu(4)
28 height: parent.height
29 Rectangle {
30 color: theme.palette.normal.backgroundSecondaryText
31 opacity: 0.1
32 anchors.fill: parent
33 visible: button.pressed
34 }
35 Row {
36 id: layout
37 anchors.centerIn: parent
38 spacing: units.gu(1)
39 Icon {
40 anchors.verticalCenter: parent.verticalCenter
41 width: visible ? units.gu(2) : 0
42 height: width
43 name: action.iconName
44 source: action.iconSource
45 visible: (name != "") || (source != "")
46 color: {
47 if (button.enabled)
48 return text === i18n.tr("Pick") ? theme.palette.selected.backgroundText : theme.palette.normal.backgroundText
49
50 return theme.palette.disabled.backgroundText
51 }
52 }
53 Label {
54 anchors.verticalCenter: parent.verticalCenter
55 text: action.text
56 font.weight: text === i18n.tr("Pick") ? Font.Normal : Font.Light
57 // Hide text from overflow button of ActionBar
58 visible: text !== "More" && !button.showText
59 width: visible ? paintedWidth : 0
60 textSize: button.smallText ? Label.Small : Label.Medium
61 color: {
62 if (button.enabled)
63 return text === i18n.tr("Pick") ? theme.palette.selected.backgroundText : theme.palette.normal.backgroundText
64
65 return theme.palette.disabled.backgroundText
66 }
67 }
68 }
69 }
70 }