Skip to content

Commit

Permalink
Move config group definitions from header to cpp
Browse files Browse the repository at this point in the history
For Library & MacroRecorder the public definition of their
config/control group key was removed and replaced by an entry in the
anonymous namespace in the cpp file.
  • Loading branch information
xeruf committed Jul 31, 2020
1 parent e54928b commit a6e84e9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
24 changes: 11 additions & 13 deletions src/library/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@
#include "widget/wtracktableview.h"

namespace {

const mixxx::Logger kLogger("Library");

const QString kConfigGroup("[Library]");
} // anonymous namespace

//static
const QString Library::kConfigGroup("[Library]");

// This is the name which we use to register the WTrackTableView with the
// WLibrary
Expand Down Expand Up @@ -77,7 +75,7 @@ Library::Library(
m_pAnalysisFeature(nullptr) {
qRegisterMetaType<Library::RemovalType>("Library::RemovalType");

m_pKeyNotation.reset(new ControlObject(ConfigKey(kConfigGroup, "key_notation")));
m_pKeyNotation.reset(new ControlObject(ConfigKey(kLibraryConfigGroup, "key_notation")));

connect(m_pTrackCollectionManager,
&TrackCollectionManager::libraryScanFinished,
Expand Down Expand Up @@ -142,24 +140,24 @@ Library::Library(
// mouse or keyboard if you're using MIDI control and you scroll through them...)
if (RhythmboxFeature::isSupported() &&
m_pConfig->getValue(
ConfigKey(kConfigGroup, "ShowRhythmboxLibrary"), true)) {
ConfigKey(kLibraryConfigGroup, "ShowRhythmboxLibrary"), true)) {
addFeature(new RhythmboxFeature(this, m_pConfig));
}
if (m_pConfig->getValue(
ConfigKey(kConfigGroup, "ShowBansheeLibrary"), true)) {
ConfigKey(kLibraryConfigGroup, "ShowBansheeLibrary"), true)) {
BansheeFeature::prepareDbPath(m_pConfig);
if (BansheeFeature::isSupported()) {
addFeature(new BansheeFeature(this, m_pConfig));
}
}
if (ITunesFeature::isSupported() &&
m_pConfig->getValue(
ConfigKey(kConfigGroup, "ShowITunesLibrary"), true)) {
ConfigKey(kLibraryConfigGroup, "ShowITunesLibrary"), true)) {
addFeature(new ITunesFeature(this, m_pConfig));
}
if (TraktorFeature::isSupported() &&
m_pConfig->getValue(
ConfigKey(kConfigGroup, "ShowTraktorLibrary"), true)) {
ConfigKey(kLibraryConfigGroup, "ShowTraktorLibrary"), true)) {
addFeature(new TraktorFeature(this, m_pConfig));
}

Expand All @@ -168,12 +166,12 @@ Library::Library(
// are mounted/unmounted would be to have some form of timed thread to check
// periodically. Not ideal performance wise.
if (m_pConfig->getValue(
ConfigKey(kConfigGroup, "ShowRekordboxLibrary"), true)) {
ConfigKey(kLibraryConfigGroup, "ShowRekordboxLibrary"), true)) {
addFeature(new RekordboxFeature(this, m_pConfig));
}

if (m_pConfig->getValue(
ConfigKey(kConfigGroup, "ShowSeratoLibrary"), true)) {
ConfigKey(kLibraryConfigGroup, "ShowSeratoLibrary"), true)) {
addFeature(new SeratoFeature(this, m_pConfig));
}

Expand Down Expand Up @@ -204,17 +202,17 @@ Library::Library(
}

m_iTrackTableRowHeight = m_pConfig->getValue(
ConfigKey(kConfigGroup, "RowHeight"), kDefaultRowHeightPx);
ConfigKey(kLibraryConfigGroup, "RowHeight"), kDefaultRowHeightPx);
QString fontStr =
m_pConfig->getValueString(ConfigKey(kConfigGroup, "Font"));
m_pConfig->getValueString(ConfigKey(kLibraryConfigGroup, "Font"));
if (!fontStr.isEmpty()) {
m_trackTableFont.fromString(fontStr);
} else {
m_trackTableFont = QApplication::font();
}

m_editMetadataSelectedClick = m_pConfig->getValue(
ConfigKey(kConfigGroup, "EditMetadataSelectedClick"),
ConfigKey(kLibraryConfigGroup, "EditMetadataSelectedClick"),
PREF_LIBRARY_EDIT_METADATA_DEFAULT);
}

