Source Code (Use browser search to find items of interest.)
Class Index
kpresenter'BackDia (./koffice/kpresenter/backdia.h:75)
class BackDia : public QDialog
{
Q_OBJECT
public:
BackDia( QWidget* parent, const char* name,
BackType backType, const QColor &backColor1,
const QColor &backColor2, BCType _bcType,
const QString &backPic, const QDateTime &picLM,
const QString &backClip, const QDateTime &clipLM,
BackView backPicView, bool _unbalanced,
int _xfactor, int _yfactor, KPresenterDoc *doc );
QColor getBackColor1();
QColor getBackColor2();
BCType getBackColorType();
BackType getBackType();
QString getBackPixFilename();
QString getBackClipFilename();
BackView getBackView();
bool getBackUnbalanced();
int getBackXFactor();
int getBackYFactor();
protected:
void showEvent( QShowEvent *e );
private:
QLabel *lPicName, *picPreview, *lClipName;
QCheckBox *unbalanced;
QComboBox *cType, *backCombo, *picView;
QPushButton *okBut, *applyBut, *applyGlobalBut, *cancelBut;
QPushButton *picChoose, *clipChoose;
KColorButton *color1Choose, *color2Choose;
QSlider *xfactor, *yfactor;
QString chosenPic;
QString chosenClip;
BackPreview *preview;
bool picChanged, clipChanged, lockUpdate;
QDateTime picLastModified, clipLastModified;
private slots:
void selectPic();
void selectClip();
void updateConfiguration();
void Ok() { emit backOk( FALSE ); }
void Apply() { emit backOk( FALSE ); }
void ApplyGlobal() { emit backOk( TRUE ); }
signals:
void backOk( bool );
};
kpresenter'BackDia::BackDia() (./koffice/kpresenter/backdia.cc:93)
BackDia::BackDia( QWidget* parent, const char* name,
BackType backType, const QColor &backColor1,
const QColor &backColor2, BCType _bcType,
const QString &backPic, const QDateTime &picLM,
const QString &backClip, const QDateTime &clipLM,
BackView backPicView, bool _unbalanced,
int _xfactor, int _yfactor, KPresenterDoc *doc )
: QDialog( parent, name, true ), picLastModified( picLM ), clipLastModified( clipLM )
{
lockUpdate = TRUE;
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 5 );
layout->setSpacing( 5 );
QHBoxLayout *hbox = new QHBoxLayout( layout );
hbox->setSpacing( 5 );
QVBoxLayout *vbox = new QVBoxLayout( hbox );
vbox->setSpacing( 5 );
vbox->addWidget( new QLabel( i18n( "Background Type:" ), this ) );
backCombo = new QComboBox( FALSE, this );
backCombo->insertItem( i18n( "Color/Gradient" ) );
backCombo->insertItem( i18n( "Picture" ) );
backCombo->insertItem( i18n( "Clipart" ) );
backCombo->setCurrentItem( (int)backType );
connect( backCombo, SIGNAL( activated( int ) ),
this, SLOT( updateConfiguration() ) );
vbox->addWidget( backCombo );
QTabWidget *tabWidget = new QTabWidget( this );
vbox->addWidget( tabWidget );
// color/gradient tab ---------------
QVBox *colorTab = new QVBox( tabWidget );
colorTab->setSpacing( 5 );
colorTab->setMargin( 5 );
color1Choose = new KColorButton( backColor1, colorTab );
connect( color1Choose, SIGNAL( changed( const QColor& ) ),
this, SLOT( updateConfiguration() ) );
color2Choose = new KColorButton( backColor2, colorTab );
connect( color2Choose, SIGNAL( changed( const QColor& ) ),
this, SLOT( updateConfiguration() ) );
cType = new QComboBox( FALSE, colorTab );
cType->insertItem( i18n( "Plain" ), -1 );
cType->insertItem( i18n( "Horizontal Gradient" ), -1 );
cType->insertItem( i18n( "Vertical Gradient" ), -1 );
cType->insertItem( i18n( "Diagonal Gradient 1" ), -1 );
cType->insertItem( i18n( "Diagonal Gradient 2" ), -1 );
cType->insertItem( i18n( "Circle Gradient" ), -1 );
cType->insertItem( i18n( "Rectangle Gradient" ), -1 );
cType->insertItem( i18n( "PipeCross Gradient" ), -1 );
cType->insertItem( i18n( "Pyramid Gradient" ), -1 );
cType->setCurrentItem( _bcType );
connect( cType, SIGNAL( activated( int ) ),
this, SLOT( updateConfiguration() ) );
unbalanced = new QCheckBox( i18n( "Unbalanced" ), colorTab );
connect( unbalanced, SIGNAL( clicked() ),
this, SLOT( updateConfiguration() ) );
unbalanced->setChecked( _unbalanced );
(void)new QLabel( i18n( "X-Factor:" ), colorTab );
xfactor = new QSlider( -200, 200, 1, 100, QSlider::Horizontal, colorTab );
connect( xfactor, SIGNAL( valueChanged( int ) ),
this, SLOT( updateConfiguration() ) );
xfactor->setValue( _xfactor );
(void)new QLabel( i18n( "Y-Factor:" ), colorTab );
yfactor = new QSlider( -200, 200, 1, 100, QSlider::Horizontal, colorTab );
connect( yfactor, SIGNAL( valueChanged( int ) ),
this, SLOT( updateConfiguration() ) );
yfactor->setValue( _yfactor );
tabWidget->addTab( colorTab, i18n( "&Color/Gradient" ) );
// picture tab ---------------------
QVBox *picTab = new QVBox( tabWidget );
picTab->setSpacing( 5 );
picTab->setMargin( 5 );
QLabel *l = new QLabel( i18n( "View Mode:" ), picTab );
l->setFixedHeight( l->sizeHint().height() );
picView = new QComboBox( FALSE, picTab );
picView->insertItem( i18n( "Zoomed" ) );
picView->insertItem( i18n( "Centered" ) );
picView->insertItem( i18n( "Tiled" ) );
picView->setCurrentItem( (int)backPicView );
connect( picView, SIGNAL( activated( int ) ),
this, SLOT( updateConfiguration() ) );
picChoose = new QPushButton( i18n( "Choose Picture..." ), picTab, "picChoose" );
connect( picChoose, SIGNAL( clicked() ),
this, SLOT( selectPic() ) );
if ( backPic )
chosenPic = backPic;
else
chosenPic = QString::null;
lPicName = new QLabel( picTab, "picname" );
lPicName->setFrameStyle( QFrame::Panel | QFrame::Sunken );
if ( !backPic.isEmpty() )
lPicName->setText( backPic );
else
lPicName->setText( i18n( "No Picture" ) );
lPicName->setFixedHeight( lPicName->sizeHint().height() );
(void)new QWidget( picTab );
tabWidget->addTab( picTab, i18n( "&Picture" ) );
// clipart tab--------------------------
QVBox *clipTab = new QVBox( tabWidget );
clipTab->setSpacing( 5 );
clipTab->setMargin( 5 );
clipChoose = new QPushButton( i18n( "Choose Clipart..." ), clipTab, "clipChoose" );
connect( clipChoose, SIGNAL( clicked() ),
this, SLOT( selectClip() ) );
if ( !backClip.isEmpty() )
chosenClip = backClip;
lClipName = new QLabel( clipTab, "clipname" );
lClipName->setFrameStyle( QFrame::Panel | QFrame::Sunken );
if ( !backClip.isEmpty() )
lClipName->setText( backClip );
else
lClipName->setText( i18n( "No Clipart" ) );
lClipName->setFixedHeight( lClipName->sizeHint().height() );
(void)new QWidget( clipTab );
tabWidget->addTab( clipTab, i18n( "Clip&art" ) );
// ------------------------ preview
preview = new BackPreview( this, doc );
hbox->addWidget( preview );
// ------------------------ buttons
KButtonBox *bb = new KButtonBox( this );
bb->addStretch();
okBut = bb->addButton( i18n( "&OK" ) );
applyGlobalBut = bb->addButton( i18n( "Apply &Global" ) );
applyBut = bb->addButton( i18n( "&Apply" ) );
cancelBut = bb->addButton( i18n( "&Close" ) );
okBut->setDefault( true );
connect( okBut, SIGNAL( clicked() ),
this, SLOT( Ok() ) );
connect( applyBut, SIGNAL( clicked() ),
this, SLOT( Apply() ) );
connect( applyGlobalBut, SIGNAL( clicked() ),
this, SLOT( ApplyGlobal() ) );
connect( cancelBut, SIGNAL( clicked() ),
this, SLOT( reject() ) );
connect( okBut, SIGNAL( clicked() ),
this, SLOT( accept() ) );
bb->layout();
layout->addWidget( bb );
picChanged = clipChanged = TRUE;
lockUpdate = FALSE;
updateConfiguration();
}
/*=============================================================*/
kpresenter'BackDia::showEvent() (./koffice/kpresenter/backdia.cc:274)
void BackDia::showEvent( QShowEvent *e )
{
QDialog::showEvent( e );
lockUpdate = FALSE;
updateConfiguration();
}
/*=============================================================*/
kpresenter'BackDia::updateConfiguration() (./koffice/kpresenter/backdia.cc:282)
void BackDia::updateConfiguration()
{
if ( lockUpdate )
return;
if ( getBackColorType() == BCT_PLAIN ) {
unbalanced->setEnabled( FALSE );
xfactor->setEnabled( FALSE );
yfactor->setEnabled( FALSE );
color2Choose->setEnabled( FALSE );
} else {
unbalanced->setEnabled( TRUE );
if ( unbalanced->isChecked() ) {
xfactor->setEnabled( TRUE );
yfactor->setEnabled( TRUE );
} else {
xfactor->setEnabled( FALSE );
yfactor->setEnabled( FALSE );
}
color2Choose->setEnabled( TRUE );
}
picChanged = getBackType() == BT_PICTURE;
clipChanged = getBackType() == BT_CLIPART;
preview->backGround()->setBackType( getBackType() );
preview->backGround()->setBackView( getBackView() );
preview->backGround()->setBackColor1( getBackColor1() );
preview->backGround()->setBackColor2( getBackColor2() );
preview->backGround()->setBackColorType( getBackColorType() );
preview->backGround()->setBackUnbalanced( getBackUnbalanced() );
preview->backGround()->setBackXFactor( getBackXFactor() );
preview->backGround()->setBackYFactor( getBackYFactor() );
if ( !chosenPic.isEmpty() && picChanged )
preview->backGround()->setBackPixmap( getBackPixFilename(), picLastModified );
if ( !chosenClip.isEmpty() && clipChanged )
preview->backGround()->setBackClipFilename( getBackClipFilename(), clipLastModified );
preview->backGround()->setBackType( getBackType() );
if ( preview->isVisible() && isVisible() ) {
preview->backGround()->restore();
preview->repaint( FALSE );
}
picChanged = clipChanged = FALSE;
}
/*=============================================================*/
kpresenter'BackDia::getBackType() (./koffice/kpresenter/backdia.cc:328)
BackType BackDia::getBackType()
{
return (BackType)backCombo->currentItem();
}
/*=============================================================*/
kpresenter'BackDia::getBackView() (./koffice/kpresenter/backdia.cc:334)
BackView BackDia::getBackView()
{
return (BackView)picView->currentItem();
}
/*=============================================================*/
kpresenter'BackDia::getBackColor1() (./koffice/kpresenter/backdia.cc:340)
QColor BackDia::getBackColor1()
{
return color1Choose->color();
}
/*=============================================================*/
kpresenter'BackDia::getBackColor2() (./koffice/kpresenter/backdia.cc:346)
QColor BackDia::getBackColor2()
{
return color2Choose->color();
}
/*=============================================================*/
kpresenter'BackDia::getBackColorType() (./koffice/kpresenter/backdia.cc:352)
BCType BackDia::getBackColorType()
{
return (BCType)cType->currentItem();
}
/*=============================================================*/
kpresenter'BackDia::getBackPixFilename() (./koffice/kpresenter/backdia.cc:358)
QString BackDia::getBackPixFilename()
{
return chosenPic;
}
/*=============================================================*/
kpresenter'BackDia::getBackClipFilename() (./koffice/kpresenter/backdia.cc:364)
QString BackDia::getBackClipFilename()
{
return chosenClip;
}
/*=============================================================*/
kpresenter'BackDia::getBackUnbalanced() (./koffice/kpresenter/backdia.cc:370)
bool BackDia::getBackUnbalanced()
{
return unbalanced->isChecked();
}
/*=============================================================*/
kpresenter'BackDia::getBackXFactor() (./koffice/kpresenter/backdia.cc:376)
int BackDia::getBackXFactor()
{
return xfactor->value();
}
/*=============================================================*/
kpresenter'BackDia::getBackYFactor() (./koffice/kpresenter/backdia.cc:382)
int BackDia::getBackYFactor()
{
return yfactor->value();
}
/*=============================================================*/
kpresenter'BackDia::selectPic() (./koffice/kpresenter/backdia.cc:389)
void BackDia::selectPic()
{
KURL url;
KFileDialog fd( QString::null,
//i18n( "Pictures (*.gif *.png *.jpg *.jpeg *.xpm *.bmp)\nAll files (*)" )
KImageIO::pattern(KImageIO::Reading), 0, 0, TRUE );
//fd.setPreviewMode( FALSE, TRUE );
fd.setPreviewWidget( new Preview( &fd ) );
//fd.setViewMode( QFileDialog::ListView | QFileDialog::PreviewContents );
if ( fd.exec() == QDialog::Accepted )
{
url = fd.selectedURL();
/*
if (!url.isLocalFile())
{
KMessageBox::sorry( 0, i18n("Remote URLs not supported") );
return;
}
chosenPic = url.path();
*/
chosenPic = QString::null;
if (!KIO::NetAccess::download( url, chosenPic ))
return;
lPicName->setText( url.decodedURL() );
backCombo->setCurrentItem( 1 );
picChanged = TRUE;
picLastModified = QDateTime();
updateConfiguration();
// Problem : when to remove the temp file ?
}
}
/*=============================================================*/
kpresenter'BackDia::selectClip() (./koffice/kpresenter/backdia.cc:422)
void BackDia::selectClip()
{
KURL url;
KFileDialog fd( QString::null, i18n( "Windows Metafiles (*.wmf)" ), 0, 0, TRUE );
//fd.setPreviewMode( FALSE, TRUE );
fd.setPreviewWidget( new Preview( &fd ) );
//fd.setViewMode( QFileDialog::ListView | QFileDialog::PreviewContents );
if ( fd.exec() == QDialog::Accepted )
{
url = fd.selectedURL();
chosenClip = QString::null;
if (!KIO::NetAccess::download( url, chosenClip ))
return;
lClipName->setText( url.decodedURL() );
backCombo->setCurrentItem( 2 );
clipChanged = TRUE;
clipLastModified = QDateTime();
updateConfiguration();
// Problem : when to remove the temp file ?
}
}