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

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");