Commit 72deb2db authored by Michael Pyne's avatar Michael Pyne

Implement wish 88099 (Automatically set folder icon for album when using the

File Renamer).

This feature could probably use some more testing, and it doesn't really work
too well when the Album name is the same as the Artist name if the Artist and
Album directories are separate (e.g. /.../Artist/Album/ wouldn't work.)

Now my JuK tree is finally identical to that in /trunk. :)


svn path=/trunk/KDE/kdemultimedia/juk/; revision=414826
parent e0d24657
......@@ -32,6 +32,7 @@
#include <kpushbutton.h>
#include <kapplication.h>
#include <kmessagebox.h>
#include <ksimpleconfig.h>
#include <qfile.h>
#include <qhbox.h>
......@@ -53,6 +54,7 @@
#include "exampleoptions.h"
#include "playlistitem.h"
#include "playlist.h"
#include "coverinfo.h"
class ConfirmationDialog : public KDialogBase
......@@ -729,6 +731,8 @@ void FileRenamer::rename(const PlaylistItemList &items)
if(moveFile(it.key(), {
setFolderIcon(, itemMap[it.key()]);
errorFiles << i18n("%1 to %2").arg(it.key()).arg(;
......@@ -775,6 +779,48 @@ bool FileRenamer::moveFile(const QString &src, const QString &dest)
return KIO::NetAccess::file_move(srcURL, dstURL);
void FileRenamer::setFolderIcon(const KURL &dst, const PlaylistItem *item)
if(item->file().tag()->album().isEmpty() ||
KURL dstURL = dst;
// Split path, and go through each path element. If a path element has
// the album information, set its folder icon.
QStringList elements = QStringList::split("/",;
QString path;
for(QStringList::ConstIterator it = elements.begin(); it != elements.end(); ++it) {
path.append("/" + (*it));
kdDebug() << "Checking path: " << path << endl;
if((*it).find(item->file().tag()->album()) != -1 &&
!QFile::exists(path + "/.directory"))
// Seems to be a match, let's set the folder icon for the current
// path. First we should write out the file.
QPixmap thumb = item->file().coverInfo()->pixmap(CoverInfo::Thumbnail); + "/.juk-thumbnail.png", "PNG");
KSimpleConfig config(path + "/.directory");
config.setGroup("Desktop Entry");
if(!config.hasKey("Icon")) {
config.writeEntry("Icon", QString("%1/.juk-thumbnail.png").arg(path));
QString FileRenamer::fileName(const CategoryReaderInterface &interface)
const QValueList<TagType> categoryOrder = interface.categoryOrder();
......@@ -436,6 +436,13 @@ public:
static QString fixupTrack(const QString &track, const CategoryReaderInterface &interface);
* Sets the folder icon for elements of the destination path for item (if
* there is not already a folder icon set, and if the folder's name has
* the album name.
void setFolderIcon(const KURL &dst, const PlaylistItem *item);
* Attempts to rename the file from \a src to \a dest. Returns true if the
* operation succeeded.
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