summaryrefslogtreecommitdiffstats
path: root/src/preferences
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-06-13 21:52:25 +0200
committerUwe Klotz <uklotz@mixxx.org>2021-06-13 21:52:25 +0200
commit9e8f678944a52bcccccd659901007b7118fbfebd (patch)
tree723dcef5228074c98cc8486b380e23432ae69a6e /src/preferences
parent9fa60a77bd23b74038169ee85dc5709c31b1cb34 (diff)
parent1e211c571204cdea3da7543b784809b9ef3c9ba5 (diff)
Merge branch '2.3' of git@github.com:mixxxdj/mixxx.git
# Conflicts: # src/waveform/widgets/waveformwidgettype.h
Diffstat (limited to 'src/preferences')
-rw-r--r--src/preferences/dialog/dlgprefwaveform.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp
index faf25c2fca..d1d2e8d35a 100644
--- a/src/preferences/dialog/dlgprefwaveform.cpp
+++ b/src/preferences/dialog/dlgprefwaveform.cpp
@@ -27,11 +27,15 @@ DlgPrefWaveform::DlgPrefWaveform(
// Populate waveform options.
WaveformWidgetFactory* factory = WaveformWidgetFactory::instance();
+ // 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(),
- handles[i].getType());
+ waveformTypeComboBox->addItem(handles[i].getDisplayName(), i);
}
+ // Sort the combobox items alphabetically
+ waveformTypeComboBox->model()->sort(0);
// Populate zoom options.
for (int i = static_cast<int>(WaveformWidgetRenderer::s_waveformMinZoom);
@@ -144,8 +148,8 @@ void DlgPrefWaveform::slotUpdate() {
openGlStatusIcon->setText(tr("OpenGL not available") + ": " + factory->getOpenGLVersion());
}
- WaveformWidgetType::Type currentType = factory->getType();
- int currentIndex = waveformTypeComboBox->findData(currentType);
+ // The combobox holds a list of [handle name, handle index]
+ int currentIndex = waveformTypeComboBox->findData(factory->getHandleIndex());
if (currentIndex != -1 && waveformTypeComboBox->currentIndex() != currentIndex) {
waveformTypeComboBox->setCurrentIndex(currentIndex);
}
@@ -194,10 +198,10 @@ void DlgPrefWaveform::slotApply() {
void DlgPrefWaveform::slotResetToDefaults() {
WaveformWidgetFactory* factory = WaveformWidgetFactory::instance();
- // Get the default we ought to use based on whether the user has OpenGL or
- // not.
- WaveformWidgetType::Type defaultType = factory->autoChooseWidgetType();
- int defaultIndex = waveformTypeComboBox->findData(defaultType);
+ // 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()));
if (defaultIndex != -1 && waveformTypeComboBox->currentIndex() != defaultIndex) {
waveformTypeComboBox->setCurrentIndex(defaultIndex);
}
@@ -247,7 +251,8 @@ void DlgPrefWaveform::slotSetWaveformType(int index) {
if (index < 0) {
return;
}
- WaveformWidgetFactory::instance()->setWidgetTypeFromHandle(index);
+ int handleIndex = waveformTypeComboBox->itemData(index).toInt();
+ WaveformWidgetFactory::instance()->setWidgetTypeFromHandle(handleIndex);
}
void DlgPrefWaveform::slotSetWaveformOverviewType(int index) {