#include "directoryplaylist.h"
+#include <QDebug>
+
DirectoryPlaylist::DirectoryPlaylist(QObject *parent)
: AbstractPlaylist(parent), m_currentIndex(-1)
{
void DirectoryPlaylist::setDirectory(QDir directory)
{
+ if (m_directory == directory)
+ return;
+
m_directory = directory;
- m_currentIndex = 2;
- emit currentChanged(m_currentIndex - 2);
- emit currentChanged(m_directory[m_currentIndex]);
+ entryList = m_directory.entryInfoList(QDir::Files | QDir::Readable, QDir::Name);
+ m_currentIndex = 0;
}
int DirectoryPlaylist::indexOfFile(const QString &file) const
{
- return m_directory.entryList().indexOf(file);
+qDebug() << file;
+ int tmp = entryList.indexOf(file);
+qDebug() << "indexOfFile" << tmp;
+ return tmp;
}
bool DirectoryPlaylist::isEmpty() const
{
- return m_directory.count() == 2;
+ return entryList.count();
}
int DirectoryPlaylist::count() const
{
- return m_directory.count() - 2;
+ return m_directory.count();
}
int DirectoryPlaylist::currentIndex() const
{
++m_currentIndex;
if (m_currentIndex == count())
- m_currentIndex = 2;
+ m_currentIndex = 0;
- emit currentChanged(m_currentIndex - 2);
- emit currentChanged(m_directory[m_currentIndex]);
+ emit currentChanged(m_currentIndex);
+ emit currentChanged(entryList[m_currentIndex].absoluteFilePath());
}
void DirectoryPlaylist::previous()
{
--m_currentIndex;
if (m_currentIndex == 1)
- m_currentIndex = m_directory.count() - 1;
+ m_currentIndex = entryList.count() - 1;
- emit currentChanged(m_currentIndex - 2);
- emit currentChanged(m_directory[m_currentIndex]);
+ emit currentChanged(m_currentIndex);
+ emit currentChanged(entryList[m_currentIndex].absoluteFilePath());
}
void DirectoryPlaylist::setCurrent(int index)
if (index == m_currentIndex)
return;
- if (index < 0 || index > count() - 2)
+ if (index < 0 || index > count() - 1)
return;
- m_currentIndex = index + 2;
+ m_currentIndex = index;
- emit currentChanged(m_currentIndex - 2);
- emit currentChanged(m_directory[m_currentIndex]);
+ emit currentChanged(m_currentIndex);
+ emit currentChanged(entryList[m_currentIndex].absoluteFilePath());
}
addAction("play", "Play", QKeySequence("P"));
addAction("pause", "Pause", QKeySequence("W"));
addAction("stop", "Stop", QKeySequence("X"));
-// addAction("next", "Next", QKeySequence("."));
-// addAction("previous", "Previous", QKeySequence(","));
+ addAction("next", "Next", QKeySequence("CTRL+."));
+ addAction("previous", "Previous", QKeySequence("CTRL+,"));
#ifndef BROWSERPLUGIN_BUILD
addAction("togglePinMenu", "Pin Menu", QKeySequence(), true);
addAction("toggleStayOnTop", "Stay on top", QKeySequence("T"), true);
connect(videoWidget, SIGNAL(menuToggleRequested()), this, SLOT(toggleMenu()));
connect(videoWidget, SIGNAL(volumeChangeRequested(int)), this, SLOT(changeVolume(int)));
-// connect(m_actions["next"], SIGNAL(triggered()), playlist, SLOT(next()));
-// connect(m_actions["previous"], SIGNAL(triggered()), playlist, SLOT(previous()));
-// connect(playlist, SIGNAL(currentChanged(QString)), this, SLOT(play(QString)));
+ connect(m_actions["next"], SIGNAL(triggered()), playlist, SLOT(next()));
+ connect(m_actions["previous"], SIGNAL(triggered()), playlist, SLOT(previous()));
+ connect(playlist, SIGNAL(currentChanged(QString)), this, SLOT(play(QString)));
#ifndef BROWSERPLUGIN_BUILD
connect(menu, SIGNAL(positionChanged()), this, SLOT(moveWithMenu()));
#endif
anidb->setCompression(true);
anidb->setIdlePolicy(AniDBUdpClient::LogoutIdlePolicy);
-
+qDebug() << m_currentFile;
open(m_currentFile);
}
{
if (file == "")
return;
-
+qDebug() << "open => " << file;
QFileInfo fileInfo(file);
if (!fileInfo.exists())
{
play(closeOnStop);
}
-void play(const QString &file);
-
void VideoWindow::togglePlay()
{
Phonon::State state = mediaObject->state();