If playqueue is cleared when dynamizer is running, then also stop dynamizer.

This commit is contained in:
craig.p.drummond
2013-09-02 18:27:30 +00:00
committed by craig.p.drummond
parent b1b0b8a294
commit b800ead19a
7 changed files with 36 additions and 5 deletions

View File

@@ -23,6 +23,8 @@
used.
10. Add ability to 'filter search' stream categories.
11. Add option to prevent system from suspending whilst playing (Linux only).
12. If playqueue is cleared when dynamizer is running, then also stop
dynamizer.
1.1.2
-----

2
README
View File

@@ -490,6 +490,8 @@ ControlDynamizer:
Mode: HTTP POST
URL: http://host:port/control
Params: state={start/stop} [Required]
clear={1/0} If set to '1', and statr=stop, then the MPD
playqueue is also cleared.
In order to detect whether the set of stored rules has changed, a client should

View File

@@ -1029,8 +1029,12 @@ sub control() {
&sendServerMessage();
return "OK";
} elsif ($command eq "stop") {
my $doClear=shift;
$dynamicIsActive=0;
$currentStatus="IDLE";
if ($doClear eq "true" || $doClear eq "1") {
&sendCommand("clear");
}
&sendServerMessage();
return "OK";
}
@@ -1191,7 +1195,7 @@ sub httpServer() {
} elsif ($request{URL} eq '/save') {
$response=&saveRulesToFile($queryItems{name}, $request{CONTENT});
} elsif ($request{URL} eq '/control') {
$response=&control($queryItems{state});
$response=&control($queryItems{state}, $queryItems{clear});
}
} elsif ($request{METHOD} eq 'DELETE') {
$response=&deleteRules($request{URL});

View File

@@ -431,10 +431,14 @@ void Dynamic::start(const QString &name)
}
}
void Dynamic::stop()
void Dynamic::stop(bool sendClear)
{
if (isRemote()) {
sendCommand(Control, QStringList() << "state" << "stop");
if (sendClear) {
sendCommand(Control, QStringList() << "state" << "stop" << "clear" << "1");
} else {
sendCommand(Control, QStringList() << "state" << "stop");
}
return;
}
@@ -444,6 +448,9 @@ void Dynamic::stop()
int pid=getPid();
if (!pid) {
if (sendClear) {
emit clear();
}
currentEntry=QString();
emit running(false);
if (idx.isValid()) {
@@ -453,6 +460,9 @@ void Dynamic::stop()
}
if (0!=::kill(pid, 0)) {
if (sendClear) {
emit clear();
}
currentEntry=QString();
emit running(false);
if (idx.isValid()) {
@@ -462,6 +472,9 @@ void Dynamic::stop()
}
if (controlApp(false)) {
if (sendClear) {
emit clear();
}
currentEntry=QString();
emit running(isRunning());
if (idx.isValid()) {

View File

@@ -112,7 +112,7 @@ public:
bool save(const Entry &e);
void del(const QString &name);
void start(const QString &name);
void stop();
void stop(bool sendClear=false);
void toggle(const QString &name);
bool isRunning();
QString current() const { return currentEntry; }

View File

@@ -752,7 +752,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(StdActions::self()->replacePlayQueueAction, SIGNAL(triggered(bool)), this, SLOT(replacePlayQueue()));
connect(removeFromPlayQueueAction, SIGNAL(triggered(bool)), this, SLOT(removeFromPlayQueue()));
connect(clearPlayQueueAction, SIGNAL(triggered(bool)), playQueueSearchWidget, SLOT(clear()));
connect(clearPlayQueueAction, SIGNAL(triggered(bool)), MPDConnection::self(), SLOT(clear()));
connect(clearPlayQueueAction, SIGNAL(triggered(bool)), this, SLOT(clearPlayQueue()));
connect(copyTrackInfoAction, SIGNAL(triggered(bool)), this, SLOT(copyTrackInfo()));
connect(cropPlayQueueAction, SIGNAL(triggered(bool)), this, SLOT(cropPlayQueue()));
connect(shufflePlayQueueAction, SIGNAL(triggered(bool)), MPDConnection::self(), SLOT(shuffle()));
@@ -2066,6 +2066,15 @@ void MainWindow::playQueueItemActivated(const QModelIndex &index)
emit startPlayingSongId(playQueueModel.getIdByRow(playQueueProxyModel.mapToSource(index).row()));
}
void MainWindow::clearPlayQueue()
{
if (dynamicLabel->isVisible()) {
Dynamic::self()->stop(true);
} else {
emit clear();
}
}
void MainWindow::removeFromPlayQueue()
{
const QModelIndexList items = playQueue->selectedIndexes();

View File

@@ -237,6 +237,7 @@ public Q_SLOTS:
void updateStats();
void updateStatus();
void playQueueItemActivated(const QModelIndex &);
void clearPlayQueue();
void removeFromPlayQueue();
void replacePlayQueue();
void addToPlayQueue();