use elements dimensions to resize the scrollbar

svn path=/trunk/KDE/kdelibs/; revision=893050
This commit is contained in:
Marco Martin 2008-12-05 21:04:33 +00:00
parent 2952fe3e5f
commit b47c32869f
3 changed files with 20 additions and 0 deletions

View File

@ -137,6 +137,22 @@ void Style::drawComplexControl(ComplexControl control,
painter->restore(); painter->restore();
} }
int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
{
switch (metric) {
case PM_ScrollBarExtent: {
const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
if (scrollOption && scrollOption->orientation == Qt::Vertical) {
return d->scrollbar->elementSize("arrow-down").width() + 2;
} else {
return d->scrollbar->elementSize("arrow-left").height() + 2;
}
}
default:
return QCommonStyle::pixelMetric(metric, option, widget);
}
}
} }
#include "style_p.moc" #include "style_p.moc"

View File

@ -41,6 +41,8 @@ protected:
const QStyleOptionComplex *option, const QStyleOptionComplex *option,
QPainter *painter, QPainter *painter,
const QWidget *widget) const; const QWidget *widget) const;
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
private: private:
StylePrivate *d; StylePrivate *d;
}; };

View File

@ -40,6 +40,8 @@ ScrollBar::ScrollBar(Qt::Orientation orientation, QGraphicsWidget *parent)
setWidget(scrollbar); setWidget(scrollbar);
d->style = new Plasma::Style(); d->style = new Plasma::Style();
scrollbar->setStyle(d->style); scrollbar->setStyle(d->style);
scrollbar->resize(scrollbar->sizeHint());
} }
ScrollBar::~ScrollBar() ScrollBar::~ScrollBar()