Skip to content

Commit

Permalink
Add option to for signal split waveform
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed May 9, 2024
1 parent 0ace13e commit 0907c2e
Show file tree
Hide file tree
Showing 5 changed files with 437 additions and 393 deletions.
48 changes: 41 additions & 7 deletions src/preferences/dialog/dlgprefwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const QList<WaveformWidgetType::Type> kWaveformWithOnlyAcceleration = {
const QList<WaveformWidgetType::Type> kWaveformWithoutAcceleration = {
WaveformWidgetType::VSyncTest,
WaveformWidgetType::Empty};
const QList<WaveformWidgetType::Type> kWaveformWithSplitSignalSupport = {
WaveformWidgetType::RGB};

void setAccelerationCheckboxProperty(WaveformWidgetType::Type type, QCheckBox* checkbox) {
checkbox->blockSignals(true);
Expand All @@ -30,6 +32,13 @@ void setAccelerationCheckboxProperty(WaveformWidgetType::Type type, QCheckBox* c
}
checkbox->blockSignals(false);
}
void updateStereoSplitVisibility(WaveformWidgetType::Type type,
bool isAccelerationEnabled,
QCheckBox* checkbox) {
checkbox->blockSignals(true);
checkbox->setVisible(isAccelerationEnabled && kWaveformWithSplitSignalSupport.contains(type));
checkbox->blockSignals(false);
}
} // anonymous namespace

DlgPrefWaveform::DlgPrefWaveform(
Expand Down Expand Up @@ -121,6 +130,10 @@ DlgPrefWaveform::DlgPrefWaveform(
&QCheckBox::clicked,
this,
&DlgPrefWaveform::slotSetWaveformAcceleration);
connect(splitLeftRightCheckBox,
&QCheckBox::clicked,
this,
&DlgPrefWaveform::slotSetWaveformSplitSignal);
connect(defaultZoomComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
Expand Down Expand Up @@ -191,14 +204,15 @@ DlgPrefWaveform::~DlgPrefWaveform() {
void DlgPrefWaveform::slotUpdate() {
WaveformWidgetFactory* factory = WaveformWidgetFactory::instance();

bool isAccelerationEnabled = false;
if (factory->isOpenGlAvailable() || factory->isOpenGlesAvailable()) {
openGlStatusData->setText(factory->getOpenGLVersion());
useAccelerationCheckBox->setEnabled(true);
useAccelerationCheckBox->setChecked(
m_pConfig->getValue(
ConfigKey("[Waveform]", "use_hardware_acceleration"),
WaveformWidgetBackend::AllShader) !=
WaveformWidgetBackend::None);
isAccelerationEnabled = m_pConfig->getValue(
ConfigKey("[Waveform]", "use_hardware_acceleration"),
WaveformWidgetBackend::AllShader) !=
WaveformWidgetBackend::None;
useAccelerationCheckBox->setChecked(isAccelerationEnabled);
} else {
openGlStatusData->setText(tr("OpenGL not available") + ": " + factory->getOpenGLVersion());
useAccelerationCheckBox->setEnabled(false);
Expand All @@ -210,8 +224,13 @@ void DlgPrefWaveform::slotUpdate() {
if (currentIndex != -1 && waveformTypeComboBox->currentIndex() != currentIndex) {
waveformTypeComboBox->setCurrentIndex(currentIndex);
}
splitLeftRightCheckBox->setChecked(
m_pConfig->getValue(
ConfigKey("[Waveform]", "split_stereo_signal"),
false));

setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox);
updateStereoSplitVisibility(factory->getType(), isAccelerationEnabled, splitLeftRightCheckBox);
updateEnableUntilMark();

frameRateSpinBox->setValue(factory->getFrameRate());
Expand Down Expand Up @@ -320,10 +339,16 @@ void DlgPrefWaveform::slotSetWaveformType(int index) {
}
auto type = static_cast<WaveformWidgetType::Type>(
waveformTypeComboBox->itemData(index).toInt());
auto factory = WaveformWidgetFactory::instance();
auto* factory = WaveformWidgetFactory::instance();
factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type));

setAccelerationCheckboxProperty(factory->getType(), useAccelerationCheckBox);
bool isAccelerationEnabled = m_pConfig->getValue(
ConfigKey("[Waveform]", "use_hardware_acceleration"),
WaveformWidgetBackend::AllShader) !=
WaveformWidgetBackend::None;
useAccelerationCheckBox->setChecked(isAccelerationEnabled);
updateStereoSplitVisibility(factory->getType(), isAccelerationEnabled, splitLeftRightCheckBox);
updateEnableUntilMark();
}

Expand All @@ -342,12 +367,21 @@ void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) {
WaveformWidgetBackend::None);
}
auto type = static_cast<WaveformWidgetType::Type>(waveformTypeComboBox->currentData().toInt());
auto factory = WaveformWidgetFactory::instance();
auto* factory = WaveformWidgetFactory::instance();
factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true);
updateStereoSplitVisibility(type, checked, splitLeftRightCheckBox);

updateEnableUntilMark();
}

void DlgPrefWaveform::slotSetWaveformSplitSignal(bool checked) {
m_pConfig->setValue(ConfigKey("[Waveform]", "split_stereo_signal"),
checked);
auto type = static_cast<WaveformWidgetType::Type>(waveformTypeComboBox->currentData().toInt());
auto* factory = WaveformWidgetFactory::instance();
factory->setWidgetTypeFromHandle(factory->findHandleIndexFromType(type), true);
}

void DlgPrefWaveform::updateEnableUntilMark() {
#ifndef MIXXX_USE_QOPENGL
const bool enabled = false;
Expand Down
1 change: 1 addition & 0 deletions src/preferences/dialog/dlgprefwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg
void slotSetFrameRate(int frameRate);
void slotSetWaveformType(int index);
void slotSetWaveformAcceleration(bool checked);
void slotSetWaveformSplitSignal(bool checked);
void slotSetWaveformOverviewType(int index);
void slotSetDefaultZoom(int index);
void slotSetZoomSynchronization(bool checked);
Expand Down
Loading

0 comments on commit 0907c2e

Please sign in to comment.