From a6ba49b4230279c8f3c92c1db290a2cbc1a3ee49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96nnerby?= Date: Mon, 12 Jan 2009 23:09:04 +0000 Subject: [PATCH] Added "Append to playlist" option in OpenURL dialog. --- src/cube/dialog/OpenURLController.cpp | 17 ++++++++++++++++- src/cube/dialog/OpenURLView.cpp | 11 +++++------ src/cube/dialog/OpenURLView.hpp | 2 ++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/cube/dialog/OpenURLController.cpp b/src/cube/dialog/OpenURLController.cpp index 494dfb3f1..aa8dd738d 100644 --- a/src/cube/dialog/OpenURLController.cpp +++ b/src/cube/dialog/OpenURLController.cpp @@ -38,6 +38,7 @@ #include #include +#include #include @@ -45,6 +46,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// 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(); } diff --git a/src/cube/dialog/OpenURLView.cpp b/src/cube/dialog/OpenURLView.cpp index 8aa7a416f..a2fa13717 100644 --- a/src/cube/dialog/OpenURLView.cpp +++ b/src/cube/dialog/OpenURLView.cpp @@ -41,6 +41,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// @@ -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); diff --git a/src/cube/dialog/OpenURLView.hpp b/src/cube/dialog/OpenURLView.hpp index aaf0b22f0..c4e0085d4 100644 --- a/src/cube/dialog/OpenURLView.hpp +++ b/src/cube/dialog/OpenURLView.hpp @@ -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; }; //////////////////////////////////////////////////////////////////////////////