From c31f9b59dba873739494fcd9916c7cb9120ce1d9 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 02 Dec 2002 17:42:44 +0000 Subject: - don't enable the play button if switching to the playlist tab and the playlist is empty - don't crash when starting to play and no item is selected in the playlist. instead select the first item then. --- diff --git a/noncore/multimedia/opieplayer2/playlistselection.h b/noncore/multimedia/opieplayer2/playlistselection.h index d10bc82..9cc4e30 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.h +++ b/noncore/multimedia/opieplayer2/playlistselection.h @@ -45,6 +45,8 @@ public slots: bool first(); bool last(); + bool isEmpty() const { return childCount() == 0; } + protected: virtual void contentsMouseMoveEvent(QMouseEvent *); /* #ifdef USE_PLAYLIST_BACKGROUND */ diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index f53def6..b08204e 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -418,7 +418,13 @@ void PlayListWidget::useSelectedDocument() { const DocLnk *PlayListWidget::current() const { // this is fugly assert( currentTab() == CurrentPlayList ); - return d->selectedFiles->current(); + const DocLnk *lnk = d->selectedFiles->current(); + if ( !lnk ) { + d->selectedFiles->first(); + lnk = d->selectedFiles->current(); + } + assert( lnk ); + return lnk; } @@ -564,6 +570,8 @@ void PlayListWidget::tabChanged(QWidget *) { } d->tbRemoveFromList->setEnabled(TRUE); d->tbAddToList->setEnabled(FALSE); + + d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); } break; case AudioFiles: -- cgit v0.9.0.2