mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-13 02:01:08 +00:00
Move subControlRect for CC_ToolButton to RDTweakedNativeStyle
This means the full rect won't be returned for SC_ToolButtonMenu if it is used in a context where the default style doesn't expect the menu. This is a separate commit to isolate future changes to this function.
This commit is contained in:
committed by
Baldur Karlsson
parent
f82ef87595
commit
4c45c07160
@@ -317,33 +317,7 @@ bool RDStyle::eventFilter(QObject *watched, QEvent *event)
|
||||
QRect RDStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
if(cc == QStyle::CC_ToolButton)
|
||||
{
|
||||
int indicatorWidth = proxy()->pixelMetric(PM_MenuButtonIndicator, opt, widget);
|
||||
|
||||
QRect ret = opt->rect;
|
||||
|
||||
const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt);
|
||||
|
||||
// return the normal rect if there's no menu
|
||||
if(!(toolbutton->subControls & SC_ToolButtonMenu) &&
|
||||
!(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(sc == QStyle::SC_ToolButton)
|
||||
{
|
||||
ret.setRight(ret.right() - indicatorWidth);
|
||||
}
|
||||
else if(sc == QStyle::SC_ToolButtonMenu)
|
||||
{
|
||||
ret.setLeft(ret.right() - indicatorWidth);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else if(cc == QStyle::CC_GroupBox)
|
||||
if(cc == QStyle::CC_GroupBox)
|
||||
{
|
||||
QRect ret = opt->rect;
|
||||
|
||||
|
||||
@@ -51,6 +51,39 @@ RDTweakedNativeStyle::~RDTweakedNativeStyle()
|
||||
{
|
||||
}
|
||||
|
||||
QRect RDTweakedNativeStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
|
||||
SubControl sc, const QWidget *widget) const
|
||||
{
|
||||
if(cc == QStyle::CC_ToolButton)
|
||||
{
|
||||
int indicatorWidth = proxy()->pixelMetric(PM_MenuButtonIndicator, opt, widget);
|
||||
|
||||
QRect ret = opt->rect;
|
||||
|
||||
const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt);
|
||||
|
||||
// return the normal rect if there's no menu
|
||||
if(!(toolbutton->subControls & SC_ToolButtonMenu) &&
|
||||
!(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(sc == QStyle::SC_ToolButton)
|
||||
{
|
||||
ret.setRight(ret.right() - indicatorWidth);
|
||||
}
|
||||
else if(sc == QStyle::SC_ToolButtonMenu)
|
||||
{
|
||||
ret.setLeft(ret.right() - indicatorWidth);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return QProxyStyle::subControlRect(cc, opt, sc, widget);
|
||||
}
|
||||
|
||||
QRect RDTweakedNativeStyle::subElementRect(SubElement element, const QStyleOption *opt,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
RDTweakedNativeStyle(QStyle *parent);
|
||||
~RDTweakedNativeStyle();
|
||||
|
||||
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
|
||||
const QWidget *widget = Q_NULLPTR) const override;
|
||||
virtual QRect subElementRect(SubElement element, const QStyleOption *option,
|
||||
const QWidget *widget) const override;
|
||||
virtual QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size,
|
||||
|
||||
Reference in New Issue
Block a user