Skip to content

Commit

Permalink
Delay setting up Qt signals for the sliders until the initial assignm…
Browse files Browse the repository at this point in the history
…ent has completed
  • Loading branch information
sakertooth committed Mar 2, 2025
1 parent d7597be commit 7ee4f6c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/gui/modals/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,11 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :

auto sampleRateBox = new QGroupBox{tr("Sample rate"), audio_w};

m_sampleRateSlider = new QSlider{Qt::Horizontal, sampleRateBox};
m_sampleRateSlider = new QSlider{Qt::Horizontal};
m_sampleRateSlider->setRange(0, SUPPORTED_SAMPLERATES.size() - 1);
m_sampleRateSlider->setTickPosition(QSlider::TicksBelow);

auto sampleRateResetButton = new QPushButton{embed::getIconPixmap("reload"), "", sampleRateBox};
auto sampleRateResetButton = new QPushButton{embed::getIconPixmap("reload"), ""};
sampleRateResetButton->setFixedSize(32, 32);

auto sampleRateSubLayout = new QHBoxLayout{};
Expand All @@ -586,18 +586,16 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
m_sampleRate = SUPPORTED_SAMPLERATES[index];
m_sampleRateSlider->setValue(index);
sampleRateLabel->setText(tr("Sample rate: %1").arg(m_sampleRate));

showRestartWarning();
};

setSampleRate(m_sampleRate);

connect(m_sampleRateSlider, &QSlider::valueChanged, this,
[setSampleRate](int value) { setSampleRate(SUPPORTED_SAMPLERATES[value]); });

connect(sampleRateResetButton, &QPushButton::clicked, this,
[setSampleRate] { setSampleRate(SUPPORTED_SAMPLERATES.front()); });

setSampleRate(m_sampleRate);

// Buffer size group
QGroupBox * bufferSizeBox = new QGroupBox(tr("Buffer size"), audio_w);
QVBoxLayout * bufferSizeLayout = new QVBoxLayout(bufferSizeBox);
Expand Down

0 comments on commit 7ee4f6c

Please sign in to comment.