Skip to content

Commit

Permalink
Fix corrupted group box layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 15, 2018
1 parent 88da833 commit 0fb0023
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion python/gui/auto_generated/qgscollapsiblegroupbox.sip.in
Expand Up @@ -119,7 +119,6 @@ Visual fixes for when group box is collapsed/expanded
void clearModifiers();



};


Expand Down
20 changes: 16 additions & 4 deletions src/gui/qgscollapsiblegroupbox.cpp
Expand Up @@ -26,6 +26,8 @@
#include <QStyleOptionGroupBox>
#include <QScrollArea>

const QString COLLAPSE_HIDE_BORDER_FIX = QStringLiteral( " QgsCollapsibleGroupBoxBasic { border: none; }" );

QgsCollapsibleGroupBoxBasic::QgsCollapsibleGroupBoxBasic( QWidget *parent )
: QGroupBox( parent )
{
Expand Down Expand Up @@ -382,8 +384,7 @@ void QgsCollapsibleGroupBoxBasic::updateStyle()
ss += QLatin1String( " background-color: rgba(0,0,0,0)" );
}
ss += '}';
mStyleSheet = styleSheet() + ss;
setStyleSheet( mStyleSheet );
setStyleSheet( styleSheet() + ss );

// clear toolbutton default background and border and apply offset
QString ssd;
Expand Down Expand Up @@ -444,9 +445,15 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
// handle child widgets so they don't paint while hidden
const char *hideKey = "CollGrpBxHide";

QString ss = styleSheet();
if ( mCollapsed )
{
setStyleSheet( mStyleSheet + " QgsCollapsibleGroupBoxBasic { border: none; }" );
if ( !ss.contains( COLLAPSE_HIDE_BORDER_FIX ) )
{
ss += COLLAPSE_HIDE_BORDER_FIX;
setStyleSheet( ss );
}

Q_FOREACH ( QObject *child, children() )
{
QWidget *w = qobject_cast<QWidget *>( child );
Expand All @@ -459,7 +466,12 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
}
else // on expand
{
setStyleSheet( mStyleSheet );
if ( ss.contains( COLLAPSE_HIDE_BORDER_FIX ) )
{
ss.replace( COLLAPSE_HIDE_BORDER_FIX, QString() );
setStyleSheet( ss );
}

Q_FOREACH ( QObject *child, children() )
{
QWidget *w = qobject_cast<QWidget *>( child );
Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgscollapsiblegroupbox.h
Expand Up @@ -161,8 +161,6 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox

QIcon mCollapseIcon;
QIcon mExpandIcon;

QString mStyleSheet;
};

/**
Expand Down

0 comments on commit 0fb0023

Please sign in to comment.