Commit d75180d3 authored by Frerich Raabe's avatar Frerich Raabe

- Configuration and testing facility for the "Rename file according to tag"

  feature, check the whats this texts for information how to use this (quite
  a few placeholders involved in this)

svn path=/trunk/kdemultimedia/juk/; revision=248822
parent 7f97a935
......@@ -13,7 +13,8 @@ juk_SOURCES = directorylistbase.ui genrelisteditorbase.ui \
playlistsearch.cpp searchwidget.cpp filerenamer.cpp dynamicplaylist.cpp \
searchplaylist.cpp musicbrainzquery.cpp mediafiles.cpp viewmode.cpp \
advancedsearchdialog.cpp historyplaylist.cpp trackpickerdialogbase.ui \
musicbrainzitem.cpp trackpickerdialog.cpp
musicbrainzitem.cpp trackpickerdialog.cpp filerenamerconfigdlgwidget.ui \
filerenamerconfigdlg.cpp
tagguessertest_SOURCES = tagguessertest.cpp tagguesser.cpp
......
/*
* filerenamerconfigdlg.cpp - (c) 2003 Frerich Raabe <raabe@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 "filerenamer.h"
#include "filerenamerconfigdlg.h"
#include "filerenamerconfigdlgwidget.h"
#include "tag.h"
#include <kapplication.h>
#include <kconfig.h>
#include <klineedit.h>
#include <klocale.h>
#include <kurlrequester.h>
#include <qcheckbox.h>
#include <qlabel.h>
FileRenamerConfigDlg::FileRenamerConfigDlg(QWidget *parent, const char *name)
: KDialogBase(parent, name, true, i18n("File Renamer Configuration"),
Ok | Cancel, Ok, true)
{
m_child = new FileRenamerConfigDlgWidget(this, "child");
m_child->urlReqCurrentFilename->setMode(KFile::File | KFile::ExistingOnly);
connect(m_child->leFilenameScheme, SIGNAL(textChanged(const QString &)),
this, SLOT(stateChanged(const QString &)));
connect(m_child->leTitleToken, SIGNAL(textChanged(const QString &)),
this, SLOT(stateChanged(const QString &)));
connect(m_child->cbNeedTitle, SIGNAL(clicked()), SLOT(stateChanged()));
connect(m_child->leArtistToken, SIGNAL(textChanged(const QString &)),
this, SLOT(stateChanged(const QString &)));
connect(m_child->cbNeedArtist, SIGNAL(clicked()), SLOT(stateChanged()));
connect(m_child->leAlbumToken, SIGNAL(textChanged(const QString &)),
this, SLOT(stateChanged(const QString &)));
connect(m_child->cbNeedAlbum, SIGNAL(clicked()), SLOT(stateChanged()));
connect(m_child->leTrackToken, SIGNAL(textChanged(const QString &)),
this, SLOT(stateChanged(const QString &)));
connect(m_child->cbNeedTrack, SIGNAL(clicked()), SLOT(stateChanged()));
connect(m_child->leCommentToken, SIGNAL(textChanged(const QString &)),
this, SLOT(stateChanged(const QString &)));
connect(m_child->cbNeedComment, SIGNAL(clicked()), SLOT(stateChanged()));
connect(m_child->urlReqCurrentFilename, SIGNAL(textChanged(const QString &)),
this, SLOT(currentFilenameChanged(const QString &)));
setMainWidget(m_child);
loadSettings();
resize( 400, 300 );
}
void FileRenamerConfigDlg::accept()
{
saveSettings();
KDialogBase::accept();
}
void FileRenamerConfigDlg::currentFilenameChanged(const QString &curFilename)
{
Tag *tag = Tag::createTag(curFilename);
if(tag == 0) {
m_child->lNewFilename->setText(i18n("Could not read tag from file"));
return;
}
FileRenamer renamer;
m_child->lNewFilename->setText(renamer.rename(curFilename, *tag));
delete tag;
}
void FileRenamerConfigDlg::loadSettings()
{
const FileRenamer::Config cfg(kapp->config());
m_child->leFilenameScheme->setText(cfg.filenameScheme());
m_child->leTitleToken->setText(cfg.getToken(FileRenamer::Title));
m_child->cbNeedTitle->setChecked(cfg.tokenNeedsValue(FileRenamer::Title));
m_child->leArtistToken->setText(cfg.getToken(FileRenamer::Artist));
m_child->cbNeedArtist->setChecked(cfg.tokenNeedsValue(FileRenamer::Artist));
m_child->leAlbumToken->setText(cfg.getToken(FileRenamer::Album));
m_child->cbNeedAlbum->setChecked(cfg.tokenNeedsValue(FileRenamer::Album));
m_child->leTrackToken->setText(cfg.getToken(FileRenamer::Track));
m_child->cbNeedTrack->setChecked(cfg.tokenNeedsValue(FileRenamer::Track));
m_child->leCommentToken->setText(cfg.getToken(FileRenamer::Comment));
m_child->cbNeedComment->setChecked(cfg.tokenNeedsValue(FileRenamer::Comment));
}
void FileRenamerConfigDlg::saveSettings()
{
FileRenamer::Config cfg(kapp->config());
cfg.setFilenameScheme(m_child->leFilenameScheme->text());
cfg.setToken(FileRenamer::Title, m_child->leTitleToken->text());
cfg.setTokenNeedsValue(FileRenamer::Title, m_child->cbNeedTitle->isChecked());
cfg.setToken(FileRenamer::Artist, m_child->leArtistToken->text());
cfg.setTokenNeedsValue(FileRenamer::Artist, m_child->cbNeedArtist->isChecked());
cfg.setToken(FileRenamer::Album, m_child->leAlbumToken->text());
cfg.setTokenNeedsValue(FileRenamer::Album, m_child->cbNeedAlbum->isChecked());
cfg.setToken(FileRenamer::Track, m_child->leTrackToken->text());
cfg.setTokenNeedsValue(FileRenamer::Track, m_child->cbNeedTrack->isChecked());
cfg.setToken(FileRenamer::Comment, m_child->leCommentToken->text());
cfg.setTokenNeedsValue(FileRenamer::Comment, m_child->cbNeedComment->isChecked());
kapp->config()->sync();
}
void FileRenamerConfigDlg::stateChanged(const QString &)
{
if(m_child->urlReqCurrentFilename->url().isEmpty())
return;
saveSettings();
currentFilenameChanged(m_child->urlReqCurrentFilename->url());
}
#include "filerenamerconfigdlg.moc"
// vim:ts=4:sw=4:et
/*
* filerenamerconfigdlg.h - (c) 2003 Frerich Raabe <raabe@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 FILERENAMERCONFIGDLG_H
#define FILERENAMERCONFIGDLG_H
#include <kdialogbase.h>
class FileRenamerConfigDlgWidget;
class FileRenamerConfigDlg : public KDialogBase
{
Q_OBJECT
public:
FileRenamerConfigDlg(QWidget *parent, const char *name = 0);
protected slots:
virtual void accept();
private slots:
void currentFilenameChanged(const QString &curFilename);
void stateChanged(const QString & = QString::null);
private:
void loadSettings();
void saveSettings();
FileRenamerConfigDlgWidget *m_child;
};
#endif // FILERENAMERCONFIGDLG_H
// vim:ts=4:sw=4:et
This diff is collapsed.
......@@ -33,6 +33,7 @@
#include "systemtray.h"
#include "keydialog.h"
#include "tagguesserconfigdlg.h"
#include "filerenamerconfigdlg.h"
////////////////////////////////////////////////////////////////////////////////
// public members
......@@ -445,6 +446,9 @@ void JuK::setupActions()
new KAction(i18n("&Tag Guesser..."), 0, 0, this, SLOT(slotConfigureTagGuesser()),
actionCollection(), "tagGuesserConfig");
new KAction(i18n("&File Renamer..."), 0, 0, this, SLOT(slotConfigureFileRenamer()),
actionCollection(), "fileRenamerConfig");
KStdAction::keyBindings(this, SLOT(slotEditKeys()), actionCollection());
//////////////////////////////////////////////////
......@@ -945,4 +949,10 @@ void JuK::slotConfigureTagGuesser()
dlg.exec();
}
void JuK::slotConfigureFileRenamer()
{
FileRenamerConfigDlg dlg(this);
dlg.exec();
}
#include "juk.moc"
......@@ -153,6 +153,7 @@ private slots:
void slotSetOutput(int output);
void slotEditKeys();
void slotConfigureTagGuesser();
void slotConfigureFileRenamer();
// additional player slots
void slotTrackPositionSliderClicked();
......
......@@ -61,6 +61,7 @@
<Action name="dockOnClose" append="show_merge"/>
<Action name="togglePopups" append="show_merge"/>
<Action name="tagGuesserConfig" append="save_merge"/>
<Action name="fileRenamerConfig" append="save_merge"/>
<Action name="outputSelect" append="save_merge"/>
</Menu>
</MenuBar>
......
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