00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <config.h>
00027
00028 #ifdef KDE_USE_FINAL
00029 #undef Always
00030 #include <tqdockwindow.h>
00031 #endif
00032
00033 #include <string.h>
00034
00035 #include <tqpainter.h>
00036 #include <tqtooltip.h>
00037 #include <tqdrawutil.h>
00038 #include <tqstring.h>
00039 #include <tqrect.h>
00040 #include <tqobjectlist.h>
00041 #include <tqtimer.h>
00042 #include <tqstyle.h>
00043 #include <tqlayout.h>
00044
00045 #include <tdetoolbar.h>
00046 #include <tdemainwindow.h>
00047 #include <klineedit.h>
00048 #include <kseparator.h>
00049 #include <tdelocale.h>
00050 #include <tdeapplication.h>
00051 #include <tdeaction.h>
00052 #include <kstdaction.h>
00053 #include <tdeglobal.h>
00054 #include <tdeconfig.h>
00055 #include <kiconloader.h>
00056 #include <kcombobox.h>
00057 #include <tdepopupmenu.h>
00058 #include <kanimwidget.h>
00059 #include <kedittoolbar.h>
00060 #include <kipc.h>
00061 #include <twin.h>
00062 #include <kdebug.h>
00063 #include <tdetoolbarbutton.h>
00064
00065 enum {
00066 CONTEXT_TOP = 0,
00067 CONTEXT_LEFT = 1,
00068 CONTEXT_RIGHT = 2,
00069 CONTEXT_BOTTOM = 3,
00070 CONTEXT_FLOAT = 4,
00071 CONTEXT_FLAT = 5,
00072 CONTEXT_ICONS = 6,
00073 CONTEXT_TEXT = 7,
00074 CONTEXT_TEXTRIGHT = 8,
00075 CONTEXT_TEXTUNDER = 9,
00076 CONTEXT_ICONSIZES = 50
00077 };
00078
00079 class TDEToolBarPrivate
00080 {
00081 public:
00082 TDEToolBarPrivate() {
00083 m_iconSize = 0;
00084 m_iconText = TDEToolBar::IconOnly;
00085 m_highlight = true;
00086 m_transparent = true;
00087 m_honorStyle = false;
00088
00089 m_enableContext = true;
00090
00091 m_parent = NULL;
00092 m_xmlguiClient = 0;
00093
00094 oldPos = TQt::DockUnmanaged;
00095
00096 modified = m_isHorizontal = positioned = false;
00097
00098 IconSizeDefault = 0;
00099 IconTextDefault = "IconOnly";
00100
00101 NewLineDefault = false;
00102 OffsetDefault = 0;
00103 PositionDefault = "Top";
00104 HiddenDefault = false;
00105 idleButtons.setAutoDelete(true);
00106 }
00107
00108 int m_iconSize;
00109 TDEToolBar::IconText m_iconText;
00110 bool m_highlight : 1;
00111 bool m_transparent : 1;
00112 bool m_honorStyle : 1;
00113 bool m_isHorizontal : 1;
00114 bool m_enableContext : 1;
00115 bool modified : 1;
00116 bool positioned : 1;
00117
00118 TQWidget *m_parent;
00119
00120 TQMainWindow::ToolBarDock oldPos;
00121
00122 KXMLGUIClient *m_xmlguiClient;
00123
00124 struct ToolBarInfo
00125 {
00126 ToolBarInfo() : index( -1 ), offset( -1 ), newline( false ), dock( TQt::DockTop ) {}
00127 ToolBarInfo( TQt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {}
00128 int index, offset;
00129 bool newline;
00130 TQt::Dock dock;
00131 };
00132
00133 ToolBarInfo toolBarInfo;
00134 TQValueList<int> iconSizes;
00135 TQTimer repaintTimer;
00136
00137
00138 bool HiddenDefault;
00139 int IconSizeDefault;
00140 TQString IconTextDefault;
00141 bool NewLineDefault;
00142 int OffsetDefault;
00143 TQString PositionDefault;
00144
00145 TQPtrList<TQWidget> idleButtons;
00146 };
00147
00148 TDEToolBarSeparator::TDEToolBarSeparator(Orientation o , bool l, TQToolBar *parent,
00149 const char* name )
00150 :TQFrame( parent, name ), line( l )
00151 {
00152 connect( parent, TQT_SIGNAL(orientationChanged(Orientation)),
00153 this, TQT_SLOT(setOrientation(Orientation)) );
00154 setOrientation( o );
00155 setBackgroundMode( parent->backgroundMode() );
00156 setBackgroundOrigin( ParentOrigin );
00157 }
00158
00159 void TDEToolBarSeparator::setOrientation( Orientation o )
00160 {
00161 orient = o;
00162 setFrameStyle( NoFrame );
00163 }
00164
00165 void TDEToolBarSeparator::drawContents( TQPainter* p )
00166 {
00167 if ( line ) {
00168 TQStyle::SFlags flags = TQStyle::Style_Default;
00169
00170 if ( orientation() == Qt::Horizontal )
00171 flags = flags | TQStyle::Style_Horizontal;
00172
00173 style().tqdrawPrimitive(TQStyle::PE_DockWindowSeparator, p,
00174 contentsRect(), colorGroup(), flags);
00175 } else {
00176 TQFrame::drawContents(p);
00177 }
00178 }
00179
00180 void TDEToolBarSeparator::styleChange( TQStyle& )
00181 {
00182 setOrientation( orient );
00183 }
00184
00185 TQSize TDEToolBarSeparator::sizeHint() const
00186 {
00187 int dim = style().pixelMetric( TQStyle::PM_DockWindowSeparatorExtent, this );
00188 return orientation() == Qt::Vertical ? TQSize( 0, dim ) : TQSize( dim, 0 );
00189 }
00190
00191 TQSizePolicy TDEToolBarSeparator::sizePolicy() const
00192 {
00193 return TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Minimum );
00194 }
00195
00196 TDEToolBar::TDEToolBar( TQWidget *parent, const char *name, bool honorStyle, bool readConfig )
00197 : TQToolBar( TQString::fromLatin1( name ),
00198 tqt_dynamic_cast<TQMainWindow*>(parent),
00199 parent, false,
00200 name ? name : "mainToolBar")
00201 {
00202 init( readConfig, honorStyle );
00203 }
00204
00205 TDEToolBar::TDEToolBar( TQMainWindow *parentWindow, TQMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
00206 : TQToolBar( TQString::fromLatin1( name ),
00207 parentWindow, dock, newLine,
00208 name ? name : "mainToolBar")
00209 {
00210 init( readConfig, honorStyle );
00211 }
00212
00213 TDEToolBar::TDEToolBar( TQMainWindow *parentWindow, TQWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
00214 : TQToolBar( TQString::fromLatin1( name ),
00215 parentWindow, dock, newLine,
00216 name ? name : "mainToolBar")
00217 {
00218 init( readConfig, honorStyle );
00219 }
00220
00221 TDEToolBar::~TDEToolBar()
00222 {
00223 emit toolbarDestroyed();
00224 delete d;
00225 }
00226
00227 void TDEToolBar::init( bool readConfig, bool honorStyle )
00228 {
00229 d = new TDEToolBarPrivate();
00230
00231 setFullSize( true );
00232 d->m_honorStyle = honorStyle;
00233 context = 0;
00234 layoutTimer = new TQTimer( this );
00235 connect( layoutTimer, TQT_SIGNAL( timeout() ),
00236 this, TQT_SLOT( rebuildLayout() ) );
00237 connect( &(d->repaintTimer), TQT_SIGNAL( timeout() ),
00238 this, TQT_SLOT( slotRepaint() ) );
00239
00240 if ( kapp ) {
00241 connect(kapp, TQT_SIGNAL(toolbarAppearanceChanged(int)), this, TQT_SLOT(slotAppearanceChanged()));
00242
00243 kapp->addKipcEventMask(KIPC::IconChanged);
00244 connect(kapp, TQT_SIGNAL(iconChanged(int)), this, TQT_SLOT(slotIconChanged(int)));
00245 }
00246
00247
00248 if ( readConfig )
00249 slotReadConfig();
00250
00251 if ( mainWindow() )
00252 connect( mainWindow(), TQT_SIGNAL( toolBarPositionChanged( TQToolBar * ) ),
00253 this, TQT_SLOT( toolBarPosChanged( TQToolBar * ) ) );
00254
00255
00256 connect( this, TQT_SIGNAL(placeChanged(TQDockWindow::Place)), TQT_SLOT(rebuildLayout()) );
00257 }
00258
00259 int TDEToolBar::insertButton(const TQString& icon, int id, bool enabled,
00260 const TQString& text, int index, TDEInstance *_instance )
00261 {
00262 TDEToolBarButton *button = new TDEToolBarButton( icon, id, this, 0, text, _instance );
00263
00264 insertWidgetInternal( button, index, id );
00265 button->setEnabled( enabled );
00266 doConnections( button );
00267 return index;
00268 }
00269
00270
00271 int TDEToolBar::insertButton(const TQString& icon, int id, const char *signal,
00272 const TQObject *receiver, const char *slot,
00273 bool enabled, const TQString& text, int index, TDEInstance *_instance )
00274 {
00275 TDEToolBarButton *button = new TDEToolBarButton( icon, id, this, 0, text, _instance);
00276 insertWidgetInternal( button, index, id );
00277 button->setEnabled( enabled );
00278 connect( button, signal, receiver, slot );
00279 doConnections( button );
00280 return index;
00281 }
00282
00283
00284 int TDEToolBar::insertButton(const TQPixmap& pixmap, int id, bool enabled,
00285 const TQString& text, int index )
00286 {
00287 TDEToolBarButton *button = new TDEToolBarButton( pixmap, id, this, 0, text);
00288 insertWidgetInternal( button, index, id );
00289 button->setEnabled( enabled );
00290 doConnections( button );
00291 return index;
00292 }
00293
00294
00295 int TDEToolBar::insertButton(const TQPixmap& pixmap, int id, const char *signal,
00296 const TQObject *receiver, const char *slot,
00297 bool enabled, const TQString& text,
00298 int index )
00299 {
00300 TDEToolBarButton *button = new TDEToolBarButton( pixmap, id, this, 0, text);
00301 insertWidgetInternal( button, index, id );
00302 button->setEnabled( enabled );
00303 connect( button, signal, receiver, slot );
00304 doConnections( button );
00305 return index;
00306 }
00307
00308
00309 int TDEToolBar::insertButton(const TQString& icon, int id, TQPopupMenu *popup,
00310 bool enabled, const TQString &text, int index )
00311 {
00312 TDEToolBarButton *button = new TDEToolBarButton( icon, id, this, 0, text );
00313 insertWidgetInternal( button, index, id );
00314 button->setEnabled( enabled );
00315 button->setPopup( popup );
00316 doConnections( button );
00317 return index;
00318 }
00319
00320
00321 int TDEToolBar::insertButton(const TQPixmap& pixmap, int id, TQPopupMenu *popup,
00322 bool enabled, const TQString &text, int index )
00323 {
00324 TDEToolBarButton *button = new TDEToolBarButton( pixmap, id, this, 0, text );
00325 insertWidgetInternal( button, index, id );
00326 button->setEnabled( enabled );
00327 button->setPopup( popup );
00328 doConnections( button );
00329 return index;
00330 }
00331
00332
00333 int TDEToolBar::insertLined (const TQString& text, int id,
00334 const char *signal,
00335 const TQObject *receiver, const char *slot,
00336 bool enabled ,
00337 const TQString& toolTipText,
00338 int size, int index )
00339 {
00340 KLineEdit *lined = new KLineEdit ( this, 0 );
00341 if ( !toolTipText.isEmpty() )
00342 TQToolTip::add( lined, toolTipText );
00343 if ( size > 0 )
00344 lined->setMinimumWidth( size );
00345 insertWidgetInternal( lined, index, id );
00346 connect( lined, signal, receiver, slot );
00347 lined->setText(text);
00348 lined->setEnabled( enabled );
00349 return index;
00350 }
00351
00352 int TDEToolBar::insertCombo (const TQStringList &list, int id, bool writable,
00353 const char *signal, const TQObject *receiver,
00354 const char *slot, bool enabled,
00355 const TQString& tooltiptext,
00356 int size, int index,
00357 TQComboBox::Policy policy )
00358 {
00359 KComboBox *combo = new KComboBox ( writable, this );
00360
00361 insertWidgetInternal( combo, index, id );
00362 combo->insertStringList (list);
00363 combo->setInsertionPolicy(policy);
00364 combo->setEnabled( enabled );
00365 if ( size > 0 )
00366 combo->setMinimumWidth( size );
00367 if (!tooltiptext.isNull())
00368 TQToolTip::add( combo, tooltiptext );
00369
00370 if ( signal && receiver && slot )
00371 connect ( combo, signal, receiver, slot );
00372 return index;
00373 }
00374
00375
00376 int TDEToolBar::insertCombo (const TQString& text, int id, bool writable,
00377 const char *signal, TQObject *receiver,
00378 const char *slot, bool enabled,
00379 const TQString& tooltiptext,
00380 int size, int index,
00381 TQComboBox::Policy policy )
00382 {
00383 KComboBox *combo = new KComboBox ( writable, this );
00384 insertWidgetInternal( combo, index, id );
00385 combo->insertItem (text);
00386 combo->setInsertionPolicy(policy);
00387 combo->setEnabled( enabled );
00388 if ( size > 0 )
00389 combo->setMinimumWidth( size );
00390 if (!tooltiptext.isNull())
00391 TQToolTip::add( combo, tooltiptext );
00392 connect (combo, signal, receiver, slot);
00393 return index;
00394 }
00395
00396 int TDEToolBar::insertSeparator(int index, int id)
00397 {
00398 TQWidget *w = new TDEToolBarSeparator( orientation(), false, this, "tool bar separator" );
00399 insertWidgetInternal( w, index, id );
00400 return index;
00401 }
00402
00403 int TDEToolBar::insertLineSeparator(int index, int id)
00404 {
00405 TQWidget *w = new TDEToolBarSeparator( orientation(), true, this, "tool bar separator" );
00406 insertWidgetInternal( w, index, id );
00407 return index;
00408 }
00409
00410
00411 int TDEToolBar::insertWidget(int id, int , TQWidget *widget, int index)
00412 {
00413 removeWidgetInternal( widget );
00414 insertWidgetInternal( widget, index, id );
00415 return index;
00416 }
00417
00418 int TDEToolBar::insertAnimatedWidget(int id, TQObject *receiver, const char *slot,
00419 const TQString& icons, int index )
00420 {
00421 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this );
00422 insertWidgetInternal( anim, index, id );
00423
00424 if ( receiver )
00425 connect( anim, TQT_SIGNAL(clicked()), receiver, slot);
00426
00427 return index;
00428 }
00429
00430 KAnimWidget *TDEToolBar::animatedWidget( int id )
00431 {
00432 Id2WidgetMap::Iterator it = id2widget.find( id );
00433 if ( it == id2widget.end() )
00434 return 0;
00435 KAnimWidget *aw = tqt_dynamic_cast<KAnimWidget *>(*it);
00436 if ( aw )
00437 return aw;
00438 TQObjectList *l = queryList( "KAnimWidget" );
00439 if ( !l || !l->first() ) {
00440 delete l;
00441 return 0;
00442 }
00443
00444 for ( TQObject *o = l->first(); o; o = l->next() ) {
00445 KAnimWidget *aw = tqt_dynamic_cast<KAnimWidget *>(o);
00446 if ( aw )
00447 {
00448 delete l;
00449 return aw;
00450 }
00451 }
00452
00453 delete l;
00454 return 0;
00455 }
00456
00457
00458 void TDEToolBar::addConnection (int id, const char *signal,
00459 const TQObject *receiver, const char *slot)
00460 {
00461 TQWidget* w = getWidget( id );
00462 if ( w )
00463 connect( w, signal, receiver, slot );
00464 }
00465
00466 void TDEToolBar::setItemEnabled( int id, bool enabled )
00467 {
00468 TQWidget* w = getWidget( id );
00469 if ( w )
00470 w->setEnabled( enabled );
00471 }
00472
00473
00474 void TDEToolBar::setButtonPixmap( int id, const TQPixmap& _pixmap )
00475 {
00476 TDEToolBarButton * button = getButton( id );
00477 if ( button )
00478 button->setPixmap( _pixmap );
00479 }
00480
00481
00482 void TDEToolBar::setButtonIcon( int id, const TQString& _icon )
00483 {
00484 TDEToolBarButton * button = getButton( id );
00485 if ( button )
00486 button->setIcon( _icon );
00487 }
00488
00489 void TDEToolBar::setButtonIconSet( int id, const TQIconSet& iconset )
00490 {
00491 TDEToolBarButton * button = getButton( id );
00492 if ( button )
00493 button->setIconSet( iconset );
00494 }
00495
00496
00497 void TDEToolBar::setDelayedPopup (int id , TQPopupMenu *_popup, bool toggle )
00498 {
00499 TDEToolBarButton * button = getButton( id );
00500 if ( button )
00501 button->setDelayedPopup( _popup, toggle );
00502 }
00503
00504
00505 void TDEToolBar::setAutoRepeat (int id, bool flag)
00506 {
00507 TDEToolBarButton * button = getButton( id );
00508 if ( button )
00509 button->setAutoRepeat( flag );
00510 }
00511
00512
00513 void TDEToolBar::setToggle (int id, bool flag )
00514 {
00515 TDEToolBarButton * button = getButton( id );
00516 if ( button )
00517 button->setToggle( flag );
00518 }
00519
00520
00521 void TDEToolBar::toggleButton (int id)
00522 {
00523 TDEToolBarButton * button = getButton( id );
00524 if ( button )
00525 button->toggle();
00526 }
00527
00528
00529 void TDEToolBar::setButton (int id, bool flag)
00530 {
00531 TDEToolBarButton * button = getButton( id );
00532 if ( button )
00533 button->on( flag );
00534 }
00535
00536
00537 bool TDEToolBar::isButtonOn (int id) const
00538 {
00539 TDEToolBarButton * button = const_cast<TDEToolBar*>( this )->getButton( id );
00540 return button ? button->isOn() : false;
00541 }
00542
00543
00544 void TDEToolBar::setLinedText (int id, const TQString& text)
00545 {
00546 KLineEdit * lineEdit = getLined( id );
00547 if ( lineEdit )
00548 lineEdit->setText( text );
00549 }
00550
00551
00552 TQString TDEToolBar::getLinedText (int id) const
00553 {
00554 KLineEdit * lineEdit = const_cast<TDEToolBar*>( this )->getLined( id );
00555 return lineEdit ? lineEdit->text() : TQString::null;
00556 }
00557
00558
00559 void TDEToolBar::insertComboItem (int id, const TQString& text, int index)
00560 {
00561 KComboBox * comboBox = getCombo( id );
00562 if (comboBox)
00563 comboBox->insertItem( text, index );
00564 }
00565
00566 void TDEToolBar::insertComboList (int id, const TQStringList &list, int index)
00567 {
00568 KComboBox * comboBox = getCombo( id );
00569 if (comboBox)
00570 comboBox->insertStringList( list, index );
00571 }
00572
00573
00574 void TDEToolBar::removeComboItem (int id, int index)
00575 {
00576 KComboBox * comboBox = getCombo( id );
00577 if (comboBox)
00578 comboBox->removeItem( index );
00579 }
00580
00581
00582 void TDEToolBar::setCurrentComboItem (int id, int index)
00583 {
00584 KComboBox * comboBox = getCombo( id );
00585 if (comboBox)
00586 comboBox->setCurrentItem( index );
00587 }
00588
00589
00590 void TDEToolBar::changeComboItem (int id, const TQString& text, int index)
00591 {
00592 KComboBox * comboBox = getCombo( id );
00593 if (comboBox)
00594 comboBox->changeItem( text, index );
00595 }
00596
00597
00598 void TDEToolBar::clearCombo (int id)
00599 {
00600 KComboBox * comboBox = getCombo( id );
00601 if (comboBox)
00602 comboBox->clear();
00603 }
00604
00605
00606 TQString TDEToolBar::getComboItem (int id, int index) const
00607 {
00608 KComboBox * comboBox = const_cast<TDEToolBar*>( this )->getCombo( id );
00609 return comboBox ? comboBox->text( index ) : TQString::null;
00610 }
00611
00612
00613 KComboBox * TDEToolBar::getCombo(int id)
00614 {
00615 Id2WidgetMap::Iterator it = id2widget.find( id );
00616 if ( it == id2widget.end() )
00617 return 0;
00618 return tqt_dynamic_cast<KComboBox *>( *it );
00619 }
00620
00621
00622 KLineEdit * TDEToolBar::getLined (int id)
00623 {
00624 Id2WidgetMap::Iterator it = id2widget.find( id );
00625 if ( it == id2widget.end() )
00626 return 0;
00627 return tqt_dynamic_cast<KLineEdit *>( *it );
00628 }
00629
00630
00631 TDEToolBarButton * TDEToolBar::getButton (int id)
00632 {
00633 Id2WidgetMap::Iterator it = id2widget.find( id );
00634 if ( it == id2widget.end() )
00635 return 0;
00636 return tqt_dynamic_cast<TDEToolBarButton *>( *it );
00637 }
00638
00639
00640 void TDEToolBar::alignItemRight (int id, bool right )
00641 {
00642 Id2WidgetMap::Iterator it = id2widget.find( id );
00643 if ( it == id2widget.end() )
00644 return;
00645 if ( rightAligned && !right && (*it) == rightAligned )
00646 rightAligned = 0;
00647 if ( (*it) && right )
00648 rightAligned = (*it);
00649 }
00650
00651
00652 TQWidget *TDEToolBar::getWidget (int id)
00653 {
00654 Id2WidgetMap::Iterator it = id2widget.find( id );
00655 return ( it == id2widget.end() ) ? 0 : (*it);
00656 }
00657
00658
00659 void TDEToolBar::setItemAutoSized (int id, bool yes )
00660 {
00661 TQWidget *w = getWidget(id);
00662 if ( w && yes )
00663 setStretchableWidget( w );
00664 }
00665
00666
00667 void TDEToolBar::clear ()
00668 {
00669
00670 for(TQWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
00671 w->blockSignals(false);
00672 d->idleButtons.clear();
00673
00674 TQToolBar::clear();
00675 widget2id.clear();
00676 id2widget.clear();
00677 }
00678
00679
00680 void TDEToolBar::removeItem(int id)
00681 {
00682 Id2WidgetMap::Iterator it = id2widget.find( id );
00683 if ( it == id2widget.end() )
00684 {
00685 kdDebug(220) << name() << " TDEToolBar::removeItem item " << id << " not found" << endl;
00686 return;
00687 }
00688 TQWidget * w = (*it);
00689 id2widget.remove( id );
00690 widget2id.remove( w );
00691 widgets.removeRef( w );
00692 delete w;
00693 }
00694
00695
00696 void TDEToolBar::removeItemDelayed(int id)
00697 {
00698 Id2WidgetMap::Iterator it = id2widget.find( id );
00699 if ( it == id2widget.end() )
00700 {
00701 kdDebug(220) << name() << " TDEToolBar::removeItem item " << id << " not found" << endl;
00702 return;
00703 }
00704 TQWidget * w = (*it);
00705 id2widget.remove( id );
00706 widget2id.remove( w );
00707 widgets.removeRef( w );
00708
00709 w->blockSignals(true);
00710 d->idleButtons.append(w);
00711 layoutTimer->start( 50, true );
00712 }
00713
00714
00715 void TDEToolBar::hideItem (int id)
00716 {
00717 TQWidget *w = getWidget(id);
00718 if ( w )
00719 w->hide();
00720 }
00721
00722
00723 void TDEToolBar::showItem (int id)
00724 {
00725 TQWidget *w = getWidget(id);
00726 if ( w )
00727 w->show();
00728 }
00729
00730
00731 int TDEToolBar::itemIndex (int id)
00732 {
00733 TQWidget *w = getWidget(id);
00734 return w ? widgets.findRef(w) : -1;
00735 }
00736
00737 int TDEToolBar::idAt (int index)
00738 {
00739 TQWidget *w = widgets.at(index);
00740 return widget2id[w];
00741 }
00742
00743 void TDEToolBar::setFullSize(bool flag )
00744 {
00745 setHorizontalStretchable( flag );
00746 setVerticalStretchable( flag );
00747 }
00748
00749
00750 bool TDEToolBar::fullSize() const
00751 {
00752 return isHorizontalStretchable() || isVerticalStretchable();
00753 }
00754
00755
00756 void TDEToolBar::enableMoving(bool flag )
00757 {
00758 setMovingEnabled(flag);
00759 }
00760
00761
00762 void TDEToolBar::setBarPos (BarPosition bpos)
00763 {
00764 if ( !mainWindow() )
00765 return;
00766 mainWindow()->moveDockWindow( this, (Dock)bpos );
00767
00768 }
00769
00770
00771 TDEToolBar::BarPosition TDEToolBar::barPos() const
00772 {
00773 if ( !this->mainWindow() )
00774 return place() == TQDockWindow::InDock ? TDEToolBar::Top : TDEToolBar::Floating;
00775 Dock dock;
00776 int dm1, dm2;
00777 bool dm3;
00778 this->mainWindow()->getLocation( (TQToolBar*)this, dock, dm1, dm3, dm2 );
00779 if ( dock == DockUnmanaged ) {
00780 return (TDEToolBar::BarPosition)DockTop;
00781 }
00782 return (BarPosition)dock;
00783 }
00784
00785
00786 bool TDEToolBar::enable(BarStatus stat)
00787 {
00788 bool mystat = isVisible();
00789
00790 if ( (stat == Toggle && mystat) || stat == Hide )
00791 hide();
00792 else
00793 show();
00794
00795 return isVisible() == mystat;
00796 }
00797
00798
00799 void TDEToolBar::setMaxHeight ( int h )
00800 {
00801 setMaximumHeight( h );
00802 }
00803
00804 int TDEToolBar::maxHeight()
00805 {
00806 return maximumHeight();
00807 }
00808
00809
00810 void TDEToolBar::setMaxWidth (int dw)
00811 {
00812 setMaximumWidth( dw );
00813 }
00814
00815
00816 int TDEToolBar::maxWidth()
00817 {
00818 return maximumWidth();
00819 }
00820
00821
00822 void TDEToolBar::setTitle (const TQString& _title)
00823 {
00824 setLabel( _title );
00825 }
00826
00827
00828 void TDEToolBar::enableFloating (bool )
00829 {
00830 }
00831
00832
00833 void TDEToolBar::setIconText(IconText it)
00834 {
00835 setIconText( it, true );
00836 }
00837
00838
00839 void TDEToolBar::setIconText(IconText icontext, bool update)
00840 {
00841 bool doUpdate=false;
00842
00843 if (icontext != d->m_iconText) {
00844 d->m_iconText = icontext;
00845 doUpdate=true;
00846
00847 }
00848 else {
00849
00850 }
00851
00852 if (!update)
00853 return;
00854
00855 if (doUpdate)
00856 doModeChange();
00857
00858
00859 TQMainWindow *mw = mainWindow();
00860 if ( mw ) {
00861 mw->setUpdatesEnabled( false );
00862 mw->setToolBarsMovable( !mw->toolBarsMovable() );
00863 mw->setToolBarsMovable( !mw->toolBarsMovable() );
00864 mw->setUpdatesEnabled( true );
00865 }
00866 }
00867
00868
00869 TDEToolBar::IconText TDEToolBar::iconText() const
00870 {
00871 return d->m_iconText;
00872 }
00873
00874
00875 void TDEToolBar::setIconSize(int size)
00876 {
00877 setIconSize( size, true );
00878 }
00879
00880 void TDEToolBar::setIconSize(int size, bool update)
00881 {
00882 bool doUpdate=false;
00883
00884 if ( size != d->m_iconSize ) {
00885 d->m_iconSize = size;
00886 doUpdate=true;
00887 }
00888
00889 if (!update)
00890 return;
00891
00892 if (doUpdate)
00893 doModeChange();
00894
00895
00896 if ( mainWindow() ) {
00897 TQMainWindow *mw = mainWindow();
00898 mw->setUpdatesEnabled( false );
00899 mw->setToolBarsMovable( !mw->toolBarsMovable() );
00900 mw->setToolBarsMovable( !mw->toolBarsMovable() );
00901 mw->setUpdatesEnabled( true );
00902 }
00903 }
00904
00905 int TDEToolBar::iconSize() const
00906 {
00907 if ( !d->m_iconSize )
00908 return iconSizeDefault();
00909
00910 return d->m_iconSize;
00911 }
00912
00913 int TDEToolBar::iconSizeDefault() const
00914 {
00915 if (!::qstrcmp(name(), "mainToolBar"))
00916 return TDEGlobal::iconLoader()->currentSize(TDEIcon::MainToolbar);
00917
00918 return TDEGlobal::iconLoader()->currentSize(TDEIcon::Toolbar);
00919 }
00920
00921 void TDEToolBar::setEnableContextMenu(bool enable )
00922 {
00923 d->m_enableContext = enable;
00924 }
00925
00926
00927 bool TDEToolBar::contextMenuEnabled() const
00928 {
00929 return d->m_enableContext;
00930 }
00931
00932
00933 void TDEToolBar::setItemNoStyle(int id, bool no_style )
00934 {
00935 TDEToolBarButton * button = getButton( id );
00936 if (button)
00937 button->setNoStyle( no_style );
00938 }
00939
00940
00941 void TDEToolBar::setFlat (bool flag)
00942 {
00943 if ( !mainWindow() )
00944 return;
00945 if ( flag )
00946 mainWindow()->moveDockWindow( this, DockMinimized );
00947 else
00948 mainWindow()->moveDockWindow( this, DockTop );
00949
00950 TDEMainWindow *kmw = tqt_dynamic_cast<TDEMainWindow *>(mainWindow());
00951 if ( kmw )
00952 kmw->setSettingsDirty();
00953 }
00954
00955
00956 int TDEToolBar::count() const
00957 {
00958 return id2widget.count();
00959 }
00960
00961
00962 void TDEToolBar::saveState()
00963 {
00964
00965 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
00966
00967 TQString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
00968
00969 d->modified = false;
00970
00971 TQDomElement current;
00972 for( TQDomNode n = d->m_xmlguiClient->domDocument().documentElement().firstChild();
00973 !n.isNull(); n = n.nextSibling()) {
00974 current = n.toElement();
00975
00976 if ( current.tagName().lower() != "toolbar" )
00977 continue;
00978
00979 TQString curname(current.attribute( "name" ));
00980
00981 if ( curname == barname ) {
00982 saveState( current );
00983 break;
00984 }
00985 }
00986
00987 if ( !d->modified )
00988 return;
00989
00990
00991 TQString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
00992 TQDomDocument local;
00993 local.setContent(local_xml);
00994
00995
00996 bool just_append = true;
00997
00998 for( TQDomNode n = local.documentElement().firstChild();
00999 !n.isNull(); n = n.nextSibling()) {
01000 TQDomElement elem = n.toElement();
01001
01002 if ( elem.tagName().lower() != "toolbar" )
01003 continue;
01004
01005 TQString curname(elem.attribute( "name" ));
01006
01007 if ( curname == barname ) {
01008 just_append = false;
01009 local.documentElement().replaceChild( current, elem );
01010 break;
01011 }
01012 }
01013
01014 if (just_append)
01015 local.documentElement().appendChild( current );
01016
01017 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
01018
01019 return;
01020 }
01021
01022
01023 TDEConfig *config = TDEGlobal::config();
01024 saveSettings(config, TQString::null);
01025 config->sync();
01026 }
01027
01028 TQString TDEToolBar::settingsGroup() const
01029 {
01030 TQString configGroup;
01031 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
01032 configGroup = "Toolbar style";
01033 else
01034 configGroup = TQString(name()) + " Toolbar style";
01035 if ( this->mainWindow() )
01036 {
01037 configGroup.prepend(" ");
01038 configGroup.prepend( this->mainWindow()->name() );
01039 }
01040 return configGroup;
01041 }
01042
01043 void TDEToolBar::saveSettings(TDEConfig *config, const TQString &_configGroup)
01044 {
01045 TQString configGroup = _configGroup;
01046 if (configGroup.isEmpty())
01047 configGroup = settingsGroup();
01048
01049
01050 TQString position, icontext;
01051 int index;
01052 getAttributes( position, icontext, index );
01053
01054
01055
01056 TDEConfigGroupSaver saver(config, configGroup);
01057
01058 if(!config->hasDefault("Position") && position == d->PositionDefault )
01059 config->revertToDefault("Position");
01060 else
01061 config->writeEntry("Position", position);
01062
01063
01064
01065 if(d->m_honorStyle && icontext == d->IconTextDefault && !config->hasDefault("IconText") )
01066 {
01067
01068 config->revertToDefault("IconText");
01069 }
01070 else
01071 {
01072
01073 config->writeEntry("IconText", icontext);
01074 }
01075
01076 if(!config->hasDefault("IconSize") && iconSize() == iconSizeDefault() )
01077 config->revertToDefault("IconSize");
01078 else
01079 config->writeEntry("IconSize", iconSize());
01080
01081 if(!config->hasDefault("Hidden") && isHidden() == d->HiddenDefault )
01082 config->revertToDefault("Hidden");
01083 else
01084 config->writeEntry("Hidden", isHidden());
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096 TDEMainWindow *kmw = tqt_dynamic_cast<TDEMainWindow *>(mainWindow());
01097
01098
01099
01100
01101 TQPtrList<TDEToolBar> toolbarList;
01102 TQPtrList<TQToolBar> lst;
01103 for ( int i = (int)TQMainWindow::DockUnmanaged; i <= (int)DockMinimized; ++i ) {
01104 lst = kmw->toolBars( (ToolBarDock)i );
01105 for ( TQToolBar *tb = lst.first(); tb; tb = lst.next() ) {
01106 if ( !tb->inherits( "TDEToolBar" ) )
01107 continue;
01108 toolbarList.append( (TDEToolBar*)tb );
01109 }
01110 }
01111 TQPtrListIterator<TDEToolBar> toolbarIterator( toolbarList );
01112 if ( !kmw || toolbarIterator.count() > 1 )
01113 config->writeEntry("Index", index);
01114 else
01115 config->revertToDefault("Index");
01116
01117 if(!config->hasDefault("Offset") && offset() == d->OffsetDefault )
01118 config->revertToDefault("Offset");
01119 else
01120 config->writeEntry("Offset", offset());
01121
01122 if(!config->hasDefault("NewLine") && newLine() == d->NewLineDefault )
01123 config->revertToDefault("NewLine");
01124 else
01125 config->writeEntry("NewLine", newLine());
01126 }
01127
01128
01129 void TDEToolBar::setXMLGUIClient( KXMLGUIClient *client )
01130 {
01131 d->m_xmlguiClient = client;
01132 }
01133
01134 void TDEToolBar::setText( const TQString & txt )
01135 {
01136 setLabel( txt + " (" + kapp->caption() + ") " );
01137 }
01138
01139
01140 TQString TDEToolBar::text() const
01141 {
01142 return label();
01143 }
01144
01145
01146 void TDEToolBar::doConnections( TDEToolBarButton *button )
01147 {
01148 connect(button, TQT_SIGNAL(clicked(int)), this, TQT_SIGNAL( clicked( int ) ) );
01149 connect(button, TQT_SIGNAL(doubleClicked(int)), this, TQT_SIGNAL( doubleClicked( int ) ) );
01150 connect(button, TQT_SIGNAL(released(int)), this, TQT_SIGNAL( released( int ) ) );
01151 connect(button, TQT_SIGNAL(pressed(int)), this, TQT_SIGNAL( pressed( int ) ) );
01152 connect(button, TQT_SIGNAL(toggled(int)), this, TQT_SIGNAL( toggled( int ) ) );
01153 connect(button, TQT_SIGNAL(highlighted(int, bool)), this, TQT_SIGNAL( highlighted( int, bool ) ) );
01154 }
01155
01156 void TDEToolBar::mousePressEvent ( TQMouseEvent *m )
01157 {
01158 if ( !mainWindow() )
01159 return;
01160 TQMainWindow *mw = mainWindow();
01161 if ( mw->toolBarsMovable() && d->m_enableContext ) {
01162 if ( m->button() == Qt::RightButton ) {
01163 TQGuardedPtr<TDEToolBar> guard( this );
01164 int i = contextMenu()->exec( m->globalPos(), 0 );
01165
01166 if ( guard )
01167 slotContextAboutToHide();
01168 switch ( i ) {
01169 case -1:
01170 return;
01171 case CONTEXT_LEFT:
01172 mw->moveDockWindow( this, DockLeft );
01173 break;
01174 case CONTEXT_RIGHT:
01175 mw->moveDockWindow( this, DockRight );
01176 break;
01177 case CONTEXT_TOP:
01178 mw->moveDockWindow( this, DockTop );
01179 break;
01180 case CONTEXT_BOTTOM:
01181 mw->moveDockWindow( this, DockBottom );
01182 break;
01183 case CONTEXT_FLOAT:
01184 mw->moveDockWindow( this, DockTornOff );
01185 break;
01186 case CONTEXT_FLAT:
01187 mw->moveDockWindow( this, DockMinimized );
01188 break;
01189 case CONTEXT_ICONS:
01190 setIconText( IconOnly );
01191 break;
01192 case CONTEXT_TEXTRIGHT:
01193 setIconText( IconTextRight );
01194 break;
01195 case CONTEXT_TEXT:
01196 setIconText( TextOnly );
01197 break;
01198 case CONTEXT_TEXTUNDER:
01199 setIconText( IconTextBottom );
01200 break;
01201 default:
01202 if ( i >= CONTEXT_ICONSIZES )
01203 setIconSize( i - CONTEXT_ICONSIZES );
01204 else
01205 return;
01206 }
01207 TDEMainWindow *kmw = tqt_dynamic_cast<TDEMainWindow *>(mw);
01208 if ( kmw )
01209 kmw->setSettingsDirty();
01210 }
01211 }
01212 }
01213
01214 void TDEToolBar::doModeChange()
01215 {
01216 for(TQWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
01217 w->blockSignals(false);
01218 d->idleButtons.clear();
01219
01220 emit modechange();
01221 }
01222
01223 void TDEToolBar::rebuildLayout()
01224 {
01225 for(TQWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
01226 w->blockSignals(false);
01227 d->idleButtons.clear();
01228
01229 layoutTimer->stop();
01230 TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
01231 TQBoxLayout *l = boxLayout();
01232
01233
01234 TQLayoutIterator it = l->iterator();
01235 while ( it.current() )
01236 it.deleteCurrent();
01237
01238 for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) {
01239 if ( w == rightAligned )
01240 continue;
01241 TDEToolBarSeparator *ktbs = tqt_dynamic_cast<TDEToolBarSeparator *>(w);
01242 if ( ktbs && !ktbs->showLine() ) {
01243 l->addSpacing( orientation() == Qt::Vertical ? w->sizeHint().height() : w->sizeHint().width() );
01244 w->hide();
01245 continue;
01246 }
01247 if ( tqt_dynamic_cast<TQPopupMenu *>(w) )
01248 continue;
01249 l->addWidget( w );
01250 w->show();
01251 if ((orientation() == Qt::Horizontal) && tqt_dynamic_cast<TQLineEdit *>(w))
01252 l->addSpacing(2);
01253 }
01254 if ( rightAligned ) {
01255 l->addStretch();
01256 l->addWidget( rightAligned );
01257 rightAligned->show();
01258 }
01259
01260 if ( fullSize() ) {
01261 if ( !rightAligned )
01262 l->addStretch();
01263 if ( stretchableWidget )
01264 l->setStretchFactor( stretchableWidget, 10 );
01265 }
01266 l->invalidate();
01267 TQApplication::postEvent( this, new TQEvent( TQEvent::LayoutHint ) );
01268 }
01269
01270 void TDEToolBar::childEvent( TQChildEvent *e )
01271 {
01272 if ( e->child()->isWidgetType() ) {
01273 TQWidget * w = tqt_dynamic_cast<TQWidget *>(e->child());
01274 if (!w || !(::qstrcmp( "qt_dockwidget_internal", w->name())))
01275 {
01276 TQToolBar::childEvent( e );
01277 return;
01278 }
01279 if ( e->type() == TQEvent::ChildInserted ) {
01280 if ( !tqt_dynamic_cast<TQPopupMenu *>(w)) {
01281
01282
01283 if ( !widget2id.contains( w ) )
01284 {
01285 int dummy = -1;
01286 insertWidgetInternal( w, dummy, -1 );
01287 }
01288 }
01289 } else {
01290 removeWidgetInternal( w );
01291 }
01292 if ( isVisibleTo( 0 ) )
01293 {
01294 layoutTimer->start( 50, true );
01295 TQBoxLayout *l = boxLayout();
01296
01297
01298
01299 TQLayoutIterator it = l->iterator();
01300 while ( it.current() )
01301 it.deleteCurrent();
01302 }
01303 }
01304 TQToolBar::childEvent( e );
01305 }
01306
01307 void TDEToolBar::insertWidgetInternal( TQWidget *w, int &index, int id )
01308 {
01309
01310
01311
01312 connect( w, TQT_SIGNAL( destroyed() ),
01313 this, TQT_SLOT( widgetDestroyed() ) );
01314 if ( index == -1 || index > (int)widgets.count() ) {
01315 index = (int)widgets.count();
01316 widgets.append( w );
01317 }
01318 else
01319 widgets.insert( index, w );
01320 if ( id == -1 )
01321 id = id2widget.count();
01322 id2widget.insert( id, w );
01323 widget2id.insert( w, id );
01324 }
01325
01326 void TDEToolBar::showEvent( TQShowEvent *e )
01327 {
01328 TQToolBar::showEvent( e );
01329 rebuildLayout();
01330 }
01331
01332 void TDEToolBar::setStretchableWidget( TQWidget *w )
01333 {
01334 TQToolBar::setStretchableWidget( w );
01335 stretchableWidget = w;
01336 }
01337
01338 TQSizePolicy TDEToolBar::sizePolicy() const
01339 {
01340 if ( orientation() == Qt::Horizontal )
01341 return TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed );
01342 else
01343 return TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Expanding );
01344 }
01345
01346 TQSize TDEToolBar::sizeHint() const
01347 {
01348 TQSize minSize(0,0);
01349 TDEToolBar *ncThis = const_cast<TDEToolBar *>(this);
01350
01351 ncThis->polish();
01352
01353 int margin = static_cast<TQWidget*>(ncThis)->layout()->margin() + frameWidth();
01354 switch( barPos() )
01355 {
01356 case TDEToolBar::Top:
01357 case TDEToolBar::Bottom:
01358 for ( TQWidget *w = ncThis->widgets.first(); w; w = ncThis->widgets.next() )
01359 {
01360 TQSize sh = w->sizeHint();
01361 if ( w->sizePolicy().horData() == TQSizePolicy::Ignored )
01362 sh.setWidth( 1 );
01363 if ( w->sizePolicy().verData() == TQSizePolicy::Ignored )
01364 sh.setHeight( 1 );
01365 sh = sh.boundedTo( w->maximumSize() )
01366 .expandedTo( w->minimumSize() ).expandedTo( TQSize(1, 1) );
01367
01368 minSize = minSize.expandedTo(TQSize(0, sh.height()));
01369 minSize += TQSize(sh.width()+1, 0);
01370 if (tqt_dynamic_cast<TQLineEdit *>(w))
01371 minSize += TQSize(2, 0);
01372 }
01373
01374 minSize += TQSize(TQApplication::style().pixelMetric( TQStyle::PM_DockWindowHandleExtent ), 0);
01375 minSize += TQSize(margin*2, margin*2);
01376 break;
01377
01378 case TDEToolBar::Left:
01379 case TDEToolBar::Right:
01380 for ( TQWidget *w = ncThis->widgets.first(); w; w = ncThis->widgets.next() )
01381 {
01382 TQSize sh = w->sizeHint();
01383 if ( w->sizePolicy().horData() == TQSizePolicy::Ignored )
01384 sh.setWidth( 1 );
01385 if ( w->sizePolicy().verData() == TQSizePolicy::Ignored )
01386 sh.setHeight( 1 );
01387 sh = sh.boundedTo( w->maximumSize() )
01388 .expandedTo( w->minimumSize() ).expandedTo( TQSize(1, 1) );
01389
01390 minSize = minSize.expandedTo(TQSize(sh.width(), 0));
01391 minSize += TQSize(0, sh.height()+1);
01392 }
01393 minSize += TQSize(0, TQApplication::style().pixelMetric( TQStyle::PM_DockWindowHandleExtent ));
01394 minSize += TQSize(margin*2, margin*2);
01395 break;
01396
01397 default:
01398 minSize = TQToolBar::sizeHint();
01399 break;
01400 }
01401 return minSize;
01402 }
01403
01404 TQSize TDEToolBar::minimumSize() const
01405 {
01406 return minimumSizeHint();
01407 }
01408
01409 TQSize TDEToolBar::minimumSizeHint() const
01410 {
01411 return sizeHint();
01412 }
01413
01414 bool TDEToolBar::highlight() const
01415 {
01416 return d->m_highlight;
01417 }
01418
01419 void TDEToolBar::hide()
01420 {
01421 TQToolBar::hide();
01422 }
01423
01424 void TDEToolBar::show()
01425 {
01426 TQToolBar::show();
01427 }
01428
01429 void TDEToolBar::resizeEvent( TQResizeEvent *e )
01430 {
01431 bool b = isUpdatesEnabled();
01432 setUpdatesEnabled( false );
01433 TQToolBar::resizeEvent( e );
01434 if (b)
01435 {
01436 if (layoutTimer->isActive())
01437 {
01438
01439 d->repaintTimer.start( 100, true );
01440 }
01441 else
01442 {
01443
01444 slotRepaint();
01445 }
01446 }
01447
01448
01449
01450
01451 }
01452
01453 void TDEToolBar::slotIconChanged(int group)
01454 {
01455 if ((group != TDEIcon::Toolbar) && (group != TDEIcon::MainToolbar))
01456 return;
01457 if ((group == TDEIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
01458 return;
01459
01460 doModeChange();
01461
01462 if (isVisible())
01463 updateGeometry();
01464 }
01465
01466 void TDEToolBar::slotReadConfig()
01467 {
01468
01469
01470
01471
01472 applyAppearanceSettings(TDEGlobal::config(), TQString::null );
01473 }
01474
01475 void TDEToolBar::slotAppearanceChanged()
01476 {
01477
01478 applyAppearanceSettings(TDEGlobal::config(), TQString::null, true );
01479
01480
01481 TDEMainWindow *kmw = tqt_dynamic_cast<TDEMainWindow *>(mainWindow());
01482 if ( kmw )
01483 kmw->setSettingsDirty();
01484 }
01485
01486
01487 bool TDEToolBar::highlightSetting()
01488 {
01489 TQString grpToolbar(TQString::fromLatin1("Toolbar style"));
01490 TDEConfigGroupSaver saver(TDEGlobal::config(), grpToolbar);
01491 return TDEGlobal::config()->readBoolEntry(TQString::fromLatin1("Highlighting"),true);
01492 }
01493
01494
01495 bool TDEToolBar::transparentSetting()
01496 {
01497 TQString grpToolbar(TQString::fromLatin1("Toolbar style"));
01498 TDEConfigGroupSaver saver(TDEGlobal::config(), grpToolbar);
01499 return TDEGlobal::config()->readBoolEntry(TQString::fromLatin1("TransparentMoving"),true);
01500 }
01501
01502
01503 TDEToolBar::IconText TDEToolBar::iconTextSetting()
01504 {
01505 TQString grpToolbar(TQString::fromLatin1("Toolbar style"));
01506 TDEConfigGroupSaver saver(TDEGlobal::config(), grpToolbar);
01507 TQString icontext = TDEGlobal::config()->readEntry(TQString::fromLatin1("IconText"),TQString::fromLatin1("IconOnly"));
01508 if ( icontext == "IconTextRight" )
01509 return IconTextRight;
01510 else if ( icontext == "IconTextBottom" )
01511 return IconTextBottom;
01512 else if ( icontext == "TextOnly" )
01513 return TextOnly;
01514 else
01515 return IconOnly;
01516 }
01517
01518 void TDEToolBar::applyAppearanceSettings(TDEConfig *config, const TQString &_configGroup, bool forceGlobal)
01519 {
01520 TQString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
01521
01522
01523
01524
01525
01526
01527
01528 bool xmlgui = d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty();
01529
01530 TDEConfig *gconfig = TDEGlobal::config();
01531
01532 static const TQString &attrIconText = TDEGlobal::staticQString("IconText");
01533 static const TQString &attrHighlight = TDEGlobal::staticQString("Highlighting");
01534 static const TQString &attrTrans = TDEGlobal::staticQString("TransparentMoving");
01535 static const TQString &attrIconSize = TDEGlobal::staticQString("IconSize");
01536
01537
01538
01539
01540 bool highlight;
01541 int transparent;
01542 bool applyIconText = !xmlgui;
01543 bool applyIconSize = !xmlgui;
01544
01545 int iconSize = d->IconSizeDefault;
01546 TQString iconText = d->IconTextDefault;
01547
01548
01549 TQString grpToolbar(TQString::fromLatin1("Toolbar style"));
01550 {
01551 TDEConfigGroupSaver saver(gconfig, grpToolbar);
01552
01553
01554 highlight = gconfig->readBoolEntry(attrHighlight, true);
01555 transparent = gconfig->readBoolEntry(attrTrans, true);
01556
01557
01558
01559 if (d->m_honorStyle)
01560 d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
01561 else
01562 d->IconTextDefault = "IconOnly";
01563
01564
01565 d->IconSizeDefault = gconfig->readNumEntry(attrIconSize, d->IconSizeDefault);
01566
01567 iconSize = d->IconSizeDefault;
01568 iconText = d->IconTextDefault;
01569
01570 if ( !forceGlobal && config->hasGroup(configGroup) )
01571 {
01572 config->setGroup(configGroup);
01573
01574
01575 highlight = config->readBoolEntry(attrHighlight, highlight);
01576 transparent = config->readBoolEntry(attrTrans, transparent);
01577
01578
01579 if ( config->hasKey( attrIconText ) ) {
01580 iconText = config->readEntry(attrIconText);
01581 applyIconText = true;
01582
01583 }
01584
01585
01586 if ( config->hasKey( attrIconSize ) ) {
01587 iconSize = config->readNumEntry(attrIconSize);
01588 applyIconSize = true;
01589 }
01590 }
01591
01592
01593 }
01594
01595 bool doUpdate = false;
01596
01597 IconText icon_text;
01598 if ( iconText == "IconTextRight" )
01599 icon_text = IconTextRight;
01600 else if ( iconText == "IconTextBottom" )
01601 icon_text = IconTextBottom;
01602 else if ( iconText == "TextOnly" )
01603 icon_text = TextOnly;
01604 else
01605 icon_text = IconOnly;
01606
01607
01608 if (icon_text != d->m_iconText && applyIconText) {
01609
01610 setIconText(icon_text, false);
01611 doUpdate = true;
01612 }
01613
01614
01615 if (iconSize != d->m_iconSize && applyIconSize) {
01616 setIconSize(iconSize, false);
01617 doUpdate = true;
01618 }
01619
01620 TQMainWindow *mw = mainWindow();
01621
01622
01623 if ( highlight != d->m_highlight ) {
01624 d->m_highlight = highlight;
01625 doUpdate = true;
01626 }
01627
01628
01629 if ( mw && transparent != (!mw->opaqueMoving()) ) {
01630 mw->setOpaqueMoving( !transparent );
01631 }
01632
01633 if (doUpdate)
01634 doModeChange();
01635
01636 if (isVisible ())
01637 updateGeometry();
01638 }
01639
01640 void TDEToolBar::applySettings(TDEConfig *config, const TQString &_configGroup)
01641 {
01642 return applySettings(config,_configGroup,false);
01643 }
01644
01645 void TDEToolBar::applySettings(TDEConfig *config, const TQString &_configGroup, bool force)
01646 {
01647
01648
01649 TQString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666 applyAppearanceSettings( config, configGroup );
01667
01668
01669 if ( config->hasGroup(configGroup) || force )
01670 {
01671 TDEConfigGroupSaver cgs(config, configGroup);
01672
01673 static const TQString &attrPosition = TDEGlobal::staticQString("Position");
01674 static const TQString &attrIndex = TDEGlobal::staticQString("Index");
01675 static const TQString &attrOffset = TDEGlobal::staticQString("Offset");
01676 static const TQString &attrNewLine = TDEGlobal::staticQString("NewLine");
01677 static const TQString &attrHidden = TDEGlobal::staticQString("Hidden");
01678
01679 TQString position = config->readEntry(attrPosition, d->PositionDefault);
01680 int index = config->readNumEntry(attrIndex, -1);
01681 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
01682 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
01683 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
01684
01685 Dock pos(DockTop);
01686 if ( position == "Top" )
01687 pos = DockTop;
01688 else if ( position == "Bottom" )
01689 pos = DockBottom;
01690 else if ( position == "Left" )
01691 pos = DockLeft;
01692 else if ( position == "Right" )
01693 pos = DockRight;
01694 else if ( position == "Floating" )
01695 pos = DockTornOff;
01696 else if ( position == "Flat" )
01697 pos = DockMinimized;
01698
01699
01700 if (hidden)
01701 hide();
01702 else
01703 show();
01704
01705 if ( mainWindow() )
01706 {
01707
01708 d->toolBarInfo = TDEToolBarPrivate::ToolBarInfo( pos, index, newLine, offset );
01709 positionYourself( true );
01710 }
01711 if (isVisible ())
01712 updateGeometry();
01713 }
01714 }
01715
01716 bool TDEToolBar::event( TQEvent *e )
01717 {
01718 if ( (e->type() == TQEvent::LayoutHint) && isUpdatesEnabled() )
01719 d->repaintTimer.start( 100, true );
01720
01721 if (e->type() == TQEvent::ChildInserted )
01722 {
01723
01724
01725
01726 childEvent((TQChildEvent *)e);
01727 return true;
01728 }
01729
01730 return TQToolBar::event( e );
01731 }
01732
01733 void TDEToolBar::slotRepaint()
01734 {
01735 setUpdatesEnabled( false );
01736
01737
01738
01739 TQResizeEvent ev(size(), size());
01740 resizeEvent(&ev);
01741 TQApplication::sendPostedEvents( this, TQEvent::LayoutHint );
01742 setUpdatesEnabled( true );
01743 repaint( true );
01744 }
01745
01746 void TDEToolBar::toolBarPosChanged( TQToolBar *tb )
01747 {
01748 if ( tb != this )
01749 return;
01750 if ( d->oldPos == DockMinimized )
01751 rebuildLayout();
01752 d->oldPos = (TQMainWindow::ToolBarDock)barPos();
01753 TDEMainWindow *kmw = tqt_dynamic_cast<TDEMainWindow *>(mainWindow());
01754 if ( kmw )
01755 kmw->setSettingsDirty();
01756 }
01757
01758 static TDEToolBar::Dock stringToDock( const TQString& attrPosition )
01759 {
01760 TDEToolBar::Dock dock = TDEToolBar::DockTop;
01761 if ( !attrPosition.isEmpty() ) {
01762 if ( attrPosition == "top" )
01763 dock = TDEToolBar::DockTop;
01764 else if ( attrPosition == "left" )
01765 dock = TDEToolBar::DockLeft;
01766 else if ( attrPosition == "right" )
01767 dock = TDEToolBar::DockRight;
01768 else if ( attrPosition == "bottom" )
01769 dock = TDEToolBar::DockBottom;
01770 else if ( attrPosition == "floating" )
01771 dock = TDEToolBar::DockTornOff;
01772 else if ( attrPosition == "flat" )
01773 dock = TDEToolBar::DockMinimized;
01774 }
01775 return dock;
01776 }
01777
01778
01779 void TDEToolBar::loadState( const TQDomElement &element )
01780 {
01781 TQMainWindow *mw = mainWindow();
01782
01783 if ( !mw )
01784 return;
01785
01786 {
01787 TQCString text = element.namedItem( "text" ).toElement().text().utf8();
01788 if ( text.isEmpty() )
01789 text = element.namedItem( "Text" ).toElement().text().utf8();
01790 if ( !text.isEmpty() )
01791 setText( i18n( text ) );
01792 }
01793
01794 {
01795 TQCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1();
01796 if ( !attrFullWidth.isEmpty() )
01797 setFullSize( attrFullWidth == "true" );
01798 }
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816 bool loadingAppDefaults = true;
01817 if ( element.hasAttribute( "offsetDefault" ) )
01818 {
01819
01820 loadingAppDefaults = false;
01821 d->OffsetDefault = element.attribute( "offsetDefault" ).toInt();
01822 d->NewLineDefault = element.attribute( "newlineDefault" ) == "true";
01823 d->HiddenDefault = element.attribute( "hiddenDefault" ) == "true";
01824 d->IconSizeDefault = element.attribute( "iconSizeDefault" ).toInt();
01825 d->PositionDefault = element.attribute( "positionDefault" );
01826 d->IconTextDefault = element.attribute( "iconTextDefault" );
01827 }
01828
01829
01830 Dock dock = stringToDock( element.attribute( "position" ).lower() );
01831
01832 {
01833 TQCString attrIconText = element.attribute( "iconText" ).lower().latin1();
01834 if ( !attrIconText.isEmpty() ) {
01835
01836 if ( attrIconText == "icontextright" )
01837 setIconText( TDEToolBar::IconTextRight );
01838 else if ( attrIconText == "textonly" )
01839 setIconText( TDEToolBar::TextOnly );
01840 else if ( attrIconText == "icontextbottom" )
01841 setIconText( TDEToolBar::IconTextBottom );
01842 else if ( attrIconText == "icononly" )
01843 setIconText( TDEToolBar::IconOnly );
01844 } else
01845 {
01846
01847
01848 if (d->m_honorStyle)
01849 setIconText( iconTextSetting() );
01850 else
01851 setIconText( d->IconTextDefault );
01852 }
01853 }
01854
01855 TQString attrIconSize = element.attribute( "iconSize" ).lower();
01856 int iconSize = d->IconSizeDefault;
01857 if ( !attrIconSize.isEmpty() )
01858 iconSize = attrIconSize.toInt();
01859 setIconSize( iconSize );
01860
01861 int index = -1;
01862
01863 {
01864 TQString attrIndex = element.attribute( "index" ).lower();
01865 if ( !attrIndex.isEmpty() )
01866 index = attrIndex.toInt();
01867 }
01868
01869 int offset = d->OffsetDefault;
01870 bool newLine = d->NewLineDefault;
01871 bool hidden = d->HiddenDefault;
01872
01873 {
01874 TQString attrOffset = element.attribute( "offset" );
01875 if ( !attrOffset.isEmpty() )
01876 offset = attrOffset.toInt();
01877 }
01878
01879 {
01880 TQString attrNewLine = element.attribute( "newline" ).lower();
01881 if ( !attrNewLine.isEmpty() )
01882 newLine = attrNewLine == "true";
01883 }
01884
01885 {
01886 TQString attrHidden = element.attribute( "hidden" ).lower();
01887 if ( !attrHidden.isEmpty() ) {
01888 hidden = attrHidden == "true";
01889 }
01890 }
01891
01892 d->toolBarInfo = TDEToolBarPrivate::ToolBarInfo( dock, index, newLine, offset );
01893 mw->addDockWindow( this, dock, newLine );
01894 mw->moveDockWindow( this, dock, newLine, index, offset );
01895
01896
01897 d->m_highlight = highlightSetting();
01898
01899 if ( hidden )
01900 hide();
01901 else
01902 show();
01903
01904 if ( loadingAppDefaults )
01905 {
01906 getAttributes( d->PositionDefault, d->IconTextDefault, index );
01907
01908 d->OffsetDefault = offset;
01909 d->NewLineDefault = newLine;
01910 d->HiddenDefault = hidden;
01911 d->IconSizeDefault = iconSize;
01912 }
01913
01914
01915
01916
01917
01918 if ( transparentSetting() != !mw->opaqueMoving() ) {
01919 mw->setOpaqueMoving( !transparentSetting() );
01920 }
01921 }
01922
01923 int TDEToolBar::dockWindowIndex()
01924 {
01925 int index = 0;
01926 Q_ASSERT( mainWindow() );
01927 if ( mainWindow() ) {
01928 TQMainWindow::ToolBarDock dock;
01929 bool newLine;
01930 int offset;
01931 mainWindow()->getLocation( this, dock, index, newLine, offset );
01932 }
01933 return index;
01934 }
01935
01936 void TDEToolBar::getAttributes( TQString &position, TQString &icontext, int &index )
01937 {
01938
01939 switch ( barPos() ) {
01940 case TDEToolBar::Flat:
01941 position = "Flat";
01942 break;
01943 case TDEToolBar::Bottom:
01944 position = "Bottom";
01945 break;
01946 case TDEToolBar::Left:
01947 position = "Left";
01948 break;
01949 case TDEToolBar::Right:
01950 position = "Right";
01951 break;
01952 case TDEToolBar::Floating:
01953 position = "Floating";
01954 break;
01955 case TDEToolBar::Top:
01956 default:
01957 position = "Top";
01958 break;
01959 }
01960
01961 index = dockWindowIndex();
01962
01963 switch (d->m_iconText) {
01964 case TDEToolBar::IconTextRight:
01965 icontext = "IconTextRight";
01966 break;
01967 case TDEToolBar::IconTextBottom:
01968 icontext = "IconTextBottom";
01969 break;
01970 case TDEToolBar::TextOnly:
01971 icontext = "TextOnly";
01972 break;
01973 case TDEToolBar::IconOnly:
01974 default:
01975 icontext = "IconOnly";
01976 break;
01977 }
01978
01979 }
01980
01981 void TDEToolBar::saveState( TQDomElement ¤t )
01982 {
01983 Q_ASSERT( !current.isNull() );
01984 TQString position, icontext;
01985 int index = -1;
01986 getAttributes( position, icontext, index );
01987
01988 current.setAttribute( "noMerge", "1" );
01989 current.setAttribute( "position", position );
01990 current.setAttribute( "iconText", icontext );
01991 current.setAttribute( "index", index );
01992 current.setAttribute( "offset", offset() );
01993 current.setAttribute( "newline", newLine() );
01994 if ( isHidden() )
01995 current.setAttribute( "hidden", "true" );
01996 d->modified = true;
01997
01998
01999
02000 current.setAttribute( "offsetDefault", d->OffsetDefault );
02001 current.setAttribute( "newlineDefault", d->NewLineDefault );
02002 current.setAttribute( "hiddenDefault", d->HiddenDefault ? "true" : "false" );
02003 current.setAttribute( "iconSizeDefault", d->IconSizeDefault );
02004 current.setAttribute( "positionDefault", d->PositionDefault );
02005 current.setAttribute( "iconTextDefault", d->IconTextDefault );
02006
02007
02008 }
02009
02010
02011 void TDEToolBar::positionYourself( bool force )
02012 {
02013 if (force)
02014 d->positioned = false;
02015
02016 if ( d->positioned || !mainWindow() )
02017 {
02018
02019 return;
02020 }
02021
02022
02023 bool hidden = isHidden();
02024
02025 mainWindow()->moveDockWindow( this, d->toolBarInfo.dock,
02026 d->toolBarInfo.newline,
02027 d->toolBarInfo.index,
02028 d->toolBarInfo.offset );
02029
02030
02031 if ( hidden )
02032 hide();
02033 else
02034 show();
02035
02036 d->positioned = true;
02037 }
02038
02039 TDEPopupMenu *TDEToolBar::contextMenu()
02040 {
02041 if ( context )
02042 return context;
02043
02044
02045 context = new TDEPopupMenu( this, "qt_dockwidget_internal" );
02046 context->insertTitle(i18n("Toolbar Menu"));
02047
02048 TDEPopupMenu *orient = new TDEPopupMenu( context, "orient" );
02049 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP );
02050 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT );
02051 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT );
02052 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM );
02053 orient->insertSeparator(-1);
02054 orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT );
02055 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT );
02056
02057 TDEPopupMenu *mode = new TDEPopupMenu( context, "mode" );
02058 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS );
02059 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT );
02060 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT );
02061 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER );
02062
02063 TDEPopupMenu *size = new TDEPopupMenu( context, "size" );
02064 size->insertItem( i18n("Default"), CONTEXT_ICONSIZES );
02065
02066 TDEIconTheme *theme = TDEGlobal::instance()->iconLoader()->theme();
02067 TQValueList<int> avSizes;
02068 if (theme)
02069 {
02070 if (!::qstrcmp(name(), "mainToolBar"))
02071 avSizes = theme->querySizes( TDEIcon::MainToolbar);
02072 else
02073 avSizes = theme->querySizes( TDEIcon::Toolbar);
02074 }
02075
02076 d->iconSizes = avSizes;
02077 qHeapSort(avSizes);
02078
02079 TQValueList<int>::Iterator it;
02080 if (avSizes.count() < 10) {
02081
02082 TQValueList<int>::Iterator end(avSizes.end());
02083 for (it=avSizes.begin(); it!=end; ++it) {
02084 TQString text;
02085 if ( *it < 19 )
02086 text = i18n("Small (%1x%2)").arg(*it).arg(*it);
02087 else if (*it < 25)
02088 text = i18n("Medium (%1x%2)").arg(*it).arg(*it);
02089 else if (*it < 35)
02090 text = i18n("Large (%1x%2)").arg(*it).arg(*it);
02091 else
02092 text = i18n("Huge (%1x%2)").arg(*it).arg(*it);
02093
02094 size->insertItem( text, CONTEXT_ICONSIZES + *it );
02095 }
02096 }
02097 else {
02098
02099 const int progression[] = {16, 22, 32, 48, 64, 96, 128, 192, 256};
02100
02101 it = avSizes.begin();
02102 for (uint i = 0; i < 9; i++) {
02103 while (it++ != avSizes.end()) {
02104 if (*it >= progression[i]) {
02105 TQString text;
02106 if ( *it < 19 )
02107 text = i18n("Small (%1x%2)").arg(*it).arg(*it);
02108 else if (*it < 25)
02109 text = i18n("Medium (%1x%2)").arg(*it).arg(*it);
02110 else if (*it < 35)
02111 text = i18n("Large (%1x%2)").arg(*it).arg(*it);
02112 else
02113 text = i18n("Huge (%1x%2)").arg(*it).arg(*it);
02114
02115 size->insertItem( text, CONTEXT_ICONSIZES + *it );
02116 break;
02117 }
02118 }
02119 }
02120 }
02121
02122 context->insertItem( i18n("Orientation"), orient );
02123 orient->setItemChecked(CONTEXT_TOP, true);
02124 context->insertItem( i18n("Text Position"), mode );
02125 context->setItemChecked(CONTEXT_ICONS, true);
02126 context->insertItem( i18n("Icon Size"), size );
02127
02128 connect( context, TQT_SIGNAL( aboutToShow() ), this, TQT_SLOT( slotContextAboutToShow() ) );
02129
02130
02131
02132 return context;
02133 }
02134
02135 void TDEToolBar::slotContextAboutToShow()
02136 {
02137
02138
02139
02140
02141
02142 TDEMainWindow *kmw = tqt_dynamic_cast<TDEMainWindow *>(mainWindow());
02143 if ( kmw ) {
02144 kmw->setupToolbarMenuActions();
02145
02146 TDEAction *tbAction = kmw->toolBarMenuAction();
02147 if ( tbAction && tbAction->containerCount() > 0 )
02148 tbAction->plug(context);
02149 }
02150
02151
02152 TDEAction *configureAction = 0;
02153 const char* actionName = KStdAction::name(KStdAction::ConfigureToolbars);
02154 if ( d->m_xmlguiClient )
02155 configureAction = d->m_xmlguiClient->actionCollection()->action(actionName);
02156 if ( !configureAction && kmw )
02157 configureAction = kmw->actionCollection()->action(actionName);
02158 if ( configureAction )
02159 configureAction->plug(context);
02160 KEditToolbar::setDefaultToolbar(name());
02161
02162 for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i)
02163 context->setItemChecked(i, false);
02164
02165 switch( d->m_iconText )
02166 {
02167 case IconOnly:
02168 default:
02169 context->setItemChecked(CONTEXT_ICONS, true);
02170 break;
02171 case IconTextRight:
02172 context->setItemChecked(CONTEXT_TEXTRIGHT, true);
02173 break;
02174 case TextOnly:
02175 context->setItemChecked(CONTEXT_TEXT, true);
02176 break;
02177 case IconTextBottom:
02178 context->setItemChecked(CONTEXT_TEXTUNDER, true);
02179 break;
02180 }
02181
02182 TQValueList<int>::ConstIterator iIt = d->iconSizes.begin();
02183 TQValueList<int>::ConstIterator iEnd = d->iconSizes.end();
02184 for (; iIt != iEnd; ++iIt )
02185 context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false );
02186
02187 context->setItemChecked( CONTEXT_ICONSIZES, false );
02188
02189 context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true );
02190
02191 for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i )
02192 context->setItemChecked( i, false );
02193
02194 switch ( barPos() )
02195 {
02196 case TDEToolBar::Flat:
02197 context->setItemChecked( CONTEXT_FLAT, true );
02198 break;
02199 case TDEToolBar::Bottom:
02200 context->setItemChecked( CONTEXT_BOTTOM, true );
02201 break;
02202 case TDEToolBar::Left:
02203 context->setItemChecked( CONTEXT_LEFT, true );
02204 break;
02205 case TDEToolBar::Right:
02206 context->setItemChecked( CONTEXT_RIGHT, true );
02207 break;
02208 case TDEToolBar::Floating:
02209 context->setItemChecked( CONTEXT_FLOAT, true );
02210 break;
02211 case TDEToolBar::Top:
02212 context->setItemChecked( CONTEXT_TOP, true );
02213 break;
02214 default: break;
02215 }
02216 }
02217
02218 void TDEToolBar::slotContextAboutToHide()
02219 {
02220
02221
02222 TDEMainWindow *kmw = tqt_dynamic_cast<TDEMainWindow *>(mainWindow());
02223 if ( kmw && kmw->toolBarMenuAction() )
02224 if ( kmw->toolBarMenuAction()->containerCount() > 1 )
02225 kmw->toolBarMenuAction()->unplug(context);
02226
02227
02228 TDEAction *configureAction = 0;
02229 const char* actionName = KStdAction::name(KStdAction::ConfigureToolbars);
02230 if ( d->m_xmlguiClient )
02231 configureAction = d->m_xmlguiClient->actionCollection()->action(actionName);
02232 if ( !configureAction && kmw )
02233 configureAction = kmw->actionCollection()->action(actionName);
02234 if ( configureAction )
02235 configureAction->unplug(context);
02236
02237 TQPtrListIterator<TQWidget> it( widgets );
02238 TQWidget *wdg;
02239 while ( ( wdg = it.current() ) != 0 ) {
02240 if ( wdg->inherits( TQTOOLBUTTON_OBJECT_NAME_STRING ) )
02241 static_cast<TQToolButton*>( wdg )->setDown( false );
02242 ++it;
02243 }
02244 }
02245
02246 void TDEToolBar::widgetDestroyed()
02247 {
02248 removeWidgetInternal( (TQWidget*)sender() );
02249 }
02250
02251 void TDEToolBar::removeWidgetInternal( TQWidget * w )
02252 {
02253 widgets.removeRef( w );
02254 TQMap< TQWidget*, int >::Iterator it = widget2id.find( w );
02255 if ( it == widget2id.end() )
02256 return;
02257 id2widget.remove( *it );
02258 widget2id.remove( it );
02259 }
02260
02261 void TDEToolBar::virtual_hook( int, void* )
02262 { }
02263
02264 #include "tdetoolbar.moc"
02265