And add tag editor

This commit is contained in:
Craig Drummond
2018-02-07 19:48:01 +00:00
parent 4512fb56a0
commit ce6b9005fe
5 changed files with 35 additions and 25 deletions

View File

@@ -136,7 +136,7 @@ void CustomActions::doAction()
return;
}
if (Song::LocalFile != songs.at(0).type) {
if (!songs.at(0).isLocalFile()) {
if (!MPDConnection::self()->getDetails().dirReadable) {
DBUG << "MPD dir is not readable";
return;

View File

@@ -28,6 +28,7 @@
#include "widgets/menubutton.h"
#include "support/monoicon.h"
#include "support/configuration.h"
#include "tags/tags.h"
#include <QDesktopServices>
LocalFolderBrowsePage::LocalFolderBrowsePage(bool isHome, QWidget *p)
@@ -51,12 +52,12 @@ LocalFolderBrowsePage::LocalFolderBrowsePage(bool isHome, QWidget *p)
init(ReplacePlayQueue|AppendToPlayQueue, QList<QWidget *>() << menu);
view->addAction(CustomActions::self());
// #ifdef TAGLIB_FOUND
// view->addAction(StdActions::self()->editTagsAction);
#ifdef TAGLIB_FOUND
view->addAction(StdActions::self()->editTagsAction);
// #ifdef ENABLE_REPLAYGAIN_SUPPORT
// view->addAction(StdActions::self()->replaygainAction);
// #endif
// #endif // TAGLIB_FOUND
#endif // TAGLIB_FOUND
view->addAction(browseAction);
view->closeSearch();
view->alwaysShowHeader();
@@ -108,7 +109,7 @@ QList<Song> LocalFolderBrowsePage::selectedSongs(bool allowPlaylists) const
if (!allowPlaylists && MPDConnection::isPlaylist(path)) {
continue;
}
Song s;
Song s = Tags::read(path);
s.file = path;
s.type = Song::LocalFile;
songs.append(s);
@@ -140,14 +141,14 @@ void LocalFolderBrowsePage::controlActions()
{
QModelIndexList selected=view->selectedIndexes(false); // Dont need sorted selection here...
bool enable=selected.count()>0;
bool trackSelected=false;
bool folderSelected=false;
int numSelectedTracks=0;
for (const QModelIndex &idx: selected) {
if (model->fileInfo(proxy->mapToSource(idx)).isDir()) {
folderSelected=true;
} else {
trackSelected=true;
numSelectedTracks++;
}
}
StdActions::self()->enableAddToPlayQueue(enable);
@@ -155,12 +156,12 @@ void LocalFolderBrowsePage::controlActions()
CustomActions::self()->setEnabled(false);
bool fileActions = trackSelected && !folderSelected;
bool fileActions = numSelectedTracks>0 && numSelectedTracks<=250 && !folderSelected;
CustomActions::self()->setEnabled(fileActions);
// #ifdef TAGLIB_FOUND
// StdActions::self()->editTagsAction->setEnabled(fileActions);
#ifdef TAGLIB_FOUND
StdActions::self()->editTagsAction->setEnabled(fileActions);
// #ifdef ENABLE_REPLAYGAIN_SUPPORT
// StdActions::self()->replaygainAction->setEnabled(fileActions);
// #endif
// #endif // TAGLIB_FOUND
#endif // TAGLIB_FOUND
}

View File

@@ -211,6 +211,7 @@ struct Song
bool setAlbumArtist();
static QString capitalize(const QString &s);
bool capitalise();
bool isLocalFile() const { return LocalFile==type; }
bool isStream() const { return Stream==type || CantataStream==type; }
bool isStandardStream() const { return Stream==type && !isDlnaStream(); }
bool isDlnaStream() const { return Stream==type && !albumArtist().isEmpty() && !album.isEmpty() && track>0; }

View File

@@ -163,6 +163,12 @@ TagEditor::TagEditor(QWidget *parent, const QList<Song> &songs,
song.genres[0]=song.displayGenre();
song.genres[1]=QString();
original.append(song);
if (s.isLocalFile()) {
ratingsSupport = false;
composerSupport = true;
commentSupport = false;
baseDir = QString();
}
}
if (original.isEmpty()) {
@@ -1189,7 +1195,7 @@ bool TagEditor::applyUpdates()
// }
}
updatedSongs.append(edit);
if (!renameFiles && file!=opts.createFilename(edit)) {
if (!renameFiles && !orig.isLocalFile() && file!=opts.createFilename(edit)) {
renameFiles=true;
}
break;

View File

@@ -40,20 +40,22 @@ bool SongDialog::songsOk(const QList<Song> &songs, const QString &base, bool isM
QWidget *wid=isVisible() ? this : parentWidget();
int checked=0;
for (const Song &s: songs) {
const QString sfile=s.filePath();
const QString file=s.filePath(base);
DBUG << "Checking dir:" << base << " song:" << sfile << " file:" << file;
if (!QFile::exists(file)) {
DBUG << QString(file) << "does not exist";
if (isMpd) {
MessageBox::error(wid, tr("Cannot access song files!\n\n"
"Please check Cantata's \"Music folder\" setting, and MPD's \"music_directory\" setting."));
} else {
MessageBox::error(wid, tr("Cannot access song files!\n\n"
"Please check that the device is still attached."));
if (!s.isLocalFile()) {
const QString sfile=s.filePath();
const QString file=s.filePath(base);
DBUG << "Checking dir:" << base << " song:" << sfile << " file:" << file;
if (!QFile::exists(file)) {
DBUG << QString(file) << "does not exist";
if (isMpd) {
MessageBox::error(wid, tr("Cannot access song files!\n\n"
"Please check Cantata's \"Music folder\" setting, and MPD's \"music_directory\" setting."));
} else {
MessageBox::error(wid, tr("Cannot access song files!\n\n"
"Please check that the device is still attached."));
}
deleteLater();
return false;
}
deleteLater();
return false;
}
if (++checked>constNumToCheck) {
break;