mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-24 14:40:54 +01:00
Make playlist moodbar column respect moodbar enabled setting
This commit is contained in:
parent
819800d3a4
commit
9f5249e5b8
@ -51,6 +51,7 @@ MoodbarItemDelegate::MoodbarItemDelegate(Application *app, PlaylistView *view, Q
|
|||||||
: QItemDelegate(parent),
|
: QItemDelegate(parent),
|
||||||
app_(app),
|
app_(app),
|
||||||
view_(view),
|
view_(view),
|
||||||
|
enabled_(false),
|
||||||
style_(MoodbarRenderer::Style_Normal) {
|
style_(MoodbarRenderer::Style_Normal) {
|
||||||
|
|
||||||
QObject::connect(app_, &Application::SettingsChanged, this, &MoodbarItemDelegate::ReloadSettings);
|
QObject::connect(app_, &Application::SettingsChanged, this, &MoodbarItemDelegate::ReloadSettings);
|
||||||
@ -62,9 +63,14 @@ void MoodbarItemDelegate::ReloadSettings() {
|
|||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
|
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
|
||||||
|
enabled_ = s.value("enabled", false).toBool();
|
||||||
MoodbarRenderer::MoodbarStyle new_style = static_cast<MoodbarRenderer::MoodbarStyle>(s.value("style", MoodbarRenderer::Style_Normal).toInt());
|
MoodbarRenderer::MoodbarStyle new_style = static_cast<MoodbarRenderer::MoodbarStyle>(s.value("style", MoodbarRenderer::Style_Normal).toInt());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
if (!enabled_) {
|
||||||
|
data_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (new_style != style_) {
|
if (new_style != style_) {
|
||||||
style_ = new_style;
|
style_ = new_style;
|
||||||
ReloadAllColors();
|
ReloadAllColors();
|
||||||
@ -74,7 +80,11 @@ void MoodbarItemDelegate::ReloadSettings() {
|
|||||||
|
|
||||||
void MoodbarItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
void MoodbarItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const {
|
||||||
|
|
||||||
QPixmap pixmap = const_cast<MoodbarItemDelegate*>(this)->PixmapForIndex(idx, option.rect.size());
|
QPixmap pixmap;
|
||||||
|
|
||||||
|
if (enabled_) {
|
||||||
|
pixmap = const_cast<MoodbarItemDelegate*>(this)->PixmapForIndex(idx, option.rect.size());
|
||||||
|
}
|
||||||
|
|
||||||
drawBackground(painter, option, idx);
|
drawBackground(painter, option, idx);
|
||||||
|
|
||||||
|
@ -91,6 +91,7 @@ class MoodbarItemDelegate : public QItemDelegate {
|
|||||||
PlaylistView *view_;
|
PlaylistView *view_;
|
||||||
QCache<QUrl, Data> data_;
|
QCache<QUrl, Data> data_;
|
||||||
|
|
||||||
|
bool enabled_;
|
||||||
MoodbarRenderer::MoodbarStyle style_;
|
MoodbarRenderer::MoodbarStyle style_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user