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