From 0ef07b7969e9d07353bf05325192cbef9229d198 Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 24 Oct 2016 20:15:10 +0200 Subject: [PATCH] Refactor settings --- CMakeLists.txt | 2 +- application/settings.cpp | 529 ++++++++------------------------ application/settings.h | 177 ++++++----- dbquery/dbquery.h | 6 +- dbquery/lyricswikia.cpp | 12 +- dbquery/musicbrainz.cpp | 6 +- gui/dbquerywidget.cpp | 216 +++++++++---- gui/dbquerywidget.h | 5 +- gui/initiate.cpp | 4 +- gui/mainwindow.cpp | 33 +- gui/picturepreviewselection.cpp | 5 +- gui/renamefilesdialog.cpp | 20 +- gui/settingsdialog.cpp | 196 ++++++------ gui/tagedit.cpp | 4 +- gui/tageditorwidget.cpp | 66 ++-- gui/tagfieldedit.cpp | 15 +- translations/tageditor_de_DE.ts | 266 ++++++++-------- translations/tageditor_en_US.ts | 266 ++++++++-------- 18 files changed, 851 insertions(+), 977 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b5ff3c..f98b985 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "A tageditor with Qt GUI and command line interface. Supports MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska") set(META_GUI_OPTIONAL true) set(META_VERSION_MAJOR 2) -set(META_VERSION_MINOR 0) +set(META_VERSION_MINOR 1) set(META_VERSION_PATCH 0) # add project files diff --git a/application/settings.cpp b/application/settings.cpp index a569274..4a031b3 100644 --- a/application/settings.cpp +++ b/application/settings.cpp @@ -8,8 +8,6 @@ #include -#include -#include #include #include @@ -17,541 +15,272 @@ using namespace Media; namespace Settings { -// editor -AdoptFields &adoptFields() -{ - static AdoptFields v = AdoptFields::Never; - return v; -} -bool &saveAndShowNextOnEnter() -{ - static bool v = false; - return v; -} -bool &askBeforeDeleting() -{ - static bool v = true; - return v; -} -MultipleTagHandling &multipleTagHandling() -{ - static MultipleTagHandling v = MultipleTagHandling::SingleEditorPerTarget; - return v; -} -bool &hideTagSelectionComboBox() -{ - static bool v = false; - return v; -} -bool &forceFullParse() -{ - static bool v = false; - return v; -} -#ifndef TAGEDITOR_NO_WEBVIEW -bool &noWebView() -{ - static bool v = false; - return v; -} -#endif -bool &hideCoverButtons() -{ - static bool v = false; - return v; -} +AutoCompletition::AutoCompletition() : + fields(nullptr, KnownFieldModel::DefaultSelection::None) +{} -// file browser -bool &hideBackupFiles() -{ - static bool v = true; - return v; -} -bool &fileBrowserReadOnly() -{ - static bool v = true; - return v; -} +Editor::Editor() : + fields(nullptr, KnownFieldModel::DefaultSelection::CommonFields), + defaultTargets(nullptr, TargetLevelModel::DefaultSelection::MostUsefulTargets) +{} -// general tag processing -Media::TagTextEncoding &preferredEncoding() -{ - static Media::TagTextEncoding v = Media::TagTextEncoding::Utf8; - return v; -} +DbQuery::DbQuery() : + fields(QList() + << KnownFieldModel::mkItem(KnownField::Title) + << KnownFieldModel::mkItem(KnownField::TrackPosition) + << KnownFieldModel::mkItem(KnownField::DiskPosition) + << KnownFieldModel::mkItem(KnownField::Album) + << KnownFieldModel::mkItem(KnownField::Album) + << KnownFieldModel::mkItem(KnownField::Year) + << KnownFieldModel::mkItem(KnownField::Genre) + << KnownFieldModel::mkItem(KnownField::Cover, Qt::Unchecked) + << KnownFieldModel::mkItem(KnownField::Lyrics, Qt::Unchecked)) +{} -UnsupportedFieldHandling &unsupportedFieldHandling() +Settings &values() { - static UnsupportedFieldHandling v = UnsupportedFieldHandling::Ignore; - return v; -} - -bool &autoTagManagement() -{ - static bool v = true; - return v; -} - -// ID3 tag processing -TagUsage &id3v1usage() -{ - static TagUsage v = TagUsage::Always; - return v; -} - -TagUsage &id3v2usage() -{ - static TagUsage v = TagUsage::Always; - return v; -} - -byte &id3v2versionToBeUsed() -{ - static byte v = 3; - return v; -} - -bool &keepVersionOfExistingId3v2Tag() -{ - static bool v = true; - return v; -} - -bool &mergeMultipleSuccessiveId3v2Tags() -{ - static bool v = true; - return v; -} - -// file layout -bool &forceRewrite() -{ - static bool v = true; - return v; -} - -ElementPosition &preferredTagPosition() -{ - static ElementPosition v = ElementPosition::BeforeData; - return v; -} - -bool &forceTagPosition() -{ - static bool v = true; - return v; -} - -ElementPosition &preferredIndexPosition() -{ - static ElementPosition v = ElementPosition::BeforeData; - return v; -} - -bool &forceIndexPosition() -{ - static bool v = true; - return v; -} - -size_t &minPadding() -{ - static size_t v = 0; - return v; -} - -size_t &maxPadding() -{ - static size_t v = 0; - return v; -} - -size_t &preferredPadding() -{ - static size_t v = 0; - return v; -} - -// targets -TargetLevelModel &defaultTargetsModel() -{ - static TargetLevelModel model(nullptr, TargetLevelModel::DefaultSelection::MostUsefulTargets); - return model; -} - -// fields -KnownFieldModel &selectedFieldsModel() -{ - static KnownFieldModel model(nullptr, KnownFieldModel::DefaultSelection::CommonFields); - return model; -} - -// auto correction/completition -bool &insertTitleFromFilename() -{ - static bool v = false; - return v; -} - -bool &trimWhitespaces() -{ - static bool v = true; - return v; -} - -bool &formatNames() -{ - static bool v = false; - return v; -} - -bool &fixUmlauts() -{ - static bool v = false; - return v; -} - -KnownFieldModel &autoCorrectionFields() -{ - static KnownFieldModel model(nullptr, KnownFieldModel::DefaultSelection::None); - return model; -} - -// main window -QByteArray &mainWindowGeometry() -{ - static QByteArray v; - return v; -} - -QByteArray &mainWindowState() -{ - static QByteArray v; - return v; -} - -QString &mainWindowCurrentFileBrowserDirectory() -{ - static QString v; - return v; -} - -bool &mainWindowLayoutLocked() -{ - static bool v = false; - return v; -} - -// db query -bool &dbQueryWidgetShown() -{ - static bool v = false; - return v; -} - -bool &dbQueryOverride() -{ - static bool v = false; - return v; -} - -KnownFieldModel &dbQueryFields() -{ - static KnownFieldModel v(QList() - << KnownFieldModel::mkItem(KnownField::Title) - << KnownFieldModel::mkItem(KnownField::TrackPosition) - << KnownFieldModel::mkItem(KnownField::DiskPosition) - << KnownFieldModel::mkItem(KnownField::Album) - << KnownFieldModel::mkItem(KnownField::Album) - << KnownFieldModel::mkItem(KnownField::Year) - << KnownFieldModel::mkItem(KnownField::Genre) - << KnownFieldModel::mkItem(KnownField::Cover, Qt::Unchecked) - << KnownFieldModel::mkItem(KnownField::Lyrics, Qt::Unchecked)); - return v; -} - -QString &musicBrainzUrl() -{ - static QString v; - return v; -} - -QString &coverArtArchiveUrl() -{ - static QString v; - return v; -} - -QString &lyricsWikiaUrl() -{ - static QString v; - return v; -} - -// renaming files dialog -int &scriptSource() -{ - static int v = 0; - return v; -} - -QString &externalScript() -{ - static QString v; - return v; -} - -QString &editorScript() -{ - static QString v; - return v; -} - -// Qt settings -Dialogs::QtSettings &qtSettings() -{ - static Dialogs::QtSettings v; - return v; + static Settings settings; + return settings; } void restore() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()); + Settings &v = values(); settings.beginGroup(QStringLiteral("editor")); switch(settings.value(QStringLiteral("adoptfields"), 0).toInt()) { case 1: - adoptFields() = AdoptFields::WithinDirectory; + v.editor.adoptFields = AdoptFields::WithinDirectory; break; case 2: - adoptFields() = AdoptFields::Always; + v.editor.adoptFields = AdoptFields::Always; break; default: - adoptFields() = AdoptFields::Never; + v.editor.adoptFields = AdoptFields::Never; break; }; - saveAndShowNextOnEnter() = settings.value(QStringLiteral("saveandshownextonenter"), false).toBool(); - askBeforeDeleting() = settings.value(QStringLiteral("askbeforedeleting"), true).toBool(); + v.editor.saveAndShowNextOnEnter = settings.value(QStringLiteral("saveandshownextonenter"), false).toBool(); + v.editor.askBeforeDeleting = settings.value(QStringLiteral("askbeforedeleting"), true).toBool(); switch(settings.value(QStringLiteral("multipletaghandling"), 0).toInt()) { case 0: - multipleTagHandling() = MultipleTagHandling::SingleEditorPerTarget; + v.editor.multipleTagHandling = MultipleTagHandling::SingleEditorPerTarget; break; case 1: - multipleTagHandling() = MultipleTagHandling::SeparateEditors; + v.editor.multipleTagHandling = MultipleTagHandling::SeparateEditors; break; } - hideTagSelectionComboBox() = settings.value(QStringLiteral("hidetagselectioncombobox"), false).toBool(); + v.editor.hideTagSelectionComboBox = settings.value(QStringLiteral("hidetagselectioncombobox"), false).toBool(); settings.beginGroup(QStringLiteral("autocorrection")); - insertTitleFromFilename() = settings.value(QStringLiteral("inserttitlefromfilename"), false).toBool(); - trimWhitespaces() = settings.value(QStringLiteral("trimwhitespaces"), true).toBool(); - formatNames() = settings.value(QStringLiteral("formatnames"), false).toBool(); - fixUmlauts() = settings.value(QStringLiteral("fixumlauts"), false).toBool(); + v.editor.autoCompletition.insertTitleFromFilename = settings.value(QStringLiteral("inserttitlefromfilename"), false).toBool(); + v.editor.autoCompletition.trimWhitespaces = settings.value(QStringLiteral("trimwhitespaces"), true).toBool(); + v.editor.autoCompletition.formatNames = settings.value(QStringLiteral("formatnames"), false).toBool(); + v.editor.autoCompletition.fixUmlauts = settings.value(QStringLiteral("fixumlauts"), false).toBool(); settings.endGroup(); BackupHelper::backupDirectory() = settings.value(QStringLiteral("tempdir")).toString().toStdString(); - Settings::hideCoverButtons() = settings.value(QStringLiteral("hidecoverbtn"), false).toBool(); + v.editor.hideCoverButtons = settings.value(QStringLiteral("hidecoverbtn"), false).toBool(); settings.endGroup(); - selectedFieldsModel().restore(settings, QStringLiteral("selectedfields")); - - autoCorrectionFields().restore(settings, QStringLiteral("autocorrectionfields")); + v.editor.fields.restore(settings, QStringLiteral("selectedfields")); + v.editor.autoCompletition.fields.restore(settings, QStringLiteral("autocorrectionfields")); settings.beginGroup(QStringLiteral("info")); - Settings::forceFullParse() = settings.value(QStringLiteral("forcefullparse"), false).toBool(); + v.editor.forceFullParse = settings.value(QStringLiteral("forcefullparse"), false).toBool(); #ifndef TAGEDITOR_NO_WEBVIEW - Settings::noWebView() = settings.value(QStringLiteral("nowebview"), false).toBool(); + v.editor.noWebView = settings.value(QStringLiteral("nowebview"), false).toBool(); #endif settings.endGroup(); settings.beginGroup(QStringLiteral("filebrowser")); - hideBackupFiles() = settings.value(QStringLiteral("hidebackupfiles"), true).toBool(); - fileBrowserReadOnly() = settings.value(QStringLiteral("readonly"), true).toBool(); + v.fileBrowser.hideBackupFiles = settings.value(QStringLiteral("hidebackupfiles"), true).toBool(); + v.fileBrowser.readOnly = settings.value(QStringLiteral("readonly"), true).toBool(); settings.endGroup(); settings.beginGroup(QStringLiteral("tagprocessing")); switch(settings.value(QStringLiteral("preferredencoding"), 1).toInt()) { case 0: - preferredEncoding() = Media::TagTextEncoding::Latin1; + v.tagPocessing.preferredEncoding = Media::TagTextEncoding::Latin1; break; case 2: - preferredEncoding() = Media::TagTextEncoding::Utf16BigEndian; + v.tagPocessing.preferredEncoding = Media::TagTextEncoding::Utf16BigEndian; break; case 3: - preferredEncoding() = Media::TagTextEncoding::Utf16LittleEndian; + v.tagPocessing.preferredEncoding = Media::TagTextEncoding::Utf16LittleEndian; break; default: - preferredEncoding() = Media::TagTextEncoding::Utf8; + v.tagPocessing.preferredEncoding = Media::TagTextEncoding::Utf8; }; switch(settings.value(QStringLiteral("unsupportedfieldhandling"), 0).toInt()) { case 1: - unsupportedFieldHandling() = UnsupportedFieldHandling::Discard; + v.tagPocessing.unsupportedFieldHandling = UnsupportedFieldHandling::Discard; break; default: - unsupportedFieldHandling() = UnsupportedFieldHandling::Ignore; + v.tagPocessing.unsupportedFieldHandling = UnsupportedFieldHandling::Ignore; }; - autoTagManagement() = settings.value(QStringLiteral("autotagmanagement"), true).toBool(); + v.tagPocessing.autoTagManagement = settings.value(QStringLiteral("autotagmanagement"), true).toBool(); settings.beginGroup(QStringLiteral("id3v1")); switch(settings.value(QStringLiteral("usage"), 0).toInt()) { case 1: - id3v1usage() = TagUsage::KeepExisting; + v.tagPocessing.id3.v1Usage = TagUsage::KeepExisting; break; case 2: - id3v1usage() = TagUsage::Never; + v.tagPocessing.id3.v1Usage = TagUsage::Never; break; default: - id3v1usage() = TagUsage::Always; + v.tagPocessing.id3.v1Usage = TagUsage::Always; break; }; settings.endGroup(); settings.beginGroup(QStringLiteral("id3v2")); switch(settings.value(QStringLiteral("usage"), 0).toInt()) { case 1: - id3v2usage() = TagUsage::KeepExisting; + v.tagPocessing.id3.v2Usage = TagUsage::KeepExisting; break; case 2: - id3v2usage() = TagUsage::Never; + v.tagPocessing.id3.v2Usage = TagUsage::Never; break; default: - id3v2usage() = TagUsage::Always; + v.tagPocessing.id3.v2Usage = TagUsage::Always; }; - id3v2versionToBeUsed() = settings.value(QStringLiteral("versiontobeused"), 3).toUInt(); - keepVersionOfExistingId3v2Tag() = settings.value(QStringLiteral("keepversionofexistingtag"), true).toBool(); - mergeMultipleSuccessiveId3v2Tags() = settings.value(QStringLiteral("mergemultiplesuccessivetags"), true).toBool(); + v.tagPocessing.id3.v2Version = settings.value(QStringLiteral("versiontobeused"), 3).toUInt(); + v.tagPocessing.id3.keepVersionOfExistingId3v2Tag = settings.value(QStringLiteral("keepversionofexistingtag"), true).toBool(); + v.tagPocessing.id3.mergeMultipleSuccessiveId3v2Tags = settings.value(QStringLiteral("mergemultiplesuccessivetags"), true).toBool(); settings.endGroup(); - defaultTargetsModel().restore(settings, QStringLiteral("targets")); + v.editor.defaultTargets.restore(settings, QStringLiteral("targets")); settings.beginGroup(QStringLiteral("filelayout")); - forceRewrite() = settings.value(QStringLiteral("forcerewrite"), true).toBool(); + v.tagPocessing.fileLayout.forceRewrite = settings.value(QStringLiteral("forcerewrite"), true).toBool(); switch(settings.value(QStringLiteral("tagpos")).toInt()) { case 0: - preferredTagPosition() = ElementPosition::BeforeData; + v.tagPocessing.fileLayout.preferredTagPosition = ElementPosition::BeforeData; break; case 1: - preferredTagPosition() = ElementPosition::AfterData; + v.tagPocessing.fileLayout.preferredTagPosition = ElementPosition::AfterData; break; } - forceTagPosition() = settings.value(QStringLiteral("forcetagpos"), true).toBool(); + v.tagPocessing.fileLayout.forceTagPosition = settings.value(QStringLiteral("forcetagpos"), true).toBool(); switch(settings.value(QStringLiteral("indexpos")).toInt()) { case 0: - preferredIndexPosition() = ElementPosition::BeforeData; + v.tagPocessing.fileLayout.preferredIndexPosition = ElementPosition::BeforeData; break; case 1: - preferredIndexPosition() = ElementPosition::AfterData; + v.tagPocessing.fileLayout.preferredIndexPosition = ElementPosition::AfterData; break; } - forceIndexPosition() = settings.value(QStringLiteral("forceindexpos"), true).toBool(); - minPadding() = settings.value(QStringLiteral("minpad"), 0).toUInt(); - maxPadding() = settings.value(QStringLiteral("maxpad"), 0).toUInt(); - preferredPadding() = settings.value(QStringLiteral("prefpad"), 0).toUInt(); + v.tagPocessing.fileLayout.forceIndexPosition = settings.value(QStringLiteral("forceindexpos"), true).toBool(); + v.tagPocessing.fileLayout.minPadding = settings.value(QStringLiteral("minpad"), 0).toUInt(); + v.tagPocessing.fileLayout.maxPadding = settings.value(QStringLiteral("maxpad"), 0).toUInt(); + v.tagPocessing.fileLayout.preferredPadding = settings.value(QStringLiteral("prefpad"), 0).toUInt(); settings.endGroup(); settings.endGroup(); settings.beginGroup(QStringLiteral("mainwindow")); - mainWindowGeometry() = settings.value(QStringLiteral("geometry")).toByteArray(); - mainWindowState() = settings.value(QStringLiteral("windowstate")).toByteArray(); - mainWindowCurrentFileBrowserDirectory() = settings.value(QStringLiteral("currentfilebrowserdirectory")).toString(); - mainWindowLayoutLocked() = settings.value(QStringLiteral("layoutlocked"), mainWindowLayoutLocked()).toBool(); + v.mainWindow.geometry = settings.value(QStringLiteral("geometry")).toByteArray(); + v.mainWindow.state = settings.value(QStringLiteral("windowstate")).toByteArray(); + v.mainWindow.currentFileBrowserDirectory = settings.value(QStringLiteral("currentfilebrowserdirectory")).toString(); + v.mainWindow.layoutLocked = settings.value(QStringLiteral("layoutlocked"), v.mainWindow.layoutLocked).toBool(); settings.endGroup(); settings.beginGroup(QStringLiteral("dbquery")); - dbQueryWidgetShown() = settings.value(QStringLiteral("visible"), false).toBool(); - dbQueryOverride() = settings.value(QStringLiteral("override"), true).toBool(); - dbQueryFields().restore(settings, QStringLiteral("fields")); - musicBrainzUrl() = settings.value(QStringLiteral("musicbrainzurl")).toString(); - coverArtArchiveUrl() = settings.value(QStringLiteral("coverartarchiveurl")).toString(); + v.dbQuery.widgetShown = settings.value(QStringLiteral("visible"), false).toBool(); + v.dbQuery.override = settings.value(QStringLiteral("override"), true).toBool(); + v.dbQuery.fields.restore(settings, QStringLiteral("fields")); + v.dbQuery.musicBrainzUrl = settings.value(QStringLiteral("musicbrainzurl")).toString(); + v.dbQuery.coverArtArchiveUrl = settings.value(QStringLiteral("coverartarchiveurl")).toString(); settings.endGroup(); settings.beginGroup(QStringLiteral("renamedlg")); - scriptSource() = settings.value(QStringLiteral("src")).toInt(); - externalScript() = settings.value(QStringLiteral("file")).toString(); - editorScript() = settings.value(QStringLiteral("script")).toString(); + v.renamingUtility.scriptSource = settings.value(QStringLiteral("src")).toInt(); + v.renamingUtility.externalScript = settings.value(QStringLiteral("file")).toString(); + v.renamingUtility.editorScript = settings.value(QStringLiteral("script")).toString(); settings.endGroup(); - qtSettings().restore(settings); + v.qt.restore(settings); } void save() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()); + const Settings &v = values(); settings.beginGroup(QStringLiteral("editor")); - settings.setValue(QStringLiteral("adoptfields"), static_cast(adoptFields())); - settings.setValue(QStringLiteral("saveandshownextonenter"), saveAndShowNextOnEnter()); - settings.setValue(QStringLiteral("askbeforedeleting"), askBeforeDeleting()); - settings.setValue(QStringLiteral("multipletaghandling"), static_cast(multipleTagHandling())); - settings.setValue(QStringLiteral("hidetagselectioncombobox"), hideTagSelectionComboBox()); + settings.setValue(QStringLiteral("adoptfields"), static_cast(v.editor.adoptFields)); + settings.setValue(QStringLiteral("saveandshownextonenter"), v.editor.saveAndShowNextOnEnter); + settings.setValue(QStringLiteral("askbeforedeleting"), v.editor.askBeforeDeleting); + settings.setValue(QStringLiteral("multipletaghandling"), static_cast(v.editor.multipleTagHandling)); + settings.setValue(QStringLiteral("hidetagselectioncombobox"), v.editor.hideTagSelectionComboBox); settings.beginGroup(QStringLiteral("autocorrection")); - settings.setValue(QStringLiteral("inserttitlefromfilename"), Settings::insertTitleFromFilename()); - settings.setValue(QStringLiteral("trimwhitespaces"), Settings::trimWhitespaces()); - settings.setValue(QStringLiteral("formatnames"), Settings::formatNames()); - settings.setValue(QStringLiteral("fixumlauts"), Settings::fixUmlauts()); + settings.setValue(QStringLiteral("inserttitlefromfilename"), v.editor.autoCompletition.insertTitleFromFilename); + settings.setValue(QStringLiteral("trimwhitespaces"), v.editor.autoCompletition.trimWhitespaces); + settings.setValue(QStringLiteral("formatnames"), v.editor.autoCompletition.formatNames); + settings.setValue(QStringLiteral("fixumlauts"), v.editor.autoCompletition.fixUmlauts); settings.endGroup(); settings.setValue(QStringLiteral("tempdir"), QString::fromStdString(BackupHelper::backupDirectory())); - settings.setValue(QStringLiteral("hidecoverbtn"), Settings::hideCoverButtons()); + settings.setValue(QStringLiteral("hidecoverbtn"), v.editor.hideCoverButtons); settings.endGroup(); - selectedFieldsModel().save(settings, QStringLiteral("selectedfields")); - - autoCorrectionFields().save(settings, QStringLiteral("autocorrectionfields")); + v.editor.fields.save(settings, QStringLiteral("selectedfields")); + v.editor.autoCompletition.fields.save(settings, QStringLiteral("autocorrectionfields")); settings.beginGroup(QStringLiteral("info")); - settings.setValue(QStringLiteral("forcefullparse"), Settings::forceFullParse()); + settings.setValue(QStringLiteral("forcefullparse"), v.editor.forceFullParse); #ifndef TAGEDITOR_NO_WEBVIEW - settings.setValue(QStringLiteral("nowebview"), Settings::noWebView()); + settings.setValue(QStringLiteral("nowebview"), v.editor.noWebView); #endif settings.endGroup(); settings.beginGroup(QStringLiteral("filebrowser")); - settings.setValue(QStringLiteral("hidebackupfiles"), hideBackupFiles()); - settings.setValue(QStringLiteral("readonly"), fileBrowserReadOnly()); + settings.setValue(QStringLiteral("hidebackupfiles"), v.fileBrowser.hideBackupFiles); + settings.setValue(QStringLiteral("readonly"), v.fileBrowser.readOnly); settings.endGroup(); settings.beginGroup(QStringLiteral("tagprocessing")); - settings.setValue(QStringLiteral("preferredencoding"), static_cast(preferredEncoding())); - settings.setValue(QStringLiteral("unsupportedfieldhandling"), static_cast(unsupportedFieldHandling())); - settings.setValue(QStringLiteral("autotagmanagement"), autoTagManagement()); + settings.setValue(QStringLiteral("preferredencoding"), static_cast(v.tagPocessing.preferredEncoding)); + settings.setValue(QStringLiteral("unsupportedfieldhandling"), static_cast(v.tagPocessing.unsupportedFieldHandling)); + settings.setValue(QStringLiteral("autotagmanagement"), v.tagPocessing.autoTagManagement); settings.beginGroup(QStringLiteral("id3v1")); - settings.setValue(QStringLiteral("usage"), static_cast(id3v1usage())); + settings.setValue(QStringLiteral("usage"), static_cast(v.tagPocessing.id3.v1Usage)); settings.endGroup(); settings.beginGroup(QStringLiteral("id3v2")); - settings.setValue(QStringLiteral("usage"), static_cast(id3v2usage())); - settings.setValue(QStringLiteral("versiontobeused"), id3v2versionToBeUsed()); - settings.setValue(QStringLiteral("keepversionofexistingtag"), keepVersionOfExistingId3v2Tag()); - settings.setValue(QStringLiteral("mergemultiplesuccessivetags"), mergeMultipleSuccessiveId3v2Tags()); + settings.setValue(QStringLiteral("usage"), static_cast(v.tagPocessing.id3.v2Usage)); + settings.setValue(QStringLiteral("versiontobeused"), v.tagPocessing.id3.v2Version); + settings.setValue(QStringLiteral("keepversionofexistingtag"), v.tagPocessing.id3.keepVersionOfExistingId3v2Tag); + settings.setValue(QStringLiteral("mergemultiplesuccessivetags"), v.tagPocessing.id3.mergeMultipleSuccessiveId3v2Tags); settings.endGroup(); - defaultTargetsModel().save(settings, QStringLiteral("targets")); + v.editor.defaultTargets.save(settings, QStringLiteral("targets")); settings.beginGroup(QStringLiteral("filelayout")); - settings.setValue(QStringLiteral("forcerewrite"), forceRewrite()); - settings.setValue(QStringLiteral("tagpos"), static_cast(preferredTagPosition())); - settings.setValue(QStringLiteral("forcetagpos"), forceTagPosition()); - settings.setValue(QStringLiteral("indexpos"), static_cast(preferredIndexPosition())); - settings.setValue(QStringLiteral("forceindexpos"), forceIndexPosition()); - settings.setValue(QStringLiteral("minpad"), QVariant::fromValue(minPadding())); - settings.setValue(QStringLiteral("maxpad"), QVariant::fromValue(maxPadding())); - settings.setValue(QStringLiteral("prefpad"), QVariant::fromValue(preferredPadding())); + settings.setValue(QStringLiteral("forcerewrite"), v.tagPocessing.fileLayout.forceRewrite); + settings.setValue(QStringLiteral("tagpos"), static_cast(v.tagPocessing.fileLayout.preferredTagPosition)); + settings.setValue(QStringLiteral("forcetagpos"), v.tagPocessing.fileLayout.forceTagPosition); + settings.setValue(QStringLiteral("indexpos"), static_cast(v.tagPocessing.fileLayout.preferredIndexPosition)); + settings.setValue(QStringLiteral("forceindexpos"), v.tagPocessing.fileLayout.forceIndexPosition); + settings.setValue(QStringLiteral("minpad"), QVariant::fromValue(v.tagPocessing.fileLayout.minPadding)); + settings.setValue(QStringLiteral("maxpad"), QVariant::fromValue(v.tagPocessing.fileLayout.maxPadding)); + settings.setValue(QStringLiteral("prefpad"), QVariant::fromValue(v.tagPocessing.fileLayout.preferredPadding)); settings.endGroup(); settings.endGroup(); settings.beginGroup(QStringLiteral("mainwindow")); - settings.setValue(QStringLiteral("geometry"), mainWindowGeometry()); - settings.setValue(QStringLiteral("windowstate"), mainWindowState()); - settings.setValue(QStringLiteral("currentfilebrowserdirectory"), mainWindowCurrentFileBrowserDirectory()); - settings.setValue(QStringLiteral("layoutlocked"), mainWindowLayoutLocked()); + settings.setValue(QStringLiteral("geometry"), v.mainWindow.geometry); + settings.setValue(QStringLiteral("windowstate"), v.mainWindow.state); + settings.setValue(QStringLiteral("currentfilebrowserdirectory"), v.mainWindow.currentFileBrowserDirectory); + settings.setValue(QStringLiteral("layoutlocked"), v.mainWindow.layoutLocked); settings.endGroup(); settings.beginGroup(QStringLiteral("dbquery")); - settings.setValue(QStringLiteral("visible"), dbQueryWidgetShown()); - settings.setValue(QStringLiteral("override"), dbQueryOverride()); - dbQueryFields().save(settings, QStringLiteral("fields")); - settings.setValue(QStringLiteral("musicbrainzurl"), musicBrainzUrl()); - settings.setValue(QStringLiteral("coverartarchiveurl"), coverArtArchiveUrl()); + settings.setValue(QStringLiteral("visible"), v.dbQuery.widgetShown); + settings.setValue(QStringLiteral("override"), v.dbQuery.override); + v.dbQuery.fields.save(settings, QStringLiteral("fields")); + settings.setValue(QStringLiteral("musicbrainzurl"), v.dbQuery.musicBrainzUrl); + settings.setValue(QStringLiteral("coverartarchiveurl"), v.dbQuery.coverArtArchiveUrl); settings.endGroup(); settings.beginGroup(QStringLiteral("renamedlg")); - settings.setValue(QStringLiteral("src"), Settings::scriptSource()); - settings.setValue(QStringLiteral("file"), Settings::externalScript()); - settings.setValue(QStringLiteral("script"), Settings::editorScript()); + settings.setValue(QStringLiteral("src"), v.renamingUtility.scriptSource); + settings.setValue(QStringLiteral("file"), v.renamingUtility.externalScript); + settings.setValue(QStringLiteral("script"), v.renamingUtility.editorScript); settings.endGroup(); - qtSettings().save(settings); + v.qt.save(settings); } } diff --git a/application/settings.h b/application/settings.h index 957de5b..b8114d8 100644 --- a/application/settings.h +++ b/application/settings.h @@ -1,27 +1,22 @@ #ifndef SETTINGS_H #define SETTINGS_H +#include "./targetlevelmodel.h" +#include "./knownfieldmodel.h" + #include #include +#include +#include -#include +#include -QT_FORWARD_DECLARE_CLASS(QByteArray) -QT_FORWARD_DECLARE_CLASS(QString) - -namespace Media { -enum class TagUsage; -enum class ElementPosition; -} - -namespace Dialogs { -class QtSettings; -} +#include +#include namespace Settings { -// general enum class ActionEnabled { Ask, @@ -29,97 +24,127 @@ enum class ActionEnabled No }; -// editor enum class AdoptFields { Never, WithinDirectory, Always }; -AdoptFields &adoptFields(); -bool &saveAndShowNextOnEnter(); -bool &askBeforeDeleting(); + enum class MultipleTagHandling { SingleEditorPerTarget, SeparateEditors }; -MultipleTagHandling &multipleTagHandling(); -bool &hideTagSelectionComboBox(); -bool &forceFullParse(); + +struct AutoCompletition +{ + AutoCompletition(); + bool insertTitleFromFilename = false; + bool trimWhitespaces = true; + bool formatNames = false; + bool fixUmlauts = false; + KnownFieldModel fields; +}; + +struct Editor +{ + Editor(); + AdoptFields adoptFields = AdoptFields::Never; + bool saveAndShowNextOnEnter = false; + bool askBeforeDeleting = true; + MultipleTagHandling multipleTagHandling = MultipleTagHandling::SingleEditorPerTarget; + bool hideTagSelectionComboBox = false; + bool forceFullParse = false; #ifndef TAGEDITOR_NO_WEBVIEW -bool &noWebView(); + bool noWebView = false; #endif -bool &hideCoverButtons(); + bool hideCoverButtons = false; + AutoCompletition autoCompletition; + KnownFieldModel fields; + TargetLevelModel defaultTargets; +}; -// file browser -bool &hideBackupFiles(); -bool &fileBrowserReadOnly(); - -// general tag processing -Media::TagTextEncoding &preferredEncoding(); enum class UnsupportedFieldHandling { Ignore, Discard }; -UnsupportedFieldHandling &unsupportedFieldHandling(); -bool &autoTagManagement(); -// ID3 tag processing -Media::TagUsage &id3v1usage(); -Media::TagUsage &id3v2usage(); -byte &id3v2versionToBeUsed(); -bool &keepVersionOfExistingId3v2Tag(); -bool &mergeMultipleSuccessiveId3v2Tags(); +struct FileBrowser +{ + bool hideBackupFiles = true; + bool readOnly = true; +}; -// file layout -bool &forceRewrite(); -Media::ElementPosition &preferredTagPosition(); -bool &forceTagPosition(); -Media::ElementPosition &preferredIndexPosition(); -bool &forceIndexPosition(); -size_t &minPadding(); -size_t &maxPadding(); -size_t &preferredPadding(); +struct Id3Processing +{ + Media::TagUsage v1Usage = Media::TagUsage::Always; + Media::TagUsage v2Usage = Media::TagUsage::Always; + byte v2Version = 3; + bool keepVersionOfExistingId3v2Tag = true; + bool mergeMultipleSuccessiveId3v2Tags = true; +}; -// targets -class TargetLevelModel; -TargetLevelModel &defaultTargetsModel(); +struct FileLayout +{ + bool forceRewrite = true; + Media::ElementPosition preferredTagPosition = Media::ElementPosition::BeforeData; + bool forceTagPosition = true; + Media::ElementPosition preferredIndexPosition = Media::ElementPosition::BeforeData; + bool forceIndexPosition = true; + std::size_t minPadding = 0; + std::size_t maxPadding = 0; + std::size_t preferredPadding = 0; +}; -// fields -class KnownFieldModel; -KnownFieldModel &selectedFieldsModel(); +struct TagProcessing +{ + Media::TagTextEncoding preferredEncoding = Media::TagTextEncoding::Utf8; + UnsupportedFieldHandling unsupportedFieldHandling = UnsupportedFieldHandling::Ignore; + bool autoTagManagement = true; + Id3Processing id3; + FileLayout fileLayout; +}; -// auto correction/completition -bool &insertTitleFromFilename(); -bool &trimWhitespaces(); -bool &formatNames(); -bool &fixUmlauts(); -KnownFieldModel &autoCorrectionFields(); +struct MainWindow +{ + QByteArray geometry; + QByteArray state; + QString currentFileBrowserDirectory; + bool layoutLocked = false; +}; -// main window -QByteArray &mainWindowGeometry(); -QByteArray &mainWindowState(); -QString &mainWindowCurrentFileBrowserDirectory(); -bool &mainWindowLayoutLocked(); +struct DbQuery +{ + DbQuery(); + bool widgetShown = false; + bool override = false; + KnownFieldModel fields; + QString musicBrainzUrl; + QString coverArtArchiveUrl; + QString lyricsWikiaUrl; +}; -// db query -bool &dbQueryWidgetShown(); -bool &dbQueryOverride(); -KnownFieldModel &dbQueryFields(); -QString &musicBrainzUrl(); -QString &coverArtArchiveUrl(); -QString &lyricsWikiaUrl(); +struct RenamingUtility +{ + int scriptSource = 0; + QString externalScript; + QString editorScript; +}; -// rename files dialog -int &scriptSource(); -QString &externalScript(); -QString &editorScript(); - -// Qt settings -Dialogs::QtSettings &qtSettings(); +struct Settings +{ + Editor editor; + FileBrowser fileBrowser; + TagProcessing tagPocessing; + MainWindow mainWindow; + DbQuery dbQuery; + RenamingUtility renamingUtility; + Dialogs::QtSettings qt; +}; +Settings &values(); void restore(); void save(); diff --git a/dbquery/dbquery.h b/dbquery/dbquery.h index d13d263..0ae0a79 100644 --- a/dbquery/dbquery.h +++ b/dbquery/dbquery.h @@ -57,11 +57,11 @@ public: bool isFetchingCover() const; Media::TagValue fieldValue(int row, Media::KnownField knownField) const; - QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; const QByteArray *cover(const QModelIndex &index) const; virtual bool fetchCover(const QModelIndex &index); const QString *lyrics(const QModelIndex &index) const; diff --git a/dbquery/lyricswikia.cpp b/dbquery/lyricswikia.cpp index 9f80aca..b4caef1 100644 --- a/dbquery/lyricswikia.cpp +++ b/dbquery/lyricswikia.cpp @@ -19,6 +19,12 @@ namespace QtGui { static const QString defaultLyricsWikiaUrl(QStringLiteral("https://lyrics.wikia.com")); +QUrl lyricsWikiaApiUrl() +{ + const QString &lyricsWikiaUrl = Settings::values().dbQuery.lyricsWikiaUrl; + return QUrl((lyricsWikiaUrl.isEmpty() ? defaultLyricsWikiaUrl : lyricsWikiaUrl) + QStringLiteral("/api.php")); +} + LyricsWikiaResultsModel::LyricsWikiaResultsModel(SongDescription &&initialSongDescription, QNetworkReply *reply) : HttpResultsModel(move(initialSongDescription), reply) {} @@ -117,7 +123,6 @@ void LyricsWikiaResultsModel::parseInitialResults(const QByteArray &data) QNetworkReply *LyricsWikiaResultsModel::requestSongDetails(const SongDescription &songDescription) { // compose URL - QUrl url((Settings::lyricsWikiaUrl().isEmpty() ? defaultLyricsWikiaUrl : Settings::lyricsWikiaUrl()) + QStringLiteral("/api.php")); QUrlQuery query; query.addQueryItem(QStringLiteral("func"), QStringLiteral("getSong")); query.addQueryItem(QStringLiteral("action"), QStringLiteral("lyrics")); @@ -129,6 +134,7 @@ QNetworkReply *LyricsWikiaResultsModel::requestSongDetails(const SongDescription // specifying album seems to have no effect but also don't hurt query.addQueryItem(QStringLiteral("album"), songDescription.album); } + QUrl url(lyricsWikiaApiUrl()); url.setQuery(query); return Utility::networkAccessManager().get(QNetworkRequest(url)); @@ -202,7 +208,7 @@ void LyricsWikiaResultsModel::parseSongDetails(int row, const QByteArray &data) return; } // do not use parsed URL directly to avoid unintended requests - QUrl requestUrl(Settings::lyricsWikiaUrl().isEmpty() ? defaultLyricsWikiaUrl : Settings::lyricsWikiaUrl()); + QUrl requestUrl(lyricsWikiaApiUrl()); requestUrl.setPath(parsedUrl.path()); auto *reply = Utility::networkAccessManager().get(QNetworkRequest(parsedUrl)); addReply(reply, bind(&LyricsWikiaResultsModel::handleLyricsReplyFinished, this, reply, row)); @@ -250,12 +256,12 @@ void LyricsWikiaResultsModel::parseLyricsResults(int row, const QByteArray &data QueryResultsModel *queryLyricsWikia(SongDescription &&songDescription) { // compose URL - QUrl url((Settings::lyricsWikiaUrl().isEmpty() ? defaultLyricsWikiaUrl : Settings::lyricsWikiaUrl()) + QStringLiteral("/api.php")); QUrlQuery query; query.addQueryItem(QStringLiteral("func"), QStringLiteral("getArtist")); query.addQueryItem(QStringLiteral("fmt"), QStringLiteral("xml")); query.addQueryItem(QStringLiteral("fixXML"), QString()); query.addQueryItem(QStringLiteral("artist"), songDescription.artist); + QUrl url(lyricsWikiaApiUrl()); url.setQuery(query); // NOTE: Only getArtist seems to work, so artist must be specified and filtering must diff --git a/dbquery/musicbrainz.cpp b/dbquery/musicbrainz.cpp index 81090cb..659841e 100644 --- a/dbquery/musicbrainz.cpp +++ b/dbquery/musicbrainz.cpp @@ -206,7 +206,8 @@ QueryResultsModel *queryMusicBrainz(SongDescription &&songDescription) } // compose URL - QUrl url(Settings::musicBrainzUrl().isEmpty() ? defaultMusicBrainzUrl : (Settings::musicBrainzUrl() + QStringLiteral("/recording/"))); + const QString &musicBrainzUrl = Settings::values().dbQuery.musicBrainzUrl; + QUrl url(musicBrainzUrl.isEmpty() ? defaultMusicBrainzUrl : (musicBrainzUrl + QStringLiteral("/recording/"))); QUrlQuery query; query.addQueryItem(QStringLiteral("query"), parts.join(QStringLiteral(" AND "))); url.setQuery(query); @@ -218,7 +219,8 @@ QueryResultsModel *queryMusicBrainz(SongDescription &&songDescription) QNetworkReply *queryCoverArtArchive(const QString &albumId) { static const QString defaultArchiveUrl(QStringLiteral("https://coverartarchive.org")); - return networkAccessManager().get(QNetworkRequest(QUrl((Settings::coverArtArchiveUrl().isEmpty() ? defaultArchiveUrl : Settings::coverArtArchiveUrl()) % QStringLiteral("/release/") % albumId % QStringLiteral("/front")))); + const QString &coverArtArchiveUrl = Settings::values().dbQuery.coverArtArchiveUrl; + return networkAccessManager().get(QNetworkRequest(QUrl((coverArtArchiveUrl.isEmpty() ? defaultArchiveUrl : coverArtArchiveUrl) % QStringLiteral("/release/") % albumId % QStringLiteral("/front")))); } } // namespace QtGui diff --git a/gui/dbquerywidget.cpp b/gui/dbquerywidget.cpp index 47f9080..f9cdde8 100644 --- a/gui/dbquerywidget.cpp +++ b/gui/dbquerywidget.cpp @@ -22,6 +22,10 @@ #include #include +#include + +using namespace std; +using namespace std::placeholders; using namespace ConversionUtilities; using namespace Dialogs; using namespace Models; @@ -56,13 +60,13 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent) m_ui->applyPushButton->setIcon(style()->standardIcon(QStyle::SP_DialogApplyButton, nullptr, m_ui->applyPushButton)); // initialize fields model - m_ui->fieldsListView->setModel(&Settings::dbQueryFields()); + m_ui->fieldsListView->setModel(&values().dbQuery.fields); // initialize search terms form insertSearchTermsFromTagEdit(m_tagEditorWidget->activeTagEdit()); // restore settings - m_ui->overrideCheckBox->setChecked(Settings::dbQueryOverride()); + m_ui->overrideCheckBox->setChecked(values().dbQuery.override); // setup menu m_insertPresentDataAction = m_menu->addAction(tr("Insert present data")); @@ -78,14 +82,14 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent) connect(m_ui->abortPushButton, &QPushButton::clicked, this, &DbQueryWidget::abortSearch); connect(m_ui->searchMusicBrainzPushButton, &QPushButton::clicked, this, &DbQueryWidget::searchMusicBrainz); connect(m_ui->searchLyricsWikiaPushButton, &QPushButton::clicked, this, &DbQueryWidget::searchLyricsWikia); - connect(m_ui->applyPushButton, &QPushButton::clicked, this, &DbQueryWidget::applyResults); + connect(m_ui->applyPushButton, &QPushButton::clicked, this, static_cast(&DbQueryWidget::applySelectedResults)); connect(m_tagEditorWidget, &TagEditorWidget::fileStatusChanged, this, &DbQueryWidget::fileStatusChanged); connect(m_ui->resultsTreeView, &QTreeView::customContextMenuRequested, this, &DbQueryWidget::showResultsContextMenu); } DbQueryWidget::~DbQueryWidget() { - Settings::dbQueryOverride() = m_ui->overrideCheckBox->isChecked(); + values().dbQuery.override = m_ui->overrideCheckBox->isChecked(); } void DbQueryWidget::insertSearchTermsFromTagEdit(TagEdit *tagEdit) @@ -239,80 +243,156 @@ void DbQueryWidget::fileStatusChanged(bool, bool hasTags) m_insertPresentDataAction->setEnabled(hasTags); } -void DbQueryWidget::applyResults() +/*! + * \brief Applies the selected results for the selected fields to the active tag edit. + * \sa applyResults() + */ +void DbQueryWidget::applySelectedResults() { // check whether model, tag edit and current selection exist + if(TagEdit *tagEdit = m_tagEditorWidget->activeTagEdit()) { + if(const QItemSelectionModel *selectionModel = m_ui->resultsTreeView->selectionModel()) { + const QModelIndexList selection = selectionModel->selection().indexes(); + if(!selection.isEmpty()) { + applyResults(tagEdit, selection.front()); + } + } + } +} + +/*! + * \brief Completes all present tag edits with the best matching result row. + * \remarks + * - Does nothing if no result row matches. + * - Only the selected fields are applied. + * \sa applyResults() + */ +void DbQueryWidget::applyMatchingResults() +{ + m_tagEditorWidget->foreachTagEdit(bind(static_cast(&DbQueryWidget::applyMatchingResults), this, _1)); +} + +/*! + * \brief Completes the specified \a tagEdit with the best matching result row. + * \remarks + * - Does nothing if no result row matches. + * - Only the selected fields are applied. + * \sa applyResults() + */ +void DbQueryWidget::applyMatchingResults(TagEdit *tagEdit) +{ + // determine already present title, album and artist + const TagValue givenTitle = tagEdit->value(KnownField::Title); + const TagValue givenAlbum = tagEdit->value(KnownField::Album); + const TagValue givenArtist = tagEdit->value(KnownField::Artist); + + // also determine already present track number (which is a little bit more complex -> TODO: improve backend API) + int givenTrack; + try { + givenTrack = tagEdit->value(KnownField::TrackPosition).toPositionInSet().position(); + } catch (const ConversionException &) { + } + if(!givenTrack) { + for(const Tag *tag : tagEdit->tags()) { + if(!tag->supportsTarget() || tag->targetLevel() == TagTargetLevel::Track) { + try { + givenTrack = tagEdit->value(KnownField::PartNumber).toInteger(); + } catch (const ConversionException &) { + } + break; + } + } + } + + // find row matching already present data + for(int row = 0, rowCount = m_model->rowCount(); row != rowCount; ++row) { + if((!givenTitle.isEmpty() && givenTitle != m_model->fieldValue(row, KnownField::Title)) + || (!givenAlbum.isEmpty() && givenAlbum != m_model->fieldValue(row, KnownField::Album)) + || (!givenArtist.isEmpty() && givenArtist != m_model->fieldValue(row, KnownField::Artist)) + || (givenTrack && m_model->data(m_model->index(row, QueryResultsModel::TitleCol)).toInt())) { + continue; + } + + // apply results for matching row + applyResults(tagEdit, m_model->index(row, 0)); + + // just take the first matching row for now + break; + } +} + +/*! + * \brief Applies the results at the specified \a resultIndex for the selected fields to the specified \a tagEdit. + * \remarks + * - Returns instantly. If cover/lyrics need to be retrieved, this is done asynchronously. + * - Does nothing if no results are available. + */ +void DbQueryWidget::applyResults(TagEdit *tagEdit, const QModelIndex &resultIndex) +{ if(m_model) { - if(TagEdit *tagEdit = m_tagEditorWidget->activeTagEdit()) { - if(const QItemSelectionModel *selectionModel = m_ui->resultsTreeView->selectionModel()) { - const QModelIndexList selection = selectionModel->selection().indexes(); - if(!selection.isEmpty()) { - // determine previous value handling - PreviousValueHandling previousValueHandling = m_ui->overrideCheckBox->isChecked() - ? PreviousValueHandling::Update : PreviousValueHandling::Keep; + // determine previous value handling + PreviousValueHandling previousValueHandling = m_ui->overrideCheckBox->isChecked() + ? PreviousValueHandling::Update : PreviousValueHandling::Keep; - // loop through all fields - for(const ChecklistItem &item : Settings::dbQueryFields().items()) { - if(item.isChecked()) { - // field should be used - const auto field = static_cast(item.id().toInt()); - int row = selection.front().row(); - TagValue value = m_model->fieldValue(row, field); + // loop through all fields + for(const ChecklistItem &item : values().dbQuery.fields.items()) { + if(item.isChecked()) { + // field should be used + const auto field = static_cast(item.id().toInt()); + int row = resultIndex.row(); + TagValue value = m_model->fieldValue(row, field); - if(value.isEmpty()) { - // cover and lyrics might be fetched belated - switch(field) { - case KnownField::Cover: - if(m_model->fetchCover(selection.front())) { - // cover is available now + if(value.isEmpty()) { + // cover and lyrics might be fetched belated + switch(field) { + case KnownField::Cover: + if(m_model->fetchCover(resultIndex)) { + // cover is available now + tagEdit->setValue(KnownField::Cover, m_model->fieldValue(row, KnownField::Cover), previousValueHandling); + } else { + // cover is fetched asynchronously + // -> show status + m_ui->notificationLabel->setNotificationType(NotificationType::Progress); + m_ui->notificationLabel->appendLine(tr("Retrieving cover art to be applied ...")); + setStatus(false); + // -> apply cover when available + connect(m_model, &QueryResultsModel::coverAvailable, [this, row, previousValueHandling](const QModelIndex &index) { + if(row == index.row()) { + if(TagEdit *tagEdit = m_tagEditorWidget->activeTagEdit()) { tagEdit->setValue(KnownField::Cover, m_model->fieldValue(row, KnownField::Cover), previousValueHandling); - } else { - // cover is fetched asynchronously - // -> show status - m_ui->notificationLabel->setNotificationType(NotificationType::Progress); - m_ui->notificationLabel->appendLine(tr("Retrieving cover art to be applied ...")); - setStatus(false); - // -> apply cover when available - connect(m_model, &QueryResultsModel::coverAvailable, [this, row, previousValueHandling](const QModelIndex &index) { - if(row == index.row()) { - if(TagEdit *tagEdit = m_tagEditorWidget->activeTagEdit()) { - tagEdit->setValue(KnownField::Cover, m_model->fieldValue(row, KnownField::Cover), previousValueHandling); - } - } - }); } - break; - - case KnownField::Lyrics: - if(m_model->fetchLyrics(selection.front())) { - // lyrics are available now - tagEdit->setValue(KnownField::Lyrics, m_model->fieldValue(row, KnownField::Lyrics), previousValueHandling); - } else { - // lyrics are fetched asynchronously - // -> show status - m_ui->notificationLabel->setNotificationType(NotificationType::Progress); - m_ui->notificationLabel->appendLine(tr("Retrieving lyrics to be applied ...")); - setStatus(false); - // -> apply cover when available - connect(m_model, &QueryResultsModel::lyricsAvailable, [this, row, previousValueHandling](const QModelIndex &index) { - if(row == index.row()) { - if(TagEdit *tagEdit = m_tagEditorWidget->activeTagEdit()) { - tagEdit->setValue(KnownField::Lyrics, m_model->fieldValue(row, KnownField::Lyrics), previousValueHandling); - } - } - }); - } - break; - - default: - ; } - } else { - // any other fields are just set - tagEdit->setValue(field, value, previousValueHandling); - } + }); } + break; + + case KnownField::Lyrics: + if(m_model->fetchLyrics(resultIndex)) { + // lyrics are available now + tagEdit->setValue(KnownField::Lyrics, m_model->fieldValue(row, KnownField::Lyrics), previousValueHandling); + } else { + // lyrics are fetched asynchronously + // -> show status + m_ui->notificationLabel->setNotificationType(NotificationType::Progress); + m_ui->notificationLabel->appendLine(tr("Retrieving lyrics to be applied ...")); + setStatus(false); + // -> apply cover when available + connect(m_model, &QueryResultsModel::lyricsAvailable, [this, row, previousValueHandling](const QModelIndex &index) { + if(row == index.row()) { + if(TagEdit *tagEdit = m_tagEditorWidget->activeTagEdit()) { + tagEdit->setValue(KnownField::Lyrics, m_model->fieldValue(row, KnownField::Lyrics), previousValueHandling); + } + } + }); + } + break; + + default: + ; } + } else { + // any other fields are just set + tagEdit->setValue(field, value, previousValueHandling); } } } diff --git a/gui/dbquerywidget.h b/gui/dbquerywidget.h index fdfd22c..7365a4a 100644 --- a/gui/dbquerywidget.h +++ b/gui/dbquerywidget.h @@ -34,12 +34,15 @@ public: void insertSearchTermsFromTagEdit(TagEdit *tagEdit); SongDescription currentSongDescription() const; + void applyResults(TagEdit *tagEdit, const QModelIndex &resultIndex); public slots: void searchMusicBrainz(); void searchLyricsWikia(); void abortSearch(); - void applyResults(); + void applySelectedResults(); + void applyMatchingResults(); + void applyMatchingResults(TagEdit *tagEdit); void insertSearchTermsFromActiveTagEdit(); void clearSearchCriteria(); diff --git a/gui/initiate.cpp b/gui/initiate.cpp index f4ebf92..c4ce367 100644 --- a/gui/initiate.cpp +++ b/gui/initiate.cpp @@ -23,8 +23,8 @@ int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, QApplication a(argc, argv); Settings::restore(); // apply settings specified via command line args after the settings chosen in the GUI to give the CLI options precedence - Settings::qtSettings().apply(); - qtConfigArgs.applySettings(Settings::qtSettings().hasCustomFont()); + Settings::values().qt.apply(); + qtConfigArgs.applySettings(Settings::values().qt.hasCustomFont()); // load resources needed by classes of qtutilities QtUtilitiesResources::init(); LOAD_QT_TRANSLATIONS; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 52427f6..d58379e 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -88,8 +88,9 @@ MainWindow::MainWindow(QWidget *parent) : #endif // restore geometry and state - restoreGeometry(Settings::mainWindowGeometry()); - restoreState(Settings::mainWindowState()); + const auto &settings = Settings::values(); + restoreGeometry(settings.mainWindow.geometry); + restoreState(settings.mainWindow.state); // setup file model and file tree view m_fileModel = new QFileSystemModel(this); @@ -97,7 +98,7 @@ MainWindow::MainWindow(QWidget *parent) : m_fileFilterModel = new FileFilterProxyModel(this); m_fileFilterModel->setExtensionsToBeFiltered(QStringList() << QStringLiteral("bak") << QStringLiteral("tmp")); m_fileFilterModel->setSourceModel(m_fileModel); - m_fileFilterModel->setFilterEnabled(Settings::hideBackupFiles()); + m_fileFilterModel->setFilterEnabled(settings.fileBrowser.hideBackupFiles); m_ui->filesTreeView->sortByColumn(0, Qt::AscendingOrder); m_ui->filesTreeView->setModel(m_fileFilterModel); m_ui->filesTreeView->setColumnWidth(0, 300); @@ -109,12 +110,12 @@ MainWindow::MainWindow(QWidget *parent) : handleFileStatusChange(false, false); // dbquery dock widget - if(Settings::dbQueryWidgetShown()) { + if(settings.dbQuery.widgetShown) { m_ui->dbQueryDockWidget->setWidget(m_dbQueryWidget = new DbQueryWidget(m_ui->tagEditorWidget, this)); } // restore locked - setLayoutLocked(Settings::mainWindowLayoutLocked()); + setLayoutLocked(settings.mainWindow.layoutLocked); // connect signals and slots, install event filter // menu: application @@ -147,7 +148,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_ui->filesTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::fileSelected); connect(m_ui->selectNextCommandLinkButton, &QCommandLinkButton::clicked, this, static_cast(&MainWindow::selectNextFile)); // apply settings - setCurrentDirectory(Settings::mainWindowCurrentFileBrowserDirectory()); + setCurrentDirectory(settings.mainWindow.currentFileBrowserDirectory); applySettingsFromDialog(); } @@ -222,14 +223,15 @@ void MainWindow::startParsing(const QString &path) */ bool MainWindow::event(QEvent *event) { + auto &settings = Settings::values(); switch(event->type()) { case QEvent::Close: // save settings - Settings::mainWindowGeometry() = saveGeometry(); - Settings::mainWindowState() = saveState(); - Settings::mainWindowCurrentFileBrowserDirectory() = currentDirectory(); - Settings::mainWindowLayoutLocked() = isLayoutLocked(); - Settings::dbQueryWidgetShown() = m_ui->dbQueryDockWidget->isVisible(); + settings.mainWindow.geometry = saveGeometry(); + settings.mainWindow.state = saveState(); + settings.mainWindow.currentFileBrowserDirectory = currentDirectory(); + settings.mainWindow.layoutLocked = isLayoutLocked(); + settings.dbQuery.widgetShown = m_ui->dbQueryDockWidget->isVisible(); break; default: ; @@ -542,16 +544,17 @@ void MainWindow::saveFileInformation() */ void MainWindow::applySettingsFromDialog() { - if(m_fileFilterModel->isFilterEnabled() != Settings::hideBackupFiles()) { + auto &settings = Settings::values(); + if(m_fileFilterModel->isFilterEnabled() != settings.fileBrowser.hideBackupFiles) { // check this condition to avoid unnecessary model reset - m_fileFilterModel->setFilterEnabled(Settings::hideBackupFiles()); + m_fileFilterModel->setFilterEnabled(settings.fileBrowser.hideBackupFiles); const QModelIndex index = m_fileFilterModel->mapFromSource(m_fileModel->index(m_ui->pathLineEdit->text())); if(index.isValid()) { m_ui->filesTreeView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select); } } - if(m_fileModel->isReadOnly() != Settings::fileBrowserReadOnly()) { - m_fileModel->setReadOnly(Settings::fileBrowserReadOnly()); + if(m_fileModel->isReadOnly() != settings.fileBrowser.readOnly) { + m_fileModel->setReadOnly(settings.fileBrowser.readOnly); } } diff --git a/gui/picturepreviewselection.cpp b/gui/picturepreviewselection.cpp index 53b5c81..b6733de 100644 --- a/gui/picturepreviewselection.cpp +++ b/gui/picturepreviewselection.cpp @@ -55,7 +55,7 @@ PicturePreviewSelection::PicturePreviewSelection(Tag *tag, KnownField field, QWi m_currentTypeIndex(0) { m_ui->setupUi(this); - m_ui->coverButtonsWidget->setHidden(Settings::hideCoverButtons()); + m_ui->coverButtonsWidget->setHidden(Settings::values().editor.hideCoverButtons); connect(m_ui->addButton, &QPushButton::clicked, this, static_cast(&PicturePreviewSelection::addOfSelectedType)); connect(m_ui->removeButton, &QPushButton::clicked, this, &PicturePreviewSelection::removeSelected); connect(m_ui->extractButton, &QPushButton::clicked, this, &PicturePreviewSelection::extractSelected); @@ -549,7 +549,8 @@ void PicturePreviewSelection::updateDescription(int lastIndex, int newIndex) { TagTextEncoding enc; if(m_tag) { - enc = m_tag->canEncodingBeUsed(Settings::preferredEncoding()) ? Settings::preferredEncoding() : m_tag->proposedTextEncoding(); + TagTextEncoding preferredEncoding = Settings::values().tagPocessing.preferredEncoding; + enc = m_tag->canEncodingBeUsed(preferredEncoding) ? preferredEncoding : m_tag->proposedTextEncoding(); } else { enc = m_values[lastIndex].descriptionEncoding(); } diff --git a/gui/renamefilesdialog.cpp b/gui/renamefilesdialog.cpp index 5c6ce97..b8b0153 100644 --- a/gui/renamefilesdialog.cpp +++ b/gui/renamefilesdialog.cpp @@ -66,12 +66,13 @@ RenameFilesDialog::RenameFilesDialog(QWidget *parent) : m_ui->abortClosePushButton->setIcon(style()->standardIcon(QStyle::SP_DialogCancelButton, nullptr, m_ui->abortClosePushButton)); // restore settings - if(Settings::scriptSource() < m_ui->sourceFileStackedWidget->count()) { - m_ui->sourceFileStackedWidget->setCurrentIndex(Settings::scriptSource()); + const auto &settings = Settings::values().renamingUtility; + if(Settings::values().renamingUtility.scriptSource < m_ui->sourceFileStackedWidget->count()) { + m_ui->sourceFileStackedWidget->setCurrentIndex(settings.scriptSource); } - m_ui->scriptFilePathLineEdit->setText(Settings::externalScript()); - if(!Settings::editorScript().isEmpty()) { - m_ui->javaScriptPlainTextEdit->setPlainText(Settings::editorScript()); + m_ui->scriptFilePathLineEdit->setText(settings.externalScript); + if(!Settings::values().renamingUtility.editorScript.isEmpty()) { + m_ui->javaScriptPlainTextEdit->setPlainText(settings.editorScript); m_scriptModified = true; } else { pasteDefaultExampleScript(); @@ -108,15 +109,16 @@ void RenameFilesDialog::setDirectory(const QString &directory) bool RenameFilesDialog::event(QEvent *event) { + auto &settings = Settings::values().renamingUtility; switch(event->type()) { case QEvent::Close: // save settings - Settings::scriptSource() = m_ui->sourceFileStackedWidget->currentIndex(); - Settings::externalScript() = m_ui->scriptFilePathLineEdit->text(); + settings.scriptSource = m_ui->sourceFileStackedWidget->currentIndex(); + settings.externalScript = m_ui->scriptFilePathLineEdit->text(); if(m_scriptModified) { - Settings::editorScript() = m_ui->javaScriptPlainTextEdit->toPlainText(); + settings.editorScript = m_ui->javaScriptPlainTextEdit->toPlainText(); } else { - Settings::editorScript().clear(); + settings.editorScript.clear(); } break; default: diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index aa1c0ce..f94b436 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -46,18 +46,20 @@ FileBrowserGeneralOptionPage::~FileBrowserGeneralOptionPage() bool FileBrowserGeneralOptionPage::apply() { + auto &settings = values().fileBrowser; if(hasBeenShown()) { - hideBackupFiles() = ui()->hideBackupFilesCheckBox->isChecked(); - fileBrowserReadOnly() = ui()->readOnlyCheckBox->isChecked(); + settings.hideBackupFiles = ui()->hideBackupFilesCheckBox->isChecked(); + settings.readOnly = ui()->readOnlyCheckBox->isChecked(); } return true; } void FileBrowserGeneralOptionPage::reset() { + const auto &settings = values().fileBrowser; if(hasBeenShown()) { - ui()->hideBackupFilesCheckBox->setChecked(hideBackupFiles()); - ui()->readOnlyCheckBox->setChecked(fileBrowserReadOnly()); + ui()->hideBackupFilesCheckBox->setChecked(settings.hideBackupFiles); + ui()->readOnlyCheckBox->setChecked(settings.readOnly); } } @@ -72,22 +74,23 @@ EditorGeneralOptionPage::~EditorGeneralOptionPage() bool EditorGeneralOptionPage::apply() { if(hasBeenShown()) { + auto &settings = values().editor; if(ui()->disableAdoptRadioButton->isChecked()) { - adoptFields() = AdoptFields::Never; + settings.adoptFields = AdoptFields::Never; } else if(ui()->enableWithinDirRadioButton->isChecked()) { - adoptFields() = AdoptFields::WithinDirectory; + settings.adoptFields = AdoptFields::WithinDirectory; } else if(ui()->enableForAllRadioButton->isChecked()) { - adoptFields() = AdoptFields::Always; + settings.adoptFields = AdoptFields::Always; } if(ui()->multipleTagsOneEditorRadioButton->isChecked()) { - multipleTagHandling() = MultipleTagHandling::SingleEditorPerTarget; + settings.multipleTagHandling = MultipleTagHandling::SingleEditorPerTarget; } else if(ui()->multipleTagsSeparateEditorsRadioButton->isChecked()) { - multipleTagHandling() = MultipleTagHandling::SeparateEditors; + settings.multipleTagHandling = MultipleTagHandling::SeparateEditors; } - saveAndShowNextOnEnter() = ui()->nextWhenPressingEnterCheckBox->isChecked(); - askBeforeDeleting() = ui()->askBeforeDeletingCheckBox->isChecked(); - hideTagSelectionComboBox() = ui()->hideTagSelectionComboBoxCheckBox->isChecked(); - hideCoverButtons() = ui()->hideCoverButtonsCheckBox->isChecked(); + settings.saveAndShowNextOnEnter = ui()->nextWhenPressingEnterCheckBox->isChecked(); + settings.askBeforeDeleting = ui()->askBeforeDeletingCheckBox->isChecked(); + settings.hideTagSelectionComboBox = ui()->hideTagSelectionComboBoxCheckBox->isChecked(); + settings.hideCoverButtons = ui()->hideCoverButtonsCheckBox->isChecked(); } return true; } @@ -95,7 +98,8 @@ bool EditorGeneralOptionPage::apply() void EditorGeneralOptionPage::reset() { if(hasBeenShown()) { - switch(adoptFields()) { + const auto &settings = values().editor; + switch(settings.adoptFields) { case AdoptFields::Never: ui()->disableAdoptRadioButton->setChecked(true); break; @@ -106,7 +110,7 @@ void EditorGeneralOptionPage::reset() ui()->enableForAllRadioButton->setChecked(true); break; } - switch(multipleTagHandling()) { + switch(settings.multipleTagHandling) { case MultipleTagHandling::SingleEditorPerTarget: ui()->multipleTagsOneEditorRadioButton->setChecked(true); break; @@ -114,10 +118,10 @@ void EditorGeneralOptionPage::reset() ui()->multipleTagsSeparateEditorsRadioButton->setChecked(true); break; } - ui()->nextWhenPressingEnterCheckBox->setChecked(saveAndShowNextOnEnter()); - ui()->askBeforeDeletingCheckBox->setChecked(askBeforeDeleting()); - ui()->hideTagSelectionComboBoxCheckBox->setChecked(hideTagSelectionComboBox()); - ui()->hideCoverButtonsCheckBox->setChecked(hideCoverButtons()); + ui()->nextWhenPressingEnterCheckBox->setChecked(settings.saveAndShowNextOnEnter); + ui()->askBeforeDeletingCheckBox->setChecked(settings.askBeforeDeleting); + ui()->hideTagSelectionComboBoxCheckBox->setChecked(settings.hideTagSelectionComboBox); + ui()->hideCoverButtonsCheckBox->setChecked(settings.hideCoverButtons); } } @@ -164,7 +168,7 @@ EditorFieldsOptionPage::~EditorFieldsOptionPage() bool EditorFieldsOptionPage::apply() { if(hasBeenShown() && m_model) { - Settings::selectedFieldsModel().setItems(m_model->items()); + values().editor.fields.setItems(m_model->items()); } return true; } @@ -172,7 +176,7 @@ bool EditorFieldsOptionPage::apply() void EditorFieldsOptionPage::reset() { if(hasBeenShown() && m_model) { - m_model->setItems(Settings::selectedFieldsModel().items()); + m_model->setItems(values().editor.fields.items()); } } @@ -198,12 +202,13 @@ EditorAutoCorrectionOptionPage::~EditorAutoCorrectionOptionPage() bool EditorAutoCorrectionOptionPage::apply() { if(hasBeenShown()) { - Settings::insertTitleFromFilename() = ui()->insertTitleFromFilenameCheckBox->isChecked(); - Settings::trimWhitespaces() = ui()->trimWhitespacesCheckBox->isChecked(); - Settings::formatNames() = ui()->formatNamesCheckBox->isChecked(); - Settings::fixUmlauts() = ui()->fixUmlautsCheckBox->isChecked(); + auto &settings = values().editor.autoCompletition; + settings.insertTitleFromFilename = ui()->insertTitleFromFilenameCheckBox->isChecked(); + settings.trimWhitespaces = ui()->trimWhitespacesCheckBox->isChecked(); + settings.formatNames = ui()->formatNamesCheckBox->isChecked(); + settings.fixUmlauts = ui()->fixUmlautsCheckBox->isChecked(); if(m_model) { - Settings::autoCorrectionFields().setItems(m_model->items()); + settings.fields.setItems(m_model->items()); } } return true; @@ -212,12 +217,13 @@ bool EditorAutoCorrectionOptionPage::apply() void EditorAutoCorrectionOptionPage::reset() { if(hasBeenShown()) { - ui()->insertTitleFromFilenameCheckBox->setChecked(Settings::insertTitleFromFilename()); - ui()->trimWhitespacesCheckBox->setChecked(Settings::trimWhitespaces()); - ui()->formatNamesCheckBox->setChecked(Settings::formatNames()); - ui()->fixUmlautsCheckBox->setChecked(Settings::fixUmlauts()); + const auto &settings = values().editor.autoCompletition; + ui()->insertTitleFromFilenameCheckBox->setChecked(settings.insertTitleFromFilename); + ui()->trimWhitespacesCheckBox->setChecked(settings.trimWhitespaces); + ui()->formatNamesCheckBox->setChecked(settings.formatNames); + ui()->fixUmlautsCheckBox->setChecked(settings.fixUmlauts); if(m_model) { - m_model->setItems(Settings::autoCorrectionFields().items()); + m_model->setItems(settings.fields.items()); } } } @@ -243,8 +249,9 @@ EditorDbQueryOptionsPage::~EditorDbQueryOptionsPage() bool EditorDbQueryOptionsPage::apply() { if(hasBeenShown()) { - Settings::musicBrainzUrl() = ui()->musicBrainzUrlLineEdit->text(); - Settings::coverArtArchiveUrl() = ui()->coverArtArchiveUrlLineEdit->text(); + auto &settings = values().dbQuery; + settings.musicBrainzUrl = ui()->musicBrainzUrlLineEdit->text(); + settings.coverArtArchiveUrl = ui()->coverArtArchiveUrlLineEdit->text(); } return true; } @@ -252,8 +259,9 @@ bool EditorDbQueryOptionsPage::apply() void EditorDbQueryOptionsPage::reset() { if(hasBeenShown()) { - ui()->musicBrainzUrlLineEdit->setText(Settings::musicBrainzUrl()); - ui()->coverArtArchiveUrlLineEdit->setText(Settings::coverArtArchiveUrl()); + const auto &settings = values().dbQuery; + ui()->musicBrainzUrlLineEdit->setText(settings.musicBrainzUrl); + ui()->coverArtArchiveUrlLineEdit->setText(settings.coverArtArchiveUrl); } } @@ -268,9 +276,10 @@ InfoOptionPage::~InfoOptionPage() bool InfoOptionPage::apply() { if(hasBeenShown()) { - Settings::forceFullParse() = ui()->forceFullParseCheckBox->isChecked(); + auto &settings = values().editor; + settings.forceFullParse = ui()->forceFullParseCheckBox->isChecked(); #ifndef TAGEDITOR_NO_WEBVIEW - Settings::noWebView() = ui()->noWebViewCheckBox->isChecked(); + settings.noWebView = ui()->noWebViewCheckBox->isChecked(); #endif } return true; @@ -279,12 +288,13 @@ bool InfoOptionPage::apply() void InfoOptionPage::reset() { if(hasBeenShown()) { - ui()->forceFullParseCheckBox->setChecked(Settings::forceFullParse()); + const auto &settings = values().editor; + ui()->forceFullParseCheckBox->setChecked(settings.forceFullParse); #ifdef TAGEDITOR_NO_WEBVIEW ui()->noWebViewCheckBox->setChecked(true); ui()->noWebViewCheckBox->setEnabled(false); #else - ui()->noWebViewCheckBox->setChecked(Settings::noWebView()); + ui()->noWebViewCheckBox->setChecked(settings.noWebView); #endif } } @@ -300,24 +310,25 @@ TagProcessingGeneralOptionPage::~TagProcessingGeneralOptionPage() bool TagProcessingGeneralOptionPage::apply() { if(hasBeenShown()) { + auto &settings = values().tagPocessing; if(ui()->latin1RadioButton->isChecked()) { - preferredEncoding() = TagTextEncoding::Latin1; + settings.preferredEncoding = TagTextEncoding::Latin1; } else if(ui()->utf8RadioButton->isChecked()) { - preferredEncoding() = TagTextEncoding::Utf8; + settings.preferredEncoding = TagTextEncoding::Utf8; } else if(ui()->utf16leRadioButton->isChecked()) { - preferredEncoding() = TagTextEncoding::Utf16LittleEndian; + settings.preferredEncoding = TagTextEncoding::Utf16LittleEndian; } else if(ui()->utf16beRadioButton->isChecked()) { - preferredEncoding() = TagTextEncoding::Utf16BigEndian; + settings.preferredEncoding = TagTextEncoding::Utf16BigEndian; } else if(ui()->autoRadioButton->isChecked()) { - preferredEncoding() = TagTextEncoding::Unspecified; + settings.preferredEncoding = TagTextEncoding::Unspecified; } if(ui()->ignoreUnsupportedRadioButton->isChecked()) { - unsupportedFieldHandling() = UnsupportedFieldHandling::Ignore; + settings.unsupportedFieldHandling = UnsupportedFieldHandling::Ignore; } else if(ui()->discardUnsupportedRadioButton->isChecked()) { - unsupportedFieldHandling() = UnsupportedFieldHandling::Discard; + settings.unsupportedFieldHandling = UnsupportedFieldHandling::Discard; } - autoTagManagement() = ui()->autoTagManagementCheckBox->isChecked(); + settings.autoTagManagement = ui()->autoTagManagementCheckBox->isChecked(); } return true; } @@ -325,7 +336,8 @@ bool TagProcessingGeneralOptionPage::apply() void TagProcessingGeneralOptionPage::reset() { if(hasBeenShown()) { - switch(preferredEncoding()) { + const auto &settings = values().tagPocessing; + switch(settings.preferredEncoding) { case TagTextEncoding::Latin1: ui()->latin1RadioButton->setChecked(true); break; @@ -342,7 +354,7 @@ void TagProcessingGeneralOptionPage::reset() ui()->autoRadioButton->setChecked(true); break; } - switch(unsupportedFieldHandling()) { + switch(settings.unsupportedFieldHandling) { case UnsupportedFieldHandling::Ignore: ui()->ignoreUnsupportedRadioButton->setChecked(true); break; @@ -350,7 +362,7 @@ void TagProcessingGeneralOptionPage::reset() ui()->discardUnsupportedRadioButton->setChecked(true); break; } - ui()->autoTagManagementCheckBox->setChecked(autoTagManagement()); + ui()->autoTagManagementCheckBox->setChecked(settings.autoTagManagement); } } @@ -365,12 +377,13 @@ Id3v1OptionPage::~Id3v1OptionPage() bool Id3v1OptionPage::apply() { if(hasBeenShown()) { + auto &settings = values().tagPocessing.id3; if(ui()->alwaysCreateRadioButton->isChecked()) { - id3v1usage() = TagUsage::Always; + settings.v1Usage = TagUsage::Always; } else if(ui()->keepExistingRadioButton->isChecked()) { - id3v1usage() = TagUsage::KeepExisting; + settings.v1Usage = TagUsage::KeepExisting; } else if(ui()->removeExistingRadioButton->isChecked()) { - id3v1usage() = TagUsage::Never; + settings.v1Usage = TagUsage::Never; } } return true; @@ -379,7 +392,8 @@ bool Id3v1OptionPage::apply() void Id3v1OptionPage::reset() { if(hasBeenShown()) { - switch(id3v1usage()) { + const auto &settings = values().tagPocessing.id3; + switch(settings.v1Usage) { case TagUsage::Always: ui()->alwaysCreateRadioButton->setChecked(true); break; @@ -404,22 +418,23 @@ Id3v2OptionPage::~Id3v2OptionPage() bool Id3v2OptionPage::apply() { if(hasBeenShown()) { + auto &settings = values().tagPocessing.id3; if(ui()->alwaysCreateRadioButton->isChecked()) { - id3v2usage() = TagUsage::Always; + settings.v2Usage = TagUsage::Always; } else if(ui()->keepExistingRadioButton->isChecked()) { - id3v2usage() = TagUsage::KeepExisting; + settings.v2Usage = TagUsage::KeepExisting; } else if(ui()->removeExistingRadioButton->isChecked()) { - id3v2usage() = TagUsage::Never; + settings.v2Usage = TagUsage::Never; } if(ui()->version230radioButton->isChecked()) { - id3v2versionToBeUsed() = 3; + settings.v2Version = 3; } else if(ui()->version240radioButton->isChecked()) { - id3v2versionToBeUsed() = 4; + settings.v2Version = 4; } else if(ui()->version220radioButton->isChecked()) { - id3v2versionToBeUsed() = 2; + settings.v2Version = 2; } - keepVersionOfExistingId3v2Tag() = ui()->keepExistingVersionCheckBox->isChecked(); - mergeMultipleSuccessiveId3v2Tags() = ui()->mergeRadioButton->isChecked(); + settings.keepVersionOfExistingId3v2Tag = ui()->keepExistingVersionCheckBox->isChecked(); + settings.mergeMultipleSuccessiveId3v2Tags = ui()->mergeRadioButton->isChecked(); } return true; } @@ -427,7 +442,8 @@ bool Id3v2OptionPage::apply() void Id3v2OptionPage::reset() { if(hasBeenShown()) { - switch(id3v2usage()) { + const auto &settings = values().tagPocessing.id3; + switch(settings.v2Usage) { case TagUsage::Always: ui()->alwaysCreateRadioButton->setChecked(true); break; @@ -438,7 +454,7 @@ void Id3v2OptionPage::reset() ui()->removeExistingRadioButton->setChecked(true); break; } - switch(id3v2versionToBeUsed()) { + switch(settings.v2Version) { case 3: ui()->version230radioButton->setChecked(true); break; @@ -449,8 +465,8 @@ void Id3v2OptionPage::reset() ui()->version220radioButton->setChecked(true); break; } - ui()->keepExistingVersionCheckBox->setChecked(keepVersionOfExistingId3v2Tag()); - if(mergeMultipleSuccessiveId3v2Tags()) { + ui()->keepExistingVersionCheckBox->setChecked(settings.keepVersionOfExistingId3v2Tag); + if(settings.mergeMultipleSuccessiveId3v2Tags) { ui()->mergeRadioButton->setChecked(true); } else { ui()->keepSeparateRadioButton->setChecked(true); @@ -470,7 +486,7 @@ TagProcessingTargetsOptionPage::~TagProcessingTargetsOptionPage() bool TagProcessingTargetsOptionPage::apply() { if(hasBeenShown() && m_model) { - Settings::defaultTargetsModel().setItems(m_model->items()); + values().editor.defaultTargets.setItems(m_model->items()); } return true; } @@ -478,7 +494,7 @@ bool TagProcessingTargetsOptionPage::apply() void TagProcessingTargetsOptionPage::reset() { if(hasBeenShown() && m_model) { - m_model->setItems(Settings::defaultTargetsModel().items()); + m_model->setItems(values().editor.defaultTargets.items()); } } @@ -507,31 +523,32 @@ bool FileLayoutPage::apply() bool ok = true; if(hasBeenShown()) { - Settings::forceRewrite() = ui()->forceRewriteCheckBox->isChecked(); + auto &settings = values().tagPocessing.fileLayout; + settings.forceRewrite = ui()->forceRewriteCheckBox->isChecked(); if(ui()->minPaddingSpinBox->value() > ui()->maxPaddingSpinBox->value()) { errors() << QCoreApplication::translate("QtGui::FileLayoutPage", "Minimum padding must be less or equal than maximum padding."); ok = false; } else { - Settings::maxPadding() = static_cast(ui()->maxPaddingSpinBox->value()); - Settings::minPadding() = static_cast(ui()->minPaddingSpinBox->value()); + settings.maxPadding = static_cast(ui()->maxPaddingSpinBox->value()); + settings.minPadding = static_cast(ui()->minPaddingSpinBox->value()); } - Settings::preferredPadding() = static_cast(ui()->preferredPaddingSpinBox->value()); + settings.preferredPadding = static_cast(ui()->preferredPaddingSpinBox->value()); if(ui()->tagPosBeforeDataRadioButton->isChecked()) { - preferredTagPosition() = ElementPosition::BeforeData; + settings.preferredTagPosition = ElementPosition::BeforeData; } else if(ui()->tagPosAfterDataRadioButton->isChecked()) { - preferredTagPosition() = ElementPosition::AfterData; + settings.preferredTagPosition = ElementPosition::AfterData; } else if(ui()->tagPosKeepRadioButton->isChecked()) { - preferredTagPosition() = ElementPosition::Keep; + settings.preferredTagPosition = ElementPosition::Keep; } - forceTagPosition() = ui()->tagPosForceCheckBox->isChecked(); + settings.forceTagPosition = ui()->tagPosForceCheckBox->isChecked(); if(ui()->indexPosBeforeDataRadioButton->isChecked()) { - preferredIndexPosition() = ElementPosition::BeforeData; + settings.preferredIndexPosition = ElementPosition::BeforeData; } else if(ui()->indexPosAfterDataRadioButton->isChecked()) { - preferredIndexPosition() = ElementPosition::AfterData; + settings.preferredIndexPosition = ElementPosition::AfterData; } else if(ui()->indexPosKeepRadioButton->isChecked()) { - preferredIndexPosition() = ElementPosition::Keep; + settings.preferredIndexPosition = ElementPosition::Keep; } - forceIndexPosition() = ui()->indexPosForceCheckBox->isChecked(); + settings.forceIndexPosition = ui()->indexPosForceCheckBox->isChecked(); } return ok; } @@ -539,11 +556,12 @@ bool FileLayoutPage::apply() void FileLayoutPage::reset() { if(hasBeenShown()) { - ui()->forceRewriteCheckBox->setChecked(Settings::forceRewrite()); - ui()->maxPaddingSpinBox->setValue(static_cast(Settings::maxPadding())); - ui()->minPaddingSpinBox->setValue(static_cast(Settings::minPadding())); - ui()->preferredPaddingSpinBox->setValue(static_cast(Settings::preferredPadding())); - switch(preferredTagPosition()) { + const auto &settings = values().tagPocessing.fileLayout; + ui()->forceRewriteCheckBox->setChecked(settings.forceRewrite); + ui()->maxPaddingSpinBox->setValue(static_cast(settings.maxPadding)); + ui()->minPaddingSpinBox->setValue(static_cast(settings.minPadding)); + ui()->preferredPaddingSpinBox->setValue(static_cast(settings.preferredPadding)); + switch(settings.preferredTagPosition) { case ElementPosition::BeforeData: ui()->tagPosBeforeDataRadioButton->setChecked(true); break; @@ -554,8 +572,8 @@ void FileLayoutPage::reset() ui()->tagPosKeepRadioButton->setChecked(true); break; } - ui()->tagPosForceCheckBox->setChecked(forceTagPosition()); - switch(preferredIndexPosition()) { + ui()->tagPosForceCheckBox->setChecked(settings.forceTagPosition); + switch(settings.preferredIndexPosition) { case ElementPosition::BeforeData: ui()->indexPosBeforeDataRadioButton->setChecked(true); break; @@ -566,7 +584,7 @@ void FileLayoutPage::reset() ui()->indexPosKeepRadioButton->setChecked(true); break; } - ui()->indexPosForceCheckBox->setChecked(forceIndexPosition()); + ui()->indexPosForceCheckBox->setChecked(settings.forceIndexPosition); } } @@ -616,7 +634,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : category->assignPages(QList() << new FileBrowserGeneralOptionPage); categories << category; - categories << Settings::qtSettings().category(); + categories << values().qt.category(); categoryModel()->setCategories(categories); diff --git a/gui/tagedit.cpp b/gui/tagedit.cpp index 94c4e51..375b86e 100644 --- a/gui/tagedit.cpp +++ b/gui/tagedit.cpp @@ -179,7 +179,7 @@ void TagEdit::restore() */ void TagEdit::apply() { - switch(Settings::unsupportedFieldHandling()) { + switch(Settings::values().tagPocessing.unsupportedFieldHandling) { case Settings::UnsupportedFieldHandling::Discard: // remove all old fields of all tags to discard // all unsupported values @@ -241,7 +241,7 @@ void TagEdit::setupUi() // setup editing controls TagFieldEdit *edit = nullptr; int rowOverall = 0, rowLeft = 0, rowRight = 0; - for(const auto &item : Settings::selectedFieldsModel().items()) { + for(const auto &item : Settings::values().editor.fields.items()) { KnownField field = static_cast(item.id().toInt()); if(item.isChecked() && hasField(field)) { // the field is not disabled and the field is supported by at least one of the assigned tags diff --git a/gui/tageditorwidget.cpp b/gui/tageditorwidget.cpp index 69b2f00..07eb557 100644 --- a/gui/tageditorwidget.cpp +++ b/gui/tageditorwidget.cpp @@ -116,7 +116,7 @@ TagEditorWidget::TagEditorWidget(QWidget *parent) : // setup m_tagOptionsMenu, m_addTagMenu, m_removeTagMenu, m_changeTargetMenu m_tagOptionsMenu = new QMenu(this); m_tagOptionsMenu->addAction(m_ui->actionManage_tags_automatically_when_loading_file); - connect(m_ui->actionManage_tags_automatically_when_loading_file, &QAction::triggered, [] (bool checked) { Settings::autoTagManagement() = checked; }); + connect(m_ui->actionManage_tags_automatically_when_loading_file, &QAction::triggered, [] (bool checked) { Settings::values().tagPocessing.autoTagManagement = checked; }); m_tagOptionsMenu->addSeparator(); m_addTagMenu = new QMenu(tr("Add tag"), m_tagOptionsMenu); m_addTagMenu->setEnabled(false); @@ -284,7 +284,7 @@ void TagEditorWidget::updateTagEditsAndAttachmentEdits(bool updateUi, PreviousVa // determine to previous value handling according to the settings if auto is specified switch(previousValueHandling) { case PreviousValueHandling::Auto: - switch(Settings::adoptFields()) { + switch(Settings::values().editor.adoptFields) { case Settings::AdoptFields::WithinDirectory: if(m_lastDir != m_currentDir) { previousValueHandling = PreviousValueHandling::Clear; @@ -333,7 +333,7 @@ void TagEditorWidget::updateTagEditsAndAttachmentEdits(bool updateUi, PreviousVa } } // create a singe editor per target or seperate editors for each tag depending on the settings - switch(Settings::multipleTagHandling()) { + switch(Settings::values().editor.multipleTagHandling) { case Settings::MultipleTagHandling::SingleEditorPerTarget: // iterate through all targets in both cases for(int targetIndex = 0, targetCount = targets.size(); targetIndex < targetCount; ++targetIndex) { @@ -411,7 +411,7 @@ void TagEditorWidget::updateTagSelectionComboBox() m_ui->tagSelectionComboBox->addItem(label); } // set visibility - m_ui->tagSelectionComboBox->setHidden(Settings::hideTagSelectionComboBox() && m_ui->tagSelectionComboBox->count() <= 1 && !haveTargetInfo); + m_ui->tagSelectionComboBox->setHidden(Settings::values().editor.hideTagSelectionComboBox && m_ui->tagSelectionComboBox->count() <= 1 && !haveTargetInfo); // restore selected index if(previouslySelectedEditIndex >= 0 && previouslySelectedEditIndex < m_ui->tagSelectionComboBox->count()) { m_ui->tagSelectionComboBox->setCurrentIndex(previouslySelectedEditIndex); @@ -564,7 +564,7 @@ void TagEditorWidget::updateTagManagementMenu() */ void TagEditorWidget::insertTitleFromFilename() { - if(!m_tags.empty() && Settings::insertTitleFromFilename()) { + if(!m_tags.empty() && Settings::values().editor.autoCompletition.insertTitleFromFilename) { QString title; int trackNum; parseFileName(QString::fromLocal8Bit(m_fileInfo.fileName().c_str()), title, trackNum); @@ -583,7 +583,7 @@ void TagEditorWidget::insertTitleFromFilename() void TagEditorWidget::initInfoView() { #ifndef TAGEDITOR_NO_WEBVIEW - if(!Settings::noWebView() && !m_infoWebView) { + if(!Settings::values().editor.noWebView && !m_infoWebView) { if(m_infoTreeView) { m_infoTreeView->deleteLater(); m_infoTreeView = nullptr; @@ -597,7 +597,7 @@ void TagEditorWidget::initInfoView() m_infoWebView->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_infoWebView, &QWidget::customContextMenuRequested, this, &TagEditorWidget::showInfoWebViewContextMenu); m_ui->tagSplitter->addWidget(m_infoWebView); - } else if(Settings::noWebView() && !m_infoTreeView) { + } else if(Settings::values().editor.noWebView && !m_infoTreeView) { if(m_infoWebView) { m_infoWebView->deleteLater(); m_infoWebView = nullptr; @@ -761,7 +761,7 @@ bool TagEditorWidget::startParsing(const QString &path, bool forceRefresh) // try to open read-only if opening with write access failed m_fileInfo.reopen(true); } - m_fileInfo.setForceFullParse(Settings::forceFullParse()); + m_fileInfo.setForceFullParse(Settings::values().editor.forceFullParse); m_fileInfo.parseEverything(); result = ParsingSuccessful; } catch(const Failure &) { @@ -845,21 +845,22 @@ void TagEditorWidget::showFile(char result) } // create appropriate tags according to file type and user preferences when automatic tag management is enabled - if(Settings::autoTagManagement()) { + const auto &settings = Settings::values().tagPocessing; + if(settings.autoTagManagement) { vector requiredTargets; requiredTargets.reserve(2); - for(const ChecklistItem &targetItem : Settings::defaultTargetsModel().items()) { + for(const ChecklistItem &targetItem : Settings::values().editor.defaultTargets.items()) { if(targetItem.isChecked()) { requiredTargets.emplace_back(containerTargetLevelValue(m_fileInfo.containerFormat(), static_cast(targetItem.id().toInt()))); } } // TODO: allow initialization of new ID3 tag with values from already present ID3 tag // TODO: allow not to transfer values from removed ID3 tag to remaining ID3 tags - if(!m_fileInfo.createAppropriateTags(false, Settings::id3v1usage(), Settings::id3v2usage(), false, true, Settings::mergeMultipleSuccessiveId3v2Tags(), - Settings::keepVersionOfExistingId3v2Tag(), Settings::id3v2versionToBeUsed(), requiredTargets)) { + if(!m_fileInfo.createAppropriateTags(false, settings.id3.v1Usage, settings.id3.v2Usage, false, true, settings.id3.mergeMultipleSuccessiveId3v2Tags, + settings.id3.keepVersionOfExistingId3v2Tag, settings.id3.v2Version, requiredTargets)) { if(confirmCreationOfId3TagForUnsupportedFile()) { - m_fileInfo.createAppropriateTags(true, Settings::id3v1usage(), Settings::id3v2usage(), false, true, Settings::mergeMultipleSuccessiveId3v2Tags(), - Settings::keepVersionOfExistingId3v2Tag(), Settings::id3v2versionToBeUsed(), requiredTargets); + m_fileInfo.createAppropriateTags(true, settings.id3.v1Usage, settings.id3.v2Usage, false, true, settings.id3.mergeMultipleSuccessiveId3v2Tags, + settings.id3.keepVersionOfExistingId3v2Tag, settings.id3.v2Version, requiredTargets); } } // tags might have been adjusted -> reload tags @@ -981,7 +982,7 @@ bool TagEditorWidget::deleteAllTagsAndSave() { TryLocker<> locker(m_fileOperationMutex); if(locker) { - if(Settings::askBeforeDeleting()) { + if(Settings::values().editor.askBeforeDeleting) { QMessageBox msgBox(this); msgBox.setText(tr("Do you really want to delete all tags from the file?")); msgBox.setIcon(QMessageBox::Warning); @@ -995,7 +996,7 @@ bool TagEditorWidget::deleteAllTagsAndSave() int res = msgBox.exec(); #if QT_VERSION >= 0x050200 if(checkBox->isChecked()) { - Settings::askBeforeDeleting() = false; + Settings::values().editor.askBeforeDeleting = false; } #endif if(res != QMessageBox::Yes) { @@ -1056,14 +1057,15 @@ bool TagEditorWidget::startSaving() // remove current path from file watcher m_fileWatcher->removePath(m_currentPath); // use current configuration - m_fileInfo.setForceRewrite(Settings::forceRewrite()); - m_fileInfo.setTagPosition(Settings::preferredTagPosition()); - m_fileInfo.setForceTagPosition(Settings::forceTagPosition()); - m_fileInfo.setIndexPosition(Settings::preferredIndexPosition()); - m_fileInfo.setForceIndexPosition(Settings::forceIndexPosition()); - m_fileInfo.setMinPadding(Settings::minPadding()); - m_fileInfo.setMaxPadding(Settings::maxPadding()); - m_fileInfo.setPreferredPadding(Settings::preferredPadding()); + const auto &settings = Settings::values().tagPocessing.fileLayout; + m_fileInfo.setForceRewrite(settings.forceRewrite); + m_fileInfo.setTagPosition(settings.preferredTagPosition); + m_fileInfo.setForceTagPosition(settings.forceTagPosition); + m_fileInfo.setIndexPosition(settings.preferredIndexPosition); + m_fileInfo.setForceIndexPosition(settings.forceIndexPosition); + m_fileInfo.setMinPadding(settings.minPadding); + m_fileInfo.setMaxPadding(settings.maxPadding); + m_fileInfo.setPreferredPadding(settings.preferredPadding); // define functions to show the saving progress and to actually applying the changes auto showProgress = [this] (StatusProvider &sender) -> void { QMetaObject::invokeMethod(m_ui->makingNotificationWidget, "setPercentage", Qt::QueuedConnection, Q_ARG(int, static_cast(sender.currentPercentage() * 100.0))); @@ -1233,19 +1235,20 @@ void TagEditorWidget::closeFile() */ void TagEditorWidget::handleReturnPressed() { - if(Settings::saveAndShowNextOnEnter() && m_fileInfo.isOpen()) { + if(Settings::values().editor.saveAndShowNextOnEnter && m_fileInfo.isOpen()) { saveAndShowNextFile(); } } void TagEditorWidget::handleKeepPreviousValuesActionTriggered(QAction *action) { + auto &settings = Settings::values().editor; if(action == m_ui->actionKeep_previous_values_never) { - Settings::adoptFields() = Settings::AdoptFields::Never; + settings.adoptFields = Settings::AdoptFields::Never; } else if(action == m_ui->actionKeep_previous_values_within_same_dir) { - Settings::adoptFields() = Settings::AdoptFields::WithinDirectory; + settings.adoptFields = Settings::AdoptFields::WithinDirectory; } else if(action == m_ui->actionKeep_previous_values_always) { - Settings::adoptFields() = Settings::AdoptFields::Always; + settings.adoptFields = Settings::AdoptFields::Always; } } @@ -1255,7 +1258,8 @@ void TagEditorWidget::handleKeepPreviousValuesActionTriggered(QAction *action) */ void TagEditorWidget::applySettingsFromDialog() { - switch(Settings::adoptFields()) { + const auto &settings = Settings::values(); + switch(settings.editor.adoptFields) { case Settings::AdoptFields::Never: m_ui->actionKeep_previous_values_never->setChecked(true); break; @@ -1266,8 +1270,8 @@ void TagEditorWidget::applySettingsFromDialog() m_ui->actionKeep_previous_values_always->setChecked(true); break; } - m_ui->actionManage_tags_automatically_when_loading_file->setChecked(Settings::autoTagManagement()); - foreachTagEdit(bind(&TagEdit::setCoverButtonsHidden, _1, Settings::hideCoverButtons())); + m_ui->actionManage_tags_automatically_when_loading_file->setChecked(settings.tagPocessing.autoTagManagement); + foreachTagEdit(bind(&TagEdit::setCoverButtonsHidden, _1, settings.editor.hideCoverButtons)); // ensure info view is displayed/not displayed according to settings initInfoView(); updateInfoView(); diff --git a/gui/tagfieldedit.cpp b/gui/tagfieldedit.cpp index df38e5b..a067051 100644 --- a/gui/tagfieldedit.cpp +++ b/gui/tagfieldedit.cpp @@ -193,12 +193,12 @@ bool TagFieldEdit::canApply(KnownField field) const for(Tag *tag : tags()) { switch(tag->type()) { case TagType::Id3v1Tag: - if(Settings::id3v1usage() == TagUsage::Never) { + if(Settings::values().tagPocessing.id3.v1Usage == TagUsage::Never) { continue; } break; case TagType::Id3v2Tag: - if(Settings::id3v2usage() == TagUsage::Never) { + if(Settings::values().tagPocessing.id3.v2Usage == TagUsage::Never) { continue; } break; @@ -851,20 +851,21 @@ void TagFieldEdit::showRestoreButton() */ void TagFieldEdit::applyAutoCorrection(QString &textValue) { - auto &fields = Settings::autoCorrectionFields().items(); + const auto &settings = Settings::values().editor.autoCompletition; + auto &fields = settings.fields.items(); auto i = find_if(fields.constBegin(), fields.constEnd(), [this] (const ChecklistItem &item) { bool ok; return (item.id().toInt(&ok) == static_cast(this->field())) && ok; }); // if current field is in the list of auto correction fields and auto correction should be applied if(i != fields.constEnd() && i->isChecked()) { - if(Settings::trimWhitespaces()) { + if(settings.trimWhitespaces) { textValue = textValue.trimmed(); } - if(Settings::fixUmlauts()) { + if(settings.fixUmlauts) { textValue = Utility::fixUmlauts(textValue); } - if(Settings::formatNames()) { + if(settings.formatNames) { textValue = Utility::formatName(textValue); } } @@ -943,7 +944,7 @@ void TagFieldEdit::apply() m_pictureSelection->apply(); } } else { - TagTextEncoding encoding = Settings::preferredEncoding(); + TagTextEncoding encoding = Settings::values().tagPocessing.preferredEncoding; if(!tag->canEncodingBeUsed(encoding)) { encoding = tag->proposedTextEncoding(); } diff --git a/translations/tageditor_de_DE.ts b/translations/tageditor_de_DE.ts index 46387ac..fdc5b02 100644 --- a/translations/tageditor_de_DE.ts +++ b/translations/tageditor_de_DE.ts @@ -648,123 +648,123 @@ QtGui::DbQueryWidget - + MusicBrainz/LyricsWikia search - + Search &criteria - + Song - - - - + + + + ? - + Album - + Artist - + Fields to be used - - override existing values + + Override existing values - + Abort - + Search MusicBrainz - + Search LyricWikia - + Inserts the selected result into the current tag (doesn't save anything) - + Use selected row - + Search hasn't been started - + Insert present data - + Clear search criteria - + Insufficient search criteria supplied - at least title, album or artist must be specified - + Retrieving meta data from MusicBrainz ... - + Insufficient search criteria supplied - artist is mandatory - + Retrieving meta data from LyricsWikia ... - + Aborted - + No results available - + %1 result(s) available @@ -772,47 +772,47 @@ row - + Retrieving cover art to be applied ... - + Retrieving lyrics to be applied ... - + Use selected row - + Show cover - + Show lyrics - + Retrieving cover art ... - + Retrieving lyrics ... - + Cover - %1 - + Lyrics - %1 @@ -996,7 +996,7 @@ Remarks - + To avoid unnecessary copying this directory should be on the same partition as the files you want to edit. @@ -1593,12 +1593,12 @@ another position would prevent rewriting the entire file - + Minimum padding must be less or equal than maximum padding. - + These options might be ignored if not supported by either the format or the implementation. @@ -1759,32 +1759,32 @@ another position would prevent rewriting the entire file QtGui::LyricsWikiaResultsModel - + Unable to fetch lyrics: Artist or title is unknown. - + Internal error: context for song details reply invalid - + Unable to parse song details: - + Song details requested for %1/%2 do not contain URL for Wiki page - + Internal error: context for LyricsWikia page reply invalid - + Song details requested for %1/%2 do not contain lyrics @@ -1912,7 +1912,7 @@ another position would prevent rewriting the entire file - + Lock layout @@ -1988,63 +1988,63 @@ another position would prevent rewriting the entire file - + No file opened. - + A tag editing utility supporting ID3, MP4 (iTunes style), Vorbis and Matroska tags. - + Unable to show the next file because it can't be found anymore. - + Open file - - + Save changes as - - + Save file information - - + No file is opened. - + Unable to save file information because the current process hasn't been finished yet. - + Unable to write to file. %1 - + Unlock layout - + Unable to open file. - + No file information available. @@ -2139,7 +2139,7 @@ another position would prevent rewriting the entire file - + Add @@ -2338,7 +2338,7 @@ another position would prevent rewriting the entire file - + The attached image can't be found. @@ -2358,22 +2358,22 @@ another position would prevent rewriting the entire file - + No image (of the selected type) attached. - + Unable to display attached image. - + Change - + Change MIME-type @@ -2470,8 +2470,8 @@ another position would prevent rewriting the entire file - - + + Close @@ -2491,8 +2491,8 @@ another position would prevent rewriting the entire file - - + + Abort @@ -2538,28 +2538,28 @@ another position would prevent rewriting the entire file - + Generating preview ... - + The script is not valid. Error in line %1: %3 - + The selected directory doesn't exist. - + Applying changings ... - + %1 files/directories processed @@ -2567,13 +2567,13 @@ Error in line %1: %3 - + Preview has been generated. - - + + %1 error(s) occured. @@ -2581,8 +2581,8 @@ Error in line %1: %3 - - + + %1 files/directories have been processed. @@ -2590,12 +2590,12 @@ Error in line %1: %3 - + No files and directories have been found. - + %1 error(s) occured @@ -2603,62 +2603,62 @@ Error in line %1: %3 - + There is no external script file is selected. - + Unable to open external script file. - + An error occured when parsing the script: %1 - + The script is empty. - + Generation of preview has been aborted prematurely. - + Changins applied. - + Applying has been aborted prematurely. - + Unable to open script file. - + Select script - + Clipboard contains no text. - + Expand all - + Collapse all @@ -2672,17 +2672,17 @@ Error in line %1: %3 - + Tag processing - + Editor - + File browser @@ -2774,7 +2774,7 @@ the file reverting all unsaved changings. - + Abort @@ -2926,22 +2926,22 @@ the file reverting all unsaved changings. - + File could be parsed correctly. - + File couldn't be parsed correctly. - + There are critical parsing notifications. - + There are warnings. @@ -2951,67 +2951,67 @@ the file reverting all unsaved changings. - + File format is not supported (an ID3 tag can be added anyways). - + The file %1 has been opened. - + Unable to apply the entered tags to the file because the current process hasn't finished yet. - + Saving tags ... - + No file has been opened. - + Unable to delete all tags from the file because the current process hasn't been finished yet. - + Do you really want to delete all tags from the file? - + don't show this message again - + Deleting all tags ... - + The selected file stores no tag (at least no supported), so there is nothing to delete. - + No file has been opened, so no tags can be deleted. - + Unable to start saving process because there an other process hasn't finished yet. - + Cancelling ... @@ -3036,17 +3036,17 @@ the file reverting all unsaved changings. - + No write access; the file has been opened in read-only mode. - + The file is composed of multiple segments. Dealing with such files has not been tested yet and might be broken. - + The tags have been saved, but there is/are %1 warning(s) @@ -3054,7 +3054,7 @@ the file reverting all unsaved changings. - + and %1 error(s). @@ -3062,7 +3062,7 @@ the file reverting all unsaved changings. - + The tags have been saved, but there is/are %1 warning(s). @@ -3070,72 +3070,72 @@ the file reverting all unsaved changings. - + The tags have been saved. - + The tags couldn't be saved. See the info box for detail. - + The tags couldn't be saved because an IO error occured. - + Automatic tag management - + The container format of the selected file is not supported. The file can be treated as MP3 file (an ID3 tag according to the settings will be created). This might break the file. Do you want to continue? - + Treat file as MP3 file - + The currently opened file changed on the disk. - + A tag (with the selected target) already exists. - + The tag can not be created. - + Unable to remove the tag because the current process hasn't been finished yet. - + Unable to remove the tag because no file is opened. - + Unable to change the target because the current process hasn't been finished yet. - + Unable to change the target because no file is opened. - + Can not change the target of the selected tag because the tag does not support targets. @@ -4134,7 +4134,7 @@ the file reverting all unsaved changings. - + restore to value from %1 (%2) diff --git a/translations/tageditor_en_US.ts b/translations/tageditor_en_US.ts index d1f29db..25395e9 100644 --- a/translations/tageditor_en_US.ts +++ b/translations/tageditor_en_US.ts @@ -648,52 +648,52 @@ QtGui::DbQueryWidget - + Search hasn't been started - + Insert present data - + Clear search criteria - + Insufficient search criteria supplied - at least title, album or artist must be specified - + Retrieving meta data from MusicBrainz ... - + Insufficient search criteria supplied - artist is mandatory - + Retrieving meta data from LyricsWikia ... - + Aborted - + No results available - + %1 result(s) available %1 result available @@ -701,117 +701,117 @@ - + Retrieving cover art to be applied ... - + Retrieving lyrics to be applied ... - + Use selected row - + Show cover - + Show lyrics - + Retrieving cover art ... - + Retrieving lyrics ... - + Cover - %1 - + Lyrics - %1 - + MusicBrainz/LyricsWikia search - + Search &criteria - + Song - - - - + + + + ? - + Album - + Artist - + Fields to be used - - override existing values + + Override existing values - + Abort - + Search MusicBrainz - + Search LyricWikia - + Inserts the selected result into the current tag (doesn't save anything) - + Use selected row @@ -996,7 +996,7 @@ Remarks - + To avoid unnecessary copying this directory should be on the same partition as the files you want to edit. @@ -1593,12 +1593,12 @@ another position would prevent rewriting the entire file - + Minimum padding must be less or equal than maximum padding. - + These options might be ignored if not supported by either the format or the implementation. @@ -1759,32 +1759,32 @@ another position would prevent rewriting the entire file QtGui::LyricsWikiaResultsModel - + Unable to fetch lyrics: Artist or title is unknown. - + Internal error: context for song details reply invalid - + Unable to parse song details: - + Song details requested for %1/%2 do not contain URL for Wiki page - + Internal error: context for LyricsWikia page reply invalid - + Song details requested for %1/%2 do not contain lyrics @@ -1978,7 +1978,7 @@ another position would prevent rewriting the entire file - + Lock layout @@ -1988,63 +1988,63 @@ another position would prevent rewriting the entire file - + Unlock layout - + No file opened. - + A tag editing utility supporting ID3, MP4 (iTunes style), Vorbis and Matroska tags. - + Unable to show the next file because it can't be found anymore. - + Open file - - + Save changes as - - + Save file information - - + Unable to write to file. %1 - + Unable to open file. - + No file information available. - + No file is opened. - + Unable to save file information because the current process hasn't been finished yet. @@ -2145,7 +2145,7 @@ another position would prevent rewriting the entire file - + Add @@ -2338,7 +2338,7 @@ another position would prevent rewriting the entire file - + The attached image can't be found. @@ -2358,22 +2358,22 @@ another position would prevent rewriting the entire file - + No image (of the selected type) attached. - + Unable to display attached image. - + Change - + Change MIME-type @@ -2435,7 +2435,7 @@ another position would prevent rewriting the entire file - + %1 files/directories processed %1 file/directory processed @@ -2443,23 +2443,23 @@ another position would prevent rewriting the entire file - + Preview has been generated. - + No files and directories have been found. - + Generation of preview has been aborted prematurely. - - + + %1 error(s) occured. %1 error occured. @@ -2467,8 +2467,8 @@ another position would prevent rewriting the entire file - - + + %1 files/directories have been processed. %1 file/directory has been processed. @@ -2491,54 +2491,54 @@ another position would prevent rewriting the entire file - + There is no external script file is selected. - + Unable to open external script file. - + Generating preview ... - - + + Abort - + The script is not valid. Error in line %1: %3 - + An error occured when parsing the script: %1 - + The script is empty. - + The selected directory doesn't exist. - + Applying changings ... - + %1 error(s) occured %1 error occured @@ -2546,37 +2546,37 @@ Error in line %1: %3 - + Changins applied. - + Applying has been aborted prematurely. - + Unable to open script file. - + Select script - + Clipboard contains no text. - + Expand all - + Collapse all @@ -2637,8 +2637,8 @@ Error in line %1: %3 - - + + Close @@ -2672,17 +2672,17 @@ Error in line %1: %3 - + Tag processing - + Editor - + File browser @@ -2816,37 +2816,37 @@ Error in line %1: %3 - + File could be parsed correctly. - + File couldn't be parsed correctly. - + There are critical parsing notifications. - + There are warnings. - + No write access; the file has been opened in read-only mode. - + File format is not supported (an ID3 tag can be added anyways). - + The file is composed of multiple segments. Dealing with such files has not been tested yet and might be broken. @@ -2856,67 +2856,67 @@ Error in line %1: %3 - + The file %1 has been opened. - + Saving tags ... - + No file has been opened. - + Unable to apply the entered tags to the file because the current process hasn't finished yet. - + Do you really want to delete all tags from the file? - + don't show this message again - + Deleting all tags ... - + The selected file stores no tag (at least no supported), so there is nothing to delete. - + No file has been opened, so no tags can be deleted. - + Unable to delete all tags from the file because the current process hasn't been finished yet. - + Cancelling ... - + Unable to start saving process because there an other process hasn't finished yet. - + The tags have been saved, but there is/are %1 warning(s) The tags have been saved, but there is %1 warning @@ -2924,7 +2924,7 @@ Error in line %1: %3 - + and %1 error(s). and %1 error. @@ -2932,7 +2932,7 @@ Error in line %1: %3 - + The tags have been saved, but there is/are %1 warning(s). The tags have been saved, but there is %1 warning. @@ -2940,72 +2940,72 @@ Error in line %1: %3 - + The tags have been saved. - + The tags couldn't be saved. See the info box for detail. - + The tags couldn't be saved because an IO error occured. - + Automatic tag management - + The container format of the selected file is not supported. The file can be treated as MP3 file (an ID3 tag according to the settings will be created). This might break the file. Do you want to continue? - + Treat file as MP3 file - + The currently opened file changed on the disk. - + A tag (with the selected target) already exists. - + The tag can not be created. - + Unable to remove the tag because no file is opened. - + Unable to remove the tag because the current process hasn't been finished yet. - + Unable to change the target because no file is opened. - + Can not change the target of the selected tag because the tag does not support targets. - + Unable to change the target because the current process hasn't been finished yet. @@ -3075,7 +3075,7 @@ the file reverting all unsaved changings. - + Abort @@ -4134,7 +4134,7 @@ the file reverting all unsaved changings. - + restore to value from %1 (%2)