diff --git a/src/libs/ui/docsetlistitemdelegate.cpp b/src/libs/ui/docsetlistitemdelegate.cpp index 9c80f615..b1062725 100644 --- a/src/libs/ui/docsetlistitemdelegate.cpp +++ b/src/libs/ui/docsetlistitemdelegate.cpp @@ -31,14 +31,14 @@ using namespace Zeal; using namespace Zeal::WidgetUi; DocsetListItemDelegate::DocsetListItemDelegate(QObject *parent) : - QItemDelegate(parent) + QStyledItemDelegate(parent) { } void DocsetListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const + const QModelIndex &index) const { - QItemDelegate::paint(painter, option, index); + QStyledItemDelegate::paint(painter, option, index); if (!index.model()->data(index, Registry::ItemDataRole::UpdateAvailableRole).toBool()) return; @@ -55,8 +55,24 @@ void DocsetListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem painter->save(); - if (option.state & QStyle::State_Selected) - painter->setPen(QPen(option.palette.highlightedText(), 1)); + QPalette palette = option.palette; + +#ifdef Q_OS_WIN32 + // QWindowsVistaStyle overrides highlight colour. + if (option.widget->style()->objectName() == QLatin1String("windowsvista")) { + palette.setColor(QPalette::All, QPalette::HighlightedText, + palette.color(QPalette::Active, QPalette::Text)); + } +#endif + + const QPalette::ColorGroup cg = (option.state & QStyle::State_Active) + ? QPalette::Normal : QPalette::Inactive; + + if (option.state & QStyle::State_Selected) { + painter->setPen(palette.color(cg, QPalette::HighlightedText)); + } else { + painter->setPen(palette.color(cg, QPalette::Text)); + } painter->setFont(font); painter->drawText(textRect, text); diff --git a/src/libs/ui/docsetlistitemdelegate.h b/src/libs/ui/docsetlistitemdelegate.h index 9e09003f..7e054b40 100644 --- a/src/libs/ui/docsetlistitemdelegate.h +++ b/src/libs/ui/docsetlistitemdelegate.h @@ -24,12 +24,12 @@ #ifndef ZEAL_WIDGETUI_DOCSETLISTITEMDELEGATE_H #define ZEAL_WIDGETUI_DOCSETLISTITEMDELEGATE_H -#include +#include namespace Zeal { namespace WidgetUi { -class DocsetListItemDelegate : public QItemDelegate +class DocsetListItemDelegate : public QStyledItemDelegate { Q_OBJECT public: diff --git a/src/libs/ui/progressitemdelegate.cpp b/src/libs/ui/progressitemdelegate.cpp index e69acb52..331f3c4b 100644 --- a/src/libs/ui/progressitemdelegate.cpp +++ b/src/libs/ui/progressitemdelegate.cpp @@ -29,7 +29,7 @@ using namespace Zeal::WidgetUi; ProgressItemDelegate::ProgressItemDelegate(QObject *parent) : - QItemDelegate(parent) + QStyledItemDelegate(parent) { } @@ -37,7 +37,7 @@ void ProgressItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & const QModelIndex &index) const { if (!index.model()->data(index, ShowProgressRole).toBool()) { - QItemDelegate::paint(painter, option, index); + QStyledItemDelegate::paint(painter, option, index); return; } @@ -45,7 +45,7 @@ void ProgressItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & const int value = index.model()->data(index, ValueRole).toInt(&ok); if (!ok) { - QItemDelegate::paint(painter, option, index); + QStyledItemDelegate::paint(painter, option, index); return; } @@ -71,5 +71,5 @@ void ProgressItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem & painter->restore(); - QItemDelegate::paint(painter, styleOption, index); + QStyledItemDelegate::paint(painter, styleOption, index); } diff --git a/src/libs/ui/progressitemdelegate.h b/src/libs/ui/progressitemdelegate.h index e77a7358..89594e31 100644 --- a/src/libs/ui/progressitemdelegate.h +++ b/src/libs/ui/progressitemdelegate.h @@ -24,12 +24,12 @@ #ifndef ZEAL_WIDGETUI_PROGRESSITEMDELEGATE_H #define ZEAL_WIDGETUI_PROGRESSITEMDELEGATE_H -#include +#include namespace Zeal { namespace WidgetUi { -class ProgressItemDelegate : public QItemDelegate +class ProgressItemDelegate : public QStyledItemDelegate { Q_OBJECT public: