From 4d6590fa5288bbb72d848f94c9b1766007e890e5 Mon Sep 17 00:00:00 2001 From: presentformyfriends Date: Tue, 23 Jul 2024 03:10:42 -0400 Subject: [PATCH] Fix line length, naming case, redundant function 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. --- src/engine/sidechain/enginerecord.cpp | 21 +++++++++++++++------ src/preferences/dialog/dlgprefrecord.cpp | 21 +++++++++++---------- src/preferences/dialog/dlgprefrecord.h | 1 - 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/engine/sidechain/enginerecord.cpp b/src/engine/sidechain/enginerecord.cpp index 61ee564825a..7d803801242 100644 --- a/src/engine/sidechain/enginerecord.cpp +++ b/src/engine/sidechain/enginerecord.cpp @@ -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. @@ -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()); } @@ -388,3 +396,4 @@ void EngineRecord::closeCueFile() { m_cueFile.close(); } } + diff --git a/src/preferences/dialog/dlgprefrecord.cpp b/src/preferences/dialog/dlgprefrecord.cpp index 83c5696da16..bd2fa2908ae 100644 --- a/src/preferences/dialog/dlgprefrecord.cpp +++ b/src/preferences/dialog/dlgprefrecord.cpp @@ -12,6 +12,7 @@ namespace { constexpr bool kDefaultCueEnabled = true; +constexpr bool kDefaultCueFileAnnotationEnabled = false; } // anonymous namespace DlgPrefRecord::DlgPrefRecord(QWidget* parent, UserSettingsPointer pConfig) @@ -77,7 +78,8 @@ DlgPrefRecord::DlgPrefRecord(QWidget* parent, UserSettingsPointer pConfig) ConfigKey(RECORDING_PREF_KEY, "CueEnabled"), kDefaultCueEnabled)); CheckBoxUseCueFileAnnotation->setChecked(m_pConfig->getValue( - ConfigKey(RECORDING_PREF_KEY, "cue_file_annotation_enabled"), false)); + ConfigKey(RECORDING_PREF_KEY, "cue_file_annotation_enabled"), + kDefaultCueFileAnnotationEnabled)); // Setting split comboBoxSplitting->addItem(SPLIT_650MB); @@ -188,7 +190,7 @@ void DlgPrefRecord::slotUpdate() { CheckBoxRecordCueFile->setChecked(m_pConfig->getValue( ConfigKey(RECORDING_PREF_KEY, "CueEnabled"), kDefaultCueEnabled)); - updateCueEnabled(); + slotToggleCueEnabled(); QString fileSizeStr = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "FileSize")); int index = comboBoxSplitting->findText(fileSizeStr); @@ -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( @@ -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() { @@ -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())); } + diff --git a/src/preferences/dialog/dlgprefrecord.h b/src/preferences/dialog/dlgprefrecord.h index bb086885d8a..19d287c43c1 100644 --- a/src/preferences/dialog/dlgprefrecord.h +++ b/src/preferences/dialog/dlgprefrecord.h @@ -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