Added "Append to playlist" option in OpenURL dialog.

This commit is contained in:
Daniel Önnerby 2009-01-12 23:09:04 +00:00
parent 294cf5279e
commit a6ba49b423
3 changed files with 23 additions and 7 deletions

View File

@ -38,6 +38,7 @@
#include <core/PlaybackQueue.h>
#include <core/TrackFactory.h>
#include <core/tracklist/MultiLibraryList.h>
#include <cube/dialog/OpenURLController.hpp>
@ -45,6 +46,7 @@
#include <win32cpp/Button.hpp>
#include <win32cpp/EditView.hpp>
#include <win32cpp/RedrawLock.hpp>
#include <win32cpp/CheckBox.hpp>
//////////////////////////////////////////////////////////////////////////////
using namespace musik::cube::dialog;
@ -79,7 +81,20 @@ void OpenURLController::OnCancel(win32cpp::Button* button){
}
void OpenURLController::OnOK(win32cpp::Button* button){
(*musik::core::PlaybackQueue::Instance().NowPlayingTracklist()) += musik::core::TrackFactory::CreateTrack( this->view->url->Caption().c_str() );
musik::core::TrackPtr track = musik::core::TrackFactory::CreateTrack( this->view->url->Caption().c_str() );
if(track){
if(this->view->append->IsChecked()){
// Append
(*musik::core::PlaybackQueue::Instance().NowPlayingTracklist()) += track;
}else{
// Create a playlist to play
musik::core::tracklist::MultiLibraryList playlist;
playlist += track;
playlist.SetPosition(0);
musik::core::PlaybackQueue::Instance().Play(playlist);
}
}
this->mainWindow.Close();
}

View File

@ -41,6 +41,7 @@
#include <win32cpp/Button.hpp>
#include <win32cpp/LinearLayout.hpp>
#include <win32cpp/EditView.hpp>
#include <win32cpp/CheckBox.hpp>
//////////////////////////////////////////////////////////////////////////////
@ -62,18 +63,16 @@ void OpenURLView::OnCreated()
// Top Row layout
LinearLayout* rowLayout = new LinearLayout(VerticalLayout,win32cpp::LayoutFillFill);
LinearLayout* firstRow = new LinearLayout(HorizontalLayout,win32cpp::LayoutFillFill);
Label *label = firstRow->AddChild(new Label(_T("URL:") ));
Label *label = rowLayout->AddChild(new Label(_T("URL:") ));
label->SetFont(boldFont);
this->url = firstRow->AddChild(new EditView(_T("url"),win32cpp::LayoutFillFill ));
rowLayout->AddChild(firstRow);
this->url = rowLayout->AddChild(new EditView(_T(""),win32cpp::LayoutFillFill ));
this->append = rowLayout->AddChild(new CheckBox(_T("Append to playlist"),win32cpp::LayoutFillFill ));
// Last rows column layout
LinearLayout* bottomButtonLayout = new LinearLayout(HorizontalLayout);
this->cancelButton = bottomButtonLayout->AddChild(new Button(_T("Cancel")));
this->okButton = bottomButtonLayout->AddChild(new Button(_T("OK")));
// this->cancelButton->Resize(60,20);
// this->okButton->Resize(60,20);
rowLayout->AddChild(bottomButtonLayout);
bottomButtonLayout->SetLayoutAlignment(LayoutAlignRight);

View File

@ -40,6 +40,7 @@
namespace win32cpp{
class Button;
class EditView;
class CheckBox;
}
//////////////////////////////////////////////////////////////////////////////
@ -61,6 +62,7 @@ class OpenURLView: public win32cpp::Frame{
win32cpp::Button *okButton, *cancelButton;
win32cpp::EditView *url;
win32cpp::CheckBox *append;
};
//////////////////////////////////////////////////////////////////////////////