Remove settings for changing palette colors

Fixes #1087
This commit is contained in:
Jonas Kvinge 2022-12-31 18:20:28 +01:00
parent f632e95600
commit a2b5c3ea08
12 changed files with 2 additions and 389 deletions

5
debian/copyright vendored
View File

@ -130,11 +130,6 @@ Copyright: 2012, David Sansome <me@davidsansome.com>
2018-2021, Jonas Kvinge <jonas@jkvinge.net>
License: GPL-3+
Files: src/core/appearance.cpp
src/core/appearance.h
Copyright: 2012, Arnaud Bienner <arnaud.bienner@gmail.com>
License: GPL-3+
Files: src/covermanager/discogscoverprovider.cpp
src/covermanager/discogscoverprovider.h
Copyright: 2012, Martin Björklund <mbj4668@gmail.com>

View File

@ -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

View File

@ -1,92 +0,0 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2012, Arnaud Bienner <arnaud.bienner@gmail.com>
*
* 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 "config.h"
#include <QApplication>
#include <QObject>
#include <QPalette>
#include <QColor>
#include <QSettings>
#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<QColor>();
foreground_color_ = s.value(AppearanceSettingsPage::kForegroundColor, p.color(QPalette::Window)).value<QColor>();
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;
}

View File

@ -1,48 +0,0 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2012, Arnaud Bienner <arnaud.bienner@gmail.com>
*
* 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 APPEARANCE_H
#define APPEARANCE_H
#include "config.h"
#include <QObject>
#include <QColor>
#include <QPalette>
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

View File

@ -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<TagReaderClient> tag_reader_client_;
Lazy<Database> database_;
Lazy<Appearance> appearance_;
Lazy<TaskManager> task_manager_;
Lazy<Player> player_;
Lazy<DeviceFinders> 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(); }

View File

@ -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;

View File

@ -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<SystemTrayIcon> 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<QPalette&>(Appearance::kDefaultPalette) = QApplication::palette();
app_->appearance()->LoadUserTheme();
StyleSheetLoader *css_loader = new StyleSheetLoader(this);
css_loader->SetStyleSheet(this, ":/style/strawberry.css");

View File

@ -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());

View File

@ -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_;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>612</width>
<height>1166</height>
<height>1186</height>
</rect>
</property>
<property name="windowTitle">
@ -64,77 +64,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_colors">
<property name="title">
<string>Colors</string>
</property>
<layout class="QVBoxLayout" name="layout_colors">
<item>
<widget class="QRadioButton" name="use_system_color_set">
<property name="text">
<string>&amp;Use the system default color set</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="use_a_custom_color_set">
<property name="text">
<string>Use a custom color set</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_foreground_color">
<item>
<widget class="QLabel" name="select_foreground_color_label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Select foreground color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="select_foreground_color">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_background_color">
<item>
<widget class="QLabel" name="select_background_color_label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Select background color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="select_background_color">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_tabbar_colors">
<property name="title">
@ -669,10 +598,6 @@
</layout>
</widget>
<tabstops>
<tabstop>use_system_color_set</tabstop>
<tabstop>use_a_custom_color_set</tabstop>
<tabstop>select_foreground_color</tabstop>
<tabstop>select_background_color</tabstop>
<tabstop>tabbar_system_color</tabstop>
<tabstop>tabbar_custom_color</tabstop>
<tabstop>tabbar_gradient</tabstop>
@ -699,38 +624,5 @@
<tabstop>spinbox_icon_size_configure_buttons</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>use_a_custom_color_set</sender>
<signal>toggled(bool)</signal>
<receiver>select_background_color</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>440</x>
<y>139</y>
</hint>
</hints>
</connection>
<connection>
<sender>use_a_custom_color_set</sender>
<signal>toggled(bool)</signal>
<receiver>select_foreground_color</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>440</x>
<y>104</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

View File

@ -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) {

View File

@ -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_;