Add keyboard navigation for media playback
This commit is contained in:
parent
76d1d48bff
commit
cb4aa06901
3 changed files with 48 additions and 1 deletions
|
@ -40,6 +40,14 @@ MediaPlayer {
|
||||||
property int lastDuration: 0
|
property int lastDuration: 0
|
||||||
property int playedFrom: 0
|
property int playedFrom: 0
|
||||||
|
|
||||||
|
function togglePause() {
|
||||||
|
if (playbackState === MediaPlayer.PlayingState) {
|
||||||
|
pause();
|
||||||
|
} else if (playbackState === MediaPlayer.PausedState) {
|
||||||
|
play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function playbackEpisode(episode_id) {
|
function playbackEpisode(episode_id) {
|
||||||
if (episode == episode_id) {
|
if (episode == episode_id) {
|
||||||
// If the episode is already loaded, just start playing
|
// If the episode is already loaded, just start playing
|
||||||
|
|
|
@ -34,6 +34,35 @@ Item {
|
||||||
GPodderPodcastListModel { id: podcastListModel }
|
GPodderPodcastListModel { id: podcastListModel }
|
||||||
GPodderPodcastListModelConnections {}
|
GPodderPodcastListModelConnections {}
|
||||||
|
|
||||||
|
Keys.onPressed: {
|
||||||
|
switch (event.key) {
|
||||||
|
case Qt.Key_Space:
|
||||||
|
player.togglePause();
|
||||||
|
break;
|
||||||
|
case Qt.Key_Q:
|
||||||
|
player.seekAndSync(player.position - 60 * 1000);
|
||||||
|
break;
|
||||||
|
case Qt.Key_W:
|
||||||
|
player.seekAndSync(player.position - 10 * 1000);
|
||||||
|
break;
|
||||||
|
case Qt.Key_O:
|
||||||
|
player.seekAndSync(player.position + 10 * 1000);
|
||||||
|
break;
|
||||||
|
case Qt.Key_P:
|
||||||
|
player.seekAndSync(player.position + 60 * 1000);
|
||||||
|
break;
|
||||||
|
case Qt.Key_Escape:
|
||||||
|
case Qt.Key_Backspace:
|
||||||
|
backButton.clicked();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial focus
|
||||||
|
focus: true
|
||||||
|
|
||||||
property real scalef: (width < height) ? (width / 480) : (height / 480)
|
property real scalef: (width < height) ? (width / 480) : (height / 480)
|
||||||
property int shorterSide: (width < height) ? width : height
|
property int shorterSide: (width < height) ? width : height
|
||||||
property int dialogsVisible: 0
|
property int dialogsVisible: 0
|
||||||
|
@ -169,7 +198,11 @@ Item {
|
||||||
icon: Icons.arrow_left
|
icon: Icons.arrow_left
|
||||||
|
|
||||||
enabled: pgst.hasBackButton
|
enabled: pgst.hasBackButton
|
||||||
onClicked: pgst.children[pgst.children.length-1].closePage();
|
onClicked: {
|
||||||
|
if (enabled) {
|
||||||
|
pgst.children[pgst.children.length-1].closePage();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,12 @@ Item {
|
||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
id: textInput
|
id: textInput
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
// Return keyboard focus to pgst
|
||||||
|
pgst.focus = true;
|
||||||
|
}
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue