Skip to content

Commit

Permalink
move some [Library] ConfigKeys to library_prefs.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Apr 15, 2022
1 parent 7573432 commit 1ee63ac
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "engine/enginemaster.h"
#include "library/coverartcache.h"
#include "library/library.h"
#include "library/library_prefs.h"
#include "library/trackcollection.h"
#include "library/trackcollectionmanager.h"
#include "mixer/playerinfo.h"
Expand Down Expand Up @@ -375,7 +376,7 @@ void CoreServices::initialize(QApplication* pApp) {

// Scan the library for new files and directories
bool rescan = pConfig->getValue<bool>(
ConfigKey("[Library]", "RescanOnStartup"));
library::prefs::kRescanOnStartupConfigKey);
// rescan the library if we get a new plugin
QList<QString> prev_plugins_list =
pConfig->getValueString(
Expand Down
25 changes: 25 additions & 0 deletions src/library/library_prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,36 @@ const ConfigKey mixxx::library::prefs::kLegacyDirectoryConfigKey =
const QString mixxx::library::prefs::kConfigGroup =
QStringLiteral("[Library]");

const ConfigKey mixxx::library::prefs::kRescanOnStartupConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("RescanOnStartup")};

const ConfigKey mixxx::library::prefs::kKeyNotationConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("key_notation")};

const ConfigKey mixxx::library::prefs::kTrackDoubleClickActionConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("TrackLoadAction")};

const ConfigKey mixxx::library::prefs::kEditMetadataSelectedClickConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("EditMetadataSelectedClick")};

const ConfigKey mixxx::library::prefs::kHistoryCleanupMinTracksConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("history_cleanup_min_tracks")};

const ConfigKey mixxx::library::prefs::kHistoryCleanupKeepLockedConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("history_cleanup_keep_locked")};

const ConfigKey mixxx::library::prefs::kSearchDebouncingTimeoutMillisConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
Expand All @@ -39,3 +59,8 @@ const ConfigKey mixxx::library::prefs::kSyncSeratoMetadataConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("SeratoMetadataExport")};

const ConfigKey mixxx::library::prefs::kUseRelativePathOnExportConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("UseRelativePathOnExport")};
10 changes: 10 additions & 0 deletions src/library/library_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ extern const ConfigKey kLegacyDirectoryConfigKey;

extern const QString kConfigGroup;

extern const ConfigKey kRescanOnStartupConfigKey;

extern const ConfigKey kKeyNotationConfigKey;

extern const ConfigKey kTrackDoubleClickActionConfigKey;

extern const ConfigKey kSearchDebouncingTimeoutMillisConfigKey;

extern const ConfigKey kEditMetadataSelectedClickConfigKey;

extern const ConfigKey kHistoryCleanupMinTracksConfigKey;

extern const ConfigKey kHistoryCleanupKeepLockedConfigKey;

const bool kEditMetadataSelectedClickDefault = false;

extern const ConfigKey kSyncTrackMetadataConfigKey;
Expand All @@ -26,6 +34,8 @@ extern const ConfigKey kSyncSeratoMetadataConfigKey;

extern const ConfigKey kSyncSeratoMetadataConfigKey;

extern const ConfigKey kUseRelativePathOnExportConfigKey;

} // namespace prefs

} // namespace library
Expand Down
5 changes: 4 additions & 1 deletion src/library/trackset/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "controllers/keyboard/keyboardeventfilter.h"
#include "library/export/trackexportwizard.h"
#include "library/library.h"
#include "library/library_prefs.h"
#include "library/parser.h"
#include "library/parsercsv.h"
#include "library/parserm3u.h"
Expand All @@ -31,6 +32,8 @@ const ConfigKey kConfigKeyLastImportExportPlaylistDirectory(

} // anonymous namespace

using namespace mixxx::library::prefs;

BasePlaylistFeature::BasePlaylistFeature(
Library* pLibrary,
UserSettingsPointer pConfig,
Expand Down Expand Up @@ -568,7 +571,7 @@ void BasePlaylistFeature::slotExportPlaylist() {

// check config if relative paths are desired
bool useRelativePath = m_pConfig->getValue<bool>(
ConfigKey("[Library]", "UseRelativePathOnExport"));
kUseRelativePathOnExportConfigKey);

if (fileLocation.endsWith(".csv", Qt::CaseInsensitive)) {
ParserCsv::writeCSVFile(fileLocation, pPlaylistTableModel.data(), useRelativePath);
Expand Down
5 changes: 4 additions & 1 deletion src/library/trackset/crate/cratefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "library/export/trackexportwizard.h"
#include "library/library.h"
#include "library/library_prefs.h"
#include "library/parser.h"
#include "library/parsercsv.h"
#include "library/parserm3u.h"
Expand Down Expand Up @@ -42,6 +43,8 @@ const ConfigKey kConfigKeyLastImportExportCrateDirectoryKey(

} // anonymous namespace

using namespace mixxx::library::prefs;

CrateFeature::CrateFeature(Library* pLibrary,
UserSettingsPointer pConfig)
: BaseTrackSetFeature(pLibrary, pConfig, "CRATEHOME", QStringLiteral("crates")),
Expand Down Expand Up @@ -739,7 +742,7 @@ void CrateFeature::slotExportPlaylist() {
// check config if relative paths are desired
bool useRelativePath =
m_pConfig->getValue<bool>(
ConfigKey("[Library]", "UseRelativePathOnExport"));
kUseRelativePathOnExportConfigKey);

// Create list of files of the crate
// Create a new table model since the main one might have an active search.
Expand Down
7 changes: 5 additions & 2 deletions src/library/trackset/setlogfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "control/controlobject.h"
#include "library/library.h"
#include "library/library_prefs.h"
#include "library/playlisttablemodel.h"
#include "library/queryutil.h"
#include "library/trackcollection.h"
Expand All @@ -23,6 +24,8 @@ namespace {
constexpr int kNumToplevelHistoryEntries = 5;
}

using namespace mixxx::library::prefs;

SetlogFeature::SetlogFeature(
Library* pLibrary,
UserSettingsPointer pConfig)
Expand Down Expand Up @@ -93,9 +96,9 @@ void SetlogFeature::deleteAllPlaylistsWithFewerTracks() {
->internalCollection()
->database());
int minTrackCount = m_pConfig->getValue(
ConfigKey("[Library]", "history_cleanup_min_tracks"), 1);
kHistoryCleanupMinTracksConfigKey, 1);
bool keepLockedPlaylists = m_pConfig->getValue(
ConfigKey("[Library]", "history_cleanup_keep_locked"), false);
kHistoryCleanupKeepLockedConfigKey, false);
m_playlistDao.deleteAllPlaylistsWithFewerTracks(PlaylistDAO::HiddenType::PLHT_SET_LOG,
minTrackCount,
keepLockedPlaylists);
Expand Down
27 changes: 14 additions & 13 deletions src/preferences/dialog/dlgpreflibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,19 @@ void DlgPrefLibrary::slotResetToDefaults() {
void DlgPrefLibrary::slotUpdate() {
initializeDirList();
checkBox_library_scan->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","RescanOnStartup"), false));
kRescanOnStartupConfigKey, false));

spinbox_min_history_tracks->setValue(m_pConfig->getValue(
ConfigKey("[Library]", "history_cleanup_min_tracks"), 1));
kHistoryCleanupMinTracksConfigKey, 1));
checkBox_history_cleanup_keep_locked->setChecked(m_pConfig->getValue(
ConfigKey("[Library]", "history_cleanup_keep_locked"), false));
kHistoryCleanupKeepLockedConfigKey, false));

checkBox_SyncTrackMetadata->setChecked(
m_pConfig->getValue(kSyncTrackMetadataConfigKey, false));
checkBox_SeratoMetadataExport->setChecked(
m_pConfig->getValue(kSyncSeratoMetadataConfigKey, false));
checkBox_use_relative_path->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","UseRelativePathOnExport"), false));
kUseRelativePathOnExportConfigKey, false));

checkBox_show_rhythmbox->setChecked(m_pConfig->getValue(
ConfigKey("[Library]","ShowRhythmboxLibrary"), true));
Expand All @@ -242,7 +242,7 @@ void DlgPrefLibrary::slotUpdate() {
ConfigKey("[Library]", "ShowSeratoLibrary"), true));

switch (m_pConfig->getValue<int>(
ConfigKey("[Library]", "TrackLoadAction"),
kTrackDoubleClickActionConfigKey,
static_cast<int>(TrackDoubleClickAction::LoadToDeck))) {
case static_cast<int>(TrackDoubleClickAction::AddToAutoDJBottom):
radioButton_dbclick_bottom->setChecked(true);
Expand Down Expand Up @@ -392,15 +392,15 @@ void DlgPrefLibrary::slotSeratoMetadataExportClicked(bool checked) {
}

void DlgPrefLibrary::slotApply() {
m_pConfig->set(ConfigKey("[Library]","RescanOnStartup"),
ConfigValue((int)checkBox_library_scan->isChecked()));
m_pConfig->set(kRescanOnStartupConfigKey,
ConfigValue((int)checkBox_library_scan->isChecked()));

int historyMinTracks = spinbox_min_history_tracks->value();
if (historyMinTracks > 0) {
m_pConfig->set(ConfigKey("[Library]", "history_cleanup_min_tracks"),
m_pConfig->set(kHistoryCleanupMinTracksConfigKey,
ConfigValue(historyMinTracks));
}
m_pConfig->set(ConfigKey("[Library]", "history_cleanup_keep_locked"),
m_pConfig->set(kHistoryCleanupKeepLockedConfigKey,
ConfigValue((int)checkBox_history_cleanup_keep_locked->isChecked()));

m_pConfig->set(
Expand All @@ -410,8 +410,9 @@ void DlgPrefLibrary::slotApply() {
kSyncSeratoMetadataConfigKey,
ConfigValue{checkBox_SeratoMetadataExport->isChecked()});

m_pConfig->set(ConfigKey("[Library]","UseRelativePathOnExport"),
ConfigValue((int)checkBox_use_relative_path->isChecked()));
m_pConfig->set(kUseRelativePathOnExportConfigKey,
ConfigValue((int)checkBox_use_relative_path->isChecked()));

m_pConfig->set(ConfigKey("[Library]","ShowRhythmboxLibrary"),
ConfigValue((int)checkBox_show_rhythmbox->isChecked()));
m_pConfig->set(ConfigKey("[Library]","ShowBansheeLibrary"),
Expand All @@ -435,8 +436,8 @@ void DlgPrefLibrary::slotApply() {
} else { // radioButton_dbclick_ignore
dbclick_status = static_cast<int>(TrackDoubleClickAction::Ignore);
}
m_pConfig->set(ConfigKey("[Library]","TrackLoadAction"),
ConfigValue(dbclick_status));
m_pConfig->set(kTrackDoubleClickActionConfigKey,
ConfigValue(dbclick_status));

m_pConfig->set(kEditMetadataSelectedClickConfigKey,
ConfigValue(checkBoxEditMetadataSelectedClicked->checkState()));
Expand Down
1 change: 0 additions & 1 deletion src/preferences/dialog/dlgpreflibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <QWidget>
#include <memory>

#include "defs_urls.h"
#include "library/library_decl.h"
#include "preferences/dialog/dlgpreferencepage.h"
#include "preferences/dialog/ui_dlgpreflibrarydlg.h"
Expand Down
4 changes: 2 additions & 2 deletions src/widget/wtracktableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ void WTrackTableView::initTrackMenu() {

// slot
void WTrackTableView::slotMouseDoubleClicked(const QModelIndex& index) {
// Read the current TrackLoadAction settings
// Read the current TrackDoubleClickAction setting
int doubleClickActionConfigValue =
m_pConfig->getValue(ConfigKey("[Library]", "TrackLoadAction"),
m_pConfig->getValue(mixxx::library::prefs::kTrackDoubleClickActionConfigKey,
static_cast<int>(DlgPrefLibrary::TrackDoubleClickAction::LoadToDeck));
DlgPrefLibrary::TrackDoubleClickAction doubleClickAction =
static_cast<DlgPrefLibrary::TrackDoubleClickAction>(
Expand Down

0 comments on commit 1ee63ac

Please sign in to comment.