diff --git a/src/dialog/dlgkeywheel.cpp b/src/dialog/dlgkeywheel.cpp index 16a835f0a07..e05e075f55d 100644 --- a/src/dialog/dlgkeywheel.cpp +++ b/src/dialog/dlgkeywheel.cpp @@ -6,6 +6,7 @@ #include #include "control/controlobject.h" +#include "library/library_prefs.h" using namespace mixxx::track::io::key; @@ -46,7 +47,7 @@ DlgKeywheel::DlgKeywheel(QWidget* parent, const UserSettingsPointer& pConfig) // load the user configured setting as default const int notation = static_cast(ControlObject::get( - ConfigKey("[Library]", "key_notation"))); + mixxx::library::prefs::kKeyNotationConfigKey)); m_notation = static_cast(notation); // Display the current or next valid notation switchNotation(0); diff --git a/src/library/columncache.cpp b/src/library/columncache.cpp index af00d83c377..596859466d5 100644 --- a/src/library/columncache.cpp +++ b/src/library/columncache.cpp @@ -2,6 +2,7 @@ #include "library/dao/playlistdao.h" #include "library/dao/trackschema.h" +#include "library/library_prefs.h" #include "moc_columncache.cpp" #include "util/db/dbconnection.h" @@ -15,7 +16,7 @@ const QString kSortNoCaseLex = mixxx::DbConnection::collateLexicographically( } // namespace ColumnCache::ColumnCache(const QStringList& columns) { - m_pKeyNotationCP = new ControlProxy("[Library]", "key_notation", this); + m_pKeyNotationCP = new ControlProxy(mixxx::library::prefs::kKeyNotationConfigKey, this); m_pKeyNotationCP->connectValueChanged(this, &ColumnCache::slotSetKeySortOrder); // ColumnCache is initialized before the preferences, so slotSetKeySortOrder is called diff --git a/src/library/library.cpp b/src/library/library.cpp index 825b7eeef9f..bf48d9a33f2 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -80,7 +80,8 @@ Library::Library( m_pAnalysisFeature(nullptr) { qRegisterMetaType("LibraryRemovalType"); - m_pKeyNotation.reset(new ControlObject(ConfigKey(kConfigGroup, "key_notation"))); + m_pKeyNotation.reset( + new ControlObject(mixxx::library::prefs::kKeyNotationConfigKey)); connect(m_pTrackCollectionManager, &TrackCollectionManager::libraryScanFinished, diff --git a/src/library/library_prefs.cpp b/src/library/library_prefs.cpp index 8dc49c1a588..020b930dcd8 100644 --- a/src/library/library_prefs.cpp +++ b/src/library/library_prefs.cpp @@ -6,24 +6,34 @@ // reliably at compile time. const ConfigKey mixxx::library::prefs::kLegacyDirectoryConfigKey = - ConfigKey( + ConfigKey{ QStringLiteral("[Playlist]"), - QStringLiteral("Directory")); + QStringLiteral("Directory")}; const QString mixxx::library::prefs::kConfigGroup = QStringLiteral("[Library]"); +const ConfigKey mixxx::library::prefs::kKeyNotationConfigKey = + ConfigKey{ + mixxx::library::prefs::kConfigGroup, + QStringLiteral("key_notation")}; + const ConfigKey mixxx::library::prefs::kEditMetadataSelectedClickConfigKey = - ConfigKey( + ConfigKey{ mixxx::library::prefs::kConfigGroup, - "EditMetadataSelectedClick"); + QStringLiteral("EditMetadataSelectedClick")}; const ConfigKey mixxx::library::prefs::kSearchDebouncingTimeoutMillisConfigKey = - ConfigKey( + ConfigKey{ mixxx::library::prefs::kConfigGroup, - QStringLiteral("SearchDebouncingTimeoutMillis")); + QStringLiteral("SearchDebouncingTimeoutMillis")}; const ConfigKey mixxx::library::prefs::kSyncTrackMetadataExportConfigKey = - ConfigKey( + ConfigKey{ + mixxx::library::prefs::kConfigGroup, + QStringLiteral("SyncTrackMetadataExport")}; + +const ConfigKey mixxx::library::prefs::kSeratoMetadataExportConfigKey = + ConfigKey{ mixxx::library::prefs::kConfigGroup, - QStringLiteral("SyncTrackMetadataExport")); + QStringLiteral("SeratoMetadataExport")}; diff --git a/src/library/library_prefs.h b/src/library/library_prefs.h index 710964e2351..32077ebc3b3 100644 --- a/src/library/library_prefs.h +++ b/src/library/library_prefs.h @@ -12,6 +12,8 @@ extern const ConfigKey kLegacyDirectoryConfigKey; extern const QString kConfigGroup; +extern const ConfigKey kKeyNotationConfigKey; + extern const ConfigKey kSearchDebouncingTimeoutMillisConfigKey; extern const ConfigKey kEditMetadataSelectedClickConfigKey; @@ -20,6 +22,8 @@ const bool kEditMetadataSelectedClickDefault = false; extern const ConfigKey kSyncTrackMetadataExportConfigKey; +extern const ConfigKey kSeratoMetadataExportConfigKey; + } // namespace prefs } // namespace library diff --git a/src/preferences/dialog/dlgprefkey.cpp b/src/preferences/dialog/dlgprefkey.cpp index b5acd41e4ed..14d27baf7f6 100644 --- a/src/preferences/dialog/dlgprefkey.cpp +++ b/src/preferences/dialog/dlgprefkey.cpp @@ -5,6 +5,7 @@ #include "analyzer/analyzerkey.h" #include "control/controlproxy.h" +#include "library/library_prefs.h" #include "moc_dlgprefkey.cpp" #include "util/compatibility.h" #include "util/xml.h" @@ -48,7 +49,7 @@ DlgPrefKey::DlgPrefKey(QWidget* parent, UserSettingsPointer pConfig) plugincombo->addItem(info.name(), info.id()); } - m_pKeyNotation = new ControlProxy(ConfigKey("[Library]", "key_notation"), this); + m_pKeyNotation = new ControlProxy(mixxx::library::prefs::kKeyNotationConfigKey, this); loadSettings(); diff --git a/src/preferences/dialog/dlgpreflibrary.cpp b/src/preferences/dialog/dlgpreflibrary.cpp index ce5749f8d32..cf7b43dac81 100644 --- a/src/preferences/dialog/dlgpreflibrary.cpp +++ b/src/preferences/dialog/dlgpreflibrary.cpp @@ -199,8 +199,8 @@ void DlgPrefLibrary::slotUpdate() { ConfigKey("[Library]","RescanOnStartup"), false)); checkBox_SyncTrackMetadataExport->setChecked( m_pConfig->getValue(kSyncTrackMetadataExportConfigKey, false)); - checkBox_SeratoMetadataExport->setChecked(m_pConfig->getValue( - ConfigKey("[Library]", "SeratoMetadataExport"), false)); + checkBox_SeratoMetadataExport->setChecked( + m_pConfig->getValue(kSeratoMetadataExportConfigKey, false)); checkBox_use_relative_path->setChecked(m_pConfig->getValue( ConfigKey("[Library]","UseRelativePathOnExport"), false)); checkBox_show_rhythmbox->setChecked(m_pConfig->getValue( @@ -367,8 +367,9 @@ void DlgPrefLibrary::slotApply() { m_pConfig->set( kSyncTrackMetadataExportConfigKey, ConfigValue{checkBox_SyncTrackMetadataExport->isChecked()}); - m_pConfig->set(ConfigKey("[Library]", "SeratoMetadataExport"), - ConfigValue(static_cast(checkBox_SeratoMetadataExport->isChecked()))); + m_pConfig->set( + kSeratoMetadataExportConfigKey, + ConfigValue{checkBox_SeratoMetadataExport->isChecked()}); m_pConfig->set(ConfigKey("[Library]","UseRelativePathOnExport"), ConfigValue((int)checkBox_use_relative_path->isChecked())); m_pConfig->set(ConfigKey("[Library]","ShowRhythmboxLibrary"), diff --git a/src/test/librarytest.cpp b/src/test/librarytest.cpp index 23048a411d5..c87a1387fc8 100644 --- a/src/test/librarytest.cpp +++ b/src/test/librarytest.cpp @@ -1,5 +1,6 @@ #include "test/librarytest.h" +#include "library/library_prefs.h" #include "track/track.h" namespace { @@ -31,7 +32,7 @@ std::unique_ptr newTrackCollectionManager( LibraryTest::LibraryTest() : MixxxDbTest(kInMemoryDbConnection), m_pTrackCollectionManager(newTrackCollectionManager(config(), dbConnectionPooler())), - m_keyNotationCO(ConfigKey("[Library]", "key_notation")) { + m_keyNotationCO(mixxx::library::prefs::kKeyNotationConfigKey) { } TrackPointer LibraryTest::getOrAddTrackByLocation( diff --git a/src/track/track.cpp b/src/track/track.cpp index 2e3b2d00d6d..a77325ae292 100644 --- a/src/track/track.cpp +++ b/src/track/track.cpp @@ -4,6 +4,7 @@ #include #include "engine/engine.h" +#include "library/library_prefs.h" #include "moc_track.cpp" #include "sources/metadatasource.h" #include "track/beatfactory.h" @@ -18,7 +19,6 @@ namespace { const mixxx::Logger kLogger("Track"); constexpr bool kLogStats = false; -const ConfigKey kConfigKeySeratoMetadataExport("[Library]", "SeratoMetadataExport"); // Count the number of currently existing instances for detecting // memory leaks. @@ -1457,7 +1457,7 @@ ExportTrackMetadataResult Track::exportMetadata( return ExportTrackMetadataResult::Skipped; } - if (pConfig->getValue(kConfigKeySeratoMetadataExport)) { + if (pConfig->getValue(mixxx::library::prefs::kSeratoMetadataExportConfigKey)) { const auto streamInfo = m_record.getStreamInfoFromSource(); VERIFY_OR_DEBUG_ASSERT(streamInfo && streamInfo->getSignalInfo().isValid() && diff --git a/src/widget/wkey.cpp b/src/widget/wkey.cpp index 9955f99e872..bbfa78a72e0 100644 --- a/src/widget/wkey.cpp +++ b/src/widget/wkey.cpp @@ -1,5 +1,6 @@ #include "widget/wkey.h" +#include "library/library_prefs.h" #include "moc_wkey.cpp" #include "track/keys.h" #include "track/keyutils.h" @@ -7,7 +8,7 @@ WKey::WKey(const QString& group, QWidget* pParent) : WLabel(pParent), m_dOldValue(0), - m_keyNotation("[Library]", "key_notation", this), + m_keyNotation(mixxx::library::prefs::kKeyNotationConfigKey, this), m_engineKeyDistance(group, "visual_key_distance", this, diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 48c98b583e6..0b1dced9457 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -9,6 +9,7 @@ #include "control/controlobject.h" #include "library/dao/trackschema.h" #include "library/library.h" +#include "library/library_prefs.h" #include "library/librarytablemodel.h" #include "library/trackcollection.h" #include "library/trackcollectionmanager.h" @@ -27,10 +28,21 @@ namespace { -const ConfigKey kConfigKeyAllowTrackLoadToPlayingDeck("[Controls]", "AllowTrackLoadToPlayingDeck"); +// ConfigValue key for QTable vertical scrollbar position +const ConfigKey kVScrollBarPosConfigKey{ + // mixxx::library::prefs::kConfigGroup is defined in another + // unit of compilation and cannot be reused here! + QStringLiteral("[Library]"), + QStringLiteral("VScrollBarPos")}; + +const ConfigKey kConfigKeyAllowTrackLoadToPlayingDeck{ + QStringLiteral("[Controls]"), + QStringLiteral("AllowTrackLoadToPlayingDeck")}; + // Default color for the focus border of TableItemDelegates const QColor kDefaultFocusBorderColor = Qt::white; -} // namespace + +} // anonymous namespace WTrackTableView::WTrackTableView(QWidget* parent, UserSettingsPointer pConfig, @@ -39,8 +51,7 @@ WTrackTableView::WTrackTableView(QWidget* parent, bool sorting) : WLibraryTableView(parent, pConfig, - ConfigKey(LIBRARY_CONFIGVALUE, - WTRACKTABLEVIEW_VSCROLLBARPOS_KEY)), + kVScrollBarPosConfigKey), m_pConfig(pConfig), m_pLibrary(pLibrary), m_backgroundColorOpacity(backgroundColorOpacity), @@ -54,7 +65,7 @@ WTrackTableView::WTrackTableView(QWidget* parent, m_pCOTGuiTick = new ControlProxy("[Master]", "guiTick50ms", this); m_pCOTGuiTick->connectValueChanged(this, &WTrackTableView::slotGuiTick50ms); - m_pKeyNotation = new ControlProxy("[Library]", "key_notation", this); + m_pKeyNotation = new ControlProxy(mixxx::library::prefs::kKeyNotationConfigKey, this); m_pKeyNotation->connectValueChanged(this, &WTrackTableView::keyNotationChanged); m_pSortColumn = new ControlProxy("[Library]", "sort_column", this); diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 5e29c5ec270..9db21a36d23 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -18,9 +18,6 @@ class ExternalTrackCollection; class Library; class WTrackMenu; -const QString WTRACKTABLEVIEW_VSCROLLBARPOS_KEY = "VScrollBarPos"; /** ConfigValue key for QTable vertical scrollbar position */ -const QString LIBRARY_CONFIGVALUE = "[Library]"; /** ConfigValue "value" (wtf) for library stuff */ - class WTrackTableView : public WLibraryTableView { Q_OBJECT public: