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

Qt: Use slider for volume slider #659

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
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
22 changes: 16 additions & 6 deletions src/panda_qt/config_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ ConfigWindow::ConfigWindow(ConfigCallback configCallback, MainWindowCallback win
defaultRomPath->setText(newPath);
}
});
QHBoxLayout* romLayout = new QHBoxLayout;

QHBoxLayout* romLayout = new QHBoxLayout();
romLayout->setSpacing(4);
romLayout->addWidget(defaultRomPath);
romLayout->addWidget(browseRomPath);
Expand Down Expand Up @@ -250,14 +251,23 @@ ConfigWindow::ConfigWindow(ConfigCallback configCallback, MainWindowCallback win
});
audioLayout->addRow(tr("Volume curve"), volumeCurveType);

QSpinBox* volumeRaw = new QSpinBox();
volumeRaw->setRange(0, 200);
volumeRaw->setValue(config.audioDeviceConfig.volumeRaw * 100);
connect(volumeRaw, &QSpinBox::valueChanged, this, [&](int value) {
QLabel* volumeLabel = new QLabel(QString::number(int(config.audioDeviceConfig.volumeRaw * 100)));

QSlider* volumeSlider = new QSlider(Qt::Horizontal);
volumeSlider->setRange(0, 200);
volumeSlider->setValue(int(config.audioDeviceConfig.volumeRaw * 100));
connect(volumeSlider, &QSlider::valueChanged, this, [this, volumeLabel](int value) {
config.audioDeviceConfig.volumeRaw = static_cast<float>(value) / 100.0f;
volumeLabel->setText(QString::number(value));

updateConfig();
});
audioLayout->addRow(tr("Audio device volume"), volumeRaw);

QHBoxLayout* volumeLayout = new QHBoxLayout();
volumeLayout->setSpacing(4);
volumeLayout->addWidget(volumeSlider);
volumeLayout->addWidget(volumeLabel);
audioLayout->addRow(tr("Audio device volume"), volumeLayout);

// Battery settings
QGroupBox* batGroupBox = new QGroupBox(tr("Battery Settings"), this);
Expand Down
Loading