Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: simplify waveform combobox #13220

Merged
merged 19 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d065b8c
feat: simplify waveform combobox
acolombier May 7, 2024
0ace13e
Merge RGB and LRRGB into a single renderer with options
acolombier May 8, 2024
0907c2e
Add option to for signal split waveform
acolombier May 8, 2024
10c4e51
Add waveform option detection and change UI
acolombier May 11, 2024
038c68c
Update the restore slot and remove useless config key
acolombier May 12, 2024
503cd7c
Code style update
acolombier May 20, 2024
10a011a
Merge remote-tracking branch 'upstream/main' into feat/simplify-wavef…
acolombier May 20, 2024
b79a625
Add support for newly introduced filtered waveforms
acolombier May 20, 2024
7bc930a
Reduce the code in macro and use a generic option modifier
acolombier May 20, 2024
4915865
Add TODO for new code
acolombier May 20, 2024
04d9d23
Fix the update path and add tests
acolombier May 21, 2024
9536d13
Don't show VSync if not in developer mode
acolombier May 21, 2024
b4a37b2
Merge remote-tracking branch 'upstream/main' into feat/simplify-wavef…
acolombier May 21, 2024
5c3551d
single waveformwidget class for all allshader waveform widget types, …
May 21, 2024
2155dcc
restored the software renderering (non-opengl) waveforms, deprecated …
May 21, 2024
af24756
Few nits and improve upgrade procedure
acolombier May 22, 2024
f4866ac
Use an enum class for WaveformOption
acolombier May 24, 2024
d414a6e
Bump config version upgrade to 2.6
acolombier May 30, 2024
06c2015
Merge remote-tracking branch 'upstream/main' into feat/simplify-wavef…
acolombier May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,6 @@ if(QOPENGL)
src/waveform/renderers/allshader/waveformrendererslipmode.cpp
src/waveform/renderers/allshader/waveformrendererfiltered.cpp
src/waveform/renderers/allshader/waveformrendererhsv.cpp
src/waveform/renderers/allshader/waveformrendererlrrgb.cpp
src/waveform/renderers/allshader/waveformrendererpreroll.cpp
src/waveform/renderers/allshader/waveformrendererrgb.cpp
src/waveform/renderers/allshader/waveformrenderersignalbase.cpp
Expand All @@ -1529,7 +1528,6 @@ if(QOPENGL)
src/waveform/renderers/allshader/waveformrendermarkrange.cpp
src/waveform/widgets/allshader/filteredwaveformwidget.cpp
src/waveform/widgets/allshader/hsvwaveformwidget.cpp
src/waveform/widgets/allshader/lrrgbwaveformwidget.cpp
src/waveform/widgets/allshader/rgbwaveformwidget.cpp
src/waveform/widgets/allshader/simplewaveformwidget.cpp
src/waveform/widgets/allshader/waveformwidget.cpp
Expand Down
121 changes: 113 additions & 8 deletions src/preferences/dialog/dlgprefwaveform.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at dlg* code is always too tedious for me. Maybe @ronso0 has energy to do so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm sorry. I have no idea about the waveforms, let alone the latest changes and what the options depend on.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,39 @@
#include "waveform/renderers/waveformwidgetrenderer.h"
#include "waveform/waveformwidgetfactory.h"

