void Kleo::CryptoConfigModule::init( Layout layout ) {
  Kleo::CryptoConfig * const config = mConfig;
  const KPageView::FaceType type=determineJanusFace( config, layout );
  setFaceType(type);
  QVBoxLayout * vlay = 0;
  QWidget * vbox = 0;
  if ( type == Plain ) {
    vbox = new QWidget(this);
    vlay = new QVBoxLayout( vbox );
    vlay->setSpacing( KDialog::spacingHint() );
    vlay->setMargin( 0 );
    addPage( vbox, i18n("GpgConf Error") );
  }

  const QStringList components = config->componentList();
  for ( QStringList::const_iterator it = components.begin(); it != components.end(); ++it ) {
    //kDebug(5150) <<"Component" << (*it).toLocal8Bit() <<":";
    Kleo::CryptoConfigComponent* comp = config->component( *it );
    Q_ASSERT( comp );
    if ( comp->groupList().empty() )
      continue;
    if ( type != Plain ) {
      vbox = new QWidget(this);
      vlay = new QVBoxLayout( vbox );
      vlay->setSpacing( KDialog::spacingHint() );
      vlay->setMargin( 0 );
      KPageWidgetItem *pageItem = new KPageWidgetItem( vbox, comp->description() );
      if ( type != Tabbed )
          pageItem->setIcon( loadIcon( comp->iconName() ) );
      addPage(pageItem);
    }

    QScrollArea* scrollArea = type == Tabbed ? new QScrollArea( this ) : new ScrollArea( this );
    scrollArea->setWidgetResizable( true );

    vlay->addWidget( scrollArea );

    CryptoConfigComponentGUI* compGUI =
      new CryptoConfigComponentGUI( this, comp, scrollArea );
    compGUI->setObjectName( *it );
    scrollArea->setWidget( compGUI );
    scrollArea->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
    // KJanusWidget doesn't seem to have iterators, so we store a copy...
    mComponentGUIs.append( compGUI );

    // Set a nice startup size
    const int deskHeight = QApplication::desktop()->height();
    int dialogHeight;
    if (deskHeight > 1000) // very big desktop ?
      dialogHeight = 800;
    else if (deskHeight > 650) // big desktop ?
      dialogHeight = 500;
    else // small (800x600, 640x480) desktop
      dialogHeight = 400;
    assert( scrollArea->widget() );
    if ( type != Tabbed )
        scrollArea->setMinimumHeight( qMin( compGUI->sizeHint().height(), dialogHeight ) );
  }
  if ( mComponentGUIs.empty() ) {
      const QString msg = i18n("The gpgconf tool used to provide the information "
                               "for this dialog does not seem to be installed "
                               "properly. It did not return any components. "
                               "Try running \"%1\" on the command line for more "
                               "information.",
                               components.empty() ? "gpgconf --list-components" : "gpgconf --list-options gpg" );
      QLabel * label = new QLabel( msg, vbox );
      label->setWordWrap( true);
      label->setMinimumHeight( fontMetrics().lineSpacing() * 5 );
      vlay->addWidget( label );
  }
}