class ProxyStyle : public QStyle
{
private:
QStyle *m_style;
protected:
const QStyle *style() const
{
return m_style;
}
virtual void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const
{
m_style->drawComplexControl(control, option, painter, widget);
}
virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const
{
m_style->drawControl(element, option, painter, widget);
}
virtual void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const
{
m_style->drawPrimitive(element, option, painter, widget);
}
virtual QPixmap generatedIconPixmap (QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const
{
return m_style->generatedIconPixmap(iconMode, pixmap, option);
}
virtual SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget = 0) const
{
return m_style->hitTestComplexControl(control, option, position, widget);
}
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget * widget = 0) const
{
return m_style->pixelMetric(metric, option, widget);
}
virtual QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
{
return m_style->sizeFromContents(type, option, contentsSize, widget);
}
virtual int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
{
return m_style->styleHint(hint, option, widget, returnData);
}
virtual QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget = 0) const
{
return m_style->subControlRect(control, option, subControl, widget);
}
virtual QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget = 0) const
{
return m_style->subElementRect(element, option, widget);
}
virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0, const QWidget *widget = 0) const
{
return m_style->standardPixmap(standardPixmap, option, widget);
}
public:
ProxyStyle(QWidget *widget) : QStyle()
{
m_style = QStyleFactory::create(widget->style()->objectName());
}
};
class NoFocusStyle : public ProxyStyle {
protected:
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const
{
if (element != QStyle::PE_FrameFocusRect)
style()->drawPrimitive(element, option, painter, widget);
}
public:
NoFocusStyle(QWidget *widget) : ProxyStyle(widget)
{
}
};