[vlc-devel] [PATCH 4/6] A new icon added for the playlist shuffle button. Shuffle functionality added.

Martin Zeman dileptor at gmail.com
Sat Mar 9 00:17:22 CET 2013


---
 modules/gui/qt4/components/playlist/playlist.cpp   |    2 +-
 .../gui/qt4/components/playlist/standardpanel.cpp  |   21 ++++++++++++++++----
 .../gui/qt4/pixmaps/playlist/shuffle_playlist.png  |  Bin 0 -> 1622 bytes
 modules/gui/qt4/vlc.qrc                            |    1 +
 4 files changed, 19 insertions(+), 5 deletions(-)
 create mode 100644 modules/gui/qt4/pixmaps/playlist/shuffle_playlist.png

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 59d0b8c..4138f3f 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -125,7 +125,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     /* Button to shuffle playlist */
     QToolButton *shuffleButton = new QToolButton( this );
-    shuffleButton->setIcon(QIcon( ":/buttons/playlist/shuffle_on"));
+    shuffleButton->setIcon(QIcon( ":/buttons/playlist/shuffle_playlist"));
     shuffleButton->setToolTip( qtr("Shuffle the playlist") );
     topbarLayout->addWidget( shuffleButton );
 
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 738d099..2089aa5 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -65,9 +65,6 @@
 #include <assert.h>
 
 
-#include <iostream>
-#include <string.h>
-
 StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   intf_thread_t *_p_intf,
                                   playlist_item_t *p_root,
@@ -745,7 +742,23 @@ void StandardPLPanel::shufflePlaylist()
 	    }
 	    p_plModel->doDelete(l);
 
-	    for( int i = i_rowCount-1; i > -1; i--)
+	    srand( time(NULL) );
+	    int i_ub, i_j;
+	    char psz_tmp[i_max + 1];
+	    for( int i = i_rowCount-1; i > 0; i--)
+	    {
+	    	i_ub = RAND_MAX - ( ( RAND_MAX % (i + 1) ) + 1);
+
+	    	do
+	    	{
+	    		i_j = rand() & (i + 1);
+	    	} while (i_j > i_ub);
+
+	    	strcpy( psz_tmp, shuffle[i_j] );
+	    	strcpy( shuffle[i_j], shuffle[i] );
+	    	strcpy( shuffle[i], psz_tmp );
+	    }
+	    for( int i = 0; i < i_rowCount; i++)
 	    {
 	    	playlist_Add( THEPL, shuffle[i], NULL, PLAYLIST_APPEND, PLAYLIST_END, true,false );
 	    }
diff --git a/modules/gui/qt4/pixmaps/playlist/shuffle_playlist.png b/modules/gui/qt4/pixmaps/playlist/shuffle_playlist.png
new file mode 100644
index 0000000000000000000000000000000000000000..81ec0eb75365352b6bd61989f3ed02fbc8878e78
GIT binary patch
literal 1622
zcmbVMdr;GM9IuGTx^YurcaxnE0&*~H(}X at F6-(2O0tGBE>P^AW1{$GFm!z~Ho0FHX
zDW^DK=Qi<yH*P124^;G~9L_l(6UUI%2R=|4-l22g=IIGb!Mgpy`Nw{j<oEi1KHqoN
zWu$!&zz^Z`c)S2z5 at z7$S)SM5kNbv=jN{xiht(L_Osar&;xxfinW=mN&{^?9!a(5W
z(vN>4;(5I31!R_yHR at AQ6J-_R9vPv_YUj{AUVMVfj+=@I7RV<GNt+UUbo?X;kY**A
zBhicWb~Rxklgel!vn(ykR90kCn8AdFK)eg(2&@E)11 at W^jX_;XaDo@*)}CVs1SUk-
zA|*I!lu at 4ns41ENB*Hj>Nd&`yR4RnU5~&oP4<I5KfkfOR6~JOtB1I7y at N$5hHriZ(
z8ZhlkUEEFyT3FVOLXgwx6guOC6kQ0x3WdVMfgl1-Lco;TSllJBF%ez{j9^SOX=h2w
z26!0pe9FNpLC(@i7p!)@{uQx}c^N1!WRMHDL$FW;S*;$wCZrkGK>TaQl+sLAshxlf
z1VcG!6PJ&I2rrn6-Rl*31UYNabeiOnf)`_y$zdg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OG$d&;D+4`5n1%*|$;2)!<nEKwZ=W_T=qVGoIuWz2Sc79E&)`i&0M>Ll^jk
PdH(b|O&ZpkxV+*Y($-&q

literal 0
HcmV?d00001

diff --git a/modules/gui/qt4/vlc.qrc b/modules/gui/qt4/vlc.qrc
index e2c1f8d..26341f2 100644
--- a/modules/gui/qt4/vlc.qrc
+++ b/modules/gui/qt4/vlc.qrc
@@ -73,6 +73,7 @@
         <file alias="repeat_all">pixmaps/playlist/repeat_all.png</file>
         <file alias="repeat_one">pixmaps/playlist/repeat_one.png</file>
         <file alias="shuffle_on">pixmaps/playlist/shuffle_on.png</file>
+	<file alias="shuffle_playlist">pixmaps/playlist/shuffle_playlist.png</file>
         <file alias="jump_to">pixmaps/playlist/jumpto.png</file>
     </qresource>
     <qresource prefix="/type">
-- 
1.7.9.5




More information about the vlc-devel mailing list