Allow overriding standardIcon() in a proxy style

[ChangeLog][QtWidgets][Styles] Allow overriding standardIcon() in a proxy style

Change-Id: I3c7983a7e51a8b220a0ca8ead2b4d7b87a77d71b
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Alexander Volkov 2014-09-09 18:37:58 +04:00
parent 18b0aaab77
commit eb6507039f
5 changed files with 22 additions and 22 deletions

View File

@ -2918,7 +2918,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
QRect closeRect;
if (canClose) {
QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton,
QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton,
opt, widget).actualSize(QSize(iconSize, iconSize));
sz += QSize(buttonMargin, buttonMargin);
if (verticalTitleBar)
@ -2935,7 +2935,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
QRect floatRect;
if (canFloat) {
QSize sz = standardIcon(QStyle::SP_TitleBarNormalButton,
QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarNormalButton,
opt, widget).actualSize(QSize(iconSize, iconSize));
sz += QSize(buttonMargin, buttonMargin);
if (verticalTitleBar)
@ -3410,9 +3410,9 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|| qobject_cast<const QDockWidget *>(widget)
#endif
)
pm = standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_DockWidgetCloseButton, &tool, widget).pixmap(10, 10);
else
pm = standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(10, 10);
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@ -3431,7 +3431,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, widget);
down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken);
pm = standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(10, 10);
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@ -3449,7 +3449,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
&& !(tb->titleBarState & Qt::WindowMinimized)) {
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, widget);
down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken);
pm = standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(10, 10);
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@ -3471,7 +3471,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
if (drawNormalButton) {
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, widget);
down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken);
pm = standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(10, 10);
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@ -3489,7 +3489,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
&& !(tb->titleBarState & Qt::WindowMinimized)) {
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, widget);
down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken));
pm = standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(10, 10);
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@ -3507,7 +3507,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, widget);
down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken);
pm = standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(10, 10);
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@ -3523,7 +3523,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, widget);
down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken);
pm = standardIcon(SP_TitleBarContextHelpButton, &tool, widget).pixmap(10, 10);
pm = proxy()->standardIcon(SP_TitleBarContextHelpButton, &tool, widget).pixmap(10, 10);
tool.rect = ir;
tool.state = down ? State_Sunken : State_Raised;
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
@ -3540,7 +3540,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
tb->icon.paint(p, ir);
} else {
int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget);
pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(iconSize, iconSize);
pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(iconSize, iconSize);
tool.rect = ir;
p->save();
proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm);
@ -3727,7 +3727,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
QPixmap pm = standardIcon(SP_TitleBarCloseButton).pixmap(16, 16);
QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(16, 16);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiNormalButton) {
@ -3744,7 +3744,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
QPixmap pm = standardIcon(SP_TitleBarNormalButton).pixmap(16, 16);
QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(16, 16);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiMinButton) {
@ -3761,7 +3761,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
QPixmap pm = standardIcon(SP_TitleBarMinButton).pixmap(16, 16);
QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(16, 16);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
}

View File

@ -959,7 +959,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
{
Q_D(const QFusionStyle);
if (d->tabBarcloseButtonIcon.isNull())
d->tabBarcloseButtonIcon = standardIcon(SP_DialogCloseButton, option, widget);
d->tabBarcloseButtonIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget);
if ((option->state & State_Enabled) && (option->state & State_MouseOver))
proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget);
QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On);
@ -2383,7 +2383,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
} else {
QStyleOption tool(0);
tool.palette = titleBar->palette;
QPixmap pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
tool.rect = iconRect;
painter->save();
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);

View File

@ -1774,7 +1774,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
} else {
QStyleOption tool(0);
tool.palette = titleBar->palette;
QPixmap pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
tool.rect = iconRect;
painter->save();
proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);

View File

@ -2848,7 +2848,7 @@ QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOpt
return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
recursionGuard = true;
QIcon icon = standardIcon(standardPixmap, opt, widget);
QIcon icon = proxy()->standardIcon(standardPixmap, opt, widget);
recursionGuard = false;
int size;
switch (standardPixmap) {
@ -4888,7 +4888,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
QRect closeRect;
if (canClose) {
QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton,
QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton,
opt, widget).actualSize(QSize(iconSize, iconSize));
sz += QSize(buttonMargin, buttonMargin);
if (verticalTitleBar)
@ -4905,7 +4905,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
QRect floatRect;
if (canFloat) {
QSize sz = standardIcon(QStyle::SP_TitleBarNormalButton,
QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarNormalButton,
opt, widget).actualSize(QSize(iconSize, iconSize));
sz += QSize(buttonMargin, buttonMargin);
if (verticalTitleBar)

View File

@ -1410,12 +1410,12 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
QRect titleRect = r;
if (dwOpt->closable) {
QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10));
QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10));
titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
}
if (dwOpt->floatable) {
QSize sz = standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10));
QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10));
titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
}