Skip to content

Commit

Permalink
Set QgsCollapsibleGroupBox's collapse-on-uncheck to happen only when …
Browse files Browse the repository at this point in the history
…clicked by user

- This keeps checkable group boxes from being programmatically collapsed when initializing a dialog
  • Loading branch information
dakcarto committed Apr 14, 2013
1 parent a276f01 commit 0fd52ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/gui/qgscollapsiblegroupbox.sip
Expand Up @@ -35,6 +35,7 @@ class QgsCollapsibleGroupBoxBasic : QGroupBox

public slots:
void checkToggled( bool ckd );
void checkClicked( bool ckd );
void toggleCollapsed();

protected:
Expand Down
11 changes: 10 additions & 1 deletion src/gui/qgscollapsiblegroupbox.cpp
Expand Up @@ -82,6 +82,7 @@ void QgsCollapsibleGroupBoxBasic::init()

connect( mCollapseButton, SIGNAL( clicked() ), this, SLOT( toggleCollapsed() ) );
connect( this, SIGNAL( toggled( bool ) ), this, SLOT( checkToggled( bool ) ) );
connect( this, SIGNAL( clicked( bool ) ), this, SLOT( checkClicked( bool ) ) );
}

void QgsCollapsibleGroupBoxBasic::showEvent( QShowEvent * event )
Expand Down Expand Up @@ -213,8 +214,16 @@ void QgsCollapsibleGroupBoxBasic::clearModifiers()

void QgsCollapsibleGroupBoxBasic::checkToggled( bool chkd )
{
Q_UNUSED( chkd );
mCollapseButton->setEnabled( true ); // always keep enabled
// expand/collapse when toggled
}

void QgsCollapsibleGroupBoxBasic::checkClicked( bool chkd )
{
// expand/collapse when checkbox toggled by user click.
// don't do this on toggle signal, otherwise group boxes will default to collapsed
// in option dialog constructors, reducing discovery of options by new users and
// overriding user's auto-saved collapsed/expanded state for the group box
if ( chkd && isCollapsed() )
setCollapsed( false );
else if ( ! chkd && ! isCollapsed() )
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgscollapsiblegroupbox.h
Expand Up @@ -96,6 +96,7 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox

public slots:
void checkToggled( bool ckd );
void checkClicked( bool ckd );
void toggleCollapsed();

protected:
Expand Down

0 comments on commit 0fd52ec

Please sign in to comment.