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