diff --git a/ext/libclementine-tagreader/tagreader.cpp b/ext/libclementine-tagreader/tagreader.cpp index 67f3cd2a1..b01f4dd6a 100644 --- a/ext/libclementine-tagreader/tagreader.cpp +++ b/ext/libclementine-tagreader/tagreader.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -190,10 +191,12 @@ void TagReader::ReadFile(const QString& filename, TStringToQString(map["TCMP"].front()->toString()).trimmed(); if (!map["USLT"].isEmpty()) { - lyrics = TStringToQString((map["USLT"].front())->toString()).trimmed(); - qLog(Debug) << "Read ULST lyrics " << lyrics; - } else if (!map["SYLT"].isEmpty()) - lyrics = TStringToQString((map["SYLT"].front())->toString()).trimmed(); + Decode(map["USLT"].front()->toString(), nullptr, + song->mutable_lyrics()); + } else if (!map["SYLT"].isEmpty()) { + Decode(map["SYLT"].front()->toString(), nullptr, + song->mutable_lyrics()); + } if (!map["APIC"].isEmpty()) song->set_art_automatic(kEmbeddedCover); @@ -628,7 +631,7 @@ bool TagReader::SaveFile(const QString& filename, SetTextFrame("TCOM", song.composer(), tag); SetTextFrame("TIT1", song.grouping(), tag); SetTextFrame("TOPE", song.performer(), tag); - SetTextFrame("USLT", song.lyrics(), tag); + SetUnsyncLyricsFrame(song.lyrics(), tag); // Skip TPE1 (which is the artist) here because we already set it SetTextFrame("TPE2", song.albumartist(), tag); SetTextFrame("TCMP", std::string(song.compilation() ? "1" : "0"), tag); @@ -857,6 +860,23 @@ void TagReader::SetTextFrame(const char* id, const std::string& value, tag->addFrame(frame); } +void TagReader::SetUnsyncLyricsFrame(const std::string& value, + TagLib::ID3v2::Tag* tag) const { + TagLib::ByteVector id_vector("USLT"); + + // Remove the frame if it already exists + while (tag->frameListMap().contains(id_vector) && + tag->frameListMap()[id_vector].size() != 0) { + tag->removeFrame(tag->frameListMap()[id_vector].front()); + } + + // Create and add a new frame + TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = + new TagLib::ID3v2::UnsynchronizedLyricsFrame(TagLib::String::UTF8); + frame->setText(StdStringToTaglibString(value)); + tag->addFrame(frame); +} + bool TagReader::IsMediaFile(const QString& filename) const { qLog(Debug) << "Checking for valid file" << filename; diff --git a/ext/libclementine-tagreader/tagreader.h b/ext/libclementine-tagreader/tagreader.h index 28d989803..2408aced6 100644 --- a/ext/libclementine-tagreader/tagreader.h +++ b/ext/libclementine-tagreader/tagreader.h @@ -87,12 +87,12 @@ class TagReader { void SetFMPSStatisticsVorbisComments( TagLib::Ogg::XiphComment* vorbis_comments, const pb::tagreader::SongMetadata& song) const; - void SetFMPSRatingVorbisComments(TagLib::Ogg::XiphComment* vorbis_comments, - const pb::tagreader::SongMetadata& song) - const; + void SetFMPSRatingVorbisComments( + TagLib::Ogg::XiphComment* vorbis_comments, + const pb::tagreader::SongMetadata& song) const; - pb::tagreader::SongMetadata_Type GuessFileType(TagLib::FileRef* fileref) - const; + pb::tagreader::SongMetadata_Type GuessFileType( + TagLib::FileRef* fileref) const; void SetUserTextFrame(const QString& description, const QString& value, TagLib::ID3v2::Tag* tag) const; @@ -104,6 +104,8 @@ class TagReader { TagLib::ID3v2::Tag* tag) const; void SetTextFrame(const char* id, const std::string& value, TagLib::ID3v2::Tag* tag) const; + void SetUnsyncLyricsFrame(const std::string& value, + TagLib::ID3v2::Tag* tag) const; private: static const char* kMP4_FMPS_Rating_ID; diff --git a/src/ui/edittagdialog.cpp b/src/ui/edittagdialog.cpp index a69c67fbe..2f5a88aa5 100644 --- a/src/ui/edittagdialog.cpp +++ b/src/ui/edittagdialog.cpp @@ -304,6 +304,7 @@ QVariant EditTagDialog::Data::value(const Song& song, const QString& id) { if (id == "grouping") return song.grouping(); if (id == "genre") return song.genre(); if (id == "comment") return song.comment(); + if (id == "lyrics") return song.lyrics(); if (id == "track") return song.track(); if (id == "disc") return song.disc(); if (id == "year") return song.year(); @@ -330,6 +331,8 @@ void EditTagDialog::Data::set_value(const QString& id, const QVariant& value) { current_.set_genre(value.toString()); else if (id == "comment") current_.set_comment(value.toString()); + else if (id == "lyrics") + current_.set_lyrics(value.toString()); else if (id == "track") current_.set_track(value.toInt()); else if (id == "disc") diff --git a/src/ui/edittagdialog.ui b/src/ui/edittagdialog.ui index f862236ef..fb7e30604 100644 --- a/src/ui/edittagdialog.ui +++ b/src/ui/edittagdialog.ui @@ -30,7 +30,7 @@ - 0 + 1 @@ -605,284 +605,350 @@ + + + 0 + 0 + + + + + 528 + 514 + + Edit tags - + - - - Title - - - title - - - - - - - true - - - false - - - - - - - Track - - - track - - - - - - - QAbstractSpinBox::CorrectToNearestValue - - - 9999 - - - false - - - true - - - - - - - Artist - - - artist - - - - - - - true - - - false - - - - - - - Disc - - - disc - - - - - - - QAbstractSpinBox::CorrectToNearestValue - - - 9999 - - - false - - - true - - - - - - - Album - - - album - - - - - - - true - - - false - - - - - - - Year - - - year - - - - - - - QAbstractSpinBox::CorrectToNearestValue - - - 9999 - - - false - - - true - - - - - - - Album artist - - - albumartist - - - - - - - true - - - false - - - - - - - Composer - - - composer - - - - - - - true - - - false - - - - - - - Performer - - - performer - - - - - - - true - - - false - - - - - - - Grouping - - - grouping - - - - - - - true - - - false - - - - - - - Genre - - - genre - - - - - - - true - - - false - - - - - - - Complete tags automatically - - - - :/providers/musicbrainz.png:/providers/musicbrainz.png - - - - 38 - 22 - - - - - - - - Comment - - - comment - - - - - - - true - - - false - - + + + + + + + Title + + + title + + + + + + + true + + + false + + + + + + + Track + + + track + + + + + + + QAbstractSpinBox::CorrectToNearestValue + + + 9999 + + + false + + + true + + + + + + + Artist + + + artist + + + + + + + true + + + false + + + + + + + Disc + + + disc + + + + + + + QAbstractSpinBox::CorrectToNearestValue + + + 9999 + + + false + + + true + + + + + + + Album + + + album + + + + + + + true + + + false + + + + + + + Year + + + year + + + + + + + QAbstractSpinBox::CorrectToNearestValue + + + 9999 + + + false + + + true + + + + + + + Album artist + + + albumartist + + + + + + + true + + + false + + + + + + + Composer + + + composer + + + + + + + true + + + false + + + + + + + Performer + + + performer + + + + + + + true + + + false + + + + + + + Grouping + + + grouping + + + + + + + true + + + false + + + + + + + Genre + + + genre + + + + + + + true + + + false + + + + + + + Complete tags automatically + + + + :/providers/musicbrainz.png:/providers/musicbrainz.png + + + + 38 + 22 + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + Lyrics + + + lyrics + + + + + + + true + + + false + + + + + + + + + + + + 100 + 0 + + + + Comment + + + comment + + + + + + + true + + + false + + + + + + @@ -890,7 +956,7 @@ - + diff --git a/src/widgets/nowplayingwidget.cpp b/src/widgets/nowplayingwidget.cpp index 25f59df47..0c5b4ce4e 100644 --- a/src/widgets/nowplayingwidget.cpp +++ b/src/widgets/nowplayingwidget.cpp @@ -99,8 +99,8 @@ NowPlayingWidget::NowPlayingWidget(QWidget* parent) CreateModeAction(LargeSongDetailsBelow, tr("Large album cover (details below)"), mode_group, mode_mapper); - CreateModeAction(LargeNoSongDetails, tr("Large album cover (no details)"), mode_group, - mode_mapper); + CreateModeAction(LargeNoSongDetails, tr("Large album cover (no details)"), + mode_group, mode_mapper); menu_->addActions(mode_group->actions()); @@ -528,7 +528,8 @@ void NowPlayingWidget::SetMode(int mode) { void NowPlayingWidget::resizeEvent(QResizeEvent* e) { if (visible_ && e->oldSize() != e->size()) { - if (mode_ == LargeSongDetails || mode_ == LargeNoSongDetails || mode_ == LargeSongDetailsBelow) { + if (mode_ == LargeSongDetails || mode_ == LargeNoSongDetails || + mode_ == LargeSongDetailsBelow) { UpdateHeight(); UpdateDetailsText(); }