00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "kdialogbase.h"
00025 #include <stdlib.h>
00026
00027 #include <qgrid.h>
00028 #include <qhbox.h>
00029 #include <qlayout.h>
00030 #include <qtooltip.h>
00031 #include <qvbox.h>
00032 #include <qwhatsthis.h>
00033 #include <qtimer.h>
00034
00035 #include <kapplication.h>
00036 #include <klocale.h>
00037 #include <kconfig.h>
00038 #include <kiconloader.h>
00039 #include <kglobal.h>
00040 #include <kseparator.h>
00041 #include <kurllabel.h>
00042 #include <kdebug.h>
00043
00044 #include "kdialogbase_priv.h"
00045 #include "kdialogbase_priv.moc"
00046
00047 KDialogBaseTile *KDialogBase::mTile = 0;
00048
00049 int KDialogBaseButton::id()
00050 {
00051 return( mKey );
00052 }
00053
00054 template class QPtrList<KDialogBaseButton>;
00055
00059 struct SButton : public Qt
00060 {
00061 SButton()
00062 {
00063 box = 0;
00064 mask = 0;
00065 style = 0;
00066 }
00067
00068 KPushButton *append( int key, const KGuiItem &item );
00069
00070 void resize( bool sameWidth, int margin, int spacing, int orientation );
00071
00072 KPushButton *button( int key );
00073
00074 QWidget *box;
00075 int mask;
00076 int style;
00077 QPtrList<KDialogBaseButton> list;
00078 };
00079
00080 class KDialogBase::KDialogBasePrivate {
00081 public:
00082 KDialogBasePrivate() : bDetails(false), bFixed(false), bSettingDetails(false), detailsWidget(0) { }
00083
00084 bool bDetails;
00085 bool bFixed;
00086 bool bSettingDetails;
00087 QWidget *detailsWidget;
00088 QSize incSize;
00089 QSize minSize;
00090 QString detailsButton;
00091 SButton mButton;
00092 };
00093
00094 KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal,
00095 const QString &caption, int buttonMask,
00096 ButtonCode defaultButton, bool separator,
00097 const KGuiItem &user1, const KGuiItem &user2,
00098 const KGuiItem &user3 )
00099 :KDialog( parent, name, modal, WStyle_DialogBorder ),
00100 mTopLayout(0), mMainWidget(0), mUrlHelp(0), mJanus(0), mActionSep(0),
00101 mIsActivated(false), mShowTile(false), mMessageBoxMode(false),
00102 mButtonOrientation(Horizontal)
00103 {
00104 d = new KDialogBasePrivate;
00105 setCaption( caption );
00106
00107 makeRelay();
00108 connect( this, SIGNAL(layoutHintChanged()), this, SLOT(updateGeometry()) );
00109
00110 enableButtonSeparator( separator );
00111 makeButtonBox( buttonMask, defaultButton, user1, user2, user3 );
00112
00113 mIsActivated = true;
00114 setupLayout();
00115 }
00116
00117 KDialogBase::KDialogBase( int dialogFace, const QString &caption,
00118 int buttonMask, ButtonCode defaultButton,
00119 QWidget *parent, const char *name, bool modal,
00120 bool separator, const KGuiItem &user1,
00121 const KGuiItem &user2, const KGuiItem &user3 )
00122 :KDialog( parent, name, modal, WStyle_DialogBorder ),
00123 mTopLayout(0), mMainWidget(0), mUrlHelp(0), mJanus(0), mActionSep(0),
00124 mIsActivated(false), mShowTile(false), mMessageBoxMode(false),
00125 mButtonOrientation(Horizontal)
00126 {
00127 d = new KDialogBasePrivate;
00128 setCaption( caption );
00129
00130 makeRelay();
00131 connect( this, SIGNAL(layoutHintChanged()), this, SLOT(updateGeometry()) );
00132
00133 mJanus = new KJanusWidget( this, "janus", dialogFace );
00134 connect(mJanus, SIGNAL(aboutToShowPage(QWidget *)),
00135 this, SIGNAL(aboutToShowPage(QWidget *)));
00136
00137 if( mJanus == 0 || mJanus->isValid() == false ) { return; }
00138
00139 enableButtonSeparator( separator );
00140 makeButtonBox( buttonMask, defaultButton, user1, user2, user3 );
00141
00142 mIsActivated = true;
00143 setupLayout();
00144 }
00145
00146 KDialogBase::KDialogBase( const QString &caption, int buttonMask,
00147 ButtonCode defaultButton, ButtonCode escapeButton,
00148 QWidget *parent, const char *name, bool modal,
00149 bool separator, const KGuiItem &yes,
00150 const KGuiItem &no, const KGuiItem &cancel )
00151 :KDialog( parent, name, modal, WStyle_DialogBorder ),
00152 mTopLayout(0), mMainWidget(0), mUrlHelp(0), mJanus(0), mActionSep(0),
00153 mIsActivated(false), mShowTile(false), mMessageBoxMode(true),
00154 mButtonOrientation(Horizontal),mEscapeButton(escapeButton)
00155 {
00156 d = new KDialogBasePrivate;
00157
00158 setCaption( caption );
00159
00160 makeRelay();
00161 connect( this, SIGNAL(layoutHintChanged()), this, SLOT(updateGeometry()) );
00162
00163 enableButtonSeparator( separator );
00164
00165 buttonMask &= Details|Yes|No|Cancel;
00166
00167 makeButtonBox( buttonMask, defaultButton,
00168 no.text().isEmpty() ? KStdGuiItem::no() : no,
00169 yes.text().isEmpty() ? KStdGuiItem::yes() : yes );
00170
00171 setButtonCancelText( cancel.text().isEmpty() ?
00172 KStdGuiItem::cancel().text() : cancel.text() );
00173
00174 mIsActivated = true;
00175 setupLayout();
00176 }
00177
00178
00179
00180 KDialogBase::~KDialogBase()
00181 {
00182 delete d;
00183 }
00184
00185 KPushButton *SButton::append( int key, const KGuiItem &item )
00186 {
00187 KDialogBaseButton *p = new KDialogBaseButton( item, key, box );
00188 list.append( p );
00189 return( p );
00190 }
00191
00192 void SButton::resize( bool sameWidth, int margin,
00193 int spacing, int orientation )
00194 {
00195 KDialogBaseButton *p;
00196 int w = 0;
00197 int t = 0;
00198
00199 for( p = list.first(); p!=0; p = list.next() )
00200 {
00201 if( p->sizeHint().width() > w ) { w = p->sizeHint().width(); }
00202 }
00203
00204 if( orientation == Horizontal )
00205 {
00206 for( p = list.first(); p!=0; p = list.next() )
00207 {
00208 QSize s( p->sizeHint() );
00209 if( sameWidth == true ) { s.setWidth( w ); }
00210 p->setFixedWidth( s.width() );
00211 t += s.width() + spacing;
00212 }
00213
00214 p = list.first();
00215 box->setMinimumHeight( margin*2 + ( p==0?0:p->sizeHint().height()));
00216 box->setMinimumWidth( margin*2 + t - spacing );
00217 }
00218 else
00219 {
00220
00221 for( p = list.first(); p!=0; p = list.next() )
00222 {
00223 QSize s( p->sizeHint() );
00224 s.setWidth( w );
00225 p->setFixedSize( s );
00226 t += s.height() + spacing;
00227 }
00228 box->setMinimumHeight( margin*2 + t - spacing );
00229 box->setMinimumWidth( margin*2 + w );
00230 }
00231 }
00232
00233 KPushButton *SButton::button( int key )
00234 {
00235 KDialogBaseButton *p;
00236 for( p = list.first(); p != 0; p = list.next() )
00237 {
00238 if( p->id() == key )
00239 {
00240 return( p );
00241 }
00242 }
00243 return( 0 );
00244 }
00245
00246 void
00247 KDialogBase::delayedDestruct()
00248 {
00249 if (isVisible())
00250 hide();
00251 QTimer::singleShot( 0, this, SLOT(slotDelayedDestruct()));
00252 }
00253
00254 void
00255 KDialogBase::slotDelayedDestruct()
00256 {
00257 delete this;
00258 }
00259
00260 void KDialogBase::setupLayout()
00261 {
00262 if( mTopLayout != 0 )
00263 {
00264 delete mTopLayout;
00265 }
00266
00267
00268
00269 if( mButtonOrientation == Horizontal )
00270 {
00271 mTopLayout = new QBoxLayout( this, QBoxLayout::TopToBottom,
00272 marginHint(), spacingHint() );
00273 }
00274 else
00275 {
00276 mTopLayout = new QBoxLayout( this, QBoxLayout::LeftToRight,
00277 marginHint(), spacingHint() );
00278 }
00279
00280 if( mUrlHelp != 0 )
00281 {
00282 mTopLayout->addWidget( mUrlHelp, 0, AlignRight );
00283 }
00284
00285 if( mJanus != 0 )
00286 {
00287 mTopLayout->addWidget( mJanus, 10 );
00288 }
00289 else if( mMainWidget != 0 )
00290 {
00291 mTopLayout->addWidget( mMainWidget, 10 );
00292 }
00293
00294 if ( d->detailsWidget )
00295 {
00296 mTopLayout->addWidget( d->detailsWidget );
00297 }
00298
00299 if( mActionSep != 0 )
00300 {
00301 mTopLayout->addWidget( mActionSep );
00302 }
00303
00304 if( d->mButton.box != 0 )
00305 {
00306 mTopLayout->addWidget( d->mButton.box );
00307 }
00308 }
00309
00310
00311
00312 void KDialogBase::setButtonBoxOrientation( int orientation )
00313 {
00314 if( mButtonOrientation != orientation )
00315 {
00316 mButtonOrientation = orientation;
00317 if( mActionSep != 0 )
00318 {
00319 mActionSep->setOrientation( mButtonOrientation == Horizontal ?
00320 QFrame::HLine : QFrame::VLine );
00321 }
00322 if( mButtonOrientation == Vertical )
00323 {
00324 enableLinkedHelp(false);
00325 }
00326 setupLayout();
00327 setButtonStyle( d->mButton.style );
00328 }
00329 }
00330
00331
00332 void KDialogBase::setEscapeButton( ButtonCode id )
00333 {
00334 mEscapeButton = id;
00335 }
00336
00337
00338
00339 void KDialogBase::makeRelay()
00340 {
00341 if( mTile != 0 )
00342 {
00343 connect( mTile, SIGNAL(pixmapChanged()), this, SLOT(updateBackground()) );
00344 return;
00345 }
00346
00347 mTile = new KDialogBaseTile;
00348 if( mTile != 0 )
00349 {
00350 connect( mTile, SIGNAL(pixmapChanged()), this, SLOT(updateBackground()) );
00351 connect( qApp, SIGNAL(aboutToQuit()), mTile, SLOT(cleanup()) );
00352 }
00353 }
00354
00355
00356 void KDialogBase::enableButtonSeparator( bool state )
00357 {
00358 if( state == true )
00359 {
00360 if( mActionSep != 0 )
00361 {
00362 return;
00363 }
00364 mActionSep = new KSeparator( this );
00365 mActionSep->setFocusPolicy(QWidget::NoFocus);
00366 mActionSep->setOrientation( mButtonOrientation == Horizontal ?
00367 QFrame::HLine : QFrame::VLine );
00368 mActionSep->show();
00369 }
00370 else
00371 {
00372 if( mActionSep == 0 )
00373 {
00374 return;
00375 }
00376 delete mActionSep; mActionSep = 0;
00377 }
00378
00379 if( mIsActivated == true )
00380 {
00381 setupLayout();
00382 }
00383 }
00384
00385
00386
00387 QFrame *KDialogBase::plainPage()
00388 {
00389 return( mJanus == 0 ? 0 : mJanus->plainPage() );
00390 }
00391
00392
00393
00394 void KDialogBase::adjustSize()
00395 {
00396
00397
00398 if( d->bFixed )
00399 setFixedSize( sizeHint() );
00400 else
00401 resize( sizeHint() );
00402 }
00403
00404 QSize KDialogBase::sizeHint() const
00405 {
00406 return d->minSize.expandedTo( minimumSizeHint() ) + d->incSize;
00407 }
00408
00409 QSize KDialogBase::minimumSizeHint() const
00410 {
00411 int m = marginHint();
00412 int s = spacingHint();
00413
00414 QSize s1(0,0);
00415 QSize s2(0,0);
00416
00417
00418
00419
00420 if( mUrlHelp != 0 )
00421 {
00422 s2 = mUrlHelp->minimumSize() + QSize( 0, s );
00423 }
00424 s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
00425 s1.rheight() += s2.rheight();
00426
00427
00428
00429
00430 if( mJanus != 0 )
00431 {
00432 s2 = mJanus->minimumSizeHint() + QSize( 0, s );
00433 }
00434 else if( mMainWidget != 0 )
00435 {
00436 s2 = mMainWidget->sizeHint() + QSize( 0, s );
00437 s2 = s2.expandedTo( mMainWidget->minimumSize() );
00438 s2 = s2.expandedTo( mMainWidget->minimumSizeHint() );
00439 if( s2.isEmpty() == true )
00440 {
00441 s2 = QSize( 100, 100+s );
00442 }
00443 }
00444 else
00445 {
00446 s2 = QSize( 100, 100+s );
00447 }
00448 s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
00449 s1.rheight() += s2.rheight();
00450
00451 if (d->detailsWidget && d->bDetails)
00452 {
00453 s2 = d->detailsWidget->sizeHint() + QSize( 0, s );
00454 s2 = s2.expandedTo( d->detailsWidget->minimumSize() );
00455 s2 = s2.expandedTo( d->detailsWidget->minimumSizeHint() );
00456 s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
00457 s1.rheight() += s2.rheight();
00458 }
00459
00460
00461
00462
00463 if( mActionSep != 0 )
00464 {
00465 s1.rheight() += mActionSep->minimumSize().height() + s;
00466 }
00467
00468
00469
00470
00471 if( d->mButton.box != 0 )
00472 {
00473 s2 = d->mButton.box->minimumSize();
00474 if( mButtonOrientation == Horizontal )
00475 {
00476 s1.rwidth() = QMAX( s1.rwidth(), s2.rwidth() );
00477 s1.rheight() += s2.rheight();
00478 }
00479 else
00480 {
00481 s1.rwidth() += s2.rwidth();
00482 s1.rheight() = QMAX( s1.rheight(), s2.rheight() );
00483 }
00484 }
00485
00486
00487
00488
00489 s1.rheight() += 2*m;
00490 s1.rwidth() += 2*m;
00491
00492 return s1;
00493 }
00494
00495
00496 void KDialogBase::disableResize()
00497 {
00498 setFixedSize( sizeHint() );
00499 }
00500
00501
00502 void KDialogBase::setInitialSize( const QSize &s, bool noResize )
00503 {
00504 d->minSize = s;
00505 d->bFixed = noResize;
00506 adjustSize();
00507 }
00508
00509
00510 void KDialogBase::incInitialSize( const QSize &s, bool noResize )
00511 {
00512 d->incSize = s;
00513 d->bFixed = noResize;
00514 adjustSize();
00515 }
00516
00517
00518 void KDialogBase::makeButtonBox( int buttonMask, ButtonCode defaultButton,
00519 const KGuiItem &user1, const KGuiItem &user2,
00520 const KGuiItem &user3 )
00521 {
00522 if( buttonMask == 0 )
00523 {
00524 d->mButton.box = 0;
00525 return;
00526 }
00527
00528 if( buttonMask & Cancel ) { buttonMask &= ~Close; }
00529 if( buttonMask & Apply ) { buttonMask &= ~Try; }
00530 if( buttonMask & Details ) { buttonMask &= ~Default; }
00531
00532 if( mMessageBoxMode == false )
00533 {
00534 mEscapeButton = (buttonMask&Cancel) ? Cancel : Close;
00535 }
00536
00537 d->mButton.box = new QWidget( this );
00538
00539 d->mButton.mask = buttonMask;
00540 if( d->mButton.mask & Help )
00541 {
00542 KPushButton *pb = d->mButton.append( Help, KStdGuiItem::help() );
00543
00544 connect( pb, SIGNAL(clicked()), this, SLOT(slotHelp()) );
00545 }
00546 if( d->mButton.mask & Default )
00547 {
00548 KPushButton *pb = d->mButton.append( Default, KStdGuiItem::defaults() );
00549
00550 connect( pb, SIGNAL(clicked()), this, SLOT(slotDefault()) );
00551 }
00552 if( d->mButton.mask & Details )
00553 {
00554 KPushButton *pb = d->mButton.append( Details, QString::null );
00555 connect( pb, SIGNAL(clicked()), this, SLOT(slotDetails()) );
00556 setDetails(false);
00557 }
00558 if( d->mButton.mask & User3 )
00559 {
00560 KPushButton *pb = d->mButton.append( User3, user3 );
00561 connect( pb, SIGNAL(clicked()), this, SLOT(slotUser3()) );
00562 }
00563 if( d->mButton.mask & User2 )
00564 {
00565 KPushButton *pb = d->mButton.append( User2, user2 );
00566 if( mMessageBoxMode == true )
00567 {
00568 connect( pb, SIGNAL(clicked()), this, SLOT(slotYes()) );
00569 }
00570 else
00571 {
00572 connect( pb, SIGNAL(clicked()), this, SLOT(slotUser2()) );
00573 }
00574 }
00575 if( d->mButton.mask & User1 )
00576 {
00577 KPushButton *pb = d->mButton.append( User1, user1 );
00578 if( mMessageBoxMode == true )
00579 {
00580 connect( pb, SIGNAL(clicked()), this, SLOT(slotNo()) );
00581 }
00582 else
00583 {
00584 connect( pb, SIGNAL(clicked()), this, SLOT(slotUser1()) );
00585 }
00586 }
00587 if( d->mButton.mask & Ok )
00588 {
00589 KPushButton *pb = d->mButton.append( Ok, KStdGuiItem::ok() );
00590 connect( pb, SIGNAL(clicked()), this, SLOT(slotOk()) );
00591 }
00592 if( d->mButton.mask & Apply )
00593 {
00594 KPushButton *pb = d->mButton.append( Apply, KStdGuiItem::apply() );
00595 connect( pb, SIGNAL(clicked()), this, SLOT(slotApply()) );
00596 connect( pb, SIGNAL(clicked()), this, SLOT(applyPressed()) );
00597 }
00598 if( d->mButton.mask & Try )
00599 {
00600 KPushButton *pb = d->mButton.append( Try,
00601 KGuiItem( i18n( "&Try" ), "try" ) );
00602 connect( pb, SIGNAL(clicked()), this, SLOT(slotTry()) );
00603 }
00604 if( d->mButton.mask & Cancel )
00605 {
00606 KPushButton *pb = d->mButton.append( Cancel, KStdGuiItem::cancel() );
00607 connect( pb, SIGNAL(clicked()), this, SLOT(slotCancel()) );
00608 }
00609 if( d->mButton.mask & Close )
00610 {
00611 KPushButton *pb = d->mButton.append( Close, KStdGuiItem::close() );
00612 connect( pb, SIGNAL(clicked()), this, SLOT(slotClose()) );
00613 }
00614
00615 QPushButton *pb = actionButton( defaultButton );
00616 if( pb != 0 )
00617 {
00618 setButtonFocus( pb, true, true );
00619 }
00620
00621 setButtonStyle( ActionStyle0 );
00622 }
00623
00624
00625
00626 void KDialogBase::setButtonStyle( int style )
00627 {
00628 if( d->mButton.box == 0 )
00629 {
00630 return;
00631 }
00632
00633 if( style < 0 || style > ActionStyleMAX ) { style = ActionStyle0; }
00634 d->mButton.style = style;
00635
00636 const int *layout;
00637 int layoutMax = 0;
00638 if (mMessageBoxMode)
00639 {
00640 static const int layoutRule[5][6] =
00641 {
00642 {Details,Stretch,User2|Stretch,User1|Stretch,Cancel|Stretch, Details|Filler},
00643 {Details,Stretch,User2|Stretch,User1|Stretch,Cancel|Stretch, Details|Filler},
00644 {Details,Stretch,User2|Stretch,User1|Stretch,Cancel|Stretch, Details|Filler},
00645 {Details|Filler,Stretch,Cancel|Stretch,User2|Stretch,User1|Stretch,Details},
00646 {Details|Filler,Stretch,Cancel|Stretch,User2|Stretch,User1|Stretch,Details}
00647 };
00648 layoutMax = 6;
00649 layout = layoutRule[ d->mButton.style ];
00650 }
00651 else if (mButtonOrientation == Horizontal)
00652 {
00653 static const int layoutRule[5][9] =
00654 {
00655 {Help,Default,Stretch,User3,User2,User1,Ok,Apply|Try,Cancel|Close},
00656 {Help,Default,Stretch,User3,User2,User1,Cancel|Close,Apply|Try,Ok},
00657 {Help,Default,Stretch,User3,User2,User1,Apply|Try,Cancel|Close,Ok},
00658 {Ok,Apply|Try,Cancel|Close,User3,User2,User1,Stretch,Default,Help},
00659 {Ok,Cancel|Close,Apply|Try,User3,User2,User1,Stretch,Default,Help}
00660 };
00661 layoutMax = 9;
00662 layout = layoutRule[ d->mButton.style ];
00663 }
00664 else
00665 {
00666 static const int layoutRule[5][9] =
00667 {
00668 {Ok,Apply|Try,User1,User2,User3,Stretch,Default,Cancel|Close,Help},
00669
00670 {Help,Default,Stretch,User3,User2,User1,Cancel|Close,Apply|Try,Ok},
00671 {Help,Default,Stretch,User3,User2,User1,Apply|Try,Cancel|Close,Ok},
00672 {Ok,Apply|Try,Cancel|Close,User3,User2,User1,Stretch,Default,Help},
00673 {Ok,Cancel|Close,Apply|Try,User3,User2,User1,Stretch,Default,Help}
00674 };
00675 layoutMax = 9;
00676 layout = layoutRule[ d->mButton.style ];
00677 }
00678
00679 if( d->mButton.box->layout() )
00680 {
00681 delete d->mButton.box->layout();
00682 }
00683
00684 QBoxLayout *lay;
00685 if( mButtonOrientation == Horizontal )
00686 {
00687 lay = new QBoxLayout( d->mButton.box, QBoxLayout::LeftToRight, 0,
00688 spacingHint());
00689 }
00690 else
00691 {
00692 lay = new QBoxLayout( d->mButton.box, QBoxLayout::TopToBottom, 0,
00693 spacingHint());
00694 }
00695
00696 int numButton = 0;
00697 QPushButton *prevButton = 0;
00698 QPushButton *newButton;
00699
00700 for( int i=0; i<layoutMax; i++ )
00701 {
00702 if(((ButtonCode) layout[i]) == Stretch)
00703 {
00704 lay->addStretch(1);
00705 continue;
00706 }
00707 else if (layout[i] & Filler)
00708 {
00709 if (d->mButton.mask & layout[i])
00710 {
00711 newButton = actionButton( (ButtonCode) (layout[i] & ~(Stretch | Filler)));
00712 if (newButton)
00713 lay->addSpacing(newButton->sizeHint().width());
00714 }
00715 continue;
00716 }
00717 else if( d->mButton.mask & Help & layout[i] )
00718 {
00719 newButton = actionButton( Help );
00720 lay->addWidget( newButton ); numButton++;
00721 }
00722 else if( d->mButton.mask & Default & layout[i] )
00723 {
00724 newButton = actionButton( Default );
00725 lay->addWidget( newButton ); numButton++;
00726 }
00727 else if( d->mButton.mask & User3 & layout[i] )
00728 {
00729 newButton = actionButton( User3 );
00730 lay->addWidget( newButton ); numButton++;
00731 }
00732 else if( d->mButton.mask & User2 & layout[i] )
00733 {
00734 newButton = actionButton( User2 );
00735 lay->addWidget( newButton ); numButton++;
00736 }
00737 else if( d->mButton.mask & User1 & layout[i] )
00738 {
00739 newButton = actionButton( User1 );
00740 lay->addWidget( newButton ); numButton++;
00741 }
00742 else if( d->mButton.mask & Ok & layout[i] )
00743 {
00744 newButton = actionButton( Ok );
00745 lay->addWidget( newButton ); numButton++;
00746 }
00747 else if( d->mButton.mask & Apply & layout[i] )
00748 {
00749 newButton = actionButton( Apply );
00750 lay->addWidget( newButton ); numButton++;
00751 }
00752 else if( d->mButton.mask & Try & layout[i] )
00753 {
00754 newButton = actionButton( Try );
00755 lay->addWidget( newButton ); numButton++;
00756 }
00757 else if( d->mButton.mask & Cancel & layout[i] )
00758 {
00759 newButton = actionButton( Cancel );
00760 lay->addWidget( newButton ); numButton++;
00761 }
00762 else if( d->mButton.mask & Close & layout[i] )
00763 {
00764 newButton = actionButton( Close );
00765 lay->addWidget( newButton ); numButton++;
00766 }
00767 else if( d->mButton.mask & Details & layout[i] )
00768 {
00769 newButton = actionButton( Details );
00770 lay->addWidget( newButton ); numButton++;
00771 }
00772 else
00773 {
00774 continue;
00775 }
00776
00777
00778 if(layout[i] & Stretch)
00779 {
00780 lay->addStretch(1);
00781 }
00782
00783 if( prevButton != 0 )
00784 {
00785 setTabOrder( prevButton, newButton );
00786 }
00787 prevButton = newButton;
00788 }
00789
00790 d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
00791 }
00792
00793
00794 QPushButton *KDialogBase::actionButton( ButtonCode id )
00795 {
00796 return( d->mButton.button(id) );
00797 }
00798
00799
00800 void KDialogBase::enableButton( ButtonCode id, bool state )
00801 {
00802 QPushButton *pb = actionButton( id );
00803 if( pb != 0 )
00804 {
00805 pb->setEnabled( state );
00806 }
00807 }
00808
00809
00810 void KDialogBase::enableButtonOK( bool state )
00811 {
00812 enableButton( Ok, state );
00813 }
00814
00815
00816 void KDialogBase::enableButtonApply( bool state )
00817 {
00818 enableButton( Apply, state );
00819 }
00820
00821
00822 void KDialogBase::enableButtonCancel( bool state )
00823 {
00824 enableButton( Cancel, state );
00825 }
00826
00827
00828 void KDialogBase::showButton( ButtonCode id, bool state )
00829 {
00830 QPushButton *pb = actionButton( id );
00831 if( pb != 0 )
00832 {
00833 state ? pb->show() : pb->hide();
00834 }
00835 }
00836
00837
00838 void KDialogBase::showButtonOK( bool state )
00839 {
00840 showButton( Ok, state );
00841 }
00842
00843
00844 void KDialogBase::showButtonApply( bool state )
00845 {
00846 showButton( Apply, state );
00847 }
00848
00849
00850 void KDialogBase::showButtonCancel( bool state )
00851 {
00852 showButton( Cancel, state );
00853 }
00854
00855
00856 void KDialogBase::setButtonOKText( const QString &text,
00857 const QString &tooltip,
00858 const QString &quickhelp )
00859 {
00860 QPushButton *pb = actionButton( Ok );
00861 if( pb == 0 )
00862 {
00863 return;
00864 }
00865
00866 const QString whatsThis = i18n( ""
00867 "If you press the <b>OK</b> button, all changes\n"
00868 "you made will be used to proceed.");
00869
00870 pb->setText( text.isEmpty() ? i18n("&OK") : text );
00871 d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
00872
00873 QToolTip::add( pb, tooltip.isEmpty() ? i18n("Accept settings") : tooltip );
00874 QWhatsThis::add( pb, quickhelp.isEmpty() ? whatsThis : quickhelp );
00875 }
00876
00877
00878
00879 void KDialogBase::setButtonApplyText( const QString &text,
00880 const QString &tooltip,
00881 const QString &quickhelp )
00882 {
00883 QPushButton *pb = actionButton( Apply );
00884 if( pb == 0 )
00885 {
00886 return;
00887 }
00888
00889 const QString whatsThis = i18n( ""
00890 "When clicking <b>Apply</b>, the settings will be\n"
00891 "handed over to the program, but the dialog\n"
00892 "will not be closed. "
00893 "Use this to try different settings. ");
00894
00895 pb->setText( text.isEmpty() ? i18n("&Apply") : text );
00896 d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
00897
00898 QToolTip::add( pb, tooltip.isEmpty() ? i18n("Apply settings") : tooltip );
00899 QWhatsThis::add( pb, quickhelp.isEmpty() ? whatsThis : quickhelp );
00900 }
00901
00902
00903 void KDialogBase::setButtonCancelText( const QString& text,
00904 const QString& tooltip,
00905 const QString& quickhelp )
00906 {
00907 QPushButton *pb = actionButton( Cancel );
00908 if( pb == 0 )
00909 {
00910 return;
00911 }
00912
00913 pb->setText( text.isEmpty() ? i18n("&Cancel") : text );
00914 d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
00915
00916 QToolTip::add( pb, tooltip );
00917 QWhatsThis::add( pb, quickhelp );
00918 }
00919
00920
00921 void KDialogBase::setButtonText( ButtonCode id, const QString &text )
00922 {
00923 if (!d->bSettingDetails && (id == Details))
00924 {
00925 d->detailsButton = text;
00926 setDetails(d->bDetails);
00927 return;
00928 }
00929 QPushButton *pb = actionButton( id );
00930 if( pb != 0 )
00931 {
00932 pb->setText( text );
00933 d->mButton.resize( false, 0, spacingHint(), mButtonOrientation );
00934 }
00935 }
00936
00937
00938 void KDialogBase::setButtonTip( ButtonCode id, const QString &text )
00939 {
00940 QPushButton *pb = actionButton( id );
00941 if( pb != 0 )
00942 {
00943 if (text.isEmpty())
00944 QToolTip::remove( pb );
00945 else
00946 QToolTip::add( pb, text );
00947 }
00948 }
00949
00950
00951 void KDialogBase::setButtonWhatsThis( ButtonCode id, const QString &text )
00952 {
00953 QPushButton *pb = actionButton( id );
00954 if( pb != 0 )
00955 {
00956 if (text.isEmpty())
00957 QWhatsThis::remove( pb );
00958 else
00959 QWhatsThis::add( pb, text );
00960 }
00961 }
00962
00963
00964 void KDialogBase::setButtonFocus( QPushButton *p,bool isDefault, bool isFocus )
00965 {
00966 p->setDefault( isDefault );
00967 isFocus ? p->setFocus() : p->clearFocus();
00968 }
00969
00970
00971 void KDialogBase::setTreeListAutoResize( bool state )
00972 {
00973 if( mJanus != 0 )
00974 {
00975 mJanus->setTreeListAutoResize( state );
00976 }
00977 }
00978
00979 void KDialogBase::setShowIconsInTreeList(bool state)
00980 {
00981 if( mJanus != 0 )
00982 {
00983 mJanus->setShowIconsInTreeList( state );
00984 }
00985 }
00986
00987 void KDialogBase::setRootIsDecorated( bool state )
00988 {
00989 if( mJanus != 0 )
00990 {
00991 mJanus->setRootIsDecorated( state );
00992 }
00993 }
00994
00995
00996
00997 void KDialogBase::setIconListAllVisible( bool state )
00998 {
00999 if( mJanus != 0 )
01000 {
01001 mJanus->setIconListAllVisible( state );
01002 }
01003 }
01004
01005
01006 void KDialogBase::slotHelp()
01007 {
01008 emit helpClicked();
01009 if ( kapp )
01010 kapp->invokeHelp( mAnchor, mHelpApp );
01011 }
01012
01013
01014 void KDialogBase::slotDefault()
01015 {
01016 emit defaultClicked();
01017 }
01018
01019 void KDialogBase::slotDetails()
01020 {
01021 setDetails(!d->bDetails);
01022 }
01023
01024 void KDialogBase::setDetailsWidget(QWidget *detailsWidget)
01025 {
01026 delete d->detailsWidget;
01027 d->detailsWidget = detailsWidget;
01028 if (d->detailsWidget->parentWidget() != this)
01029 d->detailsWidget->reparent(this, QPoint(0,0));
01030 d->detailsWidget->hide();
01031 if( mIsActivated == true )
01032 {
01033 setupLayout();
01034 }
01035 if (!d->bSettingDetails)
01036 setDetails(d->bDetails);
01037 }
01038
01039 void KDialogBase::setDetails(bool showDetails)
01040 {
01041 if (d->detailsButton.isEmpty())
01042 d->detailsButton = i18n("&Details");
01043 d->bSettingDetails = true;
01044 d->bDetails = showDetails;
01045 if (d->bDetails)
01046 {
01047 emit aboutToShowDetails();
01048 setButtonText(Details, d->detailsButton+ " <<");
01049 if (d->detailsWidget)
01050 {
01051 if (layout())
01052 layout()->setEnabled(false);
01053 adjustSize();
01054 d->detailsWidget->show();
01055 if (layout())
01056 {
01057 layout()->activate();
01058 layout()->setEnabled(true);
01059 }
01060 }
01061 }
01062 else
01063 {
01064 setButtonText(Details, d->detailsButton+" >>");
01065 if (d->detailsWidget)
01066 {
01067 d->detailsWidget->hide();
01068 }
01069 if (layout())
01070 layout()->activate();
01071 adjustSize();
01072 }
01073 d->bSettingDetails = false;
01074 }
01075
01076 void KDialogBase::slotOk()
01077 {
01078 emit okClicked();
01079 accept();
01080 }
01081
01082
01083 void KDialogBase::slotApply()
01084 {
01085 emit applyClicked();
01086 }
01087
01088
01089 void KDialogBase::slotTry()
01090 {
01091 emit tryClicked();
01092 }
01093
01094
01095 void KDialogBase::slotUser3()
01096 {
01097 emit user3Clicked();
01098 }
01099
01100
01101 void KDialogBase::slotUser2()
01102 {
01103 emit user2Clicked();
01104 }
01105
01106
01107 void KDialogBase::slotUser1()
01108 {
01109 emit user1Clicked();
01110 }
01111
01112
01113 void KDialogBase::slotYes()
01114 {
01115 emit yesClicked();
01116 done( Yes );
01117 }
01118
01119
01120 void KDialogBase::slotNo()
01121 {
01122 emit noClicked();
01123 done( No );
01124 }
01125
01126
01127 void KDialogBase::slotCancel()
01128 {
01129 emit cancelClicked();
01130 done( mMessageBoxMode == true ? (int)Cancel : (int)Rejected );
01131 }
01132
01133
01134 void KDialogBase::slotClose()
01135 {
01136 emit closeClicked();
01137 reject();
01138 }
01139
01140
01141 void KDialogBase::helpClickedSlot( const QString & )
01142 {
01143 slotHelp();
01144 }
01145
01146
01147 void KDialogBase::applyPressed()
01148 {
01149 emit apply();
01150 }
01151
01152
01153 void KDialogBase::enableLinkedHelp( bool state )
01154 {
01155 if( state == true )
01156 {
01157 if( mUrlHelp != 0 )
01158 {
01159 return;
01160 }
01161
01162 mUrlHelp = new KURLLabel( this, "url" );
01163 mUrlHelp->setText( helpLinkText() );
01164 mUrlHelp->setFloat(true);
01165 mUrlHelp->setUnderline(true);
01166 if( mShowTile == true && mTile->get() != 0 )
01167 {
01168 mUrlHelp->setBackgroundPixmap(*mTile->get());
01169 }
01170 mUrlHelp->setMinimumHeight( fontMetrics().height() + marginHint() );
01171 connect(mUrlHelp,SIGNAL(leftClickedURL(const QString &)),
01172 SLOT(helpClickedSlot(const QString &)));
01173 mUrlHelp->show();
01174 }
01175 else
01176 {
01177 if( mUrlHelp == 0 )
01178 {
01179 return;
01180 }
01181 delete mUrlHelp; mUrlHelp = 0;
01182 }
01183
01184 if( mIsActivated == true )
01185 {
01186 setupLayout();
01187 }
01188 }
01189
01190
01191 void KDialogBase::setHelp( const QString &anchor, const QString &appname )
01192 {
01193 mAnchor = anchor;
01194 mHelpApp = appname;
01195 }
01196
01197
01198 void KDialogBase::setHelpLinkText( const QString &text )
01199 {
01200 mHelpLinkText = text;
01201 if( mUrlHelp != 0 )
01202 {
01203 mUrlHelp->setText( helpLinkText() );
01204 }
01205 }
01206
01207
01208 QFrame *KDialogBase::addPage( const QString &itemName, const QString &header,
01209 const QPixmap &pixmap )
01210 {
01211 return( mJanus == 0 ? 0 : mJanus->addPage( itemName, header, pixmap ) );
01212 }
01213
01214 QFrame *KDialogBase::addPage( const QStringList &items, const QString &header,
01215 const QPixmap &pixmap )
01216 {
01217 return( mJanus == 0 ? 0 : mJanus->addPage( items, header, pixmap ) );
01218 }
01219
01220
01221 QVBox *KDialogBase::addVBoxPage( const QString &itemName,
01222 const QString &header, const QPixmap &pixmap )
01223 {
01224 return( mJanus == 0 ? 0 : mJanus->addVBoxPage( itemName, header, pixmap) );
01225 }
01226
01227 QVBox *KDialogBase::addVBoxPage( const QStringList &items,
01228 const QString &header, const QPixmap &pixmap )
01229 {
01230 return( mJanus == 0 ? 0 : mJanus->addVBoxPage( items, header, pixmap) );
01231 }
01232
01233
01234 QHBox *KDialogBase::addHBoxPage( const QString &itemName,
01235 const QString &header,
01236 const QPixmap &pixmap )
01237 {
01238 return( mJanus == 0 ? 0 : mJanus->addHBoxPage( itemName, header, pixmap ) );
01239 }
01240
01241 QHBox *KDialogBase::addHBoxPage( const QStringList &items,
01242 const QString &header,
01243 const QPixmap &pixmap )
01244 {
01245 return( mJanus == 0 ? 0 : mJanus->addHBoxPage( items, header, pixmap ) );
01246 }
01247
01248
01249 QGrid *KDialogBase::addGridPage( int n, Orientation dir,
01250 const QString &itemName,
01251 const QString &header, const QPixmap &pixmap )
01252 {
01253 return( mJanus == 0 ? 0 : mJanus->addGridPage( n, dir, itemName, header,
01254 pixmap) );
01255 }
01256
01257 QGrid *KDialogBase::addGridPage( int n, Orientation dir,
01258 const QStringList &items,
01259 const QString &header, const QPixmap &pixmap )
01260 {
01261 return( mJanus == 0 ? 0 : mJanus->addGridPage( n, dir, items, header,
01262 pixmap) );
01263 }
01264
01265 void KDialogBase::setFolderIcon(const QStringList &path, const QPixmap &pixmap)
01266 {
01267 if (mJanus == 0)
01268 return;
01269
01270 mJanus->setFolderIcon(path,pixmap);
01271 }
01272
01273 QFrame *KDialogBase::makeMainWidget()
01274 {
01275 if( mJanus != 0 || mMainWidget != 0 )
01276 {
01277 printMakeMainWidgetError();
01278 return( 0 );
01279 }
01280
01281 QFrame *mainWidget = new QFrame( this );
01282 setMainWidget( mainWidget );
01283 return( mainWidget );
01284 }
01285
01286
01287 QVBox *KDialogBase::makeVBoxMainWidget()
01288 {
01289 if( mJanus != 0 || mMainWidget != 0 )
01290 {
01291 printMakeMainWidgetError();
01292 return( 0 );
01293 }
01294
01295 QVBox *mainWidget = new QVBox( this );
01296 mainWidget->setSpacing( spacingHint() );
01297 setMainWidget( mainWidget );
01298 return( mainWidget );
01299 }
01300
01301
01302 QHBox *KDialogBase::makeHBoxMainWidget()
01303 {
01304 if( mJanus != 0 || mMainWidget != 0 )
01305 {
01306 printMakeMainWidgetError();
01307 return( 0 );
01308 }
01309
01310 QHBox *mainWidget = new QHBox( this );
01311 mainWidget->setSpacing( spacingHint() );
01312 setMainWidget( mainWidget );
01313 return( mainWidget );
01314 }
01315
01316
01317 QGrid *KDialogBase::makeGridMainWidget( int n, Orientation dir )
01318 {
01319 if( mJanus != 0 || mMainWidget != 0 )
01320 {
01321 printMakeMainWidgetError();
01322 return( 0 );
01323 }
01324
01325 QGrid *mainWidget = new QGrid( n, dir, this );
01326 mainWidget->setSpacing( spacingHint() );
01327 setMainWidget( mainWidget );
01328 return( mainWidget );
01329 }
01330
01331
01332 void KDialogBase::printMakeMainWidgetError()
01333 {
01334 if( mJanus != 0 )
01335 {
01336 kdDebug() << "makeMainWidget: Illegal mode (wrong constructor)" << endl;
01337 }
01338 else if( mMainWidget != 0 )
01339 {
01340 kdDebug() << "makeMainWidget: Main widget already defined" << endl;
01341 }
01342 }
01343
01344
01345 void KDialogBase::setMainWidget( QWidget *widget )
01346 {
01347 if( mJanus != 0 )
01348 {
01349 if( mJanus->setSwallowedWidget(widget) == true )
01350 {
01351 mMainWidget = widget;
01352 }
01353 }
01354 else
01355 {
01356 mMainWidget = widget;
01357 if( mIsActivated == true )
01358 {
01359 setupLayout();
01360 }
01361 }
01362 }
01363
01364
01365 QWidget *KDialogBase::mainWidget()
01366 {
01367 return( mMainWidget );
01368 }
01369
01370
01371 bool KDialogBase::showPage( int index )
01372 {
01373 return( mJanus == 0 ? false : mJanus->showPage(index) );
01374 }
01375
01376
01377 int KDialogBase::activePageIndex() const
01378 {
01379 return( mJanus == 0 ? -1 : mJanus->activePageIndex() );
01380 }
01381
01382
01383 int KDialogBase::pageIndex( QWidget *widget ) const
01384 {
01385 return( mJanus == 0 ? -1 : mJanus->pageIndex( widget) );
01386 }
01387
01388
01389
01390 QRect KDialogBase::getContentsRect() const
01391 {
01392 QRect r;
01393 r.setLeft( marginHint() );
01394 r.setTop( marginHint() + (mUrlHelp != 0 ? mUrlHelp->height() : 0) );
01395 r.setRight( width() - marginHint() );
01396 int h = (mActionSep==0?0:mActionSep->minimumSize().height()+marginHint());
01397 if( d->mButton.box != 0 )
01398 {
01399 r.setBottom( height() - d->mButton.box->minimumSize().height() - h );
01400 }
01401 else
01402 {
01403 r.setBottom( height() - h );
01404 }
01405
01406 return(r);
01407 }
01408
01409
01410
01411 void KDialogBase::getBorderWidths(int& ulx, int& uly, int& lrx, int& lry) const
01412 {
01413 ulx = marginHint();
01414 uly = marginHint();
01415 if( mUrlHelp != 0 )
01416 {
01417 uly += mUrlHelp->minimumSize().height();
01418 }
01419
01420 lrx = marginHint();
01421 lry = d->mButton.box != 0 ? d->mButton.box->minimumSize().height() : 0;
01422 if( mActionSep != 0 )
01423 {
01424 lry += mActionSep->minimumSize().height() + marginHint();
01425 }
01426 }
01427
01428
01429 QSize KDialogBase::calculateSize(int w, int h) const
01430 {
01431 int ulx, uly, lrx, lry;
01432 getBorderWidths(ulx, uly, lrx, lry);
01433 return( QSize(ulx+w+lrx,uly+h+lry) );
01434 }
01435
01436
01437 QString KDialogBase::helpLinkText() const
01438 {
01439 return( mHelpLinkText==QString::null ? i18n("Get help...") : mHelpLinkText );
01440 }
01441
01442
01443 void KDialogBase::updateGeometry()
01444 {
01445 if( mTopLayout != 0 )
01446 {
01447 mTopLayout->setMargin( marginHint() );
01448 mTopLayout->setSpacing(spacingHint() );
01449 }
01450 }
01451
01452
01453
01454 void KDialogBase::keyPressEvent( QKeyEvent *e )
01455 {
01456
01457
01458
01459
01460 if( e->state() == 0 )
01461 {
01462 if( e->key() == Key_F1 )
01463 {
01464 QPushButton *pb = actionButton( Help );
01465 if( pb != 0 )
01466 {
01467 pb->animateClick();
01468 e->accept();
01469 return;
01470 }
01471 }
01472 if( e->key() == Key_Escape )
01473 {
01474 QPushButton *pb = actionButton( mEscapeButton );
01475 if( pb != 0 )
01476 {
01477 pb->animateClick();
01478 e->accept();
01479 return;
01480 }
01481
01482 }
01483 }
01484 else if( e->key() == Key_F1 && e->state() == ShiftButton )
01485 {
01486 QWhatsThis::enterWhatsThisMode();
01487 e->accept();
01488 return;
01489 }
01490
01491
01492 else if ( e->state() == ControlButton &&
01493 qApp->focusWidget() &&
01494 (qApp->focusWidget()->inherits( "QTextEdit" ) ||
01495 qApp->focusWidget()->inherits( "QLineEdit" )) &&
01496 (e->key() == Key_Return || e->key() == Key_Enter) )
01497 {
01498 QPushButton *pb = actionButton( Ok );
01499 if ( pb )
01500 {
01501 pb->animateClick();
01502 e->accept();
01503 return;
01504 }
01505 }
01506
01507
01508
01509
01510 QDialog::keyPressEvent(e);
01511 }
01512
01513
01514
01515 void KDialogBase::hideEvent( QHideEvent *ev )
01516 {
01517 emit hidden();
01518 if (!ev->spontaneous())
01519 {
01520 emit finished();
01521 }
01522 }
01523
01524
01525
01526 void KDialogBase::closeEvent( QCloseEvent *e )
01527 {
01528 QPushButton *pb = actionButton( mEscapeButton );
01529 if( pb != 0 ) {
01530 pb->animateClick();
01531 } else {
01532 QDialog::closeEvent( e );
01533 }
01534 }
01535
01536 void KDialogBase::cancel()
01537 {
01538 switch ( mEscapeButton ) {
01539 case Ok:
01540 slotOk();
01541 break;
01542 case User1:
01543 if ( mMessageBoxMode )
01544 slotNo();
01545 else
01546 slotUser1();
01547 break;
01548 case User2:
01549 if ( mMessageBoxMode )
01550 slotYes();
01551 else
01552 slotUser2();
01553 break;
01554 case User3:
01555 slotUser3();
01556 break;
01557 case Close:
01558 slotClose();
01559 break;
01560 case Cancel:
01561 default:
01562 slotCancel();
01563 }
01564 }
01565
01566 bool KDialogBase::haveBackgroundTile()
01567 {
01568 return( mTile == 0 || mTile->get() == 0 ? false : true );
01569 }
01570
01571
01572 const QPixmap *KDialogBase::getBackgroundTile() { return backgroundTile(); }
01573
01574 const QPixmap *KDialogBase::backgroundTile()
01575 {
01576 return( mTile == 0 ? 0 : mTile->get() );
01577 }
01578
01579
01580 void KDialogBase::setBackgroundTile( const QPixmap *pix )
01581 {
01582 if( mTile != 0 )
01583 {
01584 mTile->set( pix );
01585 }
01586 }
01587
01588
01589 void KDialogBase::updateBackground()
01590 {
01591 if( mTile == 0 || mTile->get() == 0 )
01592 {
01593 QPixmap nullPixmap;
01594 setBackgroundPixmap(nullPixmap);
01595 if( d->mButton.box != 0 )
01596 {
01597 d->mButton.box->setBackgroundPixmap(nullPixmap);
01598 d->mButton.box->setBackgroundMode(PaletteBackground);
01599 }
01600 setBackgroundMode(PaletteBackground);
01601 }
01602 else
01603 {
01604 const QPixmap *pix = mTile->get();
01605 setBackgroundPixmap(*pix);
01606 if( d->mButton.box != 0 )
01607 {
01608 d->mButton.box->setBackgroundPixmap(*pix);
01609 }
01610 showTile( mShowTile );
01611 }
01612 }
01613
01614
01615 void KDialogBase::showTile( bool state )
01616 {
01617 mShowTile = state;
01618 if( mShowTile == false || mTile == 0 || mTile->get() == 0 )
01619 {
01620 setBackgroundMode(PaletteBackground);
01621 if( d->mButton.box != 0 )
01622 {
01623 d->mButton.box->setBackgroundMode(PaletteBackground);
01624 }
01625 if( mUrlHelp != 0 )
01626 {
01627 mUrlHelp->setBackgroundMode(PaletteBackground);
01628 }
01629 }
01630 else
01631 {
01632 const QPixmap *pix = mTile->get();
01633 setBackgroundPixmap(*pix);
01634 if( d->mButton.box != 0 )
01635 {
01636 d->mButton.box->setBackgroundPixmap(*pix);
01637 }
01638 if( mUrlHelp != 0 )
01639 {
01640 mUrlHelp->setBackgroundPixmap(*pix);
01641 }
01642 }
01643 }
01644
01645 QSize KDialogBase::configDialogSize( const QString& groupName ) const
01646 {
01647 int w, h;
01648 int scnum = QApplication::desktop()->screenNumber(parentWidget());
01649 QRect desk = QApplication::desktop()->screenGeometry(scnum);
01650 w = QMIN( 530, (int) (desk.width() * 0.5));
01651 h = (int) (desk.height() * 0.4);
01652
01653 KConfig *kc = KGlobal::config();
01654
01655 if( kc )
01656 {
01657 KConfigGroupSaver cs(kc, groupName);
01658 w = kc->readNumEntry( QString::fromLatin1("Width %1").arg( desk.width()), w );
01659 h = kc->readNumEntry( QString::fromLatin1("Height %1").arg( desk.height()), h );
01660 }
01661 return( QSize( w, h ) );
01662 }
01663
01664
01665 void KDialogBase::saveDialogSize( const QString& groupName, bool global )
01666 {
01667 int scnum = QApplication::desktop()->screenNumber(parentWidget());
01668 QRect desk = QApplication::desktop()->screenGeometry(scnum);
01669 KConfig *kc = KGlobal::config();
01670
01671 if( kc )
01672 {
01673 KConfigGroupSaver cs(kc, groupName);
01674 QSize sizeToSave = size();
01675
01676 kc->writeEntry( QString::fromLatin1("Width %1").arg( desk.width()),
01677 QString::number( sizeToSave.width()), true, global);
01678 kc->writeEntry( QString::fromLatin1("Height %1").arg( desk.height()),
01679 QString::number( sizeToSave.height()), true, global);
01680 }
01681 }
01682
01683
01684 KDialogBaseButton::KDialogBaseButton( const KGuiItem &item, int key,
01685 QWidget *parent, const char *name )
01686 : KPushButton( item, parent, name )
01687 {
01688 mKey = key;
01689 }
01690
01691
01692
01693
01694 KDialogBaseTile::KDialogBaseTile( QObject *parent, const char *name )
01695 : QObject( parent, name )
01696 {
01697 mPixmap = 0;
01698 }
01699
01700
01701 KDialogBaseTile::~KDialogBaseTile()
01702 {
01703 cleanup();
01704 }
01705
01706
01707 void KDialogBaseTile::set( const QPixmap *pix )
01708 {
01709 if( pix == 0 )
01710 {
01711 cleanup();
01712 }
01713 else
01714 {
01715 if( mPixmap == 0 )
01716 {
01717 mPixmap = new QPixmap(*pix);
01718 }
01719 else
01720 {
01721 *mPixmap = *pix;
01722 }
01723 }
01724
01725 emit pixmapChanged();
01726 }
01727
01728
01729 const QPixmap *KDialogBaseTile::get() const
01730 {
01731 return( mPixmap );
01732 }
01733
01734
01735 void KDialogBaseTile::cleanup()
01736 {
01737 delete mPixmap; mPixmap = 0;
01738 }
01739
01740 void KDialogBase::virtual_hook( int id, void* data )
01741 { KDialog::virtual_hook( id, data ); }
01742
01743 #include "kdialogbase.moc"