Commit 5f892fc4 authored by Scott Wheeler's avatar Scott Wheeler

Added support for keeping track of which dirs have been loaded and

automatically finding new files in those on startup.

svn path=/trunk/kdemultimedia/juk/; revision=204955
parent 28bc59bb
......@@ -3,12 +3,12 @@ bin_PROGRAMS = juk
## INCLUDES were found outside kdevelop specific part
juk_SOURCES = stringhash.cpp sortedstringlist.cpp systemtray.cpp genrelisteditor.cpp genrelisteditorbase.ui splashscreen.cpp statuslabel.cpp cachedtag.cpp oggtag.cpp id3tag.cpp collectionlist.cpp playlistitem.cpp playlist.cpp playlistsplitter.cpp listboxpixmap.cpp playlistbox.cpp tageditor.cpp cache.cpp audiodata.cpp genrelistreader.cpp genrelistlist.cpp genrelist.cpp genre.cpp player.cpp tag.cpp customaction.cpp slideraction.cpp juk.cpp main.cpp
juk_SOURCES = directorylist.cpp directorylistbase.ui stringhash.cpp sortedstringlist.cpp systemtray.cpp genrelisteditor.cpp genrelisteditorbase.ui splashscreen.cpp statuslabel.cpp cachedtag.cpp oggtag.cpp id3tag.cpp collectionlist.cpp playlistitem.cpp playlist.cpp playlistsplitter.cpp listboxpixmap.cpp playlistbox.cpp tageditor.cpp cache.cpp audiodata.cpp genrelistreader.cpp genrelistlist.cpp genrelist.cpp genre.cpp player.cpp tag.cpp customaction.cpp slideraction.cpp juk.cpp main.cpp
juk_LDADD = -lid3 -lsoundserver_idl $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
SUBDIRS = pics data
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc slideraction.cpp slideraction.h customaction.h customaction.cpp tag.cpp tag.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png genrelist.cpp genrelist.h genrelistlist.cpp genrelistlist.h genrelistreader.cpp genrelistreader.h audiodata.cpp audiodata.h cache.cpp cache.h tageditor.cpp tageditor.h playlistbox.cpp playlistbox.h listboxpixmap.cpp listboxpixmap.h playlistsplitter.cpp playlistsplitter.h playlist.cpp playlist.h playlistitem.cpp playlistitem.h collectionlist.cpp collectionlist.h id3tag.cpp id3tag.h oggtag.cpp oggtag.h cachedtag.cpp cachedtag.h statuslabel.cpp statuslabel.h splashscreen.cpp splashscreen.h genrelisteditorbase.ui genrelisteditor.cpp genrelisteditor.h systemtray.h systemtray.cpp sortedstringlist.cpp sortedstringlist.h stringhash.cpp stringhash.h
EXTRA_DIST = main.cpp juk.cpp juk.h juk.desktop jukui.rc slideraction.cpp slideraction.h customaction.h customaction.cpp tag.cpp tag.h player.cpp player.h genre.h genre.cpp hi16-app-juk.png hi32-app-juk.png hi48-app-juk.png genrelist.cpp genrelist.h genrelistlist.cpp genrelistlist.h genrelistreader.cpp genrelistreader.h audiodata.cpp audiodata.h cache.cpp cache.h tageditor.cpp tageditor.h playlistbox.cpp playlistbox.h listboxpixmap.cpp listboxpixmap.h playlistsplitter.cpp playlistsplitter.h playlist.cpp playlist.h playlistitem.cpp playlistitem.h collectionlist.cpp collectionlist.h id3tag.cpp id3tag.h oggtag.cpp oggtag.h cachedtag.cpp cachedtag.h statuslabel.cpp statuslabel.h splashscreen.cpp splashscreen.h genrelisteditorbase.ui genrelisteditor.cpp genrelisteditor.h systemtray.h systemtray.cpp sortedstringlist.cpp sortedstringlist.h stringhash.cpp stringhash.h directorylistbase.ui directorylist.cpp directorylist.h
install-data-local:
$(mkinstalldirs) $(kde_appsdir)/Multimedia/
......
/***************************************************************************
directorylist.cpp - description
-------------------
begin : Tue Feb 4 2003
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <kfiledialog.h>
#include <klistview.h>
#include <kpushbutton.h>
#include "directorylist.h"
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
DirectoryList::DirectoryList(QStringList &directories, QWidget* parent, const char* name) : DirectoryListBase(parent, name, true, 0),
dirList(directories)
{
directoryListView->setFullWidth(true);
connect(addDirectoryButton, SIGNAL(clicked()), this, SLOT(addDirectory()));
connect(removeDirectoryButton, SIGNAL(clicked()), this, SLOT(removeDirectory()));
for(QStringList::ConstIterator it = directories.begin(); it != directories.end(); ++it)
new KListViewItem(directoryListView, *it);
}
DirectoryList::~DirectoryList()
{
}
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////
void DirectoryList::addDirectory()
{
QString dir = KFileDialog::getExistingDirectory();
if(!dir.isEmpty() && dirList.find(dir) == dirList.end()) {
dirList.append(dir);
new KListViewItem(directoryListView, dir);
emit directoryAdded(dir);
}
}
void DirectoryList::removeDirectory()
{
QString dir = directoryListView->selectedItem()->text(0);
dirList.remove(dir);
emit directoryRemoved(dir);
delete(directoryListView->selectedItem());
}
#include "directorylist.moc"
/***************************************************************************
directorylist.h - description
-------------------
begin : Tue Feb 4 2003
copyright : (C) 2003 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef DIRECTORYLIST_H
#define DIRECTORYLIST_H
#include <qstringlist.h>
#include "directorylistbase.h"
class DirectoryList : public DirectoryListBase
{
Q_OBJECT
public:
DirectoryList(QStringList &directories, QWidget* parent = 0, const char* name = 0);
virtual ~DirectoryList();
signals:
void directoryAdded(const QString &directory);
void directoryRemoved(const QString &directory);
private slots:
void addDirectory();
void removeDirectory();
private:
QStringList dirList;
};
#endif
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
<class>DirectoryListBase</class>
<widget class="QDialog">
<property name="name">
<cstring>DirectoryListBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<height>231</height>
</rect>
</property>
<property name="caption">
<string>Directory List</string>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="KListView">
<column>
<property name="text">
<string>Directories</string>
</property>
<property name="clickable">
<bool>true</bool>
</property>
<property name="resizable">
<bool>true</bool>
</property>
</column>
<property name="name">
<cstring>directoryListView</cstring>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>rightColumnLayout</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="KPushButton">
<property name="name">
<cstring>addDirectoryButton</cstring>
</property>
<property name="text">
<string>Add Directory</string>
</property>
</widget>
<widget class="KPushButton">
<property name="name">
<cstring>removeDirectoryButton</cstring>
</property>
<property name="text">
<string>Remove Directory</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>informationLabel</cstring>
</property>
<property name="text">
<string>These directories will be scanned on startup for new files.</string>
</property>
<property name="alignment">
<set>WordBreak|AlignVCenter</set>
</property>
</widget>
<spacer>
<property name="name">
<cstring>rightColumnSpacer</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout13</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>okButton</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>cancelButton</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
</hbox>
</widget>
<connections>
<connection>
<sender>okButton</sender>
<signal>clicked()</signal>
<receiver>DirectoryListBase</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>DirectoryListBase</receiver>
<slot>reject()</slot>
</connection>
</connections>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
<includehint>klistview.h</includehint>
<includehint>kpushbutton.h</includehint>
<includehint>kpushbutton.h</includehint>
</includehints>
</UI>
......@@ -24,6 +24,7 @@
#include "playlistsplitter.h"
#include "collectionlist.h"
#include "directorylist.h"
////////////////////////////////////////////////////////////////////////////////
// helper functions
......@@ -44,11 +45,12 @@ void processEvents()
PlaylistSplitter::PlaylistSplitter(QWidget *parent, bool restoreOnLoad, const char *name) : QSplitter(Qt::Horizontal, parent, name),
playingItem(0), restore(restoreOnLoad)
{
setupLayout();
readConfig();
mediaExtensions.append("mp3");
mediaExtensions.append("ogg");
listExtensions.append("m3u");
setupLayout();
readConfig();
}
PlaylistSplitter::~PlaylistSplitter()
......@@ -251,10 +253,25 @@ void PlaylistSplitter::open()
{
QStringList files = KFileDialog::getOpenFileNames(QString::null,
extensionsString((mediaExtensions + listExtensions), i18n("Media Files")));
// QStringList files = KFileDialog::getOpenFileNames();
open(files);
}
void PlaylistSplitter::openDirectory()
{
DirectoryList *l = new DirectoryList(directoryList, this, "directoryList");
directoryQueue.clear();
connect(l, SIGNAL(directoryAdded(const QString &)), this, SLOT(queueDirectory(const QString &)));
connect(l, SIGNAL(directoryRemoved(const QString &)), this, SLOT(removeDirectory(const QString &)));
if(l->exec() == QDialog::Accepted) {
open(directoryQueue);
directoryList += directoryQueue;
for(QStringList::Iterator it = directoryQueueRemove.begin(); it != directoryQueueRemove.end(); it++)
directoryList.remove(*it);
}
}
void PlaylistSplitter::setEditorVisible(bool visible)
{
if(visible)
......@@ -437,6 +454,8 @@ void PlaylistSplitter::readConfig()
{ // block for Playlists group
KConfigGroupSaver saver(config, "Playlists");
directoryList = config->readListEntry("DirectoryList");
if(restore) {
QStringList external = config->readListEntry("ExternalPlaylists");
for(QStringList::Iterator it = external.begin(); it != external.end(); ++it)
......@@ -448,6 +467,8 @@ void PlaylistSplitter::readConfig()
if(p)
p->setInternal(true);
}
open(directoryList);
}
}
}
......@@ -481,6 +502,7 @@ void PlaylistSplitter::saveConfig()
KConfigGroupSaver saver(config, "Playlists");
config->writeEntry("InternalPlaylists", internalPlaylists);
config->writeEntry("ExternalPlaylists", externalPlaylists);
config->writeEntry("DirectoryList", directoryList);
}
}
}
......
......@@ -139,7 +139,7 @@ public slots:
* Open a directory recursively, grabbing all of the music and playlist files
* in it's heirarchy.
*/
void openDirectory() { open(KFileDialog::getExistingDirectory()); }
void openDirectory();
/**
* Open each of \a files, where \a files is a list of playlists and music
......@@ -229,6 +229,18 @@ public slots:
*/
void setEditorVisible(bool visible);
/**
* Add a directory to the directory list queue. We need to queue these
* rather than processing them when they become available because the user
* could cancel the action.
*/
void queueDirectory(const QString &directory) { directoryQueue.append(directory); }
/**
* Add a directory to the queue
*/
void queueDirectoryRemove(const QString &directory) { directoryQueueRemove.append(directory); }
// PlaylistBox forwarding slots
void savePlaylist() { playlistBox->save(); }
......@@ -281,6 +293,10 @@ private:
QStringList mediaExtensions;
QStringList listExtensions;
QStringList directoryList;
QStringList directoryQueue;
QStringList directoryQueueRemove;
bool showEditor;
bool restore;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment