summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--beetplayer.qrc1
-rw-r--r--mute.pngbin0 -> 2689 bytes
-rw-r--r--playerwidget.cpp70
-rw-r--r--playerwidget.h9
4 files changed, 69 insertions, 11 deletions
diff --git a/beetplayer.qrc b/beetplayer.qrc
index 3ba8fbf..c115556 100644
--- a/beetplayer.qrc
+++ b/beetplayer.qrc
@@ -11,5 +11,6 @@
<file>refresh.png</file>
<file>dice.png</file>
<file>shuffle.png</file>
+ <file>mute.png</file>
</qresource>
</RCC>
diff --git a/mute.png b/mute.png
new file mode 100644
index 0000000..2ee846d
--- /dev/null
+++ b/mute.png
Binary files differ
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 40294db..13cd2f5 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -29,6 +29,9 @@ PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent){
}
void PlayerWidget::setupGui(){
+ //the Player
+ mPlayer = new QMediaPlayer(this);
+
//THE view
mView = new BeetView;
mViewModel = new QStandardItemModel;
@@ -64,9 +67,16 @@ void PlayerWidget::setupGui(){
mNowPlayingL->setFont(QFont("courier new", 20, QFont::Bold));
mNowPlayingL->setText(tr("(none)"));
- //slider
- mSlider = new QSlider;
- mSlider->setOrientation(Qt::Horizontal);
+ //song slider
+ QLabel *l1 = new QLabel(tr("Song"));
+ mSongSlider = new QSlider;
+ mSongSlider->setOrientation(Qt::Horizontal);
+ mPos = new QLabel(tr("00:00"));
+ mPos->setFont(QFont("courier"));
+ QHBoxLayout *songSliderL = new QHBoxLayout;
+ songSliderL->addWidget(l1);
+ songSliderL->addWidget(mSongSlider);
+ songSliderL->addWidget(mPos);
//current info
QGroupBox *currentInfoGB = new QGroupBox(tr("Current"));
@@ -76,14 +86,31 @@ void PlayerWidget::setupGui(){
currentInfoL->addWidget(mCurrentTE);
currentInfoGB->setLayout(currentInfoL);
+ //volume slider
+ QLabel *l2 = new QLabel(tr("Volume"));
+ mVolumeSlider = new QSlider;
+ mVolumeSlider->setOrientation(Qt::Horizontal);
+ mVolumeSlider->setMinimum(0);
+ mVolumeSlider->setMaximum(100);
+ mVolumePos = new QLabel(tr("000 %"));
+ mVolumePos->setFont(QFont("courier"));
+ connect(mVolumeSlider, SIGNAL(valueChanged(int)), mPlayer, SLOT(setVolume(int)));
+ connect(mVolumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));
+ mVolumeSlider->setValue(33);
+ QHBoxLayout *volumeL = new QHBoxLayout;
+ volumeL->addWidget(l2);
+ volumeL->addWidget(mVolumeSlider);
+ volumeL->addWidget(mVolumePos);
+
//center widget
QWidget *centerWidget = new QWidget;
QVBoxLayout *centerWidgetL = new QVBoxLayout;
mToolBar = new QToolBar;
centerWidgetL->addWidget(mToolBar);
centerWidgetL->addWidget(mNowPlayingL);
- centerWidgetL->addWidget(mSlider);
+ centerWidgetL->addLayout(songSliderL);
centerWidgetL->addWidget(currentInfoGB);
+ centerWidgetL->addLayout(volumeL);
centerWidget->setLayout(centerWidgetL);
//playlist
@@ -105,9 +132,6 @@ void PlayerWidget::setupGui(){
rightWidgetL->addWidget(playListGB);
rightWidget->setLayout(rightWidgetL);
- //the Player
- mPlayer = new QMediaPlayer(this);
-
//put it all together
QSplitter *splitter = new QSplitter;
splitter->addWidget(leftWidget);
@@ -120,9 +144,21 @@ void PlayerWidget::setupGui(){
}
void PlayerWidget::createActions(){
- QAction *playA = new QAction(QIcon(":/play.png"), tr("Play"), this);
+ QActionGroup *playAG = new QActionGroup(this);
+ playAG->setExclusive(true);
+ mPlayA = new QAction(QIcon(":/play.png"), tr("Play"), this);
+ mPlayA->setCheckable(true);
+ playAG->addAction(mPlayA);
+ connect(mPlayA, SIGNAL(triggered()), mPlayer, SLOT(play()));
QAction *pauseA = new QAction(QIcon(":/pause.png"), tr("Pause"), this);
+ pauseA->setCheckable(true);
+ playAG->addAction(pauseA);
+ connect(pauseA, SIGNAL(triggered()), mPlayer, SLOT(pause()));
QAction *stopA = new QAction(QIcon(":/stop.png"), tr("Stop"), this);
+ stopA->setCheckable(true);
+ playAG->addAction(stopA);
+ stopA->trigger();
+ connect(stopA, SIGNAL(triggered()), mPlayer, SLOT(stop()));
QAction *addToPlayListA = new QAction(QIcon(":/belly_right.png"), tr("Add to playlist"), this);
connect(addToPlayListA, SIGNAL(triggered()), this, SLOT(addToPlayList()));
QAction *removeFromPlayListA = new QAction(QIcon(":/belly_left.png"), tr("Remove from playlist"), this);
@@ -135,6 +171,9 @@ void PlayerWidget::createActions(){
connect(shufflePlayistA, SIGNAL(triggered()), this, SLOT(shufflePlayList()));
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->setCheckable(true);
+ connect(muteA, SIGNAL(triggered(bool)), this, SLOT(mute(bool)));
QAction *configA = Globals::instance()->action(Globals::ConfigAction);
mView->addAction(addToPlayListA);
mView->addAction(randomPlayA);
@@ -144,7 +183,7 @@ void PlayerWidget::createActions(){
QWidget* spacer1 = new QWidget();
spacer1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mToolBar->addWidget(spacer1);
- mToolBar->addAction(playA);
+ mToolBar->addAction(mPlayA);
mToolBar->addAction(pauseA);
mToolBar->addAction(stopA);
mToolBar->addSeparator();
@@ -156,6 +195,8 @@ void PlayerWidget::createActions(){
mToolBar->addSeparator();
mToolBar->addAction(refreshA);
mToolBar->addSeparator();
+ mToolBar->addAction(muteA);
+ mToolBar->addSeparator();
mToolBar->addAction(configA);
QWidget* spacer2 = new QWidget();
spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -414,5 +455,14 @@ void PlayerWidget::playCurrent(const QModelIndex &index){
void PlayerWidget::play(const QString &fullPath){
mPlayer->setMedia(QUrl::fromLocalFile(fullPath));
- mPlayer->play();
+ mPlayA->trigger();
+}
+
+void PlayerWidget::volumeChanged(int volume){
+ QString s = QString("%1 %").arg(volume, 3, 10, QChar('0'));
+ mVolumePos->setText(s);
+}
+
+void PlayerWidget::mute(bool triggered){
+ mPlayer->setMuted(triggered);
}
diff --git a/playerwidget.h b/playerwidget.h
index a321e4a..a4d183a 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -11,6 +11,7 @@ class QSlider;
class QTextEdit;
class QMediaPlayer;
class QToolBar;
+class QAction;
class BeetPlayerProxy;
class BeetView;
@@ -32,6 +33,8 @@ class PlayerWidget : public QWidget {
void shufflePlayList();
void randomPlay();
void playCurrent(const QModelIndex &index);
+ void mute(bool triggered);
+ void volumeChanged(int volume);
private:
void setupGui();
@@ -49,11 +52,15 @@ class PlayerWidget : public QWidget {
QStandardItemModel *mSearchModel;
QStandardItemModel *currentModel;
QLabel *mNowPlayingL;
- QSlider *mSlider;
+ QSlider *mSongSlider;
+ QLabel *mPos;
+ QSlider *mVolumeSlider;
+ QLabel *mVolumePos;
QTextEdit *mCurrentTE;
BeetView *mPlayListView;
QStandardItemModel *mPlayListModel;
QToolBar *mToolBar;
+ QAction *mPlayA;
};
#endif // PLAYERWIDGET_H