Sleep timer UI

This commit is contained in:
Thomas Perl 2014-12-17 21:13:37 +01:00
parent 3cc6847ee4
commit af609a0b3f
4 changed files with 100 additions and 1 deletions

View file

@ -3,7 +3,6 @@
# be started with qmlscene directly from a source checkout
ln -sf gpodder-core/src/gpodder .
ln -sf gpodder-core/src/jsonconfig.py .
ln -sf podcastparser/podcastparser.py .
ln -sf gpodder-ui-qml/main.py .
ln -sf ../gpodder-ui-qml/common qml

View file

@ -39,6 +39,17 @@ Column {
color: Theme.primaryColor
}
Label {
visible: player.sleepTimerRunning
text: 'Sleep timer: ' + Util.formatDuration(player.sleepTimerRemaining)
width: parent.width
horizontalAlignment: Text.AlignHCenter
color: Theme.secondaryHighlightColor
wrapMode: Text.Wrap
font.pixelSize: Theme.fontSizeExtraSmall
}
Label {
text: player.episode_title
width: parent.width

View file

@ -38,6 +38,17 @@ Page {
model: player.episode_chapters
}
MenuItem {
text: player.sleepTimerRunning ? 'Stop sleep timer' : 'Sleep timer'
onClicked: {
if (player.sleepTimerRunning) {
player.stopSleepTimer();
} else {
pageStack.push('SleepTimerDialog.qml', { player: player });
}
}
}
MenuItem {
text: player.isPlaying ? 'Pause': 'Play'
onClicked: {
@ -73,6 +84,22 @@ Page {
font.pixelSize: Theme.fontSizeSmall
}
Label {
anchors {
left: parent.left
right: parent.right
margins: Theme.paddingLarge
}
visible: player.sleepTimerRunning
truncationMode: TruncationMode.Fade
horizontalAlignment: Text.AlignRight
text: 'Sleep timer: ' + Util.formatDuration(player.sleepTimerRemaining)
color: Theme.rgba(Theme.highlightColor, 0.7)
font.pixelSize: Theme.fontSizeExtraSmall
}
Connections {
target: player
onPositionChanged: {

62
qml/SleepTimerDialog.qml Normal file
View file

@ -0,0 +1,62 @@
/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2014, Thomas Perl <m@thp.io>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: sleepTimerSelector
property var player
SilicaListView {
anchors.fill: parent
header: PageHeader {
title: 'Sleep timer'
}
model: player.durationChoices
delegate: ListItem {
id: listItem
highlighted: down
onClicked: {
sleepTimerSelector.player.startSleepTimer(60 * modelData);
pageStack.pop();
}
Label {
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
margins: Theme.paddingMedium
}
color: listItem.highlighted ? Theme.highlightColor : Theme.primaryColor
text: modelData + ' minutes'
}
}
VerticalScrollDecorator { }
}
}