From 52922f89f1dfed2757da3b727c5a458b38501904 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 31 Jul 2010 06:55:26 +0000 Subject: [PATCH] (trunk qt) fix icon spacing issue in Oxygen theme --- qt/filterbar.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/qt/filterbar.cc b/qt/filterbar.cc index 081b538f5..b0a61e289 100644 --- a/qt/filterbar.cc +++ b/qt/filterbar.cc @@ -10,8 +10,6 @@ * $Id$ */ -#include - #include #include @@ -38,6 +36,14 @@ enum TrackerRole }; +namespace +{ + int getHSpacing( QWidget * w ) + { + return qMax( 4, w->style()->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, w ) ); + } +} + FilterBarComboBoxDelegate :: FilterBarComboBoxDelegate( QObject * parent, QComboBox * combo ): QItemDelegate( parent ), myCombo( combo ) @@ -80,7 +86,7 @@ FilterBarComboBoxDelegate :: paint( QPainter * painter, disabledOption.state &= ~( QStyle::State_Enabled | QStyle::State_Selected ); QRect boundingBox = option.rect; - const int hmargin = myCombo->style()->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, myCombo ); + const int hmargin = getHSpacing( myCombo ); boundingBox.setLeft( boundingBox.left() + hmargin ); boundingBox.setRight( boundingBox.right() - hmargin ); @@ -121,8 +127,7 @@ FilterBarComboBoxDelegate :: sizeHint( const QStyleOptionViewItem & option, else { QStyle * s = myCombo->style( ); - const int hmargin = s->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, myCombo ); - + const int hmargin = getHSpacing( myCombo ); QSize size = QItemDelegate::sizeHint( option, index ); size.setHeight( qMax( size.height(), myCombo->iconSize().height() + 6 ) ); @@ -161,7 +166,7 @@ FilterBarComboBox :: paintEvent( QPaintEvent * e ) { QStyle * s = style(); QRect rect = s->subControlRect( QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxEditField, this ); - const int hmargin = s->pixelMetric( QStyle::PM_LayoutHorizontalSpacing, 0, this ); + const int hmargin = getHSpacing( this ); rect.setRight( rect.right() - hmargin ); // draw the icon