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., 51 Franklin Street, Fifth Floor,
00019  *  Boston, MA 02110-1301, 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 //MOC_SKIP_BEGIN
00045 template class QPtrList<KAboutContributor>;
00046 //MOC_SKIP_END
00047 
00048 #define WORKTEXT_IDENTATION 16
00049 #define Grid 3
00050 
00051 // ##############################################################
00052 // MOC OUTPUT FILES:
00053 #include "kaboutdialog.moc"
00054 #include "kaboutdialog_private.moc"
00055 // ##############################################################
00056 
00057 class KAboutTabWidget : public QTabWidget
00058 {
00059 public:
00060     KAboutTabWidget( QWidget* parent ) : QTabWidget( parent ) {}
00061     QSize sizeHint() const {
00062     return QTabWidget::sizeHint().expandedTo( tabBar()->sizeHint() + QSize(4,4) );
00063     }
00064 };
00065 
00066 
00067 
00068 
00069 KAboutContributor::KAboutContributor( QWidget *_parent, const char *wname,
00070                           const QString &_name,const QString &_email,
00071                           const QString &_url, const QString &_work,
00072                           bool showHeader, bool showFrame,
00073                       bool showBold )
00074   : QFrame( _parent, wname ), mShowHeader(showHeader), mShowBold(showBold), d(0)
00075 {
00076   if( showFrame )
00077   {
00078     setFrameStyle(QFrame::Panel | QFrame::Raised);
00079   }
00080 
00081   mLabel[0] = new QLabel( this );
00082   mLabel[1] = new QLabel( this );
00083   mLabel[2] = new QLabel( this );
00084   mLabel[3] = new QLabel( this );
00085   mText[0] = new QLabel( this );
00086   mText[1] = new KURLLabel( this );
00087   mText[2] = new KURLLabel( this );
00088   mText[3] = new QLabel( this );
00089 
00090   setName( _name, i18n("Author"), false );
00091   setEmail( _email, i18n("Email"), false );
00092   setURL( _url, i18n("Homepage"), false );
00093   setWork( _work, i18n("Task"), false );
00094 
00095   KURLLabel *kurl = static_cast<KURLLabel *>(mText[1]);
00096   kurl->setFloat(true);
00097   kurl->setUnderline(true);
00098   kurl->setMargin(0);
00099   connect(kurl, SIGNAL(leftClickedURL(const QString &)),
00100       SLOT(emailClickedSlot(const QString &)));
00101 
00102   kurl = static_cast<KURLLabel *>(mText[2]);
00103   kurl->setFloat(true);
00104   kurl->setUnderline(true);
00105   kurl->setMargin(0);
00106   connect(kurl, SIGNAL(leftClickedURL(const QString &)),
00107       SLOT(urlClickedSlot(const QString &)));
00108 
00109   mLabel[3]->setAlignment( AlignTop );
00110 
00111   fontChange( font() );
00112   updateLayout();
00113 }
00114 
00115 
00116 void KAboutContributor::setName( const QString &_text, const QString &_header,
00117                  bool _update )
00118 {
00119   mLabel[0]->setText(_header);
00120   mText[0]->setText(_text);
00121   if( _update ) { updateLayout(); }
00122 }
00123 
00124 
00125 void KAboutContributor::setEmail( const QString &_text, const QString &_header,
00126                   bool _update )
00127 {
00128   mLabel[1]->setText(_header);
00129   KURLLabel* const kurl = static_cast<KURLLabel *>(mText[1]);
00130   kurl->setText(_text);
00131   kurl->setURL(_text);
00132   if( _update ) { updateLayout(); }
00133 }
00134 
00135 
00136 void KAboutContributor::setURL( const QString &_text, const QString &_header,
00137                 bool _update )
00138 {
00139   mLabel[2]->setText(_header);
00140   KURLLabel* const kurl = static_cast<KURLLabel *>(mText[2]);
00141   kurl->setText(_text);
00142   kurl->setURL(_text);
00143   if( _update ) { updateLayout(); }
00144 }
00145 
00146 
00147 void KAboutContributor::setWork( const QString &_text, const QString &_header,
00148                  bool _update )
00149 {
00150   mLabel[3]->setText(_header);
00151   mText[3]->setText(_text);
00152   if( _update ) { updateLayout(); }
00153 }
00154 
00155 
00156 QString KAboutContributor::getName( void ) const
00157 {
00158   return mText[0]->text();
00159 }
00160 
00161 
00162 QString KAboutContributor::getEmail( void ) const
00163 {
00164   return mText[1]->text();
00165 }
00166 
00167 
00168 QString KAboutContributor::getURL( void ) const
00169 {
00170   return mText[2]->text();
00171 }
00172 
00173 
00174 QString KAboutContributor::getWork( void ) const
00175 {
00176   return mText[3]->text();
00177 }
00178 
00179 
00180 
00181 void KAboutContributor::updateLayout( void )
00182 {
00183   delete layout();
00184 
00185   int row = 0;
00186   if( !mText[0]->text().isEmpty() ) { ++row; }
00187   if( !mText[1]->text().isEmpty() ) { ++row; }
00188   if( !mText[2]->text().isEmpty() ) { ++row; }
00189   if( !mText[3]->text().isEmpty() ) { ++row; }
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 )
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 )
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 )
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 )
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 )
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),d(0)
00301 {
00302   mTopLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
00303   if( !mTopLayout ) { 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* const productArea = new  QWidget( this, "area" );
00325     mTopLayout->addWidget( productArea, 0, QApplication::reverseLayout() ? AlignRight : AlignLeft );
00326 
00327     QHBoxLayout* const hbox = new QHBoxLayout(productArea,0,KDialog::spacingHint());
00328     if( !hbox ) { return; }
00329 
00330     mIconLabel = new QLabel( productArea );
00331     hbox->addWidget( mIconLabel, 0, AlignLeft|AlignHCenter );
00332 
00333     QVBoxLayout* const vbox = new QVBoxLayout();
00334     if( !vbox ) { 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* const hbox = new QHBoxLayout();
00347   if( !hbox ) { 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 ) { 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* const 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 ) { 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 )
00438   {
00439     QFont f( KGlobalSettings::generalFont() );
00440     f.setBold( true );
00441     int fs = f.pointSize();
00442     if (fs == -1)
00443        fs = QFontInfo(f).pointSize();
00444     f.setPointSize( fs+2 ); // Lets not make it too big
00445     mTitleLabel->setFont(f);
00446   }
00447 
00448   if( mVersionLabel )
00449   {
00450     QFont f( KGlobalSettings::generalFont() );
00451     f.setBold( true );
00452     mVersionLabel->setFont(f);
00453     mAuthorLabel->setFont(f);
00454     mVersionLabel->parentWidget()->layout()->activate();
00455   }
00456 
00457   update();
00458 }
00459 
00460 QFrame *KAboutContainerBase::addTextPage( const QString &title,
00461                       const QString &text,
00462                       bool richText, int numLines )
00463 {
00464   QFrame* const page = addEmptyPage( title );
00465   if( !page ) { return 0; }
00466   if( numLines <= 0 ) { numLines = 10; }
00467 
00468   QVBoxLayout* const vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00469 
00470   if( richText )
00471   {
00472     KTextBrowser* const browser = new KTextBrowser( page, "browser" );
00473     browser->setHScrollBarMode( QScrollView::AlwaysOff );
00474     browser->setText( text );
00475     browser->setMinimumHeight( fontMetrics().lineSpacing()*numLines );
00476 
00477     vbox->addWidget(browser);
00478     connect(browser, SIGNAL(urlClick(const QString &)),
00479         SLOT(slotUrlClick(const QString &)));
00480     connect(browser, SIGNAL(mailClick(const QString &,const QString &)),
00481         SLOT(slotMailClick(const QString &,const QString &)));
00482   }
00483   else
00484   {
00485     KTextEdit* const textEdit = new KTextEdit( page, "text" );
00486     textEdit->setReadOnly( true );
00487     textEdit->setMinimumHeight( fontMetrics().lineSpacing()*numLines );
00488     textEdit->setWordWrap( QTextEdit::NoWrap );
00489     vbox->addWidget( textEdit );
00490   }
00491 
00492   return page;
00493 }
00494 
00495 QFrame *KAboutContainerBase::addLicensePage( const QString &title,
00496                       const QString &text, int numLines)
00497 {
00498   QFrame* const page = addEmptyPage( title );
00499   if( !page ) { return 0; }
00500   if( numLines <= 0 ) { numLines = 10; }
00501 
00502   QVBoxLayout* const vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00503 
00504   KTextEdit* const textEdit = new KTextEdit( page, "license" );
00505   textEdit->setFont( KGlobalSettings::fixedFont() );
00506   textEdit->setReadOnly( true );
00507   textEdit->setWordWrap( QTextEdit::NoWrap );
00508   textEdit->setText( text );
00509   textEdit->setMinimumHeight( fontMetrics().lineSpacing()*numLines );
00510   vbox->addWidget( textEdit );
00511   return page;
00512 }
00513 
00514 
00515 KAboutContainer *KAboutContainerBase::addContainerPage( const QString &title,
00516                             int childAlignment,
00517                             int innerAlignment )
00518 {
00519   if( !mPageTab )
00520   {
00521     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00522     return 0;
00523   }
00524 
00525   KAboutContainer* const container = new KAboutContainer( mPageTab, "container",
00526     KDialog::spacingHint(), KDialog::spacingHint(), childAlignment,
00527                           innerAlignment );
00528   mPageTab->addTab( container, title );
00529 
00530   connect(container, SIGNAL(urlClick(const QString &)),
00531       SLOT(slotUrlClick(const QString &)));
00532   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00533       SLOT(slotMailClick(const QString &,const QString &)));
00534 
00535   return container;
00536 }
00537 
00538 
00539 KAboutContainer *KAboutContainerBase::addScrolledContainerPage(
00540                       const QString &title,
00541                       int childAlignment,
00542                       int innerAlignment )
00543 {
00544   if( !mPageTab )
00545   {
00546     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00547     return 0;
00548   }
00549 
00550   QFrame* const page = addEmptyPage( title );
00551   QVBoxLayout* const vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00552   QScrollView* const scrollView = new QScrollView( page );
00553   scrollView->viewport()->setBackgroundMode( PaletteBackground );
00554   vbox->addWidget( scrollView );
00555 
00556   KAboutContainer* const container = new KAboutContainer( scrollView, "container",
00557     KDialog::spacingHint(), KDialog::spacingHint(), childAlignment,
00558     innerAlignment );
00559   scrollView->addChild( container );
00560 
00561 
00562   connect(container, SIGNAL(urlClick(const QString &)),
00563       SLOT(slotUrlClick(const QString &)));
00564   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00565       SLOT(slotMailClick(const QString &,const QString &)));
00566 
00567   return container;
00568 }
00569 
00570 
00571 QFrame *KAboutContainerBase::addEmptyPage( const QString &title )
00572 {
00573   if( !mPageTab )
00574   {
00575     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00576     return 0;
00577   }
00578 
00579   QFrame* const page = new QFrame( mPageTab, title.latin1() );
00580   page->setFrameStyle( QFrame::NoFrame );
00581 
00582   mPageTab->addTab( page, title );
00583   return page;
00584 }
00585 
00586 
00587 KAboutContainer *KAboutContainerBase::addContainer( int childAlignment,
00588                             int innerAlignment )
00589 {
00590   KAboutContainer* const container = new KAboutContainer( this, "container",
00591     0, KDialog::spacingHint(), childAlignment, innerAlignment );
00592   mTopLayout->addWidget( container, 0, childAlignment );
00593 
00594   connect(container, SIGNAL(urlClick(const QString &)),
00595       SLOT(slotUrlClick(const QString &)));
00596   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00597       SLOT(slotMailClick(const QString &,const QString &)));
00598 
00599   return container;
00600 }
00601 
00602 
00603 
00604 void KAboutContainerBase::setTitle( const QString &title )
00605 {
00606   if( !mTitleLabel )
00607   {
00608     kdDebug(291) << "setTitle: " << "Invalid layout" << endl;
00609     return;
00610   }
00611   mTitleLabel->setText(title);
00612 }
00613 
00614 
00615 void KAboutContainerBase::setImage( const QString &fileName )
00616 {
00617   if( !mImageLabel )
00618   {
00619     kdDebug(291) << "setImage: " << "Invalid layout" << endl;
00620     return;
00621   }
00622   if( fileName.isNull() )
00623   {
00624     return;
00625   }
00626 
00627   const QPixmap logo( fileName );
00628   if( !logo.isNull() )
00629     mImageLabel->setPixmap( logo );
00630 
00631   mImageFrame->layout()->activate();
00632 }
00633 
00634 void KAboutContainerBase::setProgramLogo( const QString &fileName )
00635 {
00636   if( fileName.isNull() )
00637   {
00638     return;
00639   }
00640 
00641   const QPixmap logo( fileName );
00642   setProgramLogo( logo );
00643 }
00644 
00645 void KAboutContainerBase::setProgramLogo( const QPixmap &pixmap )
00646 {
00647   if( !mIconLabel )
00648   {
00649     kdDebug(291) << "setProgramLogo: " << "Invalid layout" << endl;
00650     return;
00651   }
00652   if( !pixmap.isNull() )
00653   {
00654     mIconLabel->setPixmap( pixmap );
00655   }
00656 }
00657 
00658 void KAboutContainerBase::setImageBackgroundColor( const QColor &color )
00659 {
00660   if( mImageFrame )
00661   {
00662     mImageFrame->setBackgroundColor( color );
00663   }
00664 }
00665 
00666 
00667 void KAboutContainerBase::setImageFrame( bool state )
00668 {
00669   if( mImageFrame )
00670   {
00671     if( state )
00672     {
00673       mImageFrame->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00674       mImageFrame->setLineWidth(1);
00675     }
00676     else
00677     {
00678       mImageFrame->setFrameStyle( QFrame::NoFrame );
00679       mImageFrame->setLineWidth(0);
00680     }
00681   }
00682 }
00683 
00684 
00685 void KAboutContainerBase::setProduct( const QString &appName,
00686                       const QString &version,
00687                       const QString &author,
00688                       const QString &year )
00689 {
00690   if( !mIconLabel )
00691   {
00692     kdDebug(291) << "setProduct: " << "Invalid layout" << endl;
00693     return;
00694   }
00695 
00696   if ( kapp )
00697   {
00698     mIconLabel->setPixmap( kapp->icon() );
00699     kdDebug(291) << "setPixmap (iconName): " << kapp->iconName() << endl;
00700   }
00701   else
00702     kdDebug(291) << "no kapp" << endl;
00703 
00704   const QString msg1 = i18n("%1 %2 (Using KDE %3)").arg(appName).arg(version).
00705     arg(QString::fromLatin1(KDE_VERSION_STRING));
00706   const QString msg2 = !year.isEmpty() ? i18n("%1 %2, %3").arg('©').arg(year).
00707     arg(author) : QString::fromLatin1("");
00708 
00709   //if (!year.isEmpty())
00710   //  msg2 = i18n("%1 %2, %3").arg('©').arg(year).arg(author);
00711 
00712   mVersionLabel->setText( msg1 );
00713   mAuthorLabel->setText( msg2 );
00714   if( msg2.isEmpty() )
00715   {
00716     mAuthorLabel->hide();
00717   }
00718 
00719   mIconLabel->parentWidget()->layout()->activate();
00720 }
00721 
00722 
00723 void KAboutContainerBase::slotMouseTrack( int mode, const QMouseEvent *e )
00724 {
00725   emit mouseTrack( mode, e );
00726 }
00727 
00728 
00729 void KAboutContainerBase::slotUrlClick( const QString &url )
00730 {
00731   emit urlClick( url );
00732 }
00733 
00734 void KAboutContainerBase::slotMailClick( const QString &_name,
00735                      const QString &_address )
00736 {
00737   emit mailClick( _name, _address );
00738 }
00739 
00740 
00741 
00742 KAboutContainer::KAboutContainer( QWidget *_parent, const char *_name,
00743                   int _margin, int _spacing,
00744                   int childAlignment, int innerAlignment )
00745   : QFrame( _parent, _name ), d(0)
00746 {
00747   mAlignment = innerAlignment;
00748 
00749   QGridLayout* const gbox = new QGridLayout( this, 3, 3, _margin, _spacing );
00750   if( childAlignment & AlignHCenter )
00751   {
00752     gbox->setColStretch( 0, 10 );
00753     gbox->setColStretch( 2, 10 );
00754   }
00755   else if( childAlignment & AlignRight )
00756   {
00757     gbox->setColStretch( 0, 10 );
00758   }
00759   else
00760   {
00761     gbox->setColStretch( 2, 10 );
00762   }
00763 
00764   if( childAlignment & AlignVCenter )
00765   {
00766     gbox->setRowStretch( 0, 10 );
00767     gbox->setRowStretch( 2, 10 );
00768   }
00769   else if( childAlignment & AlignRight )
00770   {
00771     gbox->setRowStretch( 0, 10 );
00772   }
00773   else
00774   {
00775     gbox->setRowStretch( 2, 10 );
00776   }
00777 
00778   mVbox = new QVBoxLayout( _spacing );
00779   gbox->addLayout( mVbox, 1, 1 );
00780   gbox->activate();
00781 }
00782 
00783 
00784 void KAboutContainer::childEvent( QChildEvent *e )
00785 {
00786   if( !e->inserted() || !e->child()->isWidgetType() )
00787   {
00788     return;
00789   }
00790 
00791   QWidget* const w = static_cast<QWidget *>(e->child());
00792   mVbox->addWidget( w, 0, mAlignment );
00793   const QSize s( sizeHint() );
00794   setMinimumSize( s );
00795 
00796   QObjectList* const l = const_cast<QObjectList *>(children()); // silence please
00797   QObjectListIterator itr( *l );
00798   QObject * o;
00799   while ( (o = itr.current()) ) {
00800     ++itr;
00801     if( o->isWidgetType() )
00802     {
00803         static_cast<QWidget *>(o)->setMinimumWidth( s.width() );
00804     }
00805   }
00806 }
00807 
00808 
00809 QSize KAboutContainer::sizeHint( void ) const
00810 {
00811   //
00812   // The size is computed by adding the sizeHint().height() of all
00813   // widget children and taking the width of the widest child and adding
00814   // layout()->margin() and layout()->spacing()
00815   //
00816 
00817   QSize total_size;
00818 
00819   int numChild = 0;
00820   QObjectList* const l = const_cast<QObjectList *>(children()); // silence please
00821 
00822   QObjectListIterator itr( *l );
00823   QObject * o;
00824   while ( (o = itr.current()) ) {
00825     ++itr;
00826     if( o->isWidgetType() )
00827     {
00828       ++numChild;
00829       QWidget* const w= static_cast<QWidget *>(o);
00830 
00831       QSize s = w->minimumSize();
00832       if( s.isEmpty() )
00833       {
00834     s = w->minimumSizeHint();
00835     if( s.isEmpty() )
00836     {
00837       s = w->sizeHint();
00838       if( s.isEmpty() )
00839       {
00840         s = QSize( 100, 100 ); // Default size
00841       }
00842     }
00843       }
00844       total_size.setHeight( total_size.height() + s.height() );
00845       if( s.width() > total_size.width() ) { total_size.setWidth( s.width() ); }
00846     }
00847   }
00848 
00849   if( numChild > 0 )
00850   {
00851     //
00852     // Seems I have to add 1 to the height to properly show the border
00853     // of the last entry if layout()->margin() is 0
00854     //
00855 
00856     total_size.setHeight( total_size.height() + layout()->spacing()*(numChild-1) );
00857     total_size += QSize( layout()->margin()*2, layout()->margin()*2 + 1 );
00858   }
00859   else
00860   {
00861     total_size = QSize( 1, 1 );
00862   }
00863   return total_size;
00864 }
00865 
00866 
00867 QSize KAboutContainer::minimumSizeHint( void ) const
00868 {
00869   return sizeHint();
00870 }
00871 
00872 
00873 void KAboutContainer::addWidget( QWidget *widget )
00874 {
00875   widget->reparent( this, 0, QPoint(0,0) );
00876 }
00877 
00878 
00879 void KAboutContainer::addPerson( const QString &_name, const QString &_email,
00880                  const QString &_url, const QString &_task,
00881                  bool showHeader, bool showFrame,bool showBold)
00882 {
00883 
00884   KAboutContributor* const cont = new KAboutContributor( this, "pers",
00885     _name, _email, _url, _task, showHeader, showFrame, showBold );
00886   connect( cont, SIGNAL( openURL(const QString&)),
00887        this, SIGNAL( urlClick(const QString &)));
00888   connect( cont, SIGNAL( sendEmail(const QString &, const QString &)),
00889        this, SIGNAL( mailClick(const QString &, const QString &)));
00890 }
00891 
00892 
00893 void KAboutContainer::addTitle( const QString &title, int alignment,
00894                 bool showFrame, bool showBold )
00895 {
00896 
00897   QLabel* const label = new QLabel( title, this, "title" );
00898   if( showBold  )
00899   {
00900     QFont labelFont( font() );
00901     labelFont.setBold( true );
00902     label->setFont( labelFont );
00903   }
00904   if( showFrame )
00905   {
00906     label->setFrameStyle(QFrame::Panel | QFrame::Raised);
00907   }
00908   label->setAlignment( alignment );
00909 }
00910 
00911 
00912 void KAboutContainer::addImage( const QString &fileName, int alignment )
00913 {
00914   if( fileName.isNull() )
00915   {
00916     return;
00917   }
00918 
00919   KImageTrackLabel* const label = new KImageTrackLabel( this, "image" );
00920   const QImage logo( fileName );
00921   if( !logo.isNull() )
00922   {
00923     QPixmap pix;
00924     pix = logo;
00925     label->setPixmap( pix );
00926   }
00927   label->setAlignment( alignment );
00928 }
00929 
00930 #if 0
00931 //MOC_SKIP_BEGIN
00932 
00938 class KAboutContributor : public QFrame
00939 {
00940   // ############################################################################
00941   Q_OBJECT
00942   // ----------------------------------------------------------------------------
00943 public:
00945   KAboutContributor(QWidget* parent=0, const char* name=0);
00947   void setName(const QString&);
00949   QString getName();
00951   void setEmail(const QString&);
00953   QString getEmail();
00955   void setURL(const QString&);
00957   QString getURL();
00960   void setWork(const QString&);
00963   QSize sizeHint();
00964   QSize minimumSizeHint(void);
00965   virtual void show( void );
00966 
00967   // ----------------------------------------------------------------------------
00968 protected:
00969   // events:
00971   void resizeEvent(QResizeEvent*);
00973   void paintEvent(QPaintEvent*);
00975   QLabel *name;
00978   KURLLabel *email;
00980   KURLLabel *url;
00982   QString work;
00983   // ----------------------------------------------------------------------------
00984 protected slots:
00986   void urlClickedSlot(const QString&);
00988   void emailClickedSlot(const QString& emailaddress);
00989   // ----------------------------------------------------------------------------
00990 signals:
00992   void sendEmail(const QString& name, const QString& email);
00994   void openURL(const QString& url);
00995   // ############################################################################
00996 };
00997 
00998 
00999 
01000 KAboutContributor::KAboutContributor(QWidget* parent, const char* n)
01001   : QFrame(parent, n),
01002     name(new QLabel(this)),
01003     email(new KURLLabel(this)),
01004     url(new KURLLabel(this))
01005 {
01006   // ############################################################
01007   if(name==0 || email==0)
01008     { // this will nearly never happen (out of memory in about box?)
01009       kdDebug() << "KAboutContributor::KAboutContributor: Out of memory." << endl;
01010       qApp->quit();
01011     }
01012   setFrameStyle(QFrame::Panel | QFrame::Raised);
01013   // -----
01014   connect(email, SIGNAL(leftClickedURL(const QString&)),
01015       SLOT(emailClickedSlot(