Skip to content

Commit

Permalink
Fix QgsCollapsibleGroupBox signal and scrolling issue
Browse files Browse the repository at this point in the history
- Signal now passes pointer to custom widget; calling isCollapsed() now works in connected slot
- Keep expanded group boxes in scroll areas from scrolling on first showing of dialog
  • Loading branch information
dakcarto committed Sep 15, 2012
1 parent 2edbc04 commit 8f0cb99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/gui/qgscollapsiblegroupbox.cpp
Expand Up @@ -85,7 +85,6 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
event->accept();
return;
}
mShown = true;

// check if groupbox was set to flat in Designer or in code
mInitFlat = isFlat();
Expand All @@ -111,11 +110,12 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
}
else
{
/* manually expanding (already default) on show may scroll scroll areas;
still emit signal for connections using expanded state */
// emit signal for connections using expanded state
emit collapsedStateChanged( this );
}

// set mShown after first setCollapsed call or expanded groupboxes
// will scroll scroll areas when first shown
mShown = true;
event->accept();
}

Expand Down Expand Up @@ -292,7 +292,7 @@ void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
mCollapseButton->setIcon( collapse ? mExpandIcon : mCollapseIcon );

// if expanding and is in a QScrollArea, scroll down to make entire widget visible
if ( mScrollOnExpand && !collapse && mParentScrollArea )
if ( mShown && mScrollOnExpand && !collapse && mParentScrollArea )
{
// process events so entire widget is shown
QApplication::processEvents();
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgscollapsiblegroupbox.h
Expand Up @@ -48,7 +48,8 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
void setScrollOnExpand( bool scroll ) { mScrollOnExpand = scroll; }

signals:
void collapsedStateChanged( QWidget* );
/** Signal emitted when groupbox collapsed/expanded state is changed, and when first shown */
void collapsedStateChanged( QgsCollapsibleGroupBox* );

public slots:
void checkToggled( bool ckd );
Expand Down

0 comments on commit 8f0cb99

Please sign in to comment.