Merge lp:~ken-vandine/ubuntu-system-settings/brightness_slider_rtm into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ken VanDine
Status: Merged
Approved by: Ken VanDine
Approved revision: 936
Merged at revision: 944
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/brightness_slider_rtm
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 176 lines (+38/-105)
3 files modified
plugins/brightness/BrightnessSlider.qml (+0/-103)
plugins/brightness/CMakeLists.txt (+0/-1)
plugins/brightness/PageComponent.qml (+38/-1)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/brightness_slider_rtm
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Approve
Review via email: mp+241982@code.launchpad.net

Commit message

Use the SliderMenu component instead of the Slider component to fixed value binding issues

Description of the change

Use the SliderMenu component instead of the Slider component to fixed value binding issues

To post a comment you must log in.
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'plugins/brightness/BrightnessSlider.qml'
2--- plugins/brightness/BrightnessSlider.qml 2014-08-11 16:13:17 +0000
3+++ plugins/brightness/BrightnessSlider.qml 1970-01-01 00:00:00 +0000
4@@ -1,103 +0,0 @@
5-/*
6- * This file is part of system-settings
7- *
8- * Copyright (C) 2013-14 Canonical Ltd.
9- *
10- * Contact: Iain Lane <iain.lane@canonical.com>
11- *
12- * This program is free software: you can redistribute it and/or modify it
13- * under the terms of the GNU General Public License version 3, as published
14- * by the Free Software Foundation.
15- *
16- * This program is distributed in the hope that it will be useful, but
17- * WITHOUT ANY WARRANTY; without even the implied warranties of
18- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
19- * PURPOSE. See the GNU General Public License for more details.
20- *
21- * You should have received a copy of the GNU General Public License along
22- * with this program. If not, see <http://www.gnu.org/licenses/>.
23- */
24-
25-import Ubuntu.Components 0.1
26-import Ubuntu.Components.ListItems 0.1 as ListItem
27-import QtQuick 2.0
28-import QMenuModel 0.1
29-
30-Column {
31- signal pressed
32- readonly property bool pressed: sliderId.pressed
33-
34- anchors {
35- left: parent.left
36- right: parent.right
37- }
38-
39- QDBusActionGroup {
40- id: indicatorPower
41- busType: 1
42- busName: "com.canonical.indicator.power"
43- objectPath: "/com/canonical/indicator/power"
44-
45- property variant brightness: action("brightness").state
46- onBrightnessChanged: {
47- sliderId.enabled = brightness != null
48- sliderId.value = sliderId.enabled ? brightness * 100 : 0.0
49- }
50- }
51-
52- Component.onCompleted: indicatorPower.start()
53-
54- ListItem.Standard {
55- text: i18n.tr("Display brightness")
56- showDivider: false
57- }
58-
59- ListItem.Base {
60-
61- Icon {
62- id: iconLeft
63- anchors.verticalCenter: parent.verticalCenter
64- height: sliderId.height - units.gu(1)
65- name: "torch-off"
66- width: height
67-
68- MouseArea {
69- anchors.fill: parent
70- onClicked: sliderId.value = 0.0
71- }
72- }
73- Slider {
74- id: sliderId
75- function formatValue(v) {
76- return "%1%".arg(v.toFixed(0))
77- }
78-
79- anchors {
80- left: iconLeft.right
81- right: iconRight.left
82- leftMargin: units.gu(1)
83- rightMargin: units.gu(1)
84- verticalCenter: parent.verticalCenter
85- }
86- height: parent.height - units.gu(2)
87- minimumValue: 0.0
88- maximumValue: 100.0
89- live: true
90-
91- onValueChanged: indicatorPower.action('brightness').updateState(value / 100.0)
92- }
93- Icon {
94- id: iconRight
95- anchors.right: parent.right
96- anchors.verticalCenter: parent.verticalCenter
97- height: sliderId.height - units.gu(1)
98- name: "torch-on"
99- width: height
100-
101- MouseArea {
102- anchors.fill: parent
103- onClicked: sliderId.value = 100.0
104- }
105- }
106- }
107-}
108
109=== modified file 'plugins/brightness/CMakeLists.txt'
110--- plugins/brightness/CMakeLists.txt 2014-08-11 16:13:17 +0000
111+++ plugins/brightness/CMakeLists.txt 2014-11-17 15:39:24 +0000
112@@ -1,7 +1,6 @@
113 add_subdirectory(plugin)
114
115 set(QML_SOURCES
116- BrightnessSlider.qml
117 PageComponent.qml
118 )
119
120
121=== modified file 'plugins/brightness/PageComponent.qml'
122--- plugins/brightness/PageComponent.qml 2014-08-12 13:32:30 +0000
123+++ plugins/brightness/PageComponent.qml 2014-11-17 15:39:24 +0000
124@@ -24,6 +24,8 @@
125 import Ubuntu.Components 0.1
126 import Ubuntu.Components.ListItems 0.1 as ListItem
127 import Ubuntu.SystemSettings.Brightness 1.0
128+import Ubuntu.Settings.Menus 0.1 as Menus
129+import QMenuModel 0.1
130
131 ItemPage {
132 id: root
133@@ -39,7 +41,42 @@
134 anchors.left: parent.left
135 anchors.right: parent.right
136
137- BrightnessSlider {}
138+ QDBusActionGroup {
139+ id: indicatorPower
140+ busType: 1
141+ busName: "com.canonical.indicator.power"
142+ objectPath: "/com/canonical/indicator/power"
143+
144+ property variant brightness: action("brightness")
145+
146+ Component.onCompleted: start()
147+ }
148+
149+ Binding {
150+ target: sliderMenu
151+ property: "value"
152+ value: sliderMenu.enabled ? indicatorPower.action("brightness").state * 100 : 0.0
153+ }
154+
155+ ListItem.Standard {
156+ text: i18n.tr("Display brightness")
157+ showDivider: false
158+ }
159+
160+ /* Use the SliderMenu component instead of the Slider to avoid binding
161+ issues on valueChanged until LP: #1388094 is fixed.
162+ */
163+ Menus.SliderMenu {
164+ id: sliderMenu
165+ objectName: "sliderMenu"
166+ enabled: indicatorPower.action("brightness").state != null
167+ live: true
168+ minimumValue: 0.0
169+ maximumValue: 100.0
170+ minIcon: "image://theme/display-brightness-min"
171+ maxIcon: "image://theme/display-brightness-max"
172+ onUpdated: indicatorPower.action("brightness").updateState(value / 100.0)
173+ }
174
175 Binding {
176 target: autoAdjustCheck

Subscribers

People subscribed via source and target branches