Refactoring
This commit is contained in:
@@ -41,11 +41,11 @@
|
||||
|
||||
#include "backendsettingspage.h"
|
||||
|
||||
#include "core/application.h"
|
||||
#include "constants/backendsettings.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/player.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/player.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "engine/enginedevice.h"
|
||||
#include "engine/devicefinders.h"
|
||||
@@ -58,11 +58,7 @@
|
||||
#include "ui_backendsettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
const char *BackendSettingsPage::kSettingsGroup = "Backend";
|
||||
const qint64 BackendSettingsPage::kDefaultBufferDuration = 4000;
|
||||
const double BackendSettingsPage::kDefaultBufferLowWatermark = 0.33;
|
||||
const double BackendSettingsPage::kDefaultBufferHighWatermark = 0.99;
|
||||
using namespace BackendSettings;
|
||||
|
||||
namespace {
|
||||
constexpr char kOutputAutomaticallySelect[] = "Automatically select";
|
||||
@@ -73,9 +69,11 @@ static const QRegularExpression kRegex_ALSA_PCM_Card(u"^.*:.*CARD=.*"_s);
|
||||
static const QRegularExpression kRegex_ALSA_PCM_Dev(u"^.*:.*DEV=.*"_s);
|
||||
} // namespace
|
||||
|
||||
BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog, const SharedPtr<Player> player, const SharedPtr<DeviceFinders> device_finders, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_BackendSettingsPage),
|
||||
player_(player),
|
||||
device_finders_(device_finders),
|
||||
configloaded_(false),
|
||||
engineloaded_(false),
|
||||
enginetype_current_(EngineBase::Type::None) {
|
||||
@@ -128,22 +126,22 @@ void BackendSettingsPage::Load() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
EngineBase::Type enginetype = EngineBase::TypeFromName(s.value("engine", EngineBase::Name(EngineBase::Type::None)).toString());
|
||||
if (enginetype == EngineBase::Type::None && engine()) enginetype = engine()->type();
|
||||
EngineBase::Type enginetype = EngineBase::TypeFromName(s.value(kEngine, EngineBase::Name(EngineBase::Type::None)).toString());
|
||||
if (enginetype == EngineBase::Type::None && player_->engine()) enginetype = player_->engine()->type();
|
||||
|
||||
ui_->combobox_engine->clear();
|
||||
ui_->combobox_engine->addItem(IconLoader::Load(u"gstreamer"_s), EngineBase::Description(EngineBase::Type::GStreamer), static_cast<int>(EngineBase::Type::GStreamer));
|
||||
|
||||
enginetype_current_ = enginetype;
|
||||
output_current_ = s.value("output", QString()).toString();
|
||||
device_current_ = s.value("device", QVariant());
|
||||
output_current_ = s.value(kOutput, QString()).toString();
|
||||
device_current_ = s.value(kDevice, QVariant());
|
||||
|
||||
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast<int>(enginetype)));
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
ui_->lineedit_device->show();
|
||||
ui_->widget_alsa_plugin->show();
|
||||
const ALSAPluginType alsa_plugin_type = static_cast<ALSAPluginType>(s.value("alsaplugin", static_cast<int>(ALSAPluginType::PCM)).toInt());
|
||||
const ALSAPluginType alsa_plugin_type = static_cast<ALSAPluginType>(s.value(kALSAPlugin, static_cast<int>(ALSAPluginType::PCM)).toInt());
|
||||
switch (alsa_plugin_type) {
|
||||
case ALSAPluginType::HW:
|
||||
ui_->radiobutton_alsa_hw->setChecked(true);
|
||||
@@ -161,34 +159,34 @@ void BackendSettingsPage::Load() {
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
ui_->checkbox_exclusive_mode->setChecked(s.value("exclusive_mode", false).toBool());
|
||||
ui_->checkbox_exclusive_mode->setChecked(s.value(kExclusiveMode, false).toBool());
|
||||
#endif
|
||||
|
||||
if (EngineInitialized()) Load_Engine(enginetype);
|
||||
|
||||
ui_->checkbox_volume_control->setChecked(s.value("volume_control", true).toBool());
|
||||
ui_->checkbox_volume_control->setChecked(s.value(kVolumeControl, true).toBool());
|
||||
|
||||
ui_->checkbox_channels->setChecked(s.value("channels_enabled", false).toBool());
|
||||
ui_->spinbox_channels->setValue(s.value("channels", 2).toInt());
|
||||
ui_->checkbox_channels->setChecked(s.value(kChannelsEnabled, false).toBool());
|
||||
ui_->spinbox_channels->setValue(s.value(kChannels, 2).toInt());
|
||||
ui_->widget_channels->setEnabled(ui_->checkbox_channels->isChecked());
|
||||
|
||||
ui_->checkbox_bs2b->setChecked(s.value("bs2b", false).toBool());
|
||||
ui_->checkbox_bs2b->setChecked(s.value(kBS2B, false).toBool());
|
||||
|
||||
ui_->checkbox_http2->setChecked(s.value("http2", false).toBool());
|
||||
ui_->checkbox_strict_ssl->setChecked(s.value("strict_ssl", false).toBool());
|
||||
ui_->checkbox_http2->setChecked(s.value(kHTTP2, false).toBool());
|
||||
ui_->checkbox_strict_ssl->setChecked(s.value(kStrictSSL, false).toBool());
|
||||
|
||||
ui_->spinbox_bufferduration->setValue(s.value("bufferduration", kDefaultBufferDuration).toInt());
|
||||
ui_->spinbox_low_watermark->setValue(s.value("bufferlowwatermark", kDefaultBufferLowWatermark).toDouble());
|
||||
ui_->spinbox_high_watermark->setValue(s.value("bufferhighwatermark", kDefaultBufferHighWatermark).toDouble());
|
||||
ui_->spinbox_bufferduration->setValue(s.value(kBufferDuration, kDefaultBufferDuration).toInt());
|
||||
ui_->spinbox_low_watermark->setValue(s.value(kBufferLowWatermark, kDefaultBufferLowWatermark).toDouble());
|
||||
ui_->spinbox_high_watermark->setValue(s.value(kBufferHighWatermark, kDefaultBufferHighWatermark).toDouble());
|
||||
|
||||
ui_->radiobutton_replaygain->setChecked(s.value("rgenabled", false).toBool());
|
||||
ui_->combobox_replaygainmode->setCurrentIndex(s.value("rgmode", 0).toInt());
|
||||
ui_->stickyslider_replaygainpreamp->setValue(static_cast<int>(s.value("rgpreamp", 0.0).toDouble() * 10 + 600));
|
||||
ui_->checkbox_replaygaincompression->setChecked(s.value("rgcompression", true).toBool());
|
||||
ui_->stickyslider_replaygainfallbackgain->setValue(static_cast<int>(s.value("rgfallbackgain", 0.0).toDouble() * 10 + 600));
|
||||
ui_->radiobutton_replaygain->setChecked(s.value(kRgEnabled, false).toBool());
|
||||
ui_->combobox_replaygainmode->setCurrentIndex(s.value(kRgMode, 0).toInt());
|
||||
ui_->stickyslider_replaygainpreamp->setValue(static_cast<int>(s.value(kRgPreamp, 0.0).toDouble() * 10 + 600));
|
||||
ui_->checkbox_replaygaincompression->setChecked(s.value(kRgCompression, true).toBool());
|
||||
ui_->stickyslider_replaygainfallbackgain->setValue(static_cast<int>(s.value(kRgFallbackGain, 0.0).toDouble() * 10 + 600));
|
||||
|
||||
ui_->radiobutton_ebur128_loudness_normalization->setChecked(s.value("ebur128_loudness_normalization", false).toBool());
|
||||
ui_->stickyslider_ebur128_target_level->setValue(static_cast<int>(s.value("ebur128_target_level_lufs", -23.0).toDouble() * 10));
|
||||
ui_->radiobutton_ebur128_loudness_normalization->setChecked(s.value(kEBUR128LoudnessNormalization, false).toBool());
|
||||
ui_->stickyslider_ebur128_target_level->setValue(static_cast<int>(s.value(kEBUR128TargetLevelLUFS, -23.0).toDouble() * 10));
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
bool fade_default = false;
|
||||
@@ -196,17 +194,17 @@ void BackendSettingsPage::Load() {
|
||||
bool fade_default = true;
|
||||
#endif
|
||||
|
||||
ui_->checkbox_fadeout_stop->setChecked(s.value("FadeoutEnabled", fade_default).toBool());
|
||||
ui_->checkbox_fadeout_cross->setChecked(s.value("CrossfadeEnabled", fade_default).toBool());
|
||||
ui_->checkbox_fadeout_auto->setChecked(s.value("AutoCrossfadeEnabled", false).toBool());
|
||||
ui_->checkbox_fadeout_samealbum->setChecked(s.value("NoCrossfadeSameAlbum", true).toBool());
|
||||
ui_->checkbox_fadeout_pauseresume->setChecked(s.value("FadeoutPauseEnabled", false).toBool());
|
||||
ui_->spinbox_fadeduration->setValue(s.value("FadeoutDuration", 2000).toInt());
|
||||
ui_->spinbox_fadeduration_pauseresume->setValue(s.value("FadeoutPauseDuration", 250).toInt());
|
||||
ui_->checkbox_fadeout_stop->setChecked(s.value(kFadeoutEnabled, fade_default).toBool());
|
||||
ui_->checkbox_fadeout_cross->setChecked(s.value(kCrossfadeEnabled, fade_default).toBool());
|
||||
ui_->checkbox_fadeout_auto->setChecked(s.value(kAutoCrossfadeEnabled, false).toBool());
|
||||
ui_->checkbox_fadeout_samealbum->setChecked(s.value(kNoCrossfadeSameAlbum, true).toBool());
|
||||
ui_->checkbox_fadeout_pauseresume->setChecked(s.value(kFadeoutPauseEnabled, false).toBool());
|
||||
ui_->spinbox_fadeduration->setValue(s.value(kFadeoutDuration, 2000).toInt());
|
||||
ui_->spinbox_fadeduration_pauseresume->setValue(s.value(kFadeoutPauseDuration, 250).toInt());
|
||||
|
||||
if (!EngineInitialized()) return;
|
||||
|
||||
if (engine()->state() == EngineBase::State::Empty) {
|
||||
if (player_->engine()->state() == EngineBase::State::Empty) {
|
||||
if (ui_->combobox_engine->count() > 1) ui_->combobox_engine->setEnabled(true);
|
||||
else ui_->combobox_engine->setEnabled(false);
|
||||
}
|
||||
@@ -229,7 +227,7 @@ void BackendSettingsPage::Load() {
|
||||
enginetype = ui_->combobox_engine->itemData(ui_->combobox_engine->currentIndex()).value<EngineBase::Type>();
|
||||
QString output_name;
|
||||
if (ui_->combobox_output->currentText().isEmpty()) {
|
||||
output_name = engine()->DefaultOutput();
|
||||
output_name = player_->engine()->DefaultOutput();
|
||||
}
|
||||
else {
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||
@@ -250,7 +248,7 @@ void BackendSettingsPage::Load() {
|
||||
|
||||
bool BackendSettingsPage::EngineInitialized() {
|
||||
|
||||
if (!engine() || engine()->type() == EngineBase::Type::None) {
|
||||
if (!player_->engine() || player_->engine()->type() == EngineBase::Type::None) {
|
||||
errordialog_.ShowMessage(u"Engine is not initialized! Please restart."_s);
|
||||
return false;
|
||||
}
|
||||
@@ -277,12 +275,12 @@ void BackendSettingsPage::Load_Engine(const EngineBase::Type enginetype) {
|
||||
ui_->groupbox_replaygain->setEnabled(false);
|
||||
ui_->groupbox_ebur128->setEnabled(false);
|
||||
|
||||
if (engine()->type() != enginetype) {
|
||||
if (player_->engine()->type() != enginetype) {
|
||||
qLog(Debug) << "Switching engine.";
|
||||
EngineBase::Type new_enginetype = dialog()->app()->player()->CreateEngine(enginetype);
|
||||
dialog()->app()->player()->Init();
|
||||
EngineBase::Type new_enginetype = player_->CreateEngine(enginetype);
|
||||
player_->Init();
|
||||
if (new_enginetype != enginetype) {
|
||||
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast<int>(engine()->type())));
|
||||
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast<int>(player_->engine()->type())));
|
||||
}
|
||||
set_changed();
|
||||
}
|
||||
@@ -297,10 +295,10 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
|
||||
|
||||
if (!EngineInitialized()) return;
|
||||
|
||||
if (output.isEmpty()) output = engine()->DefaultOutput();
|
||||
if (output.isEmpty()) output = player_->engine()->DefaultOutput();
|
||||
|
||||
ui_->combobox_output->clear();
|
||||
const EngineBase::OutputDetailsList outputs = engine()->GetOutputsList();
|
||||
const EngineBase::OutputDetailsList outputs = player_->engine()->GetOutputsList();
|
||||
for (const EngineBase::OutputDetails &o : outputs) {
|
||||
ui_->combobox_output->addItem(IconLoader::Load(o.iconname), o.description, QVariant::fromValue(o));
|
||||
}
|
||||
@@ -316,8 +314,8 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
|
||||
}
|
||||
}
|
||||
if (!found) { // Output is invalid for this engine, reset to default output.
|
||||
output = engine()->DefaultOutput();
|
||||
device = (engine()->CustomDeviceSupport(output) ? QString() : QVariant());
|
||||
output = player_->engine()->DefaultOutput();
|
||||
device = (player_->engine()->CustomDeviceSupport(output) ? QString() : QVariant());
|
||||
for (int i = 0; i < ui_->combobox_output->count(); ++i) {
|
||||
EngineBase::OutputDetails o = ui_->combobox_output->itemData(i).value<EngineBase::OutputDetails>();
|
||||
if (o.name == output) {
|
||||
@@ -327,7 +325,7 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
|
||||
}
|
||||
}
|
||||
|
||||
if (engine()->type() == EngineBase::Type::GStreamer) {
|
||||
if (player_->engine()->type() == EngineBase::Type::GStreamer) {
|
||||
ui_->groupbox_buffer->setEnabled(true);
|
||||
ui_->groupbox_replaygain->setEnabled(true);
|
||||
ui_->groupbox_ebur128->setEnabled(true);
|
||||
@@ -339,7 +337,7 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
ui_->widget_exclusive_mode->setEnabled(engine()->ExclusiveModeSupport(output));
|
||||
ui_->widget_exclusive_mode->setEnabled(player_->engine()->ExclusiveModeSupport(output));
|
||||
#endif
|
||||
|
||||
if (ui_->combobox_output->count() >= 1) Load_Device(output, device);
|
||||
@@ -359,11 +357,11 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
|
||||
ui_->lineedit_device->clear();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if (engine()->type() != EngineBase::Type::GStreamer)
|
||||
if (player_->engine()->type() != EngineBase::Type::GStreamer)
|
||||
#endif
|
||||
ui_->combobox_device->addItem(IconLoader::Load(u"soundcard"_s), QLatin1String(kOutputAutomaticallySelect), QVariant());
|
||||
|
||||
const QList<DeviceFinder*> device_finders = dialog()->app()->device_finders()->ListFinders();
|
||||
const QList<DeviceFinder*> device_finders = device_finders_->ListFinders();
|
||||
for (DeviceFinder *f : device_finders) {
|
||||
if (!f->outputs().contains(output)) continue;
|
||||
const EngineDeviceList engine_devices = f->ListDevices();
|
||||
@@ -374,7 +372,7 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
|
||||
}
|
||||
}
|
||||
|
||||
if (engine()->CustomDeviceSupport(output)) {
|
||||
if (player_->engine()->CustomDeviceSupport(output)) {
|
||||
ui_->combobox_device->addItem(IconLoader::Load(u"soundcard"_s), QLatin1String(kOutputCustom), QVariant());
|
||||
ui_->lineedit_device->setEnabled(true);
|
||||
}
|
||||
@@ -383,7 +381,7 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
|
||||
}
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
if (engine()->ALSADeviceSupport(output)) {
|
||||
if (player_->engine()->ALSADeviceSupport(output)) {
|
||||
ui_->widget_alsa_plugin->setEnabled(true);
|
||||
ui_->radiobutton_alsa_hw->setEnabled(true);
|
||||
ui_->radiobutton_alsa_plughw->setEnabled(true);
|
||||
@@ -435,7 +433,7 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
|
||||
}
|
||||
|
||||
// This allows a custom ALSA device string ie: "hw:0,0" even if it is not listed.
|
||||
if (engine()->CustomDeviceSupport(output) && device.metaType().id() == QMetaType::QString && !device.toString().isEmpty()) {
|
||||
if (player_->engine()->CustomDeviceSupport(output) && device.metaType().id() == QMetaType::QString && !device.toString().isEmpty()) {
|
||||
ui_->lineedit_device->setText(device.toString());
|
||||
if (!found) {
|
||||
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
||||
@@ -447,7 +445,7 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
|
||||
}
|
||||
}
|
||||
|
||||
ui_->combobox_device->setEnabled(devices > 0 || engine()->CustomDeviceSupport(output));
|
||||
ui_->combobox_device->setEnabled(devices > 0 || player_->engine()->CustomDeviceSupport(output));
|
||||
|
||||
FadingOptionsChanged();
|
||||
|
||||
@@ -463,7 +461,7 @@ void BackendSettingsPage::Save() {
|
||||
QVariant device_value;
|
||||
|
||||
if (ui_->combobox_output->currentText().isEmpty()) {
|
||||
output_name = engine()->DefaultOutput();
|
||||
output_name = player_->engine()->DefaultOutput();
|
||||
}
|
||||
else {
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||
@@ -477,51 +475,51 @@ void BackendSettingsPage::Save() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
s.setValue("engine", EngineBase::Name(enginetype));
|
||||
s.setValue("output", output_name);
|
||||
s.setValue("device", device_value);
|
||||
s.setValue(kEngine, EngineBase::Name(enginetype));
|
||||
s.setValue(kOutput, output_name);
|
||||
s.setValue(kDevice, device_value);
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
if (ui_->radiobutton_alsa_hw->isChecked()) s.setValue("alsaplugin", static_cast<int>(ALSAPluginType::HW));
|
||||
else if (ui_->radiobutton_alsa_plughw->isChecked()) s.setValue("alsaplugin", static_cast<int>(ALSAPluginType::PlugHW));
|
||||
else if (ui_->radiobutton_alsa_pcm->isChecked()) s.setValue("alsaplugin", static_cast<int>(ALSAPluginType::PCM));
|
||||
else s.remove("alsaplugin");
|
||||
if (ui_->radiobutton_alsa_hw->isChecked()) s.setValue(kALSAPlugin, static_cast<int>(ALSAPluginType::HW));
|
||||
else if (ui_->radiobutton_alsa_plughw->isChecked()) s.setValue(kALSAPlugin, static_cast<int>(ALSAPluginType::PlugHW));
|
||||
else if (ui_->radiobutton_alsa_pcm->isChecked()) s.setValue(kALSAPlugin, static_cast<int>(ALSAPluginType::PCM));
|
||||
else s.remove(kALSAPlugin);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
s.setValue("exclusive_mode", ui_->checkbox_exclusive_mode->isChecked());
|
||||
s.setValue(kExclusiveMode, ui_->checkbox_exclusive_mode->isChecked());
|
||||
#endif
|
||||
|
||||
s.setValue("volume_control", ui_->checkbox_volume_control->isChecked());
|
||||
s.setValue(kVolumeControl, ui_->checkbox_volume_control->isChecked());
|
||||
|
||||
s.setValue("channels_enabled", ui_->checkbox_channels->isChecked());
|
||||
s.setValue("channels", ui_->spinbox_channels->value());
|
||||
s.setValue(kChannelsEnabled, ui_->checkbox_channels->isChecked());
|
||||
s.setValue(kChannels, ui_->spinbox_channels->value());
|
||||
|
||||
s.setValue("bs2b", ui_->checkbox_bs2b->isChecked());
|
||||
s.setValue(kBS2B, ui_->checkbox_bs2b->isChecked());
|
||||
|
||||
s.setValue("http2", ui_->checkbox_http2->isChecked());
|
||||
s.setValue("strict_ssl", ui_->checkbox_strict_ssl->isChecked());
|
||||
s.setValue(kHTTP2, ui_->checkbox_http2->isChecked());
|
||||
s.setValue(kStrictSSL, ui_->checkbox_strict_ssl->isChecked());
|
||||
|
||||
s.setValue("bufferduration", ui_->spinbox_bufferduration->value());
|
||||
s.setValue("bufferlowwatermark", ui_->spinbox_low_watermark->value());
|
||||
s.setValue("bufferhighwatermark", ui_->spinbox_high_watermark->value());
|
||||
s.setValue(kBufferDuration, ui_->spinbox_bufferduration->value());
|
||||
s.setValue(kBufferLowWatermark, ui_->spinbox_low_watermark->value());
|
||||
s.setValue(kBufferHighWatermark, ui_->spinbox_high_watermark->value());
|
||||
|
||||
s.setValue("rgenabled", ui_->radiobutton_replaygain->isChecked());
|
||||
s.setValue("rgmode", ui_->combobox_replaygainmode->currentIndex());
|
||||
s.setValue("rgpreamp", static_cast<double>(ui_->stickyslider_replaygainpreamp->value()) / 10 - 60);
|
||||
s.setValue("rgfallbackgain", static_cast<double>(ui_->stickyslider_replaygainfallbackgain->value()) / 10 - 60);
|
||||
s.setValue("rgcompression", ui_->checkbox_replaygaincompression->isChecked());
|
||||
s.setValue(kRgEnabled, ui_->radiobutton_replaygain->isChecked());
|
||||
s.setValue(kRgMode, ui_->combobox_replaygainmode->currentIndex());
|
||||
s.setValue(kRgPreamp, static_cast<double>(ui_->stickyslider_replaygainpreamp->value()) / 10 - 60);
|
||||
s.setValue(kRgFallbackGain, static_cast<double>(ui_->stickyslider_replaygainfallbackgain->value()) / 10 - 60);
|
||||
s.setValue(kRgCompression, ui_->checkbox_replaygaincompression->isChecked());
|
||||
|
||||
s.setValue("ebur128_loudness_normalization", ui_->radiobutton_ebur128_loudness_normalization->isChecked());
|
||||
s.setValue("ebur128_target_level_lufs", static_cast<double>(ui_->stickyslider_ebur128_target_level->value()) / 10);
|
||||
s.setValue(kEBUR128LoudnessNormalization, ui_->radiobutton_ebur128_loudness_normalization->isChecked());
|
||||
s.setValue(kEBUR128TargetLevelLUFS, static_cast<double>(ui_->stickyslider_ebur128_target_level->value()) / 10);
|
||||
|
||||
s.setValue("FadeoutEnabled", ui_->checkbox_fadeout_stop->isChecked());
|
||||
s.setValue("CrossfadeEnabled", ui_->checkbox_fadeout_cross->isChecked());
|
||||
s.setValue("AutoCrossfadeEnabled", ui_->checkbox_fadeout_auto->isChecked());
|
||||
s.setValue("NoCrossfadeSameAlbum", ui_->checkbox_fadeout_samealbum->isChecked());
|
||||
s.setValue("FadeoutPauseEnabled", ui_->checkbox_fadeout_pauseresume->isChecked());
|
||||
s.setValue("FadeoutDuration", ui_->spinbox_fadeduration->value());
|
||||
s.setValue("FadeoutPauseDuration", ui_->spinbox_fadeduration_pauseresume->value());
|
||||
s.setValue(kFadeoutEnabled, ui_->checkbox_fadeout_stop->isChecked());
|
||||
s.setValue(kCrossfadeEnabled, ui_->checkbox_fadeout_cross->isChecked());
|
||||
s.setValue(kAutoCrossfadeEnabled, ui_->checkbox_fadeout_auto->isChecked());
|
||||
s.setValue(kNoCrossfadeSameAlbum, ui_->checkbox_fadeout_samealbum->isChecked());
|
||||
s.setValue(kFadeoutPauseEnabled, ui_->checkbox_fadeout_pauseresume->isChecked());
|
||||
s.setValue(kFadeoutDuration, ui_->spinbox_fadeduration->value());
|
||||
s.setValue(kFadeoutPauseDuration, ui_->spinbox_fadeduration_pauseresume->value());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@@ -529,9 +527,9 @@ void BackendSettingsPage::Save() {
|
||||
|
||||
void BackendSettingsPage::Cancel() {
|
||||
|
||||
if (engine() && engine()->type() != enginetype_current_) { // Reset engine back to the original because user cancelled.
|
||||
dialog()->app()->player()->CreateEngine(enginetype_current_);
|
||||
dialog()->app()->player()->Init();
|
||||
if (player_->engine() && player_->engine()->type() != enginetype_current_) { // Reset engine back to the original because user cancelled.
|
||||
player_->CreateEngine(enginetype_current_);
|
||||
player_->Init();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -543,11 +541,11 @@ void BackendSettingsPage::EngineChanged(const int index) {
|
||||
QVariant v = ui_->combobox_engine->itemData(index);
|
||||
EngineBase::Type enginetype = v.value<EngineBase::Type>();
|
||||
|
||||
if (engine()->type() == enginetype) return;
|
||||
if (player_->engine()->type() == enginetype) return;
|
||||
|
||||
if (engine()->state() != EngineBase::State::Empty) {
|
||||
if (player_->engine()->state() != EngineBase::State::Empty) {
|
||||
errordialog_.ShowMessage(u"Can't switch engine while playing!"_s);
|
||||
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast<int>(engine()->type())));
|
||||
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(static_cast<int>(player_->engine()->type())));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -563,7 +561,7 @@ void BackendSettingsPage::OutputChanged(const int index) {
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(index).value<EngineBase::OutputDetails>();
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
ui_->widget_exclusive_mode->setEnabled(engine()->ExclusiveModeSupport(output.name));
|
||||
ui_->widget_exclusive_mode->setEnabled(player_->engine()->ExclusiveModeSupport(output.name));
|
||||
#endif
|
||||
|
||||
Load_Device(output.name, QVariant());
|
||||
@@ -577,7 +575,7 @@ void BackendSettingsPage::DeviceSelectionChanged(int index) {
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||
QVariant device = ui_->combobox_device->itemData(index).value<QVariant>();
|
||||
|
||||
if (engine()->CustomDeviceSupport(output.name)) {
|
||||
if (player_->engine()->CustomDeviceSupport(output.name)) {
|
||||
ui_->lineedit_device->setEnabled(true);
|
||||
if (ui_->combobox_device->currentText() != QLatin1String(kOutputCustom)) {
|
||||
if (device.metaType().id() == QMetaType::QString)
|
||||
@@ -602,7 +600,7 @@ void BackendSettingsPage::DeviceStringChanged() {
|
||||
bool found = false;
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
if (engine()->ALSADeviceSupport(output.name)) {
|
||||
if (player_->engine()->ALSADeviceSupport(output.name)) {
|
||||
if (ui_->lineedit_device->text().contains(kRegex_ALSA_HW) && !ui_->radiobutton_alsa_hw->isChecked()) {
|
||||
ui_->radiobutton_alsa_hw->setChecked(true);
|
||||
SwitchALSADevices(ALSAPluginType::HW);
|
||||
@@ -630,7 +628,7 @@ void BackendSettingsPage::DeviceStringChanged() {
|
||||
}
|
||||
}
|
||||
|
||||
if (engine()->CustomDeviceSupport(output.name)) {
|
||||
if (player_->engine()->CustomDeviceSupport(output.name)) {
|
||||
ui_->lineedit_device->setEnabled(true);
|
||||
if ((!found) && (ui_->combobox_device->currentText() != QLatin1String(kOutputCustom))) {
|
||||
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
|
||||
@@ -711,7 +709,7 @@ void BackendSettingsPage::radiobutton_alsa_hw_clicked(const bool checked) {
|
||||
if (!configloaded_ || !EngineInitialized()) return;
|
||||
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||
if (!engine()->ALSADeviceSupport(output.name)) return;
|
||||
if (!player_->engine()->ALSADeviceSupport(output.name)) return;
|
||||
|
||||
SwitchALSADevices(ALSAPluginType::HW);
|
||||
|
||||
@@ -740,7 +738,7 @@ void BackendSettingsPage::radiobutton_alsa_plughw_clicked(const bool checked) {
|
||||
if (!configloaded_ || !EngineInitialized()) return;
|
||||
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||
if (!engine()->ALSADeviceSupport(output.name)) return;
|
||||
if (!player_->engine()->ALSADeviceSupport(output.name)) return;
|
||||
|
||||
SwitchALSADevices(ALSAPluginType::PlugHW);
|
||||
|
||||
@@ -769,7 +767,7 @@ void BackendSettingsPage::radiobutton_alsa_pcm_clicked(const bool checked) {
|
||||
if (!configloaded_ || !EngineInitialized()) return;
|
||||
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||
if (!engine()->ALSADeviceSupport(output.name)) return;
|
||||
if (!player_->engine()->ALSADeviceSupport(output.name)) return;
|
||||
|
||||
SwitchALSADevices(ALSAPluginType::PCM);
|
||||
|
||||
@@ -827,8 +825,8 @@ void BackendSettingsPage::FadingOptionsChanged() {
|
||||
if (!configloaded_ || !EngineInitialized()) return;
|
||||
|
||||
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
|
||||
if (engine()->type() == EngineBase::Type::GStreamer &&
|
||||
(!engine()->ALSADeviceSupport(output.name) || ui_->lineedit_device->text().isEmpty() || (!ui_->lineedit_device->text().contains(kRegex_ALSA_HW) && !ui_->lineedit_device->text().contains(kRegex_ALSA_PlugHW)))) {
|
||||
if (player_->engine()->type() == EngineBase::Type::GStreamer &&
|
||||
(!player_->engine()->ALSADeviceSupport(output.name) || ui_->lineedit_device->text().isEmpty() || (!ui_->lineedit_device->text().contains(kRegex_ALSA_HW) && !ui_->lineedit_device->text().contains(kRegex_ALSA_PlugHW)))) {
|
||||
ui_->groupbox_fading->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user