author | zautrix <zautrix> | 2005-02-07 20:05:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-07 20:05:18 (UTC) |
commit | da5e47069d88fa9aa656423ce4c60bf505728e1c (patch) (side-by-side diff) | |
tree | fdbaf29835a028f1204a19fc10dea97d469c0b29 /microkde/kdeui/ktoolbar.cpp | |
parent | 456b0246521847635fe98471691ceecae211e0c3 (diff) | |
download | kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.zip kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.gz kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.bz2 |
fixes
-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 1ad1728..09ad0c8 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp @@ -369,1025 +369,1025 @@ int KToolBar::insertLined (const QString& text, int id, bool enabled , const QString& toolTipText, int size, int index ) { KLineEdit *lined = new KLineEdit ( this, 0 ); if ( !toolTipText.isEmpty() ) QToolTip::add( lined, toolTipText ); if ( size > 0 ) lined->setMinimumWidth( size ); insertWidgetInternal( lined, index, id ); connect( lined, signal, receiver, slot ); lined->setText(text); lined->setEnabled( enabled ); return index; } int KToolBar::insertCombo (const QStringList &list, int id, bool writable, const char *signal, const QObject *receiver, const char *slot, bool enabled, const QString& tooltiptext, int size, int index, QComboBox::Policy policy ) { //US KComboBox *combo = new KComboBox ( writable, this ); KComboBox *combo = new KComboBox ( this ); combo->setEditable(writable); insertWidgetInternal( combo, index, id ); combo->insertStringList (list); combo->setInsertionPolicy(policy); combo->setEnabled( enabled ); if ( !tooltiptext.isEmpty() ) QToolTip::add( combo, tooltiptext ); if ( size > 0 ) combo->setMinimumWidth( size ); if (!tooltiptext.isNull()) QToolTip::add( combo, tooltiptext ); if ( signal && receiver && slot ) connect ( combo, signal, receiver, slot ); return index; } int KToolBar::insertCombo (const QString& text, int id, bool writable, const char *signal, QObject *receiver, const char *slot, bool enabled, const QString& tooltiptext, int size, int index, QComboBox::Policy policy ) { //US KComboBox *combo = new KComboBox ( writable, this ); KComboBox *combo = new KComboBox ( this ); combo->setEditable(writable); insertWidgetInternal( combo, index, id ); combo->insertItem (text); combo->setInsertionPolicy(policy); combo->setEnabled( enabled ); if ( !tooltiptext.isEmpty() ) QToolTip::add( combo, tooltiptext ); if ( size > 0 ) combo->setMinimumWidth( size ); if (!tooltiptext.isNull()) QToolTip::add( combo, tooltiptext ); connect (combo, signal, receiver, slot); return index; } int KToolBar::insertSeparator(int index, int id) { QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); insertWidgetInternal( w, index, id ); return index; } int KToolBar::insertLineSeparator(int index, int id) { QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); insertWidgetInternal( w, index, id ); return index; } int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) { // removeWidgetInternal( widget ); // in case we already have it ? insertWidgetInternal( widget, index, id ); return index; } /*US int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, const QString& icons, int index ) { KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); insertWidgetInternal( anim, index, id ); if ( receiver ) connect( anim, SIGNAL(clicked()), receiver, slot); return index; } KAnimWidget *KToolBar::animatedWidget( int id ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return 0; if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) return (KAnimWidget*)(*it); QObjectList *l = queryList( "KAnimWidget" ); if ( !l || !l->first() ) { delete l; return 0; } for ( QObject *o = l->first(); o; o = l->next() ) { if ( o->inherits( "KAnimWidget" ) ) { delete l; return (KAnimWidget*)o; } } delete l; return 0; } */ void KToolBar::addConnection (int id, const char *signal, const QObject *receiver, const char *slot) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; if ( (*it) ) connect( (*it), signal, receiver, slot ); } void KToolBar::setItemEnabled( int id, bool enabled ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; if ( (*it) ) (*it)->setEnabled( enabled ); } void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->setPixmap( _pixmap ); } void KToolBar::setButtonIcon( int id, const QString& _icon ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->setIcon( _icon ); } void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->setIconSet( iconset ); } void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->setDelayedPopup( _popup, toggle ); } void KToolBar::setAutoRepeat (int id, bool flag) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->setAutoRepeat( flag ); } void KToolBar::setToggle (int id, bool flag ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->setToggle( flag ); } void KToolBar::toggleButton (int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->toggle(); } void KToolBar::setButton (int id, bool flag) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if ( button ) button->on( flag ); } bool KToolBar::isButtonOn (int id) const { Id2WidgetMap::ConstIterator it = id2widget.find( id ); if ( it == id2widget.end() ) return false; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); return button ? button->isOn() : false; } void KToolBar::setLinedText (int id, const QString& text) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); QLineEdit * lineEdit = (QLineEdit *)( *it ); if ( lineEdit ) lineEdit->setText( text ); } QString KToolBar::getLinedText (int id) const { Id2WidgetMap::ConstIterator it = id2widget.find( id ); if ( it == id2widget.end() ) return QString::null; //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); QLineEdit * lineEdit = (QLineEdit *)( *it ); return lineEdit ? lineEdit->text() : QString::null; } void KToolBar::insertComboItem (int id, const QString& text, int index) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); QComboBox * comboBox = (QComboBox *)( *it ); if (comboBox) comboBox->insertItem( text, index ); } void KToolBar::insertComboList (int id, const QStringList &list, int index) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); QComboBox * comboBox = (QComboBox *)( *it ); if (comboBox) comboBox->insertStringList( list, index ); } void KToolBar::removeComboItem (int id, int index) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); QComboBox * comboBox = (QComboBox *)( *it ); if (comboBox) comboBox->removeItem( index ); } void KToolBar::setCurrentComboItem (int id, int index) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); QComboBox * comboBox = (QComboBox *)( *it ); if (comboBox) comboBox->setCurrentItem( index ); } void KToolBar::changeComboItem (int id, const QString& text, int index) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); QComboBox * comboBox = (QComboBox *)( *it ); if (comboBox) comboBox->changeItem( text, index ); } void KToolBar::clearCombo (int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); QComboBox * comboBox = (QComboBox *)( *it ); if (comboBox) comboBox->clear(); } QString KToolBar::getComboItem (int id, int index) const { Id2WidgetMap::ConstIterator it = id2widget.find( id ); if ( it == id2widget.end() ) return QString::null; //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); QComboBox * comboBox = (QComboBox *)( *it ); return comboBox ? comboBox->text( index ) : QString::null; } KComboBox * KToolBar::getCombo(int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return 0; //US return dynamic_cast<KComboBox *>( *it ); return (KComboBox *)( *it ); } KLineEdit * KToolBar::getLined (int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return 0; //US return dynamic_cast<KLineEdit *>( *it ); return (KLineEdit *)( *it ); } KToolBarButton * KToolBar::getButton (int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return 0; //US return dynamic_cast<KToolBarButton *>( *it ); return (KToolBarButton *)( *it ); } void KToolBar::alignItemRight (int id, bool right ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; if ( rightAligned && !right && (*it) == rightAligned ) rightAligned = 0; if ( (*it) && right ) rightAligned = (*it); } QWidget *KToolBar::getWidget (int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); return ( it == id2widget.end() ) ? 0 : (*it); } void KToolBar::setItemAutoSized (int id, bool yes ) { QWidget *w = getWidget(id); if ( w && yes ) setStretchableWidget( w ); } void KToolBar::clear () { QToolBar::clear(); widget2id.clear(); id2widget.clear(); } void KToolBar::removeItem(int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) { kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; return; } QWidget * w = (*it); id2widget.remove( id ); widget2id.remove( w ); widgets.removeRef( w ); delete w; } void KToolBar::removeItemDelayed(int id) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) { kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; return; } QWidget * w = (*it); id2widget.remove( id ); widget2id.remove( w ); widgets.removeRef( w ); w->blockSignals(true); d->idleButtons.append(w); layoutTimer->start( 50, TRUE ); } void KToolBar::hideItem (int id) { QWidget *w = getWidget(id); if ( w ) w->hide(); } void KToolBar::showItem (int id) { QWidget *w = getWidget(id); if ( w ) w->show(); } int KToolBar::itemIndex (int id) { QWidget *w = getWidget(id); return w ? widgets.findRef(w) : -1; } void KToolBar::setFullSize(bool flag ) { setHorizontalStretchable( flag ); setVerticalStretchable( flag ); } bool KToolBar::fullSize() const { return isHorizontalStretchable() || isVerticalStretchable(); } void KToolBar::enableMoving(bool flag ) { //US setMovingEnabled(flag); this->mainWindow()->setToolBarsMovable(flag); } void KToolBar::setBarPos (BarPosition bpos) { if ( !mainWindow() ) return; //US mainWindow()->moveDockWindow( this, (Dock)bpos ); mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); } -KToolBar::BarPosition KToolBar::barPos() +KToolBar::BarPosition KToolBar::barPos() const { if ( !(QMainWindow*)mainWindow() ) return KToolBar::Top; //US Dock dock; QMainWindow::ToolBarDock dock; int dm1, dm2; bool dm3; ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); //US if ( dock == DockUnmanaged ) { if ( dock == QMainWindow::Unmanaged ) { return (KToolBar::BarPosition)Top; } return (BarPosition)dock; } bool KToolBar::enable(BarStatus stat) { bool mystat = isVisible(); if ( (stat == Toggle && mystat) || stat == Hide ) hide(); else show(); return isVisible() == mystat; } void KToolBar::setMaxHeight ( int h ) { setMaximumHeight( h ); } int KToolBar::maxHeight() { return maximumHeight(); } void KToolBar::setMaxWidth (int dw) { setMaximumWidth( dw ); } int KToolBar::maxWidth() { return maximumWidth(); } void KToolBar::setTitle (const QString& _title) { setLabel( _title ); } void KToolBar::enableFloating (bool ) { } void KToolBar::setIconText(IconText it) { setIconText( it, true ); } void KToolBar::setIconText(IconText icontext, bool update) { bool doUpdate=false; if (icontext != d->m_iconText) { d->m_iconText = icontext; doUpdate=true; } if (update == false) return; if (doUpdate) emit modechange(); // tell buttons what happened // ugly hack to force a QMainWindow::triggerLayout( TRUE ) if ( mainWindow() ) { QMainWindow *mw = mainWindow(); mw->setUpdatesEnabled( FALSE ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setUpdatesEnabled( TRUE ); } } KToolBar::IconText KToolBar::iconText() const { return d->m_iconText; } void KToolBar::setIconSize(int size) { setIconSize( size, true ); } void KToolBar::setIconSize(int size, bool update) { bool doUpdate=false; if ( size != d->m_iconSize ) { d->m_iconSize = size; doUpdate=true; } if (update == false) return; if (doUpdate) emit modechange(); // tell buttons what happened // ugly hack to force a QMainWindow::triggerLayout( TRUE ) if ( mainWindow() ) { QMainWindow *mw = mainWindow(); mw->setUpdatesEnabled( FALSE ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setUpdatesEnabled( TRUE ); } } int KToolBar::iconSize() const { /*US if ( !d->m_iconSize ) // default value? { if (!::qstrcmp(QObject::name(), "mainToolBar")) return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); else return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); } return d->m_iconSize; */ int ret = 18; if ( QApplication::desktop()->width() > 320 ) ret = 30; return ret; } void KToolBar::setEnableContextMenu(bool enable ) { d->m_enableContext = enable; } bool KToolBar::contextMenuEnabled() const { return d->m_enableContext; } void KToolBar::setItemNoStyle(int id, bool no_style ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) return; //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); KToolBarButton * button = (KToolBarButton *)( *it ); if (button) button->setNoStyle( no_style ); } void KToolBar::setFlat (bool flag) { if ( !mainWindow() ) return; if ( flag ) //US mainWindow()->moveDockWindow( this, DockMinimized ); mainWindow()->moveToolBar( this, QMainWindow::Minimized ); else //US mainWindow()->moveDockWindow( this, DockTop ); mainWindow()->moveToolBar( this, QMainWindow::Top ); // And remember to save the new look later /*US if ( mainWindow()->inherits( "KMainWindow" ) ) static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); */ } int KToolBar::count() const { return id2widget.count(); } void KToolBar::saveState() { /*US // first, try to save to the xml file if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { // go down one level to get to the right tags QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); elem = elem.firstChild().toElement(); QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); QDomElement current; // now try to find our toolbar d->modified = false; for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { current = elem; if ( current.tagName().lower() != "toolbar" ) continue; QString curname(current.attribute( "name" )); if ( curname == barname ) { saveState( current ); break; } } // if we didn't make changes, then just return if ( !d->modified ) return; // now we load in the (non-merged) local file QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); QDomDocument local; local.setContent(local_xml); // make sure we don't append if this toolbar already exists locally bool just_append = true; elem = local.documentElement().toElement(); KXMLGUIFactory::removeDOMComments( elem ); elem = elem.firstChild().toElement(); for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { if ( elem.tagName().lower() != "toolbar" ) continue; QString curname(elem.attribute( "name" )); if ( curname == barname ) { just_append = false; local.documentElement().replaceChild( current, elem ); break; } } if (just_append) local.documentElement().appendChild( current ); KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); return; } */ // if that didn't work, we save to the config file KConfig *config = KGlobal::config(); saveSettings(config, QString::null); config->sync(); } QString KToolBar::settingsGroup() { QString configGroup; if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) configGroup = "Toolbar style"; else configGroup = QString(name()) + " Toolbar style"; if ( this->mainWindow() ) { configGroup.prepend(" "); configGroup.prepend( this->mainWindow()->name() ); } return configGroup; } void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) { QString configGroup = _configGroup; if (configGroup.isEmpty()) configGroup = settingsGroup(); //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; QString position, icontext; int index; getAttributes( position, icontext, index ); //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; KConfigGroupSaver saver(config, configGroup); if ( position != d->PositionDefault ) config->writeEntry("Position", position); else config->deleteEntry("Position"); if ( icontext != d->IconTextDefault ) config->writeEntry("IconText", icontext); else config->deleteEntry("IconText"); if ( iconSize() != d->IconSizeDefault ) config->writeEntry("IconSize", iconSize()); else config->deleteEntry("IconSize"); if ( isHidden() != d->HiddenDefault ) config->writeEntry("Hidden", isHidden()); else config->deleteEntry("Hidden"); if ( index != d->IndexDefault ) config->writeEntry( "Index", index ); else config->deleteEntry("Index"); //US the older version of KDE (used on the Zaurus) has no Offset property /* if ( offset() != d->OffsetDefault ) config->writeEntry( "Offset", offset() ); else */ config->deleteEntry("Offset"); //US the older version of KDE (used on the Zaurus) has no NewLine property /* if ( newLine() != d->NewLineDefault ) config->writeEntry( "NewLine", newLine() ); else */ config->deleteEntry("NewLine"); } void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) { d->m_xmlguiClient = client; } void KToolBar::setText( const QString & txt ) { //US setLabel( txt + " ( " + kapp->caption() + " ) " ); setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); } QString KToolBar::text() const { return label(); } void KToolBar::doConnections( KToolBarButton *button ) { connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); } void KToolBar::mousePressEvent ( QMouseEvent *m ) { if ( !mainWindow() ) return; QMainWindow *mw = mainWindow(); if ( mw->toolBarsMovable() && d->m_enableContext ) { if ( m->button() == RightButton ) { int i = contextMenu()->exec( m->globalPos(), 0 ); switch ( i ) { case -1: return; // popup cancelled case CONTEXT_LEFT: //US mw->moveDockWindow( this, DockLeft ); mw->moveToolBar( this, QMainWindow::Left ); break; case CONTEXT_RIGHT: //US mw->moveDockWindow( this, DockRight ); mw->moveToolBar( this, QMainWindow::Right ); break; case CONTEXT_TOP: //US mw->moveDockWindow( this, DockTop ); mw->moveToolBar( this, QMainWindow::Top ); break; case CONTEXT_BOTTOM: //US mw->moveDockWindow( this, DockBottom ); mw->moveToolBar( this, QMainWindow::Bottom ); break; case CONTEXT_FLOAT: break; case CONTEXT_FLAT: //US mw->moveDockWindow( this, DockMinimized ); mw->moveToolBar( this, QMainWindow::Minimized ); break; case CONTEXT_ICONS: setIconText( IconOnly ); break; case CONTEXT_TEXTRIGHT: setIconText( IconTextRight ); break; case CONTEXT_TEXT: setIconText( TextOnly ); break; case CONTEXT_TEXTUNDER: setIconText( IconTextBottom ); break; default: if ( i >= CONTEXT_ICONSIZES ) setIconSize( i - CONTEXT_ICONSIZES ); else return; // assume this was an action handled elsewhere, no need for setSettingsDirty() } /*US if ( mw->inherits("KMainWindow") ) static_cast<KMainWindow *>(mw)->setSettingsDirty(); */ } } } void KToolBar::rebuildLayout() { for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) w->blockSignals(false); d->idleButtons.clear(); layoutTimer->stop(); QApplication::sendPostedEvents( this, QEvent::ChildInserted ); QBoxLayout *l = boxLayout(); l->setMargin( 1 ); // clear the old layout QLayoutIterator it = l->iterator(); while ( it.current() ) { it.deleteCurrent(); } for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { if ( w == rightAligned ) { continue; } if ( w->inherits( "KToolBarSeparator" ) && !( (KToolBarSeparator*)w )->showLine() ) { l->addSpacing( 6 ); w->hide(); continue; } if ( w->inherits( "QPopupMenu" ) ) continue; l->addWidget( w ); w->show(); } if ( rightAligned ) { l->addStretch(); l->addWidget( rightAligned ); rightAligned->show(); } if ( fullSize() ) { // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). //if ( !stretchableWidget && widgets.last() && // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) // setStretchableWidget( widgets.last() ); if ( !rightAligned ) l->addStretch(); if ( stretchableWidget ) l->setStretchFactor( stretchableWidget, 10 ); } l->invalidate(); QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); //#endif //DESKTOP_VERSION } void KToolBar::childEvent( QChildEvent *e ) { if ( e->child()->isWidgetType() ) { QWidget * w = (QWidget*)e->child(); if ( e->type() == QEvent::ChildInserted ) { if ( !e->child()->inherits( "QPopupMenu" ) && ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { // prevent items that have been explicitly inserted by insert*() from // being inserted again if ( !widget2id.contains( w ) ) { int dummy = -1; insertWidgetInternal( w, dummy, -1 ); } } } else { removeWidgetInternal( w ); } if ( isVisibleTo( 0 ) ) { QBoxLayout *l = boxLayout(); // QLayout *l = layout(); // clear the old layout so that we don't get unnecassery layout // changes till we have rebuild the thing QLayoutIterator it = l->iterator(); while ( it.current() ) { it.deleteCurrent(); } layoutTimer->start( 50, TRUE ); } } QToolBar::childEvent( e ); } |