void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
{
  mCollapsed = collapse;

  if ( !isVisible() )
    return;

  // for consistent look/spacing across platforms when collapsed
  if ( ! mInitFlat ) // skip if initially set to flat in Designer
    setFlat( collapse );

  // avoid flicker in X11
  QApplication::processEvents();

  // set maximum height to hide contents - does this work in all envs?
  // setMaximumHeight( collapse ? 25 : 16777215 );
  setMaximumHeight( collapse ? titleRect().bottom() + 6 : 16777215 );
  mCollapseButton->setIcon( collapse ? mExpandIcon : mCollapseIcon );

  // if expanding and is in a QScrollArea, scroll down to make entire widget visible
  if ( mShown && mScrollOnExpand && !collapse && mParentScrollArea )
  {
    // process events so entire widget is shown
    QApplication::processEvents();
    mParentScrollArea->ensureWidgetVisible( this );
  }
  emit collapsedStateChanged( this );
}
void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
{
  // initialise widget on first show event only
  if ( mShown )
  {
    event->accept();
    return;
  }

  // check if groupbox was set to flat in Designer or in code
  mInitFlat = isFlat();

  // find parent QScrollArea - this might not work in complex layouts - should we look deeper?
  if ( parent() && parent()->parent() )
    mParentScrollArea = dynamic_cast<QScrollArea*>( parent()->parent()->parent() );
  else
    mParentScrollArea = 0;
  if ( mParentScrollArea )
    QgsDebugMsg( "found a QScrollArea parent: " + mParentScrollArea->objectName() );
  else
    QgsDebugMsg( "did not find a QScrollArea parent" );

  loadState();

  updateStyle();

  // expand if needed - any calls to setCollapsed() before only set mCollapsed, but have UI effect
  if ( mCollapsed )
  {
    setCollapsed( mCollapsed );
  }
  else
  {
    // 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();
}
Exemplo n.º 3
0
void GenericEditor::switchCollapsedState()
{

    if (!getProcessor()->isMerger() && !getProcessor()->isSplitter())
    {

        if (isCollapsed)
        {
            // open it up
            desiredWidth = originalWidth;
            isCollapsed = false;

        }
        else
        {
            originalWidth = desiredWidth;
            desiredWidth = 25;
            isCollapsed = true;
        }

        for (int i = 0; i < getNumChildComponents(); i++)
        {
            Component* c = getChildComponent(i);
            c->setVisible(!isCollapsed);
        }

        if (channelSelector != nullptr)
        {
            if (!drawerOpen)
                channelSelector->setVisible(false);
        }

        collapsedStateChanged();

        AccessClass::getEditorViewport()->refreshEditors();
    }
}