← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~mzanetti/ubuntu-clock-app/detect-qtmm-version into lp:ubuntu-clock-app

 

Michael Zanetti has proposed merging lp:~mzanetti/ubuntu-clock-app/detect-qtmm-version into lp:ubuntu-clock-app.

Commit message:
add a hack to detect the available QtMultimedia version
  
This is supposed to handle API changes in our QtMultimedia distro-patches
without requiring to go through a deprecation phase

Requested reviews:
  Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot): continuous-integration
  Ubuntu Clock Developers (ubuntu-clock-dev)

For more details, see:
https://code.launchpad.net/~mzanetti/ubuntu-clock-app/detect-qtmm-version/+merge/275177

This would be the theoretical correct approach forward if we want the alarm sound preview to reflect the alarm volume. However, as the alarm volume seems to be restored to what the setting in the clock app is before the alarm is triggered, the current alarm role volume does not necessarily reflect the upcoming alarm's volume. Because of this, it is arguable how much sense it makes to include this workaround.
-- 
Your team Ubuntu Clock Developers is requested to review the proposed merge of lp:~mzanetti/ubuntu-clock-app/detect-qtmm-version into lp:ubuntu-clock-app.
=== modified file 'app/alarm/AlarmSound.qml'
--- app/alarm/AlarmSound.qml	2015-08-28 20:06:32 +0000
+++ app/alarm/AlarmSound.qml	2015-10-21 12:17:28 +0000
@@ -23,6 +23,7 @@
 import Ubuntu.Components 1.2
 import QtQuick.Layouts 1.1
 import Qt.labs.folderlistmodel 2.1
+import "../components"
 
 Page {
     id: _alarmSoundPage
@@ -147,9 +148,8 @@
         }
     }
 
-    Audio {
+    AlarmAudio {
         id: previewAlarmSound
-        audioRole: MediaPlayer.alert
 
         function controlPlayback(fileURL) {
             source = fileURL

=== added file 'app/components/AlarmAudio.qml'
--- app/components/AlarmAudio.qml	1970-01-01 00:00:00 +0000
+++ app/components/AlarmAudio.qml	2015-10-21 12:17:28 +0000
@@ -0,0 +1,34 @@
+import QtQuick 2.4
+
+Item {
+    id: root
+    property string source: ""
+    property var playbackState: null
+
+    function play() {
+        priv.audio.play();
+    }
+    function stop() {
+        priv.audio.stop();
+    }
+
+    QtObject {
+        id: priv
+        property var audio: null
+    }
+
+    Binding {
+        target: root
+        property: "playbackState"
+        value: priv.audio ? priv.audio.playbackState : 0
+    }
+
+    Component.onCompleted: {
+        try {
+            priv.audio = Qt.createQmlObject("import QtMultimedia 5.5; Audio { source: root.source; audioRole: MediaPlayer.AlarmRole }", priv)
+        } catch(err) {
+            print("QtMultimedia 5.5 not installed. Falling back to 5.4.");
+            priv.audio = Qt.createQmlObject("import QtMultimedia 5.4; Audio { source: root.source; audioRole: MediaPlayer.alarm }", priv)
+        }
+    }
+}

=== modified file 'app/components/CMakeLists.txt'
--- app/components/CMakeLists.txt	2015-08-13 18:26:31 +0000
+++ app/components/CMakeLists.txt	2015-10-21 12:17:28 +0000
@@ -2,6 +2,7 @@
     ActionIcon.qml
     AnalogMode.qml
     AnalogShadow.qml
+    AlarmAudio.qml
     Background.qml
     Clock.qml
     ClockCircle.qml