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, QApplication::reverseLayout() ? AlignRight : 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     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 != 0 )
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 *page = addEmptyPage( title );
00465   if( page == 0 ) { return(0); }
00466   if( numLines <= 0 ) { numLines = 10; }
00467 
00468   QVBoxLayout *vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00469 
00470   if( richText == true )
00471   {
00472     KTextBrowser *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 *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 *page = addEmptyPage( title );
00499   if( page == 0 ) { return(0); }
00500   if( numLines <= 0 ) { numLines = 10; }
00501 
00502   QVBoxLayout *vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00503 
00504   KTextEdit *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   page->setMinimumWidth( textEdit->contentsWidth ()+ textEdit->visibleWidth ());
00512   return( page );
00513 }
00514 
00515 
00516 KAboutContainer *KAboutContainerBase::addContainerPage( const QString &title,
00517                             int childAlignment,
00518                             int innerAlignment )
00519 {
00520   if( mPageTab == 0 )
00521   {
00522     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00523     return( 0 );
00524   }
00525 
00526   KAboutContainer *container = new KAboutContainer( mPageTab, "container",
00527     KDialog::spacingHint(), KDialog::spacingHint(), childAlignment,
00528                           innerAlignment );
00529   mPageTab->addTab( container, title );
00530 
00531   if( mContainerList.resize( mContainerList.size() + 1) == true )
00532   {
00533     mContainerList[ mContainerList.size()-1 ]=container;
00534   }
00535 
00536   connect(container, SIGNAL(urlClick(const QString &)),
00537       SLOT(slotUrlClick(const QString &)));
00538   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00539       SLOT(slotMailClick(const QString &,const QString &)));
00540 
00541   return( container );
00542 }
00543 
00544 
00545 KAboutContainer *KAboutContainerBase::addScrolledContainerPage(
00546                       const QString &title,
00547                       int childAlignment,
00548                       int innerAlignment )
00549 {
00550   if( mPageTab == 0 )
00551   {
00552     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00553     return( 0 );
00554   }
00555 
00556   QFrame *page = addEmptyPage( title );
00557   QVBoxLayout *vbox = new QVBoxLayout( page, KDialog::spacingHint() );
00558   QScrollView *scrollView = new QScrollView( page );
00559   scrollView->viewport()->setBackgroundMode( PaletteBackground );
00560   vbox->addWidget( scrollView );
00561 
00562   KAboutContainer *container = new KAboutContainer( scrollView, "container",
00563     KDialog::spacingHint(), KDialog::spacingHint(), childAlignment,
00564     innerAlignment );
00565   scrollView->addChild( container );
00566 
00567 
00568   connect(container, SIGNAL(urlClick(const QString &)),
00569       SLOT(slotUrlClick(const QString &)));
00570   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00571       SLOT(slotMailClick(const QString &,const QString &)));
00572 
00573   return( container );
00574 }
00575 
00576 
00577 QFrame *KAboutContainerBase::addEmptyPage( const QString &title )
00578 {
00579   if( mPageTab == 0 )
00580   {
00581     kdDebug(291) << "addPage: " << "Invalid layout" << endl;
00582     return( 0 );
00583   }
00584 
00585   QFrame *page = new QFrame( mPageTab, title.latin1() );
00586   page->setFrameStyle( QFrame::NoFrame );
00587 
00588   mPageTab->addTab( page, title );
00589   return( page );
00590 }
00591 
00592 
00593 KAboutContainer *KAboutContainerBase::addContainer( int childAlignment,
00594                             int innerAlignment )
00595 {
00596   KAboutContainer *container = new KAboutContainer( this, "container",
00597     0, KDialog::spacingHint(), childAlignment, innerAlignment );
00598   mTopLayout->addWidget( container, 0, childAlignment );
00599 
00600   if( mContainerList.resize( mContainerList.size() + 1) == true )
00601   {
00602     mContainerList[ mContainerList.size()-1 ]=container;
00603   }
00604 
00605   connect(container, SIGNAL(urlClick(const QString &)),
00606       SLOT(slotUrlClick(const QString &)));
00607   connect(container, SIGNAL(mailClick(const QString &,const QString &)),
00608       SLOT(slotMailClick(const QString &,const QString &)));
00609 
00610   return( container );
00611 }
00612 
00613 
00614 
00615 void KAboutContainerBase::setTitle( const QString &title )
00616 {
00617   if( mTitleLabel == 0 )
00618   {
00619     kdDebug(291) << "setTitle: " << "Invalid layout" << endl;
00620     return;
00621   }
00622   mTitleLabel->setText(title);
00623 }
00624 
00625 
00626 void KAboutContainerBase::setImage( const QString &fileName )
00627 {
00628   if( mImageLabel == 0 )
00629   {
00630     kdDebug(291) << "setImage: " << "Invalid layout" << endl;
00631     return;
00632   }
00633   if( fileName.isNull() )
00634   {
00635     return;
00636   }
00637 
00638   QPixmap logo( fileName );
00639   if( !logo.isNull() )
00640     mImageLabel->setPixmap( logo );
00641 
00642   mImageFrame->layout()->activate();
00643 }
00644 
00645 void KAboutContainerBase::setIcon( const QString &fileName )
00646 {
00647   if( mIconLabel == 0 )
00648   {
00649     kdDebug(291) << "setIcon: " << "Invalid layout" << endl;
00650     return;
00651   }
00652   if( fileName.isNull() )
00653   {
00654     return;
00655   }
00656 
00657   QPixmap logo( fileName );
00658   if( !logo.isNull() )
00659   {
00660     mIconLabel->setPixmap( logo );
00661   }
00662 }
00663 
00664 void KAboutContainerBase::setImageBackgroundColor( const QColor &color )
00665 {
00666   if( mImageFrame != 0 )
00667   {
00668     mImageFrame->setBackgroundColor( color );
00669   }
00670 }
00671 
00672 
00673 void KAboutContainerBase::setImageFrame( bool state )
00674 {
00675   if( mImageFrame != 0 )
00676   {
00677     if( state == true )
00678     {
00679       mImageFrame->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00680       mImageFrame->setLineWidth(1);
00681     }
00682     else
00683     {
00684       mImageFrame->setFrameStyle( QFrame::NoFrame );
00685       mImageFrame->setLineWidth(0);
00686     }
00687   }
00688 }
00689 
00690 
00691 void KAboutContainerBase::setProduct( const QString &appName,
00692                       const QString &version,
00693                       const QString &author,
00694                       const QString &year )
00695 {
00696   if( mIconLabel == 0 )
00697   {
00698     kdDebug(291) << "setProduct: " << "Invalid layout" << endl;
00699     return;
00700   }
00701 
00702   if ( kapp )
00703   {
00704     mIconLabel->setPixmap( kapp->icon() );
00705     kdDebug(291) << "setPixmap (iconName): " << kapp->iconName() << endl;
00706   }
00707   else
00708     kdDebug(291) << "no kapp" << endl;
00709 
00710   QString msg1 = i18n("%1 %2 (Using KDE %3)").arg(appName).arg(version).
00711     arg(QString::fromLatin1(KDE_VERSION_STRING));
00712   QString msg2 = !year.isEmpty() ? i18n("%1 %2, %3").arg('©').arg(year).
00713     arg(author) : QString::fromLatin1("");
00714 
00715   //if (!year.isEmpty())
00716   //  msg2 = i18n("%1 %2, %3").arg('©').arg(year).arg(author);
00717 
00718   mVersionLabel->setText( msg1 );
00719   mAuthorLabel->setText( msg2 );
00720   if( msg2.isEmpty() )
00721   {
00722     mAuthorLabel->hide();
00723   }
00724 
00725   mIconLabel->parentWidget()->layout()->activate();
00726 }
00727 
00728 
00729 void KAboutContainerBase::slotMouseTrack( int mode, const QMouseEvent *e )
00730 {
00731   emit mouseTrack( mode, e );
00732 }
00733 
00734 
00735 void KAboutContainerBase::slotUrlClick( const QString &url )
00736 {
00737   emit urlClick( url );
00738 }
00739 
00740 void KAboutContainerBase::slotMailClick( const QString &_name,
00741                      const QString &_address )
00742 {
00743   emit mailClick( _name, _address );
00744 }
00745 
00746 
00747 
00748 KAboutContainer::KAboutContainer( QWidget *_parent, const char *_name,
00749                   int _margin, int _spacing,
00750                   int childAlignment, int innerAlignment )
00751   : QFrame( _parent, _name )
00752 {
00753   mAlignment = innerAlignment;
00754 
00755   QGridLayout *gbox = new QGridLayout( this, 3, 3, _margin, _spacing );
00756   if( childAlignment & AlignHCenter )
00757   {
00758     gbox->setColStretch( 0, 10 );
00759     gbox->setColStretch( 2, 10 );
00760   }
00761   else if( childAlignment & AlignRight )
00762   {
00763     gbox->setColStretch( 0, 10 );
00764   }
00765   else
00766   {
00767     gbox->setColStretch( 2, 10 );
00768   }
00769 
00770   if( childAlignment & AlignVCenter )
00771   {
00772     gbox->setRowStretch( 0, 10 );
00773     gbox->setRowStretch( 2, 10 );
00774   }
00775   else if( childAlignment & AlignRight )
00776   {
00777     gbox->setRowStretch( 0, 10 );
00778   }
00779   else
00780   {
00781     gbox->setRowStretch( 2, 10 );
00782   }
00783 
00784   mVbox = new QVBoxLayout( _spacing );
00785   gbox->addLayout( mVbox, 1, 1 );
00786   gbox->activate();
00787 }
00788 
00789 
00790 void KAboutContainer::childEvent( QChildEvent *e )
00791 {
00792   if( !e->inserted() || !e->child()->isWidgetType() )
00793   {
00794     return;
00795   }
00796 
00797   QWidget *w = static_cast<QWidget *>(e->child());
00798   mVbox->addWidget( w, 0, mAlignment );
00799   QSize s( sizeHint() );
00800   setMinimumSize( s );
00801 
00802   QObjectList *l = const_cast<QObjectList *>(children()); // silence please
00803   for( uint i=0; i < l->count(); i++ )
00804   {
00805     QObject *o = l->at(i);
00806     if( o->isWidgetType() )
00807     {
00808         static_cast<QWidget *>(o)->setMinimumWidth( s.width() );
00809     }
00810   }
00811 }
00812 
00813 
00814 QSize KAboutContainer::sizeHint( void ) const
00815 {
00816   //
00817   // The size is computed by adding the sizeHint().height() of all
00818   // widget children and taking the width of the widest child and adding
00819   // layout()->margin() and layout()->spacing()
00820   //
00821 
00822   QSize total_size;
00823 
00824   int numChild = 0;
00825   QObjectList *l = const_cast<QObjectList *>(children()); // silence please
00826 
00827   for( uint i=0; i < l->count(); i++ )
00828   {
00829     QObject *o = l->at(i);
00830     if( o->isWidgetType() )
00831     {
00832       numChild += 1;
00833       QWidget *w= static_cast<QWidget *>(o);
00834 
00835       QSize s = w->minimumSize();
00836       if( s.isEmpty() == true )
00837       {
00838     s = w->minimumSizeHint();
00839     if( s.isEmpty() == true )
00840     {
00841       s = w->sizeHint();
00842       if( s.isEmpty() == true )
00843       {
00844         s = QSize( 100, 100 ); // Default size
00845       }
00846     }
00847       }
00848       total_size.setHeight( total_size.height() + s.height() );
00849       if( s.width() > total_size.width() ) { total_size.setWidth( s.width() ); }
00850     }
00851   }
00852 
00853   if( numChild > 0 )
00854   {
00855     //
00856     // Seems I have to add 1 to the height to properly show the border
00857     // of the last entry if layout()->margin() is 0
00858     //
00859 
00860     total_size.setHeight( total_size.height() + layout()->spacing()*(numChild-1) );
00861     total_size += QSize( layout()->margin()*2, layout()->margin()*2 + 1 );
00862   }
00863   else
00864   {
00865     total_size = QSize( 1, 1 );
00866   }
00867   return( total_size );
00868 }
00869 
00870 
00871 QSize KAboutContainer::minimumSizeHint( void ) const
00872 {
00873   return( sizeHint() );
00874 }
00875 
00876 
00877 void KAboutContainer::addWidget( QWidget *widget )
00878 {
00879   widget->reparent( this, 0, QPoint(0,0) );
00880 }
00881 
00882 
00883 void KAboutContainer::addPerson( const QString &_name, const QString &_email,
00884                  const QString &_url, const QString &_task,
00885                  bool showHeader, bool showFrame,bool showBold)
00886 {
00887 
00888   KAboutContributor *cont = new KAboutContributor( this, "pers",
00889     _name, _email, _url, _task, showHeader, showFrame, showBold );
00890   connect( cont, SIGNAL( openURL(const QString&)),
00891        this, SIGNAL( urlClick(const QString &)));
00892   connect( cont, SIGNAL( sendEmail(const QString &, const QString &)),
00893        this, SIGNAL( mailClick(const QString &, const QString &)));
00894 }
00895 
00896 
00897 void KAboutContainer::addTitle( const QString &title, int alignment,
00898                 bool showFrame, bool showBold )
00899 {
00900 
00901   QLabel *label = new QLabel( title, this, "title" );
00902   if( showBold == true )
00903   {
00904     QFont labelFont( font() );
00905     labelFont.setBold( true );
00906     label->setFont( labelFont );
00907   }
00908   if( showFrame == true )
00909   {
00910     label->setFrameStyle(QFrame::Panel | QFrame::Raised);
00911   }
00912   label->setAlignment( alignment );
00913 }
00914 
00915 
00916 void KAboutContainer::addImage( const QString &fileName, int alignment )
00917 {
00918   if( fileName.isNull() )
00919   {
00920     return;
00921   }
00922 
00923   KImageTrackLabel *label = new KImageTrackLabel( this, "image" );
00924   QImage logo( fileName );
00925   if( logo.isNull() == false )
00926   {
00927     QPixmap pix;
00928     pix = logo;
00929     label->setPixmap( pix );
00930   }
00931   label->setAlignment( alignment );
00932 }
00933 
00934 #if 0
00935 
00941 class KAboutContributor : public QFrame
00942 {
00943   // ############################################################################
00944   Q_OBJECT
00945   // ----------------------------------------------------------------------------
00946 public:
00948   KAboutContributor(QWidget* parent=0, const char* name=0);
00950   void setName(const QString&);
00952   QString getName();
00954   void setEmail(const QString&);
00956   QString getEmail();
00958   void setURL(const QString&);
00960   QString getURL();
00963   void setWork(const QString&);
00966   QSize sizeHint();
00967   QSize minimumSizeHint(void);
00968   virtual void show( void );
00969 
00970   // ----------------------------------------------------------------------------
00971 protected:
00972   // events:
00974   void resizeEvent(QResizeEvent*);
00976   void paintEvent(QPaintEvent*);
00978   QLabel *name;
00981   KURLLabel *email;
00983   KURLLabel *url;
00985   QString work;
00986   // ----------------------------------------------------------------------------
00987 protected slots:
00989   void urlClickedSlot(const QString&);
00991   void emailClickedSlot(const QString& emailaddress);
00992   // ----------------------------------------------------------------------------
00993 signals:
00995   void sendEmail(const QString& name, const QString& email);
00997   void openURL(const QString& url);
00998   // ############################################################################
00999 };
01000 
01001 
01002 
01003 KAboutContributor::KAboutContributor(QWidget* parent, const char* n)
01004   : QFrame(parent, n),
01005     name(new QLabel(this)),
01006     email(new KURLLabel(this)),
01007     url(new KURLLabel(this))
01008 {
01009   // ############################################################
01010   if(name==0 || email==0)
01011     { // this will nearly never happen (out of memory in about box?)
01012       kdDebug() << "KAboutContributor::KAboutContributor: Out of memory." << endl;
01013       qApp->quit();
01014     }
01015   setFrameStyle(QFrame::Panel | QFrame::Raised);
01016   // -----
01017   connect(email, SIGNAL(leftClickedURL(const QString&)),
01018       SLOT(emailClickedSlot(const QString&)));
01019   connect(url, SIGNAL(leftClickedURL(const QString&)),
01020       SLOT(urlClickedSlot(const QString&)));
01021   // ############################################################
01022 }
01023 
01024 void
01025 KAboutContributor::setName(const QString& n)
01026 {
01027   // ############################################################
01028   name->setText(n);
01029   // ############################################################
01030 }
01031 
01032 QString
01033 KAboutContributor::getName()
01034 {
01035   // ###########################################################
01036   return name->text();
01037   // ###########################################################
01038 }
01039 void
01040 KAboutContributor::setURL(const QString& u)
01041 {
01042   // ###########################################################
01043   url->setText(u);
01044   // ###########################################################
01045 }
01046 
01047 QString
01048 KAboutContributor::getURL()
01049 {
01050   // ###########################################################
01051   return url->text();
01052   // ###########################################################
01053 }
01054 
01055 void
01056 KAboutContributor::setEmail(const QString& e)
01057 {
01058   // ###########################################################
01059   email->setText(e);
01060   // ###########################################################
01061 }
01062 
01063 QString
01064 KAboutContributor::getEmail()
01065 {
01066   // ###########################################################
01067   return email->text();
01068   // ###########################################################
01069 }
01070 
01071 void
01072 KAboutContributor::emailClickedSlot(const QString& e)
01073 {
01074   // ###########################################################
01075   kdDebug() << "KAboutContributor::emailClickedSlot: called." << endl;
01076   emit(sendEmail(name->text(), e));
01077   // ###########################################################
01078 }
01079 
01080 void
01081 KAboutContributor::urlClickedSlot(const QString& u)
01082 {
01083   // ###########################################################
01084   kdDebug() << "KAboutContributor::urlClickedSlot: called." << endl;
01085   emit(openURL(u));
01086   // ###########################################################
01087 }
01088 
01089 void
01090 KAboutContributor::setWork(const QString& w)
01091 {
01092   // ###########################################################
01093   work=w;
01094   // ###########################################################
01095 }
01096 
01097 #endif
01098 
01099 
01100 #if 0
01101 QSize
01102 KAboutContributor::sizeHint()
01103 {
01104   // ############################################################################
01105   const int FrameWidth=frameWidth();
01106   const int WorkTextWidth=200;
01107   int maxx, maxy;
01108   QRect rect;
01109   // ----- first calculate name and email width:
01110   maxx=name->sizeHint().width();
01111   maxx=QMAX(maxx, email->sizeHint().width()+WORKTEXT_IDENTATION);
01112   // ----- now determine "work" text rectangle:
01113   if(!work.isEmpty()) // save time
01114     {
01115       rect=fontMetrics().boundingRect
01116     (0, 0, WorkTextWidth, 32000, WordBreak | AlignLeft, work);
01117     }
01118   if(maxx<rect.width())
01119   {
01120     maxx=WorkTextWidth+WORKTEXT_IDENTATION;
01121   }
01122   maxx=QMAX(maxx, url->sizeHint().width()+WORKTEXT_IDENTATION);
01123   // -----
01124   maxy=2*(name->sizeHint().height()+Grid); // need a space above the KURLLabels
01125   maxy+=/* email */ name->sizeHint().height();
01126   maxy+=rect.height();
01127   // -----
01128   maxx+=2*FrameWidth;
01129   maxy+=2*FrameWidth;
01130   return QSize(maxx, maxy);
01131   // ############################################################################
01132 }
01133 
01134 QSize KAboutContributor::minimumSizeHint(void)
01135 {
01136   return( sizeHint() );
01137 }
01138 
01139 
01140 void KAboutContributor::show( void )
01141 {
01142   QFrame::show();
01143   setMinimumSize( sizeHint() );
01144 }
01145 
01146 
01147 
01148 void
01149 KAboutContributor::resizeEvent(QResizeEvent*)
01150 { // the widgets are simply aligned from top to bottom, since the parent is
01151   // expected to respect the size hint
01152   // ############################################################################
01153   int framewidth=frameWidth(), childwidth=width()-2*framewidth;
01154   int cy=framewidth;
01155   // -----
01156   name->setGeometry
01157     (framewidth, framewidth, childwidth, name->sizeHint().height());
01158   cy=name->height()+Grid;
01159   email->setGeometry
01160     (framewidth+WORKTEXT_IDENTATION, cy,
01161      childwidth-WORKTEXT_IDENTATION, /* email */ name->sizeHint().height());
01162   cy+=name->height()+Grid;
01163   url->setGeometry
01164     (framewidth+WORKTEXT_IDENTATION, cy,
01165      childwidth-WORKTEXT_IDENTATION, /* url */ name->sizeHint().height());
01166   // the work text is drawn in the paint event
01167   // ############################################################################
01168 }
01169 
01170 
01171 void
01172 KAboutContributor::paintEvent(QPaintEvent* e)
01173 { // the widgets are simply aligned from top to bottom, since the parent is
01174   // expected to respect the size hint (the widget is only used locally by now)
01175   // ############################################################################
01176   int cy=frameWidth()+name->height()+email->height()+Grid+url->height()+Grid;
01177   int h=height()-cy-frameWidth();
01178   int w=width()-WORKTEXT_IDENTATION-2*frameWidth();
01179   // -----
01180   QFrame::paintEvent(e);
01181   if(work.isEmpty()) return;
01182   QPainter paint(this); // construct painter only if there is something to draw
01183   // -----
01184   paint.drawText(WORKTEXT_IDENTATION, cy, w, h, AlignLeft | WordBreak, work);
01185   // ############################################################################
01186 }
01187 #endif
01188 
01189 
01190 #if 0
01191 QSize KAboutContributor::sizeHint( void )
01192 {
01193   int s = KDialog::spacingHint();
01194   int h = fontMetrics().lineSpacing()*3 + 2*s;
01195   int m = frameWidth();
01196 
01197   int w = name->sizeHint().width();
01198   w = QMAX( w, email->sizeHint().width()+s);
01199   w = QMAX( w, url->sizeHint().width()+s);
01200 
01201   if( work.isEmpty() == false )
01202   {
01203     const int WorkTextWidth=200;
01204     QRect r = fontMetrics().boundingRect
01205       (0, 0, WorkTextWidth, 32000, WordBreak | AlignLeft, work);
01206     if( w < r.width() )
01207     {
01208       w = QMAX( w, WorkTextWidth+s );
01209     }
01210     h += QMAX( fontMetrics().lineSpacing(), r.height() ) + s;
01211   }
01212   return( QSize( w + 2*m, h + 2*m ) );
01213 
01214 
01215   /*
01216   int s = 3;
01217   int m = frameWidth() + KDialog::spacingHint();
01218   int h = ls * 3 + s * 2;
01219   int w = name->sizeHint().width();
01220 
01221   w = QMAX( w, email->sizeHint().width()+WORKTEXT_IDENTATION);
01222   w = QMAX( w, url->sizeHint().width()+WORKTEXT_IDENTATION);
01223   if( work.isEmpty() == false )
01224   {
01225     const int WorkTextWidth=200;
01226 
01227     QRect r = fontMetrics().boundingRect
01228       (0, 0, WorkTextWidth, 32000, WordBreak | AlignLeft, work);
01229     if( w < r.width() )
01230     {
01231       w = QMAX( w, WorkTextWidth + WORKTEXT_IDENTATION );
01232     }
01233     h += r.height() + s;
01234   }
01235   return( QSize( w + 2*m, h + 2*m ) );
01236   */
01237 }
01238 
01239 
01240 //
01241 // The widgets are simply aligned from top to bottom, since the parent is
01242 // expected to respect the size hint
01243 //
01244 void KAboutContributor::resizeEvent(QResizeEvent*)
01245 {
01246   int x = frameWidth();
01247   int s = KDialog::spacingHint();
01248   int h = fontMetrics().lineSpacing();
01249   int w = width() - 2*x;
01250   int y = x;
01251 
01252   name->setGeometry( x, y, w, h );
01253   y += h + s;
01254   email->setGeometry( x+s, y, w-s, h );
01255   y += h + s;
01256   url->setGeometry( x+s, y, w-s, h );
01257 
01258   /*
01259   int x = frameWidth() + KDialog::spacingHint();
01260   int y = x;
01261   int w = width() - 2*x;
01262   int h = name->sizeHint().height();
01263   int s = 3;
01264 
01265   name->setGeometry( x, y, w, h );
01266   y += h + s;
01267   email->setGeometry( x+WORKTEXT_IDENTATION, y, w-WORKTEXT_IDENTATION, h );
01268   y += h + s;
01269   url->setGeometry( x+WORKTEXT_IDENTATION, y, w-WORKTEXT_IDENTATION, h );
01270   //
01271   // the work text is drawn in the paint event
01272   //
01273   */
01274 }
01275 
01276 
01277 
01278 void KAboutContributor::paintEvent( QPaintEvent *e )
01279 {
01280   QFrame::paintEvent(e);
01281   if(work.isEmpty()) return;
01282 
01283   int x = frameWidth() + KDialog::spacingHint();
01284   int h = fontMetrics().lineSpacing();
01285   int y = height() - frameWidth() - fontMetrics().lineSpacing();
01286   int w = width() - frameWidth()*2 - KDialog::spacingHint();
01287 
01288   QPainter paint( this );
01289   paint.drawText( x, y, w, h, AlignLeft | WordBreak, work );
01290 
01291   /*
01292 
01293   int s = 3;
01294   int x = frameWidth() + KDialog::spacingHint() + WORKTEXT_IDENTATION;
01295   int w = width()-WORKTEXT_IDENTATION-2*(frameWidth()+KDialog::spacingHint());
01296   int y = frameWidth()+KDialog::spacingHint()+(name->sizeHint().height()+s)*3;
01297   int h = height()-y-frameWidth();
01298 
01299   QPainter paint( this );
01300   paint.drawText( x, y, w, h, AlignLeft | WordBreak, work );
01301   */
01302 }
01303 #endif
01304 
01305 
01306 
01307 
01308 
01309 
01310 KAboutWidget::KAboutWidget(QWidget *_parent, const char *_name)
01311   : QWidget(_parent, _name),
01312     version(new QLabel(this)),
01313     cont(new QLabel(this)),
01314     logo(new QLabel(this)),
01315     author(new KAboutContributor(this)),
01316     maintainer(new KAboutContributor(this)),
01317     showMaintainer(false)
01318 {
01319   // #################################################################
01320   if( version==0 || cont==0 || logo==0 || author==0 || maintainer==0 )
01321   {
01322     // this will nearly never happen (out of memory in about box?)
01323     kdDebug() << "KAboutWidget::KAboutWidget: Out of memory." << endl;
01324     qApp->quit();
01325   }
01326   // -----
01327   cont->setText(i18n("Other Contributors:"));
01328   logo->setText(i18n("(No logo available)"));
01329   logo->setFrameStyle(QFrame::Panel | QFrame::Raised);
01330   version->setAlignment(AlignCenter);
01331   // -----
01332   connect(author, SIGNAL(sendEmail(const QString&, const QString&)),
01333       SLOT(sendEmailSlot(const QString&, const QString&)));
01334   connect(author, SIGNAL(openURL(const QString&)),
01335       SLOT(openURLSlot(const QString&)));
01336   connect(maintainer, SIGNAL(sendEmail(const QString&, const QString&)),
01337       SLOT(sendEmailSlot(const QString&, const QString&)));
01338   connect(maintainer, SIGNAL(openURL(const QString&)),
01339       SLOT(openURLSlot(const QString&)));
01340   // #################################################################
01341 }
01342 
01343 
01344 void
01345 KAboutWidget::adjust()
01346 {
01347   // #################################################################
01348   int cx, cy, tempx;
01349   int maintWidth, maintHeight;
01350   QSize total_size;
01351   // -----
01352   if(showMaintainer)
01353     {
01354       total_size=maintainer->sizeHint();
01355       maintWidth=total_size.width();
01356       maintHeight=total_size.height();
01357     } else {
01358       maintWidth=0;
01359       maintHeight=0;
01360     }
01361   total_size=author->sizeHint();
01362   logo->adjustSize();
01363   cy=version->sizeHint().height()+Grid;
01364   cx=logo->width();
01365   tempx=QMAX(total_size.width(), maintWidth);
01366   cx+=Grid+tempx;
01367   cx=QMAX(cx, version->sizeHint().width());
01368   cy+=QMAX(logo->height(),
01369        total_size.height()+(showMaintainer ? Grid+maintHeight : 0));
01370   // -----
01371   if(!contributors.isEmpty())
01372     {
01373       cx=QMAX(cx, cont->sizeHint().width());
01374       cy+=cont->sizeHint().height()+Grid;
01375       QPtrListIterator<KAboutContributor> _pos(contributors);
01376       for( ; _pos.current(); ++_pos)
01377     {
01378       cy+=_pos.current()->sizeHint().height();
01379     }
01380     }
01381   // -----
01382   setMinimumSize(cx, cy);
01383   // #################################################################
01384 }
01385 
01386 void
01387 KAboutWidget::setLogo(const QPixmap& i)
01388 {
01389   // ############################################################################
01390   logo->setPixmap(i);
01391   // ############################################################################
01392 }
01393 
01394 void KAboutWidget::sendEmailSlot(const QString &_name, const QString &_email)
01395 {
01396   emit(sendEmail(_name, _email));
01397 }
01398 
01399 void KAboutWidget::openURLSlot(const QString& _url)
01400 {
01401   emit(openURL(_url));
01402 }
01403 
01404 void
01405 KAboutWidget::setAuthor(const QString &_name, const QString &_email,
01406             const QString &_url, const QString &_w)
01407 {
01408   // ############################################################################
01409   author->setName(_name);
01410   author->setEmail(_email);
01411   author->setURL(_url);
01412   author->setWork(_w);
01413   // ############################################################################
01414 }
01415 
01416 void
01417 KAboutWidget::setMaintainer(const QString &_name, const QString &_email,
01418                 const QString &_url, const QString &_w)
01419 {
01420   // ############################################################################
01421   maintainer->setName(_name);
01422   maintainer->setEmail(_email);
01423   maintainer->setWork(_w);
01424   maintainer->setURL(_url);
01425   showMaintainer=true;
01426   // ############################################################################
01427 }
01428 
01429 void
01430 KAboutWidget::addContributor(const QString &_name, const QString &_email,
01431                  const QString &_url, const QString &_w)
01432 {
01433   // ############################################################################
01434   KAboutContributor *c=new KAboutContributor(this);
01435   // -----
01436   c->setName(_name);
01437   c->setEmail(_email);
01438   c->setURL(_url);
01439   c->setWork(_w);
01440   contributors.append(c);
01441   connect(c, SIGNAL(sendEmail(const QString&, const QString&)),
01442       SLOT(sendEmailSlot(const QString&, const QString&)));
01443   connect(c, SIGNAL(openURL(const QString&)), SLOT(openURLSlot(const QString&)));
01444   // ############################################################################
01445 }
01446 
01447 void
01448 KAboutWidget::setVersion(const QString &_name)
01449 {
01450   // ############################################################################
01451   version->setText(_name);
01452   // ############################################################################
01453 }
01454 
01455 void
01456 KAboutWidget::resizeEvent(QResizeEvent*)
01457 {
01458   // ############################################################################
01459   int _x=0, _y, cx, tempx, tempy;
01460   // ----- set version label geometry:
01461   version->setGeometry(0, 0, width(), version->sizeHint().height());
01462   _y=version->height()+Grid;
01463   // ----- move logo to correct position:
01464   logo->adjustSize();
01465   logo->move(0, _y);
01466   // ----- move author and maintainer right to it:
01467   tempx=logo->width()+Grid;
01468   cx=width()-tempx;
01469   author->setGeometry
01470     (tempx, _y, cx, author->sizeHint().height());
01471   maintainer->setGeometry
01472     (tempx, _y+author->height()+Grid, cx, maintainer->sizeHint().height());
01473 
01474   _y+=QMAX(logo->height(),
01475       author->height()+(showMaintainer ? Grid+maintainer->height() : 0));
01476   // -----
01477   if(!contributors.isEmpty())
01478     {
01479       tempy=cont->sizeHint().height();
01480       cont->setGeometry(0, _y, width(), tempy);
01481       cont->show();
01482       _y+=tempy+Grid;
01483     } else {
01484       cont->hide();
01485     }
01486 
01487   for(QPtrListIterator<KAboutContributor> _pos(contributors); _pos.current(); ++_pos)
01488     {
01489       tempy=_pos.current()->sizeHint().height();
01490       // y+=Grid;
01491       _pos.current()->setGeometry(_x, _y, width(), tempy);
01492       _y+=tempy;
01493     }
01494   if(showMaintainer)
01495     {
01496       maintainer->show();
01497     } else {
01498       maintainer->hide();
01499     }
01500   // ############################################################################
01501 }
01502 
01503 KAboutDialog::KAboutDialog(QWidget *_parent, const char *_name, bool modal)
01504   : KDialogBase(_parent, _name, modal, QString::null, Ok, Ok ),
01505     about(new KAboutWidget(this)), mContainerBase(0)
01506 {
01507   // #################################################################
01508   if(about==0)
01509   {
01510     // this will nearly never happen (out of memory in about box?)
01511     kdDebug() << "KAboutDialog::KAboutDialog: Out of memory." << endl;
01512     qApp->quit();
01513   }
01514   setMainWidget(about);
01515   connect(about, SIGNAL(sendEmail(const QString&, const QString&)),
01516       SLOT(sendEmailSlot(const QString&, const QString&)));
01517   connect(about, SIGNAL(openURL(const QString&)),
01518       SLOT(openURLSlot(const QString&)));
01519   // #################################################################
01520 }
01521 
01522 
01523 KAboutDialog::KAboutDialog( int layoutType, const QString &_caption,
01524                 int buttonMask, ButtonCode defaultButton,
01525                 QWidget *_parent, const char *_name, bool modal,
01526                 bool separator, const QString &user1,
01527                 const QString &user2, const QString &user3 )
01528   :KDialogBase( _parent, _name, modal, QString::null, buttonMask, defaultButton,
01529         separator, user1, user2, user3 ),
01530    about(0)
01531 {
01532   setPlainCaption( i18n("About %1").arg(_caption) );
01533 
01534   mContainerBase = new KAboutContainerBase( layoutType, this );
01535   setMainWidget(mContainerBase);
01536 
01537   connect( mContainerBase, SIGNAL(urlClick(const QString &)),
01538        this, SLOT(openURLSlot(const QString &)));
01539   connect( mContainerBase, SIGNAL(mailClick(const QString &,const QString &)),
01540        this, SLOT(sendEmailSlot(const QString &,const QString &)));
01541   connect( mContainerBase, SIGNAL(mouseTrack(int, const QMouseEvent *)),
01542        this, SLOT(mouseTrackSlot(int, const QMouseEvent *)));
01543 }
01544 
01545 
01546 void KAboutDialog::show( void )
01547 {
01548   adjust();
01549   if( mContainerBase != 0 ) { mContainerBase->show(); }
01550   QDialog::show();
01551 }
01552 
01553 
01554 void KAboutDialog::show( QWidget */*centerParent*/ )
01555 {
01556   adjust();
01557   if( mContainerBase != 0 ) { mContainerBase->show(); }
01558   QDialog::show();
01559 }
01560 
01561 
01562 void KAboutDialog::adjust()
01563 {
01564   if( about == 0 ) { return; }
01565   about->adjust();
01566   //initializeGeometry();
01567   resize( sizeHint() );
01568 }
01569 
01570 
01571 void KAboutDialog::setLogo(const QPixmap& i)
01572 {
01573   if( about == 0 ) { return; }
01574   about->setLogo(i);
01575 }
01576 
01577 
01578 void KAboutDialog::setMaintainer(const QString &_name, const QString &_email,
01579                  const QString &_url, const QString &_w)
01580 {
01581   // #################################################################
01582   if( about == 0 ) { return; }
01583   about->setMaintainer(_name, _email, _url, _w);
01584   // #################################################################
01585 }
01586 
01587 void KAboutDialog::setAuthor(const QString &_name, const QString &_email,
01588                  const QString &_url, const QString &_work)
01589 {
01590   // #################################################################
01591   if( about == 0 ) { return; }
01592   about->setAuthor(_name, _email, _url, _work);
01593   // #################################################################
01594 }
01595 
01596 void KAboutDialog::addContributor(const QString &_name, const QString &_email,
01597                   const QString &_url, const QString &_w)
01598 {
01599   // #################################################################
01600   if( about == 0 ) { return; }
01601   about->addContributor(_name, _email, _url, _w);
01602   // #################################################################
01603 }
01604 
01605 void KAboutDialog::setVersion(const QString &_name)
01606 {
01607   // #################################################################
01608   if( about == 0 ) { return; }
01609   about->setVersion(_name);
01610   // #################################################################
01611 }
01612 
01613 void KAboutDialog::sendEmailSlot(const QString& /*name*/, const QString& email)
01614 {
01615   if ( kapp )
01616       kapp->invokeMailer( email, QString::null );
01617   /*
01618   kdDebug() << "KAboutDialog::sendEmailSlot: request to send an email to "
01619     << name << ", " << email << endl;
01620   emit(sendEmail(name, email));
01621   */
01622 }
01623 
01624 void KAboutDialog::openURLSlot(const QString& url)
01625 {
01626   if ( kapp )
01627       kapp->invokeBrowser( url );
01628   //kdDebug() << "KAboutDialog::openURLSlot: request to open URL " << url << endl;
01629   //emit(openURL(url));
01630 }
01631 
01632 
01633 void KAboutDialog::mouseTrackSlot( int /*mode*/, const QMouseEvent */*e*/ )
01634 {
01635   // By default we do nothing. This method must be reimplemented.
01636 }
01637 
01638 
01639 QFrame *KAboutDialog::addTextPage( const QString &title, const QString &text,
01640                    bool richText, int numLines )
01641 {
01642   if( mContainerBase == 0 ) { return( 0 ); }
01643   return( mContainerBase->addTextPage( title, text, richText, numLines ) );
01644 }
01645 
01646 QFrame *KAboutDialog::addLicensePage( const QString &title, const QString &text,
01647                    int numLines )
01648 {
01649   if( mContainerBase == 0 ) { return( 0 ); }
01650   return( mContainerBase->addLicensePage( title, text, numLines ) );
01651 }
01652 
01653 
01654 KAboutContainer *KAboutDialog::addContainerPage( const QString &title,
01655                   int childAlignment, int innerAlignment )
01656 {
01657   if( mContainerBase == 0 ) { return( 0 ); }
01658   return( mContainerBase->addContainerPage( title, childAlignment,
01659                         innerAlignment) );
01660 }
01661 
01662 
01663 KAboutContainer *KAboutDialog::addScrolledContainerPage( const QString &title,
01664                   int childAlignment, int innerAlignment )
01665 {
01666   if( mContainerBase == 0 ) { return( 0 ); }
01667   return( mContainerBase->addScrolledContainerPage( title, childAlignment,
01668                             innerAlignment) );
01669 }
01670 
01671 
01672 
01673 QFrame *KAboutDialog::addPage( const QString &title )
01674 {
01675   if( mContainerBase == 0 ) { return( 0 ); }
01676   return( mContainerBase->addEmptyPage( title ) );
01677 }
01678 
01679 
01680 KAboutContainer *KAboutDialog::addContainer( int childAlignment,
01681                          int innerAlignment )
01682 {
01683   if( mContainerBase == 0 ) { return( 0 ); }
01684   return( mContainerBase->addContainer( childAlignment, innerAlignment ) );
01685 }
01686 
01687 
01688 void KAboutDialog::setTitle( const QString &title )
01689 {
01690   if( mContainerBase == 0 ) { return; }
01691   mContainerBase->setTitle( title );
01692 }
01693 
01694 
01695 void KAboutDialog::setImage( const QString &fileName )
01696 {
01697   if( mContainerBase == 0 ) { return; }
01698   mContainerBase->setImage( fileName );
01699 }
01700 
01701 void KAboutDialog::setIcon( const QString &fileName )
01702 {
01703     if( mContainerBase == 0 ) { return; }
01704     mContainerBase->setIcon( fileName );
01705 }
01706 
01707 
01708 void KAboutDialog::setImageBackgroundColor( const QColor &color )
01709 {
01710   if( mContainerBase == 0 ) { return; }
01711   mContainerBase->setImageBackgroundColor( color );
01712 }
01713 
01714 
01715 void KAboutDialog::setImageFrame( bool state )
01716 {
01717   if( mContainerBase == 0 ) { return; }
01718   mContainerBase->setImageFrame( state );
01719 }
01720 
01721 
01722 void KAboutDialog::setProduct( const QString &appName, const QString &version,
01723                    const QString &author, const QString &year )
01724 {
01725   if( mContainerBase == 0 ) { return; }
01726   mContainerBase->setProduct( appName, version, author, year );
01727 }
01728 
01729 
01730 
01731 void KAboutDialog::imageURL( QWidget *_parent, const QString &_caption,
01732                  const QString &_path, const QColor &_imageColor,
01733                  const QString &_url )
01734 {
01735   KAboutDialog a( AbtImageOnly, QString::null, Close, Close, _parent, "image", true );
01736   a.setPlainCaption( _caption );
01737   a.setImage( _path );
01738   a.setImageBackgroundColor( _imageColor );
01739 
01740   KAboutContainer *c = a.addContainer( AlignCenter, AlignCenter );
01741   if( c != 0 )
01742   {
01743     c->addPerson( QString::null, QString::null, _url, QString::null );
01744   }
01745   a.exec();
01746 }
01747 
01748 
01749 
01750 
01751 //
01752 // A class that can can monitor mouse movements on the image
01753 //
01754 KImageTrackLabel::KImageTrackLabel( QWidget *_parent, const char *_name, WFlags f )
01755   : QLabel( _parent, _name, f )
01756 {
01757   setText( i18n("Image missing"));
01758 }
01759 
01760 void KImageTrackLabel::mousePressEvent( QMouseEvent *e )
01761 {
01762   emit mouseTrack( MousePress, e );
01763 }
01764 
01765 void KImageTrackLabel::mouseReleaseEvent( QMouseEvent *e )
01766 {
01767   emit mouseTrack( MouseRelease, e );
01768 }
01769 
01770 void KImageTrackLabel::mouseDoubleClickEvent( QMouseEvent *e )
01771 {
01772   emit mouseTrack( MouseDoubleClick, e );
01773 }
01774 
01775 void KImageTrackLabel::mouseMoveEvent ( QMouseEvent *e )
01776 {
01777   emit mouseTrack( MouseDoubleClick, e );
01778 }
01779 
01780 void KAboutDialog::virtual_hook( int id, void* data )
01781 { KDialogBase::virtual_hook( id, data ); }
01782 
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:11:58 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003