summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qcombobox.cpp
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2010-03-29 14:22:52 (GMT)
committerJens Bache-Wiig <jbache@trolltech.com>2010-03-29 14:25:16 (GMT)
commitb3eac3f43b087ee7939a607cd8a6e5ed398f6716 (patch)
treebc2d3aafaa48bc783bedec9283370969d162c358 /src/gui/widgets/qcombobox.cpp
parentec0fe5bb327f2533dcbb35855ca0d2a7f9a85581 (diff)
downloadQt-b3eac3f43b087ee7939a607cd8a6e5ed398f6716.zip
Qt-b3eac3f43b087ee7939a607cd8a6e5ed398f6716.tar.gz
Qt-b3eac3f43b087ee7939a607cd8a6e5ed398f6716.tar.bz2
Fix QComboBox ignoring foreground role in some styles
Basically all styles using SH_Combobox_Popup would not previously respect the foreground role set. We need to set it for multiple color roles since styles sometimes interpret them differently. Reviewed-by: ogoffart Task-number: QTBUG-8796
Diffstat (limited to 'src/gui/widgets/qcombobox.cpp')
-rw-r--r--src/gui/widgets/qcombobox.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index c16f18a..b1a27f2 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -108,7 +108,15 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
const QModelIndex &index) const
{
QStyleOptionMenuItem menuOption;
- menuOption.palette = option.palette.resolve(QApplication::palette("QMenu"));
+
+ QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu"));
+ QVariant value = index.data(Qt::ForegroundRole);
+ if (qVariantCanConvert<QBrush>(value)) {
+ resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value));
+ resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value));
+ resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
+ }
+ menuOption.palette = resolvedpalette;
menuOption.state = QStyle::State_None;
if (mCombo->window()->isActiveWindow())
menuOption.state = QStyle::State_Active;