mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-23 01:55:10 -07:00
* [Settings] Split cache_settings into multiple files Took 9 minutes Took 4 minutes * [Settings] Fwd declare settings classes in cache_settings Took 15 minutes * Fix oracle includes. Took 8 minutes * Address comments, fix windows CI Took 8 minutes * fix copy constructor visibility Took 3 minutes * lint Took 2 minutes * Fix native format tests. Took 5 minutes * Remove test header guard Took 4 seconds * Remove tests invalid in CI environ Took 24 seconds * Adjust to rebase. Took 11 minutes * Change settings file name. Took 8 minutes --------- Co-authored-by: Lukas Brübach <lukas.bruebach@bdosecurity.de> Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
91 lines
No EOL
3.6 KiB
C++
91 lines
No EOL
3.6 KiB
C++
#include "sound_settings_page.h"
|
|
|
|
#include "../../../client/settings/cache_settings.h"
|
|
#include "../client/sound_engine.h"
|
|
|
|
#include <QGridLayout>
|
|
#include <libcockatrice/settings/personal_settings.h>
|
|
#include <libcockatrice/settings/sound_settings.h>
|
|
#include <libcockatrice/utility/macros.h>
|
|
|
|
SoundSettingsPage::SoundSettingsPage()
|
|
{
|
|
soundEnabledCheckBox.setChecked(SettingsCache::instance().sound().getSoundEnabled());
|
|
connect(&soundEnabledCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().sound(),
|
|
&SoundSettings::setSoundEnabled);
|
|
|
|
QString themeName = SettingsCache::instance().sound().getSoundThemeName();
|
|
|
|
QStringList themeDirs = soundEngine->getAvailableThemes().keys();
|
|
for (int i = 0; i < themeDirs.size(); i++) {
|
|
themeBox.addItem(themeDirs[i]);
|
|
if (themeDirs[i] == themeName) {
|
|
themeBox.setCurrentIndex(i);
|
|
}
|
|
}
|
|
|
|
connect(&themeBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &SoundSettingsPage::themeBoxChanged);
|
|
connect(&soundTestButton, &QPushButton::clicked, soundEngine, &SoundEngine::testSound);
|
|
|
|
masterVolumeSlider = new QSlider(Qt::Horizontal);
|
|
masterVolumeSlider->setMinimum(0);
|
|
masterVolumeSlider->setMaximum(100);
|
|
masterVolumeSlider->setValue(SettingsCache::instance().sound().getMasterVolume());
|
|
masterVolumeSlider->setToolTip(QString::number(SettingsCache::instance().sound().getMasterVolume()));
|
|
connect(&SettingsCache::instance().sound(), &SoundSettings::masterVolumeChanged, this,
|
|
&SoundSettingsPage::masterVolumeChanged);
|
|
connect(masterVolumeSlider, &QSlider::sliderReleased, soundEngine, &SoundEngine::testSound);
|
|
connect(masterVolumeSlider, &QSlider::valueChanged, &SettingsCache::instance().sound(),
|
|
&SoundSettings::setMasterVolume);
|
|
|
|
masterVolumeSpinBox = new QSpinBox();
|
|
masterVolumeSpinBox->setMinimum(0);
|
|
masterVolumeSpinBox->setMaximum(100);
|
|
masterVolumeSpinBox->setValue(SettingsCache::instance().sound().getMasterVolume());
|
|
connect(masterVolumeSlider, &QSlider::valueChanged, masterVolumeSpinBox, &QSpinBox::setValue);
|
|
connect(masterVolumeSpinBox, qOverload<int>(&QSpinBox::valueChanged), masterVolumeSlider, &QSlider::setValue);
|
|
|
|
auto *soundGrid = new QGridLayout;
|
|
soundGrid->addWidget(&soundEnabledCheckBox, 0, 0, 1, 3);
|
|
soundGrid->addWidget(&masterVolumeLabel, 1, 0);
|
|
soundGrid->addWidget(masterVolumeSlider, 1, 1);
|
|
soundGrid->addWidget(masterVolumeSpinBox, 1, 2);
|
|
soundGrid->addWidget(&themeLabel, 2, 0);
|
|
soundGrid->addWidget(&themeBox, 2, 1);
|
|
soundGrid->addWidget(&soundTestButton, 3, 1);
|
|
|
|
soundGroupBox = new QGroupBox;
|
|
soundGroupBox->setLayout(soundGrid);
|
|
|
|
auto *mainLayout = new QVBoxLayout;
|
|
mainLayout->addWidget(soundGroupBox);
|
|
mainLayout->addStretch();
|
|
|
|
setLayout(mainLayout);
|
|
|
|
connect(&SettingsCache::instance().personal(), &PersonalSettings::langChanged, this,
|
|
&SoundSettingsPage::retranslateUi);
|
|
retranslateUi();
|
|
}
|
|
|
|
void SoundSettingsPage::themeBoxChanged(int index)
|
|
{
|
|
QStringList themeDirs = soundEngine->getAvailableThemes().keys();
|
|
if (index >= 0 && index < themeDirs.count()) {
|
|
SettingsCache::instance().sound().setSoundThemeName(themeDirs.at(index));
|
|
}
|
|
}
|
|
|
|
void SoundSettingsPage::masterVolumeChanged(int value)
|
|
{
|
|
masterVolumeSlider->setToolTip(QString::number(value));
|
|
}
|
|
|
|
void SoundSettingsPage::retranslateUi()
|
|
{
|
|
soundEnabledCheckBox.setText(tr("Enable &sounds"));
|
|
themeLabel.setText(tr("Current sounds theme:"));
|
|
soundTestButton.setText(tr("Test system sound engine"));
|
|
soundGroupBox->setTitle(tr("Sound settings"));
|
|
masterVolumeLabel.setText(tr("Master volume"));
|
|
} |