From 0da5bf7994cde2ab166fd0ced4cd4d22f6f674bf Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 11 Feb 2014 22:53:06 +0100 Subject: [PATCH] [ListItems] Apply workaround only for Fusion style It actually breaks other styles ... Fixes 2105b48ca45cca9c079ca5e7b5433662e97d6a41 --- src/lib/other/iconchooser.cpp | 10 ++++++++-- src/lib/tools/listitemdelegate.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/other/iconchooser.cpp b/src/lib/other/iconchooser.cpp index 40fc8a758..38c6f78ab 100644 --- a/src/lib/other/iconchooser.cpp +++ b/src/lib/other/iconchooser.cpp @@ -17,6 +17,8 @@ * ============================================================ */ #include "iconchooser.h" #include "ui_iconchooser.h" +#include "mainapplication.h" +#include "proxystyle.h" #include "qztools.h" #include @@ -115,8 +117,12 @@ void IconChooserDelegate::paint(QPainter* painter, const QStyleOptionViewItem &o const QStyle* style = w ? w->style() : QApplication::style(); // Draw background - // Use PanelItemViewRow, because of Qt5's Fusion style incorrectly renders PanelItemViewItem - style->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, w); + if (mApp->proxyStyle()->name() == QLatin1String("fusion")) { + style->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, w); + } + else { + style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, w); + } // Draw icon QIcon icon = index.data(Qt::DecorationRole).value(); diff --git a/src/lib/tools/listitemdelegate.cpp b/src/lib/tools/listitemdelegate.cpp index 6cf67ccb0..3893af3a4 100644 --- a/src/lib/tools/listitemdelegate.cpp +++ b/src/lib/tools/listitemdelegate.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . * ============================================================ */ #include "listitemdelegate.h" +#include "mainapplication.h" +#include "proxystyle.h" #include #include @@ -65,7 +67,12 @@ void ListItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem &opti // Draw background // Use PanelItemViewRow, because of Qt5's Fusion style incorrectly renders PanelItemViewItem - style->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter); + if (mApp->proxyStyle()->name() == QLatin1String("fusion")) { + style->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, w); + } + else { + style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, w); + } // Draw icon QRect iconRect(opt.rect.left() + (opt.rect.width() - m_iconSize) / 2, topPosition, m_iconSize, m_iconSize);