Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
Custom playqueue background is not workig with Qt 5.12 onwards, so
Browse files Browse the repository at this point in the history
disabled for now.

Issue #1554
  • Loading branch information
CDrummond authored and Craig Drummond committed Dec 3, 2019
1 parent a56f5ea commit 8b73408
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
40. Categorized view is reported to crash (#1530), so disable by default. Pass
-DENABLE_CATEGORIZED_VIEW=ON to cmake to re-enable.
41. Add 'aac' and 'libfdk_aac' as supported encoders.
42. Custom playqueue background is not workig with Qt 5.12 onwards, so
disabled for now.

2.3.3
-----
Expand Down
2 changes: 2 additions & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@

#define CANTATA_ICON_THEME "@CANTATA_ICON_THEME@"

#define ENABLE_VIEW_BACKGROUND (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))

#endif
16 changes: 16 additions & 0 deletions gui/interfacesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ InterfaceSettings::InterfaceSettings(QWidget *p)
sbPosition->addItem(tr("Bottom"), FancyTabWidget::Bot);
connect(sbAutoHide, SIGNAL(toggled(bool)), SLOT(sbAutoHideChanged()));
views->setItemDelegate(new BasicItemDelegate(views));
#if ENABLE_VIEW_BACKGROUND
playQueueBackground_none->setProperty(constValueProperty, PlayQueueView::BI_None);
playQueueBackground_cover->setProperty(constValueProperty, PlayQueueView::BI_Cover);
playQueueBackground_custom->setProperty(constValueProperty, PlayQueueView::BI_Custom);
Expand All @@ -185,6 +186,7 @@ InterfaceSettings::InterfaceSettings(QWidget *p)
connect(playQueueBackground_none, SIGNAL(toggled(bool)), SLOT(enablePlayQueueBackgroundOptions()));
connect(playQueueBackground_cover, SIGNAL(toggled(bool)), SLOT(enablePlayQueueBackgroundOptions()));
connect(playQueueBackground_custom, SIGNAL(toggled(bool)), SLOT(enablePlayQueueBackgroundOptions()));
#endif
connect(storeCoversInMpdDir, SIGNAL(toggled(bool)), this, SLOT(storeCoversInMpdDirToggled()));
if (!enableNotifications) {
REMOVE(systemTrayPopup)
Expand Down Expand Up @@ -248,13 +250,15 @@ void InterfaceSettings::load()
playQueueStartClosed->setChecked(Settings::self()->playQueueStartClosed());
playQueueScroll->setChecked(Settings::self()->playQueueScroll());

#if ENABLE_VIEW_BACKGROUND
int pqBgnd=Settings::self()->playQueueBackground();
playQueueBackground_none->setChecked(pqBgnd==playQueueBackground_none->property(constValueProperty).toInt());
playQueueBackground_cover->setChecked(pqBgnd==playQueueBackground_cover->property(constValueProperty).toInt());
playQueueBackground_custom->setChecked(pqBgnd==playQueueBackground_custom->property(constValueProperty).toInt());
playQueueBackgroundOpacity->setValue(Settings::self()->playQueueBackgroundOpacity());
playQueueBackgroundBlur->setValue(Settings::self()->playQueueBackgroundBlur());
playQueueBackgroundFile->setText(Utils::convertPathForDisplay(Settings::self()->playQueueBackgroundFile(), false));
#endif

playQueueConfirmClear->setChecked(Settings::self()->playQueueConfirmClear());
playQueueSearch->setChecked(Settings::self()->playQueueSearch());
Expand Down Expand Up @@ -301,12 +305,16 @@ void InterfaceSettings::load()
sbAutoHideChanged();
responsiveSidebar->setChecked(Settings::self()->responsiveSidebar());
viewItemChanged(views->item(0));
#if ENABLE_VIEW_BACKGROUND
setPlayQueueBackgroundOpacityLabel();
setPlayQueueBackgroundBlurLabel();
enablePlayQueueBackgroundOptions();
if (enableMpris) {
enableMpris->setChecked(Settings::self()->mpris());
}
#else
playQueueBackgroundOptions->setVisible(false);
#endif
}

static QSet<QString> toSet(const QString &str)
Expand Down Expand Up @@ -334,6 +342,7 @@ void InterfaceSettings::save()
Settings::self()->savePlayQueueStartClosed(playQueueStartClosed->isChecked());
Settings::self()->savePlayQueueScroll(playQueueScroll->isChecked());

#if ENABLE_VIEW_BACKGROUND
if (playQueueBackground_none->isChecked()) {
Settings::self()->savePlayQueueBackground(playQueueBackground_none->property(constValueProperty).toInt());
} else if (playQueueBackground_cover->isChecked()) {
Expand All @@ -344,6 +353,7 @@ void InterfaceSettings::save()
Settings::self()->savePlayQueueBackgroundOpacity(playQueueBackgroundOpacity->value());
Settings::self()->savePlayQueueBackgroundBlur(playQueueBackgroundBlur->value());
Settings::self()->savePlayQueueBackgroundFile(Utils::convertPathFromDisplay(playQueueBackgroundFile->text(), false));
#endif

Settings::self()->savePlayQueueConfirmClear(playQueueConfirmClear->isChecked());
Settings::self()->savePlayQueueSearch(playQueueSearch->isChecked());
Expand Down Expand Up @@ -562,20 +572,26 @@ void InterfaceSettings::sbAutoHideChanged()

void InterfaceSettings::setPlayQueueBackgroundOpacityLabel()
{
#if ENABLE_VIEW_BACKGROUND
playQueueBackgroundOpacityLabel->setText(tr("%1%", "value%").arg(playQueueBackgroundOpacity->value()));
#endif
}

void InterfaceSettings::setPlayQueueBackgroundBlurLabel()
{
#if ENABLE_VIEW_BACKGROUND
playQueueBackgroundBlurLabel->setText(tr("%1 px", "pixels").arg(playQueueBackgroundBlur->value()));
#endif
}

void InterfaceSettings::enablePlayQueueBackgroundOptions()
{
#if ENABLE_VIEW_BACKGROUND
playQueueBackgroundOpacity->setEnabled(!playQueueBackground_none->isChecked());
playQueueBackgroundOpacityLabel->setEnabled(playQueueBackgroundOpacity->isEnabled());
playQueueBackgroundBlur->setEnabled(playQueueBackgroundOpacity->isEnabled());
playQueueBackgroundBlurLabel->setEnabled(playQueueBackgroundOpacity->isEnabled());
#endif
}

void InterfaceSettings::systemTrayCheckBoxToggled()
Expand Down
2 changes: 1 addition & 1 deletion gui/interfacesettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
</spacer>
</item>
<item row="7" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="playQueueBackgroundOptions">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
Expand Down
14 changes: 11 additions & 3 deletions widgets/playqueueview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ PlayQueueView::PlayQueueView(QWidget *parent)
setMode(ItemView::Mode_GroupedTree);
animator.setPropertyName("fade");
animator.setTargetObject(this);
#if ENABLE_VIEW_BACKGROUND
connect(CurrentCover::self(), SIGNAL(coverImage(QImage)), this, SLOT(setImage(QImage)));
#endif
}

PlayQueueView::~PlayQueueView()
Expand All @@ -122,17 +124,18 @@ PlayQueueView::~PlayQueueView()

void PlayQueueView::readConfig()
{
setAutoExpand(Settings::self()->playQueueAutoExpand());
setStartClosed(Settings::self()->playQueueStartClosed());
setMode((ItemView::Mode)Settings::self()->playQueueView());
#if ENABLE_VIEW_BACKGROUND
int origOpacity=backgroundOpacity;
int origBlur=backgroundBlur;
QString origCustomBackgroundFile=customBackgroundFile;
BackgroundImage origType=backgroundImageType;
setAutoExpand(Settings::self()->playQueueAutoExpand());
setStartClosed(Settings::self()->playQueueStartClosed());
backgroundImageType=(BackgroundImage)Settings::self()->playQueueBackground();
backgroundOpacity=Settings::self()->playQueueBackgroundOpacity();
backgroundBlur=Settings::self()->playQueueBackgroundBlur();
customBackgroundFile=Settings::self()->playQueueBackgroundFile();
setMode((ItemView::Mode)Settings::self()->playQueueView());
switch (backgroundImageType) {
case BI_None:
if (origType!=backgroundImageType) {
Expand Down Expand Up @@ -161,6 +164,7 @@ void PlayQueueView::readConfig()
}
break;
}
#endif
}

void PlayQueueView::saveConfig()
Expand Down Expand Up @@ -426,6 +430,7 @@ void PlayQueueView::updatePalette()

void PlayQueueView::setImage(const QImage &img)
{
#if ENABLE_VIEW_BACKGROUND
if (BI_None==backgroundImageType || (sender() && BI_Custom==backgroundImageType)) {
return;
}
Expand Down Expand Up @@ -460,6 +465,7 @@ void PlayQueueView::setImage(const QImage &img)
animator.setEndValue(1.0);
animator.start();
}
#endif
}

