aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/General/hal/halplugin.cpp9
-rw-r--r--src/plugins/General/mpris/tracklistobject.cpp42
-rw-r--r--src/plugins/General/mpris/tracklistobject.h3
-rw-r--r--src/plugins/General/udisks/udisksplugin.cpp11
4 files changed, 42 insertions, 23 deletions
diff --git a/src/plugins/General/hal/halplugin.cpp b/src/plugins/General/hal/halplugin.cpp
index 90106b8b0..205fd49b7 100644
--- a/src/plugins/General/hal/halplugin.cpp
+++ b/src/plugins/General/hal/halplugin.cpp
@@ -190,10 +190,7 @@ void HalPlugin::processAction(QAction *action)
{
qDebug("HalPlugin: action triggered: %s", qPrintable(action->data().toString()));
QString path = action->data().toString();
- if (path.startsWith("cdda://"))
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addFile(path);
- else
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addDirectory(path);
+ MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path);
}
QAction *HalPlugin::findAction(const QString &dev_path)
@@ -238,11 +235,11 @@ void HalPlugin::addPath(const QString &path)
if (path.startsWith("cdda://") && m_addTracks)
{
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addFile(path);
+ MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path);
return;
}
else if (!path.startsWith("cdda://") && m_addFiles)
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addDirectory(path);
+ MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path);
}
void HalPlugin::removePath(const QString &path)
diff --git a/src/plugins/General/mpris/tracklistobject.cpp b/src/plugins/General/mpris/tracklistobject.cpp
index 56562e8cc..a55f2c770 100644
--- a/src/plugins/General/mpris/tracklistobject.cpp
+++ b/src/plugins/General/mpris/tracklistobject.cpp
@@ -35,6 +35,7 @@ TrackListObject::TrackListObject(QObject *parent) : QObject(parent)
connect (m_model, SIGNAL(listChanged()), SLOT(updateTrackList()));
connect (m_pl_manager, SIGNAL(currentPlayListChanged(PlayListModel*,PlayListModel*)),
SLOT(switchPlayList(PlayListModel*,PlayListModel*)));
+ m_prev_count = 0;
}
@@ -44,21 +45,25 @@ TrackListObject::~TrackListObject()
int TrackListObject::AddTrack(const QString &in0, bool in1)
{
- int old_count = m_model->count();
+ QString path = in0;
if(in0.startsWith("file://"))
- m_model->addFile(QUrl(in0).toLocalFile ()); //converts url to local file path
- else
- m_model->addFile(in0);
- int new_count = m_model->count();
- if(new_count == old_count)
- return 0;
+ {
+ path = QUrl(in0).toLocalFile ();
+ if(!QFile::exists(path))
+ return 1; //error
+ }
if(in1)
{
- m_model->setCurrent(new_count-1);
+ m_pl_manager->selectPlayList(m_model);
m_player->stop();
- m_player->play();
+ qDebug("1");
+ m_prev_count = m_model->count();
+ connect(m_model, SIGNAL(listChanged()), this, SLOT(checkNewItem()));
+ connect(m_model, SIGNAL(loaderFinished()), this, SLOT(disconnectPl()));
+ qDebug("2");
}
- return 1;
+ m_model->add(path);
+ return 0;
}
void TrackListObject::DelTrack(int in0)
@@ -109,6 +114,22 @@ void TrackListObject::SetRandom(bool in0)
m_pl_manager->setShuffle(in0);
}
+void TrackListObject::disconnectPl()
+{
+ disconnect(m_model, SIGNAL(listChanged()), this, SLOT(checkNewItem()));
+ disconnect(m_model, SIGNAL(loaderFinished()), this, SLOT(disconnectPl()));
+}
+
+void TrackListObject::checkNewItem() //checks for new item in playlist
+{
+ if(m_model->count() > m_prev_count)
+ {
+ disconnectPl(); //disconnect playlist;
+ m_model->setCurrent(m_prev_count); // activate first added item
+ m_player->play(); // ... and play it
+ }
+}
+
void TrackListObject::updateTrackList()
{
emit TrackListChange(m_model->count());
@@ -116,6 +137,7 @@ void TrackListObject::updateTrackList()
void TrackListObject::switchPlayList(PlayListModel *cur, PlayListModel *prev)
{
+ disconnectPl();
m_model = cur;
connect (m_model, SIGNAL(listChanged()), SLOT(updateTrackList()));
if(prev)
diff --git a/src/plugins/General/mpris/tracklistobject.h b/src/plugins/General/mpris/tracklistobject.h
index 0004f25b9..eec9eda3c 100644
--- a/src/plugins/General/mpris/tracklistobject.h
+++ b/src/plugins/General/mpris/tracklistobject.h
@@ -54,6 +54,8 @@ signals:
void TrackListChange(int in0);
private slots:
+ void disconnectPl();
+ void checkNewItem();
void updateTrackList();
void switchPlayList(PlayListModel *cur, PlayListModel *prev);
@@ -61,6 +63,7 @@ private:
PlayListModel *m_model;
PlayListManager *m_pl_manager;
MediaPlayer *m_player;
+ int m_prev_count;
};
diff --git a/src/plugins/General/udisks/udisksplugin.cpp b/src/plugins/General/udisks/udisksplugin.cpp
index 75b2a25bb..fd228319f 100644
--- a/src/plugins/General/udisks/udisksplugin.cpp
+++ b/src/plugins/General/udisks/udisksplugin.cpp
@@ -182,10 +182,7 @@ void UDisksPlugin::processAction(QAction *action)
{
qDebug("UDisksPlugin: action triggered: %s", qPrintable(action->data().toString()));
QString path = action->data().toString();
- if (path.startsWith("cdda://"))
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addFile(path);
- else
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addDirectory(path);
+ MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path);
}
QAction *UDisksPlugin::findAction(const QString &dev_path)
@@ -206,7 +203,7 @@ UDisksDevice *UDisksPlugin::findDevice(QAction *action)
if (device->property("DeviceIsOpticalDisc").toBool() &&
device->property("OpticalDiscNumAudioTracks").toInt())
{
- dev_path = "cdda://" + device->property("DeviceFile").toString();
+ dev_path = "cdda://" + device->property("DeviceFile").toString();
if (dev_path == action->data().toString())
return device;
}
@@ -230,11 +227,11 @@ void UDisksPlugin::addPath(const QString &path)
if (path.startsWith("cdda://") && m_addTracks)
{
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addFile(path);
+ MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path);
return;
}
else if (!path.startsWith("cdda://") && m_addFiles)
- MediaPlayer::instance()->playListManager()->selectedPlayList()->addDirectory(path);
+ MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path);
}
void UDisksPlugin::removePath(const QString &path)