Expand Down
2 changes: 0 additions & 2 deletions src/library/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class Library: public QObject {
Q_OBJECT

public:
static const QString kConfigGroup;

Library(QObject* parent,
UserSettingsPointer pConfig,
mixxx::DbConnectionPoolPtr pDbConnectionPool,
Expand Down
8 changes: 5 additions & 3 deletions src/macros/macrorecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

// TODO(xerus) handle track eject while recording

const QString MacroRecorder::kControlsGroup = QStringLiteral("[MacroRecording]");
namespace {
const QString kConfigGroup = QStringLiteral("[MacroRecording]");
}

MacroRecorder::MacroRecorder()
: m_COToggleRecording(ConfigKey(kControlsGroup, "recording_toggle")),
m_CORecStatus(ConfigKey(kControlsGroup, "recording_status")),
: m_COToggleRecording(ConfigKey(kConfigGroup, "recording_toggle")),
m_CORecStatus(ConfigKey(kConfigGroup, "recording_status")),
m_activeChannel(nullptr),
m_macroRecordingState(State::Disabled),
m_pStartRecordingTimer(this),
Expand Down
2 changes: 0 additions & 2 deletions src/macros/macrorecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
class MacroRecorder : public RecordingManagerBase {
Q_OBJECT
public:
static const QString kControlsGroup;

MacroRecorder();

void startRecording() override;
Expand Down
24 changes: 14 additions & 10 deletions src/test/macros_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "macros/macrorecorder.h"
#include "signalpathtest.h"

namespace {
const QString kConfigGroup = QStringLiteral("[MacroRecording]");
}

TEST(MacrosTest, CreateAndSerializeMacro) {
Macro macro;
EXPECT_EQ(macro.getLength(), 0);
Expand All @@ -31,18 +35,18 @@ TEST(MacroRecordingTest, ClaimRecording) {
recorder.claimRecording();
EXPECT_EQ(recorder.isRecordingActive(), false);
EXPECT_EQ(
ControlProxy(MacroRecorder::kControlsGroup, "recording_status").get(),
ControlProxy(kConfigGroup, "recording_status").get(),
MacroRecorder::Status::Disabled);
recorder.startRecording();
EXPECT_EQ(
ControlProxy(MacroRecorder::kControlsGroup, "recording_status").get(),
ControlProxy(kConfigGroup, "recording_status").get(),
MacroRecorder::Status::Armed);
recorder.claimRecording();
EXPECT_EQ(recorder.isRecordingActive(), true);
recorder.setState(MacroRecorder::State::Armed);
recorder.stopRecording();
EXPECT_EQ(
ControlProxy(MacroRecorder::kControlsGroup, "recording_status").get(),
ControlProxy(kConfigGroup, "recording_status").get(),
MacroRecorder::Status::Disabled);
}

Expand All @@ -68,7 +72,7 @@ TEST(MacroRecordingTest, RecordCueJump) {

recorder.pollRecordingStart();
EXPECT_EQ(
ControlProxy(MacroRecorder::kControlsGroup, "recording_status").get(),
ControlProxy(kConfigGroup, "recording_status").get(),
MacroRecorder::Status::Recording);
}

Expand All @@ -89,13 +93,13 @@ TEST(MacroRecordingTest, StopRecordingAsync) {
TEST(MacroRecordingTest, RecordingToggleControl) {
MacroRecorder recorder;
ControlObject::set(
ConfigKey(MacroRecorder::kControlsGroup, "recording_toggle"), 1);
ConfigKey(kConfigGroup, "recording_toggle"), 1);
EXPECT_EQ(recorder.isRecordingActive(), true);
ControlObject::set(
ConfigKey(MacroRecorder::kControlsGroup, "recording_toggle"), 0);
ConfigKey(kConfigGroup, "recording_toggle"), 0);
EXPECT_EQ(recorder.isRecordingActive(), true);
ControlObject::set(
ConfigKey(MacroRecorder::kControlsGroup, "recording_toggle"), 1);
ConfigKey(kConfigGroup, "recording_toggle"), 1);
EXPECT_EQ(recorder.isRecordingActive(), false);
}

Expand All @@ -110,10 +114,10 @@ class MacroRecorderTest : public SignalPathTest {

TEST_F(MacroRecorderTest, RecordSeek) {
ControlObject::toggle(
ConfigKey(MacroRecorder::kControlsGroup, "recording_toggle"));
ConfigKey(kConfigGroup, "recording_toggle"));
ASSERT_EQ(m_pMacroRecorder->isRecordingActive(), true);
EXPECT_EQ(
ControlProxy(MacroRecorder::kControlsGroup, "recording_status").get(),
ControlProxy(kConfigGroup, "recording_status").get(),
MacroRecorder::Status::Armed);
m_pChannel1->getEngineBuffer()->slotControlSeekExact(50 * mixxx::kEngineChannelCount);
ProcessBuffer();
Expand All @@ -127,7 +131,7 @@ TEST_F(MacroRecorderTest, RecordSeek) {
}

TEST_F(MacroRecorderTest, RecordHotcueActivation) {
ControlObject::toggle(ConfigKey(MacroRecorder::kControlsGroup, "recording_toggle"));
ControlObject::toggle(ConfigKey(kConfigGroup, "recording_toggle"));
ASSERT_EQ(m_pMacroRecorder->isRecordingActive(), true);
ControlObject::toggle(ConfigKey("[Channel1]", "hotcue_1_activate"));
ProcessBuffer();
Expand Down

0 comments on commit a6e84e9

Please sign in to comment.