From 232399ea284e13a65a131febfba413d1bc1549bd Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 24 Aug 2024 22:07:46 +0200 Subject: [PATCH] DynamicPlaylistControls: Make background follow system colors Fixes #1483 --- data/data.qrc | 1 + data/style/dynamicplaylistcontrols.css | 13 +++++++ src/playlist/dynamicplaylistcontrols.cpp | 49 +++++++++++++++++------- src/playlist/dynamicplaylistcontrols.h | 36 +++++++++-------- src/playlist/dynamicplaylistcontrols.ui | 19 +-------- 5 files changed, 71 insertions(+), 47 deletions(-) create mode 100644 data/style/dynamicplaylistcontrols.css diff --git a/data/data.qrc b/data/data.qrc index 1ea198804..a6e491775 100644 --- a/data/data.qrc +++ b/data/data.qrc @@ -45,5 +45,6 @@ mood/sample.mood text/ghosts.txt pictures/sidebar-background.png + style/dynamicplaylistcontrols.css diff --git a/data/style/dynamicplaylistcontrols.css b/data/style/dynamicplaylistcontrols.css new file mode 100644 index 000000000..7da768e2d --- /dev/null +++ b/data/style/dynamicplaylistcontrols.css @@ -0,0 +1,13 @@ +#container { + background: %background; + border-radius: 10px; + border: 1px solid rgba(200, 200, 200, 75%); +} + +#label1 { + font-weight: bold; +} + +#label2 { + font-size: 7.5pt; +} diff --git a/src/playlist/dynamicplaylistcontrols.cpp b/src/playlist/dynamicplaylistcontrols.cpp index 0ab0945e7..f8eae4ede 100644 --- a/src/playlist/dynamicplaylistcontrols.cpp +++ b/src/playlist/dynamicplaylistcontrols.cpp @@ -1,19 +1,30 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * 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 . + * + */ - Clementine 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. +#include +#include +#include +#include - Clementine 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 Clementine. If not, see . -*/ +#include "core/logging.h" #include "dynamicplaylistcontrols.h" #include "ui_dynamicplaylistcontrols.h" @@ -28,6 +39,16 @@ DynamicPlaylistControls::DynamicPlaylistControls(QWidget *parent) QObject::connect(ui_->repopulate, &QPushButton::clicked, this, &DynamicPlaylistControls::Repopulate); QObject::connect(ui_->off, &QPushButton::clicked, this, &DynamicPlaylistControls::TurnOff); + QFile stylesheet_file(QStringLiteral(":/style/dynamicplaylistcontrols.css")); + if (stylesheet_file.open(QIODevice::ReadOnly)) { + QString stylesheet = QString::fromLatin1(stylesheet_file.readAll()); + stylesheet_file.close(); + QColor color = palette().color(QPalette::Light); + color.setAlpha(50); + stylesheet.replace(QLatin1String("%background"), QStringLiteral("rgba(%1, %2, %3, %4%5)").arg(QString::number(color.red()), QString::number(color.green()), QString::number(color.blue()), QString::number(color.alpha())).arg(QLatin1Char('%'))); + setStyleSheet(stylesheet); + } + } DynamicPlaylistControls::~DynamicPlaylistControls() { delete ui_; } diff --git a/src/playlist/dynamicplaylistcontrols.h b/src/playlist/dynamicplaylistcontrols.h index 449e14518..c67d0e68f 100644 --- a/src/playlist/dynamicplaylistcontrols.h +++ b/src/playlist/dynamicplaylistcontrols.h @@ -1,19 +1,23 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome - - Clementine 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. - - Clementine 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 Clementine. If not, see . -*/ +/* + * Strawberry Music Player + * This file was part of Clementine. + * Copyright 2010, David Sansome + * Copyright 2018-2024, Jonas Kvinge + * + * 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 DYNAMICPLAYLISTCONTROLS_H #define DYNAMICPLAYLISTCONTROLS_H diff --git a/src/playlist/dynamicplaylistcontrols.ui b/src/playlist/dynamicplaylistcontrols.ui index bd6585c63..f6c34e18a 100644 --- a/src/playlist/dynamicplaylistcontrols.ui +++ b/src/playlist/dynamicplaylistcontrols.ui @@ -10,21 +10,6 @@ 54 - - #container { - background: rgba(200, 200, 200, 50%); - border-radius: 10px; - border: 1px solid rgba(200, 200, 200, 75%); -} - -#label1 { - font-weight: bold; -} - -#label2 { - font-size: 7.5pt; -} - 0 @@ -41,10 +26,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised