After ripping a CD, prompt as to whether to calculate ReplyGain.

This commit is contained in:
craig.p.drummond
2013-05-10 19:03:02 +00:00
committed by craig.p.drummond
parent 5120cbdf54
commit 5d2d3b1b13
5 changed files with 56 additions and 24 deletions

View File

@@ -6,6 +6,7 @@
3. If cover name contains %artist%, then replace with the album artist of the
current song. Likewise for %album%
4. Add option (to sidebar context menu) to toggle usage of monochrome icons.
5. After ripping a CD, prompt as to whether to calculate ReplyGain.
1.0.3
-----

View File

@@ -40,9 +40,13 @@
#include "freespaceinfo.h"
#include "icons.h"
#include "config.h"
#include "tags.h"
#ifdef ENABLE_ONLINE_SERVICES
#include "onlineservicesmodel.h"
#endif
#ifdef ENABLE_REPLAYGAIN_SUPPORT
#include "rgdialog.h"
#endif
#include <QFile>
static int iCount=0;
@@ -88,7 +92,7 @@ ActionDialog::~ActionDialog()
void ActionDialog::controlInfoLabel(Device *dev)
{
DeviceOptions opts;
if (Device::AudioCd==dev->devType()) {
if (sourceIsAudioCd) {
opts.load(MPDConnectionDetails::configGroupName(MPDConnection::self()->getDetails().name), true);
} else if (sourceUdi.isEmpty()) {
opts=dev->options();
@@ -116,10 +120,10 @@ void ActionDialog::controlInfoLabel(Device *dev)
index++;
}
codec->setText(QString("%1 (%2)").arg(encoder.name).arg(encoder.values.at(settingIndex).descr)+
(Device::AudioCd!=dev->devType() && opts.transcoderWhenDifferent ? QLatin1String("")+i18n("<i>(When different)</i>") : QString()));
(sourceIsAudioCd && opts.transcoderWhenDifferent ? QLatin1String("")+i18n("<i>(When different)</i>") : QString()));
} else {
codec->setText(encoder.name+
(Device::AudioCd!=dev->devType() && opts.transcoderWhenDifferent ? QLatin1String("")+i18n("<i>(When different)</i>") : QString()));
(sourceIsAudioCd && opts.transcoderWhenDifferent ? QLatin1String("")+i18n("<i>(When different)</i>") : QString()));
}
}
}
@@ -139,6 +143,7 @@ void ActionDialog::copy(const QString &srcUdi, const QString &dstUdi, const QLis
return;
}
sourceIsAudioCd=Device::AudioCd==dev->devType();
controlInfoLabel(dev);
// check space...
@@ -182,7 +187,7 @@ void ActionDialog::copy(const QString &srcUdi, const QString &dstUdi, const QLis
overwrite->setChecked(Settings::self()->overwriteSongs());
sourceLabel->setText(QLatin1String("<b>")+(sourceUdi.isEmpty()
? i18n("Local Music Library")
: Device::AudioCd==dev->devType()
: sourceIsAudioCd
? i18n("Audio CD")
: dev->data())+QLatin1String("</b>"));
destinationLabel->setText(QLatin1String("<b>")+(destUdi.isEmpty() ? i18n("Local Music Library") : dev->data())+QLatin1String("</b>"));
@@ -249,6 +254,7 @@ void ActionDialog::init(const QString &srcUdi, const QString &dstUdi, const QLis
resize(500, 160);
sourceUdi=srcUdi;
destUdi=dstUdi;
sourceIsAudioCd=false;
songsToAction=songs;
mode=m;
setCaption(Copy==mode ? i18n("Copy Songs") : i18n("Delete Songs"));
@@ -266,6 +272,9 @@ void ActionDialog::init(const QString &srcUdi, const QString &dstUdi, const QLis
currentPercent=0;
currentDev=0;
count=0;
#ifdef ENABLE_REPLAYGAIN_SUPPORT
albumsWithoutRgTags.clear();
#endif
}
void ActionDialog::slotButtonClicked(int button)
@@ -462,6 +471,24 @@ void ActionDialog::doNext()
if (!refreshLibrary()) {
emit completed();
accept();
#ifdef ENABLE_REPLAYGAIN_SUPPORT
if (Copy==mode && !albumsWithoutRgTags.isEmpty() && sourceIsAudioCd) {
QWidget *pw=parentWidget();
if (MessageBox::Yes==MessageBox::questionYesNo(pw, i18n("Calculate ReplayGain for ripped tracks?"))) {
RgDialog *dlg=new RgDialog(pw);
QList<Song> songs;
foreach (const Song &s, actionedSongs) {
if (albumsWithoutRgTags.contains(s.album)) {
Song song=s;
song.file=namingOptions.createFilename(s);
songs.append(song);
}
}
dlg->show(songs, QString(), true);
}
}
#endif
}
}
}
@@ -483,6 +510,11 @@ void ActionDialog::actionStatus(int status, bool copiedCover)
if (!wasSkip) {
actionedSongs.append(currentSong);
actionedTime+=currentSong.time;
#ifdef ENABLE_REPLAYGAIN_SUPPORT
if (Copy==mode && sourceIsAudioCd && !albumsWithoutRgTags.contains(currentSong.album) && Tags::readReplaygain(destFile).isEmpty()) {
albumsWithoutRgTags.insert(currentSong.album);
}
#endif
}
if (copiedCover) {
copiedCovers.insert(Utils::getDir(destFile));
@@ -567,18 +599,13 @@ void ActionDialog::configureSource()
void ActionDialog::configure(const QString &udi)
{
if (udi.isEmpty()) {
Device *dev=DevicesModel::self()->device(sourceUdi);
bool isCd=false;
if (dev) {
isCd=Device::AudioCd==dev->devType();
}
DevicePropertiesDialog *dlg=new DevicePropertiesDialog(this);
connect(dlg, SIGNAL(updatedSettings(const QString &, const DeviceOptions &)), SLOT(saveProperties(const QString &, const DeviceOptions &)));
if (!mpdConfigured) {
connect(dlg, SIGNAL(cancelled()), SLOT(saveProperties()));
}
dlg->setCaption(i18n("Local Music Library Properties"));
dlg->show(MPDConnection::self()->getDetails().dir, namingOptions, DevicePropertiesWidget::Prop_Basic|(isCd ? DevicePropertiesWidget::Prop_Encoder : 0));
dlg->show(MPDConnection::self()->getDetails().dir, namingOptions, DevicePropertiesWidget::Prop_Basic|(sourceIsAudioCd ? DevicePropertiesWidget::Prop_Encoder : 0));
connect(dlg, SIGNAL(destroyed()), SLOT(controlInfoLabel()));
} else {
Device *dev=DevicesModel::self()->device(udi);
@@ -592,24 +619,14 @@ void ActionDialog::configure(const QString &udi)
void ActionDialog::saveProperties(const QString &path, const DeviceOptions &opts)
{
Q_UNUSED(path)
Device *dev=DevicesModel::self()->device(sourceUdi);
bool isCd=false;
if (dev) {
isCd=Device::AudioCd==dev->devType();
}
namingOptions=opts;
namingOptions.save(MPDConnectionDetails::configGroupName(MPDConnection::self()->getDetails().name), true, isCd);
namingOptions.save(MPDConnectionDetails::configGroupName(MPDConnection::self()->getDetails().name), true, sourceIsAudioCd);
mpdConfigured=true;
}
void ActionDialog::saveProperties()
{
Device *dev=DevicesModel::self()->device(sourceUdi);
bool isCd=false;
if (dev) {
isCd=Device::AudioCd==dev->devType();
}
namingOptions.save(MPDConnectionDetails::configGroupName(MPDConnection::self()->getDetails().name), true, isCd);
namingOptions.save(MPDConnectionDetails::configGroupName(MPDConnection::self()->getDetails().name), true, sourceIsAudioCd);
mpdConfigured=true;
}

View File

@@ -83,6 +83,7 @@ private:
private:
Mode mode;
bool sourceIsAudioCd;
QString sourceUdi;
QString destUdi;
QList<Song> songsToAction;
@@ -106,6 +107,9 @@ private:
Device *currentDev;
QString destFile;
DeviceOptions namingOptions;
#ifdef ENABLE_REPLAYGAIN_SUPPORT
QSet<QString> albumsWithoutRgTags;
#endif
};
#endif

View File

@@ -107,6 +107,7 @@ RgDialog::RgDialog(QWidget *parent)
, state(State_Idle)
, totalToScan(0)
, tagReader(0)
, autoScanTags(false)
{
iCount++;
setButtons(User1|Ok|Cancel);
@@ -165,13 +166,14 @@ RgDialog::~RgDialog()
iCount--;
}
void RgDialog::show(const QList<Song> &songs, const QString &udi)
void RgDialog::show(const QList<Song> &songs, const QString &udi, bool autoScan)
{
if (songs.count()<1) {
deleteLater();
return;
}
autoScanTags=autoScan;
origSongs=songs;
qSort(origSongs);
#ifdef ENABLE_DEVICES_SUPPORT
@@ -369,6 +371,7 @@ void RgDialog::stopReadingTags()
disconnect(tagReader, SIGNAL(done()), this, SLOT(tagReaderDone()));
tagReader->requestAbort();
tagReader=0;
autoScanTags=false;
}
void RgDialog::saveTags()
@@ -634,6 +637,11 @@ void RgDialog::tagReaderDone()
enableButton(User1, true);
progress->setVisible(false);
statusLabel->setVisible(false);
if (autoScanTags) {
autoScanTags=false;
startScanning();
}
}
void RgDialog::closeEvent(QCloseEvent *event)

View File

@@ -48,7 +48,7 @@ public:
RgDialog(QWidget *parent);
virtual ~RgDialog();
void show(const QList<Song> &songs, const QString &udi);
void show(const QList<Song> &songs, const QString &udi, bool autoScan=false);
Q_SIGNALS:
// These are for communicating with MPD object (which is in its own thread, so need to talk via signal/slots)
@@ -114,6 +114,8 @@ private:
QMap<int, Tags::ReplayGain> origTags;
QSet<int> needToSave;
TagReader *tagReader;
bool autoScanTags;
};
#endif