26 #include "tdeaction.h"
30 #include <tqtooltip.h>
31 #include <tqwhatsthis.h>
34 #include <tdeaccelbase.h>
35 #include <tdeaccelprivate.h>
36 #include <tdeapplication.h>
39 #include <tdemainwindow.h>
40 #include <tdemenubar.h>
41 #include <tdepopupmenu.h>
42 #include <tdetoolbar.h>
43 #include <tdetoolbarbutton.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 TDEAction::TDEActionPrivate :
public KGuiItem
92 m_configurable =
true;
96 TQValueList<TDEAccel*> m_tdeaccelList;
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 TDEActionPrivate)
128 initPrivate(
text, cut, receiver, slot );
132 const TQObject* receiver,
const char* slot,
134 : TQObject( parent, name ), d(new TDEActionPrivate)
136 initPrivate(
text, cut, receiver, slot );
137 d->setIconName( sIconName );
141 const TQObject* receiver,
const char* slot,
143 : TQObject( parent, name ), d(new TDEActionPrivate)
145 initPrivate(
text, cut, receiver, slot );
146 d->setIconSet( pix );
150 const TQObject* receiver,
const char* slot,
152 : TQObject( parent, name ), d(new TDEActionPrivate)
154 initPrivate( item.text(), cut, receiver, slot );
156 setIcon( item.iconName() );
161 #ifndef KDE_NO_COMPAT
163 TQObject* parent,
const char* name )
164 : TQObject( parent, name ), d(new TDEActionPrivate)
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 TDEActionPrivate)
174 initPrivate(
text, cut, receiver, slot );
179 TQObject* parent,
const char* name )
180 : TQObject( parent, name ), d(new TDEActionPrivate)
182 initPrivate(
text, cut, 0, 0 );
188 TQObject* parent,
const char* name )
189 : TQObject( parent, name ), d(new TDEActionPrivate)
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 TDEActionPrivate)
201 initPrivate(
text, cut, receiver, slot );
207 const TQObject* receiver,
const char* slot, TQObject* parent,
209 : TQObject( parent, name ), d(new TDEActionPrivate)
211 initPrivate(
text, cut, receiver, slot );
216 : TQObject( parent, name ), d(new TDEActionPrivate)
218 initPrivate( TQString::null,
TDEShortcut(), 0, 0 );
224 kdDebug(129) <<
"TDEAction::~TDEAction( this = \"" << name() <<
"\" )" <<
endl;
225 #ifndef KDE_NO_COMPAT
231 if ( m_parentCollection ) {
232 m_parentCollection->
take(
this );
234 const TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
235 TQValueList<TDEAccel*>::const_iterator itr = accelList.constBegin();
236 const TQValueList<TDEAccel*>::const_iterator itrEnd = accelList.constEnd();
238 const char *
const namePtr = name();
239 for (; itr != itrEnd; ++itr )
240 (*itr)->remove(namePtr);
254 void TDEAction::initPrivate(
const TQString& text,
const TDEShortcut& cut,
255 const TQObject* receiver,
const char* slot )
257 d->m_cutDefault = cut;
260 kdDebug(129) <<
"TDEAction::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, TQ_SIGNAL(
activated() ), receiver, slot );
267 if( !cut.
isNull() && !qstrcmp( name(),
"unnamed" ) )
268 kdWarning(129) <<
"TDEAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() <<
") to an unnamed action." <<
endl;
275 return (!d->m_containers.empty()) || d->m_tdeaccel;
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 TDEAccel* TDEAction::tdeaccelCurrent()
370 else if( m_parentCollection && m_parentCollection->
tdeaccel() )
371 return m_parentCollection->
tdeaccel();
377 bool TDEAction::initShortcut(
const TDEShortcut& cut )
382 if( qstrcmp(
name(),
"unnamed" ) &&
383 m_parentCollection &&
387 insertTDEAccel( m_parentCollection->
tdeaccel() );
394 void TDEAction::plugShortcut()
396 TDEAccel*
const tdeaccel = tdeaccelCurrent();
399 if( tdeaccel && qstrcmp(
name(),
"unnamed" ) ) {
401 const TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
402 TQValueList<TDEAccel*>::const_iterator itr = accelList.constBegin();
403 const TQValueList<TDEAccel*>::const_iterator itrEnd = accelList.constEnd();
405 for( ; itr != itrEnd; ++itr) {
406 if( (*itr) == tdeaccel )
410 insertTDEAccel( tdeaccel );
416 bool bChanged = (d->m_cut != cut);
419 TDEAccel*
const tdeaccel = tdeaccelCurrent();
420 bool bInsertRequired =
true;
423 const TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
424 TQValueList<TDEAccel*>::const_iterator itr = accelList.constBegin();
425 const TQValueList<TDEAccel*>::const_iterator itrEnd = accelList.constEnd();
427 for( ; itr != itrEnd; ++itr) {
430 if( (*itr) == tdeaccel )
431 bInsertRequired =
false;
433 updateTDEAccelShortcut( *itr );
437 if( tdeaccel && bInsertRequired && qstrcmp( name(),
"unnamed" ) )
438 insertTDEAccel( tdeaccel );
441 #ifndef KDE_NO_COMPAT
443 d->m_tdeaccel->setShortcut( name(), cut );
445 int len = containerCount();
446 for(
int i = 0; i < len; ++i )
452 bool TDEAction::updateTDEAccelShortcut(
TDEAccel* tdeaccel )
455 if (kapp && !kapp->authorizeTDEAction(name()))
460 if ( !tdeaccel->actions().actionPtr( name() ) ) {
461 if(!d->m_cut.isNull() ) {
462 kdDebug(129) <<
"Inserting " << name() <<
", " << d->text() <<
", " << d->plainText() <<
endl;
463 b = tdeaccel->
insert( name(), d->plainText(), TQString::null,
465 this, TQ_SLOT(slotActivated()),
475 void TDEAction::insertTDEAccel(
TDEAccel* tdeaccel )
478 if ( !tdeaccel->actions().actionPtr(
name() ) ) {
479 if( updateTDEAccelShortcut( tdeaccel ) ) {
480 d->m_tdeaccelList.append( tdeaccel );
481 connect( tdeaccel, TQ_SIGNAL(destroyed()),
this, TQ_SLOT(slotDestroyed()) );
485 kdWarning(129) <<
"TDEAction::insertTDEAccel( tdeaccel = " << tdeaccel <<
" ): TDEAccel object already contains an action name \"" <<
name() <<
"\"" <<
endl;
488 void TDEAction::removeTDEAccel(
TDEAccel* tdeaccel )
491 TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
492 TQValueList<TDEAccel*>::iterator itr = accelList.begin();
493 const TQValueList<TDEAccel*>::iterator itrEnd = accelList.end();
495 for( ; itr != itrEnd; ++itr) {
496 if( (*itr) == tdeaccel ) {
498 accelList.remove( itr );
499 disconnect( tdeaccel, TQ_SIGNAL(destroyed()),
this, TQ_SLOT(slotDestroyed()) );
505 #ifndef KDE_NO_COMPAT
513 void TDEAction::updateShortcut(
int i )
515 int id = itemId( i );
517 TQWidget* w = container( i );
518 if ( ::tqt_cast<TQPopupMenu *>( w ) ) {
519 TQPopupMenu* menu =
static_cast<TQPopupMenu*
>(w);
520 updateShortcut( menu,
id );
522 else if ( ::tqt_cast<TQMenuBar *>( w ) )
523 static_cast<TQMenuBar*
>(w)->
setAccel( d->m_cut.keyCodeQt(), id );
526 void TDEAction::updateShortcut( TQPopupMenu* menu,
int id )
531 if ( d->m_tdeaccel || d->m_tdeaccelList.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) <<
"TDEAction::updateShortcut(): name = \"" <<
name() <<
"\", cut = " << d->m_cut.toStringInternal() <<
"; No TDEAccel, probably missing a parent collection." <<
endl;
557 return d->m_cutDefault;
560 TQString TDEAction::shortcutText()
const
562 return d->m_cut.toStringInternal();
565 void TDEAction::setShortcutText(
const TQString& s )
570 #ifndef KDE_NO_COMPAT
573 return d->m_cut.keyCodeQt();
577 void TDEAction::setGroup(
const TQString& grp )
581 int len = containerCount();
582 for(
int i = 0; i < len; ++i )
586 void TDEAction::updateGroup(
int )
591 TQString TDEAction::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 TDEAction::updateToolTip(
int i )
617 TQWidget *w = container( i );
619 if ( ::tqt_cast<TDEToolBar *>( w ) )
620 TQToolTip::add(
static_cast<TDEToolBar*
>(w)->getWidget( itemId( i ) ), d->toolTip() );
632 kdWarning(129) <<
"TDEAction::plug called with 0 argument\n";
640 TDEAccel* tdeaccel = tdeaccelCurrent();
641 if( !d->m_cut.isNull() && !tdeaccel ) {
642 kdDebug(129) <<
"TDEAction::plug(): has no TDEAccel object; this = " <<
this <<
" name = " << name() <<
" parentCollection = " << m_parentCollection <<
endl;
647 if (kapp && !kapp->authorizeTDEAction(name()))
652 if ( ::tqt_cast<TQPopupMenu *>( w ) )
654 TQPopupMenu* menu =
static_cast<TQPopupMenu*
>( w );
657 int keyQt = (d->m_tdeaccelList.count() || d->m_tdeaccel) ? 0 : d->m_cut.keyCodeQt();
662 if ( m_parentCollection )
663 instance = m_parentCollection->
instance();
666 id = menu->insertItem( d->iconSet(
TDEIcon::Small, 0, instance ), d->text(),
this,
671 id = menu->insertItem( d->text(),
this,
677 if ( d->m_tdeaccelList.count() || d->m_tdeaccel )
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, TQ_SIGNAL( destroyed() ),
this, TQ_SLOT( slotDestroyed() ) );
691 if ( m_parentCollection )
694 return d->m_containers.count() - 1;
696 else if ( ::tqt_cast<TDEToolBar *>( w ) )
702 if ( m_parentCollection )
703 instance = m_parentCollection->
instance();
707 if ( icon().isEmpty() && !
iconSet().pixmap().isNull() )
709 bar->
insertButton(
iconSet().pixmap(), id_, TQ_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_, TQ_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, TQ_SIGNAL( destroyed() ),
this, TQ_SLOT( slotDestroyed() ) );
736 if ( m_parentCollection )
739 return containerCount() - 1;
747 int i = findContainer( w );
750 int id = itemId( i );
752 if ( ::tqt_cast<TQPopupMenu *>( w ) )
754 TQPopupMenu *menu =
static_cast<TQPopupMenu *
>( w );
755 menu->removeItem(
id );
757 else if ( ::tqt_cast<TDEToolBar *>( w ) )
762 else if ( ::tqt_cast<TQMenuBar *>( w ) )
764 TQMenuBar *bar =
static_cast<TQMenuBar *
>( w );
765 bar->removeItem(
id );
768 removeContainer( i );
769 if ( m_parentCollection )
776 kdWarning(129) <<
"TDEAction::plugAccel(): call to deprecated action." <<
endl;
789 if ( !kacc->actions().actionPtr(name()) )
791 d->m_tdeaccel = kacc;
792 d->m_tdeaccel->insert(name(), d->plainText(), TQString::null,
794 this, TQ_SLOT(slotActivated()),
796 connect(d->m_tdeaccel, TQ_SIGNAL(destroyed()),
this, TQ_SLOT(slotDestroyed()));
802 kdWarning(129) <<
"TDEAction::plugAccel( kacc = " << kacc <<
" ): TDEAccel object already contains an action name \"" << name() <<
"\"" <<
endl;
812 d->m_tdeaccel->remove(name());
817 void TDEAction::plugMainWindowAccel( TQWidget *w )
822 while ( !tl->isDialog() && ( n = tl->parentWidget() ) )
829 kdDebug(129) <<
"TDEAction::plugMainWindowAccel: Toplevel widget isn't a TDEMainWindow, can't plug accel. " << tl <<
endl;
835 if ( enable == d->isEnabled() )
838 #ifndef KDE_NO_COMPAT
841 d->m_tdeaccel->setEnabled(name(), enable);
844 const TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
845 TQValueList<TDEAccel*>::const_iterator itr = accelList.constBegin();
846 const TQValueList<TDEAccel*>::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 TDEAction::updateEnabled(
int i )
864 TQWidget *w = container( i );
866 if ( ::tqt_cast<TQPopupMenu *>( w ) )
867 static_cast<TQPopupMenu*
>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
868 else if ( ::tqt_cast<TQMenuBar *>( w ) )
869 static_cast<TQMenuBar*
>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
870 else if ( ::tqt_cast<TDEToolBar *>( w ) )
876 d->m_configurable = b;
881 #ifndef KDE_NO_COMPAT
884 TDEAccelAction* pAction = d->m_tdeaccel->actions().actionPtr(name());
886 pAction->setLabel(
text );
889 const TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
890 TQValueList<TDEAccel*>::const_iterator itr = accelList.constBegin();
891 const TQValueList<TDEAccel*>::const_iterator itrEnd = accelList.constEnd();
893 const char *
const namePtr = name();
895 for( ; itr != itrEnd; ++itr ) {
896 TDEAccelAction*
const pAction = (*itr)->actions().actionPtr(namePtr);
898 pAction->setLabel(
text );
903 int len = containerCount();
904 for(
int i = 0; i < len; ++i )
908 void TDEAction::updateText(
int i )
910 TQWidget *w = container( i );
912 if ( ::tqt_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 ( ::tqt_cast<TQMenuBar *>( w ) )
919 static_cast<TQMenuBar*
>(w)->changeItem( itemId( i ), d->text() );
920 else if ( ::tqt_cast<TDEToolBar *>( w ) )
922 TQWidget *button =
static_cast<TDEToolBar *
>(w)->getWidget( itemId( i ) );
923 if ( ::tqt_cast<TDEToolBarButton *>( button ) )
933 TQString TDEAction::plainText()
const
935 return d->plainText( );
938 void TDEAction::setIcon(
const TQString &icon )
940 d->setIconName( icon );
943 int len = containerCount();
944 for (
int i = 0; i < len; ++i )
948 void TDEAction::updateIcon(
int id )
950 TQWidget* w = container(
id );
952 if ( ::tqt_cast<TQPopupMenu *>( w ) ) {
953 int itemId_ = itemId(
id );
954 static_cast<TQPopupMenu*
>(w)->changeItem( itemId_, d->iconSet(
TDEIcon::Small ), d->text() );
955 if (!d->m_cut.isNull())
956 updateShortcut(
static_cast<TQPopupMenu*
>(w), itemId_ );
958 else if ( ::tqt_cast<TQMenuBar *>( w ) )
959 static_cast<TQMenuBar*
>(w)->changeItem( itemId(
id ), d->iconSet(
TDEIcon::Small ), d->text() );
960 else if ( ::tqt_cast<TDEToolBar *>( w ) )
964 TQString TDEAction::icon()
const
966 return d->iconName( );
971 d->setIconSet( iconset );
973 int len = containerCount();
974 for(
int i = 0; i < len; ++i )
979 void TDEAction::updateIconSet(
int id )
981 TQWidget *w = container(
id );
983 if ( ::tqt_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 ( ::tqt_cast<TQMenuBar *>( w ) )
991 static_cast<TQMenuBar*
>(w)->changeItem( itemId(
id ), d->iconSet(), d->text() );
992 else if ( ::tqt_cast<TDEToolBar *>( w ) )
994 if ( icon().isEmpty() && d->hasIcon() )
1003 return d->iconSet( group, size );
1006 bool TDEAction::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 TDEAction::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 TDEAction::whatsThisWithIcon()
const
1047 if (!d->iconName().isEmpty())
1048 return TQString::fromLatin1(
"<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(
text);
1052 TQWidget* TDEAction::container(
int index )
const
1054 assert( index < containerCount() );
1055 return d->m_containers[ index ].m_container;
1058 TDEToolBar* TDEAction::toolBar(
int index )
const
1060 return dynamic_cast<TDEToolBar *
>( d->m_containers[ index ].m_container );
1063 TQPopupMenu* TDEAction::popupMenu(
int index )
const
1065 return dynamic_cast<TQPopupMenu *
>( d->m_containers[ index ].m_container );
1068 TQWidget* TDEAction::representative(
int index )
const
1070 return d->m_containers[ index ].m_representative;
1073 int TDEAction::itemId(
int index )
const
1075 return d->m_containers[ index ].m_id;
1078 int TDEAction::containerCount()
const
1080 return d->m_containers.count();
1085 return d->m_tdeaccelList.count();
1088 void TDEAction::addContainer( TQWidget* c,
int id )
1090 TDEActionPrivate::Container p;
1093 d->m_containers.append( p );
1096 void TDEAction::addContainer( TQWidget* c, TQWidget* w )
1098 TDEActionPrivate::Container p;
1100 p.m_representative = w;
1101 d->m_containers.append( p );
1106 emit
activated( TDEAction::EmulatedActivation, TQt::NoButton );
1110 void TDEAction::slotActivated()
1112 const TQObject *senderObj = sender();
1115 if ( ::tqt_cast<TDEAccelPrivate *>( senderObj ) )
1116 emit
activated( TDEAction::AccelActivation, TQt::NoButton );
1127 if( ::tqt_cast<TQSignal *>(sender()))
1129 int id =
dynamic_cast<const TQSignal *
>(sender())->value().toInt();
1130 int pos = findContainer(
id);
1133 TQPopupMenu* qpm =
dynamic_cast<TQPopupMenu *
>( container(pos) );
1137 TQt::ButtonState state;
1139 state = kpm->
state();
1141 kdDebug(129) <<
"TDEAction::slotPopupActivated not a TDEPopupMenu -> using keyboardMouseState()" <<
endl;
1144 emit
activated( TDEAction::PopupMenuActivation, state );
1151 kdWarning(129)<<
"Don't connect TDEAction::slotPopupActivated() to anything, expect into QPopupMenus which are in containers. Use slotActivated instead."<<
endl;
1152 emit
activated( TDEAction::PopupMenuActivation, TQt::NoButton );
1158 kdDebug(129) <<
"slotButtonClicked() state=" << state <<
endl;
1159 emit
activated( TDEAction::ToolBarActivation, state );
1162 if ( ( state & TQt::LeftButton ) || ( state & TQt::MidButton ) )
1167 void TDEAction::slotDestroyed()
1169 kdDebug(129) <<
"TDEAction::slotDestroyed(): this = " <<
this <<
", name = \"" << name() <<
"\", sender = " << sender() <<
endl;
1170 const TQObject*
const o = sender();
1172 #ifndef KDE_NO_COMPAT
1173 if ( o == d->m_tdeaccel )
1179 TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
1180 TQValueList<TDEAccel*>::iterator itr = accelList.begin();
1181 const TQValueList<TDEAccel*>::iterator itrEnd = accelList.end();
1183 for( ; itr != itrEnd; ++itr)
1187 disconnect( *itr, TQ_SIGNAL(destroyed()),
this, TQ_SLOT(slotDestroyed()) );
1188 accelList.remove(itr);
1196 i = findContainer(
static_cast<const TQWidget*
>(o) );
1198 removeContainer( i );
1199 }
while ( i != -1 );
1202 int TDEAction::findContainer(
const TQWidget* widget )
const
1206 const TQValueList<TDEActionPrivate::Container> & containers = d->m_containers;
1208 TQValueList<TDEActionPrivate::Container>::ConstIterator it = containers.constBegin();
1209 const TQValueList<TDEActionPrivate::Container>::ConstIterator itEnd = containers.constEnd();
1211 while( it != itEnd )
1213 if ( (*it).m_representative == widget || (*it).m_container == widget )
1222 int TDEAction::findContainer(
const int id )
const
1226 const TQValueList<TDEActionPrivate::Container> & containers = d->m_containers;
1228 TQValueList<TDEActionPrivate::Container>::ConstIterator it = containers.constBegin();
1229 const TQValueList<TDEActionPrivate::Container>::ConstIterator itEnd = containers.constEnd();
1231 while( it != itEnd )
1233 if ( (*it).m_id ==
id )
1242 void TDEAction::removeContainer(
int index )
1246 TQValueList<TDEActionPrivate::Container> & containers = d->m_containers;
1248 TQValueList<TDEActionPrivate::Container>::Iterator it = containers.begin();
1249 const TQValueList<TDEActionPrivate::Container>::Iterator itEnd = containers.end();
1251 while( it != itEnd )
1255 containers.remove( it );
1264 void TDEAction::slotKeycodeChanged()
1266 kdDebug(129) <<
"TDEAction::slotKeycodeChanged()" <<
endl;
1267 TDEAccelAction* pAction = d->m_tdeaccel->actions().actionPtr(
name());
1274 return m_parentCollection;
1277 void TDEAction::unplugAll()
1279 while ( containerCount() != 0 )
1280 unplug( container( 0 ) );
1288 void TDEAction::virtual_hook(
int,
void* )
1291 #include "tdeaction.moc"
An abstract class for GUI data such as ToolTip and Icon.
bool hasIcon() const
returns whether an icon is defined, doesn't tell if it really exists
bool remove(const TQString &sAction)
TDEAccelAction * insert(const TQString &sAction, const TQString &sLabel, const TQString &sWhatsThis, const TDEShortcut &cutDef, const TQObject *pObjSlot, const char *psMethodSlot, bool bConfigurable=true, bool bEnabled=true)
bool setShortcut(const TQString &sAction, const TDEShortcut &shortcut)
A managed set of TDEAction objects.
TDEAccel * tdeaccel()
Returns the TDEAccel object of the most recently set widget.
void insert(TDEAction *action)
Add an action to the collection.
void disconnectHighlight(TQWidget *container, TDEAction *action)
Disconnect highlight notifications for a particular pair of contianer and action.
TDEAction * take(TDEAction *action)
Removes an action from the collection.
TDEInstance * instance() const
The instance with which this class is associated.
TDEAccel * builderTDEAccel() const
void connectHighlight(TQWidget *container, TDEAction *action)
Call this function if you want to receive a signal whenever a TDEAction is highlighted in a menu or a...
bool isAutoConnectShortcuts()
This indicates whether new actions which are created in this collection have their keyboard shortcuts...
TQIconSet iconSet() const
Remove in KDE4.
virtual bool setShortcut(const TDEShortcut &)
Sets the keyboard shortcut associated with this action.
uint tdeaccelCount() const
virtual void plugAccel(TDEAccel *accel, bool configurable=true) TDE_DEPRECATED
virtual void setToolTip(const TQString &)
Sets the tooltip text for the action.
virtual void setShortcutConfigurable(bool)
Indicate whether the user may configure the action's shortcut.
virtual void activate()
Emulate user's interaction programmatically, by activating the action.
virtual bool isPlugged() const
returns whether the action is plugged into any container widget or not.
virtual bool isShortcutConfigurable() const
Returns true if this action's shortcut is configurable.
virtual void setWhatsThis(const TQString &text)
Sets the What's this text for the action.
void slotButtonClicked(int, TQt::ButtonState state)
virtual void setEnabled(bool enable)
Enables or disables this action.
void slotPopupActivated()
virtual ~TDEAction()
Standard destructor.
virtual void unplug(TQWidget *w)
"Unplug" or remove this action from a given widget.
TDEAction(const TQString &text, const TDEShortcut &cut, const TQObject *receiver, const char *slot, TDEActionCollection *parent, const char *name)
Constructs an action with text, potential keyboard shortcut, and a slot to call when this action is i...
void setAccel(int key) TDE_DEPRECATED
virtual void unplugAccel() TDE_DEPRECATED
int accel() const TDE_DEPRECATED
virtual bool isEnabled() const
Returns true if this action is enabled.
virtual TQString toolTip() const
Get the tooltip text for the action.
virtual TQString text() const
Get the text associated with this action.
virtual void setText(const TQString &text)
Sets the text associated with this action.
virtual void setIconSet(const TQIconSet &iconSet)
Sets the TQIconSet from which the icons used to display this action will be chosen.
virtual const TDEShortcut & shortcut() const
Get the keyboard shortcut associated with this action.
virtual TQString whatsThis() const
Get the What's this text for the action.
void activated()
Emitted when this action is activated.
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
const KGuiItem & guiItem() const
Return the underlying KGuiItem.
static int getToolButtonID()
How it works.
virtual const TDEShortcut & shortcutDefault() const
Get the default shortcut for this action.
static ButtonState keyboardMouseState()
static TDEInstance * instance()
KDE top level main window
kndbgstream & endl(kndbgstream &s)
TQString kdBacktrace(int levels=-1)
kdbgstream kdWarning(int area=0)
kdbgstream kdDebug(int area=0)
TQString name(StdAccel id)
const TDEShortcut & cut()