Source Code (Use browser search to find items of interest.)

Class Index

kiconedit'KBackgroundConfig (./kdegraphics/kiconedit/kiconconfig.h:88)

class KBackgroundConfig : public QWidget
{
  Q_OBJECT
public:
  KBackgroundConfig(QWidget *parent);
  ~KBackgroundConfig();

public slots:
  void saveSettings();
  void selectColor();
  void selectPixmap();

signals:

protected slots:
  void slotBackgroundMode(int);

protected:
  Properties *pprops;
  QPushButton *btpix, *btcolor;
  QPixmap pix;
  QString pixpath;
  QColor color;
  QWidget::BackgroundMode bgmode;
  QLabel *lb_ex;
};


kiconedit'KBackgroundConfig::KBackgroundConfig() (./kdegraphics/kiconedit/kiconconfig.cpp:240)

KBackgroundConfig::KBackgroundConfig( QWidget* parent )
  : QWidget( parent )
{
  debug("KBackgroundConfig - constructor");

  lb_ex = 0L;

  pprops = KIconEditProperties::getProperties(parent);
  color = pprops->backgroundcolor;

  pixpath = pprops->backgroundpixmap;
  pix.load(pixpath.data());
  if(pix.isNull())
  {
    debug("BGPIX: %s not valid!", pixpath.data());
    QPixmap pmlogo((const char**)logo);
    pix = pmlogo;
  }

  QVBoxLayout *mainLayout = new QVBoxLayout( this, 5 );

  QGroupBox *grp1 = new QGroupBox( i18n( "Color or pixmap" ), this );
  mainLayout->addWidget( grp1 );

  QGridLayout *grp1Layout = new QGridLayout( grp1, 3, 2, 15 );

  QButtonGroup* btngrp = new QButtonGroup( grp1 );
  btngrp->setExclusive( true );
  btngrp->setFrameStyle( QFrame::NoFrame );
  connect( btngrp, SIGNAL( clicked( int ) ), SLOT( slotBackgroundMode( int ) ) );
  grp1Layout->addWidget( btngrp, 0, 0 );

  QVBoxLayout *bgl = new QVBoxLayout( btngrp, 5 );

  QRadioButton *rbc = new QRadioButton( i18n( "Colored background" ), btngrp );
  btngrp->insert( rbc, 0 );
  bgl->addWidget( rbc );

  QRadioButton *rbp = new QRadioButton( i18n( "Pixmap background" ), btngrp );
  btngrp->insert( rbp, 1 );
  bgl->addWidget( rbp );

  bgl->addStretch( 1 );

  KButtonBox *bbox = new KButtonBox( grp1, KButtonBox::VERTICAL );
  grp1Layout->addWidget( bbox, 0, 1 );
  
  btcolor = bbox->addButton( i18n( "&Color..." ) );
  connect( btcolor, SIGNAL( clicked() ), SLOT( selectColor() ) );
  
  btpix = bbox->addButton( i18n( "&Pixmap..." ) );
  connect( btpix, SIGNAL( clicked() ), SLOT( selectPixmap() ) );

  bbox->layout();
  
  QRadioButton *rbb = new QRadioButton( i18n( "&Built-in" ), grp1 );
  grp1Layout->addMultiCellWidget( rbb, 1, 1, 0, 1, AlignHCenter );

  grp1Layout->setRowStretch( 2, 1 );
  
  QGroupBox *grp2 = new QGroupBox( i18n( "Example" ), this );
  mainLayout->addWidget( grp2, 1 );

  QBoxLayout *l2 = new QVBoxLayout( grp2, 15 );

  l2->addSpacing( 10 );

  lb_ex = new QLabel( grp2 );
  lb_ex->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  l2->addWidget( lb_ex );

/*
  l1->addWidget( btngrp, 0, AlignLeft );
  l1->addLayout( l1r );
*/

  bgmode = pprops->backgroundmode;
  if( bgmode == QWidget::FixedPixmap )
  {
    btngrp->setButton( 1 );
    btcolor->setEnabled( false );
    lb_ex->setBackgroundPixmap( pix );
  }
  else
  {
    btngrp->setButton( 0 );
    btpix->setEnabled( false );
    lb_ex->setBackgroundColor( color );
  }
}


kiconedit'KBackgroundConfig::~KBackgroundConfig() (./kdegraphics/kiconedit/kiconconfig.cpp:331)

KBackgroundConfig::~KBackgroundConfig()
{
}


kiconedit'KBackgroundConfig::slotBackgroundMode() (./kdegraphics/kiconedit/kiconconfig.cpp:335)

void KBackgroundConfig::slotBackgroundMode(int id)
{
  if(id == 0)
  {
    bgmode = QWidget::FixedColor;
    btpix->setEnabled(false);
    btcolor->setEnabled(true);
    if(lb_ex)
      lb_ex->setBackgroundColor(color);
  }
  else
  {
    bgmode = QWidget::FixedPixmap;
    btpix->setEnabled(true);
    btcolor->setEnabled(false);
    if(lb_ex)
      lb_ex->setBackgroundPixmap(pix);
  }
}


kiconedit'KBackgroundConfig::saveSettings() (./kdegraphics/kiconedit/kiconconfig.cpp:355)

void KBackgroundConfig::saveSettings()
{
  debug("KBackgroundConfig::saveSettings");
  Properties *pprops = props(this);
  pprops->backgroundmode = bgmode;
  pprops->backgroundpixmap = pixpath;
  pprops->backgroundcolor = color;
  debug("KBackgroundConfig::saveSettings - done");
}


kiconedit'KBackgroundConfig::selectColor() (./kdegraphics/kiconedit/kiconconfig.cpp:365)

void KBackgroundConfig::selectColor()
{
  QColor c;
  if(KColorDialog::getColor(c))
  {
    lb_ex->setBackgroundColor(c);
    color = c;
  }
}


kiconedit'KBackgroundConfig::selectPixmap() (./kdegraphics/kiconedit/kiconconfig.cpp:375)

void KBackgroundConfig::selectPixmap()
{
  KURL url = KFileDialog::getOpenURL("/", "*.xpm");
  
  if( url.isEmpty() )
    return;
  
  if( !url.isLocalFile() )
  {
    KMessageBox::sorry( 0L, i18n( "Only local files are supported yet." ) );
    return;
  }

  QPixmap p(url.path().data());
  
  if( !p.isNull() )
  {
    lb_ex->setBackgroundPixmap( p );
    pixpath = url.path().data();
  }
}