Merge lp:~nik90/ubuntu-clock-app/add-vibration-support into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 42
Merged at revision: 47
Proposed branch: lp:~nik90/ubuntu-clock-app/add-vibration-support
Merge into: lp:ubuntu-clock-app
Diff against target: 205 lines (+97/-19)
3 files modified
app/alarm/AlarmSettingsPage.qml (+49/-19)
backend/modules/Alarm/Settings/alarmsettings.cpp (+30/-0)
backend/modules/Alarm/Settings/alarmsettings.h (+18/-0)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/add-vibration-support
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Charles Kerr (community) Approve
Review via email: mp+229327@code.launchpad.net

Commit message

Added vibration settings option for alarms.

Description of the change

Added vibration settings option for alarms.

NOTE: You will require mako image >180 for this.

Screenshot: https://imgur.com/f9Wf3ao

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
39. By Nekhelesh Ramananthan

Made vibration string translatable

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Approving the C++ pieces as requested, they LGTM.

review: Approve
40. By Nekhelesh Ramananthan

Added ability to click on the list label to enable/disable vibration

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
41. By Nekhelesh Ramananthan

Merged trunk

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Works great on device, thanks!

review: Approve
42. By Nekhelesh Ramananthan

Merged trunk

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmSettingsPage.qml'
2--- app/alarm/AlarmSettingsPage.qml 2014-07-29 13:56:07 +0000
3+++ app/alarm/AlarmSettingsPage.qml 2014-08-11 15:42:53 +0000
4@@ -81,6 +81,34 @@
5
6 anchors.fill: parent
7
8+ ListItem.Base {
9+ Column {
10+ width: parent.width
11+ height: childrenRect.height
12+ anchors.verticalCenter: parent.verticalCenter
13+
14+ Label {
15+ color: UbuntuColors.midAubergine
16+ text: i18n.tr("Alarm volume")
17+ }
18+
19+ Slider {
20+ id: _volumeSlider
21+
22+ height: units.gu(2)
23+ width: parent.width
24+
25+ minimumValue: 1
26+ maximumValue: 100
27+ value: alarmSettings.volume
28+
29+ onValueChanged: {
30+ alarmSettings.volume = formatValue(value)
31+ }
32+ }
33+ }
34+ }
35+
36 ListItem.Expandable {
37 id: _alarmDuration
38
39@@ -144,31 +172,33 @@
40 }
41
42 ListItem.Base {
43- Column {
44- width: parent.width
45- height: childrenRect.height
46+ Label {
47+ text: i18n.tr("Vibration")
48+ color: UbuntuColors.midAubergine
49 anchors.verticalCenter: parent.verticalCenter
50-
51- Label {
52- color: UbuntuColors.midAubergine
53- text: i18n.tr("Alarm volume")
54+ }
55+
56+ Switch {
57+ id: vibrateSwitch
58+
59+ anchors {
60+ right: parent.right
61+ verticalCenter: parent.verticalCenter
62 }
63
64- Slider {
65- id: _volumeSlider
66-
67- height: units.gu(2)
68- width: parent.width
69-
70- minimumValue: 1
71- maximumValue: 100
72- value: alarmSettings.volume
73-
74- onValueChanged: {
75- alarmSettings.volume = formatValue(value)
76+ checked: alarmSettings.vibration === "pulse"
77+ onCheckedChanged: {
78+ if(checked) {
79+ alarmSettings.vibration = "pulse"
80+ } else {
81+ alarmSettings.vibration = "none"
82 }
83 }
84 }
85+
86+ onClicked: {
87+ vibrateSwitch.checked = !vibrateSwitch.checked
88+ }
89 }
90
91 SubtitledListItem {
92
93=== modified file 'backend/modules/Alarm/Settings/alarmsettings.cpp'
94--- backend/modules/Alarm/Settings/alarmsettings.cpp 2014-07-28 23:09:07 +0000
95+++ backend/modules/Alarm/Settings/alarmsettings.cpp 2014-08-11 15:42:53 +0000
96@@ -65,6 +65,16 @@
97 emit durationChanged();
98 }
99 }
100+
101+ it = properties.find("HapticFeedback");
102+
103+ if (it != properties.end()) {
104+ const QString vibration = it.value().toString();
105+ if (m_vibration != vibration) {
106+ m_vibration = vibration;
107+ emit vibrationChanged();
108+ }
109+ }
110 }
111
112 void AlarmSettings::refreshProperties()
113@@ -87,6 +97,7 @@
114
115 m_volume = map["DefaultVolume"].toInt();
116 m_duration = map["Duration"].toInt();
117+ m_vibration = map["HapticFeedback"].toString();
118 }
119
120 void AlarmSettings::setDBusProperty(const QString &name, const QVariant &value)
121@@ -113,6 +124,11 @@
122 return m_duration;
123 }
124
125+QString AlarmSettings::vibration() const
126+{
127+ return m_vibration;
128+}
129+
130 void AlarmSettings::setVolume(int volume)
131 {
132 if(m_volume == volume) {
133@@ -140,3 +156,17 @@
134
135 setDBusProperty("Duration", QVariant(m_duration));
136 }
137+
138+void AlarmSettings::setVibration(QString vibration)
139+{
140+ if(m_vibration == vibration) {
141+ // Don't send the vibration mode over dbus if it is the same one already
142+ return;
143+ }
144+
145+ // Change the property and let qml know about it
146+ m_vibration = vibration;
147+ emit vibrationChanged();
148+
149+ setDBusProperty("HapticFeedback", QVariant(m_vibration));
150+}
151
152=== modified file 'backend/modules/Alarm/Settings/alarmsettings.h'
153--- backend/modules/Alarm/Settings/alarmsettings.h 2014-07-28 23:09:07 +0000
154+++ backend/modules/Alarm/Settings/alarmsettings.h 2014-08-11 15:42:53 +0000
155@@ -38,6 +38,12 @@
156 WRITE setDuration
157 NOTIFY durationChanged)
158
159+ // Property to control the haptic feedback mode
160+ Q_PROPERTY(QString vibration
161+ READ vibration
162+ WRITE setVibration
163+ NOTIFY vibrationChanged)
164+
165 public:
166 AlarmSettings(QObject *parent = 0);
167
168@@ -47,12 +53,18 @@
169 // Function to return the alarm duration
170 int duration() const;
171
172+ // Function to return the alarm haptic mode
173+ QString vibration() const;
174+
175 // Function to set the alarm volume
176 void setVolume(int volume);
177
178 // Function to set the alarm duration
179 void setDuration(int duration);
180
181+ // Function to set the alarm haptic mode
182+ void setVibration(QString vibration);
183+
184 signals:
185 // Signal to notify the volume change to QML
186 void volumeChanged();
187@@ -60,6 +72,9 @@
188 // Signal to notify the duration change to QML
189 void durationChanged();
190
191+ // Signal to notify the vibration mode change to QML
192+ void vibrationChanged();
193+
194 private:
195 // Keep a store of the alarm volume
196 int m_volume;
197@@ -67,6 +82,9 @@
198 // Keep a store of the alarm duration
199 int m_duration;
200
201+ // Keep a store of the alarm haptic mode
202+ QString m_vibration;
203+
204 // Function to retrieve all the settings from dBus and update the properties
205 void refreshProperties();
206

Subscribers

People subscribed via source and target branches