Refactoring
This commit is contained in:
@@ -43,48 +43,18 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "appearancesettingspage.h"
|
||||
#include "utilities/colorutils.h"
|
||||
#include "constants/appearancesettings.h"
|
||||
#include "constants/filefilterconstants.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/stylehelper.h"
|
||||
#include "core/settings.h"
|
||||
#include "covermanager/albumcoverchoicecontroller.h"
|
||||
#include "widgets/fancytabwidget.h"
|
||||
#include "settingspage.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "ui_appearancesettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
const char *AppearanceSettingsPage::kSettingsGroup = "Appearance";
|
||||
|
||||
const char *AppearanceSettingsPage::kStyle = "style";
|
||||
const char *AppearanceSettingsPage::kSystemThemeIcons = "system_icons";
|
||||
|
||||
const char *AppearanceSettingsPage::kBackgroundImageType = "background_image_type";
|
||||
const char *AppearanceSettingsPage::kBackgroundImageFilename = "background_image_file";
|
||||
const char *AppearanceSettingsPage::kBackgroundImagePosition = "background_image_position";
|
||||
const char *AppearanceSettingsPage::kBackgroundImageStretch = "background_image_stretch";
|
||||
const char *AppearanceSettingsPage::kBackgroundImageDoNotCut = "background_image_do_not_cut";
|
||||
const char *AppearanceSettingsPage::kBackgroundImageKeepAspectRatio = "background_image_keep_aspect_ratio";
|
||||
const char *AppearanceSettingsPage::kBackgroundImageMaxSize = "background_image_max_size";
|
||||
|
||||
const char *AppearanceSettingsPage::kBlurRadius = "blur_radius";
|
||||
const char *AppearanceSettingsPage::kOpacityLevel = "opacity_level";
|
||||
|
||||
const int AppearanceSettingsPage::kDefaultBlurRadius = 0;
|
||||
const int AppearanceSettingsPage::kDefaultOpacityLevel = 40;
|
||||
|
||||
const char *AppearanceSettingsPage::kTabBarSystemColor = "tab_system_color";
|
||||
const char *AppearanceSettingsPage::kTabBarGradient = "tab_gradient";
|
||||
const char *AppearanceSettingsPage::kTabBarColor = "tab_color";
|
||||
|
||||
const char *AppearanceSettingsPage::kIconSizeTabbarSmallMode = "icon_size_tabbar_small_mode";
|
||||
const char *AppearanceSettingsPage::kIconSizeTabbarLargeMode = "icon_size_tabbar_large_mode";
|
||||
const char *AppearanceSettingsPage::kIconSizePlayControlButtons = "icon_size_play_control_buttons";
|
||||
const char *AppearanceSettingsPage::kIconSizePlaylistButtons = "icon_size_playlist_buttons";
|
||||
const char *AppearanceSettingsPage::kIconSizeLeftPanelButtons = "icon_size_left_panel_buttons";
|
||||
const char *AppearanceSettingsPage::kIconSizeConfigureButtons = "icon_size_configure_buttons";
|
||||
|
||||
const char *AppearanceSettingsPage::kPlaylistPlayingSongColor = "playlist_playing_song_color";
|
||||
using namespace AppearanceSettings;
|
||||
|
||||
AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
@@ -160,7 +130,7 @@ void AppearanceSettingsPage::Load() {
|
||||
ui_->tabbar_system_color->setChecked(tabbar_system_color);
|
||||
ui_->tabbar_custom_color->setChecked(!tabbar_system_color);
|
||||
|
||||
current_tabbar_bg_color_ = s.value(kTabBarColor, DefaultTabbarBgColor()).value<QColor>();
|
||||
current_tabbar_bg_color_ = s.value(kTabBarColor, FancyTabWidget::DefaultTabbarBgColor()).value<QColor>();
|
||||
|
||||
UpdateColorSelectorColor(ui_->select_tabbar_color, current_tabbar_bg_color_);
|
||||
TabBarSystemColor(ui_->tabbar_system_color->isChecked());
|
||||
@@ -303,7 +273,7 @@ void AppearanceSettingsPage::UpdateColorSelectorColor(QWidget *color_selector, c
|
||||
|
||||
void AppearanceSettingsPage::SelectBackgroundImage() {
|
||||
|
||||
QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), background_image_filename_, tr(AlbumCoverChoiceController::kLoadImageFileFilter) + u";;"_s + tr(AlbumCoverChoiceController::kAllFilesFilter));
|
||||
QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), background_image_filename_, tr(kLoadImageFileFilter) + u";;"_s + tr(kAllFilesFilterSpec));
|
||||
if (selected_filename.isEmpty()) return;
|
||||
background_image_filename_ = selected_filename;
|
||||
ui_->background_image_filename->setText(background_image_filename_);
|
||||
@@ -321,7 +291,7 @@ void AppearanceSettingsPage::OpacityLevelChanged(int percent) {
|
||||
void AppearanceSettingsPage::TabBarSystemColor(bool checked) {
|
||||
|
||||
if (checked) {
|
||||
current_tabbar_bg_color_ = DefaultTabbarBgColor();
|
||||
current_tabbar_bg_color_ = FancyTabWidget::DefaultTabbarBgColor();
|
||||
UpdateColorSelectorColor(ui_->select_tabbar_color, current_tabbar_bg_color_);
|
||||
}
|
||||
ui_->layout_tabbar_color->setEnabled(!checked);
|
||||
@@ -370,12 +340,3 @@ void AppearanceSettingsPage::PlaylistPlayingSongSelectColor() {
|
||||
|
||||
}
|
||||
|
||||
QColor AppearanceSettingsPage::DefaultTabbarBgColor() {
|
||||
|
||||
QColor color = StyleHelper::highlightColor();
|
||||
if (Utilities::IsColorDark(color)) {
|
||||
color = color.lighter(130);
|
||||
}
|
||||
return color;
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QColor>
|
||||
|
||||
#include "settingspage.h"
|
||||
#include "constants/appearancesettings.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
@@ -42,60 +43,9 @@ class AppearanceSettingsPage : public SettingsPage {
|
||||
explicit AppearanceSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~AppearanceSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
static const char *kStyle;
|
||||
|
||||
static const char *kBackgroundImageType;
|
||||
static const char *kBackgroundImageFilename;
|
||||
static const char *kBackgroundImagePosition;
|
||||
static const char *kBackgroundImageStretch;
|
||||
static const char *kBackgroundImageDoNotCut;
|
||||
static const char *kBackgroundImageKeepAspectRatio;
|
||||
static const char *kBackgroundImageMaxSize;
|
||||
|
||||
static const char *kBlurRadius;
|
||||
static const char *kOpacityLevel;
|
||||
|
||||
static const int kDefaultBlurRadius;
|
||||
static const int kDefaultOpacityLevel;
|
||||
|
||||
static const char *kSystemThemeIcons;
|
||||
|
||||
static const char *kTabBarSystemColor;
|
||||
static const char *kTabBarGradient;
|
||||
static const char *kTabBarColor;
|
||||
|
||||
static const char *kIconSizeTabbarSmallMode;
|
||||
static const char *kIconSizeTabbarLargeMode;
|
||||
static const char *kIconSizePlayControlButtons;
|
||||
static const char *kIconSizePlaylistButtons;
|
||||
static const char *kIconSizeLeftPanelButtons;
|
||||
static const char *kIconSizeConfigureButtons;
|
||||
|
||||
static const char *kPlaylistPlayingSongColor;
|
||||
|
||||
enum class BackgroundImageType {
|
||||
Default,
|
||||
None,
|
||||
Custom,
|
||||
Album,
|
||||
Strawbs
|
||||
};
|
||||
|
||||
enum class BackgroundImagePosition {
|
||||
UpperLeft = 1,
|
||||
UpperRight = 2,
|
||||
Middle = 3,
|
||||
BottomLeft = 4,
|
||||
BottomRight = 5
|
||||
};
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
static QColor DefaultTabbarBgColor();
|
||||
|
||||
private Q_SLOTS:
|
||||
void SelectBackgroundImage();
|
||||
void BlurLevelChanged(int);
|
||||
@@ -112,7 +62,7 @@ class AppearanceSettingsPage : public SettingsPage {
|
||||
Ui_AppearanceSettingsPage *ui_;
|
||||
|
||||
QColor current_tabbar_bg_color_;
|
||||
BackgroundImageType background_image_type_;
|
||||
AppearanceSettings::BackgroundImageType background_image_type_;
|
||||
QString background_image_filename_;
|
||||
QColor current_playlist_playing_song_color_;
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -26,34 +26,26 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "dialogs/errordialog.h"
|
||||
#include "settingspage.h"
|
||||
|
||||
class SettingsDialog;
|
||||
class Ui_BackendSettingsPage;
|
||||
class Player;
|
||||
|
||||
class BackendSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BackendSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit BackendSettingsPage(SettingsDialog *dialog, const SharedPtr<Player> player, const SharedPtr<DeviceFinders> device_finders, QWidget *parent = nullptr);
|
||||
~BackendSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
static const qint64 kDefaultBufferDuration;
|
||||
static const double kDefaultBufferLowWatermark;
|
||||
static const double kDefaultBufferHighWatermark;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
void Cancel() override;
|
||||
|
||||
SharedPtr<EngineBase> engine() const { return dialog()->app()->player()->engine(); }
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
enum class ALSAPluginType {
|
||||
HW = 1,
|
||||
@@ -90,6 +82,9 @@ class BackendSettingsPage : public SettingsPage {
|
||||
|
||||
private:
|
||||
Ui_BackendSettingsPage *ui_;
|
||||
const SharedPtr<Player> player_;
|
||||
const SharedPtr<DeviceFinders> device_finders_;
|
||||
|
||||
bool configloaded_;
|
||||
bool engineloaded_;
|
||||
ErrorDialog errordialog_;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <QGroupBox>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "constants/behavioursettings.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "settings/settingspage.h"
|
||||
@@ -46,11 +47,10 @@
|
||||
#include "ui_behavioursettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace BehaviourSettings;
|
||||
|
||||
class SettingsDialog;
|
||||
|
||||
const char *BehaviourSettingsPage::kSettingsGroup = "Behaviour";
|
||||
|
||||
#ifdef HAVE_TRANSLATIONS
|
||||
namespace {
|
||||
bool LocaleAwareCompare(const QString &a, const QString &b) {
|
||||
@@ -151,26 +151,26 @@ void BehaviourSettingsPage::Load() {
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
ui_->checkbox_keeprunning->setEnabled(true);
|
||||
ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).toBool());
|
||||
ui_->checkbox_keeprunning->setChecked(s.value(kKeepRunning, false).toBool());
|
||||
#else
|
||||
const bool systemtray_available = QSystemTrayIcon::isSystemTrayAvailable();
|
||||
ui_->checkbox_showtrayicon->setEnabled(systemtray_available);
|
||||
ui_->checkbox_showtrayicon->setChecked(systemtray_available && s.value("showtrayicon", true).toBool());
|
||||
ui_->checkbox_showtrayicon->setChecked(systemtray_available && s.value(kShowTrayIcon, true).toBool());
|
||||
ui_->checkbox_keeprunning->setEnabled(systemtray_available && ui_->checkbox_showtrayicon->isChecked());
|
||||
ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).toBool());
|
||||
ui_->checkbox_keeprunning->setChecked(s.value(kKeepRunning, false).toBool());
|
||||
ui_->checkbox_trayicon_progress->setEnabled(systemtray_available && ui_->checkbox_showtrayicon->isChecked());
|
||||
ui_->checkbox_trayicon_progress->setChecked(systemtray_available && ui_->checkbox_showtrayicon->isChecked() && s.value("trayicon_progress", false).toBool());
|
||||
ui_->checkbox_trayicon_progress->setChecked(systemtray_available && ui_->checkbox_showtrayicon->isChecked() && s.value(kTrayIconProgress, false).toBool());
|
||||
ui_->radiobutton_hide->setEnabled(systemtray_available && ui_->checkbox_showtrayicon->isChecked());
|
||||
#ifdef HAVE_DBUS
|
||||
ui_->checkbox_taskbar_progress->setChecked(s.value("taskbar_progress", true).toBool());
|
||||
ui_->checkbox_taskbar_progress->setChecked(s.value(kTaskbarProgress, true).toBool());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ui_->checkbox_resumeplayback->setChecked(s.value("resumeplayback", false).toBool());
|
||||
ui_->checkbox_playingwidget->setChecked(s.value("playing_widget", true).toBool());
|
||||
ui_->checkbox_resumeplayback->setChecked(s.value(kResumePlayback, false).toBool());
|
||||
ui_->checkbox_playingwidget->setChecked(s.value(kPlayingWidget, true).toBool());
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
const StartupBehaviour startup_behaviour = static_cast<StartupBehaviour>(s.value("startupbehaviour", static_cast<int>(StartupBehaviour::Remember)).toInt());
|
||||
const StartupBehaviour startup_behaviour = static_cast<StartupBehaviour>(s.value(kStartupBehaviour, static_cast<int>(StartupBehaviour::Remember)).toInt());
|
||||
switch (startup_behaviour) {
|
||||
case StartupBehaviour::Show:
|
||||
ui_->radiobutton_show->setChecked(true);
|
||||
@@ -188,13 +188,13 @@ void BehaviourSettingsPage::Load() {
|
||||
}
|
||||
;
|
||||
[[fallthrough]];
|
||||
case BehaviourSettingsPage::StartupBehaviour::Remember:
|
||||
case StartupBehaviour::Remember:
|
||||
ui_->radiobutton_remember->setChecked(true);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString name = language_map_.key(s.value("language").toString());
|
||||
QString name = language_map_.key(s.value(kLanguage).toString());
|
||||
if (name.isEmpty()) {
|
||||
ui_->combobox_language->setCurrentIndex(0);
|
||||
}
|
||||
@@ -202,19 +202,19 @@ void BehaviourSettingsPage::Load() {
|
||||
ui_->combobox_language->setCurrentIndex(ui_->combobox_language->findText(name));
|
||||
}
|
||||
|
||||
ui_->combobox_menuplaymode->setCurrentIndex(ui_->combobox_menuplaymode->findData(s.value("menu_playmode", static_cast<int>(PlayBehaviour::Never)).toInt()));
|
||||
ui_->combobox_menuplaymode->setCurrentIndex(ui_->combobox_menuplaymode->findData(s.value(kMenuPlayMode, static_cast<int>(PlayBehaviour::Never)).toInt()));
|
||||
|
||||
ui_->combobox_previousmode->setCurrentIndex(ui_->combobox_previousmode->findData(s.value("menu_previousmode", static_cast<int>(PreviousBehaviour::DontRestart)).toInt()));
|
||||
ui_->combobox_previousmode->setCurrentIndex(ui_->combobox_previousmode->findData(s.value(kMenuPreviousMode, static_cast<int>(PreviousBehaviour::DontRestart)).toInt()));
|
||||
|
||||
ui_->combobox_doubleclickaddmode->setCurrentIndex(ui_->combobox_doubleclickaddmode->findData(s.value("doubleclick_addmode", static_cast<int>(AddBehaviour::Append)).toInt()));
|
||||
ui_->combobox_doubleclickaddmode->setCurrentIndex(ui_->combobox_doubleclickaddmode->findData(s.value(kDoubleClickAddMode, static_cast<int>(AddBehaviour::Append)).toInt()));
|
||||
|
||||
ui_->combobox_doubleclickplaymode->setCurrentIndex(ui_->combobox_doubleclickplaymode->findData(s.value("doubleclick_playmode", static_cast<int>(PlayBehaviour::Never)).toInt()));
|
||||
ui_->combobox_doubleclickplaymode->setCurrentIndex(ui_->combobox_doubleclickplaymode->findData(s.value(kDoubleClickPlayMode, static_cast<int>(PlayBehaviour::Never)).toInt()));
|
||||
|
||||
ui_->combobox_doubleclickplaylistaddmode->setCurrentIndex(ui_->combobox_doubleclickplaylistaddmode->findData(s.value("doubleclick_playlist_addmode", static_cast<int>(PlaylistAddBehaviour::Play)).toInt()));
|
||||
ui_->combobox_doubleclickplaylistaddmode->setCurrentIndex(ui_->combobox_doubleclickplaylistaddmode->findData(s.value(kDoubleClickPlaylistAddMode, static_cast<int>(PlaylistAddBehaviour::Play)).toInt()));
|
||||
|
||||
ui_->spinbox_seekstepsec->setValue(s.value("seek_step_sec", 10).toInt());
|
||||
ui_->spinbox_seekstepsec->setValue(s.value(kSeekStepSec, 10).toInt());
|
||||
|
||||
ui_->spinbox_volumeincrement->setValue(s.value("volume_increment", 5).toInt());
|
||||
ui_->spinbox_volumeincrement->setValue(s.value(kVolumeIncrement, 5).toInt());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@@ -229,14 +229,14 @@ void BehaviourSettingsPage::Save() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
s.setValue("showtrayicon", ui_->checkbox_showtrayicon->isChecked());
|
||||
s.setValue("keeprunning", ui_->checkbox_keeprunning->isChecked());
|
||||
s.setValue("trayicon_progress", ui_->checkbox_trayicon_progress->isChecked());
|
||||
s.setValue(kShowTrayIcon, ui_->checkbox_showtrayicon->isChecked());
|
||||
s.setValue(kKeepRunning, ui_->checkbox_keeprunning->isChecked());
|
||||
s.setValue(kTrayIconProgress, ui_->checkbox_trayicon_progress->isChecked());
|
||||
#if defined(HAVE_DBUS) && !defined(Q_OS_MACOS)
|
||||
s.setValue("taskbar_progress", ui_->checkbox_taskbar_progress->isChecked());
|
||||
s.setValue(kTaskbarProgress, ui_->checkbox_taskbar_progress->isChecked());
|
||||
#endif
|
||||
s.setValue("resumeplayback", ui_->checkbox_resumeplayback->isChecked());
|
||||
s.setValue("playing_widget", ui_->checkbox_playingwidget->isChecked());
|
||||
s.setValue(kResumePlayback, ui_->checkbox_resumeplayback->isChecked());
|
||||
s.setValue(kPlayingWidget, ui_->checkbox_playingwidget->isChecked());
|
||||
|
||||
StartupBehaviour startup_behaviour = StartupBehaviour::Remember;
|
||||
if (ui_->radiobutton_remember->isChecked()) startup_behaviour = StartupBehaviour::Remember;
|
||||
@@ -244,9 +244,9 @@ void BehaviourSettingsPage::Save() {
|
||||
if (ui_->radiobutton_hide->isChecked()) startup_behaviour = StartupBehaviour::Hide;
|
||||
if (ui_->radiobutton_show_maximized->isChecked()) startup_behaviour = StartupBehaviour::ShowMaximized;
|
||||
if (ui_->radiobutton_show_minimized->isChecked()) startup_behaviour = StartupBehaviour::ShowMinimized;
|
||||
s.setValue("startupbehaviour", static_cast<int>(startup_behaviour));
|
||||
s.setValue(kStartupBehaviour, static_cast<int>(startup_behaviour));
|
||||
|
||||
s.setValue("language", language_map_.contains(ui_->combobox_language->currentText()) ? language_map_[ui_->combobox_language->currentText()] : QString());
|
||||
s.setValue(kLanguage, language_map_.contains(ui_->combobox_language->currentText()) ? language_map_[ui_->combobox_language->currentText()] : QString());
|
||||
|
||||
const PlayBehaviour menu_playmode = static_cast<PlayBehaviour>(ui_->combobox_menuplaymode->currentData().toInt());
|
||||
|
||||
@@ -257,15 +257,15 @@ void BehaviourSettingsPage::Save() {
|
||||
|
||||
const PlaylistAddBehaviour doubleclick_playlist_addmode = static_cast<PlaylistAddBehaviour>(ui_->combobox_doubleclickplaylistaddmode->currentData().toInt());
|
||||
|
||||
s.setValue("menu_playmode", static_cast<int>(menu_playmode));
|
||||
s.setValue("menu_previousmode", static_cast<int>(menu_previousmode));
|
||||
s.setValue("doubleclick_addmode", static_cast<int>(doubleclick_addmode));
|
||||
s.setValue("doubleclick_playmode", static_cast<int>(doubleclick_playmode));
|
||||
s.setValue("doubleclick_playlist_addmode", static_cast<int>(doubleclick_playlist_addmode));
|
||||
s.setValue(kMenuPlayMode, static_cast<int>(menu_playmode));
|
||||
s.setValue(kMenuPreviousMode, static_cast<int>(menu_previousmode));
|
||||
s.setValue(kDoubleClickAddMode, static_cast<int>(doubleclick_addmode));
|
||||
s.setValue(kDoubleClickPlayMode, static_cast<int>(doubleclick_playmode));
|
||||
s.setValue(kDoubleClickPlaylistAddMode, static_cast<int>(doubleclick_playlist_addmode));
|
||||
|
||||
s.setValue("seek_step_sec", ui_->spinbox_seekstepsec->value());
|
||||
s.setValue(kSeekStepSec, ui_->spinbox_seekstepsec->value());
|
||||
|
||||
s.setValue("volume_increment", ui_->spinbox_volumeincrement->value());
|
||||
s.setValue(kVolumeIncrement, ui_->spinbox_volumeincrement->value());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
|
||||
@@ -40,40 +40,6 @@ class BehaviourSettingsPage : public SettingsPage {
|
||||
explicit BehaviourSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~BehaviourSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
// Don't change the values
|
||||
enum class StartupBehaviour {
|
||||
Remember = 1,
|
||||
Show = 2,
|
||||
Hide = 3,
|
||||
ShowMaximized = 4,
|
||||
ShowMinimized = 5
|
||||
};
|
||||
|
||||
enum class PlayBehaviour {
|
||||
Never = 1,
|
||||
IfStopped = 2,
|
||||
Always = 3
|
||||
};
|
||||
|
||||
enum class PreviousBehaviour {
|
||||
DontRestart = 1,
|
||||
Restart = 2
|
||||
};
|
||||
|
||||
enum class AddBehaviour {
|
||||
Append = 1,
|
||||
Enqueue = 2,
|
||||
Load = 3,
|
||||
OpenInNew = 4
|
||||
};
|
||||
|
||||
enum class PlaylistAddBehaviour {
|
||||
Play = 1,
|
||||
Enqueue = 2
|
||||
};
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
|
||||
@@ -43,12 +43,10 @@
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "utilities/strutils.h"
|
||||
#include "utilities/timeutils.h"
|
||||
#include "collection/collection.h"
|
||||
#include "collection/collectionlibrary.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "collection/collectiondirectory.h"
|
||||
@@ -58,25 +56,25 @@
|
||||
#include "playlist/playlistdelegates.h"
|
||||
#include "settings/settingsdialog.h"
|
||||
#include "settings/settingspage.h"
|
||||
#include "constants/collectionsettings.h"
|
||||
#include "ui_collectionsettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace CollectionSettings;
|
||||
|
||||
const char *CollectionSettingsPage::kSettingsGroup = "Collection";
|
||||
const char *CollectionSettingsPage::kSettingsCacheSize = "cache_size";
|
||||
const char *CollectionSettingsPage::kSettingsCacheSizeUnit = "cache_size_unit";
|
||||
const char *CollectionSettingsPage::kSettingsDiskCacheEnable = "disk_cache_enable";
|
||||
const char *CollectionSettingsPage::kSettingsDiskCacheSize = "disk_cache_size";
|
||||
const char *CollectionSettingsPage::kSettingsDiskCacheSizeUnit = "disk_cache_size_unit";
|
||||
const int CollectionSettingsPage::kSettingsCacheSizeDefault = 160;
|
||||
const int CollectionSettingsPage::kSettingsDiskCacheSizeDefault = 360;
|
||||
|
||||
CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog,
|
||||
const SharedPtr<CollectionLibrary> collection,
|
||||
const SharedPtr<CollectionBackend> collection_backend,
|
||||
CollectionModel *collection_model,
|
||||
CollectionDirectoryModel *collection_directory_model,
|
||||
QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_CollectionSettingsPage),
|
||||
collection_backend_(dialog->app()->collection_backend()),
|
||||
collection_(collection),
|
||||
collection_backend_(collection_backend),
|
||||
collection_model_(collection_model),
|
||||
collectionsettings_directory_model_(new CollectionSettingsDirectoryModel(this)),
|
||||
collection_directory_model_(dialog->collection_directory_model()),
|
||||
collection_directory_model_(collection_directory_model),
|
||||
initialized_model_(false) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
@@ -105,7 +103,7 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog, QWidget *
|
||||
#else
|
||||
QObject::connect(ui_->checkbox_disk_cache, &QCheckBox::stateChanged, this, &CollectionSettingsPage::DiskCacheEnable);
|
||||
#endif
|
||||
QObject::connect(ui_->button_clear_disk_cache, &QPushButton::clicked, dialog->app(), &Application::ClearPixmapDiskCache);
|
||||
|
||||
QObject::connect(ui_->button_clear_disk_cache, &QPushButton::clicked, this, &CollectionSettingsPage::ClearPixmapDiskCache);
|
||||
|
||||
QObject::connect(ui_->combobox_cache_size, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CollectionSettingsPage::CacheSizeUnitChanged);
|
||||
@@ -147,19 +145,19 @@ void CollectionSettingsPage::Load() {
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(kSettingsGroup);
|
||||
ui_->auto_open->setChecked(s.value("auto_open", true).toBool());
|
||||
ui_->show_dividers->setChecked(s.value("show_dividers", true).toBool());
|
||||
ui_->pretty_covers->setChecked(s.value("pretty_covers", true).toBool());
|
||||
ui_->various_artists->setChecked(s.value("various_artists", true).toBool());
|
||||
ui_->sort_skips_articles->setChecked(s.value("sort_skips_articles", true).toBool());
|
||||
ui_->startup_scan->setChecked(s.value("startup_scan", true).toBool());
|
||||
ui_->monitor->setChecked(s.value("monitor", true).toBool());
|
||||
ui_->song_tracking->setChecked(s.value("song_tracking", false).toBool());
|
||||
ui_->song_ebur128_loudness_analysis->setChecked(s.value("song_ebur128_loudness_analysis", false).toBool());
|
||||
ui_->mark_songs_unavailable->setChecked(ui_->song_tracking->isChecked() ? true : s.value("mark_songs_unavailable", true).toBool());
|
||||
ui_->expire_unavailable_songs_days->setValue(s.value("expire_unavailable_songs", 60).toInt());
|
||||
ui_->auto_open->setChecked(s.value(kAutoOpen, true).toBool());
|
||||
ui_->show_dividers->setChecked(s.value(kShowDividers, true).toBool());
|
||||
ui_->pretty_covers->setChecked(s.value(kPrettyCovers, true).toBool());
|
||||
ui_->various_artists->setChecked(s.value(kVariousArtists, true).toBool());
|
||||
ui_->sort_skips_articles->setChecked(s.value(kSortSkipsArticles, true).toBool());
|
||||
ui_->startup_scan->setChecked(s.value(kStartupScan, true).toBool());
|
||||
ui_->monitor->setChecked(s.value(kMonitor, true).toBool());
|
||||
ui_->song_tracking->setChecked(s.value(kSongTracking, false).toBool());
|
||||
ui_->song_ebur128_loudness_analysis->setChecked(s.value(kSongENUR128LoudnessAnalysis, false).toBool());
|
||||
ui_->mark_songs_unavailable->setChecked(ui_->song_tracking->isChecked() ? true : s.value(kMarkSongsUnavailable, true).toBool());
|
||||
ui_->expire_unavailable_songs_days->setValue(s.value(kExpireUnavailableSongs, 60).toInt());
|
||||
|
||||
QStringList filters = s.value("cover_art_patterns", QStringList() << u"front"_s << u"cover"_s).toStringList();
|
||||
QStringList filters = s.value(kCoverArtPatterns, QStringList() << u"front"_s << u"cover"_s).toStringList();
|
||||
ui_->cover_art_patterns->setText(filters.join(u','));
|
||||
|
||||
ui_->spinbox_cache_size->setValue(s.value(kSettingsCacheSize, kSettingsCacheSizeDefault).toInt());
|
||||
@@ -168,18 +166,18 @@ void CollectionSettingsPage::Load() {
|
||||
ui_->spinbox_disk_cache_size->setValue(s.value(kSettingsDiskCacheSize, kSettingsDiskCacheSizeDefault).toInt());
|
||||
ui_->combobox_disk_cache_size->setCurrentIndex(ui_->combobox_disk_cache_size->findData(s.value(kSettingsDiskCacheSizeUnit, static_cast<int>(CacheSizeUnit::MB)).toInt()));
|
||||
|
||||
ui_->checkbox_save_playcounts->setChecked(s.value("save_playcounts", false).toBool());
|
||||
ui_->checkbox_save_ratings->setChecked(s.value("save_ratings", false).toBool());
|
||||
ui_->checkbox_overwrite_playcount->setChecked(s.value("overwrite_playcount", false).toBool());
|
||||
ui_->checkbox_overwrite_rating->setChecked(s.value("overwrite_rating", false).toBool());
|
||||
ui_->checkbox_save_playcounts->setChecked(s.value(kSavePlayCounts, false).toBool());
|
||||
ui_->checkbox_save_ratings->setChecked(s.value(kSaveRatings, false).toBool());
|
||||
ui_->checkbox_overwrite_playcount->setChecked(s.value(kOverwritePlaycount, false).toBool());
|
||||
ui_->checkbox_overwrite_rating->setChecked(s.value(kOverwriteRating, false).toBool());
|
||||
|
||||
ui_->checkbox_delete_files->setChecked(s.value("delete_files", false).toBool());
|
||||
ui_->checkbox_delete_files->setChecked(s.value(kDeleteFiles, false).toBool());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
DiskCacheEnable(ui_->checkbox_disk_cache->checkState());
|
||||
|
||||
ui_->disk_cache_in_use->setText((dialog()->app()->collection_model()->icon_cache_disk_size() == 0 ? u"empty"_s : Utilities::PrettySize(dialog()->app()->collection_model()->icon_cache_disk_size())));
|
||||
UpdateIconDiskCacheSize();
|
||||
|
||||
Init(ui_->layout_collectionsettingspage->parentWidget());
|
||||
if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
|
||||
@@ -191,23 +189,23 @@ void CollectionSettingsPage::Save() {
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("auto_open", ui_->auto_open->isChecked());
|
||||
s.setValue("show_dividers", ui_->show_dividers->isChecked());
|
||||
s.setValue("pretty_covers", ui_->pretty_covers->isChecked());
|
||||
s.setValue("various_artists", ui_->various_artists->isChecked());
|
||||
s.setValue("sort_skips_articles", ui_->sort_skips_articles->isChecked());
|
||||
s.setValue("startup_scan", ui_->startup_scan->isChecked());
|
||||
s.setValue("monitor", ui_->monitor->isChecked());
|
||||
s.setValue("song_tracking", ui_->song_tracking->isChecked());
|
||||
s.setValue("song_ebur128_loudness_analysis", ui_->song_ebur128_loudness_analysis->isChecked());
|
||||
s.setValue("mark_songs_unavailable", ui_->song_tracking->isChecked() ? true : ui_->mark_songs_unavailable->isChecked());
|
||||
s.setValue("expire_unavailable_songs", ui_->expire_unavailable_songs_days->value());
|
||||
s.setValue(kAutoOpen, ui_->auto_open->isChecked());
|
||||
s.setValue(kShowDividers, ui_->show_dividers->isChecked());
|
||||
s.setValue(kPrettyCovers, ui_->pretty_covers->isChecked());
|
||||
s.setValue(kVariousArtists, ui_->various_artists->isChecked());
|
||||
s.setValue(kSortSkipsArticles, ui_->sort_skips_articles->isChecked());
|
||||
s.setValue(kStartupScan, ui_->startup_scan->isChecked());
|
||||
s.setValue(kMonitor, ui_->monitor->isChecked());
|
||||
s.setValue(kSongTracking, ui_->song_tracking->isChecked());
|
||||
s.setValue(kSongENUR128LoudnessAnalysis, ui_->song_ebur128_loudness_analysis->isChecked());
|
||||
s.setValue(kMarkSongsUnavailable, ui_->song_tracking->isChecked() ? true : ui_->mark_songs_unavailable->isChecked());
|
||||
s.setValue(kExpireUnavailableSongs, ui_->expire_unavailable_songs_days->value());
|
||||
|
||||
QString filter_text = ui_->cover_art_patterns->text();
|
||||
|
||||
const QStringList filters = filter_text.split(u',', Qt::SkipEmptyParts);
|
||||
|
||||
s.setValue("cover_art_patterns", filters);
|
||||
s.setValue(kCoverArtPatterns, filters);
|
||||
|
||||
s.setValue(kSettingsCacheSize, ui_->spinbox_cache_size->value());
|
||||
s.setValue(kSettingsCacheSizeUnit, ui_->combobox_cache_size->currentData().toInt());
|
||||
@@ -215,12 +213,12 @@ void CollectionSettingsPage::Save() {
|
||||
s.setValue(kSettingsDiskCacheSize, ui_->spinbox_disk_cache_size->value());
|
||||
s.setValue(kSettingsDiskCacheSizeUnit, ui_->combobox_disk_cache_size->currentData().toInt());
|
||||
|
||||
s.setValue("save_playcounts", ui_->checkbox_save_playcounts->isChecked());
|
||||
s.setValue("save_ratings", ui_->checkbox_save_ratings->isChecked());
|
||||
s.setValue("overwrite_playcount", ui_->checkbox_overwrite_playcount->isChecked());
|
||||
s.setValue("overwrite_rating", ui_->checkbox_overwrite_rating->isChecked());
|
||||
s.setValue(kSavePlayCounts, ui_->checkbox_save_playcounts->isChecked());
|
||||
s.setValue(kSaveRatings, ui_->checkbox_save_ratings->isChecked());
|
||||
s.setValue(kOverwritePlaycount, ui_->checkbox_overwrite_playcount->isChecked());
|
||||
s.setValue(kOverwriteRating, ui_->checkbox_overwrite_rating->isChecked());
|
||||
|
||||
s.setValue("delete_files", ui_->checkbox_delete_files->isChecked());
|
||||
s.setValue(kDeleteFiles, ui_->checkbox_delete_files->isChecked());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@@ -245,14 +243,14 @@ void CollectionSettingsPage::AddDirectory() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
QString path = s.value("last_path", QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).toString();
|
||||
QString path = s.value(kLastPath, QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).toString();
|
||||
path = QDir::cleanPath(QFileDialog::getExistingDirectory(this, tr("Add directory..."), path));
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
collectionsettings_directory_model_->AddDirectory(path);
|
||||
}
|
||||
|
||||
s.setValue("last_path", path);
|
||||
s.setValue(kLastPath, path);
|
||||
|
||||
set_changed();
|
||||
|
||||
@@ -297,7 +295,9 @@ void CollectionSettingsPage::DiskCacheEnable(const int state) {
|
||||
|
||||
void CollectionSettingsPage::ClearPixmapDiskCache() {
|
||||
|
||||
ui_->disk_cache_in_use->setText(u"empty"_s);
|
||||
collection_model_->ClearIconDiskCache();
|
||||
|
||||
UpdateIconDiskCacheSize();
|
||||
|
||||
}
|
||||
|
||||
@@ -331,6 +331,12 @@ void CollectionSettingsPage::DiskCacheSizeUnitChanged(int index) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::UpdateIconDiskCacheSize() {
|
||||
|
||||
ui_->disk_cache_in_use->setText(collection_model_->icon_disk_cache_size() == 0 ? u"empty"_s : Utilities::PrettySize(collection_model_->icon_disk_cache_size()));
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::WriteAllSongsStatisticsToFiles() {
|
||||
|
||||
QMessageBox confirmation_dialog(QMessageBox::Question, tr("Write all playcounts and ratings to files"), tr("Are you sure you want to write song playcounts and ratings to file for all songs in your collection?"), QMessageBox::Yes | QMessageBox::Cancel);
|
||||
@@ -338,6 +344,6 @@ void CollectionSettingsPage::WriteAllSongsStatisticsToFiles() {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog()->app()->collection()->SyncPlaycountAndRatingToFilesAsync();
|
||||
collection_->SyncPlaycountAndRatingToFilesAsync();
|
||||
|
||||
}
|
||||
|
||||
@@ -30,11 +30,13 @@
|
||||
|
||||
#include "settingspage.h"
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
|
||||
class QModelIndex;
|
||||
class SettingsDialog;
|
||||
class CollectionLibrary;
|
||||
class CollectionBackend;
|
||||
class CollectionModel;
|
||||
class CollectionDirectoryModel;
|
||||
class CollectionSettingsDirectoryModel;
|
||||
class Ui_CollectionSettingsPage;
|
||||
@@ -43,25 +45,9 @@ class CollectionSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollectionSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit CollectionSettingsPage(SettingsDialog *dialog, const SharedPtr<CollectionLibrary> collection, const SharedPtr<CollectionBackend> collection_backend, CollectionModel *collection_model, CollectionDirectoryModel *collection_directory_model, QWidget *parent = nullptr);
|
||||
~CollectionSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
static const char *kSettingsCacheSize;
|
||||
static const char *kSettingsCacheSizeUnit;
|
||||
static const char *kSettingsDiskCacheEnable;
|
||||
static const char *kSettingsDiskCacheSize;
|
||||
static const char *kSettingsDiskCacheSizeUnit;
|
||||
static const int kSettingsCacheSizeDefault;
|
||||
static const int kSettingsDiskCacheSizeDefault;
|
||||
|
||||
enum class CacheSizeUnit {
|
||||
KB,
|
||||
MB,
|
||||
GB,
|
||||
TB
|
||||
};
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -81,9 +67,15 @@ class CollectionSettingsPage : public SettingsPage {
|
||||
void DiskCacheSizeUnitChanged(int index);
|
||||
void WriteAllSongsStatisticsToFiles();
|
||||
|
||||
private:
|
||||
void UpdateIconDiskCacheSize();
|
||||
|
||||
private:
|
||||
Ui_CollectionSettingsPage *ui_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
|
||||
const SharedPtr<CollectionLibrary> collection_;
|
||||
const SharedPtr<CollectionBackend> collection_backend_;
|
||||
CollectionModel *collection_model_;
|
||||
CollectionSettingsDirectoryModel *collectionsettings_directory_model_;
|
||||
CollectionDirectoryModel *collection_directory_model_;
|
||||
bool initialized_model_;
|
||||
|
||||
@@ -36,30 +36,17 @@
|
||||
#include <QFontComboBox>
|
||||
#include <QSettings>
|
||||
|
||||
#include "constants/mainwindowsettings.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/mainwindow.h"
|
||||
#include "core/settings.h"
|
||||
#include "constants/contextsettings.h"
|
||||
#include "settingspage.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "contextsettingspage.h"
|
||||
#include "ui_contextsettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
const char *ContextSettingsPage::kSettingsGroup = "Context";
|
||||
const char *ContextSettingsPage::kSettingsTitleFmt = "TitleFmt";
|
||||
const char *ContextSettingsPage::kSettingsSummaryFmt = "SummaryFmt";
|
||||
|
||||
const char *ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsOrder::NELEMS)] = {
|
||||
"AlbumEnable",
|
||||
"TechnicalDataEnable",
|
||||
"SongLyricsEnable",
|
||||
"SearchCoverEnable",
|
||||
"SearchLyricsEnable",
|
||||
};
|
||||
|
||||
const char ContextSettingsPage::kDefaultFontFamily[] = "Noto Sans";
|
||||
const qreal ContextSettingsPage::kDefaultFontSizeHeadline = 11;
|
||||
using namespace ContextSettings;
|
||||
|
||||
ContextSettingsPage::ContextSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
@@ -68,11 +55,11 @@ ContextSettingsPage::ContextSettingsPage(SettingsDialog *dialog, QWidget *parent
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load(u"view-choose"_s, true, 0, 32));
|
||||
|
||||
checkboxes_[static_cast<int>(ContextSettingsOrder::ALBUM)] = ui_->checkbox_album;
|
||||
checkboxes_[static_cast<int>(ContextSettingsOrder::TECHNICAL_DATA)] = ui_->checkbox_technical_data;
|
||||
checkboxes_[static_cast<int>(ContextSettingsOrder::SONG_LYRICS)] = ui_->checkbox_song_lyrics;
|
||||
checkboxes_[static_cast<int>(ContextSettingsOrder::SEARCH_COVER)] = ui_->checkbox_search_cover;
|
||||
checkboxes_[static_cast<int>(ContextSettingsOrder::SEARCH_LYRICS)] = ui_->checkbox_search_lyrics;
|
||||
checkboxes_[QLatin1String(kAlbum)] = ui_->checkbox_album;
|
||||
checkboxes_[QLatin1String(kTechnicalData)] = ui_->checkbox_technical_data;
|
||||
checkboxes_[QLatin1String(kSongLyrics)] = ui_->checkbox_song_lyrics;
|
||||
checkboxes_[QLatin1String(kSearchCover)] = ui_->checkbox_search_cover;
|
||||
checkboxes_[QLatin1String(kSearchLyrics)] = ui_->checkbox_search_lyrics;
|
||||
|
||||
// Create and populate the helper menus
|
||||
QMenu *menu = new QMenu(this);
|
||||
@@ -137,8 +124,8 @@ void ContextSettingsPage::Load() {
|
||||
ui_->context_custom_text1->setText(s.value(kSettingsTitleFmt, u"%title% - %artist%"_s).toString());
|
||||
ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, u"%album%"_s).toString());
|
||||
|
||||
for (int i = 0; i < static_cast<int>(ContextSettingsOrder::NELEMS); ++i) {
|
||||
checkboxes_[i]->setChecked(s.value(kSettingsGroupEnable[i], checkboxes_[i]->isChecked()).toBool());
|
||||
for (const QString &i : checkboxes_.keys()) {
|
||||
checkboxes_[i]->setChecked(s.value(i, checkboxes_[i]->isChecked()).toBool());
|
||||
}
|
||||
|
||||
// Fonts
|
||||
@@ -150,15 +137,15 @@ void ContextSettingsPage::Load() {
|
||||
else {
|
||||
default_font = font().family();
|
||||
}
|
||||
ui_->font_headline->setCurrentFont(s.value("font_headline", default_font).toString());
|
||||
ui_->font_normal->setCurrentFont(s.value("font_normal", default_font).toString());
|
||||
ui_->font_size_headline->setValue(s.value("font_size_headline", kDefaultFontSizeHeadline).toReal());
|
||||
ui_->font_size_normal->setValue(s.value("font_size_normal", font().pointSizeF()).toReal());
|
||||
ui_->font_headline->setCurrentFont(s.value(kFontHeadline, default_font).toString());
|
||||
ui_->font_normal->setCurrentFont(s.value(kFontNormal, default_font).toString());
|
||||
ui_->font_size_headline->setValue(s.value(kFontSizeHeadline, kDefaultFontSizeHeadline).toReal());
|
||||
ui_->font_size_normal->setValue(s.value(kFontSizeNormal, font().pointSizeF()).toReal());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(MainWindow::kSettingsGroup);
|
||||
ui_->checkbox_search_cover->setChecked(s.value("search_for_cover_auto", true).toBool());
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
ui_->checkbox_search_cover->setChecked(s.value(MainWindowSettings::kSearchForCoverAuto, true).toBool());
|
||||
s.endGroup();
|
||||
|
||||
Init(ui_->layout_contextsettingspage->parentWidget());
|
||||
@@ -174,17 +161,17 @@ void ContextSettingsPage::Save() {
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue(kSettingsTitleFmt, ui_->context_custom_text1->text());
|
||||
s.setValue(kSettingsSummaryFmt, ui_->context_custom_text2->text());
|
||||
for (int i = 0; i < static_cast<int>(ContextSettingsOrder::NELEMS); ++i) {
|
||||
s.setValue(kSettingsGroupEnable[i], checkboxes_[i]->isChecked());
|
||||
for (const QString &i : checkboxes_.keys()) {
|
||||
s.setValue(i, checkboxes_[i]->isChecked());
|
||||
}
|
||||
s.setValue("font_headline", ui_->font_headline->currentFont().family());
|
||||
s.setValue("font_normal", ui_->font_normal->currentFont().family());
|
||||
s.setValue("font_size_headline", ui_->font_size_headline->value());
|
||||
s.setValue("font_size_normal", ui_->font_size_normal->value());
|
||||
s.setValue(kFontHeadline, ui_->font_headline->currentFont().family());
|
||||
s.setValue(kFontNormal, ui_->font_normal->currentFont().family());
|
||||
s.setValue(kFontSizeHeadline, ui_->font_size_headline->value());
|
||||
s.setValue(kFontSizeNormal, ui_->font_size_normal->value());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(MainWindow::kSettingsGroup);
|
||||
s.setValue("search_for_cover_auto", ui_->checkbox_search_cover->isChecked());
|
||||
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||
s.setValue(MainWindowSettings::kSearchForCoverAuto, ui_->checkbox_search_cover->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
|
||||
#include "settingspage.h"
|
||||
@@ -42,22 +43,6 @@ class ContextSettingsPage : public SettingsPage {
|
||||
explicit ContextSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~ContextSettingsPage() override;
|
||||
|
||||
enum class ContextSettingsOrder {
|
||||
ALBUM,
|
||||
TECHNICAL_DATA,
|
||||
SONG_LYRICS,
|
||||
SEARCH_COVER,
|
||||
SEARCH_LYRICS,
|
||||
NELEMS
|
||||
};
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
static const char *kSettingsTitleFmt;
|
||||
static const char *kSettingsSummaryFmt;
|
||||
static const char *kSettingsGroupEnable[static_cast<int>(ContextSettingsOrder::NELEMS)];
|
||||
static const char kDefaultFontFamily[];
|
||||
static const qreal kDefaultFontSizeHeadline;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -70,7 +55,7 @@ class ContextSettingsPage : public SettingsPage {
|
||||
|
||||
private:
|
||||
Ui_ContextSettingsPage *ui_;
|
||||
QCheckBox *checkboxes_[static_cast<int>(ContextSettingsOrder::NELEMS)] {};
|
||||
QHash<QString, QCheckBox*> checkboxes_;
|
||||
};
|
||||
|
||||
#endif // CONTEXTSETTINGSPAGE_H
|
||||
|
||||
@@ -38,29 +38,21 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "coverssettingspage.h"
|
||||
#include "ui_coverssettingspage.h"
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "utilities/coveroptions.h"
|
||||
#include "covermanager/coverproviders.h"
|
||||
#include "covermanager/coverprovider.h"
|
||||
#include "widgets/loginstatewidget.h"
|
||||
#include "constants/coverssettings.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace CoversSettings;
|
||||
|
||||
const char *CoversSettingsPage::kSettingsGroup = "Covers";
|
||||
const char *CoversSettingsPage::kProviders = "providers";
|
||||
const char *CoversSettingsPage::kTypes = "types";
|
||||
const char *CoversSettingsPage::kSaveType = "save_type";
|
||||
const char *CoversSettingsPage::kSaveFilename = "save_filename";
|
||||
const char *CoversSettingsPage::kSavePattern = "save_pattern";
|
||||
const char *CoversSettingsPage::kSaveOverwrite = "save_overwrite";
|
||||
const char *CoversSettingsPage::kSaveLowercase = "save_lowercase";
|
||||
const char *CoversSettingsPage::kSaveReplaceSpaces = "save_replace_spaces";
|
||||
|
||||
CoversSettingsPage::CoversSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
CoversSettingsPage::CoversSettingsPage(SettingsDialog *dialog, const SharedPtr<CoverProviders> cover_providers, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui::CoversSettingsPage),
|
||||
cover_providers_(cover_providers),
|
||||
provider_selected_(false),
|
||||
types_selected_(false) {
|
||||
|
||||
@@ -101,7 +93,7 @@ void CoversSettingsPage::Load() {
|
||||
|
||||
ui_->providers->clear();
|
||||
|
||||
QList<CoverProvider*> cover_providers_sorted = dialog()->app()->cover_providers()->List();
|
||||
QList<CoverProvider*> cover_providers_sorted = cover_providers_->List();
|
||||
std::stable_sort(cover_providers_sorted.begin(), cover_providers_sorted.end(), ProviderCompareOrder);
|
||||
|
||||
for (CoverProvider *provider : std::as_const(cover_providers_sorted)) {
|
||||
@@ -213,7 +205,7 @@ void CoversSettingsPage::Save() {
|
||||
void CoversSettingsPage::ProvidersCurrentItemChanged(QListWidgetItem *item_current, QListWidgetItem *item_previous) {
|
||||
|
||||
if (item_previous) {
|
||||
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(item_previous->text());
|
||||
CoverProvider *provider = cover_providers_->ProviderByName(item_previous->text());
|
||||
if (provider && provider->AuthenticationRequired()) DisconnectAuthentication(provider);
|
||||
}
|
||||
|
||||
@@ -221,7 +213,7 @@ void CoversSettingsPage::ProvidersCurrentItemChanged(QListWidgetItem *item_curre
|
||||
const int row = ui_->providers->row(item_current);
|
||||
ui_->providers_up->setEnabled(row != 0);
|
||||
ui_->providers_down->setEnabled(row != ui_->providers->count() - 1);
|
||||
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(item_current->text());
|
||||
CoverProvider *provider = cover_providers_->ProviderByName(item_current->text());
|
||||
if (provider) {
|
||||
if (provider->AuthenticationRequired()) {
|
||||
if (provider->name() == "Tidal"_L1 && !provider->IsAuthenticated()) {
|
||||
@@ -324,7 +316,7 @@ void CoversSettingsPage::DisconnectAuthentication(CoverProvider *provider) const
|
||||
void CoversSettingsPage::AuthenticateClicked() {
|
||||
|
||||
if (!ui_->providers->currentItem()) return;
|
||||
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(ui_->providers->currentItem()->text());
|
||||
CoverProvider *provider = cover_providers_->ProviderByName(ui_->providers->currentItem()->text());
|
||||
if (!provider) return;
|
||||
ui_->button_authenticate->setEnabled(false);
|
||||
ui_->login_state->SetLoggedIn(LoginStateWidget::State::LoginInProgress);
|
||||
@@ -337,7 +329,7 @@ void CoversSettingsPage::AuthenticateClicked() {
|
||||
void CoversSettingsPage::LogoutClicked() {
|
||||
|
||||
if (!ui_->providers->currentItem()) return;
|
||||
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(ui_->providers->currentItem()->text());
|
||||
CoverProvider *provider = cover_providers_->ProviderByName(ui_->providers->currentItem()->text());
|
||||
if (!provider) return;
|
||||
provider->Deauthenticate();
|
||||
|
||||
|
||||
@@ -26,10 +26,12 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "settings/settingspage.h"
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
class CoverProviders;
|
||||
class CoverProvider;
|
||||
class SettingsDialog;
|
||||
class Ui_CoversSettingsPage;
|
||||
@@ -38,19 +40,9 @@ class CoversSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CoversSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit CoversSettingsPage(SettingsDialog *dialog, const SharedPtr<CoverProviders> cover_providers, QWidget *parent = nullptr);
|
||||
~CoversSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
static const char *kProviders;
|
||||
static const char *kTypes;
|
||||
static const char *kSaveType;
|
||||
static const char *kSaveFilename;
|
||||
static const char *kSavePattern;
|
||||
static const char *kSaveOverwrite;
|
||||
static const char *kSaveLowercase;
|
||||
static const char *kSaveReplaceSpaces;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -87,6 +79,9 @@ class CoversSettingsPage : public SettingsPage {
|
||||
};
|
||||
|
||||
Ui_CoversSettingsPage *ui_;
|
||||
|
||||
const SharedPtr<CoverProviders> cover_providers_;
|
||||
|
||||
bool provider_selected_;
|
||||
bool types_selected_;
|
||||
};
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "core/logging.h"
|
||||
#include "core/settings.h"
|
||||
#include "utilities/envutils.h"
|
||||
#include "constants/globalshortcutssettings.h"
|
||||
#include "globalshortcuts/globalshortcutgrabber.h"
|
||||
#include "globalshortcuts/globalshortcutsmanager.h"
|
||||
#include "settingspage.h"
|
||||
@@ -51,11 +52,12 @@
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
const char *GlobalShortcutsSettingsPage::kSettingsGroup = "GlobalShortcuts";
|
||||
using namespace GlobalShortcutsSettings;
|
||||
|
||||
GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog, GlobalShortcutsManager *global_shortcuts_manager, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_GlobalShortcutsSettingsPage),
|
||||
global_shortcuts_manager_(global_shortcuts_manager),
|
||||
initialized_(false),
|
||||
grabber_(new GlobalShortcutGrabber()) {
|
||||
|
||||
@@ -107,8 +109,6 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
|
||||
|
||||
if (!initialized_) {
|
||||
initialized_ = true;
|
||||
|
||||
@@ -116,7 +116,7 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||
ui_->widget_warning->hide();
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
QObject::connect(ui_->button_macos_preferences, &QPushButton::clicked, manager, &GlobalShortcutsManager::ShowMacAccessibilityDialog);
|
||||
QObject::connect(ui_->button_macos_preferences, &QPushButton::clicked, global_shortcuts_manager_, &GlobalShortcutsManager::ShowMacAccessibilityDialog);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_KDE_GLOBALSHORTCUTS
|
||||
@@ -163,7 +163,7 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||
}
|
||||
#endif
|
||||
|
||||
const QList<GlobalShortcutsManager::Shortcut> shortcuts = manager->shortcuts().values();
|
||||
const QList<GlobalShortcutsManager::Shortcut> shortcuts = global_shortcuts_manager_->shortcuts().values();
|
||||
for (const GlobalShortcutsManager::Shortcut &i : shortcuts) {
|
||||
Shortcut shortcut;
|
||||
shortcut.s = i;
|
||||
@@ -184,25 +184,25 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||
|
||||
#ifdef HAVE_KDE_GLOBALSHORTCUTS
|
||||
if (ui_->widget_kde->isVisibleTo(this)) {
|
||||
ui_->checkbox_kde->setChecked(s.value("use_kde", true).toBool());
|
||||
ui_->checkbox_kde->setChecked(s.value(kUseKDE, true).toBool());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
|
||||
if (ui_->widget_gnome->isVisibleTo(this)) {
|
||||
ui_->checkbox_gnome->setChecked(s.value("use_gnome", true).toBool());
|
||||
ui_->checkbox_gnome->setChecked(s.value(kUseGnome, true).toBool());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MATE_GLOBALSHORTCUTS
|
||||
if (ui_->widget_mate->isVisibleTo(this)) {
|
||||
ui_->checkbox_mate->setChecked(s.value("use_mate", true).toBool());
|
||||
ui_->checkbox_mate->setChecked(s.value(kUseMate, true).toBool());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_X11_GLOBALSHORTCUTS
|
||||
if (ui_->widget_x11->isVisibleTo(this)) {
|
||||
ui_->checkbox_x11->setChecked(s.value("use_x11", false).toBool());
|
||||
ui_->checkbox_x11->setChecked(s.value(kUseX11, false).toBool());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -235,24 +235,24 @@ void GlobalShortcutsSettingsPage::Save() {
|
||||
}
|
||||
|
||||
#ifdef HAVE_KDE_GLOBALSHORTCUTS
|
||||
s.setValue("use_kde", ui_->checkbox_kde->isChecked());
|
||||
s.setValue(kUseKDE, ui_->checkbox_kde->isChecked());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
|
||||
s.setValue("use_gnome", ui_->checkbox_gnome->isChecked());
|
||||
s.setValue(kUseGnome, ui_->checkbox_gnome->isChecked());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MATE_GLOBALSHORTCUTS
|
||||
s.setValue("use_mate", ui_->checkbox_mate->isChecked());
|
||||
s.setValue(kUseMate, ui_->checkbox_mate->isChecked());
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_X11_GLOBALSHORTCUTS
|
||||
s.setValue("use_x11", ui_->checkbox_x11->isChecked());
|
||||
s.setValue(kUseX11, ui_->checkbox_x11->isChecked());
|
||||
#endif
|
||||
|
||||
s.endGroup();
|
||||
|
||||
dialog()->global_shortcuts_manager()->ReloadSettings();
|
||||
global_shortcuts_manager_->ReloadSettings();
|
||||
|
||||
}
|
||||
|
||||
@@ -342,10 +342,9 @@ void GlobalShortcutsSettingsPage::DefaultClicked() {
|
||||
|
||||
void GlobalShortcutsSettingsPage::ChangeClicked() {
|
||||
|
||||
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
|
||||
manager->Unregister();
|
||||
global_shortcuts_manager_->Unregister();
|
||||
QKeySequence key = grabber_->GetKey(shortcuts_.value(current_id_).s.action->text());
|
||||
manager->Register();
|
||||
global_shortcuts_manager_->Register();
|
||||
|
||||
if (key.isEmpty()) return;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QKeySequence>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "globalshortcuts/globalshortcutsmanager.h"
|
||||
#include "settingspage.h"
|
||||
|
||||
@@ -42,11 +42,9 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GlobalShortcutsSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit GlobalShortcutsSettingsPage(SettingsDialog *dialog, GlobalShortcutsManager *global_shortcuts_manager, QWidget *parent = nullptr);
|
||||
~GlobalShortcutsSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -74,6 +72,8 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
|
||||
private:
|
||||
Ui_GlobalShortcutsSettingsPage *ui_;
|
||||
|
||||
GlobalShortcutsManager *global_shortcuts_manager_;
|
||||
|
||||
bool initialized_;
|
||||
ScopedPtr<GlobalShortcutGrabber> grabber_;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "lyricssettingspage.h"
|
||||
#include "ui_lyricssettingspage.h"
|
||||
#include "core/application.h"
|
||||
#include "constants/lyricssettings.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "lyrics/lyricsproviders.h"
|
||||
@@ -46,12 +46,12 @@
|
||||
#include "widgets/loginstatewidget.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace LyricsSettings;
|
||||
|
||||
const char *LyricsSettingsPage::kSettingsGroup = "Lyrics";
|
||||
|
||||
LyricsSettingsPage::LyricsSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
LyricsSettingsPage::LyricsSettingsPage(SettingsDialog *dialog, const SharedPtr<LyricsProviders> lyrics_providers, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui::LyricsSettingsPage),
|
||||
lyrics_providers_(lyrics_providers),
|
||||
provider_selected_(false) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
@@ -81,7 +81,7 @@ void LyricsSettingsPage::Load() {
|
||||
|
||||
ui_->providers->clear();
|
||||
|
||||
QList<LyricsProvider*> lyrics_providers_sorted = dialog()->app()->lyrics_providers()->List();
|
||||
QList<LyricsProvider*> lyrics_providers_sorted = lyrics_providers_->List();
|
||||
std::stable_sort(lyrics_providers_sorted.begin(), lyrics_providers_sorted.end(), ProviderCompareOrder);
|
||||
|
||||
for (LyricsProvider *provider : std::as_const(lyrics_providers_sorted)) {
|
||||
@@ -107,7 +107,7 @@ void LyricsSettingsPage::Save() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("providers", providers);
|
||||
s.setValue(kProviders, providers);
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
@@ -115,7 +115,7 @@ void LyricsSettingsPage::Save() {
|
||||
void LyricsSettingsPage::CurrentItemChanged(QListWidgetItem *item_current, QListWidgetItem *item_previous) {
|
||||
|
||||
if (item_previous) {
|
||||
LyricsProvider *provider = dialog()->app()->lyrics_providers()->ProviderByName(item_previous->text());
|
||||
LyricsProvider *provider = lyrics_providers_->ProviderByName(item_previous->text());
|
||||
if (provider && provider->AuthenticationRequired()) DisconnectAuthentication(provider);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ void LyricsSettingsPage::CurrentItemChanged(QListWidgetItem *item_current, QList
|
||||
const int row = ui_->providers->row(item_current);
|
||||
ui_->providers_up->setEnabled(row != 0);
|
||||
ui_->providers_down->setEnabled(row != ui_->providers->count() - 1);
|
||||
LyricsProvider *provider = dialog()->app()->lyrics_providers()->ProviderByName(item_current->text());
|
||||
LyricsProvider *provider = lyrics_providers_->ProviderByName(item_current->text());
|
||||
if (provider) {
|
||||
if (provider->AuthenticationRequired()) {
|
||||
ui_->login_state->SetLoggedIn(provider->IsAuthenticated() ? LoginStateWidget::State::LoggedIn : LoginStateWidget::State::LoggedOut);
|
||||
@@ -212,7 +212,7 @@ void LyricsSettingsPage::DisconnectAuthentication(LyricsProvider *provider) cons
|
||||
void LyricsSettingsPage::AuthenticateClicked() {
|
||||
|
||||
if (!ui_->providers->currentItem()) return;
|
||||
LyricsProvider *provider = dialog()->app()->lyrics_providers()->ProviderByName(ui_->providers->currentItem()->text());
|
||||
LyricsProvider *provider = lyrics_providers_->ProviderByName(ui_->providers->currentItem()->text());
|
||||
if (!provider) return;
|
||||
ui_->button_authenticate->setEnabled(false);
|
||||
ui_->login_state->SetLoggedIn(LoginStateWidget::State::LoginInProgress);
|
||||
@@ -225,7 +225,7 @@ void LyricsSettingsPage::AuthenticateClicked() {
|
||||
void LyricsSettingsPage::LogoutClicked() {
|
||||
|
||||
if (!ui_->providers->currentItem()) return;
|
||||
LyricsProvider *provider = dialog()->app()->lyrics_providers()->ProviderByName(ui_->providers->currentItem()->text());
|
||||
LyricsProvider *provider = lyrics_providers_->ProviderByName(ui_->providers->currentItem()->text());
|
||||
if (!provider) return;
|
||||
provider->Deauthenticate();
|
||||
|
||||
|
||||
@@ -26,10 +26,12 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "settings/settingspage.h"
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
class LyricsProviders;
|
||||
class LyricsProvider;
|
||||
class SettingsDialog;
|
||||
class Ui_LyricsSettingsPage;
|
||||
@@ -38,11 +40,9 @@ class LyricsSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LyricsSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit LyricsSettingsPage(SettingsDialog *dialog, const SharedPtr<LyricsProviders> lyrics_providers, QWidget *parent = nullptr);
|
||||
~LyricsSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -66,6 +66,7 @@ class LyricsSettingsPage : public SettingsPage {
|
||||
|
||||
private:
|
||||
Ui_LyricsSettingsPage *ui_;
|
||||
const SharedPtr<LyricsProviders> lyrics_providers_;
|
||||
bool provider_selected_;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,14 +42,17 @@
|
||||
# include "moodbar/moodbarrenderer.h"
|
||||
#endif
|
||||
|
||||
#include "constants/moodbarsettings.h"
|
||||
#include "moodbarsettingspage.h"
|
||||
#include "ui_moodbarsettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace MoodbarSettings;
|
||||
|
||||
const char *MoodbarSettingsPage::kSettingsGroup = "Moodbar";
|
||||
const int MoodbarSettingsPage::kMoodbarPreviewWidth = 150;
|
||||
const int MoodbarSettingsPage::kMoodbarPreviewHeight = 18;
|
||||
namespace {
|
||||
constexpr int kMoodbarPreviewWidth = 150;
|
||||
constexpr int kMoodbarPreviewHeight = 18;
|
||||
}
|
||||
|
||||
MoodbarSettingsPage::MoodbarSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
@@ -69,10 +72,10 @@ void MoodbarSettingsPage::Load() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
ui_->moodbar_enabled->setChecked(s.value("enabled", false).toBool());
|
||||
ui_->moodbar_show->setChecked(s.value("show", false).toBool());
|
||||
ui_->moodbar_style->setCurrentIndex(s.value("style", 0).toInt());
|
||||
ui_->moodbar_save->setChecked(s.value("save", false).toBool());
|
||||
ui_->moodbar_enabled->setChecked(s.value(kEnabled, false).toBool());
|
||||
ui_->moodbar_show->setChecked(s.value(kShow, false).toBool());
|
||||
ui_->moodbar_style->setCurrentIndex(s.value(kStyle, 0).toInt());
|
||||
ui_->moodbar_save->setChecked(s.value(kSave, false).toBool());
|
||||
s.endGroup();
|
||||
|
||||
InitMoodbarPreviews();
|
||||
@@ -87,10 +90,10 @@ void MoodbarSettingsPage::Save() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("enabled", ui_->moodbar_enabled->isChecked());
|
||||
s.setValue("show", ui_->moodbar_show->isChecked());
|
||||
s.setValue("style", ui_->moodbar_style->currentIndex());
|
||||
s.setValue("save", ui_->moodbar_save->isChecked());
|
||||
s.setValue(kEnabled, ui_->moodbar_enabled->isChecked());
|
||||
s.setValue(kShow, ui_->moodbar_show->isChecked());
|
||||
s.setValue(kStyle, ui_->moodbar_style->currentIndex());
|
||||
s.setValue(kSave, ui_->moodbar_save->isChecked());
|
||||
s.endGroup();
|
||||
}
|
||||
|
||||
@@ -114,9 +117,9 @@ void MoodbarSettingsPage::InitMoodbarPreviews() {
|
||||
file.close();
|
||||
|
||||
// Render and set each preview
|
||||
for (int i = 0; i < static_cast<int>(MoodbarRenderer::MoodbarStyle::StyleCount); ++i) {
|
||||
for (int i = 0; i < static_cast<int>(Style::StyleCount); ++i) {
|
||||
|
||||
const MoodbarRenderer::MoodbarStyle style = static_cast<MoodbarRenderer::MoodbarStyle>(i);
|
||||
const Style style = static_cast<Style>(i);
|
||||
const ColorVector colors = MoodbarRenderer::Colors(file_data, style, palette());
|
||||
|
||||
QPixmap pixmap(preview_size);
|
||||
|
||||
@@ -37,16 +37,11 @@ class MoodbarSettingsPage : public SettingsPage {
|
||||
explicit MoodbarSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~MoodbarSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
void Cancel() override;
|
||||
|
||||
private:
|
||||
static const int kMoodbarPreviewWidth;
|
||||
static const int kMoodbarPreviewHeight;
|
||||
|
||||
void InitMoodbarPreviews();
|
||||
|
||||
Ui_MoodbarSettingsPage *ui_;
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
#include "core/settings.h"
|
||||
#include "networkproxysettingspage.h"
|
||||
#include "settings/settingspage.h"
|
||||
#include "constants/networkproxysettings.h"
|
||||
#include "ui_networkproxysettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace NetworkProxySettings;
|
||||
|
||||
class SettingsDialog;
|
||||
|
||||
const char *NetworkProxySettingsPage::kSettingsGroup = "NetworkProxy";
|
||||
|
||||
NetworkProxySettingsPage::NetworkProxySettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_NetworkProxySettingsPage) {
|
||||
@@ -74,13 +74,13 @@ void NetworkProxySettingsPage::Load() {
|
||||
break;
|
||||
}
|
||||
|
||||
ui_->proxy_type->setCurrentIndex(s.value("type", QNetworkProxy::HttpProxy).toInt() == QNetworkProxy::HttpProxy ? 0 : 1);
|
||||
ui_->proxy_hostname->setText(s.value("hostname").toString());
|
||||
ui_->proxy_port->setValue(s.value("port").toInt());
|
||||
ui_->proxy_auth->setChecked(s.value("use_authentication", false).toBool());
|
||||
ui_->proxy_username->setText(s.value("username").toString());
|
||||
ui_->proxy_password->setText(s.value("password").toString());
|
||||
ui_->proxy_engine->setChecked(s.value("engine", true).toBool());
|
||||
ui_->proxy_type->setCurrentIndex(s.value(kType, QNetworkProxy::HttpProxy).toInt() == QNetworkProxy::HttpProxy ? 0 : 1);
|
||||
ui_->proxy_hostname->setText(s.value(kHostname).toString());
|
||||
ui_->proxy_port->setValue(s.value(kPort).toInt());
|
||||
ui_->proxy_auth->setChecked(s.value(kUseAuthentication, false).toBool());
|
||||
ui_->proxy_username->setText(s.value(kUsername).toString());
|
||||
ui_->proxy_password->setText(s.value(kPassword).toString());
|
||||
ui_->proxy_engine->setChecked(s.value(kEngine, true).toBool());
|
||||
s.endGroup();
|
||||
|
||||
Init(ui_->layout_networkproxysettingspage->parentWidget());
|
||||
@@ -100,13 +100,13 @@ void NetworkProxySettingsPage::Save() {
|
||||
|
||||
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
|
||||
s.setValue("mode", static_cast<int>(mode));
|
||||
s.setValue("type", ui_->proxy_type->currentIndex() == 0 ? QNetworkProxy::HttpProxy : QNetworkProxy::Socks5Proxy);
|
||||
s.setValue("hostname", ui_->proxy_hostname->text());
|
||||
s.setValue("port", ui_->proxy_port->value());
|
||||
s.setValue("use_authentication", ui_->proxy_auth->isChecked());
|
||||
s.setValue("username", ui_->proxy_username->text());
|
||||
s.setValue("password", ui_->proxy_password->text());
|
||||
s.setValue("engine", ui_->proxy_engine->isChecked());
|
||||
s.setValue(kType, ui_->proxy_type->currentIndex() == 0 ? QNetworkProxy::HttpProxy : QNetworkProxy::Socks5Proxy);
|
||||
s.setValue(kHostname, ui_->proxy_hostname->text());
|
||||
s.setValue(kPort, ui_->proxy_port->value());
|
||||
s.setValue(kUseAuthentication, ui_->proxy_auth->isChecked());
|
||||
s.setValue(kUsername, ui_->proxy_username->text());
|
||||
s.setValue(kPassword, ui_->proxy_password->text());
|
||||
s.setValue(kEngine, ui_->proxy_engine->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
NetworkProxyFactory::Instance()->ReloadSettings();
|
||||
|
||||
@@ -39,8 +39,6 @@ class NetworkProxySettingsPage : public SettingsPage {
|
||||
explicit NetworkProxySettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~NetworkProxySettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
|
||||
@@ -53,15 +53,17 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "notificationssettingspage.h"
|
||||
#include "ui_notificationssettingspage.h"
|
||||
#include "constants/notificationssettings.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
class QHideEvent;
|
||||
class QShowEvent;
|
||||
|
||||
NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, OSDBase *osd, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_NotificationsSettingsPage),
|
||||
osd_(osd),
|
||||
pretty_popup_(new OSDPretty(OSDPretty::Mode::Draggable)) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
@@ -69,8 +71,8 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, QWi
|
||||
|
||||
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"), QImage(u":/pictures/cdcase.png"_s));
|
||||
|
||||
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue), Qt::DecorationRole);
|
||||
ui_->notifications_bg_preset->setItemData(1, QColor(OSDPretty::kPresetRed), Qt::DecorationRole);
|
||||
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPrettySettings::kPresetBlue), Qt::DecorationRole);
|
||||
ui_->notifications_bg_preset->setItemData(1, QColor(OSDPrettySettings::kPresetRed), Qt::DecorationRole);
|
||||
|
||||
// Create and populate the helper menus
|
||||
QMenu *menu = new QMenu(this);
|
||||
@@ -114,15 +116,15 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog *dialog, QWi
|
||||
QObject::connect(ui_->notifications_disable_duration, &QCheckBox::toggled, ui_->notifications_duration, &NotificationsSettingsPage::setDisabled);
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
if (!dialog->osd()->SupportsNativeNotifications() && !dialog->osd()->SupportsTrayPopups()) {
|
||||
if (!osd_->SupportsNativeNotifications() && !osd_->SupportsTrayPopups()) {
|
||||
ui_->notifications_native->setEnabled(false);
|
||||
}
|
||||
#else
|
||||
if (!dialog->osd()->SupportsNativeNotifications()) {
|
||||
if (!osd_->SupportsNativeNotifications()) {
|
||||
ui_->notifications_native->setEnabled(false);
|
||||
}
|
||||
#endif
|
||||
if (!dialog->osd()->SupportsTrayPopups()) {
|
||||
if (!osd_->SupportsTrayPopups()) {
|
||||
ui_->notifications_tray->setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -158,45 +160,45 @@ void NotificationsSettingsPage::Load() {
|
||||
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(OSDBase::kSettingsGroup);
|
||||
const OSDBase::Behaviour osd_behaviour = static_cast<OSDBase::Behaviour>(s.value("Behaviour", static_cast<int>(OSDBase::Behaviour::Native)).toInt());
|
||||
switch (osd_behaviour) {
|
||||
case OSDBase::Behaviour::Native:
|
||||
s.beginGroup(OSDSettings::kSettingsGroup);
|
||||
const OSDSettings::Type osd_type = static_cast<OSDSettings::Type>(s.value(OSDSettings::kType, static_cast<int>(OSDSettings::Type::Native)).toInt());
|
||||
switch (osd_type) {
|
||||
case OSDSettings::Type::Native:
|
||||
#ifdef Q_OS_WIN32
|
||||
if (dialog()->osd()->SupportsNativeNotifications() || dialog()->osd()->SupportsTrayPopups()) {
|
||||
if (osd_->SupportsNativeNotifications() || osd_->SupportsTrayPopups()) {
|
||||
#else
|
||||
if (dialog()->osd()->SupportsNativeNotifications()) {
|
||||
if (osd_->SupportsNativeNotifications()) {
|
||||
#endif
|
||||
ui_->notifications_native->setChecked(true);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case OSDBase::Behaviour::Pretty:
|
||||
case OSDSettings::Type::Pretty:
|
||||
ui_->notifications_pretty->setChecked(true);
|
||||
break;
|
||||
|
||||
case OSDBase::Behaviour::TrayPopup:
|
||||
if (dialog()->osd()->SupportsTrayPopups()) {
|
||||
case OSDSettings::Type::TrayPopup:
|
||||
if (osd_->SupportsTrayPopups()) {
|
||||
ui_->notifications_tray->setChecked(true);
|
||||
break;
|
||||
}
|
||||
// Fallthrough
|
||||
|
||||
case OSDBase::Behaviour::Disabled:
|
||||
case OSDSettings::Type::Disabled:
|
||||
default:
|
||||
ui_->notifications_none->setChecked(true);
|
||||
break;
|
||||
}
|
||||
ui_->notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
|
||||
ui_->notifications_volume->setChecked(s.value("ShowOnVolumeChange", false).toBool());
|
||||
ui_->notifications_play_mode->setChecked(s.value("ShowOnPlayModeChange", true).toBool());
|
||||
ui_->notifications_pause->setChecked(s.value("ShowOnPausePlayback", true).toBool());
|
||||
ui_->notifications_resume->setChecked(s.value("ShowOnResumePlayback", false).toBool());
|
||||
ui_->notifications_art->setChecked(s.value("ShowArt", true).toBool());
|
||||
ui_->notifications_custom_text_enabled->setChecked(s.value("CustomTextEnabled", false).toBool());
|
||||
ui_->notifications_custom_text1->setText(s.value("CustomText1").toString());
|
||||
ui_->notifications_custom_text2->setText(s.value("CustomText2").toString());
|
||||
ui_->notifications_duration->setValue(s.value(OSDSettings::kTimeout, 5000).toInt() / 1000);
|
||||
ui_->notifications_volume->setChecked(s.value(OSDSettings::kShowOnVolumeChange, false).toBool());
|
||||
ui_->notifications_play_mode->setChecked(s.value(OSDSettings::kShowOnPlayModeChange, true).toBool());
|
||||
ui_->notifications_pause->setChecked(s.value(OSDSettings::kShowOnPausePlayback, true).toBool());
|
||||
ui_->notifications_resume->setChecked(s.value(OSDSettings::kShowOnResumePlayback, false).toBool());
|
||||
ui_->notifications_art->setChecked(s.value(OSDSettings::kShowArt, true).toBool());
|
||||
ui_->notifications_custom_text_enabled->setChecked(s.value(OSDSettings::kCustomTextEnabled, false).toBool());
|
||||
ui_->notifications_custom_text1->setText(s.value(OSDSettings::kCustomText1).toString());
|
||||
ui_->notifications_custom_text2->setText(s.value(OSDSettings::kCustomText2).toString());
|
||||
s.endGroup();
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
@@ -208,10 +210,10 @@ void NotificationsSettingsPage::Load() {
|
||||
ui_->notifications_opacity->setValue(static_cast<int>(pretty_popup_->background_opacity() * 100));
|
||||
|
||||
QRgb color = pretty_popup_->background_color();
|
||||
if (color == OSDPretty::kPresetBlue) {
|
||||
if (color == OSDPrettySettings::kPresetBlue) {
|
||||
ui_->notifications_bg_preset->setCurrentIndex(0);
|
||||
}
|
||||
else if (color == OSDPretty::kPresetRed) {
|
||||
else if (color == OSDPrettySettings::kPresetRed) {
|
||||
ui_->notifications_bg_preset->setCurrentIndex(1);
|
||||
}
|
||||
else {
|
||||
@@ -226,7 +228,7 @@ void NotificationsSettingsPage::Load() {
|
||||
|
||||
Init(ui_->layout_notificationssettingspage->parentWidget());
|
||||
|
||||
if (!Settings().childGroups().contains(QLatin1String(OSDBase::kSettingsGroup))) set_changed();
|
||||
if (!Settings().childGroups().contains(QLatin1String(OSDSettings::kSettingsGroup))) set_changed();
|
||||
|
||||
}
|
||||
|
||||
@@ -234,34 +236,34 @@ void NotificationsSettingsPage::Save() {
|
||||
|
||||
Settings s;
|
||||
|
||||
OSDBase::Behaviour osd_behaviour = OSDBase::Behaviour::Disabled;
|
||||
if (ui_->notifications_none->isChecked()) osd_behaviour = OSDBase::Behaviour::Disabled;
|
||||
else if (ui_->notifications_native->isChecked()) osd_behaviour = OSDBase::Behaviour::Native;
|
||||
else if (ui_->notifications_tray->isChecked()) osd_behaviour = OSDBase::Behaviour::TrayPopup;
|
||||
else if (ui_->notifications_pretty->isChecked()) osd_behaviour = OSDBase::Behaviour::Pretty;
|
||||
OSDSettings::Type osd_type = OSDSettings::Type::Disabled;
|
||||
if (ui_->notifications_none->isChecked()) osd_type = OSDSettings::Type::Disabled;
|
||||
else if (ui_->notifications_native->isChecked()) osd_type = OSDSettings::Type::Native;
|
||||
else if (ui_->notifications_tray->isChecked()) osd_type = OSDSettings::Type::TrayPopup;
|
||||
else if (ui_->notifications_pretty->isChecked()) osd_type = OSDSettings::Type::Pretty;
|
||||
|
||||
s.beginGroup(OSDBase::kSettingsGroup);
|
||||
s.setValue("Behaviour", static_cast<int>(osd_behaviour));
|
||||
s.setValue("Timeout", ui_->notifications_duration->value() * 1000);
|
||||
s.setValue("ShowOnVolumeChange", ui_->notifications_volume->isChecked());
|
||||
s.setValue("ShowOnPlayModeChange", ui_->notifications_play_mode->isChecked());
|
||||
s.setValue("ShowOnPausePlayback", ui_->notifications_pause->isChecked());
|
||||
s.setValue("ShowOnResumePlayback", ui_->notifications_resume->isChecked());
|
||||
s.setValue("ShowArt", ui_->notifications_art->isChecked());
|
||||
s.setValue("CustomTextEnabled", ui_->notifications_custom_text_enabled->isChecked());
|
||||
s.setValue("CustomText1", ui_->notifications_custom_text1->text());
|
||||
s.setValue("CustomText2", ui_->notifications_custom_text2->text());
|
||||
s.beginGroup(OSDSettings::kSettingsGroup);
|
||||
s.setValue(OSDSettings::kType, static_cast<int>(osd_type));
|
||||
s.setValue(OSDSettings::kTimeout, ui_->notifications_duration->value() * 1000);
|
||||
s.setValue(OSDSettings::kShowOnVolumeChange, ui_->notifications_volume->isChecked());
|
||||
s.setValue(OSDSettings::kShowOnPlayModeChange, ui_->notifications_play_mode->isChecked());
|
||||
s.setValue(OSDSettings::kShowOnPausePlayback, ui_->notifications_pause->isChecked());
|
||||
s.setValue(OSDSettings::kShowOnResumePlayback, ui_->notifications_resume->isChecked());
|
||||
s.setValue(OSDSettings::kShowArt, ui_->notifications_art->isChecked());
|
||||
s.setValue(OSDSettings::kCustomTextEnabled, ui_->notifications_custom_text_enabled->isChecked());
|
||||
s.setValue(OSDSettings::kCustomText1, ui_->notifications_custom_text1->text());
|
||||
s.setValue(OSDSettings::kCustomText2, ui_->notifications_custom_text2->text());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(OSDPretty::kSettingsGroup);
|
||||
s.setValue("foreground_color", pretty_popup_->foreground_color());
|
||||
s.setValue("background_color", pretty_popup_->background_color());
|
||||
s.setValue("background_opacity", pretty_popup_->background_opacity());
|
||||
s.setValue("popup_screen", pretty_popup_->popup_screen());
|
||||
s.setValue("popup_pos", pretty_popup_->popup_pos());
|
||||
s.setValue("font", pretty_popup_->font().toString());
|
||||
s.setValue("disable_duration", ui_->notifications_disable_duration->isChecked());
|
||||
s.setValue("fading", ui_->notifications_fading->isChecked());
|
||||
s.beginGroup(OSDPrettySettings::kSettingsGroup);
|
||||
s.setValue(OSDPrettySettings::kForegroundColor, pretty_popup_->foreground_color());
|
||||
s.setValue(OSDPrettySettings::kBackgroundColor, pretty_popup_->background_color());
|
||||
s.setValue(OSDPrettySettings::kBackgroundOpacity, pretty_popup_->background_opacity());
|
||||
s.setValue(OSDPrettySettings::kPopupScreen, pretty_popup_->popup_screen());
|
||||
s.setValue(OSDPrettySettings::kPopupPos, pretty_popup_->popup_pos());
|
||||
s.setValue(OSDPrettySettings::kFont, pretty_popup_->font().toString());
|
||||
s.setValue(OSDPrettySettings::kDisableDuration, ui_->notifications_disable_duration->isChecked());
|
||||
s.setValue(OSDPrettySettings::kFading, ui_->notifications_fading->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
@@ -285,11 +287,11 @@ void NotificationsSettingsPage::PrettyColorPresetChanged(int index) {
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
pretty_popup_->set_background_color(OSDPretty::kPresetBlue);
|
||||
pretty_popup_->set_background_color(OSDPrettySettings::kPresetBlue);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pretty_popup_->set_background_color(OSDPretty::kPresetRed);
|
||||
pretty_popup_->set_background_color(OSDPrettySettings::kPresetRed);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -350,15 +352,15 @@ void NotificationsSettingsPage::NotificationCustomTextChanged(bool enabled) {
|
||||
|
||||
void NotificationsSettingsPage::PrepareNotificationPreview() {
|
||||
|
||||
OSDBase::Behaviour notificationType = OSDBase::Behaviour::Disabled;
|
||||
OSDSettings::Type notificationType = OSDSettings::Type::Disabled;
|
||||
if (ui_->notifications_native->isChecked()) {
|
||||
notificationType = OSDBase::Behaviour::Native;
|
||||
notificationType = OSDSettings::Type::Native;
|
||||
}
|
||||
else if (ui_->notifications_pretty->isChecked()) {
|
||||
notificationType = OSDBase::Behaviour::Pretty;
|
||||
notificationType = OSDSettings::Type::Pretty;
|
||||
}
|
||||
else if (ui_->notifications_tray->isChecked()) {
|
||||
notificationType = OSDBase::Behaviour::TrayPopup;
|
||||
notificationType = OSDSettings::Type::TrayPopup;
|
||||
}
|
||||
|
||||
// If user changes timeout or other options, that won't be reflected in the preview
|
||||
|
||||
@@ -33,6 +33,7 @@ class QAction;
|
||||
class QHideEvent;
|
||||
class QShowEvent;
|
||||
|
||||
class OSDBase;
|
||||
class OSDPretty;
|
||||
class SettingsDialog;
|
||||
class Ui_NotificationsSettingsPage;
|
||||
@@ -41,15 +42,15 @@ class NotificationsSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NotificationsSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit NotificationsSettingsPage(SettingsDialog *dialog, OSDBase *osd, QWidget *parent = nullptr);
|
||||
~NotificationsSettingsPage() override;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
protected:
|
||||
void hideEvent(QHideEvent*) override;
|
||||
void showEvent(QShowEvent*) override;
|
||||
void hideEvent(QHideEvent *e) override;
|
||||
void showEvent(QShowEvent *e) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void NotificationTypeChanged();
|
||||
@@ -71,6 +72,7 @@ class NotificationsSettingsPage : public SettingsPage {
|
||||
|
||||
private:
|
||||
Ui_NotificationsSettingsPage *ui_;
|
||||
OSDBase *osd_;
|
||||
OSDPretty *pretty_popup_;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,17 +28,16 @@
|
||||
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "playlist/playlist.h"
|
||||
#include "constants/playlistsettings.h"
|
||||
#include "settingspage.h"
|
||||
#include "playlistsettingspage.h"
|
||||
#include "ui_playlistsettingspage.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace PlaylistSettings;
|
||||
|
||||
class SettingsDialog;
|
||||
|
||||
const char *PlaylistSettingsPage::kSettingsGroup = "Playlist";
|
||||
|
||||
PlaylistSettingsPage::PlaylistSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_PlaylistSettingsPage) {
|
||||
@@ -57,8 +56,8 @@ void PlaylistSettingsPage::Load() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
ui_->checkbox_alternating_row_colors->setChecked(s.value("alternating_row_colors", true).toBool());
|
||||
ui_->checkbox_barscurrenttrack->setChecked(s.value("show_bars", true).toBool());
|
||||
ui_->checkbox_alternating_row_colors->setChecked(s.value(kAlternatingRowColors, true).toBool());
|
||||
ui_->checkbox_barscurrenttrack->setChecked(s.value(kShowBars, true).toBool());
|
||||
|
||||
ui_->checkbox_glowcurrenttrack->setEnabled(ui_->checkbox_barscurrenttrack->isChecked());
|
||||
if (ui_->checkbox_barscurrenttrack->isChecked()) {
|
||||
@@ -67,19 +66,19 @@ void PlaylistSettingsPage::Load() {
|
||||
#else
|
||||
bool glow_effect = true;
|
||||
#endif
|
||||
ui_->checkbox_glowcurrenttrack->setChecked(s.value("glow_effect", glow_effect).toBool());
|
||||
ui_->checkbox_glowcurrenttrack->setChecked(s.value(kGlowEffect, glow_effect).toBool());
|
||||
}
|
||||
|
||||
ui_->checkbox_warncloseplaylist->setChecked(s.value("warn_close_playlist", true).toBool());
|
||||
ui_->checkbox_continueonerror->setChecked(s.value("continue_on_error", false).toBool());
|
||||
ui_->checkbox_greyout_songs_startup->setChecked(s.value("greyout_songs_startup", true).toBool());
|
||||
ui_->checkbox_greyout_songs_play->setChecked(s.value("greyout_songs_play", true).toBool());
|
||||
ui_->checkbox_select_track->setChecked(s.value("select_track", false).toBool());
|
||||
ui_->checkbox_show_toolbar->setChecked(s.value("show_toolbar", true).toBool());
|
||||
ui_->checkbox_playlist_clear->setChecked(s.value("playlist_clear", true).toBool());
|
||||
ui_->checkbox_auto_sort->setChecked(s.value("auto_sort", false).toBool());
|
||||
ui_->checkbox_warncloseplaylist->setChecked(s.value(kWarnClosePlaylist, true).toBool());
|
||||
ui_->checkbox_continueonerror->setChecked(s.value(kContinueOnError, false).toBool());
|
||||
ui_->checkbox_greyout_songs_startup->setChecked(s.value(kGreyoutSongsStartup, true).toBool());
|
||||
ui_->checkbox_greyout_songs_play->setChecked(s.value(kGreyoutSongsPlay, true).toBool());
|
||||
ui_->checkbox_select_track->setChecked(s.value(kSelectTrack, false).toBool());
|
||||
ui_->checkbox_show_toolbar->setChecked(s.value(kShowToolbar, true).toBool());
|
||||
ui_->checkbox_playlist_clear->setChecked(s.value(kPlaylistClear, true).toBool());
|
||||
ui_->checkbox_auto_sort->setChecked(s.value(kAutoSort, false).toBool());
|
||||
|
||||
const PathType path_type = static_cast<PathType>(s.value("path_type", static_cast<int>(PathType::Automatic)).toInt());
|
||||
const PathType path_type = static_cast<PathType>(s.value(kPathType, static_cast<int>(PathType::Automatic)).toInt());
|
||||
switch (path_type) {
|
||||
case PathType::Automatic:
|
||||
ui_->radiobutton_automaticpath->setChecked(true);
|
||||
@@ -94,10 +93,10 @@ void PlaylistSettingsPage::Load() {
|
||||
ui_->radiobutton_askpath->setChecked(true);
|
||||
}
|
||||
|
||||
ui_->checkbox_editmetadatainline->setChecked(s.value("editmetadatainline", false).toBool());
|
||||
ui_->checkbox_writemetadata->setChecked(s.value("write_metadata", false).toBool());
|
||||
ui_->checkbox_editmetadatainline->setChecked(s.value(kEditMetadataInline, false).toBool());
|
||||
ui_->checkbox_writemetadata->setChecked(s.value(kWriteMetadata, false).toBool());
|
||||
|
||||
ui_->checkbox_delete_files->setChecked(s.value("delete_files", false).toBool());
|
||||
ui_->checkbox_delete_files->setChecked(s.value(kDeleteFiles, false).toBool());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@@ -125,21 +124,21 @@ void PlaylistSettingsPage::Save() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("alternating_row_colors", ui_->checkbox_alternating_row_colors->isChecked());
|
||||
s.setValue("show_bars", ui_->checkbox_barscurrenttrack->isChecked());
|
||||
s.setValue("glow_effect", ui_->checkbox_glowcurrenttrack->isChecked());
|
||||
s.setValue("warn_close_playlist", ui_->checkbox_warncloseplaylist->isChecked());
|
||||
s.setValue("continue_on_error", ui_->checkbox_continueonerror->isChecked());
|
||||
s.setValue("greyout_songs_startup", ui_->checkbox_greyout_songs_startup->isChecked());
|
||||
s.setValue("greyout_songs_play", ui_->checkbox_greyout_songs_play->isChecked());
|
||||
s.setValue("select_track", ui_->checkbox_select_track->isChecked());
|
||||
s.setValue("show_toolbar", ui_->checkbox_show_toolbar->isChecked());
|
||||
s.setValue("playlist_clear", ui_->checkbox_playlist_clear->isChecked());
|
||||
s.setValue("path_type", static_cast<int>(path_type));
|
||||
s.setValue("editmetadatainline", ui_->checkbox_editmetadatainline->isChecked());
|
||||
s.setValue("write_metadata", ui_->checkbox_writemetadata->isChecked());
|
||||
s.setValue("delete_files", ui_->checkbox_delete_files->isChecked());
|
||||
s.setValue("auto_sort", ui_->checkbox_auto_sort->isChecked());
|
||||
s.setValue(kAlternatingRowColors, ui_->checkbox_alternating_row_colors->isChecked());
|
||||
s.setValue(kShowBars, ui_->checkbox_barscurrenttrack->isChecked());
|
||||
s.setValue(kGlowEffect, ui_->checkbox_glowcurrenttrack->isChecked());
|
||||
s.setValue(kWarnClosePlaylist, ui_->checkbox_warncloseplaylist->isChecked());
|
||||
s.setValue(kContinueOnError, ui_->checkbox_continueonerror->isChecked());
|
||||
s.setValue(kGreyoutSongsStartup, ui_->checkbox_greyout_songs_startup->isChecked());
|
||||
s.setValue(kGreyoutSongsPlay, ui_->checkbox_greyout_songs_play->isChecked());
|
||||
s.setValue(kSelectTrack, ui_->checkbox_select_track->isChecked());
|
||||
s.setValue(kShowToolbar, ui_->checkbox_show_toolbar->isChecked());
|
||||
s.setValue(kPlaylistClear, ui_->checkbox_playlist_clear->isChecked());
|
||||
s.setValue(kPathType, static_cast<int>(path_type));
|
||||
s.setValue(kEditMetadataInline, ui_->checkbox_editmetadatainline->isChecked());
|
||||
s.setValue(kWriteMetadata, ui_->checkbox_writemetadata->isChecked());
|
||||
s.setValue(kDeleteFiles, ui_->checkbox_delete_files->isChecked());
|
||||
s.setValue(kAutoSort, ui_->checkbox_auto_sort->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -39,15 +39,6 @@ class PlaylistSettingsPage : public SettingsPage {
|
||||
explicit PlaylistSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~PlaylistSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
enum class PathType {
|
||||
Automatic = 0, // Automatically select path type
|
||||
Absolute, // Always use absolute paths
|
||||
Relative, // Always use relative paths
|
||||
Ask_User // Only used in preferences: to ask user which of the previous values he wants to use.
|
||||
};
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -55,6 +46,4 @@ class PlaylistSettingsPage : public SettingsPage {
|
||||
Ui_PlaylistSettingsPage *ui_;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(PlaylistSettingsPage::PathType)
|
||||
|
||||
#endif // PLAYLISTSETTINGSPAGE_H
|
||||
|
||||
@@ -34,21 +34,19 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "qobuzsettingspage.h"
|
||||
#include "ui_qobuzsettingspage.h"
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "widgets/loginstatewidget.h"
|
||||
#include "streaming/streamingservices.h"
|
||||
#include "qobuz/qobuzservice.h"
|
||||
#include "constants/qobuzsettings.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace QobuzSettings;
|
||||
|
||||
const char *QobuzSettingsPage::kSettingsGroup = "Qobuz";
|
||||
|
||||
QobuzSettingsPage::QobuzSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
QobuzSettingsPage::QobuzSettingsPage(SettingsDialog *dialog, const SharedPtr<QobuzService> service, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui::QobuzSettingsPage),
|
||||
service_(dialog->app()->streaming_services()->Service<QobuzService>()) {
|
||||
service_(service) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load(u"qobuz"_s, true, 0, 32));
|
||||
@@ -78,22 +76,22 @@ void QobuzSettingsPage::Load() {
|
||||
if (!s.contains(kSettingsGroup)) set_changed();
|
||||
|
||||
s.beginGroup(kSettingsGroup);
|
||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||
ui_->app_id->setText(s.value("app_id").toString());
|
||||
ui_->app_secret->setText(s.value("app_secret").toString());
|
||||
ui_->enable->setChecked(s.value(kEnabled, false).toBool());
|
||||
ui_->app_id->setText(s.value(kAppId).toString());
|
||||
ui_->app_secret->setText(s.value(kAppSecret).toString());
|
||||
|
||||
ui_->username->setText(s.value("username").toString());
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
ui_->username->setText(s.value(kUsername).toString());
|
||||
QByteArray password = s.value(kPassword).toByteArray();
|
||||
if (password.isEmpty()) ui_->password->clear();
|
||||
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
|
||||
|
||||
ComboBoxLoadFromSettings(s, ui_->format, u"format"_s, 27);
|
||||
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value("songssearchlimit", 10).toInt());
|
||||
ui_->checkbox_base64_secret->setChecked(s.value("base64secret", false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool());
|
||||
ComboBoxLoadFromSettings(s, ui_->format, QLatin1String(kFormat), 27);
|
||||
ui_->searchdelay->setValue(s.value(kSearchDelay, 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value(kArtistsSearchLimit, 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value(kAlbumsSearchLimit, 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value(kSongsSearchLimit, 10).toInt());
|
||||
ui_->checkbox_base64_secret->setChecked(s.value(kBase64Secret, false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value(kDownloadAlbumCovers, true).toBool());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@@ -110,19 +108,19 @@ void QobuzSettingsPage::Save() {
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("enabled", ui_->enable->isChecked());
|
||||
s.setValue("app_id", ui_->app_id->text());
|
||||
s.setValue("app_secret", ui_->app_secret->text());
|
||||
s.setValue(kAppId, ui_->app_id->text());
|
||||
s.setValue(kAppSecret, ui_->app_secret->text());
|
||||
|
||||
s.setValue("username", ui_->username->text());
|
||||
s.setValue("password", QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
||||
s.setValue(kUsername, ui_->username->text());
|
||||
s.setValue(kPassword, QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
||||
|
||||
s.setValue("format", ui_->format->itemData(ui_->format->currentIndex()));
|
||||
s.setValue("searchdelay", ui_->searchdelay->value());
|
||||
s.setValue("artistssearchlimit", ui_->artistssearchlimit->value());
|
||||
s.setValue("albumssearchlimit", ui_->albumssearchlimit->value());
|
||||
s.setValue("songssearchlimit", ui_->songssearchlimit->value());
|
||||
s.setValue("base64secret", ui_->checkbox_base64_secret->isChecked());
|
||||
s.setValue("downloadalbumcovers", ui_->checkbox_download_album_covers->isChecked());
|
||||
s.setValue(kFormat, ui_->format->itemData(ui_->format->currentIndex()));
|
||||
s.setValue(kSearchDelay, ui_->searchdelay->value());
|
||||
s.setValue(kArtistsSearchLimit, ui_->artistssearchlimit->value());
|
||||
s.setValue(kAlbumsSearchLimit, ui_->albumssearchlimit->value());
|
||||
s.setValue(kSongsSearchLimit, ui_->songssearchlimit->value());
|
||||
s.setValue(kBase64Secret, ui_->checkbox_base64_secret->isChecked());
|
||||
s.setValue(kDownloadAlbumCovers, ui_->checkbox_download_album_covers->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "settings/settingspage.h"
|
||||
|
||||
class QEvent;
|
||||
@@ -35,11 +35,9 @@ class QobuzSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QobuzSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit QobuzSettingsPage(SettingsDialog *dialog, const SharedPtr<QobuzService> service, QWidget *parent = nullptr);
|
||||
~QobuzSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -56,7 +54,7 @@ class QobuzSettingsPage : public SettingsPage {
|
||||
|
||||
private:
|
||||
Ui_QobuzSettingsPage *ui_;
|
||||
SharedPtr<QobuzService> service_;
|
||||
const SharedPtr<QobuzService> service_;
|
||||
};
|
||||
|
||||
#endif // QOBUZSETTINGSPAGE_H
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "settingsdialog.h"
|
||||
#include "settingspage.h"
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/song.h"
|
||||
#include "core/settings.h"
|
||||
@@ -41,18 +40,18 @@
|
||||
#include "scrobbler/lastfmscrobbler.h"
|
||||
#include "scrobbler/librefmscrobbler.h"
|
||||
#include "scrobbler/listenbrainzscrobbler.h"
|
||||
#include "constants/scrobblersettings.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace ScrobblerSettings;
|
||||
|
||||
const char *ScrobblerSettingsPage::kSettingsGroup = "Scrobbler";
|
||||
|
||||
ScrobblerSettingsPage::ScrobblerSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
ScrobblerSettingsPage::ScrobblerSettingsPage(SettingsDialog *dialog, const SharedPtr<AudioScrobbler> scrobbler, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
scrobbler_(dialog->app()->scrobbler()),
|
||||
lastfmscrobbler_(dialog->app()->scrobbler()->Service<LastFMScrobbler>()),
|
||||
librefmscrobbler_(dialog->app()->scrobbler()->Service<LibreFMScrobbler>()),
|
||||
listenbrainzscrobbler_(dialog->app()->scrobbler()->Service<ListenBrainzScrobbler>()),
|
||||
ui_(new Ui_ScrobblerSettingsPage),
|
||||
scrobbler_(scrobbler),
|
||||
lastfmscrobbler_(scrobbler_->Service<LastFMScrobbler>()),
|
||||
librefmscrobbler_(scrobbler_->Service<LibreFMScrobbler>()),
|
||||
listenbrainzscrobbler_(scrobbler_->Service<ListenBrainzScrobbler>()),
|
||||
lastfm_waiting_for_auth_(false),
|
||||
librefm_waiting_for_auth_(false),
|
||||
listenbrainz_waiting_for_auth_(false) {
|
||||
@@ -136,14 +135,14 @@ void ScrobblerSettingsPage::Save() {
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("enabled", ui_->checkbox_enable->isChecked());
|
||||
s.setValue("scrobble_button", ui_->checkbox_scrobble_button->isChecked());
|
||||
s.setValue("love_button", ui_->checkbox_love_button->isChecked());
|
||||
s.setValue("offline", ui_->checkbox_offline->isChecked());
|
||||
s.setValue("submit", ui_->spinbox_submit->value());
|
||||
s.setValue("albumartist", ui_->checkbox_albumartist->isChecked());
|
||||
s.setValue("show_error_dialog", ui_->checkbox_show_error_dialog->isChecked());
|
||||
s.setValue("strip_remastered", ui_->checkbox_strip_remastered->isChecked());
|
||||
s.setValue(kEnabled, ui_->checkbox_enable->isChecked());
|
||||
s.setValue(kScrobbleButton, ui_->checkbox_scrobble_button->isChecked());
|
||||
s.setValue(kLoveButton, ui_->checkbox_love_button->isChecked());
|
||||
s.setValue(kOffline, ui_->checkbox_offline->isChecked());
|
||||
s.setValue(kSubmit, ui_->spinbox_submit->value());
|
||||
s.setValue(kAlbumArtist, ui_->checkbox_albumartist->isChecked());
|
||||
s.setValue(kShowErrorDialog, ui_->checkbox_show_error_dialog->isChecked());
|
||||
s.setValue(kStripRemastered, ui_->checkbox_strip_remastered->isChecked());
|
||||
|
||||
QStringList sources;
|
||||
if (ui_->checkbox_source_collection->isChecked()) sources << Song::TextForSource(Song::Source::Collection);
|
||||
@@ -158,21 +157,21 @@ void ScrobblerSettingsPage::Save() {
|
||||
if (ui_->checkbox_source_radioparadise->isChecked()) sources << Song::TextForSource(Song::Source::RadioParadise);
|
||||
if (ui_->checkbox_source_unknown->isChecked()) sources << Song::TextForSource(Song::Source::Unknown);
|
||||
|
||||
s.setValue("sources", sources);
|
||||
s.setValue(kSources, sources);
|
||||
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(LastFMScrobbler::kSettingsGroup);
|
||||
s.setValue("enabled", ui_->checkbox_lastfm_enable->isChecked());
|
||||
s.setValue(kEnabled, ui_->checkbox_lastfm_enable->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(LibreFMScrobbler::kSettingsGroup);
|
||||
s.setValue("enabled", ui_->checkbox_librefm_enable->isChecked());
|
||||
s.setValue(kEnabled, ui_->checkbox_librefm_enable->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
s.beginGroup(ListenBrainzScrobbler::kSettingsGroup);
|
||||
s.setValue("enabled", ui_->checkbox_listenbrainz_enable->isChecked());
|
||||
s.setValue("user_token", ui_->lineedit_listenbrainz_user_token->text());
|
||||
s.setValue(kEnabled, ui_->checkbox_listenbrainz_enable->isChecked());
|
||||
s.setValue(kUserToken, ui_->lineedit_listenbrainz_user_token->text());
|
||||
s.endGroup();
|
||||
|
||||
scrobbler_->ReloadSettings();
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
|
||||
class SettingsDialog;
|
||||
class Ui_ScrobblerSettingsPage;
|
||||
@@ -40,11 +40,9 @@ class ScrobblerSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScrobblerSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit ScrobblerSettingsPage(SettingsDialog *dialog, const SharedPtr<AudioScrobbler> scrobbler, QWidget *parent = nullptr);
|
||||
~ScrobblerSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -60,12 +58,13 @@ class ScrobblerSettingsPage : public SettingsPage {
|
||||
void ListenBrainz_AuthenticationComplete(const bool success, const QString &error = QString());
|
||||
|
||||
private:
|
||||
SharedPtr<AudioScrobbler> scrobbler_;
|
||||
SharedPtr<LastFMScrobbler> lastfmscrobbler_;
|
||||
SharedPtr<LibreFMScrobbler> librefmscrobbler_;
|
||||
SharedPtr<ListenBrainzScrobbler> listenbrainzscrobbler_;
|
||||
Ui_ScrobblerSettingsPage *ui_;
|
||||
|
||||
const SharedPtr<AudioScrobbler> scrobbler_;
|
||||
const SharedPtr<LastFMScrobbler> lastfmscrobbler_;
|
||||
const SharedPtr<LibreFMScrobbler> librefmscrobbler_;
|
||||
const SharedPtr<ListenBrainzScrobbler> listenbrainzscrobbler_;
|
||||
|
||||
bool lastfm_waiting_for_auth_;
|
||||
bool librefm_waiting_for_auth_;
|
||||
bool listenbrainz_waiting_for_auth_;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
* Copyright 2019-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -47,15 +47,17 @@
|
||||
#include <QShowEvent>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/player.h"
|
||||
#include "utilities/screenutils.h"
|
||||
#include "widgets/groupediconview.h"
|
||||
#include "collection/collectionlibrary.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "streaming/streamingservices.h"
|
||||
|
||||
#include "settingsdialog.h"
|
||||
#include "settingspage.h"
|
||||
#include "settingsitemdelegate.h"
|
||||
#include "behavioursettingspage.h"
|
||||
#include "collectionsettingspage.h"
|
||||
#include "backendsettingspage.h"
|
||||
@@ -73,15 +75,19 @@
|
||||
# include "moodbarsettingspage.h"
|
||||
#endif
|
||||
#ifdef HAVE_SUBSONIC
|
||||
# include "subsonic/subsonicservice.h"
|
||||
# include "subsonicsettingspage.h"
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
# include "tidal/tidalservice.h"
|
||||
# include "tidalsettingspage.h"
|
||||
#endif
|
||||
#ifdef HAVE_SPOTIFY
|
||||
# include "spotify/spotifyservice.h"
|
||||
# include "spotifysettingspage.h"
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
# include "qobuz/qobuzservice.h"
|
||||
# include "qobuzsettingspage.h"
|
||||
#endif
|
||||
|
||||
@@ -89,45 +95,25 @@
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
const char *SettingsDialog::kSettingsGroup = "SettingsDialog";
|
||||
|
||||
SettingsItemDelegate::SettingsItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {}
|
||||
|
||||
QSize SettingsItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
const bool is_separator = idx.data(SettingsDialog::Role_IsSeparator).toBool();
|
||||
QSize ret = QStyledItemDelegate::sizeHint(option, idx);
|
||||
|
||||
if (is_separator) {
|
||||
ret.setHeight(ret.height() * 2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
namespace {
|
||||
constexpr char kSettingsGroup[] = "SettingsDialog";
|
||||
}
|
||||
|
||||
void SettingsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
const bool is_separator = idx.data(SettingsDialog::Role_IsSeparator).toBool();
|
||||
|
||||
if (is_separator) {
|
||||
GroupedIconView::DrawHeader(painter, option.rect, option.font, option.palette, idx.data().toString());
|
||||
}
|
||||
else {
|
||||
QStyledItemDelegate::paint(painter, option, idx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *mainwindow, QWidget *parent)
|
||||
SettingsDialog::SettingsDialog(const SharedPtr<Player> player,
|
||||
const SharedPtr<DeviceFinders> device_finders,
|
||||
const SharedPtr<CollectionLibrary> collection,
|
||||
const SharedPtr<CoverProviders> cover_providers,
|
||||
const SharedPtr<LyricsProviders> lyrics_providers,
|
||||
const SharedPtr<AudioScrobbler> scrobbler,
|
||||
const SharedPtr<StreamingServices> streaming_services,
|
||||
#ifdef HAVE_GLOBALSHORTCUTS
|
||||
GlobalShortcutsManager *global_shortcuts_manager,
|
||||
#endif
|
||||
OSDBase *osd,
|
||||
QMainWindow *mainwindow,
|
||||
QWidget *parent)
|
||||
: QDialog(parent),
|
||||
mainwindow_(mainwindow),
|
||||
app_(app),
|
||||
osd_(osd),
|
||||
player_(app_->player()),
|
||||
engine_(app_->player()->engine()),
|
||||
model_(app_->collection_model()->directory_model()),
|
||||
manager_(nullptr),
|
||||
ui_(new Ui_SettingsDialog),
|
||||
loading_settings_(false) {
|
||||
|
||||
@@ -136,22 +122,22 @@ SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *main
|
||||
|
||||
QTreeWidgetItem *general = AddCategory(tr("General"));
|
||||
AddPage(Page::Behaviour, new BehaviourSettingsPage(this, this), general);
|
||||
AddPage(Page::Collection, new CollectionSettingsPage(this, this), general);
|
||||
AddPage(Page::Backend, new BackendSettingsPage(this, this), general);
|
||||
AddPage(Page::Collection, new CollectionSettingsPage(this, collection, collection->backend(), collection->model(), collection->model()->directory_model(), this), general);
|
||||
AddPage(Page::Backend, new BackendSettingsPage(this, player, device_finders, this), general);
|
||||
AddPage(Page::Playlist, new PlaylistSettingsPage(this, this), general);
|
||||
AddPage(Page::Scrobbler, new ScrobblerSettingsPage(this, this), general);
|
||||
AddPage(Page::Covers, new CoversSettingsPage(this, this), general);
|
||||
AddPage(Page::Lyrics, new LyricsSettingsPage(this, this), general);
|
||||
AddPage(Page::Scrobbler, new ScrobblerSettingsPage(this, scrobbler, this), general);
|
||||
AddPage(Page::Covers, new CoversSettingsPage(this, cover_providers, this), general);
|
||||
AddPage(Page::Lyrics, new LyricsSettingsPage(this, lyrics_providers, this), general);
|
||||
AddPage(Page::Transcoding, new TranscoderSettingsPage(this, this), general);
|
||||
AddPage(Page::Proxy, new NetworkProxySettingsPage(this, this), general);
|
||||
|
||||
QTreeWidgetItem *iface = AddCategory(tr("User interface"));
|
||||
AddPage(Page::Appearance, new AppearanceSettingsPage(this, this), iface);
|
||||
AddPage(Page::Context, new ContextSettingsPage(this, this), iface);
|
||||
AddPage(Page::Notifications, new NotificationsSettingsPage(this, this), iface);
|
||||
AddPage(Page::Notifications, new NotificationsSettingsPage(this, osd, this), iface);
|
||||
|
||||
#ifdef HAVE_GLOBALSHORTCUTS
|
||||
AddPage(Page::GlobalShortcuts, new GlobalShortcutsSettingsPage(this, this), iface);
|
||||
AddPage(Page::GlobalShortcuts, new GlobalShortcutsSettingsPage(this, global_shortcuts_manager, this), iface);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MOODBAR
|
||||
@@ -163,16 +149,16 @@ SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *main
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SUBSONIC
|
||||
AddPage(Page::Subsonic, new SubsonicSettingsPage(this, this), streaming);
|
||||
AddPage(Page::Subsonic, new SubsonicSettingsPage(this, streaming_services->Service<SubsonicService>(), this), streaming);
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
AddPage(Page::Tidal, new TidalSettingsPage(this, this), streaming);
|
||||
AddPage(Page::Tidal, new TidalSettingsPage(this, streaming_services->Service<TidalService>(), this), streaming);
|
||||
#endif
|
||||
#ifdef HAVE_SPOTIFY
|
||||
AddPage(Page::Spotify, new SpotifySettingsPage(this, this), streaming);
|
||||
AddPage(Page::Spotify, new SpotifySettingsPage(this, streaming_services->Service<SpotifyService>(), this), streaming);
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
AddPage(Page::Qobuz, new QobuzSettingsPage(this, this), streaming);
|
||||
AddPage(Page::Qobuz, new QobuzSettingsPage(this, streaming_services->Service<QobuzService>(), this), streaming);
|
||||
#endif
|
||||
|
||||
// List box
|
||||
@@ -344,7 +330,7 @@ void SettingsDialog::DialogButtonClicked(QAbstractButton *button) {
|
||||
|
||||
}
|
||||
|
||||
void SettingsDialog::OpenAtPage(Page page) {
|
||||
void SettingsDialog::OpenAtPage(const Page page) {
|
||||
|
||||
if (!pages_.contains(page)) {
|
||||
return;
|
||||
|
||||
@@ -26,21 +26,15 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QStyleOption>
|
||||
#include <QMap>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "constants/notificationssettings.h"
|
||||
#include "osd/osdbase.h"
|
||||
|
||||
class QMainWindow;
|
||||
class QWidget;
|
||||
class QModelIndex;
|
||||
class QPainter;
|
||||
class QTreeWidgetItem;
|
||||
class QComboBox;
|
||||
class QScrollArea;
|
||||
@@ -48,29 +42,35 @@ class QAbstractButton;
|
||||
class QShowEvent;
|
||||
class QCloseEvent;
|
||||
|
||||
class Application;
|
||||
class Player;
|
||||
class CollectionDirectoryModel;
|
||||
class DeviceFinders;
|
||||
class CollectionLibrary;
|
||||
class CoverProviders;
|
||||
class LyricsProviders;
|
||||
class AudioScrobbler;
|
||||
class StreamingServices;
|
||||
class GlobalShortcutsManager;
|
||||
class SettingsPage;
|
||||
|
||||
class Ui_SettingsDialog;
|
||||
|
||||
class SettingsItemDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsItemDelegate(QObject *parent);
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
};
|
||||
|
||||
|
||||
class SettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsDialog(Application *app, OSDBase *osd, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
||||
explicit SettingsDialog(const SharedPtr<Player> player,
|
||||
const SharedPtr<DeviceFinders> device_finders,
|
||||
const SharedPtr<CollectionLibrary> collection,
|
||||
const SharedPtr<CoverProviders> cover_providers,
|
||||
const SharedPtr<LyricsProviders> lyrics_providers,
|
||||
const SharedPtr<AudioScrobbler> scrobbler,
|
||||
const SharedPtr<StreamingServices> streaming_services,
|
||||
#ifdef HAVE_GLOBALSHORTCUTS
|
||||
GlobalShortcutsManager *global_shortcuts_manager,
|
||||
#endif
|
||||
OSDBase *osd,
|
||||
QMainWindow *mainwindow,
|
||||
QWidget *parent = nullptr);
|
||||
~SettingsDialog() override;
|
||||
|
||||
enum class Page {
|
||||
@@ -99,22 +99,13 @@ class SettingsDialog : public QDialog {
|
||||
Role_IsSeparator = Qt::UserRole
|
||||
};
|
||||
|
||||
void SetGlobalShortcutManager(GlobalShortcutsManager *manager) { manager_ = manager; }
|
||||
|
||||
bool is_loading_settings() const { return loading_settings_; }
|
||||
|
||||
Application *app() const { return app_; }
|
||||
OSDBase *osd() const { return osd_; }
|
||||
SharedPtr<Player> player() const { return player_; }
|
||||
SharedPtr<EngineBase> engine() const { return engine_; }
|
||||
CollectionDirectoryModel *collection_directory_model() const { return model_; }
|
||||
GlobalShortcutsManager *global_shortcuts_manager() const { return manager_; }
|
||||
|
||||
void OpenAtPage(Page page);
|
||||
void OpenAtPage(const Page page);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
void closeEvent(QCloseEvent*) override;
|
||||
void closeEvent(QCloseEvent *e) override;
|
||||
|
||||
private:
|
||||
struct PageData {
|
||||
@@ -139,26 +130,16 @@ class SettingsDialog : public QDialog {
|
||||
|
||||
Q_SIGNALS:
|
||||
void ReloadSettings();
|
||||
void NotificationPreview(const OSDBase::Behaviour, const QString&, const QString&);
|
||||
void NotificationPreview(const OSDSettings::Type, const QString&, const QString&);
|
||||
|
||||
private Q_SLOTS:
|
||||
void CurrentItemChanged(QTreeWidgetItem *item);
|
||||
void DialogButtonClicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
QMainWindow *mainwindow_;
|
||||
Application *app_;
|
||||
OSDBase *osd_;
|
||||
SharedPtr<Player> player_;
|
||||
SharedPtr<EngineBase> engine_;
|
||||
CollectionDirectoryModel *model_;
|
||||
GlobalShortcutsManager *manager_;
|
||||
|
||||
Ui_SettingsDialog *ui_;
|
||||
bool loading_settings_;
|
||||
|
||||
QMap<Page, PageData> pages_;
|
||||
};
|
||||
|
||||
|
||||
54
src/settings/settingsitemdelegate.cpp
Normal file
54
src/settings/settingsitemdelegate.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2019-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "settingsitemdelegate.h"
|
||||
#include "widgets/groupediconview.h"
|
||||
#include "settingsdialog.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
SettingsItemDelegate::SettingsItemDelegate(QObject *parent) : QStyledItemDelegate(parent) {}
|
||||
|
||||
QSize SettingsItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
const bool is_separator = idx.data(SettingsDialog::Role_IsSeparator).toBool();
|
||||
QSize ret = QStyledItemDelegate::sizeHint(option, idx);
|
||||
|
||||
if (is_separator) {
|
||||
ret.setHeight(ret.height() * 2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void SettingsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||
|
||||
const bool is_separator = idx.data(SettingsDialog::Role_IsSeparator).toBool();
|
||||
|
||||
if (is_separator) {
|
||||
GroupedIconView::DrawHeader(painter, option.rect, option.font, option.palette, idx.data().toString());
|
||||
}
|
||||
else {
|
||||
QStyledItemDelegate::paint(painter, option, idx);
|
||||
}
|
||||
|
||||
}
|
||||
39
src/settings/settingsitemdelegate.h
Normal file
39
src/settings/settingsitemdelegate.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2019-2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SETTINGSITEMDELEGATE_H
|
||||
#define SETTINGSITEMDELEGATE_H
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QStyleOptionViewItem>
|
||||
|
||||
class QPainter;
|
||||
|
||||
class SettingsItemDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsItemDelegate(QObject *parent);
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
};
|
||||
|
||||
#endif // SETTINGSITEMDELEGATE_H
|
||||
@@ -32,9 +32,9 @@
|
||||
#include <QString>
|
||||
#include <QSettings>
|
||||
|
||||
#include "osd/osdbase.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/settings.h"
|
||||
#include "constants/notificationssettings.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
@@ -81,7 +81,7 @@ class SettingsPage : public QWidget {
|
||||
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void NotificationPreview(const OSDBase::Behaviour, const QString&, const QString&);
|
||||
void NotificationPreview(const OSDSettings::Type, const QString&, const QString&);
|
||||
|
||||
private:
|
||||
SettingsDialog *dialog_;
|
||||
|
||||
@@ -38,21 +38,19 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "spotifysettingspage.h"
|
||||
#include "ui_spotifysettingspage.h"
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "streaming/streamingservices.h"
|
||||
#include "spotify/spotifyservice.h"
|
||||
#include "widgets/loginstatewidget.h"
|
||||
#include "constants/spotifysettings.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace SpotifySettings;
|
||||
|
||||
const char *SpotifySettingsPage::kSettingsGroup = "Spotify";
|
||||
|
||||
SpotifySettingsPage::SpotifySettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
SpotifySettingsPage::SpotifySettingsPage(SettingsDialog *dialog, const SharedPtr<SpotifyService> service, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui::SpotifySettingsPage),
|
||||
service_(dialog->app()->streaming_services()->Service<SpotifyService>()) {
|
||||
service_(service) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load(u"spotify"_s));
|
||||
@@ -87,14 +85,14 @@ void SpotifySettingsPage::Load() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||
ui_->enable->setChecked(s.value(kEnabled, false).toBool());
|
||||
|
||||
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value("songssearchlimit", 10).toInt());
|
||||
ui_->checkbox_fetchalbums->setChecked(s.value("fetchalbums", false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool());
|
||||
ui_->searchdelay->setValue(s.value(kSearchDelay, 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value(kArtistsSearchLimit, 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value(kAlbumsSearchLimit, 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value(kSongsSearchLimit, 10).toInt());
|
||||
ui_->checkbox_fetchalbums->setChecked(s.value(kFetchAlbums, false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value(kDownloadAlbumCovers, true).toBool());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@@ -110,13 +108,13 @@ void SpotifySettingsPage::Save() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("enabled", ui_->enable->isChecked());
|
||||
s.setValue("searchdelay", ui_->searchdelay->value());
|
||||
s.setValue("artistssearchlimit", ui_->artistssearchlimit->value());
|
||||
s.setValue("albumssearchlimit", ui_->albumssearchlimit->value());
|
||||
s.setValue("songssearchlimit", ui_->songssearchlimit->value());
|
||||
s.setValue("fetchalbums", ui_->checkbox_fetchalbums->isChecked());
|
||||
s.setValue("downloadalbumcovers", ui_->checkbox_download_album_covers->isChecked());
|
||||
s.setValue(kEnabled, ui_->enable->isChecked());
|
||||
s.setValue(kSearchDelay, ui_->searchdelay->value());
|
||||
s.setValue(kArtistsSearchLimit, ui_->artistssearchlimit->value());
|
||||
s.setValue(kAlbumsSearchLimit, ui_->albumssearchlimit->value());
|
||||
s.setValue(kSongsSearchLimit, ui_->songssearchlimit->value());
|
||||
s.setValue(kFetchAlbums, ui_->checkbox_fetchalbums->isChecked());
|
||||
s.setValue(kDownloadAlbumCovers, ui_->checkbox_download_album_covers->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "settings/settingspage.h"
|
||||
|
||||
class QEvent;
|
||||
@@ -37,11 +37,9 @@ class SpotifySettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpotifySettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit SpotifySettingsPage(SettingsDialog *dialog, const SharedPtr<SpotifyService> service, QWidget *parent = nullptr);
|
||||
~SpotifySettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
@@ -58,7 +56,7 @@ class SpotifySettingsPage : public SettingsPage {
|
||||
|
||||
private:
|
||||
Ui_SpotifySettingsPage *ui_;
|
||||
SharedPtr<SpotifyService> service_;
|
||||
const SharedPtr<SpotifyService> service_;
|
||||
};
|
||||
|
||||
#endif // SPOTIFYSETTINGSPAGE_H
|
||||
|
||||
@@ -34,18 +34,17 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "subsonicsettingspage.h"
|
||||
#include "ui_subsonicsettingspage.h"
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "streaming/streamingservices.h"
|
||||
#include "subsonic/subsonicservice.h"
|
||||
#include "constants/subsonicsettings.h"
|
||||
|
||||
const char *SubsonicSettingsPage::kSettingsGroup = "Subsonic";
|
||||
using namespace SubsonicSettings;
|
||||
|
||||
SubsonicSettingsPage::SubsonicSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
SubsonicSettingsPage::SubsonicSettingsPage(SettingsDialog *dialog, const SharedPtr<SubsonicService> service, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui::SubsonicSettingsPage),
|
||||
service_(dialog->app()->streaming_services()->Service<SubsonicService>()) {
|
||||
service_(service) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load(QStringLiteral("subsonic"), true, 0, 32));
|
||||
@@ -70,18 +69,18 @@ void SubsonicSettingsPage::Load() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||
ui_->server_url->setText(s.value("url").toString());
|
||||
ui_->username->setText(s.value("username").toString());
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
ui_->enable->setChecked(s.value(kEnabled, false).toBool());
|
||||
ui_->server_url->setText(s.value(kUrl).toString());
|
||||
ui_->username->setText(s.value(kUsername).toString());
|
||||
QByteArray password = s.value(kPassword).toByteArray();
|
||||
if (password.isEmpty()) ui_->password->clear();
|
||||
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
|
||||
ui_->checkbox_http2->setChecked(s.value("http2", false).toBool());
|
||||
ui_->checkbox_verify_certificate->setChecked(s.value("verifycertificate", false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool());
|
||||
ui_->checkbox_server_scrobbling->setChecked(s.value("serversidescrobbling", false).toBool());
|
||||
ui_->checkbox_http2->setChecked(s.value(kHTTP2, false).toBool());
|
||||
ui_->checkbox_verify_certificate->setChecked(s.value(kVerifyCertificate, false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value(kDownloadAlbumCovers, true).toBool());
|
||||
ui_->checkbox_server_scrobbling->setChecked(s.value(kServerSideScrobbling, false).toBool());
|
||||
|
||||
const AuthMethod auth_method = static_cast<AuthMethod>(s.value("authmethod", static_cast<int>(AuthMethod::MD5)).toInt());
|
||||
const AuthMethod auth_method = static_cast<AuthMethod>(s.value(kAuthMethod, static_cast<int>(AuthMethod::MD5)).toInt());
|
||||
switch (auth_method) {
|
||||
case AuthMethod::Hex:
|
||||
ui_->auth_method_hex->setChecked(true);
|
||||
@@ -103,19 +102,19 @@ void SubsonicSettingsPage::Save() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("enabled", ui_->enable->isChecked());
|
||||
s.setValue("url", QUrl(ui_->server_url->text()));
|
||||
s.setValue("username", ui_->username->text());
|
||||
s.setValue("password", QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
||||
s.setValue("http2", ui_->checkbox_http2->isChecked());
|
||||
s.setValue("verifycertificate", ui_->checkbox_verify_certificate->isChecked());
|
||||
s.setValue("downloadalbumcovers", ui_->checkbox_download_album_covers->isChecked());
|
||||
s.setValue("serversidescrobbling", ui_->checkbox_server_scrobbling->isChecked());
|
||||
s.setValue(kEnabled, ui_->enable->isChecked());
|
||||
s.setValue(kUrl, QUrl(ui_->server_url->text()));
|
||||
s.setValue(kUsername, ui_->username->text());
|
||||
s.setValue(kPassword, QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
||||
s.setValue(kHTTP2, ui_->checkbox_http2->isChecked());
|
||||
s.setValue(kVerifyCertificate, ui_->checkbox_verify_certificate->isChecked());
|
||||
s.setValue(kDownloadAlbumCovers, ui_->checkbox_download_album_covers->isChecked());
|
||||
s.setValue(kServerSideScrobbling, ui_->checkbox_server_scrobbling->isChecked());
|
||||
if (ui_->auth_method_hex->isChecked()) {
|
||||
s.setValue("authmethod", static_cast<int>(AuthMethod::Hex));
|
||||
s.setValue(kAuthMethod, static_cast<int>(AuthMethod::Hex));
|
||||
}
|
||||
else {
|
||||
s.setValue("authmethod", static_cast<int>(AuthMethod::MD5));
|
||||
s.setValue(kAuthMethod, static_cast<int>(AuthMethod::MD5));
|
||||
}
|
||||
s.endGroup();
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "constants/subsonicsettings.h"
|
||||
#include "settings/settingspage.h"
|
||||
|
||||
class QEvent;
|
||||
@@ -38,23 +39,16 @@ class SubsonicSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SubsonicSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit SubsonicSettingsPage(SettingsDialog *dialog, const SharedPtr<SubsonicService> service, QWidget *parent = nullptr);
|
||||
~SubsonicSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
enum class AuthMethod {
|
||||
Hex,
|
||||
MD5
|
||||
};
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void Test(const QUrl &url, const QString &username, const QString &password, const SubsonicSettingsPage::AuthMethod auth_method, const bool redirect = false);
|
||||
void Test(const QUrl &url, const QString &username, const QString &password, const SubsonicSettings::AuthMethod auth_method, const bool redirect = false);
|
||||
|
||||
private Q_SLOTS:
|
||||
void TestClicked();
|
||||
@@ -63,7 +57,7 @@ class SubsonicSettingsPage : public SettingsPage {
|
||||
|
||||
private:
|
||||
Ui_SubsonicSettingsPage *ui_;
|
||||
SharedPtr<SubsonicService> service_;
|
||||
const SharedPtr<SubsonicService> service_;
|
||||
};
|
||||
|
||||
#endif // SUBSONICSETTINGSPAGE_H
|
||||
|
||||
@@ -34,21 +34,19 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "tidalsettingspage.h"
|
||||
#include "ui_tidalsettingspage.h"
|
||||
#include "core/application.h"
|
||||
#include "constants/tidalsettings.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/settings.h"
|
||||
#include "streaming/streamingservices.h"
|
||||
#include "tidal/tidalservice.h"
|
||||
#include "widgets/loginstatewidget.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace TidalSettings;
|
||||
|
||||
const char *TidalSettingsPage::kSettingsGroup = "Tidal";
|
||||
|
||||
TidalSettingsPage::TidalSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
TidalSettingsPage::TidalSettingsPage(SettingsDialog *dialog, SharedPtr<TidalService> service, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui::TidalSettingsPage),
|
||||
service_(dialog->app()->streaming_services()->Service<TidalService>()) {
|
||||
service_(service) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load(u"tidal"_s, true, 0, 32));
|
||||
@@ -88,27 +86,27 @@ void TidalSettingsPage::Load() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||
ui_->oauth->setChecked(s.value("oauth", true).toBool());
|
||||
ui_->enable->setChecked(s.value(kEnabled, false).toBool());
|
||||
ui_->oauth->setChecked(s.value(kOAuth, true).toBool());
|
||||
|
||||
ui_->client_id->setText(s.value("client_id").toString());
|
||||
ui_->api_token->setText(s.value("api_token").toString());
|
||||
ui_->client_id->setText(s.value(kClientId).toString());
|
||||
ui_->api_token->setText(s.value(kApiToken).toString());
|
||||
|
||||
ui_->username->setText(s.value("username").toString());
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
ui_->username->setText(s.value(kUsername).toString());
|
||||
QByteArray password = s.value(kPassword).toByteArray();
|
||||
if (password.isEmpty()) ui_->password->clear();
|
||||
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
|
||||
|
||||
ComboBoxLoadFromSettings(s, ui_->quality, u"quality"_s, u"LOSSLESS"_s);
|
||||
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value("songssearchlimit", 10).toInt());
|
||||
ui_->checkbox_fetchalbums->setChecked(s.value("fetchalbums", false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool());
|
||||
ComboBoxLoadFromSettings(s, ui_->coversize, u"coversize"_s, u"640x640"_s);
|
||||
ui_->streamurl->setCurrentIndex(ui_->streamurl->findData(s.value("streamurl", static_cast<int>(StreamUrlMethod::StreamUrl)).toInt()));
|
||||
ui_->checkbox_album_explicit->setChecked(s.value("album_explicit", false).toBool());
|
||||
ComboBoxLoadFromSettings(s, ui_->quality, QLatin1String(kQuality), u"LOSSLESS"_s);
|
||||
ui_->searchdelay->setValue(s.value(kSearchDelay, 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value("kArtistsSearchLimit", 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value(kAlbumsSearchLimit, 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value(kSongsSearchLimit, 10).toInt());
|
||||
ui_->checkbox_fetchalbums->setChecked(s.value(kFetchAlbums, false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value(kDownloadAlbumCovers, true).toBool());
|
||||
ComboBoxLoadFromSettings(s, ui_->coversize, QLatin1String(kCoverSize), u"640x640"_s);
|
||||
ui_->streamurl->setCurrentIndex(ui_->streamurl->findData(s.value(kStreamUrl, static_cast<int>(StreamUrlMethod::StreamUrl)).toInt()));
|
||||
ui_->checkbox_album_explicit->setChecked(s.value(kAlbumExplicit, false).toBool());
|
||||
|
||||
s.endGroup();
|
||||
|
||||
@@ -125,24 +123,24 @@ void TidalSettingsPage::Save() {
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("enabled", ui_->enable->isChecked());
|
||||
s.setValue("oauth", ui_->oauth->isChecked());
|
||||
s.setValue("client_id", ui_->client_id->text());
|
||||
s.setValue("api_token", ui_->api_token->text());
|
||||
s.setValue(kEnabled, ui_->enable->isChecked());
|
||||
s.setValue(kOAuth, ui_->oauth->isChecked());
|
||||
s.setValue(kClientId, ui_->client_id->text());
|
||||
s.setValue(kApiToken, ui_->api_token->text());
|
||||
|
||||
s.setValue("username", ui_->username->text());
|
||||
s.setValue("password", QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
||||
s.setValue(kUsername, ui_->username->text());
|
||||
s.setValue(kPassword, QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
||||
|
||||
s.setValue("quality", ui_->quality->currentData().toString());
|
||||
s.setValue("searchdelay", ui_->searchdelay->value());
|
||||
s.setValue("artistssearchlimit", ui_->artistssearchlimit->value());
|
||||
s.setValue("albumssearchlimit", ui_->albumssearchlimit->value());
|
||||
s.setValue("songssearchlimit", ui_->songssearchlimit->value());
|
||||
s.setValue("fetchalbums", ui_->checkbox_fetchalbums->isChecked());
|
||||
s.setValue("downloadalbumcovers", ui_->checkbox_download_album_covers->isChecked());
|
||||
s.setValue("coversize", ui_->coversize->currentData().toString());
|
||||
s.setValue("streamurl", ui_->streamurl->currentData().toInt());
|
||||
s.setValue("album_explicit", ui_->checkbox_album_explicit->isChecked());
|
||||
s.setValue(kQuality, ui_->quality->currentData().toString());
|
||||
s.setValue(kSearchDelay, ui_->searchdelay->value());
|
||||
s.setValue(kArtistsSearchLimit, ui_->artistssearchlimit->value());
|
||||
s.setValue(kAlbumsSearchLimit, ui_->albumssearchlimit->value());
|
||||
s.setValue(kSongsSearchLimit, ui_->songssearchlimit->value());
|
||||
s.setValue(kFetchAlbums, ui_->checkbox_fetchalbums->isChecked());
|
||||
s.setValue(kDownloadAlbumCovers, ui_->checkbox_download_album_covers->isChecked());
|
||||
s.setValue(kCoverSize, ui_->coversize->currentData().toString());
|
||||
s.setValue(kStreamUrl, ui_->streamurl->currentData().toInt());
|
||||
s.setValue(kAlbumExplicit, ui_->checkbox_album_explicit->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "settings/settingspage.h"
|
||||
|
||||
class QEvent;
|
||||
@@ -37,17 +37,9 @@ class TidalSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
explicit TidalSettingsPage(SettingsDialog *dialog, SharedPtr<TidalService> service, QWidget *parent = nullptr);
|
||||
~TidalSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
enum class StreamUrlMethod {
|
||||
StreamUrl,
|
||||
UrlPostPaywall,
|
||||
PlaybackInfoPostPaywall
|
||||
};
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@
|
||||
#include "transcoder/transcoderoptionsmp3.h"
|
||||
#include "transcodersettingspage.h"
|
||||
#include "ui_transcodersettingspage.h"
|
||||
#include "constants/transcodersettings.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using namespace TranscoderSettings;
|
||||
|
||||
class SettingsDialog;
|
||||
|
||||
|
||||
@@ -41,8 +41,6 @@ class TranscoderSettingsPage : public SettingsPage {
|
||||
explicit TranscoderSettingsPage(SettingsDialog *dialog, QWidget *parent = nullptr);
|
||||
~TranscoderSettingsPage() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void Load() override;
|
||||
void Save() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user