void PlayQueueView::streamFetchStatus(const QString &msg)
Expand All @@ -480,6 +486,7 @@ void PlayQueueView::searchActive(bool a)

void PlayQueueView::drawBackdrop(QWidget *widget, const QSize &size)
{
#if ENABLE_VIEW_BACKGROUND
if (BI_None==backgroundImageType) {
return;
}
Expand All @@ -504,6 +511,7 @@ void PlayQueueView::drawBackdrop(QWidget *widget, const QSize &size)
p.drawPixmap((size.width()-curentBackground.width())/2, (size.height()-curentBackground.height())/2, curentBackground);
}
}
#endif
}

#include "moc_playqueueview.cpp"
8 changes: 8 additions & 0 deletions widgets/treeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ QImage TreeView::setOpacity(const QImage &orig, double opacity)

QPixmap TreeView::createBgndPixmap(const QIcon &icon)
{
#if ENABLE_VIEW_BACKGROUND
if (icon.isNull()) {
return QPixmap();
}
Expand All @@ -68,6 +69,9 @@ QPixmap TreeView::createBgndPixmap(const QIcon &icon)
img=img.scaled(bgndSize, bgndSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
return QPixmap::fromImage(setOpacity(img, 0.075));
#else
return QPixmap();
#endif
}

static bool forceSingleClick=true;
Expand Down Expand Up @@ -314,6 +318,7 @@ void TreeView::setUseSimpleDelegate()

void TreeView::setBackgroundImage(const QIcon &icon)
{
#if ENABLE_VIEW_BACKGROUND
QPalette pal=parentWidget()->palette();
// if (!icon.isNull()) {
// pal.setColor(QPalette::Base, Qt::transparent);
Expand All @@ -323,16 +328,19 @@ void TreeView::setBackgroundImage(const QIcon &icon)
#endif
viewport()->setPalette(pal);
bgnd=createBgndPixmap(icon);
#endif
}

void TreeView::paintEvent(QPaintEvent *e)
{
#if ENABLE_VIEW_BACKGROUND
if (!bgnd.isNull()) {
QPainter p(viewport());
QSize sz=size();
p.fillRect(0, 0, sz.width(), sz.height(), QApplication::palette().color(QPalette::Base));
p.drawPixmap((sz.width()-bgnd.width())/2, (sz.height()-bgnd.height())/2, bgnd);
}
#endif
if (!info.isEmpty() && model() && 0==model()->rowCount()) {
QPainter p(viewport());
QColor col(palette().text().color());
Expand Down

0 comments on commit 8b73408

Please sign in to comment.