summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--beetplayer.qrc2
-rw-r--r--[-rwxr-xr-x]chastity_belt.pngbin850 -> 850 bytes
-rw-r--r--[-rwxr-xr-x]delete.pngbin1333 -> 1333 bytes
-rw-r--r--dice.pngbin0 -> 1059 bytes
-rw-r--r--playerwidget.cpp21
-rw-r--r--playerwidget.h1
-rw-r--r--shuffle.pngbin0 -> 539 bytes
7 files changed, 24 insertions, 0 deletions
diff --git a/beetplayer.qrc b/beetplayer.qrc
index b35e691..3ba8fbf 100644
--- a/beetplayer.qrc
+++ b/beetplayer.qrc
@@ -9,5 +9,7 @@
<file>chastity_belt.png</file>
<file>delete.png</file>
<file>refresh.png</file>
+ <file>dice.png</file>
+ <file>shuffle.png</file>
</qresource>
</RCC>
diff --git a/chastity_belt.png b/chastity_belt.png
index ebe3390..ebe3390 100755..100644
--- a/chastity_belt.png
+++ b/chastity_belt.png
Binary files differ
diff --git a/delete.png b/delete.png
index 351659b..351659b 100755..100644
--- a/delete.png
+++ b/delete.png
Binary files differ
diff --git a/dice.png b/dice.png
new file mode 100644
index 0000000..c52be58
--- /dev/null
+++ b/dice.png
Binary files differ
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 976da48..a00ded3 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -15,6 +15,8 @@
#include <QAction>
#include <QToolBar>
+#include <algorithm>
+
#include "playerwidget.h"
#include "beetview.h"
#include "indexerdialog.h"
@@ -124,9 +126,12 @@ void PlayerWidget::createActions(){
connect(clearPlayListA, SIGNAL(triggered()), this, SLOT(clearPlayList()));
QAction *refreshA = new QAction(QIcon(":/refresh.png"), tr("Refresh..."), this);
connect(refreshA, SIGNAL(triggered()), this, SLOT(reindex()));
+ QAction *shufflePlayistA = new QAction(QIcon(":/shuffle.png"), tr("Shuffle playlist"), this);
+ connect(shufflePlayistA, SIGNAL(triggered()), this, SLOT(shufflePlayList()));
QAction *configA = Globals::instance()->action(Globals::ConfigAction);
mView->addAction(addToPlayListA);
mPlayListView->addAction(removeFromPlayListA);
+ mPlayListView->addAction(shufflePlayistA);
mPlayListView->addAction(clearPlayListA);
QWidget* spacer1 = new QWidget();
spacer1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -138,6 +143,7 @@ void PlayerWidget::createActions(){
mToolBar->addAction(addToPlayListA);
mToolBar->addAction(removeFromPlayListA);
mToolBar->addAction(clearPlayListA);
+ mToolBar->addAction(shufflePlayistA);
mToolBar->addSeparator();
mToolBar->addAction(refreshA);
mToolBar->addSeparator();
@@ -357,3 +363,18 @@ void PlayerWidget::clearPlayList(){
mPlayListModel->clear();
mPlayListModel->setHorizontalHeaderLabels(QStringList() << "Title");
}
+
+void PlayerWidget::shufflePlayList(){
+ QVector<QStandardItem*> items;
+ for(int i = 0; i < mPlayListModel->rowCount(); ++i){
+ QStandardItem *cur = mPlayListModel->item(i, 0)->clone();
+ items << cur;
+ }
+ std::random_shuffle(items.begin(), items.end());
+ mPlayListModel->clear();
+ mPlayListModel->setHorizontalHeaderLabels(QStringList() << "Title");
+ QStandardItem *root = mPlayListModel->invisibleRootItem();
+ foreach(QStandardItem *i, items){
+ root->appendRow(i);
+ }
+}
diff --git a/playerwidget.h b/playerwidget.h
index 471b223..ee0b4a1 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -29,6 +29,7 @@ class PlayerWidget : public QWidget {
void addToPlayList();
void removeFromPlayList();
void clearPlayList();
+ void shufflePlayList();
private:
void setupGui();
diff --git a/shuffle.png b/shuffle.png
new file mode 100644
index 0000000..15ea406
--- /dev/null
+++ b/shuffle.png
Binary files differ