namespace {
constexpr WaveformWidgetType::Type kDefaultWaveform = WaveformWidgetType::RGB;
const QList<WaveformWidgetType::Type> kWaveformWithOnlyAcceleration = {
WaveformWidgetType::Simple,
WaveformWidgetType::Stacked};
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);
if (kWaveformWithOnlyAcceleration.contains(type)) {
checkbox->setEnabled(false);
checkbox->setChecked(true);
} else if (kWaveformWithoutAcceleration.contains(type)) {
checkbox->setEnabled(false);
checkbox->setChecked(false);
} else {
checkbox->setEnabled(true);
}
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(
QWidget* pParent,
UserSettingsPointer pConfig,
Expand All @@ -27,9 +60,9 @@ DlgPrefWaveform::DlgPrefWaveform(
// We assume that the original type list order remains constant.
// We will use the type index later on to set waveform types and to
// update the combobox.
QVector<WaveformWidgetAbstractHandle> handles = factory->getAvailableTypes();
for (int i = 0; i < handles.size(); ++i) {
waveformTypeComboBox->addItem(handles[i].getDisplayName(), i);
QVector<WaveformWidgetAbstractHandle> types = factory->getAvailableTypes();
for (int i = 0; i < types.size(); ++i) {
waveformTypeComboBox->addItem(types[i].getDisplayName(), types[i].getType());
}
// Sort the combobox items alphabetically
waveformTypeComboBox->model()->sort(0);
Expand Down Expand Up @@ -92,6 +125,15 @@ DlgPrefWaveform::DlgPrefWaveform(
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefWaveform::slotSetWaveformType);

connect(useAccelerationCheckBox,
&QCheckBox::clicked,
this,
&DlgPrefWaveform::slotSetWaveformAcceleration);
connect(splitLeftRightCheckBox,
&QCheckBox::clicked,
this,
&DlgPrefWaveform::slotSetWaveformSplitSignal);
connect(defaultZoomComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
Expand Down Expand Up @@ -162,18 +204,33 @@ DlgPrefWaveform::~DlgPrefWaveform() {
void DlgPrefWaveform::slotUpdate() {
WaveformWidgetFactory* factory = WaveformWidgetFactory::instance();

bool isAccelerationEnabled = false;
if (factory->isOpenGlAvailable() || factory->isOpenGlesAvailable()) {
openGlStatusData->setText(factory->getOpenGLVersion());
useAccelerationCheckBox->setEnabled(true);
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);
useAccelerationCheckBox->setChecked(false);
}

// The combobox holds a list of [handle name, handle index]
int currentIndex = waveformTypeComboBox->findData(factory->getHandleIndex());
int currentIndex = waveformTypeComboBox->findData(factory->getType());
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 @@ -230,7 +287,7 @@ void DlgPrefWaveform::slotResetToDefaults() {
// Get the default we ought to use based on whether the user has OpenGL or not.
// Select the combobox index that holds the default handle's index in data column.
int defaultIndex = waveformTypeComboBox->findData(
factory->findHandleIndexFromType(factory->autoChooseWidgetType()));
factory->findHandleIndexFromType(kDefaultWaveform));
if (defaultIndex != -1 && waveformTypeComboBox->currentIndex() != defaultIndex) {
waveformTypeComboBox->setCurrentIndex(defaultIndex);
}
Expand Down Expand Up @@ -280,14 +337,62 @@ void DlgPrefWaveform::slotSetWaveformType(int index) {
if (index < 0) {
return;
}
int handleIndex = waveformTypeComboBox->itemData(index).toInt();
WaveformWidgetFactory::instance()->setWidgetTypeFromHandle(handleIndex);
auto type = static_cast<WaveformWidgetType::Type>(
waveformTypeComboBox->itemData(index).toInt());
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();
}

void DlgPrefWaveform::slotSetWaveformAcceleration(bool checked) {
if (checked) {
m_pConfig->setValue(ConfigKey("[Waveform]", "use_hardware_acceleration"),
#ifdef MIXXX_USE_QOPENGL
WaveformWidgetBackend::AllShader
#else
WaveformWidgetBackend::GL
#endif
);
} else {
m_pConfig->setValue(
ConfigKey("[Waveform]", "use_hardware_acceleration"),
WaveformWidgetBackend::None);
}
auto type = static_cast<WaveformWidgetType::Type>(waveformTypeComboBox->currentData().toInt());
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() {
const bool enabled = WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark();
#ifndef MIXXX_USE_QOPENGL
const bool enabled = false;
#else
const bool enabled =
WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark() &&
m_pConfig->getValue(
ConfigKey("[Waveform]", "use_hardware_acceleration"),
WaveformWidgetBackend::AllShader) !=
WaveformWidgetBackend::None;
#endif
untilMarkShowBeatsCheckBox->setEnabled(enabled);
untilMarkShowTimeCheckBox->setEnabled(enabled);
untilMarkAlignLabel->setEnabled(enabled);
Expand Down
2 changes: 2 additions & 0 deletions src/preferences/dialog/dlgprefwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg
private slots:
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