1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2007 Ricardo Villalba <rvm@escomposlinux.org>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#include "playlist2.h"
25
#include <qtextstream.h>
27
#include "filedialog.h"
29
#include <qfileinfo.h>
30
#include <qmessagebox.h>
31
#include <qpushbutton.h>
32
#include <qpopupmenu.h>
33
#include <qdragobject.h>
35
#include <qdatetime.h>
36
#include <qsettings.h>
37
#include <qinputdialog.h>
38
#include <qtoolbutton.h>
46
#include "preferences.h"
62
Playlist::Playlist( Core *c, QWidget * parent, const char * name, WFlags f)
63
: QMainWindow(parent, name, f)
72
setCentralWidget( listView );
82
setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding );
85
//setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
86
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
94
srand( t.hour() * 3600 + t.minute() * 60 + t.second() );
98
// Save config every 5 minutes.
99
save_timer = new QTimer(this);
100
connect( save_timer, SIGNAL(timeout()), this, SLOT(maybeSaveSettings()) );
101
save_timer->start( 5 * 60000 );
104
Playlist::~Playlist() {
107
void Playlist::setModified(bool mod) {
108
qDebug("Playlist::setModified: %d", mod);
111
emit modifiedChanged(modified);
114
void Playlist::createTable() {
115
listView = new QTable( this, "listView" );
116
listView->setShowGrid( FALSE );
117
listView->setNumCols(COL_TIME + 1);
118
listView->setReadOnly(TRUE);
119
listView->setFocusStyle(QTable::FollowStyle);
120
listView->setSelectionMode(QTable::MultiRow);
121
//listView->verticalHeader()->hide();
122
listView->setSorting(FALSE);
124
connect( listView, SIGNAL(doubleClicked(int,int,int,const QPoint &)),
125
this, SLOT(itemDoubleClicked(int)) );
127
connect( core, SIGNAL(mediaFinished()), this, SLOT(playNext()) );
129
connect( core, SIGNAL(mediaLoaded()),
130
this, SLOT(getMediaInfo()) );
133
void Playlist::createActions() {
134
openAct = new MyAction(this, "pl_open");
135
connect( openAct, SIGNAL(activated()), this, SLOT(load()) );
137
saveAct = new MyAction(this, "pl_save");
138
connect( saveAct, SIGNAL(activated()), this, SLOT(save()) );
140
playAct = new MyAction(this, "pl_play");
141
connect( playAct, SIGNAL(activated()), this, SLOT(playCurrent()) );
143
nextAct = new MyAction(Qt::Key_Greater, this, "pl_next");
144
connect( nextAct, SIGNAL(activated()), this, SLOT(playNext()) );
146
prevAct = new MyAction(Qt::Key_Less, this, "pl_prev");
147
connect( prevAct, SIGNAL(activated()), this, SLOT(playPrev()) );
149
moveUpAct = new MyAction(this, "pl_move_up");
150
connect( moveUpAct, SIGNAL(activated()), this, SLOT(upItem()) );
152
moveDownAct = new MyAction(this, "pl_move_down");
153
connect( moveDownAct, SIGNAL(activated()), this, SLOT(downItem()) );
155
repeatAct = new MyAction(this, "pl_repeat");
156
repeatAct->setToggleAction(true);
158
shuffleAct = new MyAction(this, "pl_shuffle");
159
shuffleAct->setToggleAction(true);
162
addCurrentAct = new MyAction(this, "pl_add_current");
163
connect( addCurrentAct, SIGNAL(activated()), this, SLOT(addCurrentFile()) );
165
addFilesAct = new MyAction(this, "pl_add_files");
166
connect( addFilesAct, SIGNAL(activated()), this, SLOT(addFiles()) );
168
addDirectoryAct = new MyAction(this, "pl_add_directory");
169
connect( addDirectoryAct, SIGNAL(activated()), this, SLOT(addDirectory()) );
172
removeSelectedAct = new MyAction(this, "pl_remove_selected");
173
connect( removeSelectedAct, SIGNAL(activated()), this, SLOT(removeSelected()) );
175
removeAllAct = new MyAction(this, "pl_remove_all");
176
connect( removeAllAct, SIGNAL(activated()), this, SLOT(removeAll()) );
179
editAct = new MyAction(this, "pl_edit");
180
connect( editAct, SIGNAL(activated()), this, SLOT(editCurrentItem()) );
183
void Playlist::createToolbar() {
184
toolbar = new QToolBar(this, "toolbar");
185
toolbar->setResizeEnabled(false);
186
toolbar->setMovingEnabled(false);
187
addDockWindow(toolbar, Qt::DockBottom );
189
openAct->addTo( toolbar );
190
saveAct->addTo( toolbar );
191
toolbar->addSeparator();
193
add_menu = new QPopupMenu( this, "add_menu" );
194
addCurrentAct->addTo( add_menu );
195
addFilesAct->addTo( add_menu );
196
addDirectoryAct->addTo( add_menu );
198
add_button = new QToolButton( toolbar, "add_button" );
199
add_button->setPopup( add_menu );
200
add_button->setPopupDelay(1);
202
remove_menu = new QPopupMenu( this, "remove_menu" );
203
removeSelectedAct->addTo( remove_menu );
204
removeAllAct->addTo( remove_menu );
206
remove_button = new QToolButton( toolbar, "remove_button" );
207
remove_button->setPopup( remove_menu );
208
remove_button->setPopupDelay(1);
210
toolbar->addSeparator();
211
playAct->addTo( toolbar );
212
toolbar->addSeparator();
213
prevAct->addTo( toolbar );
214
nextAct->addTo( toolbar );
215
toolbar->addSeparator();
216
repeatAct->addTo( toolbar );
217
shuffleAct->addTo( toolbar );
218
toolbar->addSeparator();
219
moveUpAct->addTo( toolbar );
220
moveDownAct->addTo( toolbar );
223
popup = new QPopupMenu(this, "popup");
224
playAct->addTo( popup );
225
removeSelectedAct->addTo( popup );
226
editAct->addTo( popup );
227
connect( listView, SIGNAL(contextMenuRequested(int,int,const QPoint &)),
228
this, SLOT(showPopup(int,int,const QPoint &)) );
231
void Playlist::languageChange() {
232
listView->horizontalHeader()->setLabel( COL_PLAY, " " );
233
listView->horizontalHeader()->setLabel( COL_NAME, tr("Name") );
234
listView->horizontalHeader()->setLabel( COL_TIME, tr("Length") );
236
openAct->change( Images::icon("open"), tr("&Load") );
237
saveAct->change( Images::icon("save"), tr("&Save") );
239
playAct->change( Images::icon("play"), tr("&Play") );
241
nextAct->change( Images::icon("next"), tr("&Next") );
242
prevAct->change( Images::icon("previous"), tr("Pre&vious") );
244
moveUpAct->change( Images::icon("up"), tr("Move &up") );
245
moveDownAct->change( Images::icon("down"), tr("Move &down") );
247
repeatAct->change( Images::icon("repeat"), tr("&Repeat") );
248
shuffleAct->change( Images::icon("shuffle"), tr("S&huffle") );
251
addCurrentAct->change( tr("Add ¤t file") );
252
addFilesAct->change( tr("Add &file(s)") );
253
addDirectoryAct->change( tr("Add &directory") );
256
removeSelectedAct->change( tr("Remove &selected") );
257
removeAllAct->change( tr("Remove &all") );
260
editAct->change( tr("&Edit") );
263
add_button->setIconSet( Images::icon("plus") );
264
QToolTip::add( add_button, tr("Add...") );
265
remove_button->setIconSet( Images::icon("minus") );
266
QToolTip::add( remove_button, tr("Remove...") );
269
setIcon( Images::icon("logo", 64) );
270
setCaption( tr( "SMPlayer - Playlist" ) );
273
void Playlist::list() {
274
qDebug("Playlist::list");
276
PlaylistItemList::iterator it;
277
for ( it = pl.begin(); it != pl.end(); ++it ) {
278
qDebug( "filename: '%s', name: '%s' duration: %f",
279
(*it).filename().utf8().data(), (*it).name().utf8().data(),
284
void Playlist::updateView() {
285
listView->setNumRows( pl.count() );
292
PlaylistItemList::iterator it;
294
for ( it = pl.begin(); it != pl.end(); ++it ) {
295
number.sprintf("%03d", n +1 );
297
if (name.isEmpty()) name = (*it).filename();
298
time = Helper::formatTime( (int) (*it).duration() );
300
//listView->setText(n, COL_POS, number);
301
listView->setText(n, COL_NAME, name);
302
listView->setText(n, COL_TIME, time);
304
if ((*it).played()) {
305
listView->setPixmap(n, COL_PLAY, Images::icon("ok_small") );
307
listView->setPixmap(n, COL_PLAY, QPixmap() );
313
for (n=0; n <= COL_TIME; n++)
314
listView->adjustColumn(n);
316
setCurrentItem(current_item);
321
void Playlist::setCurrentItem(int current) {
322
int old_current = current_item;
323
current_item = current;
325
if ( (old_current >= 0) && (old_current < listView->numRows()) ) {
326
listView->setPixmap(old_current, COL_PLAY, QPixmap() );
329
if ( (current_item >= 0) && (current_item < listView->numRows()) ) {
330
listView->setPixmap(current_item, COL_PLAY, Images::icon("play") );
332
//if (current_item >= 0) listView->selectRow(current_item);
333
if (current_item >= 0) {
334
listView->clearSelection();
335
listView->setCurrentCell( current_item, 0);
336
listView->selectRow(current_item);
340
void Playlist::clear() {
342
listView->setNumRows(0);
345
setModified( false );
348
int Playlist::count() {
352
bool Playlist::isEmpty() {
356
void Playlist::addItem(QString filename, QString name, double duration) {
357
qDebug("Playlist::addItem: '%s'", filename.utf8().data());
360
filename = Helper::changeSlashes(filename);
363
// Test if already is in the list
365
PlaylistItemList::iterator it;
366
for ( it = pl.begin(); it != pl.end(); ++it ) {
367
if ( (*it).filename() == filename ) {
374
if (name.isEmpty()) {
375
QFileInfo fi(filename);
378
name = fi.fileName(); //fi.baseName(TRUE);
384
pl.append( PlaylistItem(filename, name, duration) );
387
qDebug(" Not added. File already in the list");
391
void Playlist::load_m3u(QString file) {
392
qDebug("Playlist::load_m3u");
394
bool utf8 = (QFileInfo(file).extension(FALSE).lower() == "m3u8");
396
QRegExp m3u_id("^#EXTM3U|^#M3U");
397
QRegExp info("^#EXTINF:(.*),(.*)");
400
if ( f.open( IO_ReadOnly ) ) {
401
playlist_path = QFileInfo(file).dirPath();
408
QTextStream stream( &f );
411
stream.setEncoding(QTextStream::UnicodeUTF8);
413
stream.setEncoding(QTextStream::Locale);
416
while ( !stream.atEnd() ) {
417
line = stream.readLine(); // line of text excluding '\n'
418
qDebug( " * line: '%s'", line.utf8().data() );
419
if (m3u_id.search(line)!=-1) {
424
if (info.search(line)!=-1) {
425
duration = info.cap(1).toDouble();
427
qDebug(" * name: '%s', duration: %f", name.utf8().data(), duration );
430
if (line.startsWith("#")) {
435
QFileInfo fi(filename);
437
filename = fi.absFilePath();
440
if (QFileInfo( playlist_path + "/" + filename).exists() ) {
441
filename = playlist_path + "/" + filename;
444
addItem( filename, name, duration );
453
setModified( false );
459
bool Playlist::save_m3u(QString file) {
460
qDebug("Playlist::save_m3u: '%s'", file.utf8().data());
462
QString dir_path = QFileInfo(file).dirPath();
463
if (!dir_path.endsWith("/")) dir_path += "/";
466
dir_path = Helper::changeSlashes(dir_path);
469
qDebug(" * dirPath: '%s'", dir_path.utf8().data());
471
bool utf8 = (QFileInfo(file).extension(FALSE).lower() == "m3u8");
474
if ( f.open( IO_WriteOnly ) ) {
475
QTextStream stream( &f );
478
stream.setEncoding(QTextStream::UnicodeUTF8);
480
stream.setEncoding(QTextStream::Locale);
484
stream << "#EXTM3U" << "\n";
485
stream << "# Playlist created by SMPlayer " << VERSION << " \n";
487
PlaylistItemList::iterator it;
488
for ( it = pl.begin(); it != pl.end(); ++it ) {
489
filename = (*it).filename();
491
filename = Helper::changeSlashes(filename);
493
stream << "#EXTINF:";
494
stream << (*it).duration() << ",";
495
stream << (*it).name() << "\n";
496
// Try to save the filename as relative instead of absolute
497
if (filename.startsWith( dir_path )) {
498
filename = filename.mid( dir_path.length() );
500
stream << filename << "\n";
504
setModified( false );
511
void Playlist::load() {
513
QString s = MyFileDialog::getOpenFileName(
515
tr("Playlists") +" (*.m3u *.m3u8)",
518
tr("Choose a file") );
521
latest_dir = QFileInfo(s).dirPath(TRUE);
527
bool Playlist::save() {
528
QString s = MyFileDialog::getSaveFileName(
530
tr("Playlists") +" (*.m3u *.m3u8)",
533
tr("Choose a filename") );
536
// If filename has no extension, add it
537
if (QFileInfo(s).extension().isEmpty()) {
540
if (QFileInfo(s).exists()) {
541
int res = QMessageBox::question( this,
542
tr("Confirm overwrite?"),
543
tr("The file %1 already exists.\n"
544
"Do you want to overwrite?").arg(s),
547
QMessageBox::NoButton);
548
if (res == QMessageBox::No ) {
552
latest_dir = QFileInfo(s).dirPath(TRUE);
559
bool Playlist::maybeSave() {
560
if (!isModified()) return true;
562
int res = QMessageBox::question( this,
563
tr("Playlist modified"),
564
tr("There are unsaved changes, do you want to save the playlist?"),
567
QMessageBox::Cancel);
570
case QMessageBox::No : return true; // Discard changes
571
case QMessageBox::Cancel : return false; // Cancel operation
572
default : return save();
576
void Playlist::playCurrent() {
577
int current = listView->currentRow();
583
void Playlist::itemDoubleClicked(int row) {
584
qDebug("Playlist::itemDoubleClicked: row: %d", row );
588
void Playlist::showPopup(int row, int col, const QPoint & pos) {
589
qDebug("Playlist::showPopup: row: %d col: %d", row, col );
590
if (!popup->isVisible()) {
596
void Playlist::startPlay() {
598
if ( shuffleAct->isOn() )
599
playItem( chooseRandomItem() );
604
void Playlist::playItem( int n ) {
605
qDebug("Playlist::playItem: %d (count:%d)", n, pl.count());
607
if ( (n >= pl.count()) || (n < 0) ) {
608
qDebug(" out of range");
609
emit playlistEnded();
613
qDebug(" playlist_path: '%s'", playlist_path.utf8().data() );
615
QString filename = pl[n].filename();
616
QString filename_with_path = playlist_path + "/" + filename;
618
if (!filename.isEmpty()) {
619
pl[n].setPlayed(TRUE);
621
core->open(filename, 0);
626
void Playlist::playNext() {
627
qDebug("Playlist::playNext");
629
if (shuffleAct->isOn()) {
631
int chosen_item = chooseRandomItem();
632
if (chosen_item == -1) {
634
if (repeatAct->isOn()) chosen_item = chooseRandomItem();
636
playItem( chosen_item );
638
bool finished_list = (current_item+1 >= pl.count());
639
if (finished_list) clearPlayedTag();
641
if ( (repeatAct->isOn()) && (finished_list) ) {
644
playItem( current_item+1 );
649
void Playlist::playPrev() {
650
qDebug("Playlist::playPrev");
651
playItem( current_item-1 );
654
void Playlist::getMediaInfo() {
655
qDebug("Playlist:: getMediaInfo");
657
QString filename = core->mdat.filename;
658
double duration = core->mdat.duration;
659
QString name = core->mdat.clip_name;
660
QString artist = core->mdat.clip_artist;
663
filename = Helper::changeSlashes(filename);
666
if (name.isEmpty()) {
667
QFileInfo fi(filename);
670
name = fi.fileName();
676
if (!artist.isEmpty()) name = artist + " - " + name;
679
PlaylistItemList::iterator it;
680
for ( it = pl.begin(); it != pl.end(); ++it ) {
681
if ( (*it).filename() == filename ) {
682
if ((*it).duration()<1) {
683
if (!name.isEmpty()) {
686
(*it).setDuration(duration);
687
//setModified( true );
690
// Edited name (sets duration to 1)
691
if ((*it).duration()==1) {
692
(*it).setDuration(duration);
693
//setModified( true );
702
// Add current file to playlist
703
void Playlist::addCurrentFile() {
704
qDebug("Playlist::addCurrentFile");
705
if (!core->mdat.filename.isEmpty()) {
706
addItem( core->mdat.filename, "", 0 );
711
void Playlist::addFiles() {
712
QStringList files = MyFileDialog::getOpenFileNames(
713
tr("All files") +" (*.*)",
717
tr("Select one or more files to open") );
719
if (files.count()!=0) addFiles(files);
722
void Playlist::addFiles(QStringList files) {
723
qDebug("Playlist::addFiles");
725
QStringList::Iterator it = files.begin();
726
while( it != files.end() ) {
727
addItem( (*it), "", 0 );
728
latest_dir = QFileInfo((*it)).dirPath(TRUE);
733
qDebug( " * latest_dir: '%s'", latest_dir.utf8().data() );
736
void Playlist::addDirectory() {
737
QString s = MyFileDialog::getExistingDirectory(
740
"get existing directory",
741
tr("Choose a directory"),
750
void Playlist::addDirectory(QString dir) {
751
QStringList dir_list = QDir(dir).entryList();
754
QStringList::Iterator it = dir_list.begin();
755
while( it != dir_list.end() ) {
757
if (filename.right(1)!="/") filename += "/";
759
if (!QFileInfo(filename).isDir()) {
760
addItem( filename, "", 0 );
767
// Remove selected items
768
void Playlist::removeSelected() {
769
qDebug("Playlist::removeSelected");
771
for (int n=0; n < listView->numRows(); n++) {
772
if (listView->isRowSelected(n)) {
773
qDebug(" row %d selected", n);
774
pl[n].setMarkForDeletion(TRUE);
778
PlaylistItemList::iterator it;
779
for ( it = pl.begin(); it != pl.end(); ++it ) {
780
if ( (*it).markedForDeletion() ) {
781
qDebug("Remove '%s'", (*it).filename().utf8().data());
788
if (isEmpty()) setModified(false);
792
void Playlist::removeAll() {
796
setModified( false );
801
void Playlist::clearPlayedTag() {
802
PlaylistItemList::iterator it;
803
for ( it = pl.begin(); it != pl.end(); ++it ) {
804
(*it).setPlayed(FALSE);
809
int Playlist::chooseRandomItem() {
810
qDebug( "Playlist::chooseRandomItem");
811
QValueList <int> fi; //List of not played items (free items)
814
PlaylistItemList::iterator it;
815
for ( it = pl.begin(); it != pl.end(); ++it ) {
816
if (! (*it).played() ) fi.append(n);
820
qDebug(" * free items: %d", fi.count() );
822
if (fi.count()==0) return -1; // none free
824
qDebug(" * items: ");
825
for (int i=0; i < fi.count(); i++) {
826
qDebug(" * item: %d", fi[i]);
829
int selected = (int) ((double) fi.count() * rand()/(RAND_MAX+1.0));
830
qDebug(" * selected item: %d (%d)", selected, fi[selected]);
834
void Playlist::swapItems(int item1, int item2 ) {
835
PlaylistItem it1 = pl[item1];
836
pl[item1] = pl[item2];
842
void Playlist::upItem() {
843
qDebug("Playlist::upItem");
845
int current = listView->currentRow();
846
qDebug(" currentRow: %d", current );
849
swapItems( current, current-1 );
850
if (current_item == (current-1)) current_item = current;
852
if (current_item == current) current_item = current-1;
854
listView->clearSelection();
855
listView->setCurrentCell( current-1, 0);
859
void Playlist::downItem() {
860
qDebug("Playlist::downItem");
862
int current = listView->currentRow();
863
qDebug(" currentRow: %d", current );
865
if ( (current > -1) && (current < (pl.count()-1)) ) {
866
swapItems( current, current+1 );
867
if (current_item == (current+1)) current_item = current;
869
if (current_item == current) current_item = current+1;
871
listView->clearSelection();
872
listView->setCurrentCell( current+1, 0);
876
void Playlist::editCurrentItem() {
877
int current = listView->currentRow();
878
if (current > -1) editItem(current);
881
void Playlist::editItem(int item) {
882
QString current_name = pl[item].name();
883
if (current_name.isEmpty()) current_name = pl[item].filename();
886
QString text = QInputDialog::getText(
888
tr("Type the name that will be displayed in the playlist for this file:"),
890
current_name, &ok, this );
891
if ( ok && !text.isEmpty() ) {
892
// user entered something and pressed OK
893
pl[item].setName(text);
895
// If duration == 0 the name will be overwritten!
896
if (pl[item].duration()<1) pl[item].setDuration(1);
904
void Playlist::dragEnterEvent( QDragEnterEvent *e ) {
905
qDebug("Playlist::dragEnterEvent");
906
#if QT_VERSION < 0x040000
907
e->accept( (QUriDrag::canDecode(e) || QTextDrag::canDecode(e)) );
909
e->accept(QUriDrag::canDecode(e));
914
void Playlist::dropEvent( QDropEvent *e ) {
915
qDebug("Playlist::dropEvent");
919
if (QUriDrag::canDecode(e)) {
921
QUriDrag::decode(e, l);
924
for ( unsigned int i= 0; i < l.count(); ++i ) {
926
qDebug(" * '%s'", s.utf8().data() );
932
qDebug(" * protocol: '%s'", u.protocol().utf8().data());
933
qDebug(" * path: '%s'", u.path().utf8().data());
934
//qDebug(" filename:='%s'", u.fileName().utf8().data());
935
if (u.protocol()=="file") {
943
#if QT_VERSION < 0x040000
945
if (QTextDrag::canDecode(e)) {
947
if (QTextDrag::decode(e, s)) {
948
qDebug(" * '%s'", s.utf8().data() );
954
QStringList only_files;
955
for (int n = 0; n < files.count(); n++) {
956
if ( QFileInfo( files[n] ).isDir() ) {
957
addDirectory( files[n] );
959
//addFiles( files[n] );
960
//addItem( files[n], "", 0 );
961
only_files.append( files[n] );
966
addFiles( only_files );
970
void Playlist::hideEvent( QHideEvent * ) {
971
emit visibilityChanged();
974
void Playlist::showEvent( QShowEvent * ) {
975
emit visibilityChanged();
978
void Playlist::closeEvent( QCloseEvent * e ) {
984
void Playlist::maybeSaveSettings() {
985
qDebug("Playlist::maybeSaveSettings");
986
if (isModified()) saveSettings();
989
void Playlist::saveSettings() {
990
qDebug("Playlist::saveSettings");
992
QSettings * set = settings;
994
set->beginGroup( "playlist");
996
set->writeEntry( "repeat", repeatAct->isOn() );
997
set->writeEntry( "shuffle", shuffleAct->isOn() );
999
set->writeEntry( "window_width", size().width() );
1000
set->writeEntry( "window_height", size().height() );
1002
set->writeEntry( "latest_dir", latest_dir );
1007
set->beginGroup( "playlist_contents");
1009
set->writeEntry( "count", (int) pl.count() );
1010
for ( int n=0; n < pl.count(); n++ ) {
1011
set->writeEntry( QString("item_%1_filename").arg(n), pl[n].filename() );
1012
set->writeEntry( QString("item_%1_duration").arg(n), pl[n].duration() );
1013
set->writeEntry( QString("item_%1_name").arg(n), pl[n].name() );
1015
set->writeEntry( "current_item", current_item );
1016
set->writeEntry( "modified", modified );
1021
void Playlist::loadSettings() {
1022
qDebug("Playlist::loadSettings");
1024
QSettings * set = settings;
1026
set->beginGroup( "playlist");
1028
repeatAct->setOn( set->readBoolEntry( "repeat", repeatAct->isOn() ) );
1029
shuffleAct->setOn( set->readBoolEntry( "shuffle", shuffleAct->isOn() ) );
1033
s.setWidth( set->readNumEntry( "window_width", size().width() ) );
1034
s.setHeight( set->readNumEntry( "window_height", size().height() ) );
1038
latest_dir = set->readEntry( "latest_dir", latest_dir );
1043
set->beginGroup( "playlist_contents");
1045
int count = set->readNumEntry( "count", 0 );
1046
QString filename, name;
1048
for ( int n=0; n < count; n++ ) {
1049
filename = set->readEntry( QString("item_%1_filename").arg(n), "" );
1050
duration = set->readNumEntry( QString("item_%1_duration").arg(n), -1 );
1051
name = set->readEntry( QString("item_%1_name").arg(n), "" );
1052
addItem( filename, name, duration );
1054
setCurrentItem( set->readNumEntry( "current_item", -1 ) );
1055
setModified( set->readBoolEntry( "modified", false ) );
1061
QString Playlist::lastDir() {
1062
QString last_dir = latest_dir;
1063
if (last_dir.isEmpty()) last_dir = pref->latest_dir;