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