Commit e13f5912 authored by nikunj goyal's avatar nikunj goyal Committed by Matthieu Gallien
Browse files

Add keyboard navigation to move between tracks

parent 31566981
Pipeline #35076 passed with stage
in 21 minutes
......@@ -19,6 +19,7 @@
#include "elisa_settings.h"
#include <KConfigCore/KAuthorized>
#include <KLocalizedString>
#if defined KF5ConfigWidgets_FOUND && KF5ConfigWidgets_FOUND
#include <KConfigWidgets/KStandardAction>
......@@ -167,6 +168,18 @@ void ElisaApplication::setupActions(const QString &actionName)
d->mCollection.setDefaultShortcut(scrubAction, QKeySequence(Qt::SHIFT + Qt::Key_Left));
}
if (actionName == QLatin1String("NextTrack") && KAuthorized::authorizeAction(actionName)) {
auto nextTrackAction = d->mCollection.addAction(actionName, this, &ElisaApplication::nextTrack);
nextTrackAction->setText(i18n("Go to next track"));
d->mCollection.setDefaultShortcut(nextTrackAction, QKeySequence(Qt::CTRL + Qt::Key_Left));
}
if (actionName == QLatin1String("PreviousTrack") && KAuthorized::authorizeAction(actionName)) {
auto previousTrackAction = d->mCollection.addAction(actionName, this, &ElisaApplication::previousTrack);
previousTrackAction->setText(i18n("Go to previous track"));
d->mCollection.setDefaultShortcut(previousTrackAction, QKeySequence(Qt::CTRL + Qt::Key_Right));
}
if (actionName == QLatin1String("Play-Pause") && KAuthorized::authorizeAction(actionName)) {
auto playPauseAction = d->mCollection.addAction(actionName, this, &ElisaApplication::playPause);
d->mCollection.setDefaultShortcut(playPauseAction, QKeySequence(Qt::Key_Space));
......@@ -292,6 +305,10 @@ void ElisaApplication::seek() {}
void ElisaApplication::scrub() {}
void ElisaApplication::nextTrack() {}
void ElisaApplication::previousTrack() {}
void ElisaApplication::playPause() {}
void ElisaApplication::configChanged()
......
......@@ -193,6 +193,10 @@ private Q_SLOTS:
void configChanged();
void nextTrack();
void previousTrack();
private:
void initializeModels();
......
......@@ -52,6 +52,8 @@ Kirigami.ApplicationWindow {
property var goBackAction: ElisaApplication.action("go_back")
property var seekAction: ElisaApplication.action("Seek")
property var scrubAction: ElisaApplication.action("Scrub")
property var nextTrackAction : ElisaApplication.action("NextTrack")
property var previousTrackAction: ElisaApplication.action("PreviousTrack")
property var playPauseAction: ElisaApplication.action("Play-Pause")
property var findAction: ElisaApplication.action("edit_find")
......@@ -70,6 +72,16 @@ Kirigami.ApplicationWindow {
onTriggered: ElisaApplication.audioControl.seek(headerBar.playerControl.position - 10000)
}
Action {
shortcut: nextTrackAction.shortcut
onTriggered: ElisaApplication.mediaPlayListProxyModel.skipPreviousTrack(ElisaApplication.audioPlayer.position)
}
Action {
shortcut: previousTrackAction.shortcut
onTriggered: ElisaApplication.mediaPlayListProxyModel.skipNextTrack(ElisaApplication.audioPlayer.position)
}
Action {
shortcut: playPauseAction.shortcut
onTriggered: ElisaApplication.audioControl.playPause()
......
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