308 setUpdatesEnabled(
false );
312 QStyleOptionGroupBox box;
313 initStyleOption( &box );
314 const QRect rectFrame = style()->subControlRect( QStyle::CC_GroupBox, &box,
315 QStyle::SC_GroupBoxFrame,
this );
319 const int marginLeft = 20;
320 const int marginRight = 5;
322 const int offsetStyle = QApplication::style()->objectName().contains( QLatin1String(
"macintosh" ) ) ? 8 : 0;
323 const int topBuffer = 1 + offsetStyle;
324 int offsetTop = topBuffer;
325 int offsetTopTri = topBuffer;
329 offsetTopTri += ( rectTitle.height() -
mCollapseButton->height() ) / 2;
339 if ( QApplication::style()->objectName().compare( QLatin1String(
"oxygen" ), Qt::CaseInsensitive ) == 0 )
341 QStyleOptionGroupBox box;
342 initStyleOption( &box );
343 const QRect rectFrame = style()->subControlRect( QStyle::CC_GroupBox, &box,
344 QStyle::SC_GroupBoxFrame,
this );
345 const QRect rectCheckBox = style()->subControlRect( QStyle::CC_GroupBox, &box,
346 QStyle::SC_GroupBoxCheckBox,
this );
347 if ( rectFrame.left() <= 0 )
348 offsetLeft = 6 + rectFrame.left();
349 if ( rectFrame.top() <= 0 )
354 offsetTop = ( rectCheckBox.height() / 2 ) -
356 offsetTopTri = offsetTop + 1;
360 offsetTop = 6 + rectFrame.top();
361 offsetTopTri = offsetTop;
366 QgsDebugMsgLevel( QStringLiteral(
"groupbox: %1 style: %2 offset: left=%3 top=%4 top2=%5" ).arg(
367 objectName(), QApplication::style()->objectName() ).arg( offsetLeft ).arg( offsetTop ).arg( offsetTopTri ), 5 );
371 if ( QApplication::style()->objectName().contains( QLatin1String(
"macintosh" ) ) )
373 ss += QLatin1String(
"QgsCollapsibleGroupBoxBasic, QgsCollapsibleGroupBox {" );
374 ss += QStringLiteral(
" margin-top: %1px;" ).arg( topBuffer + rectFrame.top() );
377 ss += QLatin1String(
"QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::title {" );
378 ss += QLatin1String(
" subcontrol-origin: margin;" );
379 ss += QLatin1String(
" subcontrol-position: top left;" );
380 ss += QStringLiteral(
" margin-left: %1px;" ).arg( marginLeft );
381 ss += QStringLiteral(
" margin-right: %1px;" ).arg( marginRight );
382 ss += QStringLiteral(
" left: %1px;" ).arg( offsetLeft );
383 ss += QStringLiteral(
" top: %1px;" ).arg( offsetTop );
384 if ( QApplication::style()->objectName().contains( QLatin1String(
"macintosh" ) ) )
386 ss += QLatin1String(
" background-color: rgba(0,0,0,0)" );
393 ssd = QStringLiteral(
"QgsCollapsibleGroupBoxBasic > QToolButton#%1, QgsCollapsibleGroupBox > QToolButton#%1 {" ).arg(
mCollapseButton->objectName() );
394 ssd += QLatin1String(
" background-color: rgba(255, 255, 255, 0); border: none;" );
395 ssd += QStringLiteral(
"} QgsCollapsibleGroupBoxBasic > QToolButton#%1:focus, QgsCollapsibleGroupBox > QToolButton#%1:focus { border: 1px solid palette(highlight); }" ).arg(
mCollapseButton->objectName() );
397 if ( offsetLeft != 0 || offsetTopTri != 0 )
399 setUpdatesEnabled(
true );
448 const char *hideKey =
"CollGrpBxHide";
450 QString ss = styleSheet();
459 const auto constChildren = children();
460 for ( QObject *child : constChildren )
462 QWidget *w = qobject_cast<QWidget *>( child );
465 w->setProperty( hideKey,
true );
478 const auto constChildren = children();
479 for ( QObject *child : constChildren )
481 QWidget *w = qobject_cast<QWidget *>( child );
484 if ( w->property( hideKey ).toBool() )