Skip to content

Commit

Permalink
Fix line length, naming case, redundant function
Browse files Browse the repository at this point in the history
Resolve line length issues to pass clang-format hook in pre-commit.
Change config key to snake_case.
Remove redundant 'updateCueEnabled' function, call slotToggleCueEnabled
directly instead.
  • Loading branch information
presentformyfriends committed Jul 23, 2024
1 parent c534739 commit 77cc748
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
21 changes: 15 additions & 6 deletions src/engine/sidechain/enginerecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,16 @@ int EngineRecord::updateFromPreferences() {
m_baAuthor = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "Author"));
m_baAlbum = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "Album"));
m_cueFileName = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "CuePath"));
m_bCueIsEnabled = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "CueEnabled")).toInt();
m_bCueUsesFileAnnotation = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "CueFileAnnotationEnabled")).toInt();
m_bCueIsEnabled =
m_pConfig
->getValueString(ConfigKey(
RECORDING_PREF_KEY, "CueEnabled"))
.toInt();
m_bCueUsesFileAnnotation =
m_pConfig
->getValueString(ConfigKey(
RECORDING_PREF_KEY, "cue_file_annotation_enabled"))
.toInt();
m_sampleRate = mixxx::audio::SampleRate::fromDouble(m_sampleRateControl.get());

// Delete m_pEncoder if it has been initialized (with maybe) different bitrate.
Expand Down Expand Up @@ -240,19 +248,19 @@ void EngineRecord::writeCueLine() {
((m_frames / (m_sampleRate / 75)))
% 75);

m_cueFile.write(QString(" TRACK %1 AUDIO\n")
m_cueFile.write(QStringLiteral(" TRACK %1 AUDIO\n")
.arg((double)m_cueTrack, 2, 'f', 0, '0')
.toUtf8());

m_cueFile.write(QString(" TITLE \"%1\"\n")
m_cueFile.write(QStringLiteral(" TITLE \"%1\"\n")
.arg(m_pCurrentTrack->getTitle())
.toUtf8());
m_cueFile.write(QString(" PERFORMER \"%1\"\n")
m_cueFile.write(QStringLiteral(" PERFORMER \"%1\"\n")
.arg(m_pCurrentTrack->getArtist())
.toUtf8());

if (m_bCueUsesFileAnnotation) {
m_cueFile.write(QString(" FILE \"%1\"\n")
m_cueFile.write(QStringLiteral(" FILE \"%1\"\n")
.arg(m_pCurrentTrack->getLocation())
.toUtf8());
}
Expand Down Expand Up @@ -388,3 +396,4 @@ void EngineRecord::closeCueFile() {
m_cueFile.close();
}
}

21 changes: 11 additions & 10 deletions src/preferences/dialog/dlgprefrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace {
constexpr bool kDefaultCueEnabled = true;
constexpr bool kDefaultCueFileAnnotationEnabled = false;
} // anonymous namespace

DlgPrefRecord::DlgPrefRecord(QWidget* parent, UserSettingsPointer pConfig)
Expand Down Expand Up @@ -77,7 +78,8 @@ DlgPrefRecord::DlgPrefRecord(QWidget* parent, UserSettingsPointer pConfig)
ConfigKey(RECORDING_PREF_KEY, "CueEnabled"), kDefaultCueEnabled));

CheckBoxUseCueFileAnnotation->setChecked(m_pConfig->getValue<bool>(
ConfigKey(RECORDING_PREF_KEY, "cue_file_annotation_enabled"), false));
ConfigKey(RECORDING_PREF_KEY, "cue_file_annotation_enabled"),
kDefaultCueFileAnnotationEnabled));

// Setting split
comboBoxSplitting->addItem(SPLIT_650MB);
Expand Down Expand Up @@ -188,7 +190,7 @@ void DlgPrefRecord::slotUpdate() {
CheckBoxRecordCueFile->setChecked(m_pConfig->getValue<bool>(
ConfigKey(RECORDING_PREF_KEY, "CueEnabled"), kDefaultCueEnabled));

updateCueEnabled();
slotToggleCueEnabled();

QString fileSizeStr = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "FileSize"));
int index = comboBoxSplitting->findText(fileSizeStr);
Expand Down Expand Up @@ -319,11 +321,6 @@ void DlgPrefRecord::slotSliderQuality() {
// Settings are only stored when doing an apply so that "cancel" can actually cancel.
}

// Set 'Enable File Annotation in CUE file' checkbox value depending on 'Create a CUE file' checkbox value
void DlgPrefRecord::updateCueEnabled() {
CheckBoxUseCueFileAnnotation->setEnabled(CheckBoxRecordCueFile->isChecked());
}

void DlgPrefRecord::updateTextQuality() {
EncoderRecordingSettingsPointer settings =
EncoderFactory::getFactory().getEncoderRecordingSettings(
Expand Down Expand Up @@ -450,8 +447,11 @@ void DlgPrefRecord::saveEncoding() {
}
}

// Set 'Enable File Annotation in CUE file' checkbox value depending on 'Create
// a CUE file' checkbox value
void DlgPrefRecord::slotToggleCueEnabled() {
updateCueEnabled();
CheckBoxUseCueFileAnnotation->setEnabled(CheckBoxRecordCueFile
->isChecked());
}

void DlgPrefRecord::saveUseCueFile() {
Expand All @@ -460,11 +460,12 @@ void DlgPrefRecord::saveUseCueFile() {
}

void DlgPrefRecord::saveUseCueFileAnnotation() {
m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "CueFileAnnotationEnabled"),
ConfigValue(CheckBoxUseCueFileAnnotation->isChecked()));
m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "cue_file_annotation_enabled"),
ConfigValue(CheckBoxUseCueFileAnnotation->isChecked()));
}

void DlgPrefRecord::saveSplitSize() {
m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "FileSize"),
ConfigValue(comboBoxSplitting->currentText()));
}

1 change: 0 additions & 1 deletion src/preferences/dialog/dlgprefrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class DlgPrefRecord : public DlgPreferencePage, public Ui::DlgPrefRecordDlg {
void saveEncoding();
void saveUseCueFile();
void saveUseCueFileAnnotation();
void updateCueEnabled();
void saveSplitSize();

// Pointer to config object
Expand Down

0 comments on commit 77cc748

Please sign in to comment.