Add setting for configuring the color for the currently playing song

Fixes #676
This commit is contained in:
Jonas Kvinge 2021-04-01 02:17:30 +02:00
parent 45b9d0553f
commit 128223a28a
5 changed files with 112 additions and 3 deletions

View File

@ -455,7 +455,12 @@ QList<QPixmap> PlaylistView::LoadBarPixmap(const QString &filename) {
QPainter p(&image);
p.setCompositionMode(QPainter::CompositionMode_SourceAtop);
p.setOpacity(0.7);
p.fillRect(image.rect(), QApplication::palette().color(QPalette::Highlight));
if (playlist_playing_song_color_.isValid()) {
p.fillRect(image.rect(), playlist_playing_song_color_);
}
else {
p.fillRect(image.rect(), QApplication::palette().color(QPalette::Highlight));
}
p.end();
// Animation steps
@ -509,8 +514,9 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option
middle.setRight(middle.right() - currenttrack_bar_right_[0].width());
// Selection
if (selectionModel()->isSelected(idx))
if (selectionModel()->isSelected(idx)) {
painter->fillRect(opt.rect, opt.palette.color(QPalette::Highlight));
}
// Draw the bar
painter->drawPixmap(opt.rect.topLeft(), currenttrack_bar_left_[step]);
@ -1162,6 +1168,11 @@ void PlaylistView::ReloadSettings() {
bool background_image_keep_aspect_ratio = s.value(AppearanceSettingsPage::kBackgroundImageKeepAspectRatio, true).toBool();
int blur_radius = s.value(AppearanceSettingsPage::kBlurRadius, AppearanceSettingsPage::kDefaultBlurRadius).toInt();
int opacity_level = s.value(AppearanceSettingsPage::kOpacityLevel, AppearanceSettingsPage::kDefaultOpacityLevel).toInt();
QColor playlist_playing_song_color = s.value(AppearanceSettingsPage::kPlaylistPlayingSongColor).value<QColor>();
if (playlist_playing_song_color != playlist_playing_song_color_) {
row_height_ = -1;
}
playlist_playing_song_color_ = playlist_playing_song_color;
s.endGroup();
if (currently_glowing_ && glow_enabled_ && isVisible()) StartGlowing();

View File

@ -38,6 +38,7 @@
#include <QString>
#include <QImage>
#include <QPixmap>
#include <QColor>
#include <QRect>
#include <QRegion>
#include <QStyleOption>
@ -297,6 +298,8 @@ class PlaylistView : public QTreeView {
DynamicPlaylistControls *dynamic_controls_;
RatingItemDelegate *rating_delegate_;
QColor playlist_playing_song_color_;
};
#endif // PLAYLISTVIEW_H

View File

@ -84,6 +84,8 @@ const char *AppearanceSettingsPage::kIconSizePlaylistButtons = "icon_size_playli
const char *AppearanceSettingsPage::kIconSizeLeftPanelButtons = "icon_size_left_panel_buttons";
const char *AppearanceSettingsPage::kIconSizeConfigureButtons = "icon_size_configure_buttons";
const char *AppearanceSettingsPage::kPlaylistPlayingSongColor = "playlist_playing_song_color";
AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog)
: SettingsPage(dialog),
ui_(new Ui_AppearanceSettingsPage),
@ -130,6 +132,9 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog)
QObject::connect(ui_->select_tabbar_color, &QPushButton::pressed, this, &AppearanceSettingsPage::TabBarSelectBGColor);
QObject::connect(ui_->tabbar_system_color, &QRadioButton::toggled, this, &AppearanceSettingsPage::TabBarSystemColor);
QObject::connect(ui_->select_playlist_playing_song_color, &QPushButton::pressed, this, &AppearanceSettingsPage::PlaylistPlayingSongSelectColor);
QObject::connect(ui_->playlist_playing_song_color_system, &QRadioButton::toggled, this, &AppearanceSettingsPage::PlaylistPlayingSongColorSystem);
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
ui_->checkbox_system_icons->hide();
#endif
@ -220,6 +225,17 @@ void AppearanceSettingsPage::Load() {
ui_->spinbox_icon_size_left_panel_buttons->setValue(s.value(kIconSizeLeftPanelButtons, 22).toInt());
ui_->spinbox_icon_size_configure_buttons->setValue(s.value(kIconSizeConfigureButtons, 16).toInt());
current_playlist_playing_song_color_ = s.value(kPlaylistPlayingSongColor).value<QColor>();
if (current_playlist_playing_song_color_.isValid()) {
ui_->playlist_playing_song_color_custom->setChecked(true);
}
else {
ui_->playlist_playing_song_color_system->setChecked(true);
current_playlist_playing_song_color_ = StyleHelper::highlightColor();
}
UpdateColorSelectorColor(ui_->select_playlist_playing_song_color, current_playlist_playing_song_color_);
PlaylistPlayingSongColorSystem(ui_->playlist_playing_song_color_system->isChecked());
s.endGroup();
Init(ui_->layout_appearancesettingspage->parentWidget());
@ -297,6 +313,13 @@ void AppearanceSettingsPage::Save() {
s.setValue(kIconSizeLeftPanelButtons, ui_->spinbox_icon_size_left_panel_buttons->value());
s.setValue(kIconSizeConfigureButtons, ui_->spinbox_icon_size_configure_buttons->value());
if (ui_->playlist_playing_song_color_system->isChecked()) {
s.setValue(kPlaylistPlayingSongColor, QColor());
}
else {
s.setValue(kPlaylistPlayingSongColor, current_playlist_playing_song_color_);
}
s.endGroup();
}
@ -414,3 +437,29 @@ void AppearanceSettingsPage::TabBarSelectBGColor() {
set_changed();
}
void AppearanceSettingsPage::PlaylistPlayingSongColorSystem(bool checked) {
if (checked) {
current_playlist_playing_song_color_ = StyleHelper::highlightColor();
UpdateColorSelectorColor(ui_->select_playlist_playing_song_color, current_playlist_playing_song_color_);
}
ui_->layout_playlist_playing_song_color_custom->setEnabled(!checked);
ui_->select_playlist_playing_song_color->setEnabled(!checked);
set_changed();
}
void AppearanceSettingsPage::PlaylistPlayingSongSelectColor() {
if (ui_->playlist_playing_song_color_system->isChecked()) return;
QColor color_selected = QColorDialog::getColor(current_playlist_playing_song_color_);
if (!color_selected.isValid()) return;
current_playlist_playing_song_color_ = color_selected;
UpdateColorSelectorColor(ui_->select_playlist_playing_song_color, current_playlist_playing_song_color_);
set_changed();
}

View File

@ -77,6 +77,8 @@ class AppearanceSettingsPage : public SettingsPage {
static const char *kIconSizeLeftPanelButtons;
static const char *kIconSizeConfigureButtons;
static const char *kPlaylistPlayingSongColor;
enum BackgroundImageType {
BackgroundImageType_Default,
BackgroundImageType_None,
@ -106,6 +108,8 @@ class AppearanceSettingsPage : public SettingsPage {
void OpacityLevelChanged(int);
void TabBarSystemColor(bool checked);
void TabBarSelectBGColor();
void PlaylistPlayingSongColorSystem(bool checked);
void PlaylistPlayingSongSelectColor();
private:
// Set the widget's background to new_color
@ -123,6 +127,7 @@ class AppearanceSettingsPage : public SettingsPage {
QColor current_tabbar_bg_color_;
BackgroundImageType background_image_type_;
QString background_image_filename_;
QColor current_playlist_playing_song_color_;
};

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>612</width>
<height>1071</height>
<height>1166</height>
</rect>
</property>
<property name="windowTitle">
@ -612,6 +612,47 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="playlist_playing_song_color">
<property name="title">
<string>Playlist playing song color</string>
</property>
<layout class="QVBoxLayout" name="layout_playlist_playing_song_color">
<item>
<widget class="QRadioButton" name="playlist_playing_song_color_system">
<property name="text">
<string>System highlight color</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="playlist_playing_song_color_custom">
<property name="text">
<string>Custom color</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_playlist_playing_song_color_custom">
<item>
<widget class="QLabel" name="label_select_playlist_playing_song_color">
<property name="text">
<string>Select playlist playing song color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="select_playlist_playing_song_color">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="spacer_bottom">
<property name="orientation">