summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 38e2eff..5e6e648 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -26,6 +26,7 @@
#include <taglib/fileref.h>
#include <taglib/tag.h>
#include <taglib/audioproperties.h>
+#include <kglobalaccel.h>
#include "playerwidget.h"
#include "beetview.h"
@@ -218,10 +219,18 @@ void PlayerWidget::createActions(){
playAG->addAction(mStopA);
mStopA->setChecked(true);
connect(mStopA, SIGNAL(triggered()), this, SLOT(doStop()));
+ QAction *playOrPauseA = new QAction(tr("Play or Pause"), this);
+ playOrPauseA->setObjectName("beetPlayerDoPlayOrPause");
+ connect(playOrPauseA, SIGNAL(triggered()), this, SLOT(doPlayOrPause()));
+ KGlobalAccel::self()->setShortcut(playOrPauseA, QList<QKeySequence>() << QKeySequence(Qt::Key_MediaPlay), KGlobalAccel::Autoloading);
QAction *previousA = new QAction(QIcon(":/previous.png"), tr("Previous"), this);
+ previousA->setObjectName("beetPlayerPrevious");
connect(previousA, SIGNAL(triggered()), this, SLOT(previous()));
+ KGlobalAccel::self()->setShortcut(previousA, QList<QKeySequence>() << QKeySequence(Qt::Key_Launch2), KGlobalAccel::Autoloading);
QAction *nextA = new QAction(QIcon(":/next.png"), tr("Next"), this);
+ nextA->setObjectName("beetPlayerNext");
connect(nextA, SIGNAL(triggered()), this, SLOT(next()));
+ KGlobalAccel::self()->setShortcut(nextA, QList<QKeySequence>() << QKeySequence(Qt::Key_Launch3), KGlobalAccel::Autoloading);
QAction *addToPlayListA = new QAction(QIcon(":/belly_right.png"), tr("Add to playlist"), this);
connect(addToPlayListA, SIGNAL(triggered()), this, SLOT(addToPlayList()));
QAction *addToPlayListAndClearA = new QAction(QIcon(":/belly_right_and_clear.png"), tr("Clear and add"), this);
@@ -241,8 +250,18 @@ void PlayerWidget::createActions(){
QAction *randomPlayA = new QAction(QIcon(":/dice.png"), tr("Play random"), this);
connect(randomPlayA, SIGNAL(triggered()), this, SLOT(randomPlay()));
QAction *muteA = new QAction(QIcon(":/mute.png"), tr("Mute"), this);
+ muteA->setObjectName("beetPlayerMute");
muteA->setCheckable(true);
connect(muteA, SIGNAL(triggered(bool)), this, SLOT(mute(bool)));
+ KGlobalAccel::self()->setShortcut(muteA, QList<QKeySequence>() << QKeySequence(Qt::Key_VolumeMute), KGlobalAccel::Autoloading);
+ QAction *volumeUpA = new QAction(tr("Increase volume"), this);
+ volumeUpA->setObjectName("beetPlayerIncVolume");
+ connect(volumeUpA, SIGNAL(triggered()), this, SLOT(volumeUp()));
+ KGlobalAccel::self()->setShortcut(volumeUpA, QList<QKeySequence>() << QKeySequence(Qt::Key_VolumeUp), KGlobalAccel::Autoloading);
+ QAction *volumeDownA = new QAction(tr("Decrease volume"), this);
+ volumeDownA->setObjectName("beetPlayerDecVolume");
+ connect(volumeDownA, SIGNAL(triggered()), this, SLOT(volumeDown()));
+ KGlobalAccel::self()->setShortcut(volumeDownA, QList<QKeySequence>() << QKeySequence(Qt::Key_VolumeDown), KGlobalAccel::Autoloading);
QAction *configA = Globals::instance()->action(Globals::ConfigAction);
QAction *helpA = new QAction(Helper::iconFromQChar(QChar(0x00BF), 50), tr("Help"), this);
QMenu *helpM = new QMenu;
@@ -594,6 +613,34 @@ void PlayerWidget::doPause(){
emit setWinTitle(winTitle);
}
+void PlayerWidget::doPlayOrPause(){
+ if(mPlayA->isChecked()){
+ doPause();
+ }else if(mPauseA->isChecked() || mStopA->isChecked()){
+ doPlay();
+ }
+}
+
+void PlayerWidget::volumeUp(){
+ adjustVolume(2);
+}
+
+void PlayerWidget::volumeDown(){
+ adjustVolume(-2);
+}
+
+void PlayerWidget::adjustVolume(int by){
+ int curVol = mVolumeSlider->value();
+ int newVol = curVol + by;
+ if(newVol > 100){
+ newVol = 100;
+ }
+ if(newVol < 0){
+ newVol = 0;
+ }
+ mVolumeSlider->setValue(newVol);
+}
+
void PlayerWidget::recurse(const QModelIndex &parent){
for(int i = 0; i < mCurrentModel->rowCount(parent); ++i){
QModelIndex cur = mCurrentModel->index(i, 0, parent);