kdeui Library API Documentation

kaboutdialog.cpp

00001 /*
00002  *  This file is part of the KDE Libraries
00003  *  Copyright (C) 1999-2001 Mirko Boehm <mirko@kde.org> and
00004  *  Espen Sand <espensa@online.no>
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  *  Boston, MA 02111-1307, USA.
00020  *
00021  */
00022 
00023 #include <qclipboard.h>
00024 #include <qimage.h>
00025 #include <qlabel.h>
00026 #include <qlayout.h>
00027 #include <ktextedit.h>
00028 #include <qobjectlist.h>
00029 #include <qpainter.h>
00030 #include <qrect.h>
00031 #include <qtabwidget.h>
00032 #include <qtabbar.h>
00033 
00034 #include <kapplication.h>
00035 #include <kglobal.h>
00036 #include <kglobalsettings.h>
00037 #include <klocale.h>
00038 #include <ktextbrowser.h>
00039 #include <kurllabel.h>
00040 #include <kaboutdialog.h>
00041 #include <kaboutdialog_private.h>
00042 #include <kdebug.h>
00043 
00044 template class QMemArray<QWidget*>;
00045 template class QPtrList<KAboutContributor>;
00046 
00047 #define WORKTEXT_IDENTATION 16
00048 #define Grid 3
00049 
00050 // ##############################################################
00051 // MOC OUTPUT FILES:
00052 #include "kaboutdialog.moc"
00053 #include "kaboutdialog_private.moc"
00054 // ##############################################################
00055 
00056 class KAboutTabWidget : public QTabWidget
00057 {
00058 public:
00059     KAboutTabWidget( QWidget* parent ) : QTabWidget( parent ) {}
00060     QSize sizeHint() const {
00061     return QTabWidget::sizeHint().expandedTo( tabBar()->sizeHint() + QSize(4,4) );
00062     }
00063 };
00064 
00065 
00066 
00067 
00068 KAboutContributor::KAboutContributor( QWidget *_parent, const char *wname,
00069                           const QString &_name,const QString &_email,
00070                           const QString &_url, const QString &_work,
00071                           bool showHeader, bool showFrame,
00072                       bool showBold )
00073   : QFrame( _parent, wname ), mShowHeader(showHeader), mShowBold(showBold)
00074 {
00075   if( showFrame == true )
00076   {
00077     setFrameStyle(QFrame::Panel | QFrame::Raised);
00078   }
00079 
00080   mLabel[0] = new QLabel( this );
00081   mLabel[1] = new QLabel( this );
00082   mLabel[2] = new QLabel( this );
00083   mLabel[3] = new QLabel( this );
00084   mText[0] = new QLabel( this );
00085   mText[1] = new KURLLabel( this );
00086   mText[2] = new KURLLabel( this );
00087   mText[3] = new QLabel( this );
00088 
00089   setName( _name, i18n("Author"), false );
00090   setEmail( _email, i18n("Email"), false );
00091   setURL( _url, i18n("Homepage"), false );
00092   setWork( _work, i18n("Task"), false );
00093 
00094   KURLLabel *kurl = static_cast<KURLLabel *>(mText[1]);
00095   kurl->setFloat(true);
00096   kurl->setUnderline(true);
00097   connect(kurl, SIGNAL(leftClickedURL(const QString &)),
00098       SLOT(emailClickedSlot(const QString &)));
00099 
00100   kurl = static_cast<KURLLabel *>(mText[2]);
00101   kurl->setFloat(true);
00102   kurl->setUnderline(true);
00103   connect(kurl, SIGNAL(leftClickedURL(const QString &)),
00104       SLOT(urlClickedSlot(const QString &)));
00105 
00106   mLabel[3]->setAlignment( AlignTop );
00107 
00108   fontChange( font() );
00109   updateLayout();
00110 }
00111 
00112 
00113 void KAboutContributor::setName( const QString &_text, const QString &_header,
00114                  bool _update )
00115 {
00116   mLabel[0]->setText(_header);
00117   mText[0]->setText(_text);
00118   if( _update == true ) { updateLayout(); }
00119 }
00120 
00121 
00122 void KAboutContributor::setEmail( const QString &_text, const QString &_header,
00123                   bool _update )
00124 {
00125   mLabel[1]->setText(_header);
00126   KURLLabel *kurl = static_cast<KURLLabel *>(mText[1]);
00127   kurl->setText(_text);
00128   kurl->setURL(_text);
00129   if( _update == true ) { updateLayout(); }
00130 }
00131 
00132 
00133 void KAboutContributor::setURL( const QString &_text, const QString &_header,
00134                 bool _update )
00135 {
00136   mLabel[2]->setText(_header);
00137   KURLLabel *kurl = static_cast<KURLLabel *>(mText[2]);
00138   kurl->setText(_text);
00139   kurl->setURL(_text);
00140   if( _update == true ) { updateLayout(); }
00141 }
00142 
00143 
00144 void KAboutContributor::setWork( const QString &_text, const QString &_header,
00145                  bool _update )
00146 {
00147   mLabel[3]->setText(_header);
00148   mText[3]->setText(_text);
00149   if( _update == true ) { updateLayout(); }
00150 }
00151 
00152 
00153 QString KAboutContributor::getName( void ) const
00154 {
00155   return( mText[0]->text() );
00156 }
00157 
00158 
00159 QString KAboutContributor::getEmail( void ) const
00160 {
00161   return( mText[1]->text() );
00162 }
00163 
00164 
00165 QString KAboutContributor::getURL( void ) const
00166 {
00167   return( mText[2]->text() );
00168 }
00169 
00170 
00171 QString KAboutContributor::getWork( void ) const
00172 {
00173   return( mText[3]->text() );
00174 }
00175 
00176 
00177 
00178 void KAboutContributor::updateLayout( void )
00179 {
00180   if( layout() != 0 )
00181   {
00182     delete layout();
00183   }
00184 
00185   int row = 0;
00186   if( !mText[0]->text().isEmpty() ) { row += 1; }
00187   if( !mText[1]->text().isEmpty() ) { row += 1; }
00188   if( !mText[2]->text().isEmpty() ) { row += 1; }
00189   if( !mText[3]->text().isEmpty() ) { row += 1; }
00190 
00191 
00192   QGridLayout *gbox;
00193   if( row == 0 )
00194   {
00195     gbox = new QGridLayout( this, 1, 1, 0 );
00196     for( int i=0; i<4; i++ )
00197     {
00198       mLabel[i]->hide();
00199       mText[i]->hide();
00200     }
00201   }
00202   else
00203   {
00204     if( mText[0]->text().isEmpty() && mShowHeader == false )
00205     {
00206       gbox = new QGridLayout( this, row, 1, frameWidth()+1, 2 );
00207     }
00208     else
00209     {
00210       gbox = new QGridLayout( this, row, 2, frameWidth()+1, 2 );
00211       if( mShowHeader == false )
00212       {
00213     gbox->addColSpacing( 0, KDialog::spacingHint()*2 );
00214       }
00215       gbox->setColStretch( 1, 10 );
00216     }
00217 
00218     for( int i=0, r=0; i<4; i++ )
00219     {
00220       mLabel[i]->setFixedHeight( fontMetrics().lineSpacing() );
00221       if( i != 3 )
00222       {
00223     mText[i]->setFixedHeight( fontMetrics().lineSpacing() );
00224       }
00225 
00226       if( !mText[i]->text().isEmpty() )
00227       {
00228     if( mShowHeader == true )
00229     {
00230       gbox->addWidget( mLabel[i], r, 0, AlignLeft );
00231       gbox->addWidget( mText[i], r, 1, AlignLeft  );
00232       mLabel[i]->show();
00233       mText[i]->show();
00234     }
00235     else
00236     {
00237       mLabel[i]->hide();
00238       if( i == 0 )
00239       {
00240         gbox->addMultiCellWidget( mText[i], r, r, 0, 1, AlignLeft );
00241       }
00242       else
00243       {
00244         gbox->addWidget( mText[i], r, 1, AlignLeft  );
00245       }
00246       mText[i]->show();
00247     }
00248     r++;
00249       }
00250       else
00251       {
00252     mLabel[i]->hide();
00253     mText[i]->hide();
00254       }
00255     }
00256   }
00257 
00258   gbox->activate();
00259   setMinimumSize( sizeHint() );
00260 }
00261 
00262 
00263 void KAboutContributor::fontChange( const QFont &/*oldFont*/ )
00264 {
00265   if( mShowBold == true )
00266   {
00267     QFont f( font() );
00268     f.setBold( true );
00269     mText[0]->setFont( f );
00270   }
00271   update();
00272 }
00273 
00274 
00275 QSize KAboutContributor::sizeHint( void ) const
00276 {
00277   return( minimumSizeHint() );
00278 }
00279 
00280 
00281 void KAboutContributor::urlClickedSlot( const QString &u )
00282 {
00283   emit openURL(u);
00284 }
00285 
00286 
00287 void KAboutContributor::emailClickedSlot( const QString &e )
00288 {
00289   emit sendEmail( mText[0]->text(), e ) ;
00290 }
00291 
00292 
00293 //
00294 // Internal widget for the KAboutDialog class.
00295 //
00296 KAboutContainerBase::KAboutContainerBase( int layoutType, QWidget *_parent,
00297                       char *_name )
00298   : QWidget( _parent, _name ),
00299     mImageLabel(0), mTitleLabel(0), mIconLabel(0),mVersionLabel(0),
00300     mAuthorLabel(0), mImageFrame(0),mPageTab(0),mPlainSpace(0)
00301 {
00302   mTopLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
00303   if( mTopLayout == 0 ) { return; }
00304 
00305   if( layoutType & AbtImageOnly )
00306   {
00307     layoutType &= ~(AbtImageLeft|AbtImageRight|AbtTabbed|AbtPlain);
00308   }
00309   if( layoutType & AbtImageLeft )
00310   {
00311     layoutType &= ~AbtImageRight;
00312   }
00313 
00314   if( layoutType & AbtTitle )
00315   {
00316     mTitleLabel = new QLabel( this, "title" );
00317     mTitleLabel->setAlignment(AlignCenter);
00318     mTopLayout->addWidget( mTitleLabel );
00319     mTopLayout->addSpacing( KDialog::spacingHint() );
00320   }
00321 
00322   if( layoutType & AbtProduct )
00323   {
00324     QWidget *productArea = new  QWidget( this, "area" );
00325     mTopLayout->addWidget( productArea, 0, AlignLeft );
00326 
00327     QHBoxLayout *hbox = new QHBoxLayout(productArea,0,KDialog::spacingHint());
00328     if( hbox == 0 ) { return; }
00329 
00330     mIconLabel = new QLabel( productArea );
00331     hbox->addWidget( mIconLabel, 0, AlignLeft|AlignHCenter );
00332 
00333     QVBoxLayout *vbox = new QVBoxLayout();
00334     if( vbox == 0 ) { return; }
00335     hbox->addLayout( vbox );
00336 
00337     mVersionLabel = new QLabel( productArea, "version" );
00338     mAuthorLabel  = new QLabel( productArea, "author" );
00339     vbox->addWidget( mVersionLabel );
00340     vbox->addWidget( mAuthorLabel );
00341     hbox->activate();
00342 
00343     mTopLayout->addSpacing( KDialog::spacingHint() );
00344   }
00345 
00346   QHBoxLayout *hbox = new QHBoxLayout();
00347   if( hbox == 0 ) { return; }
00348   mTopLayout->addLayout( hbox, 10 );
00349 
00350   if( layoutType & AbtImageLeft )
00351   {
00352     QVBoxLayout *vbox = new QVBoxLayout();
00353     hbox->addLayout(vbox);
00354     vbox->addSpacing(1);
00355     mImageFrame = new QFrame( this );
00356     setImageFrame( true );
00357     vbox->addWidget( mImageFrame );
00358     vbox->addSpacing(1);
00359 
00360     vbox = new QVBoxLayout( mImageFrame, 1 );
00361     mImageLabel = new KImageTrackLabel( mImageFrame );
00362     connect( mImageLabel, SIGNAL(mouseTrack( int, const QMouseEvent * )),
00363          SLOT( slotMouseTrack( int, const QMouseEvent * )) );
00364     vbox->addStretch(10);
00365     vbox->addWidget( mImageLabel );
00366     vbox->addStretch(10);
00367     vbox->activate();
00368   }
00369 
00370   if( layoutType & AbtTabbed )
00371   {
00372     mPageTab = new KAboutTabWidget( this );
00373     if( mPageTab == 0 ) { return; }
00374     hbox->addWidget( mPageTab, 10 );
00375   }
00376   else if( layoutType & AbtImageOnly )
00377   {
00378     mImageFrame = new QFrame( this );
00379     setImageFrame( true );
00380     hbox->addWidget( mImageFrame, 10 );
00381 
00382     QGridLayout *gbox = new QGridLayout(mImageFrame, 3, 3, 1, 0 );
00383     gbox->setRowStretch( 0, 10 );
00384     gbox->setRowStretch( 2, 10 );
00385     gbox->setColStretch( 0, 10 );
00386     gbox->setColStretch( 2, 10 );
00387 
00388     mImageLabel = new KImageTrackLabel( mImageFrame );
00389     connect( mImageLabel, SIGNAL(mouseTrack( int, const QMouseEvent * )),
00390          SLOT( slotMouseTrack( int, const QMouseEvent * )) );
00391     gbox->addWidget( mImageLabel, 1, 1 );
00392     gbox->activate();
00393   }
00394   else
00395   {
00396     mPlainSpace = new QFrame( this );
00397     if( mPlainSpace == 0 ) { return; }
00398     hbox->addWidget( mPlainSpace, 10 );
00399   }
00400 
00401   if( layoutType & AbtImageRight )
00402   {
00403     QVBoxLayout *vbox = new QVBoxLayout();
00404     hbox->addLayout(vbox);
00405     vbox->addSpacing(1);
00406     mImageFrame = new QFrame( this );
00407     setImageFrame( true );
00408     vbox->addWidget( mImageFrame );
00409     vbox->addSpacing(1);
00410 
00411     vbox = new QVBoxLayout( mImageFrame, 1 );
00412     mImageLabel = new KImageTrackLabel( mImageFrame );
00413     connect( mImageLabel, SIGNAL(mouseTrack( int, const QMouseEvent * )),
00414          SLOT( slotMouseTrack( int, const QMouseEvent * )) );
00415     vbox->addStretch(10);
00416     vbox->addWidget( mImageLabel );
00417     vbox->addStretch(10);
00418     vbox->activate();
00419   }
00420 
00421   fontChange( font() );
00422 }
00423 
00424 
00425 void KAboutContainerBase::show( void )
00426 {
00427     QWidget::show();
00428 }
00429 
00430 QSize KAboutContainerBase::sizeHint( void ) const
00431 {
00432     return minimumSize().expandedTo( QSize( QWidget::sizeHint().width(), 0 ) );
00433 }
00434 
00435 void KAboutContainerBase::fontChange( const QFont &/*oldFont*/ )
00436 {
00437   if( mTitleLabel != 0 )
00438   {
00439     QFont f( KGlobalSettings::generalFont() );
00440     f.setBold( true );
00441     f.setPointSize( 14 ); // Perhaps changeable ?
00442     mTitleLabel->setFont(f);
00443   }
00444 
00445   if( mVersionLabel != 0 )
00446   {
00447     QFont f( KGlobalSettings::generalFont() );
00448     f.setBold( true );
00449     mVersionLabel->setFont(f);
00450     mAuthorLabel->setFont(f);
00451     mVersionLabel->parentWidget()->layout()->activate();
00452   }
00453 
00454   update();
00455 }
00456 
00457 QFrame *KAboutContainerBase::addTextPage( const QString &title,
00458                       const QString &text,
00459                       bool richText, int numLines )
00460 {
00461   QFrame *page = addEmptyPage( title );
00462   if( page == 0 ) { return(0); }
00463   if( numLines <= 0 ) { numLines = 10; }
00464 
00465   QVBoxLayout *vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00466 
00467   if( richText == true )
00468   {
00469     KTextBrowser *browser = new KTextBrowser( page, "browser" );
00470     browser->setHScrollBarMode( QScrollView::AlwaysOff );
00471     browser->setText( text );
00472     browser->setMinimumHeight( fontMetrics().lineSpacing()*numLines );
00473 
00474     vbox->addWidget(browser);
00475     connect(browser, SIGNAL(urlClick(const QString &)),
00476         SLOT(slotUrlClick(const QString &)));
00477     connect(browser, SIGNAL(mailClick(const QString &,const QString &)),
00478         SLOT(slotMailClick(const QString &,const QString &)));
00479   }
00480   else
00481   {
00482     KTextEdit *textEdit = new KTextEdit( page, "text" );
00483     textEdit->setReadOnly( true );
00484     textEdit->setMinimumHeight( fontMetrics().lineSpacing()*numLines );
00485     textEdit->setWordWrap( QTextEdit::NoWrap );
00486     vbox->addWidget( textEdit );
00487   }
00488 
00489   return( page );
00490 }
00491 
00492 QFrame *KAboutContainerBase::addLicensePage( const QString &title,
00493                       const QString &text, int numLines)
00494 {
00495   QFrame *page = addEmptyPage( title );
00496   if( page == 0 ) { return(0); }
00497   if( numLines <= 0 ) { numLines = 10; }
00498 
00499   QVBoxLayout *vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00500 
00501   KTextEdit *textEdit = new KTextEdit( page, "license" );
00502   textEdit->setFont( KGlobalSettings::fixedFont() );
00503   textEdit->setReadOnly( true );
00504   textEdit->setWordWrap( QTextEdit::NoWrap );
00505   textEdit->setText( text ); 
00506   textEdit->setMinimumHeight( fontMetrics().lineSpacing()*numLines );
00507   vbox->addWidget( textEdit );
00508 
00509   return( page );
00510 }
00511 
00512 
00513 KAboutContainer *KAboutContainerBase::addContainerPage( const QString &title,
00514                             int childAlignment,
00515                             int innerAlignment )
00516 {
00517   if( mPageTab == 0 )
00518   {
00519     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00520     return( 0 );
00521   }
00522 
00523   KAboutContainer *container = new KAboutContainer( mPageTab, "container",
00524     KDialog::spacingHint(), KDialog::spacingHint(), childAlignment,
00525                           innerAlignment );
00526   mPageTab->addTab( container, title );
00527 
00528   if( mContainerList.resize( mContainerList.size() + 1) == true )
00529   {
00530     mContainerList[ mContainerList.size()-1 ]=container;
00531   }
00532 
00533   connect(container, SIGNAL(urlClick(const QString &)),
00534       SLOT(slotUrlClick(const QString &)));
00535   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00536       SLOT(slotMailClick(const QString &,const QString &)));
00537 
00538   return( container );
00539 }
00540 
00541 
00542 KAboutContainer *KAboutContainerBase::addScrolledContainerPage(
00543                       const QString &title,
00544                       int childAlignment,
00545                       int innerAlignment )
00546 {
00547   if( mPageTab == 0 )
00548   {
00549     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00550     return( 0 );
00551   }
00552 
00553   QFrame *page = addEmptyPage( title );
00554   QVBoxLayout *vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00555   QScrollView *scrollView = new QScrollView( page );
00556   scrollView->viewport()->setBackgroundMode( PaletteBackground );
00557   vbox->addWidget( scrollView );
00558 
00559   KAboutContainer *container = new KAboutContainer( scrollView, "container",
00560     KDialog::spacingHint(), KDialog::spacingHint(), childAlignment,
00561     innerAlignment );
00562   scrollView->addChild( container );
00563 
00564 
00565   connect(container, SIGNAL(urlClick(const QString &)),
00566       SLOT(slotUrlClick(const QString &)));
00567   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00568       SLOT(slotMailClick(const QString &,const QString &)));
00569 
00570   return( container );
00571 }
00572 
00573 
00574 QFrame *KAboutContainerBase::addEmptyPage( const QString &title )
00575 {
00576   if( mPageTab == 0 )
00577   {
00578     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00579     return( 0 );
00580   }
00581 
00582   QFrame *page = new QFrame( mPageTab, title.latin1() );
00583   page->setFrameStyle( QFrame::NoFrame );
00584 
00585   mPageTab->addTab( page, title );
00586   return( page );
00587 }
00588 
00589 
00590 KAboutContainer *KAboutContainerBase::addContainer( int childAlignment,
00591                             int innerAlignment )
00592 {
00593   KAboutContainer *container = new KAboutContainer( this, "container",
00594     0, KDialog::spacingHint(), childAlignment, innerAlignment );
00595   mTopLayout->addWidget( container, 0, childAlignment );
00596 
00597   if( mContainerList.resize( mContainerList.size() + 1) == true )
00598   {
00599     mContainerList[ mContainerList.size()-1 ]=container;
00600   }
00601 
00602   connect(container, SIGNAL(urlClick(const QString &)),
00603       SLOT(slotUrlClick(const QString &)));
00604   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00605       SLOT(slotMailClick(const QString &,const QString &)));
00606 
00607   return( container );
00608 }
00609 
00610 
00611 
00612 void KAboutContainerBase::setTitle( const QString &title )
00613 {
00614   if( mTitleLabel == 0 )
00615   {
00616     kdDebug(291) << "setTitle: " << "Invalid layout" << endl;
00617     return;
00618   }
00619   mTitleLabel->setText(title);
00620 }
00621 
00622 
00623 void KAboutContainerBase::setImage( const QString &fileName )
00624 {
00625   if( mImageLabel == 0 )
00626   {
00627     kdDebug(291) << "setImage: " << "Invalid layout" << endl;
00628     return;
00629   }
00630   if( fileName.isNull() )
00631   {
00632     return;
00633   }
00634 
00635   QImage logo( fileName );
00636   if( logo.isNull() == false )
00637   {
00638     QPixmap pix;
00639     pix = logo;
00640     mImageLabel->setPixmap( pix );
00641   }
00642   mImageFrame->layout()->activate();
00643 
00644 }
00645 
00646 
00647 void KAboutContainerBase::setImageBackgroundColor( const QColor &color )
00648 {
00649   if( mImageFrame != 0 )
00650   {
00651     mImageFrame->setBackgroundColor( color );
00652   }
00653 }
00654 
00655 
00656 void KAboutContainerBase::setImageFrame( bool state )
00657 {
00658   if( mImageFrame != 0 )
00659   {
00660     if( state == true )
00661     {
00662       mImageFrame->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00663       mImageFrame->setLineWidth(1);
00664     }
00665     else
00666     {
00667       mImageFrame->setFrameStyle( QFrame::NoFrame );
00668       mImageFrame->setLineWidth(0);
00669     }
00670   }
00671 }
00672 
00673 
00674 void KAboutContainerBase::setProduct( const QString &appName,
00675                       const QString &version,
00676                       const QString &author,
00677                       const QString &year )
00678 {
00679   if( mIconLabel == 0 )
00680   {
00681     kdDebug(291) << "setProduct: " << "Invalid layout" << endl;
00682     return;
00683   }
00684 
00685   if ( kapp )
00686       mIconLabel->setPixmap( kapp->icon() );
00687 
00688   QString msg1 = i18n("%1 %2 (Using KDE %3)").arg(appName).arg(version).
00689     arg(QString::fromLatin1(KDE_VERSION_STRING));
00690   QString msg2 = !year.isEmpty() ? i18n("%1 %2, %3").arg('©').arg(year).
00691     arg(author) : QString::fromLatin1("");
00692 
00693   //if (!year.isEmpty())
00694   //  msg2 = i18n("%1 %2, %3").arg('©').arg(year).arg(author);
00695 
00696   mVersionLabel->setText( msg1 );
00697   mAuthorLabel->setText( msg2 );
00698   if( msg2.isEmpty() )
00699   {
00700     mAuthorLabel->hide();
00701   }
00702 
00703   mIconLabel->parentWidget()->layout()->activate();
00704 }
00705 
00706 
00707 void KAboutContainerBase::slotMouseTrack( int mode, const QMouseEvent *e )
00708 {
00709   emit mouseTrack( mode, e );
00710 }
00711 
00712 
00713 void KAboutContainerBase::slotUrlClick( const QString &url )
00714 {
00715   emit urlClick( url );
00716 }
00717 
00718 void KAboutContainerBase::slotMailClick( const QString &_name,
00719                      const QString &_address )
00720 {
00721   emit mailClick( _name, _address );
00722 }
00723 
00724 
00725 
00726 KAboutContainer::KAboutContainer( QWidget *_parent, const char *_name,
00727                   int _margin, int _spacing,
00728                   int childAlignment, int innerAlignment )
00729   : QFrame( _parent, _name )
00730 {
00731   mAlignment = innerAlignment;
00732 
00733   QGridLayout *gbox = new QGridLayout( this, 3, 3, _margin, _spacing );
00734   if( childAlignment & AlignHCenter )
00735   {
00736     gbox->setColStretch( 0, 10 );
00737     gbox->setColStretch( 2, 10 );
00738   }
00739   else if( childAlignment & AlignRight )
00740   {
00741     gbox->setColStretch( 0, 10 );
00742   }
00743   else
00744   {
00745     gbox->setColStretch( 2, 10 );
00746   }
00747 
00748   if( childAlignment & AlignVCenter )
00749   {
00750     gbox->setRowStretch( 0, 10 );
00751     gbox->setRowStretch( 2, 10 );
00752   }
00753   else if( childAlignment & AlignRight )
00754   {
00755     gbox->setRowStretch( 0, 10 );
00756   }
00757   else
00758   {
00759     gbox->setRowStretch( 2, 10 );
00760   }
00761 
00762   mVbox = new QVBoxLayout( _spacing );
00763   gbox->addLayout( mVbox, 1, 1 );
00764   gbox->activate();
00765 }
00766 
00767 
00768 void KAboutContainer::childEvent( QChildEvent *e )
00769 {
00770   if( !e->inserted() || !e->child()->isWidgetType() )
00771   {
00772     return;
00773   }
00774 
00775   QWidget *w = static_cast<QWidget *>(e->child());
00776   mVbox->addWidget( w, 0, mAlignment );
00777   QSize s( sizeHint() );
00778   setMinimumSize( s );
00779 
00780   QObjectList *l = const_cast<QObjectList *>(children()); // silence please
00781   for( uint i=0; i < l->count(); i++ )
00782   {
00783     QObject *o = l->at(i);
00784     if( o->isWidgetType() )
00785     {
00786         static_cast<QWidget *>(o)->setMinimumWidth( s.width() );
00787     }
00788   }
00789 }
00790 
00791 
00792 QSize KAboutContainer::sizeHint( void ) const
00793 {
00794   //
00795   // The size is computed by adding the sizeHint().height() of all
00796   // widget children and taking the width of the widest child and adding
00797   // layout()->margin() and layout()->spacing()
00798   //
00799 
00800   QSize total_size;
00801 
00802   int numChild = 0;
00803   QObjectList *l = const_cast<QObjectList *>(children()); // silence please
00804 
00805   for( uint i=0; i < l->count(); i++ )
00806   {
00807     QObject *o = l->at(i);
00808     if( o->isWidgetType() )
00809     {
00810       numChild += 1;
00811       QWidget *w= static_cast<QWidget *>(o);
00812 
00813       QSize s = w->minimumSize();
00814       if( s.isEmpty() == true )
00815       {
00816     s = w->minimumSizeHint();
00817     if( s.isEmpty() == true )
00818     {
00819       s = w->sizeHint();
00820       if( s.isEmpty() == true )
00821       {
00822         s = QSize( 100, 100 ); // Default size
00823       }
00824     }
00825       }
00826       total_size.setHeight( total_size.height() + s.height() );
00827       if( s.width() > total_size.width() ) { total_size.setWidth( s.width() ); }
00828     }
00829   }
00830 
00831   if( numChild > 0 )
00832   {
00833     //
00834     // Seems I have to add 1 to the height to properly show the border
00835     // of the last entry if layout()->margin() is 0
00836     //
00837 
00838     total_size.setHeight( total_size.height() + layout()->spacing()*(numChild-1) );
00839     total_size += QSize( layout()->margin()*2, layout()->margin()*2 + 1 );
00840   }
00841   else
00842   {
00843     total_size = QSize( 1, 1 );
00844   }
00845   return( total_size );
00846 }
00847 
00848 
00849 QSize KAboutContainer::minimumSizeHint( void ) const
00850 {
00851   return( sizeHint() );
00852 }
00853 
00854 
00855 void KAboutContainer::addWidget( QWidget *widget )
00856 {
00857   widget->reparent( this, 0, QPoint(0,0) );
00858 }
00859 
00860 
00861 void KAboutContainer::addPerson( const QString &_name, const QString &_email,
00862                  const QString &_url, const QString &_task,
00863                  bool showHeader, bool showFrame,bool showBold)
00864 {
00865 
00866   KAboutContributor *cont = new KAboutContributor( this, "pers",
00867     _name, _email, _url, _task, showHeader, showFrame, showBold );
00868   connect( cont, SIGNAL( openURL(const QString&)),
00869        this, SIGNAL( urlClick(const QString &)));
00870   connect( cont, SIGNAL( sendEmail(const QString &, const QString &)),
00871        this, SIGNAL( mailClick(const QString &, const QString &)));
00872 }
00873 
00874 
00875 void KAboutContainer::addTitle( const QString &title, int alignment,
00876                 bool showFrame, bool showBold )
00877 {
00878 
00879   QLabel *label = new QLabel( title, this, "title" );
00880   if( showBold == true )
00881   {
00882     QFont labelFont( font() );
00883     labelFont.setBold( true );
00884     label->setFont( labelFont );
00885   }
00886   if( showFrame == true )
00887   {
00888     label->setFrameStyle(QFrame::Panel | QFrame::Raised);
00889   }
00890   label->setAlignment( alignment );
00891 }
00892 
00893 
00894 void KAboutContainer::addImage( const QString &fileName, int alignment )
00895 {
00896   if( fileName.isNull() )
00897   {
00898     return;
00899   }
00900 
00901   KImageTrackLabel *label = new KImageTrackLabel( this, "image" );
00902   QImage logo( fileName );
00903   if( logo.isNull() == false )
00904   {
00905     QPixmap pix;
00906     pix = logo;
00907     label->setPixmap( pix );
00908   }
00909   label->setAlignment( alignment );
00910 }
00911 
00912 #if 0
00913 
00919 class KAboutContributor : public QFrame
00920 {
00921   // ############################################################################
00922   Q_OBJECT
00923   // ----------------------------------------------------------------------------
00924 public:
00926   KAboutContributor(QWidget* parent=0, const char* name=0);
00928   void setName(const QString&);
00930   QString getName();
00932   void setEmail(const QString&);
00934   QString getEmail();
00936   void setURL(const QString&);
00938   QString getURL();
00941   void setWork(const QString&);
00944   QSize sizeHint();
00945   QSize minimumSizeHint(void);
00946   virtual void show( void );
00947 
00948   // ----------------------------------------------------------------------------
00949 protected:
00950   // events:
00952   void resizeEvent(QResizeEvent*);
00954   void paintEvent(QPaintEvent*);
00956   QLabel *name;
00959   KURLLabel *email;
00961   KURLLabel *url;
00963   QString work;
00964   // ----------------------------------------------------------------------------
00965 protected slots:
00967   void urlClickedSlot(const QString&);
00969   void emailClickedSlot(const QString& emailaddress);
00970   // ----------------------------------------------------------------------------
00971 signals:
00973   void sendEmail(const QString& name, const QString& email);
00975   void openURL(const QString& url);
00976   // ############################################################################
00977 };
00978 
00979 
00980 
00981 KAboutContributor::KAboutContributor(QWidget* parent, const char* n)
00982   : QFrame(parent, n),
00983     name(new QLabel(this)),
00984     email(new KURLLabel(this)),
00985     url(new KURLLabel(this))
00986 {
00987   // ############################################################
00988   if(name==0 || email==0)
00989     { // this will nearly never happen (out of memory in about box?)
00990       kdDebug() << "KAboutContributor::KAboutContributor: Out of memory." << endl;
00991       qApp->quit();
00992     }
00993   setFrameStyle(QFrame::Panel | QFrame::Raised);
00994   // -----
00995   connect(email, SIGNAL(leftClickedURL(const QString&)),
00996       SLOT(emailClickedSlot(const QString&)));
00997   connect(url, SIGNAL(leftClickedURL(const QString&)),
00998       SLOT(urlClickedSlot(const QString&)));
00999   // ############################################################
01000 }
01001 
01002 void
01003 KAboutContributor::setName(const QString& n)
01004 {
01005   // ############################################################
01006   name->setText(n);
01007   // ############################################################
01008 }
01009 
01010 QString
01011 KAboutContributor::getName()
01012 {
01013   // ###########################################################
01014   return name->text();
01015   // ###########################################################
01016 }
01017 void
01018 KAboutContributor::setURL(const QString& u)
01019 {
01020   // ###########################################################
01021   url->setText(u);
01022   // ###########################################################
01023 }
01024 
01025 QString
01026 KAboutContributor::getURL()
01027 {
01028   // ###########################################################
01029   return url->text();
01030   // ###########################################################
01031 }
01032 
01033 void
01034 KAboutContributor::setEmail(const QString& e)
01035 {
01036   // ###########################################################
01037   email->setText(e);
01038   // ###########################################################
01039 }
01040 
01041 QString
01042 KAboutContributor::getEmail()
01043 {
01044   // ###########################################################
01045   return email->text();
01046   // ###########################################################
01047 }
01048 
01049 void
01050 KAboutContributor::emailClickedSlot(const QString& e)
01051 {
01052   // ###########################################################
01053   kdDebug() << "KAboutContributor::emailClickedSlot: called." << endl;
01054   emit(sendEmail(name->text(), e));
01055   // ###########################################################
01056 }
01057 
01058 void
01059 KAboutContributor::urlClickedSlot(const QString& u)
01060 {
01061   // ###########################################################
01062   kdDebug() << "KAboutContributor::urlClickedSlot: called." << endl;
01063   emit(openURL(u));
01064   // ###########################################################
01065 }
01066 
01067 void
01068 KAboutContributor::setWork(const QString& w)
01069 {
01070   // ###########################################################
01071   work=w;
01072   // ###########################################################
01073 }
01074 
01075 #endif
01076 
01077 
01078 #if 0
01079 QSize
01080 KAboutContributor::sizeHint()
01081 {
01082   // ############################################################################
01083   const int FrameWidth=frameWidth();
01084   const int WorkTextWidth=200;
01085   int maxx, maxy;
01086   QRect rect;
01087   // ----- first calculate name and email width:
01088   maxx=name->sizeHint().width();
01089   maxx=QMAX(maxx, email->sizeHint().width()+WORKTEXT_IDENTATION);
01090   // ----- now determine "work" text rectangle:
01091   if(!work.isEmpty()) // save time
01092     {
01093       rect=fontMetrics().boundingRect
01094     (0, 0, WorkTextWidth, 32000, WordBreak | AlignLeft, work);
01095     }
01096   if(maxx<rect.width())
01097   {
01098     maxx=WorkTextWidth+WORKTEXT_IDENTATION;
01099   }
01100   maxx=QMAX(maxx, url->sizeHint().width()+WORKTEXT_IDENTATION);
01101   // -----
01102   maxy=2*(name->sizeHint().height()+Grid); // need a space above the KURLLabels
01103   maxy+=/* email */ name->sizeHint().height();
01104   maxy+=rect.height();
01105   // -----
01106   maxx+=2*FrameWidth;
01107   maxy+=2*FrameWidth;
01108   return QSize(maxx, maxy);
01109   // ############################################################################
01110 }
01111 
01112 QSize KAboutContributor::minimumSizeHint(void)
01113 {
01114   return( sizeHint() );
01115 }
01116 
01117 
01118 void KAboutContributor::show( void )
01119 {
01120   QFrame::show();
01121   setMinimumSize( sizeHint() );
01122 }
01123 
01124 
01125 
01126 void
01127 KAboutContributor::resizeEvent(QResizeEvent*)
01128 { // the widgets are simply aligned from top to bottom, since the parent is
01129   // expected to respect the size hint
01130   // ############################################################################
01131   int framewidth=frameWidth(), childwidth=width()-2*framewidth;
01132   int cy=framewidth;
01133   // -----
01134   name->setGeometry
01135     (framewidth, framewidth, childwidth, name->sizeHint().height());
01136   cy=name->height()+Grid;
01137   email->setGeometry
01138     (framewidth+WORKTEXT_IDENTATION, cy,
01139      childwidth-WORKTEXT_IDENTATION, /* email */ name->sizeHint().height());
01140   cy+=name->height()+Grid;
01141   url->setGeometry
01142     (framewidth+WORKTEXT_IDENTATION, cy,
01143      childwidth-WORKTEXT_IDENTATION, /* url */ name->sizeHint().height());
01144   // the work text is drawn in the paint event
01145   // ############################################################################
01146 }
01147 
01148 
01149 void
01150 KAboutContributor::paintEvent(QPaintEvent* e)
01151 { // the widgets are simply aligned from top to bottom, since the parent is
01152   // expected to respect the size hint (the widget is only used locally by now)
01153   // ############################################################################
01154   int cy=frameWidth()+name->height()+email->height()+Grid+url->height()+Grid;
01155   int h=height()-cy-frameWidth();
01156   int w=width()-WORKTEXT_IDENTATION-2*frameWidth();
01157   // -----
01158   QFrame::paintEvent(e);
01159   if(work.isEmpty()) return;
01160   QPainter paint(this); // construct painter only if there is something to draw
01161   // -----
01162   paint.drawText(WORKTEXT_IDENTATION, cy, w, h, AlignLeft | WordBreak, work);
01163   // ############################################################################
01164 }
01165 #endif
01166 
01167 
01168 #if 0
01169 QSize KAboutContributor::sizeHint( void )
01170 {
01171   int s = KDialog::spacingHint();
01172   int h = fontMetrics().lineSpacing()*3 + 2*s;
01173   int m = frameWidth();
01174 
01175   int w = name->sizeHint().width();
01176   w = QMAX( w, email->sizeHint().width()+s);
01177   w = QMAX( w, url->sizeHint().width()+s);
01178 
01179   if( work.isEmpty() == false )
01180   {
01181     const int WorkTextWidth=200;
01182     QRect r = fontMetrics().boundingRect
01183       (0, 0, WorkTextWidth, 32000, WordBreak | AlignLeft, work);
01184     if( w < r.width() )
01185     {
01186       w = QMAX( w, WorkTextWidth+s );
01187     }
01188     h += QMAX( fontMetrics().lineSpacing(), r.height() ) + s;
01189   }
01190   return( QSize( w + 2*m, h + 2*m ) );
01191 
01192 
01193   /*
01194   int s = 3;
01195   int m = frameWidth() + KDialog::spacingHint();
01196   int h = ls * 3 + s * 2;
01197   int w = name->sizeHint().width();
01198 
01199   w = QMAX( w, email->sizeHint().width()+WORKTEXT_IDENTATION);
01200   w = QMAX( w, url->sizeHint().width()+WORKTEXT_IDENTATION);
01201   if( work.isEmpty() == false )
01202   {
01203     const int WorkTextWidth=200;
01204 
01205     QRect r = fontMetrics().boundingRect
01206       (0, 0, WorkTextWidth, 32000, WordBreak | AlignLeft, work);
01207     if( w < r.width() )
01208     {
01209       w = QMAX( w, WorkTextWidth + WORKTEXT_IDENTATION );
01210     }
01211     h += r.height() + s;
01212   }
01213   return( QSize( w + 2*m, h + 2*m ) );
01214   */
01215 }
01216 
01217 
01218 //
01219 // The widgets are simply aligned from top to bottom, since the parent is
01220 // expected to respect the size hint
01221 //
01222 void KAboutContributor::resizeEvent(QResizeEvent*)
01223 {
01224   int x = frameWidth();
01225   int s = KDialog::spacingHint();
01226   int h = fontMetrics().lineSpacing();
01227   int w = width() - 2*x;
01228   int y = x;
01229 
01230   name->setGeometry( x, y, w, h );
01231   y += h + s;
01232   email->setGeometry( x+s, y, w-s, h );
01233   y += h + s;
01234   url->setGeometry( x+s, y, w-s, h );
01235 
01236   /*
01237   int x = frameWidth() + KDialog::spacingHint();
01238   int y = x;
01239   int w = width() - 2*x;
01240   int h = name->sizeHint().height();
01241   int s = 3;
01242 
01243   name->setGeometry( x, y, w, h );
01244   y += h + s;
01245   email->setGeometry( x+WORKTEXT_IDENTATION, y, w-WORKTEXT_IDENTATION, h );
01246   y += h + s;
01247   url->setGeometry( x+WORKTEXT_IDENTATION, y, w-WORKTEXT_IDENTATION, h );
01248   //
01249   // the work text is drawn in the paint event
01250   //
01251   */
01252 }
01253 
01254 
01255 
01256 void KAboutContributor::paintEvent( QPaintEvent *e )
01257 {
01258   QFrame::paintEvent(e);
01259   if(work.isEmpty()) return;
01260 
01261   int x = frameWidth() + KDialog::spacingHint();
01262   int h = fontMetrics().lineSpacing();
01263   int y = height() - frameWidth() - fontMetrics().lineSpacing();
01264   int w = width() - frameWidth()*2 - KDialog::spacingHint();
01265 
01266   QPainter paint( this );
01267   paint.drawText( x, y, w, h, AlignLeft | WordBreak, work );
01268 
01269   /*
01270 
01271   int s = 3;
01272   int x = frameWidth() + KDialog::spacingHint() + WORKTEXT_IDENTATION;
01273   int w = width()-WORKTEXT_IDENTATION-2*(frameWidth()+KDialog::spacingHint());
01274   int y = frameWidth()+KDialog::spacingHint()+(name->sizeHint().height()+s)*3;
01275   int h = height()-y-frameWidth();
01276 
01277   QPainter paint( this );
01278   paint.drawText( x, y, w, h, AlignLeft | WordBreak, work );
01279   */
01280 }
01281 #endif
01282 
01283 
01284 
01285 
01286 
01287 
01288 KAboutWidget::KAboutWidget(QWidget *_parent, const char *_name)
01289   : QWidget(_parent, _name),
01290     version(new QLabel(this)),
01291     cont(new QLabel(this)),
01292     logo(new QLabel(this)),
01293     author(new KAboutContributor(this)),
01294     maintainer(new KAboutContributor(this)),
01295     showMaintainer(false)
01296 {
01297   // #################################################################
01298   if( version==0 || cont==0 || logo==0 || author==0 || maintainer==0 )
01299   {
01300     // this will nearly never happen (out of memory in about box?)
01301     kdDebug() << "KAboutWidget::KAboutWidget: Out of memory." << endl;
01302     qApp->quit();
01303   }
01304   // -----
01305   cont->setText(i18n("Other Contributors:"));
01306   logo->setText(i18n("(No logo available)"));
01307   logo->setFrameStyle(QFrame::Panel | QFrame::Raised);
01308   version->setAlignment(AlignCenter);
01309   // -----
01310   connect(author, SIGNAL(sendEmail(const QString&, const QString&)),
01311       SLOT(sendEmailSlot(const QString&, const QString&)));
01312   connect(author, SIGNAL(openURL(const QString&)),
01313       SLOT(openURLSlot(const QString&)));
01314   connect(maintainer, SIGNAL(sendEmail(const QString&, const QString&)),
01315       SLOT(sendEmailSlot(const QString&, const QString&)));
01316   connect(maintainer, SIGNAL(openURL(const QString&)),
01317       SLOT(openURLSlot(const QString&)));
01318   // #################################################################
01319 }
01320 
01321 
01322 void
01323 KAboutWidget::adjust()
01324 {
01325   // #################################################################
01326   int cx, cy, tempx;
01327   int maintWidth, maintHeight;
01328   QSize total_size;
01329   // -----
01330   if(showMaintainer)
01331     {
01332       total_size=maintainer->sizeHint();
01333       maintWidth=total_size.width();
01334       maintHeight=total_size.height();
01335     } else {
01336       maintWidth=0;
01337       maintHeight=0;
01338     }
01339   total_size=author->sizeHint();
01340   logo->adjustSize();
01341   cy=version->sizeHint().height()+Grid;
01342   cx=logo->width();
01343   tempx=QMAX(total_size.width(), maintWidth);
01344   cx+=Grid+tempx;
01345   cx=QMAX(cx, version->sizeHint().width());
01346   cy+=QMAX(logo->height(),
01347        total_size.height()+(showMaintainer ? Grid+maintHeight : 0));
01348   // -----
01349   if(!contributors.isEmpty())
01350     {
01351       cx=QMAX(cx, cont->sizeHint().width());
01352       cy+=cont->sizeHint().height()+Grid;
01353       QPtrListIterator<KAboutContributor> _pos(contributors);
01354       for( ; _pos.current(); ++_pos)
01355     {
01356       cy+=_pos.current()->sizeHint().height();
01357     }
01358     }
01359   // -----
01360   setMinimumSize(cx, cy);
01361   // #################################################################
01362 }
01363 
01364 void
01365 KAboutWidget::setLogo(const QPixmap& i)
01366 {
01367   // ############################################################################
01368   logo->setPixmap(i);
01369   // ############################################################################
01370 }
01371 
01372 void KAboutWidget::sendEmailSlot(const QString &_name, const QString &_email)
01373 {
01374   emit(sendEmail(_name, _email));
01375 }
01376 
01377 void KAboutWidget::openURLSlot(const QString& _url)
01378 {
01379   emit(openURL(_url));
01380 }
01381 
01382 void
01383 KAboutWidget::setAuthor(const QString &_name, const QString &_email,
01384             const QString &_url, const QString &_w)
01385 {
01386   // ############################################################################
01387   author->setName(_name);
01388   author->setEmail(_email);
01389   author->setURL(_url);
01390   author->setWork(_w);
01391   // ############################################################################
01392 }
01393 
01394 void
01395 KAboutWidget::setMaintainer(const QString &_name, const QString &_email,
01396                 const QString &_url, const QString &_w)
01397 {
01398   // ############################################################################
01399   maintainer->setName(_name);
01400   maintainer->setEmail(_email);
01401   maintainer->setWork(_w);
01402   maintainer->setURL(_url);
01403   showMaintainer=true;
01404   // ############################################################################
01405 }
01406 
01407 void
01408 KAboutWidget::addContributor(const QString &_name, const QString &_email,
01409                  const QString &_url, const QString &_w)
01410 {
01411   // ############################################################################
01412   KAboutContributor *c=new KAboutContributor(this);
01413   // -----
01414   c->setName(_name);
01415   c->setEmail(_email);
01416   c->setURL(_url);
01417   c->setWork(_w);
01418   contributors.append(c);
01419   connect(c, SIGNAL(sendEmail(const QString&, const QString&)),
01420       SLOT(sendEmailSlot(const QString&, const QString&)));
01421   connect(c, SIGNAL(openURL(const QString&)), SLOT(openURLSlot(const QString&)));
01422   // ############################################################################
01423 }
01424 
01425 void
01426 KAboutWidget::setVersion(const QString &_name)
01427 {
01428   // ############################################################################
01429   version->setText(_name);
01430   // ############################################################################
01431 }
01432 
01433 void
01434 KAboutWidget::resizeEvent(QResizeEvent*)
01435 {
01436   // ############################################################################
01437   int _x=0, _y, cx, tempx, tempy;
01438   // ----- set version label geometry:
01439   version->setGeometry(0, 0, width(), version->sizeHint().height());
01440   _y=version->height()+Grid;
01441   // ----- move logo to correct position:
01442   logo->adjustSize();
01443   logo->move(0, _y);
01444   // ----- move author and maintainer right to it:
01445   tempx=logo->width()+Grid;
01446   cx=width()-tempx;
01447   author->setGeometry
01448     (tempx, _y, cx, author->sizeHint().height());
01449   maintainer->setGeometry
01450     (tempx, _y+author->height()+Grid, cx, maintainer->sizeHint().height());
01451 
01452   _y+=QMAX(logo->height(),
01453       author->height()+(showMaintainer ? Grid+maintainer->height() : 0));
01454   // -----
01455   if(!contributors.isEmpty())
01456     {
01457       tempy=cont->sizeHint().height();
01458       cont->setGeometry(0, _y, width(), tempy);
01459       cont->show();
01460       _y+=tempy+Grid;
01461     } else {
01462       cont->hide();
01463     }
01464 
01465   for(QPtrListIterator<KAboutContributor> _pos(contributors); _pos.current(); ++_pos)
01466     {
01467       tempy=_pos.current()->sizeHint().height();
01468       // y+=Grid;
01469       _pos.current()->setGeometry(_x, _y, width(), tempy);
01470       _y+=tempy;
01471     }
01472   if(showMaintainer)
01473     {
01474       maintainer->show();
01475     } else {
01476       maintainer->hide();
01477     }
01478   // ############################################################################
01479 }
01480 
01481 KAboutDialog::KAboutDialog(QWidget *_parent, const char *_name, bool modal)
01482   : KDialogBase(_parent, _name, modal, QString::null, Ok, Ok ),
01483     about(new KAboutWidget(this)), mContainerBase(0)
01484 {
01485   // #################################################################
01486   if(about==0)
01487   {
01488     // this will nearly never happen (out of memory in about box?)
01489     kdDebug() << "KAboutDialog::KAboutDialog: Out of memory." << endl;
01490     qApp->quit();
01491   }
01492   setMainWidget(about);
01493   connect(about, SIGNAL(sendEmail(const QString&, const QString&)),
01494       SLOT(sendEmailSlot(const QString&, const QString&)));
01495   connect(about, SIGNAL(openURL(const QString&)),
01496       SLOT(openURLSlot(const QString&)));
01497   // #################################################################
01498 }
01499 
01500 
01501 KAboutDialog::KAboutDialog( int layoutType, const QString &_caption,
01502                 int buttonMask, ButtonCode defaultButton,
01503                 QWidget *_parent, const char *_name, bool modal,
01504                 bool separator, const QString &user1,
01505                 const QString &user2, const QString &user3 )
01506   :KDialogBase( _parent, _name, modal, QString::null, buttonMask, defaultButton,
01507         separator, user1, user2, user3 ),
01508    about(0)
01509 {
01510   setPlainCaption( i18n("About %1").arg(_caption) );
01511 
01512   mContainerBase = new KAboutContainerBase( layoutType, this );
01513   setMainWidget(mContainerBase);
01514 
01515   connect( mContainerBase, SIGNAL(urlClick(const QString &)),
01516        this, SLOT(openURLSlot(const QString &)));
01517   connect( mContainerBase, SIGNAL(mailClick(const QString &,const QString &)),
01518        this, SLOT(sendEmailSlot(const QString &,const QString &)));
01519   connect( mContainerBase, SIGNAL(mouseTrack(int, const QMouseEvent *)),
01520        this, SLOT(mouseTrackSlot(int, const QMouseEvent *)));
01521 }
01522 
01523 
01524 void KAboutDialog::show( void )
01525 {
01526   adjust();
01527   if( mContainerBase != 0 ) { mContainerBase->show(); }
01528   QDialog::show();
01529 }
01530 
01531 
01532 void KAboutDialog::show( QWidget */*centerParent*/ )
01533 {
01534   adjust();
01535   if( mContainerBase != 0 ) { mContainerBase->show(); }
01536   QDialog::show();
01537 }
01538 
01539 
01540 void KAboutDialog::adjust()
01541 {
01542   if( about == 0 ) { return; }
01543   about->adjust();
01544   //initializeGeometry();
01545   resize( sizeHint() );
01546 }
01547 
01548 
01549 void KAboutDialog::setLogo(const QPixmap& i)
01550 {
01551   if( about == 0 ) { return; }
01552   about->setLogo(i);
01553 }
01554 
01555 
01556 void KAboutDialog::setMaintainer(const QString &_name, const QString &_email,
01557                  const QString &_url, const QString &_w)
01558 {
01559   // #################################################################
01560   if( about == 0 ) { return; }
01561   about->setMaintainer(_name, _email, _url, _w);
01562   // #################################################################
01563 }
01564 
01565 void KAboutDialog::setAuthor(const QString &_name, const QString &_email,
01566                  const QString &_url, const QString &_work)
01567 {
01568   // #################################################################
01569   if( about == 0 ) { return; }
01570   about->setAuthor(_name, _email, _url, _work);
01571   // #################################################################
01572 }
01573 
01574 void KAboutDialog::addContributor(const QString &_name, const QString &_email,
01575                   const QString &_url, const QString &_w)
01576 {
01577   // #################################################################
01578   if( about == 0 ) { return; }
01579   about->addContributor(_name, _email, _url, _w);
01580   // #################################################################
01581 }
01582 
01583 void KAboutDialog::setVersion(const QString &_name)
01584 {
01585   // #################################################################
01586   if( about == 0 ) { return; }
01587   about->setVersion(_name);
01588   // #################################################################
01589 }
01590 
01591 void KAboutDialog::sendEmailSlot(const QString& /*name*/, const QString& email)
01592 {
01593   if ( kapp )
01594       kapp->invokeMailer( email, QString::null );
01595   /*
01596   kdDebug() << "KAboutDialog::sendEmailSlot: request to send an email to "
01597     << name << ", " << email << endl;
01598   emit(sendEmail(name, email));
01599   */
01600 }
01601 
01602 void KAboutDialog::openURLSlot(const QString& url)
01603 {
01604   if ( kapp )
01605       kapp->invokeBrowser( url );
01606   //kdDebug() << "KAboutDialog::openURLSlot: request to open URL " << url << endl;
01607   //emit(openURL(url));
01608 }
01609 
01610 
01611 void KAboutDialog::mouseTrackSlot( int /*mode*/, const QMouseEvent */*e*/ )
01612 {
01613   // By default we do nothing. This method must be reimplemented.
01614 }
01615 
01616 
01617 QFrame *KAboutDialog::addTextPage( const QString &title, const QString &text,
01618                    bool richText, int numLines )
01619 {
01620   if( mContainerBase == 0 ) { return( 0 ); }
01621   return( mContainerBase->addTextPage( title, text, richText, numLines ) );
01622 }
01623 
01624 QFrame *KAboutDialog::addLicensePage( const QString &title, const QString &text,
01625                    int numLines )
01626 {
01627   if( mContainerBase == 0 ) { return( 0 ); }
01628   return( mContainerBase->addLicensePage( title, text, numLines ) );
01629 }
01630 
01631 
01632 KAboutContainer *KAboutDialog::addContainerPage( const QString &title,
01633                   int childAlignment, int innerAlignment )
01634 {
01635   if( mContainerBase == 0 ) { return( 0 ); }
01636   return( mContainerBase->addContainerPage( title, childAlignment,
01637                         innerAlignment) );
01638 }
01639 
01640 
01641 KAboutContainer *KAboutDialog::addScrolledContainerPage( const QString &title,
01642                   int childAlignment, int innerAlignment )
01643 {
01644   if( mContainerBase == 0 ) { return( 0 ); }
01645   return( mContainerBase->addScrolledContainerPage( title, childAlignment,
01646                             innerAlignment) );
01647 }
01648 
01649 
01650 
01651 QFrame *KAboutDialog::addPage( const QString &title )
01652 {
01653   if( mContainerBase == 0 ) { return( 0 ); }
01654   return( mContainerBase->addEmptyPage( title ) );
01655 }
01656 
01657 
01658 KAboutContainer *KAboutDialog::addContainer( int childAlignment,
01659                          int innerAlignment )
01660 {
01661   if( mContainerBase == 0 ) { return( 0 ); }
01662   return( mContainerBase->addContainer( childAlignment, innerAlignment ) );
01663 }
01664 
01665 
01666 void KAboutDialog::setTitle( const QString &title )
01667 {
01668   if( mContainerBase == 0 ) { return; }
01669   mContainerBase->setTitle( title );
01670 }
01671 
01672 
01673 void KAboutDialog::setImage( const QString &fileName )
01674 {
01675   if( mContainerBase == 0 ) { return; }
01676   mContainerBase->setImage( fileName );
01677 }
01678 
01679 
01680 void KAboutDialog::setImageBackgroundColor( const QColor &color )
01681 {
01682   if( mContainerBase == 0 ) { return; }
01683   mContainerBase->setImageBackgroundColor( color );
01684 }
01685 
01686 
01687 void KAboutDialog::setImageFrame( bool state )
01688 {
01689   if( mContainerBase == 0 ) { return; }
01690   mContainerBase->setImageFrame( state );
01691 }
01692 
01693 
01694 void KAboutDialog::setProduct( const QString &appName, const QString &version,
01695                    const QString &author, const QString &year )
01696 {
01697   if( mContainerBase == 0 ) { return; }
01698   mContainerBase->setProduct( appName, version, author, year );
01699 }
01700 
01701 
01702 
01703 void KAboutDialog::imageURL( QWidget *_parent, const QString &_caption,
01704                  const QString &_path, const QColor &_imageColor,
01705                  const QString &_url )
01706 {
01707   KAboutDialog a( AbtImageOnly, QString::null, Close, Close, _parent, "image", true );
01708   a.setPlainCaption( _caption );
01709   a.setImage( _path );
01710   a.setImageBackgroundColor( _imageColor );
01711 
01712   KAboutContainer *c = a.addContainer( AlignCenter, AlignCenter );
01713   if( c != 0 )
01714   {
01715     c->addPerson( QString::null, QString::null, _url, QString::null );
01716   }
01717   a.exec();
01718 }
01719 
01720 
01721 
01722 
01723 //
01724 // A class that can can monitor mouse movements on the image
01725 //
01726 KImageTrackLabel::KImageTrackLabel( QWidget *_parent, const char *_name, WFlags f )
01727   : QLabel( _parent, _name, f )
01728 {
01729   setText( i18n("Image missing"));
01730 }
01731 
01732 void KImageTrackLabel::mousePressEvent( QMouseEvent *e )
01733 {
01734   emit mouseTrack( MousePress, e );
01735 }
01736 
01737 void KImageTrackLabel::mouseReleaseEvent( QMouseEvent *e )
01738 {
01739   emit mouseTrack( MouseRelease, e );
01740 }
01741 
01742 void KImageTrackLabel::mouseDoubleClickEvent( QMouseEvent *e )
01743 {
01744   emit mouseTrack( MouseDoubleClick, e );
01745 }
01746 
01747 void KImageTrackLabel::mouseMoveEvent ( QMouseEvent *e )
01748 {
01749   emit mouseTrack( MouseDoubleClick, e );
01750 }
01751 
01752 void KAboutDialog::virtual_hook( int id, void* data )
01753 { KDialogBase::virtual_hook( id, data ); }
01754 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:01 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001