diff options
| -rw-r--r-- | BeetPlayer.pro | 3 | ||||
| -rw-r--r-- | playerwidget.cpp | 47 | ||||
| -rw-r--r-- | playerwidget.h | 4 | 
3 files changed, 53 insertions, 1 deletions
| diff --git a/BeetPlayer.pro b/BeetPlayer.pro index a2aa13f..bc8e1d3 100644 --- a/BeetPlayer.pro +++ b/BeetPlayer.pro @@ -4,7 +4,8 @@  #  #------------------------------------------------- -QT       += core gui multimedia sql +QT      += core gui multimedia sql +QT      += KGlobalAccel  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 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); diff --git a/playerwidget.h b/playerwidget.h index 0218fde..a9259e2 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -36,6 +36,9 @@ class PlayerWidget : public QWidget {          void doPlay();          void doStop();          void doPause(); +        void doPlayOrPause(); +        void volumeUp(); +        void volumeDown();          void doFilter();          void clearFilter();          void reindex(); @@ -78,6 +81,7 @@ class PlayerWidget : public QWidget {          void play(const QString &fullPath);          void advance(int numSongs);          void expandRecursive(const QModelIndex &idx); +        void adjustVolume(int by);          QLineEdit *mSearch;          QMediaPlayer *mPlayer;          BeetView *mView; | 
