From a2b5c3ea08cb40a1736c00e11292ab1f2142a89e Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 31 Dec 2022 18:20:28 +0100 Subject: [PATCH] Remove settings for changing palette colors Fixes #1087 --- debian/copyright | 5 -- src/CMakeLists.txt | 2 - src/core/appearance.cpp | 92 ------------------- src/core/appearance.h | 48 ---------- src/core/application.cpp | 4 - src/core/application.h | 2 - src/core/mainwindow.cpp | 6 -- src/settings/appearancesettingspage.cpp | 101 --------------------- src/settings/appearancesettingspage.h | 15 ---- src/settings/appearancesettingspage.ui | 112 +----------------------- src/settings/settingsdialog.cpp | 1 - src/settings/settingsdialog.h | 3 - 12 files changed, 2 insertions(+), 389 deletions(-) delete mode 100644 src/core/appearance.cpp delete mode 100644 src/core/appearance.h diff --git a/debian/copyright b/debian/copyright index d5c67863..52a5c6a7 100644 --- a/debian/copyright +++ b/debian/copyright @@ -130,11 +130,6 @@ Copyright: 2012, David Sansome 2018-2021, Jonas Kvinge License: GPL-3+ -Files: src/core/appearance.cpp - src/core/appearance.h -Copyright: 2012, Arnaud Bienner -License: GPL-3+ - Files: src/covermanager/discogscoverprovider.cpp src/covermanager/discogscoverprovider.h Copyright: 2012, Martin Björklund diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7695ca5d..0a4b011d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,6 @@ endif() set(SOURCES core/mainwindow.cpp core/application.cpp - core/appearance.cpp core/player.cpp core/commandlineoptions.cpp core/database.cpp @@ -278,7 +277,6 @@ set(SOURCES set(HEADERS core/mainwindow.h core/application.h - core/appearance.h core/player.h core/database.h core/deletefiles.h diff --git a/src/core/appearance.cpp b/src/core/appearance.cpp deleted file mode 100644 index 4327e62a..00000000 --- a/src/core/appearance.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Strawberry Music Player - * This file was part of Clementine. - * Copyright 2012, Arnaud Bienner - * - * 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 . - * - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "appearance.h" -#include "settings/appearancesettingspage.h" - -const QPalette Appearance::kDefaultPalette = QPalette(); - -Appearance::Appearance(QObject *parent) : QObject(parent) { - - QPalette p = QApplication::palette(); - - QSettings s; - s.beginGroup(AppearanceSettingsPage::kSettingsGroup); - background_color_ = s.value(AppearanceSettingsPage::kBackgroundColor, p.color(QPalette::WindowText)).value(); - foreground_color_ = s.value(AppearanceSettingsPage::kForegroundColor, p.color(QPalette::Window)).value(); - s.endGroup(); - -} - -void Appearance::LoadUserTheme() { - - QSettings s; - s.beginGroup(AppearanceSettingsPage::kSettingsGroup); - bool use_a_custom_color_set = s.value(AppearanceSettingsPage::kUseCustomColorSet).toBool(); - s.endGroup(); - - if (use_a_custom_color_set) { - ChangeForegroundColor(foreground_color_); - ChangeBackgroundColor(background_color_); - } - -} - -void Appearance::ResetToSystemDefaultTheme() { - QApplication::setPalette(kDefaultPalette); -} - -void Appearance::ChangeForegroundColor(const QColor &color) { - - // Get the application palette - QPalette p = QApplication::palette(); - - // Modify the palette - p.setColor(QPalette::WindowText, color); - p.setColor(QPalette::Text, color); - - // Make the modified palette the new application's palette - QApplication::setPalette(p); - foreground_color_ = color; - -} - -void Appearance::ChangeBackgroundColor(const QColor &color) { - - // Get the application palette - QPalette p = QApplication::palette(); - - // Modify the palette - p.setColor(QPalette::Window, color); - p.setColor(QPalette::Base, color); - - // Make the modified palette the new application's palette - QApplication::setPalette(p); - background_color_ = color; - -} diff --git a/src/core/appearance.h b/src/core/appearance.h deleted file mode 100644 index d0705f0d..00000000 --- a/src/core/appearance.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Strawberry Music Player - * This file was part of Clementine. - * Copyright 2012, Arnaud Bienner - * - * 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 . - * - */ - -#ifndef APPEARANCE_H -#define APPEARANCE_H - -#include "config.h" - -#include -#include -#include - -class Appearance : public QObject { - Q_OBJECT - - public: - explicit Appearance(QObject *parent = nullptr); - - static const QPalette kDefaultPalette; - - void LoadUserTheme(); - static void ResetToSystemDefaultTheme(); - void ChangeForegroundColor(const QColor &color); - void ChangeBackgroundColor(const QColor &color); - - private: - QColor foreground_color_; - QColor background_color_; -}; - -#endif // APPEARANCE_H diff --git a/src/core/application.cpp b/src/core/application.cpp index a6a6cc09..b2f4c809 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -38,7 +38,6 @@ #include "database.h" #include "taskmanager.h" #include "player.h" -#include "appearance.h" #include "engine/devicefinders.h" #ifndef Q_OS_WIN @@ -109,7 +108,6 @@ class ApplicationImpl { QTimer::singleShot(30s, db, &Database::DoBackup); return db; }), - appearance_([app]() { return new Appearance(app); }), task_manager_([app]() { return new TaskManager(app); }), player_([app]() { return new Player(app, app); }), device_finders_([app]() { return new DeviceFinders(app); }), @@ -183,7 +181,6 @@ class ApplicationImpl { Lazy tag_reader_client_; Lazy database_; - Lazy appearance_; Lazy task_manager_; Lazy player_; Lazy device_finders_; @@ -315,7 +312,6 @@ void Application::ReloadSettings() { emit SettingsChanged(); } void Application::OpenSettingsDialogAtPage(SettingsDialog::Page page) { emit SettingsDialogRequested(page); } TagReaderClient *Application::tag_reader_client() const { return p_->tag_reader_client_.get(); } -Appearance *Application::appearance() const { return p_->appearance_.get(); } Database *Application::database() const { return p_->database_.get(); } TaskManager *Application::task_manager() const { return p_->task_manager_.get(); } Player *Application::player() const { return p_->player_.get(); } diff --git a/src/core/application.h b/src/core/application.h index ffabfa2e..3667c8bc 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -41,7 +41,6 @@ class TagReaderClient; class Database; class DeviceFinders; class Player; -class Appearance; class SCollection; class CollectionBackend; class CollectionModel; @@ -73,7 +72,6 @@ class Application : public QObject { TagReaderClient *tag_reader_client() const; Database *database() const; - Appearance *appearance() const; TaskManager *task_manager() const; Player *player() const; DeviceFinders *device_finders() const; diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index d8bff5b1..5756c9ee 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -88,7 +88,6 @@ #include "application.h" #include "database.h" #include "player.h" -#include "appearance.h" #include "filesystemmusicstorage.h" #include "deletefiles.h" #ifdef Q_OS_MACOS @@ -874,11 +873,6 @@ MainWindow::MainWindow(Application *app, std::shared_ptr tray_ic QObject::connect(ui_->action_console, &QAction::triggered, this, &MainWindow::ShowConsole); PlayingWidgetPositionChanged(ui_->widget_playing->show_above_status_bar()); - // Load theme - // This is tricky: we need to save the default/system palette now, - // before loading user preferred theme (which will override it), to be able to restore it later - const_cast(Appearance::kDefaultPalette) = QApplication::palette(); - app_->appearance()->LoadUserTheme(); StyleSheetLoader *css_loader = new StyleSheetLoader(this); css_loader->SetStyleSheet(this, ":/style/strawberry.css"); diff --git a/src/settings/appearancesettingspage.cpp b/src/settings/appearancesettingspage.cpp index a506c876..11b23f16 100644 --- a/src/settings/appearancesettingspage.cpp +++ b/src/settings/appearancesettingspage.cpp @@ -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(); - current_foreground_color_ = original_foreground_color_; - original_background_color_ = s.value(kBackgroundColor, p.color(QPalette::Window)).value(); - 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(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()); diff --git a/src/settings/appearancesettingspage.h b/src/settings/appearancesettingspage.h index c6325ca5..fcd197b9 100644 --- a/src/settings/appearancesettingspage.h +++ b/src/settings/appearancesettingspage.h @@ -46,10 +46,6 @@ class AppearanceSettingsPage : public SettingsPage { static const char *kStyle; - static const char *kUseCustomColorSet; - static const char *kForegroundColor; - static const char *kBackgroundColor; - static const char *kBackgroundImageType; static const char *kBackgroundImageFilename; static const char *kBackgroundImagePosition; @@ -97,14 +93,10 @@ class AppearanceSettingsPage : public SettingsPage { void Load() override; void Save() override; - void Cancel() override; static QColor DefaultTabbarBgColor(); private slots: - void SelectForegroundColor(); - void SelectBackgroundColor(); - void UseCustomColorSetOptionChanged(bool); void SelectBackgroundImage(); void BlurLevelChanged(int); void OpacityLevelChanged(int); @@ -116,16 +108,9 @@ class AppearanceSettingsPage : public SettingsPage { private: // Set the widget's background to new_color static void UpdateColorSelectorColor(QWidget *color_selector, const QColor &new_color); - // Init (or refresh) the colorSelectors colors - void InitColorSelectorsColors(); Ui_AppearanceSettingsPage *ui_; - bool original_use_a_custom_color_set_; - QColor original_foreground_color_; - QColor original_background_color_; - QColor current_foreground_color_; - QColor current_background_color_; QColor current_tabbar_bg_color_; BackgroundImageType background_image_type_; QString background_image_filename_; diff --git a/src/settings/appearancesettingspage.ui b/src/settings/appearancesettingspage.ui index c3976462..ed4d35a0 100644 --- a/src/settings/appearancesettingspage.ui +++ b/src/settings/appearancesettingspage.ui @@ -7,7 +7,7 @@ 0 0 612 - 1166 + 1186 @@ -64,77 +64,6 @@ - - - - Colors - - - - - - &Use the system default color set - - - - - - - Use a custom color set - - - - - - - - - true - - - Select foreground color: - - - - - - - false - - - - - - - - - - - - - - true - - - Select background color: - - - - - - - false - - - - - - - - - - - @@ -669,10 +598,6 @@ - use_system_color_set - use_a_custom_color_set - select_foreground_color - select_background_color tabbar_system_color tabbar_custom_color tabbar_gradient @@ -699,38 +624,5 @@ spinbox_icon_size_configure_buttons - - - use_a_custom_color_set - toggled(bool) - select_background_color - setEnabled(bool) - - - 301 - 72 - - - 440 - 139 - - - - - use_a_custom_color_set - toggled(bool) - select_foreground_color - setEnabled(bool) - - - 301 - 72 - - - 440 - 104 - - - - + diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index 998ced4e..e4909cbc 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -122,7 +122,6 @@ SettingsDialog::SettingsDialog(Application *app, OSDBase *osd, QMainWindow *main engine_(app_->player()->engine()), model_(app_->collection_model()->directory_model()), manager_(nullptr), - appearance_(app_->appearance()), ui_(new Ui_SettingsDialog), loading_settings_(false) { diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h index aaf89f85..7837ef64 100644 --- a/src/settings/settingsdialog.h +++ b/src/settings/settingsdialog.h @@ -50,7 +50,6 @@ class QCloseEvent; class Application; class Player; -class Appearance; class CollectionDirectoryModel; class GlobalShortcutsManager; class SettingsPage; @@ -110,7 +109,6 @@ class SettingsDialog : public QDialog { EngineBase *engine() const { return engine_; } CollectionDirectoryModel *collection_directory_model() const { return model_; } GlobalShortcutsManager *global_shortcuts_manager() const { return manager_; } - Appearance *appearance() const { return appearance_; } void OpenAtPage(Page page); @@ -157,7 +155,6 @@ class SettingsDialog : public QDialog { EngineBase *engine_; CollectionDirectoryModel *model_; GlobalShortcutsManager *manager_; - Appearance *appearance_; Ui_SettingsDialog *ui_; bool loading_settings_;