Skip to content
Permalink
Browse files

Set QgsCollapsibleGroupBox's collapse-on-uncheck to happen only when …

…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 0fd52ecf390c8715d9cd3d94b38493130d87c894
Showing with 12 additions and 1 deletion.
  1. +1 −0 python/gui/qgscollapsiblegroupbox.sip
  2. +10 −1 src/gui/qgscollapsiblegroupbox.cpp
  3. +1 −0 src/gui/qgscollapsiblegroupbox.h
@@ -35,6 +35,7 @@ class QgsCollapsibleGroupBoxBasic : QGroupBox

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

protected:
@@ -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 )
@@ -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() )
@@ -96,6 +96,7 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox

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

protected:

0 comments on commit 0fd52ec

Please sign in to comment.
You can’t perform that action at this time.