Skip to content

Commit

Permalink
Add CUE file annotation feature logic and UI
Browse files Browse the repository at this point in the history
Add boolean to EngineRecord and initialize it in updateFromPreferences

Add checkbox to DlgPrefRecord to enable file annotation in CUE file

Add logic to ensure checkbox is disabled by default, include tooltip
  • Loading branch information
presentformyfriends committed Jul 14, 2024
1 parent 9b9daca commit c0fadc1
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/engine/sidechain/enginerecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ EngineRecord::EngineRecord(UserSettingsPointer pConfig)
m_recordedDuration(0),
m_iMetaDataLife(0),
m_cueTrack(0),
m_bCueIsEnabled(false) {
m_bCueIsEnabled(false),
m_bCueUsesFileAnnotation(false)
{
m_pRecReady = new ControlProxy(RECORDING_PREF_KEY, "status", this);
m_sampleRate = mixxx::audio::SampleRate::fromDouble(m_sampleRateControl.get());
}
Expand All @@ -36,6 +38,7 @@ int EngineRecord::updateFromPreferences() {
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_sampleRate = mixxx::audio::SampleRate::fromDouble(m_sampleRateControl.get());

// Delete m_pEncoder if it has been initialized (with maybe) different bitrate.
Expand Down Expand Up @@ -248,9 +251,12 @@ void EngineRecord::writeCueLine() {
m_cueFile.write(QString(" PERFORMER \"%1\"\n")
.arg(m_pCurrentTrack->getArtist())
.toUtf8());
m_cueFile.write(QString(" FILE \"%1\"\n")
.arg(m_pCurrentTrack->getLocation())
.toUtf8());

if (m_bCueUsesFileAnnotation) {
m_cueFile.write(QString(" FILE \"%1\"\n")
.arg(m_pCurrentTrack->getLocation())
.toUtf8());
}

// Woefully inaccurate (at the seconds level anyways).
// We'd need a signal fired state tracker
Expand Down
1 change: 1 addition & 0 deletions src/engine/sidechain/enginerecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ class EngineRecord : public QObject, public EncoderCallback, public SideChainWor
QString m_cueFileName;
quint64 m_cueTrack;
bool m_bCueIsEnabled;
bool m_bCueUsesFileAnnotation;
};
40 changes: 39 additions & 1 deletion src/preferences/dialog/dlgprefrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ DlgPrefRecord::DlgPrefRecord(QWidget* parent, UserSettingsPointer pConfig)
CheckBoxRecordCueFile->setChecked(m_pConfig->getValue<bool>(
ConfigKey(RECORDING_PREF_KEY, "CueEnabled"), kDefaultCueEnabled));

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

// Setting split
comboBoxSplitting->addItem(SPLIT_650MB);
comboBoxSplitting->addItem(SPLIT_700MB);
Expand Down Expand Up @@ -119,6 +122,11 @@ DlgPrefRecord::DlgPrefRecord(QWidget* parent, UserSettingsPointer pConfig)
&QAbstractSlider::sliderReleased,
this,
&DlgPrefRecord::slotSliderCompression);

connect(CheckBoxRecordCueFile,
&QCheckBox::stateChanged,
this,
&DlgPrefRecord::slotToggleCueEnabled);
}

DlgPrefRecord::~DlgPrefRecord() {
Expand All @@ -144,6 +152,7 @@ void DlgPrefRecord::slotApply() {
saveMetaData();
saveEncoding();
saveUseCueFile();
saveUseCueFileAnnotation();
saveSplitSize();
}

Expand Down Expand Up @@ -175,10 +184,12 @@ void DlgPrefRecord::slotUpdate() {

loadMetaData();

// Setting miscellaneous
// Setting miscellaneous
CheckBoxRecordCueFile->setChecked(m_pConfig->getValue<bool>(
ConfigKey(RECORDING_PREF_KEY, "CueEnabled"), kDefaultCueEnabled));

updateCueEnabled();

QString fileSizeStr = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "FileSize"));
int index = comboBoxSplitting->findText(fileSizeStr);
if (index >= 0) {
Expand All @@ -201,7 +212,13 @@ void DlgPrefRecord::slotResetToDefaults() {

// 4GB splitting is the default
comboBoxSplitting->setCurrentIndex(4);

// Sets 'Create a CUE file' checkbox value
CheckBoxRecordCueFile->setChecked(kDefaultCueEnabled);

// Sets 'Enable File Annotation in CUE file' checkbox value
CheckBoxUseCueFileAnnotation->setChecked(false);

}

void DlgPrefRecord::slotBrowseRecordingsDir() {
Expand Down Expand Up @@ -303,6 +320,17 @@ 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() {
if (CheckBoxRecordCueFile->isChecked()) {
CheckBoxUseCueFileAnnotation->setEnabled(true);
}
else {
CheckBoxUseCueFileAnnotation->setEnabled(false);
CheckBoxUseCueFileAnnotation->setChecked(false);
}
}

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


void DlgPrefRecord::slotToggleCueEnabled() {
updateCueEnabled();
}

void DlgPrefRecord::saveUseCueFile() {
m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "CueEnabled"),
ConfigValue(CheckBoxRecordCueFile->isChecked()));
}

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

void DlgPrefRecord::saveSplitSize() {
m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "FileSize"),
ConfigValue(comboBoxSplitting->currentText()));
Expand Down
5 changes: 5 additions & 0 deletions src/preferences/dialog/dlgprefrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class DlgPrefRecord : public DlgPreferencePage, public Ui::DlgPrefRecordDlg {
void slotSliderCompression();
void slotGroupChanged();

private slots:
void slotToggleCueEnabled();

signals:
void apply(const QString &);

Expand All @@ -44,6 +47,8 @@ class DlgPrefRecord : public DlgPreferencePage, public Ui::DlgPrefRecordDlg {
void saveMetaData();
void saveEncoding();
void saveUseCueFile();
void saveUseCueFileAnnotation();
void updateCueEnabled();
void saveSplitSize();

// Pointer to config object
Expand Down
15 changes: 15 additions & 0 deletions src/preferences/dialog/dlgprefrecorddlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@
</widget>
</item>


<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="CheckBoxUseCueFileAnnotation">
<property name="toolTip">
<string>This will include the filepath for each track in the CUE file.
This option makes the CUE file less portable and can reveal personal
information from filepaths (i.e. username)</string>
</property>
<property name="text">
<string>Enable File Annotation in CUE file</string>
</property>
</widget>
</item>

</layout>
</widget>
</item>
Expand Down Expand Up @@ -386,6 +400,7 @@
<tabstop>PushButtonBrowseRecordings</tabstop>
<tabstop>comboBoxSplitting</tabstop>
<tabstop>CheckBoxRecordCueFile</tabstop>
<tabstop>CheckBoxUseCueFileAnnotation</tabstop>
<tabstop>SliderCompression</tabstop>
<tabstop>SliderQuality</tabstop>
<tabstop>LineEditTitle</tabstop>
Expand Down

0 comments on commit c0fadc1

Please sign in to comment.