Merge lp:~tpeeters/ubuntu-ui-toolkit/90-IconButton into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters on 2015-05-22
Status: Merged
Approved by: Christian Dywan on 2015-05-26
Approved revision: 1522
Merged at revision: 1519
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/90-IconButton
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 164 lines (+96/-6)
5 files modified
modules/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml (+6/-4)
modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml (+80/-0)
modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml (+1/-0)
tests/unit_x11/tst_components/tst_actionbar.qml (+1/-1)
tests/unit_x11/tst_components/tst_header_presets.qml (+8/-1)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/90-IconButton
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-05-26
Christian Dywan 2015-05-22 Approve on 2015-05-26
Review via email: mp+259906@code.launchpad.net

Commit Message

Introduce IconButtonStyle.

Description of the Change

Introduce IconButtonStyle.

This is an intermediate MR. In a following MR the PageHeadStyle will use the ActionBar (and to be added SectionsBar) component, and the (internal) PageHeadButton will be removed from the Ambience Theme.

ActionBar will have a delegate property which by default will be an AbstractButton using IconButtonStyle.

See also the API discussion for Button on https://docs.google.com/document/d/1MN-Uk15mLi0vbkmekhwzwrWCxIfh06fm9z2WmwwMll0/edit#

To post a comment you must log in.
1519. By Tim Peeters on 2015-05-22

new default icon size in IconButtonStyle

1520. By Tim Peeters on 2015-05-22

clean

1521. By Tim Peeters on 2015-05-22

clean

Christian Dywan (kalikiana) wrote :

89 + // prevent trying to render the icon with an invalid source
90 + // when the button is invisible by setting width and height to 0
91 + width: visible ? iconButtonStyle.iconWidth : 0
92 + height: visible ? iconButtonStyle.iconHeight : 0
93 + source: styledItem.iconSource

Of these two instances in the code none of them is without an icon. Where will this be used? Why can't this be solved in the Icon component? Or am I just confused over what this is supposed to be doing?

review: Needs Information
1522. By Tim Peeters on 2015-05-26

no need to check visibility in Icon

Tim Peeters (tpeeters) wrote :

Right. There was a similar workaround in PageHeadButton; that's where I got this from. But after some investigation I think that workaround may be there for an issue with the header popping a page from the stack where the Image already gets destroyed before the Icon that shows it. Not an issue here.

Christian Dywan (kalikiana) wrote :

