2014-11-01 19:26:05 +01:00
|
|
|
/* This file is part of Clementine.
|
2014-11-01 19:30:40 +01:00
|
|
|
Copyright 2010-2011, 2013, David Sansome <me@davidsansome.com>
|
|
|
|
Copyright 2010, 2012, 2014, John Maguire <john.maguire@gmail.com>
|
|
|
|
Copyright 2014, Krzysztof Sobiecki <sobkas@gmail.com>
|
2014-11-01 19:26:05 +01:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CORE_BACKGROUNDSTREAMS_H_
|
|
|
|
#define CORE_BACKGROUNDSTREAMS_H_
|
2010-12-03 14:53:43 +01:00
|
|
|
|
|
|
|
#include <QMap>
|
|
|
|
#include <QObject>
|
2010-12-04 16:11:50 +01:00
|
|
|
#include <QStringList>
|
2010-12-03 14:53:43 +01:00
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
#include "engines/engine_fwd.h"
|
|
|
|
|
2011-06-19 16:42:00 +02:00
|
|
|
class QAction;
|
|
|
|
|
2010-12-03 14:53:43 +01:00
|
|
|
class BackgroundStreams : public QObject {
|
|
|
|
Q_OBJECT
|
2014-11-01 19:26:05 +01:00
|
|
|
|
2010-12-03 14:53:43 +01:00
|
|
|
public:
|
2014-11-02 19:32:48 +01:00
|
|
|
explicit BackgroundStreams(EngineBase* engine, QObject* parent = nullptr);
|
2010-12-03 14:53:43 +01:00
|
|
|
~BackgroundStreams();
|
|
|
|
|
|
|
|
void LoadStreams();
|
|
|
|
void SaveStreams();
|
|
|
|
|
2010-12-04 16:11:50 +01:00
|
|
|
QStringList streams() const { return streams_.keys(); }
|
2010-12-03 14:53:43 +01:00
|
|
|
|
|
|
|
void EnableStream(const QString& name, bool enable);
|
|
|
|
void SetStreamVolume(const QString& name, int volume);
|
|
|
|
|
2011-06-19 16:42:00 +02:00
|
|
|
int GetStreamVolume(const QString& name) const;
|
|
|
|
bool IsPlaying(const QString& name) const;
|
2010-12-03 14:53:43 +01:00
|
|
|
|
2011-06-19 16:42:00 +02:00
|
|
|
void AddAction(const QString& name, QAction* action);
|
2010-12-03 14:53:43 +01:00
|
|
|
|
2014-11-01 19:26:05 +01:00
|
|
|
signals:
|
2010-12-03 14:53:43 +01:00
|
|
|
void StreamStarted(const QString& name);
|
|
|
|
void StreamStopped(const QString& name);
|
|
|
|
|
2011-06-19 16:42:00 +02:00
|
|
|
private slots:
|
|
|
|
void StreamActionToggled(bool checked);
|
|
|
|
void StreamActionDestroyed();
|
|
|
|
|
2010-12-03 14:53:43 +01:00
|
|
|
private:
|
|
|
|
struct Stream {
|
2014-02-21 17:24:49 +01:00
|
|
|
Stream() : volume(0), id(0), action(nullptr) {}
|
2011-06-19 16:42:00 +02:00
|
|
|
|
2010-12-03 14:53:43 +01:00
|
|
|
QString name;
|
|
|
|
QUrl url;
|
|
|
|
int volume;
|
|
|
|
int id;
|
2011-06-19 16:42:00 +02:00
|
|
|
|
|
|
|
QAction* action;
|
2010-12-03 14:53:43 +01:00
|
|
|
};
|
|
|
|
|
2013-05-04 11:25:43 +02:00
|
|
|
void AddStream(const QString& name, const QUrl& url, int volume = 50);
|
2010-12-03 14:53:43 +01:00
|
|
|
void PlayStream(Stream* stream);
|
|
|
|
void StopStream(Stream* stream);
|
|
|
|
|
|
|
|
EngineBase* engine_;
|
|
|
|
|
|
|
|
QMap<QString, Stream*> streams_;
|
|
|
|
|
|
|
|
static const char* kSettingsGroup;
|
2012-01-10 17:00:17 +01:00
|
|
|
static const int kVersion = 2;
|
2010-12-03 14:53:43 +01:00
|
|
|
|
|
|
|
static const char* kHypnotoadUrl;
|
|
|
|
static const char* kRainUrl;
|
2012-01-10 17:00:17 +01:00
|
|
|
static const char* kEnterpriseUrl;
|
2010-12-03 14:53:43 +01:00
|
|
|
};
|
|
|
|
|
2014-11-01 19:26:05 +01:00
|
|
|
#endif // CORE_BACKGROUNDSTREAMS_H_
|