diff options
author | Dave Blake <oak99sky@yahoo.co.uk> | 2019-04-05 07:47:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 07:47:36 +0100 |
commit | 20a5b591cfb3e67cc572530ea95839ca9d165cab (patch) | |
tree | 640c8b19997b98892961e923b93dee91f2e4d10b | |
parent | 6d967eba1492d1e98b42955ad2542e5c9eee56da (diff) | |
parent | f4f6e80064187578f7b0a28de4ac6f47012a5c1c (diff) |
Merge pull request #15821 from DaveTBlake/ExportEmpty
Music library export empty artist folders
-rw-r--r-- | addons/resource.language.en_gb/resources/strings.po | 49 | ||||
-rw-r--r-- | xbmc/music/MusicDatabase.cpp | 96 | ||||
-rw-r--r-- | xbmc/settings/LibExportSettings.cpp | 12 | ||||
-rw-r--r-- | xbmc/settings/LibExportSettings.h | 5 | ||||
-rw-r--r-- | xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp | 157 | ||||
-rw-r--r-- | xbmc/settings/dialogs/GUIDialogLibExportSettings.h | 5 |
6 files changed, 236 insertions, 88 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index 24057b98fd..15c74ef484 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -20979,8 +20979,9 @@ msgctxt "#38042" msgid "[Missing]" msgstr "" -#. Title album artists node +#. Title album artists node, and music item to export output, see #38306 #: system/library/music/musicroles/albumartists.xml +#: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp msgctxt "#38043" msgid "Album artists" msgstr "" @@ -21247,23 +21248,27 @@ msgstr "" #: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp msgctxt "#38309" -msgid "Output only artwork, not NFO files" +msgid "Output information to NFO files" msgstr "" +#. See #38309 when NFO and art export disabled so only artist folders #: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp msgctxt "#38310" -msgid "Overwrite existing files" +msgid "Output information to NFO files (currently exporting artist folders only)" msgstr "" -#empty string with id 38311 +#: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +msgctxt "#38311" +msgid "Overwrite existing files" +msgstr "" -#. Music item to export output, see #38093 +#. Music item to export output, see #38306 #: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp msgctxt "#38312" msgid "Song artists" msgstr "" -#. Music item to export output, see #38093 +#. Music item to export output, see #38306 #: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp msgctxt "#38313" msgid "Other artists" @@ -21295,7 +21300,37 @@ msgctxt "#38320" msgid "Do you have local artist information (NFO) and art files that you want to fetch? Set the location of these artist folders now" msgstr "" -#empty strings from id 38321 to 38329 +#. Kind of export output, see #38304 +#: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +msgctxt "#38321" +msgid "Artist folders only" +msgstr "" + +#. Explanation of what export to library folders means see #38303 when albums and artists selected +#: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +msgctxt "#38322" +msgid "Artists exported to Artist Information Folder and albums to music folders" +msgstr "" + +#. Explanation of what export to library folders means see #38303 when only albums selected +#: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +msgctxt "#38323" +msgid "Albums exported to music folders" +msgstr "" + +#. Explanation of what export to library folders means see #38303 when only artists selected +#: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +msgctxt "#38324" +msgid "Artists exported to Artist Information Folder" +msgstr "" + +#. Explanation of what export artist folders only means see #38304 +#: xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +msgctxt "#38325" +msgid "Artist subfolders created in Artist Information Folder" +msgstr "" + +#empty strings from id 38326 to 38329 #. Dialog heading when editing default settings for fetching additional music information #: xbmc/music/dialogs/GUIDialogInfoProviderSettings.cpp diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp index 21a87f7087..48c7bdb98e 100644 --- a/xbmc/music/MusicDatabase.cpp +++ b/xbmc/music/MusicDatabase.cpp @@ -9487,11 +9487,14 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog !settings.IsItemExported(ELIBEXPORT_ALBUMS)) return; - if (!settings.IsSingleFile() && settings.m_skipnfo && !settings.m_artwork) + // Exporting albums either art or NFO (or both) selected + if ((settings.IsToLibFolders() || settings.IsSeparateFiles()) && + settings.m_skipnfo && !settings.m_artwork && + settings.IsItemExported(ELIBEXPORT_ALBUMS)) return; std::string strFolder; - if (!settings.IsToLibFolders()) + if (settings.IsSingleFile() || settings.IsSeparateFiles()) { // Exporting to single file or separate files in a specified location if (settings.m_strPath.empty()) @@ -9504,15 +9507,22 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog if (strFolder.empty()) return; } - else + else if (settings.IsArtistFoldersOnly() || (settings.IsToLibFolders() && settings.IsArtists())) { - // Separate files with artists to library folder and albums to music folders. - // Without an artist information folder can not export artist NFO files or images + // Exporting artist folders only, or artist NFO or art to library folders + // need Artist Information Folder defined. + // (Album NFO and art goes to music folders) strFolder = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER); - if (!settings.IsItemExported(ELIBEXPORT_ALBUMS) && strFolder.empty()) + if (strFolder.empty()) return; } + // + bool artistfoldersonly; + artistfoldersonly = settings.IsArtistFoldersOnly() || + ((settings.IsToLibFolders() || settings.IsSeparateFiles()) && + settings.m_skipnfo && !settings.m_artwork); + int iFailCount = 0; try { @@ -9525,15 +9535,15 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog TiXmlDeclaration decl("1.0", "UTF-8", "yes"); xmlDoc.InsertEndChild(decl); TiXmlNode *pMain = NULL; - if (!settings.IsSingleFile()) + if ((settings.IsToLibFolders() || settings.IsSeparateFiles()) && !artistfoldersonly) pMain = &xmlDoc; - else + else if (settings.IsSingleFile()) { TiXmlElement xmlMainElement("musicdb"); pMain = xmlDoc.InsertEndChild(xmlMainElement); } - if (settings.IsItemExported(ELIBEXPORT_ALBUMS)) + if (settings.IsItemExported(ELIBEXPORT_ALBUMS) && !artistfoldersonly) { // Find albums to export std::vector<int> albumIds; @@ -9592,8 +9602,8 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog else { // Save album.nfo and artwork to subfolder on export path // strPath = strFolder/<albumartist name>/<albumname> - // where <albumname> is either the same name as the album folder containing the music files (if unique) - // or is craeted using the album name + // where <albumname> is either the same name as the album folder + // containing the music files (if unique) or is created using the album name std::string strAlbumArtist; pathfound = GetArtistFolderName(album.GetAlbumArtist()[0], album.GetMusicBrainzAlbumArtistID()[0], strAlbumArtist); if (pathfound) @@ -9674,9 +9684,7 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog } } - if ((settings.IsItemExported(ELIBEXPORT_ALBUMARTISTS) || - settings.IsItemExported(ELIBEXPORT_SONGARTISTS) || - settings.IsItemExported(ELIBEXPORT_OTHERARTISTS)) && !strFolder.empty()) + if ((settings.IsArtists() || artistfoldersonly) && !strFolder.empty()) { // Find artists to export std::vector<int> artistIds; @@ -9695,7 +9703,7 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog else if (settings.IsItemExported(ELIBEXPORT_OTHERARTISTS)) filter.AppendWhere("EXISTS (SELECT 1 FROM song_artist WHERE song_artist.idArtist = artist.idArtist AND song_artist.idRole > 1)", false); - if (!settings.m_unscraped) + if (!settings.m_unscraped && !artistfoldersonly) filter.AppendWhere("lastScraped IS NOT NULL", true); std::string strSQL = "SELECT idArtist FROM artist"; @@ -9716,7 +9724,7 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog for (const auto &artistId : artistIds) { CArtist artist; - GetArtist(artistId, artist, true); // include discography + GetArtist(artistId, artist, !artistfoldersonly); // include discography when not folders only std::string strPath; std::map<std::string, std::string> artwork; if (settings.IsSingleFile()) @@ -9749,38 +9757,41 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog __FUNCTION__, artist.strArtist.c_str(), strPath.c_str()); else { - if (!settings.m_skipnfo) + if (!artistfoldersonly) { - artist.Save(pMain, "artist", strPath); - std::string nfoFile = URIUtils::AddFileToFolder(strPath, "artist.nfo"); - if (settings.m_overwrite || !CFile::Exists(nfoFile)) + if (!settings.m_skipnfo) { - if (!xmlDoc.SaveFile(nfoFile)) + artist.Save(pMain, "artist", strPath); + std::string nfoFile = URIUtils::AddFileToFolder(strPath, "artist.nfo"); + if (settings.m_overwrite || !CFile::Exists(nfoFile)) { - CLog::Log(LOGERROR, "CMusicDatabase::%s: Artist nfo export failed! ('%s')", __FUNCTION__, nfoFile.c_str()); - CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(20302), nfoFile); - iFailCount++; + if (!xmlDoc.SaveFile(nfoFile)) + { + CLog::Log(LOGERROR, "CMusicDatabase::%s: Artist nfo export failed! ('%s')", __FUNCTION__, nfoFile.c_str()); + CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(20302), nfoFile); + iFailCount++; + } } } - } - if (settings.m_artwork) - { - std::string savedArtfile; - if (GetArtForItem(artist.idArtist, MediaTypeArtist, artwork)) + if (settings.m_artwork) { - for (const auto &art : artwork) + std::string savedArtfile; + if (GetArtForItem(artist.idArtist, MediaTypeArtist, artwork)) { - if (art.first == "thumb") - savedArtfile = URIUtils::AddFileToFolder(strPath, "folder"); - else - savedArtfile = URIUtils::AddFileToFolder(strPath, art.first); - CTextureCache::GetInstance().Export(art.second, savedArtfile, settings.m_overwrite); + for (const auto &art : artwork) + { + if (art.first == "thumb") + savedArtfile = URIUtils::AddFileToFolder(strPath, "folder"); + else + savedArtfile = URIUtils::AddFileToFolder(strPath, art.first); + CTextureCache::GetInstance().Export(art.second, savedArtfile, settings.m_overwrite); + } } } + xmlDoc.Clear(); + TiXmlDeclaration decl("1.0", "UTF-8", "yes"); + xmlDoc.InsertEndChild(decl); } - xmlDoc.Clear(); - TiXmlDeclaration decl("1.0", "UTF-8", "yes"); - xmlDoc.InsertEndChild(decl); } } if ((current % 50) == 0 && progressDialog) @@ -9802,12 +9813,9 @@ void CMusicDatabase::ExportToXML(const CLibExportSettings& settings, CGUIDialog xmlDoc.SaveFile(xmlFile); CVariant data; - if (settings.IsSingleFile()) - { - data["file"] = xmlFile; - if (iFailCount > 0) - data["failcount"] = iFailCount; - } + data["file"] = xmlFile; + if (iFailCount > 0) + data["failcount"] = iFailCount; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnExport", data); } } diff --git a/xbmc/settings/LibExportSettings.cpp b/xbmc/settings/LibExportSettings.cpp index 517d797eeb..f58628d75d 100644 --- a/xbmc/settings/LibExportSettings.cpp +++ b/xbmc/settings/LibExportSettings.cpp @@ -51,6 +51,13 @@ bool CLibExportSettings::IsItemExported(ELIBEXPORTOPTIONS item) const return (m_itemstoexport & item); } +bool CLibExportSettings::IsArtists() const +{ + return (m_itemstoexport & ELIBEXPORT_ALBUMARTISTS) || + (m_itemstoexport & ELIBEXPORT_SONGARTISTS) || + (m_itemstoexport & ELIBEXPORT_OTHERARTISTS); +} + std::vector<int> CLibExportSettings::GetExportItems() const { std::vector<int> values; @@ -82,3 +89,8 @@ bool CLibExportSettings::IsToLibFolders() const { return (m_exporttype == ELIBEXPORT_TOLIBRARYFOLDER); } + +bool CLibExportSettings::IsArtistFoldersOnly() const +{ + return (m_exporttype == ELIBEXPORT_ARTISTFOLDERS); +} diff --git a/xbmc/settings/LibExportSettings.h b/xbmc/settings/LibExportSettings.h index 12219b2107..a2e35c01b1 100644 --- a/xbmc/settings/LibExportSettings.h +++ b/xbmc/settings/LibExportSettings.h @@ -29,7 +29,8 @@ enum ELIBEXPORTOPTIONS ELIBEXPORT_OTHERARTISTS = 0x0080, ELIBEXPORT_ARTWORK = 0x0100, ELIBEXPORT_NFOFILES = 0x0200, - ELIBEXPORT_ACTORTHUMBS = 0x0400 + ELIBEXPORT_ACTORTHUMBS = 0x0400, + ELIBEXPORT_ARTISTFOLDERS = 0x0800 }; class CLibExportSettings @@ -40,6 +41,7 @@ public: bool operator!=(const CLibExportSettings &right) const; bool IsItemExported(ELIBEXPORTOPTIONS item) const; + bool IsArtists() const; std::vector<int> GetExportItems() const; void ClearItems() { m_itemstoexport = 0; } void AddItem(ELIBEXPORTOPTIONS item) { m_itemstoexport += item; } @@ -50,6 +52,7 @@ public: bool IsSingleFile() const; bool IsSeparateFiles() const; bool IsToLibFolders() const; + bool IsArtistFoldersOnly() const; std::string m_strPath; bool m_overwrite; diff --git a/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp b/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp index 85e995d6f3..a7d2334ef9 100644 --- a/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp +++ b/xbmc/settings/dialogs/GUIDialogLibExportSettings.cpp @@ -58,6 +58,10 @@ bool CGUIDialogLibExportSettings::Show(CLibExportSettings& settings) dialog->m_settings.m_skipnfo = pSettings->GetBool(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO); dialog->m_settings.m_overwrite = pSettings->GetBool(CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE); + // Ensure NFO or art output enabled when albums exported (adjust old saved settings) + if (dialog->m_settings.IsItemExported(ELIBEXPORT_ALBUMS) && (dialog->m_settings.m_skipnfo && !dialog->m_settings.m_artwork)) + dialog->m_settings.m_skipnfo = false; + dialog->m_destinationChecked = false; dialog->Open(); @@ -98,16 +102,38 @@ void CGUIDialogLibExportSettings::OnSettingChanged(std::shared_ptr<const CSettin else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE) m_settings.m_overwrite = std::static_pointer_cast<const CSettingBool>(setting)->GetValue(); else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_ITEMS) + { m_settings.SetItemsToExport(GetExportItemsFromSetting(setting)); + if (m_settings.IsItemExported(ELIBEXPORT_ALBUMS) && (m_settings.m_skipnfo && !m_settings.m_artwork)) + { + m_settings.m_skipnfo = false; + m_settingNFO->SetValue(true); + UpdateToggles(); + } + UpdateDescription(); + } else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_ARTWORK) { m_settings.m_artwork = std::static_pointer_cast<const CSettingBool>(setting)->GetValue(); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, m_settings.m_artwork); + if (m_settings.IsItemExported(ELIBEXPORT_ALBUMS) && (m_settings.m_skipnfo && !m_settings.m_artwork)) + { + m_settings.m_skipnfo = false; + m_settingNFO->SetValue(true); + } + UpdateToggles(); } else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_UNSCRAPED) m_settings.m_unscraped = std::static_pointer_cast<const CSettingBool>(setting)->GetValue(); else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO) - m_settings.m_skipnfo = std::static_pointer_cast<const CSettingBool>(setting)->GetValue(); + { + m_settings.m_skipnfo = !std::static_pointer_cast<const CSettingBool>(setting)->GetValue(); + if (m_settings.IsItemExported(ELIBEXPORT_ALBUMS) && (m_settings.m_skipnfo && !m_settings.m_artwork)) + { + m_settings.m_artwork = true; + m_settingArt->SetValue(true); + } + UpdateToggles(); + } } void CGUIDialogLibExportSettings::OnSettingAction(std::shared_ptr<const CSetting> setting) @@ -119,7 +145,8 @@ void CGUIDialogLibExportSettings::OnSettingAction(std::shared_ptr<const CSetting const std::string &settingId = setting->GetId(); - if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER) + if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER && + !m_settings.IsToLibFolders() && !m_settings.IsArtistFoldersOnly()) { VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); @@ -176,7 +203,7 @@ bool CGUIDialogLibExportSettings::OnMessage(CGUIMessage& message) void CGUIDialogLibExportSettings::OnOK() { // Validate destination folder - if (m_settings.IsToLibFolders()) + if (m_settings.IsToLibFolders() || m_settings.IsArtistFoldersOnly()) { // Check artist info folder setting std::string path = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER); @@ -231,30 +258,13 @@ void CGUIDialogLibExportSettings::SetupView() SET_CONTROL_LABEL(CONTROL_SETTINGS_OKAY_BUTTON, 38319); SET_CONTROL_LABEL(CONTROL_SETTINGS_CANCEL_BUTTON, 222); - SetLabel2(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, m_settings.m_strPath); - - if (m_settings.IsSingleFile()) - { - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, true); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE, false); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_ARTWORK, false); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, false); - } - else if (m_settings.IsSeparateFiles()) - { - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, true); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE, true); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_ARTWORK, true); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, m_settings.m_artwork); - } - else // To library folders - { - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, false); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE, true); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_ARTWORK, true); - ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, m_settings.m_artwork); - } + if (m_settings.IsSeparateFiles()) + ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_UNSCRAPED, !m_settings.m_skipnfo); + else if (m_settings.IsToLibFolders()) + ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_UNSCRAPED, false); UpdateButtons(); + UpdateToggles(); + UpdateDescription(); } void CGUIDialogLibExportSettings::UpdateButtons() @@ -270,6 +280,56 @@ void CGUIDialogLibExportSettings::UpdateButtons() SetFocus(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER); } +void CGUIDialogLibExportSettings::UpdateToggles() +{ + if (m_settings.IsSeparateFiles()) + ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_UNSCRAPED, !m_settings.m_skipnfo); + + if (!m_settings.IsItemExported(ELIBEXPORT_ALBUMS) && m_settings.m_skipnfo && !m_settings.m_artwork) + { + //"Output information to NFO files (currently exporting artist folders only)" + SetLabel(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, g_localizeStrings.Get(38310)); + ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE, false); + } + else + { + //"Output information to NFO files" + SetLabel(CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, g_localizeStrings.Get(38309)); + ToggleState(CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE, true); + } +} + +void CGUIDialogLibExportSettings::UpdateDescription() +{ + if (m_settings.IsToLibFolders()) + { + // Destination button is description of what to library means + SetLabel(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, ""); + if (m_settings.IsItemExported(ELIBEXPORT_ALBUMS)) + if (m_settings.IsArtists()) + //"Artists exported to Artist Information Folder and albums to music folders" + SetLabel2(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, g_localizeStrings.Get(38322)); + else + //"Albums exported to music folders" + SetLabel2(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, g_localizeStrings.Get(38323)); + else + // "Artists exported to Artist Information Folder" + SetLabel2(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, g_localizeStrings.Get(38324)); + } + else if (m_settings.IsArtistFoldersOnly()) + { + // Destination button is description of what artist folders means + SetLabel(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, ""); + //"Artists folders created in Artist Information Folder" + SetLabel2(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, g_localizeStrings.Get(38325)); + } + else + { + SetLabel2(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, m_settings.m_strPath); + SetLabel(CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, g_localizeStrings.Get(38305)); + } +} + void CGUIDialogLibExportSettings::InitializeSettings() { CGUIDialogSettingsManualBase::InitializeSettings(); @@ -291,36 +351,61 @@ void CGUIDialogLibExportSettings::InitializeSettings() TranslatableIntegerSettingOptions entries; entries.push_back(std::make_pair(38301, ELIBEXPORT_SINGLEFILE)); - entries.push_back(std::make_pair(38302, ELIBEXPORT_SEPARATEFILES)); entries.push_back(std::make_pair(38303, ELIBEXPORT_TOLIBRARYFOLDER)); + entries.push_back(std::make_pair(38302, ELIBEXPORT_SEPARATEFILES)); + entries.push_back(std::make_pair(38321, ELIBEXPORT_ARTISTFOLDERS)); AddList(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_FILETYPE, 38304, SettingLevel::Basic, m_settings.GetExportType(), entries, 38304); // "Choose kind of export output" AddButton(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_FOLDER, 38305, SettingLevel::Basic); entries.clear(); - entries.push_back(std::make_pair(132, ELIBEXPORT_ALBUMS)); //ablums + if (!m_settings.IsArtistFoldersOnly()) + entries.push_back(std::make_pair(132, ELIBEXPORT_ALBUMS)); //ablums entries.push_back(std::make_pair(38043, ELIBEXPORT_ALBUMARTISTS)); //album artists entries.push_back(std::make_pair(38312, ELIBEXPORT_SONGARTISTS)); //song artists entries.push_back(std::make_pair(38313, ELIBEXPORT_OTHERARTISTS)); //other artists - AddList(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_ITEMS, 38306, SettingLevel::Basic, m_settings.GetExportItems(), entries, 133, 1); + if (m_settings.IsArtistFoldersOnly()) + { + std::vector<int> artistitems; // Only artists, not albums + if (m_settings.IsItemExported(ELIBEXPORT_SONGARTISTS)) + artistitems.emplace_back(ELIBEXPORT_SONGARTISTS); + if (m_settings.IsItemExported(ELIBEXPORT_OTHERARTISTS)) + artistitems.emplace_back(ELIBEXPORT_OTHERARTISTS); + if (m_settings.IsItemExported(ELIBEXPORT_ALBUMARTISTS) || (artistitems.size() == 0)) + artistitems.emplace_back(ELIBEXPORT_ALBUMARTISTS); + AddList(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_ITEMS, 38306, SettingLevel::Basic, artistitems, entries, 133, 1); + } + else + { + AddList(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_ITEMS, 38306, SettingLevel::Basic, m_settings.GetExportItems(), entries, 133, 1); - AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_UNSCRAPED, 38308, SettingLevel::Basic, m_settings.m_unscraped); - AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_ARTWORK, 38307, SettingLevel::Basic, m_settings.m_artwork); - AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, 38309, SettingLevel::Basic, m_settings.m_skipnfo); - AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE, 38310, SettingLevel::Basic, m_settings.m_overwrite); + if (!m_settings.IsSingleFile()) + { + m_settingNFO = AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_SKIPNFO, 38309, SettingLevel::Basic, !m_settings.m_skipnfo); + AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_UNSCRAPED, 38308, SettingLevel::Basic, m_settings.m_unscraped); + m_settingArt = AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_ARTWORK, 38307, SettingLevel::Basic, m_settings.m_artwork); + AddToggle(groupDetails, CSettings::SETTING_MUSICLIBRARY_EXPORT_OVERWRITE, 38311, SettingLevel::Basic, m_settings.m_overwrite); + } + } } void CGUIDialogLibExportSettings::SetLabel2(const std::string &settingid, const std::string &label) { BaseSettingControlPtr settingControl = GetSettingControl(settingid); - if (settingControl != NULL && settingControl->GetControl() != NULL) + if (settingControl != nullptr && settingControl->GetControl() != nullptr) SET_CONTROL_LABEL2(settingControl->GetID(), label); } +void CGUIDialogLibExportSettings::SetLabel(const std::string &settingid, const std::string &label) +{ + BaseSettingControlPtr settingControl = GetSettingControl(settingid); + if (settingControl != nullptr && settingControl->GetControl() != nullptr) + SetControlLabel(settingControl->GetID(), label); +} void CGUIDialogLibExportSettings::ToggleState(const std::string & settingid, bool enabled) { BaseSettingControlPtr settingControl = GetSettingControl(settingid); - if (settingControl != NULL && settingControl->GetControl() != NULL) + if (settingControl != nullptr && settingControl->GetControl() != nullptr) { if (enabled) CONTROL_ENABLE(settingControl->GetID()); diff --git a/xbmc/settings/dialogs/GUIDialogLibExportSettings.h b/xbmc/settings/dialogs/GUIDialogLibExportSettings.h index 9e12d3233a..c052ac8605 100644 --- a/xbmc/settings/dialogs/GUIDialogLibExportSettings.h +++ b/xbmc/settings/dialogs/GUIDialogLibExportSettings.h @@ -44,12 +44,17 @@ protected: private: void SetLabel2(const std::string &settingid, const std::string &label); + void SetLabel(const std::string &settingid, const std::string &label); void ToggleState(const std::string &settingid, bool enabled); using CGUIDialogSettingsManualBase::SetFocus; void SetFocus(const std::string &settingid); static int GetExportItemsFromSetting(SettingConstPtr setting); + void UpdateToggles(); + void UpdateDescription(); CLibExportSettings m_settings; bool m_destinationChecked = false; + std::shared_ptr<CSettingBool> m_settingNFO; + std::shared_ptr<CSettingBool> m_settingArt; }; |