ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #04409
Re: [Merge] lp:~nik90/ubuntu-clock-app/custom-alarm-sound into lp:ubuntu-clock-app
Review: Needs Information
Some small improvements.
Diff comments:
> === modified file 'app/alarm/AlarmSound.qml'
> --- app/alarm/AlarmSound.qml 2015-08-13 13:29:49 +0000
> +++ app/alarm/AlarmSound.qml 2015-08-21 10:50:57 +0000
> @@ -37,6 +42,9 @@
> // Property to set the alarm sound model in the edit alarm page
> property var soundModel
Maybe we should rename it to defaultSoundModel, to have common name convention with customSoundModel
>
> + // Property to set the custom alarm sound model in the edit alarm page
> + property var customSoundModel
> +
> /*
> Properties to store the previously set alarm sound values to detect
> if the user changed the alarm sound or not
> @@ -70,22 +83,206 @@
> }
> }
>
> + ContentTransferHint {
> + anchors.fill: parent
> + activeTransfer: _alarmSoundPage.activeTransfer
> + }
> +
> + Connections {
> + target: _alarmSoundPage.activeTransfer
> + onStateChanged: {
> + if (_alarmSoundPage.activeTransfer.state === ContentTransfer.Charged) {
> + _alarmSoundPage.importItems = _alarmSoundPage.activeTransfer.items
> + console.log("[LOG] Original Custom Alarm Sound URL: " + _alarmSoundPage.importItems[0].url)
> + _alarmSoundPage.importItems[0].move(customSound.alarmSoundDirectory)
> + console.log("[LOG] Final Custom Alarm Sound URL: " + _alarmSoundPage.importItems[0].url)
> + }
> + }
> + }
> +
> Audio {
> id: previewAlarmSound
> audioRole: MediaPlayer.alert
> +
> + function controlPlayback(fileURL) {
> + source = fileURL
> + if (playbackState === Audio.StoppedState || playbackState === Audio.PausedState) {
> + play()
> + } else if (playbackState === Audio.PlayingState) {
> + stop()
> + }
> + }
> + }
> +
> + CustomAlarmSound {
> + id: customSound
> }
>
> Flickable {
> id: _pageFlickable
>
> anchors.fill: parent
> - contentHeight: soundModel.count * units.gu(7)
> + contentHeight: soundModel.count * units.gu(7) +
> + customSoundModel.count * units.gu(7) +
> + customSoundListItem.height
>
> Column {
> id: _alarmSoundColumn
>
> anchors.fill: parent
>
> + ListItem {
> + id: customSoundListItem
> + height: units.gu(7)
> + Button {
> + id: customSoundButton
> + text: i18n.tr("Add custom sound")
> + width: parent.width / 1.1
> + anchors.centerIn: parent
> + onClicked: {
> + pageStack.push(Qt.resolvedUrl("MusicAppPicker.qml"), {alarmSoundPage: _alarmSoundPage})
> + }
> + }
> + }
> +
> + Repeater {
> + id: _customAlarmSounds
> + objectName: "customAlarmSounds"
> +
> + model: customSoundModel
> +
> + ListItem {
> + id: _customAlarmSoundDelegate
> +
> + property alias isChecked: _customSoundStatus.checked
> +
> + height: units.gu(7)
> +
> + leadingActions: ListItemActions {
> + actions: [
> + Action {
> + iconName: "delete"
> + onTriggered: {
> + previewAlarmSound.stop()
> +
> + /*
> + In case the selected custom alarm sound is deleted by the user, then
> + set the alarm sound back to the default sound.
> + */
> + if (_customAlarmSoundDelegate.isChecked) {
> +
> + /*
> + If the oldAlarmSoundName is the deleted custom alarm sound, then
> + set the oldAlarmSound name & url to the default alarm ringtone as well.
> + */
> + if (oldAlarmSoundName === fileName) {
> + alarmSound.subText = "Alarm clock"
We should create some constant string for default sound, as it will be also used in sound preview.
> + oldAlarmSoundName = "Alarm clock"
> + for (var i=0; i<soundModel.count; i++) {
> + if (soundModel.get(i,"fileBaseName") === alarmSound.subText) {
missing space after comma
> + alarm.sound = soundModel.get(i, "fileURL")
> + oldAlarmSoundUrl = alarm.sound
> + previewAlarmSound.source = soundModel.get(i, "fileURL")
> + _alarmSounds.itemAt(i).isChecked = true
> + }
> + }
> + }
> +
> + else {
> + alarmSound.subText = oldAlarmSoundName
> + alarm.sound = oldAlarmSoundUrl
> + previewAlarmSound.source = alarm.sound
> +
> + for (var j=0; j<soundModel.count; j++) {
> + if (soundModel.get(j, "fileBaseName") === alarmSound.subText) {
> + _alarmSounds.itemAt(j).isChecked = true
> + }
> + }
> +
> + for (j=0; j<customSoundModel.count; j++) {
> + if (soundModel.get(j, "fileBaseName") === alarmSound.subText) {
> + _customAlarmSounds.itemAt(j).isChecked = true
> + }
> + }
> + }
> + }
> +
> + customSound.deleteAlarmSound(fileName)
> + }
> + }
> + ]
> + }
> +
> + Label {
> + id: _customSoundName
> + objectName: "customSoundName" + index
> +
> + anchors {
> + left: parent.left
> + leftMargin: units.gu(2)
> + right: _customSoundStatus.left
> + rightMargin: units.gu(2)
> + verticalCenter: parent.verticalCenter
> + }
> +
> + elide: Text.ElideRight
> + color: UbuntuColors.midAubergine
> + fontSize: "medium"
> + text: fileBaseName
> + }
> +
> + CheckBox {
> + id: _customSoundStatus
> + objectName: "customSoundStatus" + index
> +
> + anchors {
> + right: parent.right
> + rightMargin: units.gu(2)
> + verticalCenter: parent.verticalCenter
> + }
> +
> + checked: alarmSound.subText === _customSoundName.text ? true
> + : false
> + onCheckedChanged: {
> + if (checked) {
> + previewAlarmSound.controlPlayback(fileURL)
> + alarmSound.subText = _customSoundName.text
> + alarm.sound = fileURL
> +
> + // Ensures only one alarm sound is selected
> + for(var i=0; i<customSoundModel.count; i++) {
> + if(_customAlarmSounds.itemAt(i).isChecked &&
> + i !== index) {
> + _customAlarmSounds.itemAt(i).isChecked = false
> + }
> + }
> +
> + // Ensures only one alarm sound is selected
> + for(i=0; i<soundModel.count; i++) {
> + _alarmSounds.itemAt(i).isChecked = false
> + }
> + }
> + }
> +
> + onClicked: {
> + if (!checked) {
> + checked = true
> + } else {
> + previewAlarmSound.controlPlayback(fileURL)
> + }
> + }
> + }
> +
> + onClicked: {
> + if (!_customSoundStatus.checked) {
> + _customSoundStatus.checked = true
> + } else {
> + previewAlarmSound.controlPlayback(fileURL)
> + }
> + }
> + }
> + }
> +
> Repeater {
> id: _alarmSounds
> objectName: "alarmSounds"
--
https://code.launchpad.net/~nik90/ubuntu-clock-app/custom-alarm-sound/+merge/268499
Your team Ubuntu Clock Developers is subscribed to branch lp:ubuntu-clock-app.
References