int PMComboAction::plug( QWidget* w, int index ) { if( !w->inherits( "KToolBar" ) ) return -1; KToolBar* toolBar = ( KToolBar* ) w; int id = KAction::getToolButtonID( ); QComboBox* comboBox = new PMComboBox( toolBar ); if( m_minWidth > 0 ) comboBox->setMinimumWidth( m_minWidth ); if( m_maxWidth > 0 ) comboBox->setMaximumWidth( m_maxWidth ); toolBar->insertWidget( id, m_minWidth > 0 ? m_minWidth : 300, comboBox, index ); connect( comboBox, SIGNAL( activated( int ) ), m_receiver, m_member ); addContainer( toolBar, id ); connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) ); //toolBar->setItemAutoSized( id, true ); m_combo = comboBox; emit plugged( ); QWhatsThis::add( comboBox, whatsThis( ) ); return containerCount( ) - 1; }
int TKAction::plug(QWidget* widget, int index) { if ( widget->inherits("KToolBar") ) { KToolBar* bar = static_cast<KToolBar*>(widget); int id_ = KAction::getToolButtonID(); KInstance *instance; if ( parentCollection() ) instance = parentCollection()->instance(); else instance = KGlobal::instance(); TKToolBarButton* b = new TKToolBarButton(icon(),plainText(),bar,name(),instance); // we don't need clicked() and buttonClicked(), do we? // connect(b,SIGNAL(clicked()),SLOT(slotActivated())); b->setIconMode(m_imode); initToolBarButton(b); bar->insertWidget( id_, 100, b, index ); addContainer(bar,id_); connect( bar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); return containerCount() - 1; } return KAction::plug(widget,index); }
int PMSpinBoxAction::plug( QWidget* w, int index ) { if( !w->inherits( "KToolBar" ) ) return -1; KToolBar* toolBar = ( KToolBar* ) w; int id = KAction::getToolButtonID( ); QSpinBox* spinBox = new QSpinBox( -1000, 1000, 1, w ); toolBar->insertWidget( id, 70, spinBox, index ); connect( spinBox, SIGNAL( valueChanged( int ) ), m_receiver, m_member ); addContainer( toolBar, id ); connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) ); //toolBar->setItemAutoSized( id, false ); m_spinBox = spinBox; emit plugged( ); QWhatsThis::add( spinBox, whatsThis( ) ); return containerCount( ) - 1; }
void KAction::setToolTip( const QString& tt ) { d->setToolTip( tt ); int len = containerCount(); for( int i = 0; i < len; ++i ) updateToolTip( i ); }
void KAction::setGroup( const QString& grp ) { d->m_group = grp; int len = containerCount(); for( int i = 0; i < len; ++i ) updateGroup( i ); }
void TKAction::updateLayout() { int len = containerCount(); for( int id = 0; id < len; ++id ) { QWidget* w = container( id ); if (w->inherits("KToolBar")) { QWidget* r = static_cast<KToolBar*>(w)->getWidget(itemId(id)); if (qstrcmp(r->name(),"KTToolBarLayout")==0) { updateLayout(r); } } } }
int PMLabelAction::plug( QWidget *widget, int index ) { //do not call the previous implementation here if( widget->inherits( "KToolBar" ) ) { KToolBar* tb = ( KToolBar* ) widget; int id = KAction::getToolButtonID( ); m_button = new PMToolBarLabel( text( ), widget ); tb->insertWidget( id, m_button->width( ), m_button, index ); addContainer( tb, id ); connect( tb, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) ); return containerCount( ) - 1; } return -1; }
int TKBaseSelectAction::plug(QWidget* widget, int index) { if ( widget->inherits("KToolBar") ) { KToolBar* bar = static_cast<KToolBar*>( widget ); int id_ = KAction::getToolButtonID(); TKComboBox* cb = new TKComboBox(m_editable,bar); initComboBox(cb); cb->setMinimumWidth( cb->sizeHint().width() ); QWidget* base = createLayout(bar,cb); bar->insertWidget( id_, 100, base, index ); addContainer( bar, id_ ); connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); setCurrentItem(currentItem()); return containerCount() - 1; } return -1; }
bool KAction::setShortcut( const KShortcut& cut ) { bool bChanged = (d->m_cut != cut); d->m_cut = cut; KAccel* const kaccel = kaccelCurrent(); bool bInsertRequired = true; // Apply new shortcut to all existing KAccel objects const QValueList<KAccel*> & accelList = d->m_kaccelList; QValueList<KAccel*>::const_iterator itr = accelList.constBegin(); const QValueList<KAccel*>::const_iterator itrEnd = accelList.constEnd(); for( ; itr != itrEnd; ++itr) { // Check whether shortcut has already been plugged into // the current kaccel object. if( (*itr) == kaccel ) bInsertRequired = false; if( bChanged ) updateKAccelShortcut( *itr ); } // Only insert action into KAccel if it has a valid name, if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) insertKAccel( kaccel ); if( bChanged ) { #ifndef KDE_NO_COMPAT // KDE 4: remove if ( d->m_kaccel ) d->m_kaccel->setShortcut( name(), cut ); #endif // KDE 4: remove end int len = containerCount(); for( int i = 0; i < len; ++i ) updateShortcut( i ); } return true; }