@@ -42,7 +42,6 @@
|
||||
|
||||
#include "appearancesettingspage.h"
|
||||
#include "utilities/colorutils.h"
|
||||
#include "core/appearance.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/stylehelper.h"
|
||||
#include "covermanager/albumcoverchoicecontroller.h"
|
||||
@@ -55,10 +54,6 @@ const char *AppearanceSettingsPage::kSettingsGroup = "Appearance";
|
||||
const char *AppearanceSettingsPage::kStyle = "style";
|
||||
const char *AppearanceSettingsPage::kSystemThemeIcons = "system_icons";
|
||||
|
||||
const char *AppearanceSettingsPage::kUseCustomColorSet = "use-custom-set";
|
||||
const char *AppearanceSettingsPage::kForegroundColor = "foreground-color";
|
||||
const char *AppearanceSettingsPage::kBackgroundColor = "background-color";
|
||||
|
||||
const char *AppearanceSettingsPage::kBackgroundImageType = "background_image_type";
|
||||
const char *AppearanceSettingsPage::kBackgroundImageFilename = "background_image_file";
|
||||
const char *AppearanceSettingsPage::kBackgroundImagePosition = "background_image_position";
|
||||
@@ -89,7 +84,6 @@ const char *AppearanceSettingsPage::kPlaylistPlayingSongColor = "playlist_playin
|
||||
AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
||||
: SettingsPage(dialog, parent),
|
||||
ui_(new Ui_AppearanceSettingsPage),
|
||||
original_use_a_custom_color_set_(false),
|
||||
background_image_type_(BackgroundImageType_Default) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
@@ -109,10 +103,6 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog, QWidget *
|
||||
QObject::connect(ui_->blur_slider, &QSlider::valueChanged, this, &AppearanceSettingsPage::BlurLevelChanged);
|
||||
QObject::connect(ui_->opacity_slider, &QSlider::valueChanged, this, &AppearanceSettingsPage::OpacityLevelChanged);
|
||||
|
||||
QObject::connect(ui_->use_a_custom_color_set, &QRadioButton::toggled, this, &AppearanceSettingsPage::UseCustomColorSetOptionChanged);
|
||||
QObject::connect(ui_->select_foreground_color, &QPushButton::pressed, this, &AppearanceSettingsPage::SelectForegroundColor);
|
||||
QObject::connect(ui_->select_background_color, &QPushButton::pressed, this, &AppearanceSettingsPage::SelectBackgroundColor);
|
||||
|
||||
QObject::connect(ui_->use_default_background, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setDisabled);
|
||||
QObject::connect(ui_->use_no_background, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setDisabled);
|
||||
QObject::connect(ui_->use_album_cover_background, &QRadioButton::toggled, ui_->widget_custom_background_image_options, &AppearanceSettingsPage::setEnabled);
|
||||
@@ -158,18 +148,6 @@ void AppearanceSettingsPage::Load() {
|
||||
ui_->checkbox_system_icons->setChecked(s.value(kSystemThemeIcons, false).toBool());
|
||||
#endif
|
||||
|
||||
QPalette p = QApplication::palette();
|
||||
|
||||
// Keep in mind originals colors, in case the user clicks on Cancel, to be able to restore colors
|
||||
original_use_a_custom_color_set_ = s.value(kUseCustomColorSet, false).toBool();
|
||||
|
||||
original_foreground_color_ = s.value(kForegroundColor, p.color(QPalette::WindowText)).value<QColor>();
|
||||
current_foreground_color_ = original_foreground_color_;
|
||||
original_background_color_ = s.value(kBackgroundColor, p.color(QPalette::Window)).value<QColor>();
|
||||
current_background_color_ = original_background_color_;
|
||||
|
||||
InitColorSelectorsColors();
|
||||
|
||||
// Tab widget BG color settings.
|
||||
bool tabbar_system_color = s.value(kTabBarSystemColor, true).toBool();
|
||||
ui_->tabbar_gradient->setChecked(s.value(kTabBarGradient, true).toBool());
|
||||
@@ -185,9 +163,6 @@ void AppearanceSettingsPage::Load() {
|
||||
background_image_type_ = static_cast<BackgroundImageType>(s.value(kBackgroundImageType).toInt());
|
||||
background_image_filename_ = s.value(kBackgroundImageFilename).toString();
|
||||
|
||||
ui_->use_system_color_set->setChecked(!original_use_a_custom_color_set_);
|
||||
ui_->use_a_custom_color_set->setChecked(original_use_a_custom_color_set_);
|
||||
|
||||
switch (background_image_type_) {
|
||||
case BackgroundImageType_Default:
|
||||
ui_->use_default_background->setChecked(true);
|
||||
@@ -257,18 +232,6 @@ void AppearanceSettingsPage::Save() {
|
||||
s.setValue(kSystemThemeIcons, ui_->checkbox_system_icons->isChecked());
|
||||
#endif
|
||||
|
||||
bool use_a_custom_color_set = ui_->use_a_custom_color_set->isChecked();
|
||||
s.setValue(kUseCustomColorSet, use_a_custom_color_set);
|
||||
if (use_a_custom_color_set) {
|
||||
s.setValue(kBackgroundColor, current_background_color_);
|
||||
s.setValue(kForegroundColor, current_foreground_color_);
|
||||
}
|
||||
else {
|
||||
dialog()->appearance()->ResetToSystemDefaultTheme();
|
||||
s.remove(kBackgroundColor);
|
||||
s.remove(kForegroundColor);
|
||||
}
|
||||
|
||||
background_image_filename_ = ui_->background_image_filename->text();
|
||||
if (ui_->use_default_background->isChecked()) {
|
||||
background_image_type_ = BackgroundImageType_Default;
|
||||
@@ -326,70 +289,6 @@ void AppearanceSettingsPage::Save() {
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::Cancel() {
|
||||
|
||||
if (original_use_a_custom_color_set_) {
|
||||
dialog()->appearance()->ChangeForegroundColor(original_foreground_color_);
|
||||
dialog()->appearance()->ChangeBackgroundColor(original_background_color_);
|
||||
}
|
||||
else {
|
||||
dialog()->appearance()->ResetToSystemDefaultTheme();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::SelectForegroundColor() {
|
||||
|
||||
QColor color_selected = QColorDialog::getColor(current_foreground_color_);
|
||||
if (!color_selected.isValid()) return;
|
||||
|
||||
current_foreground_color_ = color_selected;
|
||||
dialog()->appearance()->ChangeForegroundColor(color_selected);
|
||||
|
||||
UpdateColorSelectorColor(ui_->select_foreground_color, color_selected);
|
||||
|
||||
set_changed();
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::SelectBackgroundColor() {
|
||||
|
||||
QColor color_selected = QColorDialog::getColor(current_background_color_);
|
||||
if (!color_selected.isValid()) return;
|
||||
|
||||
current_background_color_ = color_selected;
|
||||
dialog()->appearance()->ChangeBackgroundColor(color_selected);
|
||||
|
||||
UpdateColorSelectorColor(ui_->select_background_color, color_selected);
|
||||
|
||||
set_changed();
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::UseCustomColorSetOptionChanged(bool checked) {
|
||||
|
||||
if (checked) {
|
||||
dialog()->appearance()->ChangeForegroundColor(current_foreground_color_);
|
||||
dialog()->appearance()->ChangeBackgroundColor(current_background_color_);
|
||||
}
|
||||
else {
|
||||
dialog()->appearance()->ResetToSystemDefaultTheme();
|
||||
QPalette p = QApplication::palette();
|
||||
current_foreground_color_ = p.color(QPalette::WindowText);
|
||||
current_background_color_ = p.color(QPalette::Window);
|
||||
UpdateColorSelectorColor(ui_->select_foreground_color, current_foreground_color_);
|
||||
UpdateColorSelectorColor(ui_->select_background_color, current_background_color_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::InitColorSelectorsColors() {
|
||||
|
||||
UpdateColorSelectorColor(ui_->select_foreground_color, current_foreground_color_);
|
||||
UpdateColorSelectorColor(ui_->select_background_color, current_background_color_);
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::UpdateColorSelectorColor(QWidget *color_selector, const QColor &color) {
|
||||
|
||||
QString css = QString("background-color: rgb(%1, %2, %3); color: rgb(255, 255, 255); border: 1px dotted black;").arg(color.red()).arg(color.green()).arg(color.blue());
|
||||
|
||||
Reference in New Issue
Block a user