Skip to content

Commit 0fd52ec

Browse files
committedApr 14, 2013
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
1 parent a276f01 commit 0fd52ec

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
 

‎python/gui/qgscollapsiblegroupbox.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class QgsCollapsibleGroupBoxBasic : QGroupBox
3535

3636
public slots:
3737
void checkToggled( bool ckd );
38+
void checkClicked( bool ckd );
3839
void toggleCollapsed();
3940

4041
protected:

‎src/gui/qgscollapsiblegroupbox.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ void QgsCollapsibleGroupBoxBasic::init()
8282

8383
connect( mCollapseButton, SIGNAL( clicked() ), this, SLOT( toggleCollapsed() ) );
8484
connect( this, SIGNAL( toggled( bool ) ), this, SLOT( checkToggled( bool ) ) );
85+
connect( this, SIGNAL( clicked( bool ) ), this, SLOT( checkClicked( bool ) ) );
8586
}
8687

8788
void QgsCollapsibleGroupBoxBasic::showEvent( QShowEvent * event )
@@ -213,8 +214,16 @@ void QgsCollapsibleGroupBoxBasic::clearModifiers()
213214

214215
void QgsCollapsibleGroupBoxBasic::checkToggled( bool chkd )
215216
{
217+
Q_UNUSED( chkd );
216218
mCollapseButton->setEnabled( true ); // always keep enabled
217-
// expand/collapse when toggled
219+
}
220+
221+
void QgsCollapsibleGroupBoxBasic::checkClicked( bool chkd )
222+
{
223+
// expand/collapse when checkbox toggled by user click.
224+
// don't do this on toggle signal, otherwise group boxes will default to collapsed
225+
// in option dialog constructors, reducing discovery of options by new users and
226+
// overriding user's auto-saved collapsed/expanded state for the group box
218227
if ( chkd && isCollapsed() )
219228
setCollapsed( false );
220229
else if ( ! chkd && ! isCollapsed() )

‎src/gui/qgscollapsiblegroupbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox
9696

9797
public slots:
9898
void checkToggled( bool ckd );
99+
void checkClicked( bool ckd );
99100
void toggleCollapsed();
100101

101102
protected:

0 commit comments

Comments
 (0)
Please sign in to comment.