From 9617bfc3902b795dcd2322eaaa4a65564694de83 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 26 Apr 2018 12:41:35 +0100 Subject: [PATCH] Add support in RDStyle for checkboxes on group boxes --- qrenderdoc/Styles/RDStyle/RDStyle.cpp | 48 ++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/qrenderdoc/Styles/RDStyle/RDStyle.cpp b/qrenderdoc/Styles/RDStyle/RDStyle.cpp index f194af7a0..d6fa30cb3 100644 --- a/qrenderdoc/Styles/RDStyle/RDStyle.cpp +++ b/qrenderdoc/Styles/RDStyle/RDStyle.cpp @@ -342,15 +342,38 @@ QRect RDStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, const int labelHeight = lineHeight + border * 2; + const int checkWidth = + (group->subControls & QStyle::SC_GroupBoxCheckBox) ? Constants::CheckWidth : 0; + if(sc == SC_GroupBoxLabel) { - ret.setHeight(labelHeight); + if(checkWidth > 0) + { + ret.adjust(checkWidth + Constants::CheckMargin, 0, 0, 0); + ret.setHeight(qMax(labelHeight, Constants::CheckHeight)); + } + else + { + ret.setHeight(labelHeight); + } + return ret; } if(sc == SC_GroupBoxCheckBox) { - return QRect(); + if(checkWidth > 0) + { + ret.setWidth(checkWidth); + ret.setHeight(Constants::CheckHeight); + ret.adjust(Constants::CheckMargin, Constants::CheckMargin, Constants::CheckMargin, + Constants::CheckMargin); + } + else + { + ret = QRect(); + } + return ret; } if(sc == QStyle::SC_GroupBoxContents) @@ -882,7 +905,11 @@ void RDStyle::drawComplexControl(ComplexControl control, const QStyleOptionCompl } else if(control == CC_GroupBox) { - drawRoundedRectBorder(opt, p, widget, QPalette::Window, false); + // when drawing the border don't apply any states intended for the checkbox + QStyleOptionComplex frame = *opt; + frame.state &= + ~(QStyle::State_Sunken | QStyle::State_MouseOver | QStyle::State_On | QStyle::State_Off); + drawRoundedRectBorder(&frame, p, widget, QPalette::Window, false); const QStyleOptionGroupBox *group = qstyleoption_cast(opt); @@ -908,6 +935,16 @@ void RDStyle::drawComplexControl(ComplexControl control, const QStyleOptionCompl p->setPen(QPen(opt->palette.brush(m_Scheme == Light ? QPalette::Mid : QPalette::Midlight), 1.0)); p->drawLine(labelRect.bottomLeft(), labelRect.bottomRight()); + if(opt->subControls & QStyle::SC_GroupBoxCheckBox) + { + QRect checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget); + + QStyleOptionButton box; + (QStyleOption &)box = *(QStyleOption *)opt; + box.rect = checkBoxRect; + drawPrimitive(PE_IndicatorCheckBox, &box, p, widget); + } + return; } else if(control == QStyle::CC_ScrollBar) @@ -1341,15 +1378,18 @@ void RDStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *opt, Q return; } - else if(element == QStyle::PE_IndicatorViewItemCheck) + else if(element == QStyle::PE_IndicatorViewItemCheck || element == QStyle::PE_IndicatorCheckBox) { QRect rect = opt->rect; QPen outlinePen(outlineBrush(opt->palette), 1.0); p->save(); + p->setClipRect(rect); p->setRenderHint(QPainter::Antialiasing); + rect.adjust(0, 0, -1, -1); + QPainterPath path; path.addRoundedRect(rect, 1.0, 1.0);