Merge lp:~bpierre/ubuntu-ui-toolkit/newbutton into lp:ubuntu-ui-toolkit/staging

Proposed by Pierre Bertet
Status: Work in progress
Proposed branch: lp:~bpierre/ubuntu-ui-toolkit/newbutton
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-dynamic-shapes-for-new-design
Diff against target: 1810 lines (+1027/-392)
22 files modified
components.api (+16/-3)
examples/ubuntu-ui-toolkit-gallery/Buttons.qml (+116/-55)
src/Ubuntu/Components/1.3/Button.qml (+0/-125)
src/Ubuntu/Components/ComponentModule.pro (+0/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml (+29/-52)
src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonStyle.qml (+135/-132)
src/Ubuntu/Components/Themes/Ambiance/1.3/Palette.qml (+24/-12)
src/Ubuntu/Components/Themes/Ambiance/1.3/TextButtonStyle.qml (+76/-0)
src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro (+1/-0)
src/Ubuntu/Components/Themes/Ambiance/qmldir (+1/-0)
src/Ubuntu/Components/plugin/button.cpp (+268/-0)
src/Ubuntu/Components/plugin/button.h (+84/-0)
src/Ubuntu/Components/plugin/button_p.h (+46/-0)
src/Ubuntu/Components/plugin/plugin.cpp (+4/-0)
src/Ubuntu/Components/plugin/plugin.pri (+7/-7)
src/Ubuntu/Components/plugin/textbutton.cpp (+134/-0)
src/Ubuntu/Components/plugin/textbutton.h (+51/-0)
src/Ubuntu/Components/plugin/ucabstractbutton.cpp (+1/-1)
src/Ubuntu/Components/plugin/ucabstractbutton.h (+1/-1)
src/Ubuntu/Components/qmldir (+0/-1)
tests/unit/tst_performance/ButtonGrid13.qml (+30/-0)
tests/unit/tst_performance/tst_performance.cpp (+3/-2)
To merge this branch: bzr merge lp:~bpierre/ubuntu-ui-toolkit/newbutton
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Needs Fixing
Zsombor Egri Pending
Review via email: mp+291389@code.launchpad.net

This proposal supersedes a proposal from 2016-02-15.

Commit message

TextButton component, Button style and API update

- The new Button style has been implemented and is using the new Palette.
- The component is now a CPP plugin to support enum properties.
- [API] add `type`: allow to specify the type of button (normal, positive, negative, outline)
- [API] change `iconInsertion`: accept `Button.After` and `Button.Before`
- [API] deprecate `color`: moved in the button styles
- [API] deprecate `gradient`: moved in the button styles
- [API] deprecate `strokeColor`: moved in the button styles

Description of the change

TextButton component, Button style and API update

- The new Button style has been implemented and is using the new Palette.
- The component is now a CPP plugin to support enum properties.
- [API] add `type`: allow to specify the type of button (normal, positive, negative, outline)
- [API] change `iconInsertion`: accept `Button.After` and `Button.Before`
- [API] deprecate `color`: moved in the button styles
- [API] deprecate `gradient`: moved in the button styles
- [API] deprecate `strokeColor`: moved in the button styles

To post a comment you must log in.
Revision history for this message
Zsombor Egri (zsombi) wrote : Posted in a previous version of this proposal

Button implementation is missing. I've added few comments below, please condor those, they are crucial.

I was thinking whether this common style for all the buttons makes sense... Shouldn't we have separate style files for each button type rather than have one where we disable some visuals because they are not in use? Think about performance.

review: Needs Fixing
Revision history for this message
Pierre Bertet (bpierre) wrote : Posted in a previous version of this proposal

Thanks for your comments, I made the required changes.

About splitting the button: the new structure (Frame instead of UbuntuShape) is simpler and there is no unused component.

But a special behavior has been required for the text button: there should be a way to make it “strong” (bold text), and the “emphasis” property is never going to be used for them. The API is not going to be the same anymore, so I will split it in separate components.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Pierre Bertet (bpierre) wrote : Posted in a previous version of this proposal

I added the TextButton component, and removed it from Button. They are now two separate components and all the components in ButtonStyle.qml are shared by the Button.Normal and Button.Outline types.

Revision history for this message
Zsombor Egri (zsombi) wrote : Posted in a previous version of this proposal

Shouldn't you have ButtonStyle and TextButtonStyle in Ubuntu.Components.Styles?

See few comments below.

review: Needs Fixing
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Pierre Bertet (bpierre) : Posted in a previous version of this proposal
Revision history for this message
Pierre Bertet (bpierre) : Posted in a previous version of this proposal
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
1889. By Pierre Bertet

Revert development related changes on the Shadow Test app

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Pierre Bertet (bpierre) wrote :

@Zsombor Ready to be reviewed.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

1889. By Pierre Bertet

Revert development related changes on the Shadow Test app

1888. By Pierre Bertet

Move FocusShape to ShapeFrame

1887. By Pierre Bertet

[sync] merge staging

1886. By Pierre Bertet

[sync] merge staging

1885. By Pierre Bertet

Minor documentation fix

1884. By Pierre Bertet

Remove backgroundPositiveText and backgroundNegativeText from the Palette values

1883. By Pierre Bertet

[sync] merge staging

1882. By Pierre Bertet

Button: remove emphasis, move Positive and Negative to types

The outline mode of the button do not include the positive and negative
emphases anymore. Therefore, the positive and negative emphases have been moved
to the type property, since they (outline vs. positive / negative) are now
mutually exclusive.

A button can now have the following types:

- Button.Normal (default)
- Button.Outline
- Button.Positive
- Button.Negative

1881. By Pierre Bertet

[sync] merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-dynamic-shapes-for-new-design

1880. By Pierre Bertet

[sync] merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-dynamic-shapes-for-new-design

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components.api'
--- components.api 2016-04-05 05:56:32 +0000
+++ components.api 2016-04-08 16:09:06 +0000
@@ -246,12 +246,13 @@
246 property Gradient gradient246 property Gradient gradient
247 property string iconPosition247 property string iconPosition
248 property color strokeColor248 property color strokeColor
249Ubuntu.Components.Button 1.3: AbstractButton249Ubuntu.Components.Button 1.3 UbuntuToolkit::Button: AbstractButton
250 property color color250 property color color
251 property QFont font251 property QFont font
252 property Gradient gradient252 property QGradient gradient
253 property string iconPosition253 property IconPosition iconPosition
254 property color strokeColor254 property color strokeColor
255 property Type type
255Ubuntu.Components.ListItems.Caption 1.0 0.1: Item256Ubuntu.Components.ListItems.Caption 1.0 0.1: Item
256 property string text257 property string text
257Ubuntu.Components.ListItems.Caption 1.3: Item258Ubuntu.Components.ListItems.Caption 1.3: Item
@@ -1398,6 +1399,8 @@
1398 property int textFormat1399 property int textFormat
1399 property int verticalAlignment1400 property int verticalAlignment
1400 property int wrapMode1401 property int wrapMode
1402Ubuntu.Components.TextButton 1.3 UbuntuToolkit::TextButton: AbstractButton
1403 property bool strong
1401Ubuntu.Components.TextField 1.0 0.1: ActionItem1404Ubuntu.Components.TextField 1.0 0.1: ActionItem
1402 readonly property bool acceptableInput1405 readonly property bool acceptableInput
1403 property bool autoScroll1406 property bool autoScroll
@@ -1743,6 +1746,16 @@
1743 function var warningFormat(var line, var column, var message)1746 function var warningFormat(var line, var column, var message)
1744 function var waitForHeaderAnimation(var mainView)1747 function var waitForHeaderAnimation(var mainView)
1745 readonly property QuickTestUtil testUtil1748 readonly property QuickTestUtil testUtil
1749Ubuntu.Components.UbuntuToolkit.Button: Enum
1750 Negative
1751 Normal
1752 Outline
1753 Positive
1754Ubuntu.Components.UbuntuToolkit.Button: Enum
1755 After
1756 Before
1757 left
1758 right
1746Ubuntu.Components.UriHandler 1.0 0.1: QtObject singleton1759Ubuntu.Components.UriHandler 1.0 0.1: QtObject singleton
1747 signal opened(QStringList uris)1760 signal opened(QStringList uris)
1748Ubuntu.Components.ListItems.ValueSelector 1.0 0.1: Empty1761Ubuntu.Components.ListItems.ValueSelector 1.0 0.1: Empty
17491762
=== modified file 'examples/ubuntu-ui-toolkit-gallery/Buttons.qml'
--- examples/ubuntu-ui-toolkit-gallery/Buttons.qml 2016-02-12 10:55:51 +0000
+++ examples/ubuntu-ui-toolkit-gallery/Buttons.qml 2016-04-08 16:09:06 +0000
@@ -25,85 +25,150 @@
25 className: "Button"25 className: "Button"
2626
27 TemplateFlow {27 TemplateFlow {
28 title: i18n.tr("Standard")28 title: i18n.tr("Types")
2929
30 Button {30 Button {
31 objectName: "button_text"31 objectName: "button_neutral"
32 text: i18n.tr("Call")32 text: i18n.tr("Normal")
33 }
34 Button {
35 objectName: "button_positive"
36 text: i18n.tr("Positive")
37 type: Button.Positive
38 }
39 Button {
40 objectName: "button_negative"
41 text: i18n.tr("Negative")
42 type: Button.Negative
43 }
44 Button {
45 objectName: "button_outline"
46 text: i18n.tr("Outline")
47 type: Button.Outline
33 }48 }
34 }49 }
3550
36 TemplateFlow {51 TemplateFlow {
37 title: i18n.tr("Stroke")52 title: "Disabled"
3853
39 Button {54 Button {
40 objectName: "button_stroke"55 objectName: "button_normal_disabled"
41 text: i18n.tr("Call")56 text: i18n.tr("Neutral")
42 strokeColor: UbuntuColors.warmGrey57 enabled: false
58 }
59 Button {
60 objectName: "button_positive_disabled"
61 text: i18n.tr("Positive")
62 type: Button.Positive
63 enabled: false
64 }
65 Button {
66 objectName: "button_negative_disabled"
67 text: i18n.tr("Negative")
68 type: Button.Negative
69 enabled: false
70 }
71 Button {
72 objectName: "button_outline_disabled"
73 text: i18n.tr("Outline")
74 type: Button.Outline
75 enabled: false
43 }76 }
44 }77 }
4578
46 TemplateFlow {79 TemplateFlow {
47 title: i18n.tr("Color")80 title: i18n.tr("Color")
48
49 Button {81 Button {
82 id: buttonColor
50 objectName: "button_color"83 objectName: "button_color"
51 width: units.gu(20)
52 action: Action {84 action: Action {
53 text: i18n.tr("C&all %1").arg(shortcut)85 text: i18n.tr("Switch (%1)").arg(shortcut)
54 shortcut: 'Ctrl+L'86 shortcut: 'Ctrl+C'
55 property bool flipped87 property bool flipped
56 onTriggered: flipped = !flipped88 onTriggered: flipped = !flipped
57 }89 }
58 color: action.flipped ? UbuntuColors.blue : UbuntuColors.green90 StyleHints {
91 textColor: "white"
92 color: (
93 buttonColor.action.flipped? "#3EB34F" : "#19B6EE"
94 )
95 }
59 }96 }
60 }97 }
6198
62 TemplateFlow {99 TemplateFlow {
63 title: i18n.tr("Icon")100 title: i18n.tr("Icon")
64101 Button {
65 Button {102 objectName: "button_icon"
66 objectName: "button_iconsource"103 type: Button.Positive
67 iconSource: "call.png"104 iconName: "call-start"
68 }105 StyleHints {
69 }106 minimumWidth: 0
70107 }
71 TemplateFlow {108 }
72 title: i18n.tr("Icon+Text")109 }
73110
74 Button {111 TemplateFlow {
75 objectName: "button_iconsource_right_text"112 title: i18n.tr("Icon + Text")
76 width: units.gu(10)113 Button {
77 text: i18n.tr("Call")114 objectName: "button_icon_right_text"
78 iconSource: "call.png"115 text: i18n.tr("Delete")
79 iconPosition: "right"116 type: Button.Negative
80 }117 iconName: "delete"
81118 StyleHints {
82 Button {119 minimumWidth: 0
83 objectName: "button_iconsource_left_text"120 }
84 width: units.gu(10)121 }
85 text: i18n.tr("Call")122 Button {
86 iconSource: "call.png"123 objectName: "button_icon_left_text"
87 }124 text: i18n.tr("Call")
88 }125 iconName: "call-start"
89126 type: Button.Positive
90 TemplateFlow {127 iconPosition: Button.After
91 title: i18n.tr("Disabled")128 StyleHints {
92129 minimumWidth: 0
93 Button {130 }
94 objectName: "button_text_disabled"131 }
95 text: i18n.tr("Call")132 }
96 enabled: false133 }
97 }134
98 }135 TemplateSection {
99 }136 className: "TextButton"
100137
101 TemplateSection {138 TemplateFlow {
139 title: i18n.tr("Text")
140 TextButton {
141 objectName: "textbutton_normal"
142 text: i18n.tr("Normal")
143 }
144 TextButton {
145 objectName: "textbutton_strong"
146 text: i18n.tr("Strong")
147 strong: true
148 }
149 }
150
151 TemplateFlow {
152 TextButton {
153 objectName: "textbutton_normal_disabled"
154 text: i18n.tr("Normal")
155 enabled: false
156 }
157 TextButton {
158 objectName: "textbutton_strong_disabled"
159 text: i18n.tr("Strong")
160 strong: true
161 enabled: false
162 }
163 }
164 }
165
166 TemplateSection {
167 visible: false
102 className: "ComboButton"168 className: "ComboButton"
103169
104 TemplateFlow {170 TemplateFlow {
105 title: i18n.tr("Collapsed")171 title: i18n.tr("Collapsed")
106
107 ComboButton {172 ComboButton {
108 text: "Press me"173 text: "Press me"
109 objectName: "combobutton_collapsed"174 objectName: "combobutton_collapsed"
@@ -119,7 +184,6 @@
119184
120 TemplateFlow {185 TemplateFlow {
121 title: i18n.tr("Icon")186 title: i18n.tr("Icon")
122
123 ComboButton {187 ComboButton {
124 iconSource: "call.png"188 iconSource: "call.png"
125 width: parent.width < units.gu(30)? parent.width : units.gu(30)189 width: parent.width < units.gu(30)? parent.width : units.gu(30)
@@ -131,10 +195,8 @@
131 }195 }
132 }196 }
133 }197 }
134
135 TemplateFlow {198 TemplateFlow {
136 title: i18n.tr("Icon+Text")199 title: i18n.tr("Icon+Text")
137
138 ComboButton {200 ComboButton {
139 text: "Answer"201 text: "Answer"
140 iconSource: "call.png"202 iconSource: "call.png"
@@ -149,7 +211,6 @@
149 }211 }
150 TemplateFlow {212 TemplateFlow {
151 title: i18n.tr("Expanded")213 title: i18n.tr("Expanded")
152
153 ComboButton {214 ComboButton {
154 text: "Press me"215 text: "Press me"
155 objectName: "combobutton_expanded"216 objectName: "combobutton_expanded"
156217
=== removed file 'src/Ubuntu/Components/1.3/Button.qml'
--- src/Ubuntu/Components/1.3/Button.qml 2015-09-28 14:36:54 +0000
+++ src/Ubuntu/Components/1.3/Button.qml 1970-01-01 00:00:00 +0000
@@ -1,125 +0,0 @@
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
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20/*!
21 \qmltype Button
22 \inqmlmodule Ubuntu.Components 1.1
23 \ingroup ubuntu
24 \brief Standard Ubuntu button.
25
26 \l {http://design.ubuntu.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: UbuntuColors.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: UbuntuColors.warmGrey
61 }
62 }
63 \endqml*/
64AbstractButton {
65 id: button
66 /*!
67 \since Ubuntu.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 Ubuntu gradients are defined in \l UbuntuColors.
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.defaultFont
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 styleName: "ButtonStyle"
125}
1260
=== modified file 'src/Ubuntu/Components/ComponentModule.pro'
--- src/Ubuntu/Components/ComponentModule.pro 2016-02-16 11:39:32 +0000
+++ src/Ubuntu/Components/ComponentModule.pro 2016-04-08 16:09:06 +0000
@@ -83,7 +83,6 @@
83 1.3/AdaptivePageLayout.qml \83 1.3/AdaptivePageLayout.qml \
84 1.3/AnimatedItem.qml \84 1.3/AnimatedItem.qml \
85 1.3/AppHeader.qml \85 1.3/AppHeader.qml \
86 1.3/Button.qml \
87 1.3/Captions.qml \86 1.3/Captions.qml \
88 1.3/CheckBox.qml \87 1.3/CheckBox.qml \
89 1.3/ComboButton.qml \88 1.3/ComboButton.qml \
9089
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml 2015-09-07 10:05:58 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml 2016-04-08 16:09:06 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013 Canonical Ltd.2 * Copyright 2016 Canonical Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU Lesser General Public License as published by
@@ -14,42 +14,47 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Author: Florian Boucault <florian.boucault@canonical.com>16 * Author: Florian Boucault <florian.boucault@canonical.com>
17 * Author: Pierre Bertet <pierre.bertet@canonical.com>
17 */18 */
1819
19import QtQuick 2.420import QtQuick 2.4
20import Ubuntu.Components 1.321import Ubuntu.Components 1.3
2122
22Item {23Item {
23 id: buttonForeground24 id: root
2425
25 property alias text: label.text26 property alias text: label.text
26 property alias textColor: label.color27 property alias textColor: label.color
27 property alias iconSource: icon.source28 property alias iconSource: icon.source
28 property string iconPosition
29 property real iconSize29 property real iconSize
30 property real spacing30 property real spacing
31 property alias font: label.font
32 property int iconPosition
31 property bool hasIcon: iconSource != ""33 property bool hasIcon: iconSource != ""
32 property bool hasText: text != ""34 property bool hasText: text != ""
33 property alias font: label.font35 property bool hasBoth: hasIcon && hasText
3436
35 opacity: enabled ? 1.0 : 0.537 state: hasBoth && iconPosition === Button.After? "right" : "left"
38 implicitWidth: (
39 (hasText? label.width : 0) +
40 (hasBoth? spacing : 0) +
41 (hasIcon? icon.width : 0)
42 )
36 implicitHeight: Math.max(icon.height, label.height)43 implicitHeight: Math.max(icon.height, label.height)
37 state: hasIcon && hasText ? iconPosition : "center"
3844
39 Image {45 Icon {
40 id: icon46 id: icon
47 visible: hasIcon
41 anchors.verticalCenter: parent.verticalCenter48 anchors.verticalCenter: parent.verticalCenter
42 fillMode: Image.PreserveAspectFit
43 width: iconSize49 width: iconSize
44 height: iconSize50 height: iconSize
51 color: textColor
45 }52 }
4653
47 Label {54 Label {
48 id: label55 id: label
49 anchors {56 visible: hasText
50 verticalCenter: parent.verticalCenter57 anchors.verticalCenter: parent.verticalCenter
51 verticalCenterOffset: units.dp(-1)
52 }
53 elide: Text.ElideRight58 elide: Text.ElideRight
54 }59 }
5560
@@ -58,58 +63,30 @@
58 name: "left"63 name: "left"
59 AnchorChanges {64 AnchorChanges {
60 target: icon65 target: icon
61 anchors.left: buttonForeground.left66 anchors.left: root.left
62 }67 }
63 AnchorChanges {68 AnchorChanges {
64 target: label69 target: label
65 anchors.left: icon.right70 anchors.left: hasIcon? icon.right : root.left
66 }71 }
67 PropertyChanges {72 PropertyChanges {
68 target: label73 target: label
69 anchors.leftMargin: spacing74 anchors.leftMargin: hasIcon? units.gu(1) : 0
70 width: buttonForeground.width - icon.width - spacing
71 }
72 PropertyChanges {
73 target: buttonForeground
74 implicitWidth: icon.implicitWidth + spacing + label.implicitWidth
75 }75 }
76 },76 },
77 State {77 State {
78 name: "right"78 name: "right"
79 AnchorChanges {79 AnchorChanges {
80 target: icon80 target: icon
81 anchors.right: buttonForeground.right81 anchors.right: root.right
82 }82 }
83 AnchorChanges {83 AnchorChanges {
84 target: label84 target: label
85 anchors.left: buttonForeground.left85 anchors.right: icon.left
86 }86 }
87 PropertyChanges {87 PropertyChanges {
88 target: label88 target: label
89 width: buttonForeground.width - icon.width - spacing89 anchors.rightMargin: units.gu(1)
90 }
91 PropertyChanges {
92 target: buttonForeground
93 implicitWidth: label.implicitWidth + spacing + icon.implicitWidth
94 }
95 },
96 State {
97 name: "center"
98 AnchorChanges {
99 target: icon
100 anchors.horizontalCenter: buttonForeground.horizontalCenter
101 }
102 AnchorChanges {
103 target: label
104 anchors.horizontalCenter: buttonForeground.horizontalCenter
105 }
106 PropertyChanges {
107 target: label
108 width: Math.min(label.implicitWidth, buttonForeground.width)
109 }
110 PropertyChanges {
111 target: buttonForeground
112 implicitWidth: hasText ? label.implicitWidth : icon.implicitWidth
113 }90 }
114 }91 }
115 ]92 ]
11693
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonStyle.qml 2015-12-09 14:45:54 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonStyle.qml 2016-04-08 16:09:06 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013 Canonical Ltd.2 * Copyright 2016 Canonical Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU Lesser General Public License as published by
@@ -14,169 +14,172 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Author: Florian Boucault <florian.boucault@canonical.com>16 * Author: Florian Boucault <florian.boucault@canonical.com>
17 * Author: Pierre Bertet <pierre.bertet@canonical.com>
17 */18 */
1819
19import QtQuick 2.420import QtQuick 2.4
20import Ubuntu.Components 1.321import Ubuntu.Components 1.3
22import Ubuntu.Components.Private 1.3
2123
22Item {24Item {
23 id: buttonStyle25 id: buttonStyle
2426
25 property var button: styledItem27 property var button: styledItem
26 property real minimumWidth: units.gu(10)28 property real minimumWidth: button.iconName && button.text? 0 : units.gu(10)
27 property real horizontalPadding: units.gu(1)29 property real horizontalPadding: units.gu(2)
28 // FIXME: Add this color to the palette30 property real iconSpacing: units.gu(1)
29 property color defaultColor: "#b2b2b2"31
30 property font defaultFont: Qt.font({family: "Ubuntu", pixelSize: FontUtils.sizeToPixels("medium")})32 property QtObject palette: (
31 property Gradient defaultGradient33 button.enabled? theme.palette.normal : theme.palette.disabled
32 property real buttonFaceOffset: 034 )
33 property bool stroke: button.hasOwnProperty("strokeColor") && button.strokeColor != Qt.rgba(0.0, 0.0, 0.0, 0.0)35
36 property color color: {
37 // In Outline mode, the border has the same color than the text
38 if (button.type === Button.Outline) {
39 return textColor
40 }
41 if (button.type === Button.Positive) {
42 return palette.positive
43 }
44 if (button.type === Button.Negative) {
45 return palette.negative
46 }
47 return palette.foreground
48 }
49
50 property color textColor: {
51 if (button.type === Button.Positive) {
52 return palette.positiveText
53 }
54 if (button.type === Button.Negative) {
55 return palette.negativeText
56 }
57 return palette.foregroundText
58 }
59
60 property real frameThickness: units.dp(1)
61
62 property real radius: units.gu(0.6)
63
64 property color overlayColor: palette.foregroundText
65
66 property font defaultFont: Qt.font({
67 family: "Ubuntu",
68 pixelSize: FontUtils.sizeToPixels("medium"),
69 })
70
34 /*!71 /*!
35 The property overrides the button's default background with an item. This72 The property overrides the button's default background with an item. This
36 item can be used by derived styles to reuse the ButtonStyle and override73 item can be used by derived styles to reuse the ButtonStyle and override
37 the default coloured background with an image or any other drawing.74 the default coloured background with an image or any other drawing.
38 The default value is null.75 The default value is null.
39 */76 */
40 property Item backgroundSource: null77 property Item backgroundSource: null
4178
42 width: button.width79 width: button.width
43 height: button.height80 height: button.height
44 implicitWidth: Math.max(minimumWidth, foreground.implicitWidth + 2*horizontalPadding)81 implicitWidth: Math.max(minimumWidth, foreground.width + 2 * horizontalPadding)
45 implicitHeight: units.gu(4)82 implicitHeight: units.gu(4)
4683
47 LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft84 LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
48 LayoutMirroring.childrenInherit: true85 LayoutMirroring.childrenInherit: true
4986
50 /*! \internal */
51 // Color properties in a JS ternary operator don't work as expected in
52 // QML because it overwrites alpha values with 1. A workaround is to use
53 // Qt.rgba(). For more information, see
54 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1197802 and
55 // https://bugreports.qt-project.org/browse/QTBUG-32238.
56 function __colorHack(color) { return Qt.rgba(color.r, color.g, color.b, color.a); }
57
58
59 /* The proxy is necessary because Gradient.stops and GradientStop.color are
60 non-NOTIFYable properties. They cannot be written to so it is fine but
61 the proxy avoids the warnings.
62 */
63 property QtObject gradientProxy: gradientProxyObject
64 QtObject {
65 id: gradientProxyObject
66 property color topColor
67 property color bottomColor
68
69 function updateGradient() {
70 if (button.gradient) {
71 topColor = button.gradient.stops[0].color;
72 bottomColor = button.gradient.stops[1].color;
73 }
74 }
75
76 Component.onCompleted: {
77 updateGradient();
78 button.gradientChanged.connect(updateGradient);
79 }
80 }
81
82 // Use the gradient if it is defined and the color has not been set manually
83 // or the gradient has been set manually
84 property bool isGradient: button.gradient && (button.color == defaultColor ||
85 button.gradient != defaultGradient)
86
87 FocusShape {87 FocusShape {
88 }88 }
8989
90 Image {90 // Drop shadow
91 id: strokeBorder91 ShapeShadow {
92 anchors.fill: parent92 visible: button.enabled
93 anchors.margins: -units.gu(0.5)93 opacity: (
94 // FIXME: this PNG is way too big (462x108) and do not scale properly94 button.type === Button.Outline ||
95 // ie. the corners are visually incorrect at most sizes95 styledItem.keyNavigationFocus ||
96 source: stroke ? Qt.resolvedUrl("../artwork/stroke_button.png") : ""96 button.pressed? 0 : 1
97 visible: false97 )
98 cache: false98 width: parent.width
99 asynchronous: true99 height: parent.height
100 }100 radius: buttonStyle.radius
101101 style: ShapeShadow.Outer
102 ShaderEffect {102 angle: 90
103 id: colorizedImage103 distance: units.gu(0.1)
104104 size: units.gu(0.1)
105 anchors.fill: parent105 color: Qt.rgba(0, 0, 0, 0.2)
106 visible: stroke && strokeBorder.status == Image.Ready106 Behavior on opacity {
107107 UbuntuNumberAnimation {
108 property Item source: visible ? strokeBorder : null108 duration: UbuntuAnimation.SnapDuration
109 property color keyColorOut: stroke ? button.strokeColor : Qt.rgba(0.0, 0.0, 0.0, 0.0)109 }
110 property color keyColorIn: Qt.rgba(1.0, 1.0, 1.0, 1.0)110 }
111 property real threshold: 1.0111 }
112112
113 fragmentShader: "113 // Background shape
114 varying highp vec2 qt_TexCoord0;114 ShapeFill {
115 uniform sampler2D source;115 anchors.fill: parent
116 uniform highp vec4 keyColorOut;116 visible: (
117 uniform highp vec4 keyColorIn;117 button.type !== Button.Outline ||
118 uniform lowp float threshold;118 button.keyNavigationFocus ||
119 uniform lowp float qt_Opacity;119 (button.hovered && !button.pressed)
120 void main() {120 )
121 lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);121 color: {
122 gl_FragColor = mix(vec4(keyColorOut.rgb, 1.0) * sourceColor.a, sourceColor, step(threshold, distance(sourceColor.rgb / sourceColor.a, keyColorIn.rgb))) * qt_Opacity;122 var baseColor = buttonStyle.color
123 }"123 if (button.keyNavigationFocus && button.type === Button.Outline) {
124 }124 return Qt.rgba(0, 0, 0, 0.15)
125125 }
126 UbuntuShape {126 if (button.hovered && !button.pressed) {
127 id: background127 return button.type === Button.Outline
128 anchors.fill: parent128 ? Qt.rgba(0, 0, 0, 0.05)
129 borderSource: "radius_idle.sci" // Deprecated, use a dedicated shape.129 : Qt.tint(buttonStyle.color, Qt.rgba(0, 0, 0, 0.05))
130 visible: stroke ? false : ((backgroundColor.a != 0.0) || backgroundSource)130 }
131 source: backgroundSource131 return buttonStyle.color
132132 }
133 backgroundColor: backgroundSource ? "#00000000" : (isGradient ? __colorHack(gradientProxy.topColor) : __colorHack(button.color))133 radius: buttonStyle.radius
134 secondaryBackgroundColor: backgroundSource ? "#00000000" : (isGradient ? __colorHack(gradientProxy.bottomColor) : __colorHack(button.color))134 Behavior on opacity {
135 backgroundMode: isGradient ? UbuntuShape.VerticalGradient : UbuntuShape.SolidColor135 UbuntuNumberAnimation {
136 opacity: styledItem.enabled ? 1.0 : 0.6136 duration: UbuntuAnimation.SnapDuration
137 }137 }
138138 }
139 UbuntuShape {139 Behavior on color {
140 id: backgroundPressed140 enabled: button.type !== Button.Outline
141 anchors.fill: parent141 ColorAnimation {
142 backgroundColor: stroke ? button.strokeColor : background.backgroundColor142 duration: UbuntuAnimation.SnapDuration
143 secondaryBackgroundColor: background.secondaryBackgroundColor143 }
144 backgroundMode: stroke ? UbuntuShape.SolidColor : UbuntuShape.VerticalGradient144 }
145 borderSource: "radius_pressed.sci" // Deprecated, use a dedicated shape.145 }
146 opacity: button.pressed ? 1.0 : 0.0146
147 Behavior on opacity {147 // Outline
148 NumberAnimation {148 ShapeFrame {
149 duration: UbuntuAnimation.SnapDuration149 anchors.fill: parent
150 easing.type: Easing.Linear150 visible: button.type === Button.Outline && !button.keyNavigationFocus
151 }151 color: buttonStyle.color
152 }152 radius: buttonStyle.radius
153 visible: stroke || background.visible153 thickness: frameThickness
154 }154 Behavior on opacity {
155155 UbuntuNumberAnimation {
156 duration: UbuntuAnimation.SnapDuration
157 }
158 }
159 Behavior on color {
160 ColorAnimation {
161 duration: UbuntuAnimation.SnapDuration
162 }
163 }
164 }
165
166 // Foreground (text and icon)
156 ButtonForeground {167 ButtonForeground {
157 id: foreground168 id: foreground
158 width: parent.width - 2*horizontalPadding
159 anchors {169 anchors {
160 centerIn: parent170 centerIn: parent
161 horizontalCenterOffset: buttonFaceOffset
162 }171 }
163 text: button.text172 text: button.text
164 /* Pick either a clear or dark text color depending on the luminance of the173 textColor: buttonStyle.textColor
165 background color to maintain good contrast (works in most cases)
166 */
167 textColor: ColorUtils.luminance(button.color) <= 0.85 && !(stroke && !button.pressed) ? "#FFFFFF" : "#888888"
168 iconSource: button.iconSource174 iconSource: button.iconSource
169 iconPosition: button.iconPosition175 iconPosition: (
170 iconSize: units.gu(3)176 button.iconPosition !== undefined
171 font: button.font177 ? button.iconPosition
172 spacing: horizontalPadding178 : Button.Before
179 )
180 iconSize: units.gu(2)
181 font: button.font || defaultFont
182 spacing: iconSpacing
173 transformOrigin: Item.Top183 transformOrigin: Item.Top
174 scale: button.pressed ? 0.98 : 1.0
175 Behavior on scale {
176 NumberAnimation {
177 duration: UbuntuAnimation.SnapDuration
178 easing.type: Easing.Linear
179 }
180 }
181 }184 }
182}185}
183186
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/Palette.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/Palette.qml 2016-03-01 15:06:38 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/Palette.qml 2016-04-08 16:09:06 +0000
@@ -20,14 +20,22 @@
2020
21Palette {21Palette {
22 normal: AmbianceNormal {}22 normal: AmbianceNormal {}
23
23 disabled: AmbianceNormal {24 disabled: AmbianceNormal {
24 field: UbuntuColors.porcelain;
25 // inactive is 30% opaque normal
26 Component.onCompleted: {25 Component.onCompleted: {
26 // specific disabled colors
27 var diff = {
28 field: UbuntuColors.porcelain,
29 positiveText: normal.positiveText,
30 negativeText: normal.negativeText,
31 };
27 for (var p in normal) {32 for (var p in normal) {
28 // skip objectName and all change signals33 // skip objectName and all change signals
29 if (p == "objectName" || p == "field" || p.indexOf("Changed") > 0) continue;34 if (p === "objectName" || p.indexOf("Changed") > 0) continue;
30 disabled[p] = Qt.rgba(normal[p].r, normal[p].g, normal[p].b, 0.3);35 disabled[p] = diff[p] || (
36 // if not specific, colors are 30% opaque normal
37 Qt.rgba(normal[p].r, normal[p].g, normal[p].b, 0.3)
38 );
31 }39 }
32 }40 }
33 }41 }
@@ -35,18 +43,22 @@
35 // selected differs from normal in background, base, foreground43 // selected differs from normal in background, base, foreground
36 selected: AmbianceSelected {}44 selected: AmbianceSelected {}
3745
38 // selected differs from normal in background, base, foreground46 // selected disabled differs from normal in background, base, foreground
39 selectedDisabled: AmbianceSelected {47 selectedDisabled: AmbianceSelected {
40 background: UbuntuColors.porcelain
41 base: UbuntuColors.porcelain
42 foreground: UbuntuColors.porcelain
43 // inactive is 30% opaque normal
44 Component.onCompleted: {48 Component.onCompleted: {
49 // specific selected-disabled colors
50 var diff = {
51 background: UbuntuColors.porcelain,
52 base: UbuntuColors.porcelain,
53 foreground: UbuntuColors.porcelain,
54 };
45 for (var p in selected) {55 for (var p in selected) {
46 // skip objectName and all change signals56 // skip objectName and all change signals
47 if (p == "objectName" || p.indexOf("Changed") > 057 if (p === "objectName" || p.indexOf("Changed") > 0) continue;
48 || p == "background" || p == "base" || p == "foreground" ) continue;58 selectedDisabled[p] = diff[p] || (
49 selectedDisabled[p] = Qt.rgba(selected[p].r, selected[p].g, selected[p].b, 0.3);59 // if not specific, colors are 30% opaque normal
60 Qt.rgba(selected[p].r, selected[p].g, selected[p].b, 0.3)
61 );
50 }62 }
51 }63 }
52 }64 }
5365
=== added file 'src/Ubuntu/Components/Themes/Ambiance/1.3/TextButtonStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/TextButtonStyle.qml 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/TextButtonStyle.qml 2016-04-08 16:09:06 +0000
@@ -0,0 +1,76 @@
1/*
2 * Copyright 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 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 * Author: Florian Boucault <florian.boucault@canonical.com>
17 * Author: Pierre Bertet <pierre.bertet@canonical.com>
18 */
19
20import QtQuick 2.4
21import Ubuntu.Components 1.3
22import Ubuntu.Components.Private 1.3
23
24Item {
25 id: root
26
27 property var button: styledItem
28 property real minWidth: units.gu(10)
29 property real hPadding: units.gu(2)
30 property QtObject palette: (
31 button.enabled? theme.palette.normal : theme.palette.disabled
32 )
33 property color bgColor: palette.foreground
34 property color textColor: palette.foregroundText
35 property real radius: units.gu(0.6)
36 property font font: Qt.font({
37 family: "Ubuntu",
38 weight: button.strong? Font.Normal : Font.Light,
39 pixelSize: FontUtils.sizeToPixels("medium"),
40 })
41
42 width: button.width
43 height: button.height
44 implicitWidth: Math.max(minWidth, foreground.width + 2 * hPadding)
45 implicitHeight: units.gu(4)
46
47 LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
48 LayoutMirroring.childrenInherit: true
49
50 FocusShape {
51 }
52
53 // Background (on hover)
54 ShapeFill {
55 id: background
56 visible: background.color.a > 0
57 anchors.fill: parent
58 radius: root.radius
59 opacity: button.hovered? 1 : 0
60 color: root.bgColor
61 Behavior on opacity {
62 UbuntuNumberAnimation {
63 duration: UbuntuAnimation.SnapDuration
64 }
65 }
66 }
67
68 Label {
69 id: foreground
70 anchors.centerIn: parent
71 text: button.text
72 elide: Text.ElideRight
73 color: root.textColor
74 font: root.font
75 }
76}
077
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro'
--- src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2016-02-19 11:18:51 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/Ambiance.pro 2016-04-08 16:09:06 +0000
@@ -80,6 +80,7 @@
80 1.3/BubbleShape.qml \80 1.3/BubbleShape.qml \
81 1.3/ButtonForeground.qml \81 1.3/ButtonForeground.qml \
82 1.3/ButtonStyle.qml \82 1.3/ButtonStyle.qml \
83 1.3/TextButtonStyle.qml \
83 1.3/CheckBoxStyle.qml \84 1.3/CheckBoxStyle.qml \
84 1.3/ComboButtonStyle.qml \85 1.3/ComboButtonStyle.qml \
85 1.3/DatePickerStyle.qml \86 1.3/DatePickerStyle.qml \
8687
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/qmldir'
--- src/Ubuntu/Components/Themes/Ambiance/qmldir 2016-02-19 11:18:51 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/qmldir 2016-04-08 16:09:06 +0000
@@ -77,6 +77,7 @@
77PageHeadStyle 1.3 ./1.3/PageHeadStyle.qml77PageHeadStyle 1.3 ./1.3/PageHeadStyle.qml
78Palette 1.3 ./1.3/Palette.qml78Palette 1.3 ./1.3/Palette.qml
79ButtonStyle 1.3 ./1.3/ButtonStyle.qml79ButtonStyle 1.3 ./1.3/ButtonStyle.qml
80TextButtonStyle 1.3 ./1.3/TextButtonStyle.qml
80SliderStyle 1.3 ./1.3/SliderStyle.qml81SliderStyle 1.3 ./1.3/SliderStyle.qml
81SwitchStyle 1.3 ./1.3/SwitchStyle.qml82SwitchStyle 1.3 ./1.3/SwitchStyle.qml
82CheckBoxStyle 1.3 ./1.3/CheckBoxStyle.qml83CheckBoxStyle 1.3 ./1.3/CheckBoxStyle.qml
8384
=== added file 'src/Ubuntu/Components/plugin/button.cpp'
--- src/Ubuntu/Components/plugin/button.cpp 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/button.cpp 2016-04-08 16:09:06 +0000
@@ -0,0 +1,268 @@
1/*
2 * Copyright 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 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 * Author: Pierre Bertet <pierre.bertet@canonical.com>
17 */
18
19#include "button_p.h"
20#include "ucstyleditembase_p.h"
21#include "ucnamespace.h"
22
23namespace UbuntuToolkit {
24
25ButtonPrivate::ButtonPrivate()
26 : UCAbstractButtonPrivate()
27 , type(Button::Normal)
28 , font(QFont())
29 , iconPosition(Button::Before)
30 , color(QColor())
31 , strokeColor(QColor())
32 , gradient(QGradient())
33{
34}
35
36/*!
37\qmltype Button
38\instantiates UbuntuToolkit::Button
39\inherits UCAbstractButton
40\inqmlmodule Ubuntu.Components 1.3
41\ingroup ubuntu
42\brief Standard Ubuntu button.
43
44The Button component allows to create a button that follows the Ubuntu visual and behavioral standards.
45
46Several types are available: normal, the default, will be represented by an opaque shape with the text above it, while the outline type will display a transparent button with a border. The positive and negative types can be used to indicate the nature of the action.
47
48\l {http://design.ubuntu.com/apps/building-blocks/buttons}{See also the Design Guidelines on Buttons}.
49
50Example:
51\qml
52 Column {
53 Button {
54 text: "Send"
55 onClicked: print("clicked text-only Button")
56 }
57 Button {
58 iconName: "compose"
59 onClicked: print("clicked icon-only Button")
60 }
61 }
62\endqml
63
64An \l Action can be used to specify \b clicked, iconSource and text:
65\qml
66 Item {
67 Action {
68 id: action1
69 text: "Click me"
70 onTriggered: print("action!")
71 iconName: "compose"
72 }
73 Button {
74 anchors.centerIn: parent
75 action: action1
76 }
77 }
78\endqml
79
80\sa TextButton
81*/
82Button::Button(QQuickItem* parent)
83 : UCAbstractButton(*(new ButtonPrivate), parent)
84{
85 /*
86 * From ucbottomedgehint.cpp:
87 * we cannot use setStyleName as that will trigger style loading
88 * and the qmlEngine is not known at this phase of the of the
89 * initialization. Therefore we simply set the style name default. Style
90 * loading will happen during component completion.
91 */
92 UCStyledItemBasePrivate::get(this)->styleDocument = QStringLiteral("ButtonStyle");
93}
94
95/*!
96 \qmlproperty url Button::iconSource
97 The source URL of the icon to display inside the button. Leave this value
98 blank for a text-only button.
99 If \l action is set, the default iconSource is that of the action.
100*/
101
102/*!
103 \qmlproperty string Button::text
104 The text to display in the button. If an icon was defined, the text will be
105 shown next to the icon, otherwise it will be centered. Leave blank for an
106 icon-only button.
107 If \l action is set, the default text is that of the action.
108*/
109
110/*!
111 \qmlsignal Button::clicked()
112 This handler is called when there is a mouse click on the button and the
113 button is not disabled. If \l {ActionItem::action}{action} is defined, the
114 action will be triggered.
115 */
116
117/*!
118 *
119 * \qmlsignal Button::pressAndHold()
120 * This handler is called when there is a long press.
121 */
122
123/*!
124 \qmlproperty Action Button::action
125 An \l Action to specify the \l clicked, \l iconSource and \l text
126 properties.
127*/
128
129/*!
130 \qmlproperty enumeration Button::type
131 The type defines the button style. The default value is \c Button.Normal.
132 \list
133 \li \b Button.Normal - The button shape is visible.
134 \li \b Button.Outline - The button shape is transparent but a border is present.
135 \li \b Button.Positive - The action is positive.
136 \li \b Button.Negative - The action is negative.
137 \endlist
138*/
139Button::Type Button::type()
140{
141 Q_D(Button);
142 return d->type;
143}
144void Button::setType(Type &type)
145{
146 Q_D(Button);
147 d->type = type;
148 Q_EMIT typeChanged();
149}
150
151/*!
152 \qmlproperty string Button::font
153 The font used for the button's text.
154*/
155QFont Button::font()
156{
157 Q_D(Button);
158 return d->font;
159}
160void Button::setFont(QFont &font)
161{
162 Q_D(Button);
163 d->font = font;
164 Q_EMIT fontChanged();
165}
166
167/*!
168 \qmlproperty enumeration Button::iconPosition
169
170 Where to position the icon in the button. The default value is \c Button.Before.
171
172 \note If only text or only an icon is defined, this property is ignored and the
173 text or icon is centered horizontally and vertically in the button.
174
175 \list
176 \li \b Button.Before - The icon is positioned before the text.
177 \li \b Button.After - The icon is positioned after the text.
178 \endlist
179*/
180Button::IconPosition Button::iconPosition()
181{
182 Q_D(Button);
183 return d->iconPosition;
184}
185void Button::setIconPosition(IconPosition &iconPosition)
186{
187 Q_D(Button);
188 d->iconPosition = iconPosition;
189 Q_EMIT iconPositionChanged();
190}
191
192/*!
193 \qmlproperty string Button::color
194 \deprecated
195 The property is deprecated, use `emphasis` or a custom style instead.
196*/
197QColor Button::color()
198{
199 Q_D(Button);
200 return d->color;
201}
202void Button::setColor(QColor &color)
203{
204 Q_D(Button);
205
206 qDebug() << color;
207 qDebug() << d->color;
208
209 if (color == d->color) {
210 return;
211 }
212 d->color = color;
213
214 qDebug() << color;
215 qDebug() << d->color;
216
217 UC_QML_DEPRECATION_WARNING("WARNING: `color` is deprecated. Use `emphasis` or `StyleHint` instead.");
218
219 Q_EMIT colorChanged();
220}
221
222/*!
223 \qmlproperty string Button::strokeColor
224 \deprecated
225 The property is deprecated, set `type` to "outline" instead.
226*/
227QColor Button::strokeColor()
228{
229 Q_D(Button);
230 return d->strokeColor;
231}
232void Button::setStrokeColor(QColor &strokeColor)
233{
234 Q_D(Button);
235 if (strokeColor == d->strokeColor) {
236 return;
237 }
238 d->strokeColor = strokeColor;
239
240 UC_QML_DEPRECATION_WARNING("WARNING: `strokeColor` is deprecated. Set the `type` property to Button.Type.Normal, or use `StyleHint` instead.");
241
242 Q_EMIT strokeColorChanged();
243}
244
245/*!
246 \qmlproperty string Button::gradient
247 \deprecated
248 The property is deprecated, use `type` or a custom style instead.
249*/
250QGradient Button::gradient()
251{
252 Q_D(Button);
253 return d->gradient;
254}
255void Button::setGradient(QGradient &gradient)
256{
257 Q_D(Button);
258 if (gradient == d->gradient) {
259 return;
260 }
261 d->gradient = gradient;
262
263 UC_QML_DEPRECATION_WARNING("WARNING: `gradient` is deprecated. Use `type`, `type`, or `StyleHint` instead.");
264
265 Q_EMIT gradientChanged();
266}
267
268}
0269
=== added file 'src/Ubuntu/Components/plugin/button.h'
--- src/Ubuntu/Components/plugin/button.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/button.h 2016-04-08 16:09:06 +0000
@@ -0,0 +1,84 @@
1/*
2 * Copyright 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 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 * Author: Pierre Bertet <pierre.bertet@canonical.com>
17 */
18
19#ifndef BUTTON_H
20#define BUTTON_H
21
22#include "ucabstractbutton.h"
23
24namespace UbuntuToolkit {
25
26class ButtonPrivate;
27class Button : public UCAbstractButton
28{
29 Q_OBJECT
30
31 Q_ENUMS(IconPosition)
32 Q_ENUMS(Type)
33
34 Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged FINAL)
35 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged FINAL)
36 Q_PROPERTY(IconPosition iconPosition READ iconPosition WRITE setIconPosition NOTIFY iconPositionChanged FINAL)
37
38 // deprecated properties
39 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
40 Q_PROPERTY(QColor strokeColor READ strokeColor WRITE setStrokeColor NOTIFY strokeColorChanged FINAL)
41 Q_PROPERTY(QGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged FINAL)
42
43public:
44 explicit Button(QQuickItem* parent=0);
45
46 enum IconPosition { Before, left = Before, After, right = After };
47 enum Type { Normal, Outline, Positive, Negative };
48
49 Type type();
50 void setType(Type &type);
51
52 QFont font();
53 void setFont(QFont &font);
54
55 IconPosition iconPosition();
56 void setIconPosition(IconPosition &iconPosition);
57
58 QColor color();
59 void setColor(QColor &color);
60
61 QColor strokeColor();
62 void setStrokeColor(QColor &strokeColor);
63
64 QGradient gradient();
65 void setGradient(QGradient &gradient);
66
67Q_SIGNALS:
68 void typeChanged();
69 void fontChanged();
70 void iconPositionChanged();
71 void colorChanged();
72 void strokeColorChanged();
73 void gradientChanged();
74
75private:
76 Q_DECLARE_PRIVATE(Button)
77 Q_DISABLE_COPY(Button)
78};
79
80}
81
82QML_DECLARE_TYPE(UbuntuToolkit::Button)
83
84#endif // BUTTON_H
085
=== added file 'src/Ubuntu/Components/plugin/button_p.h'
--- src/Ubuntu/Components/plugin/button_p.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/button_p.h 2016-04-08 16:09:06 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright 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 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#ifndef BUTTON_P
18#define BUTTON_P
19
20#include "button.h"
21#include "ucabstractbutton_p.h"
22
23namespace UbuntuToolkit {
24
25class ButtonPrivate : public UCAbstractButtonPrivate
26{
27 Q_DECLARE_PUBLIC(Button)
28public:
29 explicit ButtonPrivate();
30
31 static ButtonPrivate *get(Button *item)
32 {
33 return item->d_func();
34 }
35
36 Button::Type type;
37 QFont font;
38 Button::IconPosition iconPosition;
39 QColor color;
40 QColor strokeColor;
41 QGradient gradient;
42};
43
44}
45
46#endif // BUTTON_P
047
=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
--- src/Ubuntu/Components/plugin/plugin.cpp 2016-04-08 16:09:04 +0000
+++ src/Ubuntu/Components/plugin/plugin.cpp 2016-04-08 16:09:06 +0000
@@ -80,6 +80,8 @@
80#include "ucperformancemonitor.h"80#include "ucperformancemonitor.h"
81#include "privates/ucpagewrapper.h"81#include "privates/ucpagewrapper.h"
82#include "privates/appheaderbase.h"82#include "privates/appheaderbase.h"
83#include "button.h"
84#include "textbutton.h"
83#include "privates/shape/shadow.h"85#include "privates/shape/shadow.h"
84#include "privates/shape/fill.h"86#include "privates/shape/fill.h"
85#include "privates/shape/frame.h"87#include "privates/shape/frame.h"
@@ -237,6 +239,8 @@
237 qmlRegisterType<UCPageTreeNode>(uri, 1, 3, "PageTreeNode");239 qmlRegisterType<UCPageTreeNode>(uri, 1, 3, "PageTreeNode");
238 qmlRegisterType<UCPopupContext>(uri, 1, 3, "PopupContext");240 qmlRegisterType<UCPopupContext>(uri, 1, 3, "PopupContext");
239 qmlRegisterType<UCMainViewBase>(uri, 1, 3, "MainViewBase");241 qmlRegisterType<UCMainViewBase>(uri, 1, 3, "MainViewBase");
242 qmlRegisterType<UbuntuToolkit::Button>(uri, 1, 3, "Button");
243 qmlRegisterType<UbuntuToolkit::TextButton>(uri, 1, 3, "TextButton");
240}244}
241245
242void UbuntuComponentsPlugin::initializeContextProperties(QQmlEngine *engine)246void UbuntuComponentsPlugin::initializeContextProperties(QQmlEngine *engine)
243247
=== modified file 'src/Ubuntu/Components/plugin/plugin.pri'
--- src/Ubuntu/Components/plugin/plugin.pri 2016-04-08 16:09:04 +0000
+++ src/Ubuntu/Components/plugin/plugin.pri 2016-04-08 16:09:06 +0000
@@ -110,22 +110,20 @@
110 $$PWD/ucmainviewbase.h \110 $$PWD/ucmainviewbase.h \
111 $$PWD/ucmainviewbase_p.h \111 $$PWD/ucmainviewbase_p.h \
112 $$PWD/ucperformancemonitor.h \112 $$PWD/ucperformancemonitor.h \
113 $$PWD/label_p.h \
114 $$PWD/privates/listviewextensions.h \113 $$PWD/privates/listviewextensions.h \
115 $$PWD/privates/ucpagewrapper.h \114 $$PWD/privates/ucpagewrapper.h \
116 $$PWD/privates/ucpagewrapper_p.h \115 $$PWD/privates/ucpagewrapper_p.h \
117 $$PWD/privates/ucpagewrapperincubator_p.h \116 $$PWD/privates/ucpagewrapperincubator_p.h \
118 $$PWD/privates/appheaderbase.h \117 $$PWD/privates/appheaderbase.h \
119<<<<<<< TREE118 $$PWD/button.h \
120 $$PWD/label_p.h \119 $$PWD/textbutton.h \
121 $$PWD/ucbottomedgeregion_p.h
122=======
123 $$PWD/privates/shape/utils.h \120 $$PWD/privates/shape/utils.h \
124 $$PWD/privates/shape/texturefactory.h \121 $$PWD/privates/shape/texturefactory.h \
125 $$PWD/privates/shape/fill.h \122 $$PWD/privates/shape/fill.h \
126 $$PWD/privates/shape/frame.h \123 $$PWD/privates/shape/frame.h \
127 $$PWD/privates/shape/shadow.h124 $$PWD/privates/shape/shadow.h \
128>>>>>>> MERGE-SOURCE125 $$PWD/label_p.h \
126 $$PWD/ucbottomedgeregion_p.h
129127
130SOURCES += $$PWD/plugin.cpp \128SOURCES += $$PWD/plugin.cpp \
131 $$PWD/uctheme.cpp \129 $$PWD/uctheme.cpp \
@@ -202,6 +200,8 @@
202 $$PWD/privates/ucpagewrapper.cpp \200 $$PWD/privates/ucpagewrapper.cpp \
203 $$PWD/privates/ucpagewrapperincubator.cpp \201 $$PWD/privates/ucpagewrapperincubator.cpp \
204 $$PWD/privates/appheaderbase.cpp \202 $$PWD/privates/appheaderbase.cpp \
203 $$PWD/button.cpp \
204 $$PWD/textbutton.cpp \
205 $$PWD/privates/shape/utils.cpp \205 $$PWD/privates/shape/utils.cpp \
206 $$PWD/privates/shape/texturefactory.cpp \206 $$PWD/privates/shape/texturefactory.cpp \
207 $$PWD/privates/shape/fill.cpp \207 $$PWD/privates/shape/fill.cpp \
208208
=== added file 'src/Ubuntu/Components/plugin/textbutton.cpp'
--- src/Ubuntu/Components/plugin/textbutton.cpp 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/textbutton.cpp 2016-04-08 16:09:06 +0000
@@ -0,0 +1,134 @@
1/*
2 * Copyright 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 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 * Author: Pierre Bertet <pierre.bertet@canonical.com>
17 */
18
19#include "textbutton_p.h"
20#include "ucstyleditembase_p.h"
21#include "ucnamespace.h"
22
23namespace UbuntuToolkit {
24
25TextButtonPrivate::TextButtonPrivate()
26 : UCAbstractButtonPrivate()
27 , strong(false)
28{
29}
30
31/*!
32\qmltype TextButton
33\instantiates UbuntuToolkit::TextButton
34\inherits UCAbstractButton
35\inqmlmodule Ubuntu.Components 1.3
36\ingroup ubuntu
37\brief Ubuntu text button.
38
39The TextButton component allows to create a text-only button that follows the Ubuntu visual and behavioral standards.
40
41The button can be strong, which will be represented by a bold font.
42
43\l {http://design.ubuntu.com/apps/building-blocks/buttons}{See also the Design Guidelines on Buttons}.
44
45Example:
46
47\qml
48TextButton {
49 text: "Send"
50 onClicked: print("clicked text-only Button")
51}
52\endqml
53
54An \l Action can be used to specify \b clicked and \b text:
55
56\qml
57Item {
58 Action {
59 id: myAction
60 text: "Click me"
61 onTriggered: print("action!")
62 }
63 TextButton {
64 action: myAction
65 }
66}
67\endqml
68
69\sa Button
70*/
71
72TextButton::TextButton(QQuickItem* parent)
73 : UCAbstractButton(*(new TextButtonPrivate), parent)
74{
75 /*
76 * From ucbottomedgehint.cpp:
77 * we cannot use setStyleName as that will trigger style loading
78 * and the qmlEngine is not known at this phase of the of the
79 * initialization. Therefore we simply set the style name default. Style
80 * loading will happen during component completion.
81 */
82 UCStyledItemBasePrivate::get(this)->styleDocument = QStringLiteral("TextButtonStyle");
83}
84
85/*!
86 \qmlproperty url TextButton::iconSource
87 The source URL of the icon to display inside the button. Leave this value
88 blank for a text-only button.
89 If \l action is set, the default iconSource is that of the action.
90*/
91
92/*!
93 \qmlproperty string TextButton::text
94 The text to display in the button. If an icon was defined, the text will be
95 shown next to the icon, otherwise it will be centered. Leave blank for an
96 icon-only button.
97 If \l action is set, the default text is that of the action.
98*/
99
100/*!
101 \qmlsignal TextButton::clicked()
102 This handler is called when there is a mouse click on the button and the
103 button is not disabled. If \l {ActionItem::action}{action} is defined, the
104 action will be triggered.
105*/
106
107/*!
108 \qmlsignal TextButton::pressAndHold()
109 This handler is called when there is a long press.
110*/
111
112/*!
113 \qmlproperty Action TextButton::action
114 An \l Action to specify the clicked and \l text properties.
115*/
116
117/*!
118 \qmlproperty bool TextButton::strong
119 Set to `true` to give importance to the button. The button font will appear
120 in bold.
121*/
122bool TextButton::strong()
123{
124 Q_D(TextButton);
125 return d->strong;
126}
127void TextButton::setStrong(bool &strong)
128{
129 Q_D(TextButton);
130 d->strong = strong;
131 Q_EMIT strongChanged();
132}
133
134}
0135
=== added file 'src/Ubuntu/Components/plugin/textbutton.h'
--- src/Ubuntu/Components/plugin/textbutton.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/textbutton.h 2016-04-08 16:09:06 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright 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 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 * Author: Pierre Bertet <pierre.bertet@canonical.com>
17 */
18
19#ifndef TEXTBUTTON_H
20#define TEXTBUTTON_H
21
22#include "ucabstractbutton.h"
23
24namespace UbuntuToolkit {
25
26class TextButtonPrivate;
27class TextButton : public UCAbstractButton
28{
29 Q_OBJECT
30
31 Q_PROPERTY(bool strong READ strong WRITE setStrong NOTIFY strongChanged)
32
33public:
34 explicit TextButton(QQuickItem* parent=0);
35
36 bool strong();
37 void setStrong(bool &strong);
38
39Q_SIGNALS:
40 void strongChanged();
41
42private:
43 Q_DECLARE_PRIVATE(TextButton)
44 Q_DISABLE_COPY(TextButton)
45};
46
47}
48
49QML_DECLARE_TYPE(UbuntuToolkit::TextButton)
50
51#endif // TEXTBUTTON_H
052
=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2016-03-01 19:36:40 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2016-04-08 16:09:06 +0000
@@ -104,7 +104,7 @@
104{104{
105 d_func()->init();105 d_func()->init();
106}106}
107UCAbstractButton::UCAbstractButton(UCAbstractButtonPrivate &&dd, QQuickItem *parent)107UCAbstractButton::UCAbstractButton(UCAbstractButtonPrivate &dd, QQuickItem *parent)
108 : UCActionItem(dd, parent)108 : UCActionItem(dd, parent)
109{109{
110 d_func()->init();110 d_func()->init();
111111
=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.h'
--- src/Ubuntu/Components/plugin/ucabstractbutton.h 2016-02-10 19:35:49 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton.h 2016-04-08 16:09:06 +0000
@@ -60,7 +60,7 @@
60 void pressAndHold();60 void pressAndHold();
6161
62protected:62protected:
63 UCAbstractButton(UCAbstractButtonPrivate &&, QQuickItem *parent = 0);63 UCAbstractButton(UCAbstractButtonPrivate &, QQuickItem *parent = 0);
6464
65 Q_DECLARE_PRIVATE(UCAbstractButton)65 Q_DECLARE_PRIVATE(UCAbstractButton)
66 Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaPressed())66 Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaPressed())
6767
=== modified file 'src/Ubuntu/Components/qmldir'
--- src/Ubuntu/Components/qmldir 2016-02-16 11:39:32 +0000
+++ src/Ubuntu/Components/qmldir 2016-04-08 16:09:06 +0000
@@ -103,7 +103,6 @@
103ToolbarButton 1.3 1.3/ToolbarButton.qml103ToolbarButton 1.3 1.3/ToolbarButton.qml
104MainView 1.3 1.3/MainView.qml104MainView 1.3 1.3/MainView.qml
105ComboButton 1.3 1.3/ComboButton.qml105ComboButton 1.3 1.3/ComboButton.qml
106Button 1.3 1.3/Button.qml
107Panel 1.3 1.3/Panel.qml106Panel 1.3 1.3/Panel.qml
108Tab 1.3 1.3/Tab.qml107Tab 1.3 1.3/Tab.qml
109TabBar 1.3 1.3/TabBar.qml108TabBar 1.3 1.3/TabBar.qml
110109
=== added file 'tests/unit/tst_performance/ButtonGrid13.qml'
--- tests/unit/tst_performance/ButtonGrid13.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/tst_performance/ButtonGrid13.qml 2016-04-08 16:09:06 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright 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 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
17import QtQuick 2.3
18import Ubuntu.Components 1.3
19
20Grid {
21 width: 800
22 height: 600
23 rows: 16
24 columns: 16
25 Repeater {
26 model: 16*16
27 Button {
28 }
29 }
30}
031
=== modified file 'tests/unit/tst_performance/tst_performance.cpp'
--- tests/unit/tst_performance/tst_performance.cpp 2015-12-07 22:16:52 +0000
+++ tests/unit/tst_performance/tst_performance.cpp 2016-04-08 16:09:06 +0000
@@ -110,7 +110,8 @@
110 QTest::newRow("grid with Label 1.3") << "LabelGrid13.qml" << QUrl();110 QTest::newRow("grid with Label 1.3") << "LabelGrid13.qml" << QUrl();
111 QTest::newRow("grid with UbuntuShape") << "UbuntuShapeGrid.qml" << QUrl();111 QTest::newRow("grid with UbuntuShape") << "UbuntuShapeGrid.qml" << QUrl();
112 QTest::newRow("grid with UbuntuShapePair") << "PairOfUbuntuShapeGrid.qml" << QUrl();112 QTest::newRow("grid with UbuntuShapePair") << "PairOfUbuntuShapeGrid.qml" << QUrl();
113 QTest::newRow("grid with Button") << "ButtonGrid.qml" << QUrl();113 QTest::newRow("grid with Button 1.1") << "ButtonGrid.qml" << QUrl();
114 QTest::newRow("grid with Button 1.3") << "ButtonGrid13.qml" << QUrl();
114 QTest::newRow("grid with Slider") << "SliderGrid.qml" << QUrl();115 QTest::newRow("grid with Slider") << "SliderGrid.qml" << QUrl();
115 QTest::newRow("list with QtQuick Item") << "ItemList.qml" << QUrl();116 QTest::newRow("list with QtQuick Item") << "ItemList.qml" << QUrl();
116 QTest::newRow("list with new ListItem") << "ListItemList.qml" << QUrl();117 QTest::newRow("list with new ListItem") << "ListItemList.qml" << QUrl();
@@ -131,7 +132,7 @@
131 QTest::newRow("list of Scrollbar 1.3") << "ListOfScrollbars_1_3.qml" << QUrl();132 QTest::newRow("list of Scrollbar 1.3") << "ListOfScrollbars_1_3.qml" << QUrl();
132 QTest::newRow("list of ScrollView 1.3 with both Scrollbars") << "ListOfScrollView_bothScrollbars_1_3.qml" << QUrl();133 QTest::newRow("list of ScrollView 1.3 with both Scrollbars") << "ListOfScrollView_bothScrollbars_1_3.qml" << QUrl();
133 // disable this test as it takes >20 seconds. Kept still for measurements to be done during development134 // disable this test as it takes >20 seconds. Kept still for measurements to be done during development
134 // QTest::newRow("list with ListItems.Base (one icon, one label and one chevron)") << "ListItemsBaseList.qml" << QUrl();135 // QTest::newRow("list with ListItems.Base (one icon, one label and one chevron)") << "ListItemsBaseList.qml" << QUrl();
135 QTest::newRow("single MainView") << "MainView.qml" << QUrl();136 QTest::newRow("single MainView") << "MainView.qml" << QUrl();
136 }137 }
137138

Subscribers

People subscribed via source and target branches