Example #1
0
void PMSettingsDialog::registerPage( QWidget* topPage,
                                     PMSettingsDialogPage* page )
{
   int i = pageIndex( topPage );
   if( i < 0 )
      kdError( PMArea ) << "PMSettingsDialog: Registered settings page"
                        << " not found" << endl;
   else
   {
      m_pages.push_back( PMRegisteredSettingsPage( topPage, page, i ) );
      connect( page, SIGNAL( repaintViews( ) ), SLOT( slotRepaint( ) ) );
      connect( page, SIGNAL( showMe( ) ), SLOT( slotShowPage( ) ) );
   }
}
Example #2
0
KJanusWidget::KJanusWidget( TQWidget *parent, const char *name, int face )
  : TQWidget( parent, name, 0 ),
    mValid(false), mPageList(0),
    mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0),
    mShowIconsInTreeList(false), d(0)
{
  TQVBoxLayout *topLayout = new TQVBoxLayout( this );

  if( mFace == TreeList || mFace == IconList )
  {
    d = new KJanusWidgetPrivate;
    d->mSplitter = 0;

    TQFrame *page;
    if( mFace == TreeList )
    {
      d->mSplitter = new TQSplitter( this );
      topLayout->addWidget( d->mSplitter, 10 );
      mTreeListResizeMode = TQSplitter::KeepSize;

      d->mListFrame = new TQWidget( d->mSplitter );
      TQVBoxLayout *dummy = new TQVBoxLayout( d->mListFrame, 0, KDialog::spacingHint() );
      dummy->setAutoAdd( true );
      mTreeList = new TDEListView( d->mListFrame );
      mTreeList->addColumn( TQString::null );
      mTreeList->header()->hide();
      mTreeList->setRootIsDecorated(true);
      mTreeList->setSorting( -1 );
      connect( mTreeList, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotShowPage()) );
      connect( mTreeList, TQT_SIGNAL(clicked(TQListViewItem *)), TQT_SLOT(slotItemClicked(TQListViewItem *)));

      //
      // Page area. Title at top with a separator below and a pagestack using
      // all available space at bottom.
      //
      TQFrame *p = new TQFrame( d->mSplitter );

      TQHBoxLayout *hbox = new TQHBoxLayout( p, 0, 0 );

      page = new TQFrame( p );
      hbox->addWidget( page, 10 );
    }
    else
    {
      TQHBoxLayout *hbox = new TQHBoxLayout( topLayout );
      d->mListFrame = new TQWidget( this );
      hbox->addWidget( d->mListFrame );

      ( new TQVBoxLayout( d->mListFrame, 0, 0 ) )->setAutoAdd( true );
      mIconList = new IconListBox( d->mListFrame );

      TQFont listFont( mIconList->font() );
      listFont.setBold( true );
      mIconList->setFont( listFont );

      mIconList->verticalScrollBar()->installEventFilter( this );
      connect( mIconList, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotShowPage()));
      connect( mIconList, TQT_SIGNAL(onItem(TQListBoxItem *)), TQT_SLOT(slotOnItem(TQListBoxItem *)));

      hbox->addSpacing( KDialog::marginHint() );
      page = new TQFrame( this );
      hbox->addWidget( page, 10 );
    }

    //
    // Rest of page area. Title at top with a separator below and a
    // pagestack using all available space at bottom.
    //

    TQVBoxLayout *vbox = new TQVBoxLayout( page, 0, KDialog::spacingHint() );

    mTitleLabel = new TQLabel( i18n("Empty Page"), page, "KJanusWidgetTitleLabel" );
    vbox->addWidget( mTitleLabel, 0, TQApplication::reverseLayout() ? AlignRight : AlignLeft );

    TQFont titleFont( mTitleLabel->font() );
    titleFont.setBold( true );
    mTitleLabel->setFont( titleFont );

    mTitleSep = new KSeparator( page );
    mTitleSep->setFrameStyle( TQFrame::HLine|TQFrame::Plain );
    vbox->addWidget( mTitleSep );

    mPageStack = new TQWidgetStack( page );
    connect(mPageStack, TQT_SIGNAL(aboutToShow(TQWidget *)),
            TQT_SIGNAL(aboutToShowPage(TQWidget *)));
    vbox->addWidget( mPageStack, 10 );
  }
  else if( mFace == Tabbed )
  {
    d = new KJanusWidgetPrivate;

    mTabControl = new TQTabWidget( this );
    mTabControl->setMargin (KDialog::marginHint());
    connect(mTabControl, TQT_SIGNAL(currentChanged(TQWidget *)),
            TQT_SIGNAL(aboutToShowPage(TQWidget *)));
    topLayout->addWidget( mTabControl, 10 );
  }
  else if( mFace == Swallow )
  {
    mSwallowPage = new TQWidget( this );
    topLayout->addWidget( mSwallowPage, 10 );
  }
  else
  {
    mFace = Plain;
    mPlainPage = new TQFrame( this );
    topLayout->addWidget( mPlainPage, 10 );
  }

  if ( kapp )
    connect(kapp,TQT_SIGNAL(tdedisplayFontChanged()),TQT_SLOT(slotFontChanged()));
  mValid = true;

  setSwallowedWidget(0); // Set default size if 'mFace' is Swallow.
}