30 #include <tqtooltip.h> 31 #include <tqwhatsthis.h> 34 #include <kaccelbase.h> 35 #include <kaccelprivate.h> 36 #include <kapplication.h> 39 #include <kmainwindow.h> 41 #include <kpopupmenu.h> 43 #include <ktoolbarbutton.h> 46 #include <X11/Xdefs.h> 48 #include <X11/Xatom.h> 49 #include <X11/Intrinsic.h> 50 #include <X11/StringDefs.h> 51 #include <X11/Shell.h> 53 #include <X11/Xft/Xft.h> 78 static int toolbutton_no = -2;
79 return toolbutton_no--;
86 class KAction::KActionPrivate :
public KGuiItem 92 m_configurable =
true;
96 TQValueList<KAccel*> m_kaccelList;
108 Container() { m_container = 0; m_representative = 0; m_id = 0; }
109 Container(
const Container& s ) { m_container = s.m_container;
110 m_id = s.m_id; m_representative = s.m_representative; }
111 TQWidget* m_container;
113 TQWidget* m_representative;
116 TQValueList<Container> m_containers;
124 const TQObject* receiver,
const char* slot,
126 : TQObject( parent, name ), d(new KActionPrivate)
128 initPrivate( text, cut, receiver, slot );
132 const TQObject* receiver,
const char* slot,
134 : TQObject( parent, name ), d(new KActionPrivate)
136 initPrivate( text, cut, receiver, slot );
137 d->setIconName( sIconName );
141 const TQObject* receiver,
const char* slot,
143 : TQObject( parent, name ), d(new KActionPrivate)
145 initPrivate( text, cut, receiver, slot );
146 d->setIconSet( pix );
150 const TQObject* receiver,
const char* slot,
152 : TQObject( parent, name ), d(new KActionPrivate)
154 initPrivate( item.text(), cut, receiver, slot );
156 setIcon( item.iconName() );
161 #ifndef KDE_NO_COMPAT // KDE 4: remove 163 TQObject* parent,
const char* name )
164 : TQObject( parent, name ), d(new KActionPrivate)
166 initPrivate( text, cut, 0, 0 );
170 const TQObject* receiver,
171 const char* slot, TQObject* parent,
const char* name )
172 : TQObject( parent, name ), d(new KActionPrivate)
174 initPrivate( text, cut, receiver, slot );
179 TQObject* parent,
const char* name )
180 : TQObject( parent, name ), d(new KActionPrivate)
182 initPrivate( text, cut, 0, 0 );
188 TQObject* parent,
const char* name )
189 : TQObject( parent, name ), d(new KActionPrivate)
191 initPrivate( text, cut, 0, 0 );
192 d->setIconName( pix );
197 const TQObject* receiver,
const char* slot, TQObject* parent,
199 : TQObject( parent, name ), d(new KActionPrivate)
201 initPrivate( text, cut, receiver, slot );
207 const TQObject* receiver,
const char* slot, TQObject* parent,
209 : TQObject( parent, name ), d(new KActionPrivate)
211 initPrivate( text, cut, receiver, slot );
216 : TQObject( parent, name ), d(new KActionPrivate)
218 initPrivate( TQString::null,
KShortcut(), 0, 0 );
220 #endif // KDE 4: remove end 224 kdDebug(129) <<
"KAction::~KAction( this = \"" << name() <<
"\" )" <<
endl;
225 #ifndef KDE_NO_COMPAT 231 if ( m_parentCollection ) {
232 m_parentCollection->
take(
this );
234 const TQValueList<KAccel*> & accelList = d->m_kaccelList;
235 TQValueList<KAccel*>::const_iterator itr = accelList.constBegin();
236 const TQValueList<KAccel*>::const_iterator itrEnd = accelList.constEnd();
238 const char *
const namePtr = name();
239 for (; itr != itrEnd; ++itr )
240 (*itr)->remove(namePtr);
254 void KAction::initPrivate(
const TQString&
text,
const KShortcut& cut,
255 const TQObject* receiver,
const char* slot )
257 d->m_cutDefault = cut;
260 kdDebug(129) <<
"KAction::initPrivate(): this = " <<
this <<
" name = \"" << name() <<
"\" cut = " << cut.toStringInternal() <<
" m_parentCollection = " << m_parentCollection <<
endl;
261 if ( m_parentCollection )
262 m_parentCollection->
insert(
this );
264 if ( receiver && slot )
265 connect(
this, TQT_SIGNAL(
activated() ), receiver, slot );
267 if( !cut.
isNull() && !qstrcmp( name(),
"unnamed" ) )
268 kdWarning(129) <<
"KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() <<
") to an unnamed action." <<
endl;
275 return (!d->m_containers.empty()) || d->m_kaccel;
280 return findContainer( container ) > -1;
285 int i = findContainer( container );
286 return ( i > -1 && itemId( i ) ==
id );
291 int i = findContainer( container );
292 return ( i > -1 && representative( i ) == _representative );
366 KAccel* KAction::kaccelCurrent()
368 if( m_parentCollection && m_parentCollection->
builderKAccel() )
370 else if( m_parentCollection && m_parentCollection->
kaccel() )
371 return m_parentCollection->
kaccel();
377 bool KAction::initShortcut(
const KShortcut& cut )
382 if( qstrcmp( name(),
"unnamed" ) &&
383 m_parentCollection &&
385 m_parentCollection->
kaccel() )
387 insertKAccel( m_parentCollection->
kaccel() );
394 void KAction::plugShortcut()
396 KAccel*
const kaccel = kaccelCurrent();
399 if( kaccel && qstrcmp( name(),
"unnamed" ) ) {
401 const TQValueList<KAccel*> & accelList = d->m_kaccelList;
402 TQValueList<KAccel*>::const_iterator itr = accelList.constBegin();
403 const TQValueList<KAccel*>::const_iterator itrEnd = accelList.constEnd();
405 for( ; itr != itrEnd; ++itr) {
406 if( (*itr) == kaccel )
410 insertKAccel( kaccel );
416 bool bChanged = (d->m_cut != cut);
419 KAccel*
const kaccel = kaccelCurrent();
420 bool bInsertRequired =
true;
423 const TQValueList<KAccel*> & accelList = d->m_kaccelList;
424 TQValueList<KAccel*>::const_iterator itr = accelList.constBegin();
425 const TQValueList<KAccel*>::const_iterator itrEnd = accelList.constEnd();
427 for( ; itr != itrEnd; ++itr) {
430 if( (*itr) == kaccel )
431 bInsertRequired =
false;
433 updateKAccelShortcut( *itr );
437 if( kaccel && bInsertRequired && qstrcmp( name(),
"unnamed" ) )
438 insertKAccel( kaccel );
441 #ifndef KDE_NO_COMPAT // KDE 4: remove 443 d->m_kaccel->setShortcut( name(), cut );
444 #endif // KDE 4: remove end 445 int len = containerCount();
446 for(
int i = 0; i < len; ++i )
452 bool KAction::updateKAccelShortcut(
KAccel* kaccel )
455 if (kapp && !kapp->authorizeKAction(name()))
460 if ( !kaccel->actions().actionPtr( name() ) ) {
461 if(!d->m_cut.isNull() ) {
462 kdDebug(129) <<
"Inserting " << name() <<
", " << d->text() <<
", " << d->plainText() <<
endl;
463 b = kaccel->
insert( name(), d->plainText(), TQString::null,
465 this, TQT_SLOT(slotActivated()),
475 void KAction::insertKAccel(
KAccel* kaccel )
478 if ( !kaccel->actions().actionPtr( name() ) ) {
479 if( updateKAccelShortcut( kaccel ) ) {
480 d->m_kaccelList.append( kaccel );
481 connect( kaccel, TQT_SIGNAL(destroyed()),
this, TQT_SLOT(slotDestroyed()) );
485 kdWarning(129) <<
"KAction::insertKAccel( kaccel = " << kaccel <<
" ): KAccel object already contains an action name \"" << name() <<
"\"" <<
endl;
488 void KAction::removeKAccel(
KAccel* kaccel )
491 TQValueList<KAccel*> & accelList = d->m_kaccelList;
492 TQValueList<KAccel*>::iterator itr = accelList.begin();
493 const TQValueList<KAccel*>::iterator itrEnd = accelList.end();
495 for( ; itr != itrEnd; ++itr) {
496 if( (*itr) == kaccel ) {
498 accelList.remove( itr );
499 disconnect( kaccel, TQT_SIGNAL(destroyed()),
this, TQT_SLOT(slotDestroyed()) );
505 #ifndef KDE_NO_COMPAT 511 #endif // KDE 4: remove end 513 void KAction::updateShortcut(
int i )
515 int id = itemId( i );
517 TQWidget* w = container( i );
518 if ( ::tqqt_cast<TQPopupMenu *>( w ) ) {
519 TQPopupMenu* menu =
static_cast<TQPopupMenu*
>(w);
520 updateShortcut( menu,
id );
522 else if ( ::tqqt_cast<TQMenuBar *>( w ) )
523 static_cast<TQMenuBar*
>(w)->
setAccel( d->m_cut.keyCodeQt(), id );
526 void KAction::updateShortcut( TQPopupMenu* menu,
int id )
531 if ( d->m_kaccel || d->m_kaccelList.count() ) {
532 TQString s = menu->text(
id );
533 int i = s.find(
'\t' );
535 s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() );
537 s +=
"\t" + d->m_cut.seq(0).toString();
539 menu->changeItem(
id, s );
545 menu->setAccel( d->m_cut.keyCodeQt(), id );
546 kdDebug(129) <<
"KAction::updateShortcut(): name = \"" << name() <<
"\", cut = " << d->m_cut.toStringInternal() <<
"; No KAccel, probably missing a parent collection." <<
endl;
557 return d->m_cutDefault;
560 TQString KAction::shortcutText()
const 562 return d->m_cut.toStringInternal();
565 void KAction::setShortcutText(
const TQString& s )
570 #ifndef KDE_NO_COMPAT // Remove in KDE 4 573 return d->m_cut.keyCodeQt();
577 void KAction::setGroup(
const TQString& grp )
581 int len = containerCount();
582 for(
int i = 0; i < len; ++i )
586 void KAction::updateGroup(
int )
591 TQString KAction::group()
const 598 return d->isEnabled();
603 return d->m_configurable;
610 int len = containerCount();
611 for(
int i = 0; i < len; ++i )
615 void KAction::updateToolTip(
int i )
617 TQWidget *w = container( i );
619 if ( ::tqqt_cast<KToolBar *>( w ) )
620 TQToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
632 kdWarning(129) <<
"KAction::plug called with 0 argument\n";
640 KAccel* kaccel = kaccelCurrent();
641 if( !d->m_cut.isNull() && !kaccel ) {
642 kdDebug(129) <<
"KAction::plug(): has no KAccel object; this = " <<
this <<
" name = " << name() <<
" parentCollection = " << m_parentCollection <<
endl;
647 if (kapp && !kapp->authorizeKAction(name()))
652 if ( ::tqqt_cast<TQPopupMenu *>( w ) )
654 TQPopupMenu* menu =
static_cast<TQPopupMenu*
>( w );
657 int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt();
662 if ( m_parentCollection )
663 instance = m_parentCollection->
instance();
666 id = menu->insertItem( d->iconSet(
KIcon::Small, 0, instance ), d->text(),
this,
671 id = menu->insertItem( d->text(),
this,
677 if ( d->m_kaccelList.count() || d->m_kaccel )
678 updateShortcut( menu,
id );
682 if ( !d->isEnabled() )
683 menu->setItemEnabled(
id,
false );
685 if ( !d->whatsThis().isEmpty() )
686 menu->TQMenuData::setWhatsThis(
id, whatsThisWithIcon() );
688 addContainer( menu,
id );
689 connect( menu, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
691 if ( m_parentCollection )
694 return d->m_containers.count() - 1;
696 else if ( ::tqqt_cast<KToolBar *>( w ) )
702 if ( m_parentCollection )
703 instance = m_parentCollection->
instance();
707 if ( icon().isEmpty() && !
iconSet().pixmap().isNull() )
709 bar->
insertButton(
iconSet().pixmap(), id_, TQT_SIGNAL( buttonClicked(
int, TQt::ButtonState) ),
this,
711 d->isEnabled(), d->plainText(), index );
715 TQString icon = d->iconName();
716 if ( icon.isEmpty() )
718 bar->
insertButton( icon, id_, TQT_SIGNAL( buttonClicked(
int, TQt::ButtonState) ),
this,
720 d->isEnabled(), d->plainText(), index, instance );
724 ktb->setName( TQCString(
"toolbutton_")+name() );
726 if ( !d->whatsThis().isEmpty() )
727 TQWhatsThis::add( bar->
getButton(id_), whatsThisWithIcon() );
729 if ( !d->toolTip().isEmpty() )
730 TQToolTip::add( bar->
getButton(id_), d->toolTip() );
732 addContainer( bar, id_ );
734 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
736 if ( m_parentCollection )
739 return containerCount() - 1;
747 int i = findContainer( w );
750 int id = itemId( i );
752 if ( ::tqqt_cast<TQPopupMenu *>( w ) )
754 TQPopupMenu *menu =
static_cast<TQPopupMenu *
>( w );
755 menu->removeItem(
id );
757 else if ( ::tqqt_cast<KToolBar *>( w ) )
762 else if ( ::tqqt_cast<TQMenuBar *>( w ) )
764 TQMenuBar *bar =
static_cast<TQMenuBar *
>( w );
765 bar->removeItem(
id );
768 removeContainer( i );
769 if ( m_parentCollection )
776 kdWarning(129) <<
"KAction::plugAccel(): call to deprecated action." <<
endl;
789 if ( !kacc->actions().actionPtr(name()) )
792 d->m_kaccel->insert(name(), d->plainText(), TQString::null,
794 this, TQT_SLOT(slotActivated()),
796 connect(d->m_kaccel, TQT_SIGNAL(destroyed()),
this, TQT_SLOT(slotDestroyed()));
802 kdWarning(129) <<
"KAction::plugAccel( kacc = " << kacc <<
" ): KAccel object already contains an action name \"" << name() <<
"\"" <<
endl;
812 d->m_kaccel->remove(name());
817 void KAction::plugMainWindowAccel( TQWidget *w )
822 while ( !tl->isDialog() && ( n = tl->parentWidget() ) )
829 kdDebug(129) <<
"KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl <<
endl;
835 if ( enable == d->isEnabled() )
838 #ifndef KDE_NO_COMPAT 841 d->m_kaccel->setEnabled(name(), enable);
842 #endif // KDE 4: remove end 844 const TQValueList<KAccel*> & accelList = d->m_kaccelList;
845 TQValueList<KAccel*>::const_iterator itr = accelList.constBegin();
846 const TQValueList<KAccel*>::const_iterator itrEnd = accelList.constEnd();
848 const char *
const namePtr = name();
850 for ( ; itr != itrEnd; ++itr )
851 (*itr)->setEnabled( namePtr, enable );
853 d->setEnabled( enable );
855 int len = containerCount();
856 for(
int i = 0; i < len; ++i )
859 emit enabled( d->isEnabled() );
862 void KAction::updateEnabled(
int i )
864 TQWidget *w = container( i );
866 if ( ::tqqt_cast<TQPopupMenu *>( w ) )
867 static_cast<TQPopupMenu*
>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
868 else if ( ::tqqt_cast<TQMenuBar *>( w ) )
869 static_cast<TQMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
870 else if ( ::tqqt_cast<KToolBar *>( w ) )
871 static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
876 d->m_configurable = b;
881 #ifndef KDE_NO_COMPAT 884 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name());
886 pAction->setLabel( text );
888 #endif // KDE 4: remove end 889 const TQValueList<KAccel*> & accelList = d->m_kaccelList;
890 TQValueList<KAccel*>::const_iterator itr = accelList.constBegin();
891 const TQValueList<KAccel*>::const_iterator itrEnd = accelList.constEnd();
893 const char *
const namePtr = name();
895 for( ; itr != itrEnd; ++itr ) {
896 KAccelAction*
const pAction = (*itr)->actions().actionPtr(namePtr);
898 pAction->setLabel( text );
903 int len = containerCount();
904 for(
int i = 0; i < len; ++i )
908 void KAction::updateText(
int i )
910 TQWidget *w = container( i );
912 if ( ::tqqt_cast<TQPopupMenu *>( w ) ) {
913 int id = itemId( i );
914 static_cast<TQPopupMenu*
>(w)->changeItem(
id, d->text() );
915 if (!d->m_cut.isNull())
916 updateShortcut( static_cast<TQPopupMenu*>(w), id );
918 else if ( ::tqqt_cast<TQMenuBar *>( w ) )
919 static_cast<TQMenuBar*>(w)->changeItem( itemId( i ), d->text() );
920 else if ( ::tqqt_cast<KToolBar *>( w ) )
922 TQWidget *button =
static_cast<KToolBar *
>(w)->getWidget( itemId( i ) );
923 if ( ::tqqt_cast<KToolBarButton *>( button ) )
924 static_cast<KToolBarButton *>(button)->
setText( d->plainText() );
933 TQString KAction::plainText()
const 935 return d->plainText( );
938 void KAction::setIcon(
const TQString &icon )
940 d->setIconName( icon );
943 int len = containerCount();
944 for (
int i = 0; i < len; ++i )
948 void KAction::updateIcon(
int id )
950 TQWidget* w = container(
id );
952 if ( ::tqqt_cast<TQPopupMenu *>( w ) ) {
953 int itemId_ = itemId(
id );
954 static_cast<TQPopupMenu*
>(w)->changeItem( itemId_, d->iconSet(
KIcon::Small ), d->text() );
955 if (!d->m_cut.isNull())
956 updateShortcut( static_cast<TQPopupMenu*>(w), itemId_ );
958 else if ( ::tqqt_cast<TQMenuBar *>( w ) )
959 static_cast<TQMenuBar*>(w)->changeItem( itemId(
id ), d->iconSet(
KIcon::Small ), d->text() );
960 else if ( ::tqqt_cast<KToolBar *>( w ) )
961 static_cast<KToolBar *>(w)->setButtonIcon( itemId(
id ), d->iconName() );
964 TQString KAction::icon()
const 966 return d->iconName( );
971 d->setIconSet( iconset );
973 int len = containerCount();
974 for(
int i = 0; i < len; ++i )
979 void KAction::updateIconSet(
int id )
981 TQWidget *w = container(
id );
983 if ( ::tqqt_cast<TQPopupMenu *>( w ) )
985 int itemId_ = itemId(
id );
986 static_cast<TQPopupMenu*
>(w)->changeItem( itemId_, d->iconSet(), d->text() );
987 if (!d->m_cut.isNull())
988 updateShortcut( static_cast<TQPopupMenu*>(w), itemId_ );
990 else if ( ::tqqt_cast<TQMenuBar *>( w ) )
991 static_cast<TQMenuBar*>(w)->changeItem( itemId(
id ), d->iconSet(), d->text() );
992 else if ( ::tqqt_cast<KToolBar *>( w ) )
994 if ( icon().isEmpty() && d->hasIcon() )
995 static_cast<KToolBar *>(w)->setButtonIconSet( itemId(
id ), d->iconSet() );
1003 return d->iconSet( group, size );
1006 bool KAction::hasIcon()
const 1008 return d->hasIcon();
1013 d->setWhatsThis( text );
1015 int len = containerCount();
1016 for(
int i = 0; i < len; ++i )
1017 updateWhatsThis( i );
1020 void KAction::updateWhatsThis(
int i )
1022 TQPopupMenu* pm = popupMenu( i );
1025 pm->TQMenuData::setWhatsThis( itemId( i ), d->whatsThis() );
1032 TQWidget *w = tb->
getButton( itemId( i ) );
1033 TQWhatsThis::remove( w );
1034 TQWhatsThis::add( w, d->whatsThis() );
1041 return d->whatsThis();
1044 TQString KAction::whatsThisWithIcon()
const 1047 if (!d->iconName().isEmpty())
1048 return TQString::fromLatin1(
"<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text);
1052 TQWidget* KAction::container(
int index )
const 1054 assert( index < containerCount() );
1055 return d->m_containers[ index ].m_container;
1058 KToolBar* KAction::toolBar(
int index )
const 1060 return tqt_dynamic_cast<
KToolBar *>( d->m_containers[ index ].m_container );
1063 TQPopupMenu* KAction::popupMenu(
int index )
const 1065 return tqt_dynamic_cast<TQPopupMenu *>( d->m_containers[ index ].m_container );
1068 TQWidget* KAction::representative(
int index )
const 1070 return d->m_containers[ index ].m_representative;
1073 int KAction::itemId(
int index )
const 1075 return d->m_containers[ index ].m_id;
1078 int KAction::containerCount()
const 1080 return d->m_containers.count();
1085 return d->m_kaccelList.count();
1088 void KAction::addContainer( TQWidget* c,
int id )
1090 KActionPrivate::Container p;
1093 d->m_containers.append( p );
1096 void KAction::addContainer( TQWidget* c, TQWidget* w )
1098 KActionPrivate::Container p;
1100 p.m_representative = w;
1101 d->m_containers.append( p );
1106 emit
activated( KAction::EmulatedActivation, Qt::NoButton );
1110 void KAction::slotActivated()
1112 const TQObject *senderObj = TQT_TQOBJECT_CONST(sender());
1115 if ( ::tqqt_cast<KAccelPrivate *>( senderObj ) )
1116 emit
activated( KAction::AccelActivation, Qt::NoButton );
1127 if( ::tqqt_cast<TQSignal *>(sender()))
1129 int id = tqt_dynamic_cast<
const TQSignal *>(sender())->value().toInt();
1130 int pos = findContainer(
id);
1133 TQPopupMenu* qpm = tqt_dynamic_cast<TQPopupMenu *>( container(pos) );
1137 TQt::ButtonState state;
1139 state = kpm->
state();
1141 kdDebug(129) <<
"KAction::slotPopupActivated not a KPopupMenu -> using keyboardMouseState()" <<
endl;
1144 emit
activated( KAction::PopupMenuActivation, state );
1151 kdWarning(129)<<
"Don't connect KAction::slotPopupActivated() to anything, expect into QPopupMenus which are in containers. Use slotActivated instead."<<
endl;
1152 emit
activated( KAction::PopupMenuActivation, Qt::NoButton );
1158 kdDebug(129) <<
"slotButtonClicked() state=" << state <<
endl;
1159 emit
activated( KAction::ToolBarActivation, state );
1162 if ( ( state & Qt::LeftButton ) || ( state & Qt::MidButton ) )
1167 void KAction::slotDestroyed()
1169 kdDebug(129) <<
"KAction::slotDestroyed(): this = " <<
this <<
", name = \"" << name() <<
"\", sender = " << sender() <<
endl;
1170 const TQObject*
const o = TQT_TQOBJECT_CONST(sender());
1172 #ifndef KDE_NO_COMPAT // KDE 4: remove 1173 if ( o == d->m_kaccel )
1178 #endif // KDE 4: remove end 1179 TQValueList<KAccel*> & accelList = d->m_kaccelList;
1180 TQValueList<KAccel*>::iterator itr = accelList.begin();
1181 const TQValueList<KAccel*>::iterator itrEnd = accelList.end();
1183 for( ; itr != itrEnd; ++itr)
1187 disconnect( *itr, TQT_SIGNAL(destroyed()),
this, TQT_SLOT(slotDestroyed()) );
1188 accelList.remove(itr);
1196 i = findContainer( TQT_TQWIDGET_CONST( static_cast<const QObject*>(o) ) );
1198 removeContainer( i );
1199 }
while ( i != -1 );
1202 int KAction::findContainer(
const TQWidget* widget )
const 1206 const TQValueList<KActionPrivate::Container> & containers = d->m_containers;
1208 TQValueList<KActionPrivate::Container>::ConstIterator it = containers.constBegin();
1209 const TQValueList<KActionPrivate::Container>::ConstIterator itEnd = containers.constEnd();
1211 while( it != itEnd )
1213 if ( (*it).m_representative == widget || (*it).m_container == widget )
1222 int KAction::findContainer(
const int id )
const 1226 const TQValueList<KActionPrivate::Container> & containers = d->m_containers;
1228 TQValueList<KActionPrivate::Container>::ConstIterator it = containers.constBegin();
1229 const TQValueList<KActionPrivate::Container>::ConstIterator itEnd = containers.constEnd();
1231 while( it != itEnd )
1233 if ( (*it).m_id ==
id )
1242 void KAction::removeContainer(
int index )
1246 TQValueList<KActionPrivate::Container> & containers = d->m_containers;
1248 TQValueList<KActionPrivate::Container>::Iterator it = containers.begin();
1249 const TQValueList<KActionPrivate::Container>::Iterator itEnd = containers.end();
1251 while( it != itEnd )
1255 containers.remove( it );
1264 void KAction::slotKeycodeChanged()
1266 kdDebug(129) <<
"KAction::slotKeycodeChanged()" <<
endl;
1267 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name());
1274 return m_parentCollection;
1277 void KAction::unplugAll()
1279 while ( containerCount() != 0 )
1280 unplug( container( 0 ) );
1288 void KAction::virtual_hook(
int,
void* )
1294 #include "kaction.moc" TQString kdBacktrace(int levels=-1)
virtual void setShortcutConfigurable(bool)
Indicate whether the user may configure the action's shortcut.
A managed set of KAction objects.
void slotButtonClicked(int, TQt::ButtonState state)
void setAccel(int key) KDE_DEPRECATED
virtual void setToolTip(const TQString &)
Sets the tooltip text for the action.
int accel() const KDE_DEPRECATED
bool hasIcon() const
returns whether an icon is defined, doesn't tell if it really exists
KAccelAction * insert(const TQString &sAction, const TQString &sLabel, const TQString &sWhatsThis, const KShortcut &cutDef, const TQObject *pObjSlot, const char *psMethodSlot, bool bConfigurable=true, bool bEnabled=true)
void slotPopupActivated()
KAction(const TQString &text, const KShortcut &cut, const TQObject *receiver, const char *slot, KActionCollection *parent, const char *name)
Constructs an action with text, potential keyboard shortcut, and a TQT_SLOT to call when this action ...
virtual bool setShortcut(const KShortcut &)
Sets the keyboard shortcut associated with this action.
virtual TQString whatsThis() const
Get the What's this text for the action.
TQIconSet iconSet() const
Remove in KDE4.
kdbgstream kdDebug(int area=0)
bool isAutoConnectShortcuts()
This indicates whether new actions which are created in this collection have their keyboard shortcuts...
KAccel * kaccel()
Returns the KAccel object of the most recently set widget.
virtual void unplugAccel() KDE_DEPRECATED
virtual bool isPlugged() const
returns whether the action is plugged into any container widget or not.
const KGuiItem & guiItem() const
Return the underlying KGuiItem.
KDE top level main window
KInstance * instance() const
The instance with which this class is associated.
An abstract class for GUI data such as ToolTip and Icon.
virtual void plugAccel(KAccel *accel, bool configurable=true) KDE_DEPRECATED
virtual void activate()
Emulate user's interaction programmatically, by activating the action.
virtual TQString toolTip() const
Get the tooltip text for the action.
kdbgstream kdWarning(int area=0)
static int getToolButtonID()
How it works.
virtual void unplug(TQWidget *w)
"Unplug" or remove this action from a given widget.
KAccel * builderKAccel() const
virtual void setIconSet(const TQIconSet &iconSet)
Sets the TQIconSet from which the icons used to display this action will be chosen.
virtual const KShortcut & shortcut() const
Get the keyboard shortcut associated with this action.
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
static KInstance * instance()
void disconnectHighlight(TQWidget *container, KAction *action)
Disconnect highlight notifications for a particular pair of contianer and action. ...
virtual const KShortcut & shortcutDefault() const
Get the default shortcut for this action.
virtual ~KAction()
Standard destructor.
virtual TQString text() const
Get the text associated with this action.
void connectHighlight(TQWidget *container, KAction *action)
Call this function if you want to receive a signal whenever a KAction is highlighted in a menu or a t...
virtual bool isShortcutConfigurable() const
Returns true if this action's shortcut is configurable.
void activated()
Emitted when this action is activated.
kndbgstream & endl(kndbgstream &s)
virtual void setWhatsThis(const TQString &text)
Sets the What's this text for the action.
virtual void setEnabled(bool enable)
Enables or disables this action.
virtual bool isEnabled() const
Returns true if this action is enabled.
void insert(KAction *action)
Add an action to the collection.
KAction * take(KAction *action)
Removes an action from the collection.
virtual void setText(const TQString &text)
Sets the text associated with this action.
bool remove(const TQString &sAction)
bool setShortcut(const TQString &sAction, const KShortcut &shortcut)
static ButtonState keyboardMouseState()