Cool. Thanks!

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml'
2--- modules/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-05-14 21:36:26 +0000
3+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-05-26 10:54:29 +0000
4@@ -58,19 +58,21 @@
5 Repeater {
6 objectName: "actions_repeater"
7 model: numberOfSlots.used
8- PageHeadButton {
9+ AbstractButton {
10+ style: IconButtonStyle { }
11 id: actionButton
12 objectName: action.objectName + "_action_button"
13+ height: actionsContainer.height
14 action: actionsContainer.visibleActions[index]
15- iconWidth: units.gu(2)
16 }
17 }
18
19- PageHeadButton {
20+ AbstractButton {
21+ style: IconButtonStyle { }
22 id: actionsOverflowButton
23 objectName: "actions_overflow_button"
24+ height: actionsContainer.height
25 visible: numberOfSlots.requested > numberOfSlots.available
26- iconWidth: units.gu(2)
27
28 // Ensure resetting of X when this button is not visible to avoid
29 // miscalculation of actionsContainer.width. Fixes bug #1408481.
30
31=== added file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml'
32--- modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 1970-01-01 00:00:00 +0000
33+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 2015-05-26 10:54:29 +0000
34@@ -0,0 +1,80 @@
35+/*
36+ * Copyright 2015 Canonical Ltd.
37+ *
38+ * This program is free software; you can redistribute it and/or modify
39+ * it under the terms of the GNU Lesser General Public License as published by
40+ * the Free Software Foundation; version 3.
41+ *
42+ * This program is distributed in the hope that it will be useful,
43+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
44+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+ * GNU Lesser General Public License for more details.
46+ *
47+ * You should have received a copy of the GNU Lesser General Public License
48+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
49+ */
50+
51+import QtQuick 2.4
52+import Ubuntu.Components 1.3
53+
54+Item {
55+ id: iconButtonStyle
56+
57+ implicitWidth: units.gu(5)
58+ implicitHeight: units.gu(5)
59+
60+ /*!
61+ The color of the icons.
62+ */
63+ property color foregroundColor: "#808080"
64+
65+ /*!
66+ The background color of the button.
67+ */
68+ property color backgroundColor: styledItem.pressed ?
69+ theme.palette.selected.background :
70+ "transparent"
71+
72+ property real iconWidth: units.gu(2)
73+ property real iconHeight: iconWidth
74+
75+ /*!
76+ Show a text label under the icon.
77+ */
78+ property bool showLabel: false
79+
80+ Rectangle {
81+ id: background
82+ color: iconButtonStyle.backgroundColor
83+ anchors.fill: parent
84+ }
85+
86+ Icon {
87+ id: icon
88+ anchors.centerIn: parent
89+ width: iconButtonStyle.iconWidth
90+ height: iconButtonStyle.iconHeight
91+ source: styledItem.iconSource
92+ color: iconButtonStyle.foregroundColor
93+ opacity: styledItem.enabled ? 1.0 : 0.3
94+ }
95+
96+ Component {
97+ id: labelComponent
98+ Label {
99+ objectName: styledItem.objectName + "_label"
100+ color: iconButtonStyle.foregroundColor
101+ opacity: styledItem.enabled ? 1.0 : 0.3
102+ text: styledItem.text
103+ fontSize: "xx-small"
104+ }
105+ }
106+ Loader {
107+ anchors {
108+ top: icon.bottom
109+ topMargin: units.gu(0.5)
110+ horizontalCenter: parent.horizontalCenter
111+ }
112+ sourceComponent: iconButtonStyle.showLabel ? labelComponent : null
113+ }
114+}
115
116=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml'
117--- modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml 2015-05-12 15:05:28 +0000
118+++ modules/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml 2015-05-26 10:54:29 +0000
119@@ -17,6 +17,7 @@
120 import QtQuick 2.4
121 import Ubuntu.Components 1.3
122
123+// TODO: Remove this component when PageHeadStyle uses ActionBar
124 AbstractButton {
125 id: button
126
127
128=== modified file 'tests/unit_x11/tst_components/tst_actionbar.qml'
129--- tests/unit_x11/tst_components/tst_actionbar.qml 2015-05-14 21:41:16 +0000
130+++ tests/unit_x11/tst_components/tst_actionbar.qml 2015-05-26 10:54:29 +0000
131@@ -30,7 +30,7 @@
132 },
133 Action {
134 iconName: "appointment"
135- text: "Appointment"
136+ text: "Date"
137 },
138 Action {
139 iconName: "attachment"
140
141=== modified file 'tests/unit_x11/tst_components/tst_header_presets.qml'
142--- tests/unit_x11/tst_components/tst_header_presets.qml 2015-03-03 13:20:06 +0000
143+++ tests/unit_x11/tst_components/tst_header_presets.qml 2015-05-26 10:54:29 +0000
144@@ -1,5 +1,5 @@
145 /*
146- * Copyright 2014 Canonical Ltd.
147+ * Copyright 2015 Canonical Ltd.
148 *
149 * This program is free software; you can redistribute it and/or modify
150 * it under the terms of the GNU Lesser General Public License as published by
151@@ -35,6 +35,13 @@
152 objectName: "selectAction"
153 text: "Select all"
154 iconName: "select"
155+ onTriggered: {
156+ if (page.head.preset === "") {
157+ page.head.preset = "select";
158+ } else {
159+ page.head.preset = "";
160+ }
161+ }
162 }
163 ]
164 }

Subscribers

People subscribed via source and target branches