aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2012-01-23 18:23:04 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2012-01-23 18:23:04 +0000
commit06552c3c142f2c1bebb7d8f54a743bc08963cc25 (patch)
tree086563daab7d54295ccc3aad4de5247a88058ffc /src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
parent2fc1c7f11729245d69539fe8ec34b35a0221dc5a (diff)
downloadqmmp-06552c3c142f2c1bebb7d8f54a743bc08963cc25.tar.gz
qmmp-06552c3c142f2c1bebb7d8f54a743bc08963cc25.tar.bz2
qmmp-06552c3c142f2c1bebb7d8f54a743bc08963cc25.zip
new command line option: --pl-play
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2560 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp')
-rw-r--r--src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
index 802fbc0a2..3424db8a9 100644
--- a/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
+++ b/src/plugins/CommandLineOptions/PlayListOption/playlistoption.cpp
@@ -32,6 +32,7 @@ bool PlayListOption::identify(const QString & str) const
return str == QString("--pl-help") ||
str == QString("--pl-list") ||
str == QString("--pl-dump") ||
+ str == QString("--pl-play") ||
str == QString("--pl-clear") ||
str == QString("--pl-repeat-toggle") ||
str == QString("--pl-shuffle-toggle") ||
@@ -41,7 +42,7 @@ bool PlayListOption::identify(const QString & str) const
const QString PlayListOption::helpString() const
{
return QString(
- "--pl-help " + tr("Show playlist manipulation commands")+"\n"
+ "--pl-help " + tr("Show playlist manipulation commands")+"\n"
);
}
@@ -54,12 +55,13 @@ QString PlayListOption::executeCommand(const QString& opt_str, const QStringList
if(opt_str == "--pl-help")
{
- out = "--pl-list " + tr("List all available playlists")+"\n"+
- "--pl-dump <id> " + tr("Show playlist content")+"\n" +
- "--pl-clear <id> " + tr("Clear playlist")+"\n"+
- "--pl-repeat-toggle " + tr("Toggle playlist repeat")+"\n"+
- "--pl-shuffle-toggle " + tr("Toggle playlist shuffle")+"\n"+
- "--pl-state " + tr("Show playlist options")+"\n";
+ out = "--pl-list " + tr("List all available playlists")+"\n"+
+ "--pl-dump <id> " + tr("Show playlist content")+"\n" +
+ "--pl-play <id> <track> " + tr("Play track <track> in playlist <id>")+"\n" +
+ "--pl-clear <id> " + tr("Clear playlist")+"\n"+
+ "--pl-repeat-toggle " + tr("Toggle playlist repeat")+"\n"+
+ "--pl-shuffle-toggle " + tr("Toggle playlist shuffle")+"\n"+
+ "--pl-state " + tr("Show playlist options")+"\n";
}
else if(opt_str == "--pl-list")
{
@@ -87,6 +89,25 @@ QString PlayListOption::executeCommand(const QString& opt_str, const QStringList
out += "\n";
}
}
+ else if(opt_str == "--pl-play")
+ {
+ if(args.count() > 2 || args.isEmpty())
+ return tr("Invalid number of arguments") + "\n";
+
+ int pl_id = (args.count() == 1) ? pl_manager->currentPlayListIndex() : args.at(0).toInt() - 1;
+ int track_id = (args.count() == 1) ? args.at(0).toInt() - 1 : args.at(1).toInt() - 1;
+ PlayListModel *model = pl_manager->playListAt(pl_id);
+ if(!model)
+ return tr("Invalid playlist ID") + "\n";
+ PlayListItem *item = model->item(track_id);
+ if(!item)
+ return tr("Invalid track ID") + "\n";
+ player->stop();
+ pl_manager->activatePlayList(model);
+ pl_manager->selectPlayList(model);
+ model->setCurrent(item);
+ player->play();
+ }
else if(opt_str == "--pl-clear")
{
int id = args.isEmpty() ? pl_manager->currentPlayListIndex() : args.at(0).toInt() - 1;