Commit 31604772 authored by kempe's avatar kempe

Updated old dockedaudioplayer to use new sleep timer

parent 283328fb
import QtQuick 2.6
import Sailfish.Silica 1.0
import it.kempe.AudioPlayer 1.0
import "../js/Storage.js" as DB
import "../sleeptimer"
import "../js/Favorites.js" as FavoritesUtils
import "../js/Utils.js" as Utils
DockedAudioPlayerForm {
id: player
......@@ -17,37 +16,40 @@ DockedAudioPlayerForm {
// Property assignment
isPlaying: AudioPlayer.isPlaying
showProgressBar: AudioPlayer.isLoading || AudioPlayer.isBuffering
bufferProgress: AudioPlayer.bufferProgress
currentTrack: AudioPlayer.title
bufferProgress: AudioPlayer.bufferProgress
showProgressBar: AudioPlayer.isLoading || AudioPlayer.isBuffering
sleepTimerActive: sleepTimer.running
sleepTimerText: sleepTimer.clockText
// Triggers
opener.onClicked: console.debug("Show fullscreen player controls")
buttonPlay.onClicked: AudioPlayer.togglePlayback();
buttonStar.onClicked: player.isFavorite = FavoritesUtils.toogleFavorite(stationData)
buttonPrevious.onClicked: playPrev()
buttonPlay.onClicked: AudioPlayer.togglePlayback();
buttonNext.onClicked: playNext()
sleepTimer.onSleepTriggered: AudioPlayer.stop()
cancelSleepTimer.onClicked: sleepTimer.stopTimer()
setSleepTimer.onClicked: {
var sTime = DB.loadSleepTimer()
console.debug("DB HOUR: " + sTime.hour)
console.debug("DB MINUTE: " + sTime.minute)
var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", {
hour: sTime.hour,
minute: sTime.minute,
hourMode: DateTime.TwentyFourHours
})
dialog.accepted.connect(function() {
DB.updateSleepTimer(dialog.hour, dialog.minute)
var sec = (dialog.minute + (dialog.hour * 60)) * 60;
sleepTimer.startTimer(sec);
})
playerMenu.close()
pageStack.push(sleepTimerDialog)
}
// Components
SleepTimer {
id: sleepTimer
onSleepTriggered: {
AudioPlayer.stop()
}
}
Component {
id: sleepTimerDialog
SleepTimerDialog {
onActivateTimer: sleepTimer.startTimer(sec)
}
}
// Helper functions
function play(station) {
......
import QtQuick 2.6
import Sailfish.Silica 1.0
import "../"
import "../sleeptimer"
DockedPanel {
id: player
property alias opener: opener
property bool isPlaying
property bool isFavorite
property var stationData
property string currentTrack
property int bufferProgress
property bool showProgressBar
property bool sleepTimerActive
property string sleepTimerText
property alias opener: opener
property alias buttonPlay: controls.buttonPlay
property alias buttonStar: controls.buttonStar
property alias buttonPrevious: controls.buttonPrevious
property alias buttonPlay: controls.buttonPlay
property alias buttonNext: controls.buttonNext
property alias playerMenu: playerMenu
property alias sleepTimer: sleepTimer
property alias cancelSleepTimer: cancelSleepTimer
property alias setSleepTimer: setSleepTimer
property bool showProgressBar: false
property bool isPlaying: false
property bool isFavorite: false
property int bufferProgress: 0
property string currentTrack: ""
property real hightPadding: Theme.paddingMedium
property var stationData
height: Theme.itemSizeExtraLarge + (hightPadding * 2)
contentHeight: height
flickableDirection: Flickable.VerticalFlick
SleepTimer {
id: sleepTimer
}
flickableDirection: Flickable.VerticalFlick
MouseArea {
id: opener
......@@ -108,19 +106,19 @@ DockedPanel {
MenuLabelSmal {
id: sleepTimerLabel
visible: sleepTimer.running
text: sleepTimer.clockText
visible: sleepTimerActive
text: sleepTimerText
}
MenuItem{
id: cancelSleepTimer
visible: sleepTimer.running
visible: sleepTimerActive
text: qsTr("Cancel")
}
MenuItem {
id: setSleepTimer
visible: !sleepTimer.running
visible: !sleepTimerActive
text: qsTr("Set")
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment