-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 79b0f9d..e9226c0 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp @@ -1221,384 +1221,390 @@ void KToolBar::setXMLGUIClient( KXMLGUIClient *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 ); } void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) { // we can't have it in widgets, or something is really wrong //widgets.removeRef( w ); connect( w, SIGNAL( destroyed() ), this, SLOT( widgetDestroyed() ) ); if ( index == -1 || index > (int)widgets.count() ) { widgets.append( w ); index = (int)widgets.count(); } else widgets.insert( index, w ); if ( id == -1 ) id = id2widget.count(); id2widget.insert( id, w ); widget2id.insert( w, id ); } +void KToolBar::repaintMe() +{ + setUpdatesEnabled( true ); + QToolBar::repaint( true ); + qDebug(" KToolBar::repaintMe() "); +} void KToolBar::showEvent( QShowEvent *e ) { QToolBar::showEvent( e ); rebuildLayout(); } void KToolBar::setStretchableWidget( QWidget *w ) { QToolBar::setStretchableWidget( w ); stretchableWidget = w; } QSizePolicy KToolBar::sizePolicy() const { if ( orientation() == Horizontal ) return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); else return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); } QSize KToolBar::sizeHint() const { return QToolBar::sizeHint(); #if 0 QWidget::polish(); static int iii = 0; ++iii; qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); switch( barPos() ) { case KToolBar::Top: case KToolBar::Bottom: for ( QWidget *w = widgets.first(); w; w =widgets.next() ) { if ( w->inherits( "KToolBarSeparator" ) && !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) { minSize += QSize(6, 0); } else { QSize sh = w->sizeHint(); if (!sh.isValid()) sh = w->minimumSize(); minSize = minSize.expandedTo(QSize(0, sh.height())); minSize += QSize(sh.width()+1, 0); } } /*US minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); */ minSize += QSize(margin*2, margin*2); break; case KToolBar::Left: case KToolBar::Right: for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { if ( w->inherits( "KToolBarSeparator" ) && !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) { minSize += QSize(0, 6); } else { QSize sh = w->sizeHint(); if (!sh.isValid()) sh = w->minimumSize(); minSize = minSize.expandedTo(QSize(sh.width(), 0)); minSize += QSize(0, sh.height()+1); } } /*US minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); */ minSize += QSize(margin*2, margin*2); break; default: minSize = QToolBar::sizeHint(); break; } return minSize; #endif } QSize KToolBar::minimumSize() const { return minimumSizeHint(); } QSize KToolBar::minimumSizeHint() const { return sizeHint(); } bool KToolBar::highlight() const { return d->m_highlight; } void KToolBar::hide() { QToolBar::hide(); } void KToolBar::show() { QToolBar::show(); } void KToolBar::resizeEvent( QResizeEvent *e ) { bool b = isUpdatesEnabled(); setUpdatesEnabled( FALSE ); QToolBar::resizeEvent( e ); if (b) d->repaintTimer.start( 100, true ); } void KToolBar::slotIconChanged(int group) { if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) return; if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) return; emit modechange(); if (isVisible()) updateGeometry(); } void KToolBar::slotReadConfig() { //kdDebug(220) << "KToolBar::slotReadConfig" << endl; // Read appearance settings (hmm, we used to do both here, // but a well behaved application will call applyMainWindowSettings // anyway, right ?) applyAppearanceSettings(KGlobal::config(), QString::null ); } void KToolBar::slotAppearanceChanged() { // Read appearance settings from global file. applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); // And remember to save the new look later /*US if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); */ } //static bool KToolBar::highlightSetting() { QString grpToolbar(QString::fromLatin1("Toolbar style")); KConfigGroupSaver saver(KGlobal::config(), grpToolbar); return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); } //static bool KToolBar::transparentSetting() { QString grpToolbar(QString::fromLatin1("Toolbar style")); KConfigGroupSaver saver(KGlobal::config(), grpToolbar); return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); } //static KToolBar::IconText KToolBar::iconTextSetting() { QString grpToolbar(QString::fromLatin1("Toolbar style")); KConfigGroupSaver saver(KGlobal::config(), grpToolbar); QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); if ( icontext == "IconTextRight" ) return IconTextRight; else if ( icontext == "IconTextBottom" ) return IconTextBottom; else if ( icontext == "TextOnly" ) return TextOnly; else return IconOnly; } void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) { QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; // We have application-specific settings in the XML file, // and nothing in the application's config file |