• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
tdeaction.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3  (C) 1999 Simon Hausmann <hausmann@kde.org>
4  (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5  (C) 2000 Kurt Granroth <granroth@kde.org>
6  (C) 2000 Michael Koch <koch@kde.org>
7  (C) 2001 Holger Freyther <freyther@kde.org>
8  (C) 2002 Ellis Whitehead <ellis@kde.org>
9  (C) 2002 Joseph Wenninger <jowenn@kde.org>
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Library General Public
13  License version 2 as published by the Free Software Foundation.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Library General Public License for more details.
19 
20  You should have received a copy of the GNU Library General Public License
21  along with this library; see the file COPYING.LIB. If not, write to
22  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  Boston, MA 02110-1301, USA.
24 */
25 
26 #include "tdeaction.h"
27 
28 #include <assert.h>
29 
30 #include <tqtooltip.h>
31 #include <tqwhatsthis.h>
32 
33 #include <tdeaccel.h>
34 #include <tdeaccelbase.h>
35 #include <tdeaccelprivate.h>
36 #include <tdeapplication.h>
37 #include <kdebug.h>
38 #include <kguiitem.h>
39 #include <tdemainwindow.h>
40 #include <tdemenubar.h>
41 #include <tdepopupmenu.h>
42 #include <tdetoolbar.h>
43 #include <tdetoolbarbutton.h>
44 
45 #include <ft2build.h>
46 #include <X11/Xdefs.h>
47 #include <X11/Xlib.h>
48 #include <X11/Xatom.h>
49 #include <X11/Intrinsic.h>
50 #include <X11/StringDefs.h>
51 #include <X11/Shell.h>
52 
53 #include <X11/Xft/Xft.h>
54 
76 int TDEAction::getToolButtonID()
77 {
78  static int toolbutton_no = -2;
79  return toolbutton_no--;
80 }
81 
82 //---------------------------------------------------------------------
83 // TDEAction::TDEActionPrivate
84 //---------------------------------------------------------------------
85 
86 class TDEAction::TDEActionPrivate : public KGuiItem
87 {
88 public:
89  TDEActionPrivate() : KGuiItem()
90  {
91  m_tdeaccel = 0;
92  m_configurable = true;
93  }
94 
95  TDEAccel *m_tdeaccel;
96  TQValueList<TDEAccel*> m_tdeaccelList;
97 
98  TQString m_groupText;
99  TQString m_group;
100 
101  TDEShortcut m_cut;
102  TDEShortcut m_cutDefault;
103 
104  bool m_configurable;
105 
106  struct Container
107  {
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;
112  int m_id;
113  TQWidget* m_representative;
114  };
115 
116  TQValueList<Container> m_containers;
117 };
118 
119 //---------------------------------------------------------------------
120 // TDEAction
121 //---------------------------------------------------------------------
122 
123 TDEAction::TDEAction( const TQString& text, const TDEShortcut& cut,
124  const TQObject* receiver, const char* slot,
125  TDEActionCollection* parent, const char* name )
126 : TQObject( parent, name ), d(new TDEActionPrivate)
127 {
128  initPrivate( text, cut, receiver, slot );
129 }
130 
131 TDEAction::TDEAction( const TQString& text, const TQString& sIconName, const TDEShortcut& cut,
132  const TQObject* receiver, const char* slot,
133  TDEActionCollection* parent, const char* name )
134 : TQObject( parent, name ), d(new TDEActionPrivate)
135 {
136  initPrivate( text, cut, receiver, slot );
137  d->setIconName( sIconName );
138 }
139 
140 TDEAction::TDEAction( const TQString& text, const TQIconSet& pix, const TDEShortcut& cut,
141  const TQObject* receiver, const char* slot,
142  TDEActionCollection* parent, const char* name )
143 : TQObject( parent, name ), d(new TDEActionPrivate)
144 {
145  initPrivate( text, cut, receiver, slot );
146  d->setIconSet( pix );
147 }
148 
149 TDEAction::TDEAction( const KGuiItem& item, const TDEShortcut& cut,
150  const TQObject* receiver, const char* slot,
151  TDEActionCollection* parent, const char* name )
152 : TQObject( parent, name ), d(new TDEActionPrivate)
153 {
154  initPrivate( item.text(), cut, receiver, slot );
155  if( item.hasIcon() )
156  setIcon( item.iconName() );
157  setToolTip( item.toolTip() );
158  setWhatsThis( item.whatsThis() );
159 }
160 
161 #ifndef KDE_NO_COMPAT // KDE 4: remove
162 TDEAction::TDEAction( const TQString& text, const TDEShortcut& cut,
163  TQObject* parent, const char* name )
164  : TQObject( parent, name ), d(new TDEActionPrivate)
165 {
166  initPrivate( text, cut, 0, 0 );
167 }
168 
169 TDEAction::TDEAction( const TQString& text, const TDEShortcut& cut,
170  const TQObject* receiver,
171  const char* slot, TQObject* parent, const char* name )
172  : TQObject( parent, name ), d(new TDEActionPrivate)
173 {
174  initPrivate( text, cut, receiver, slot );
175 }
176 
177 TDEAction::TDEAction( const TQString& text, const TQIconSet& pix,
178  const TDEShortcut& cut,
179  TQObject* parent, const char* name )
180  : TQObject( parent, name ), d(new TDEActionPrivate)
181 {
182  initPrivate( text, cut, 0, 0 );
183  setIconSet( pix );
184 }
185 
186 TDEAction::TDEAction( const TQString& text, const TQString& pix,
187  const TDEShortcut& cut,
188  TQObject* parent, const char* name )
189 : TQObject( parent, name ), d(new TDEActionPrivate)
190 {
191  initPrivate( text, cut, 0, 0 );
192  d->setIconName( pix );
193 }
194 
195 TDEAction::TDEAction( const TQString& text, const TQIconSet& pix,
196  const TDEShortcut& cut,
197  const TQObject* receiver, const char* slot, TQObject* parent,
198  const char* name )
199  : TQObject( parent, name ), d(new TDEActionPrivate)
200 {
201  initPrivate( text, cut, receiver, slot );
202  setIconSet( pix );
203 }
204 
205 TDEAction::TDEAction( const TQString& text, const TQString& pix,
206  const TDEShortcut& cut,
207  const TQObject* receiver, const char* slot, TQObject* parent,
208  const char* name )
209  : TQObject( parent, name ), d(new TDEActionPrivate)
210 {
211  initPrivate( text, cut, receiver, slot );
212  d->setIconName(pix);
213 }
214 
215 TDEAction::TDEAction( TQObject* parent, const char* name )
216  : TQObject( parent, name ), d(new TDEActionPrivate)
217 {
218  initPrivate( TQString::null, TDEShortcut(), 0, 0 );
219 }
220 #endif // KDE 4: remove end
221 
222 TDEAction::~TDEAction()
223 {
224  kdDebug(129) << "TDEAction::~TDEAction( this = \"" << name() << "\" )" << endl; // -- ellis
225 #ifndef KDE_NO_COMPAT
226  if (d->m_tdeaccel)
227  unplugAccel();
228 #endif
229 
230  // If actionCollection hasn't already been destructed,
231  if ( m_parentCollection ) {
232  m_parentCollection->take( this );
233 
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();
237 
238  const char * const namePtr = name();
239  for (; itr != itrEnd; ++itr )
240  (*itr)->remove(namePtr);
241 
242  }
243 
244  // Do not call unplugAll from here, as tempting as it sounds.
245  // TDEAction is designed around the idea that you need to plug
246  // _and_ to unplug it "manually". Unplugging leads to an important
247  // slowdown when e.g. closing the window, in which case we simply
248  // want to destroy everything asap, not to remove actions one by one
249  // from the GUI.
250 
251  delete d;
252 }
253 
254 void TDEAction::initPrivate( const TQString& text, const TDEShortcut& cut,
255  const TQObject* receiver, const char* slot )
256 {
257  d->m_cutDefault = cut;
258 
259  m_parentCollection = tqt_dynamic_cast<TDEActionCollection *>( parent() );
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 );
263 
264  if ( receiver && slot )
265  connect( this, TQT_SIGNAL( activated() ), receiver, slot );
266 
267  if( !cut.isNull() && !qstrcmp( name(), "unnamed" ) )
268  kdWarning(129) << "TDEAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl;
269  d->setText( text );
270  initShortcut( cut );
271 }
272 
273 bool TDEAction::isPlugged() const
274 {
275  return (!d->m_containers.empty()) || d->m_tdeaccel;
276 }
277 
278 bool TDEAction::isPlugged( const TQWidget *container ) const
279 {
280  return findContainer( container ) > -1;
281 }
282 
283 bool TDEAction::isPlugged( const TQWidget *container, int id ) const
284 {
285  int i = findContainer( container );
286  return ( i > -1 && itemId( i ) == id );
287 }
288 
289 bool TDEAction::isPlugged( const TQWidget *container, const TQWidget *_representative ) const
290 {
291  int i = findContainer( container );
292  return ( i > -1 && representative( i ) == _representative );
293 }
294 
295 
296 /*
297 Three actionCollection conditions:
298  1) Scope is known on creation and TDEAccel object is created (e.g. TDEMainWindow)
299  2) Scope is unknown and no TDEAccel object is available (e.g. KXMLGUIClient)
300  a) addClient() will be called on object
301  b) we just want to add the actions to another KXMLGUIClient object
302 
303 The question is how to do we incorporate #2b into the XMLGUI framework?
304 
305 
306 We have a KCommandHistory object with undo and redo actions in a passed actionCollection
307 We have a KoDoc object which holds a KCommandHistory object and the actionCollection
308 We have two KoView objects which both point to the same KoDoc object
309 Undo and Redo should be available in both KoView objects, and
310  calling the undo->setEnabled() should affect both KoViews
311 
312 When addClient is called, it needs to be able to find the undo and redo actions
313 When it calls plug() on them, they need to be inserted into the TDEAccel object of the appropriate KoView
314 
315 In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts
316 have the same scope as the KoView actionCollection
317 
318 KXMLGUIClient::addSubActionCollection
319 
320 Document:
321  create document actions
322 
323 View
324  create view actions
325  add document actionCollection as sub-collection
326 
327 A parentCollection is created
328 Scenario 1: parentCollection has a focus widget set (e.g. via TDEMainWindow)
329  A TDEAccel object is created in the parentCollection
330  A TDEAction is created with parent=parentCollection
331  The shortcut is inserted into this actionCollection
332  Scenario 1a: xml isn't used
333  done
334  Scenario 1b: KXMLGUIBuilder::addClient() called
335  setWidget is called -- ignore
336  shortcuts are set
337 Scenario 2: parentCollection has no focus widget (e.g., KParts)
338  A TDEAction is created with parent=parentCollection
339  Scenario 2a: xml isn't used
340  no shortcuts
341  Scenario 2b: KXMLGUIBuilder::addClient() called
342  setWidget is called
343  shortcuts are inserted into current TDEAccel
344  shortcuts are set in all other TDEAccels, if the action is present in the other TDEAccels
345 */
346 
347 /*
348 shortcut may be set:
349  - on construction
350  - on plug
351  - on reading XML
352  - on plugAccel (deprecated)
353 
354 On Construction: [via initShortcut()]
355  insert into TDEAccel of m_parentCollection,
356  if tdeaccel() && isAutoConnectShortcuts() exists
357 
358 On Plug: [via plug() -> plugShortcut()]
359  insert into TDEAccel of m_parentCollection, if exists and not already inserted into
360 
361 On Read XML: [via setShortcut()]
362  set in all current TDEAccels
363  insert into TDEAccel of m_parentCollection, if exists and not already inserted into
364 */
365 
366 TDEAccel* TDEAction::tdeaccelCurrent()
367 {
368  if( m_parentCollection && m_parentCollection->builderTDEAccel() )
369  return m_parentCollection->builderTDEAccel();
370  else if( m_parentCollection && m_parentCollection->tdeaccel() )
371  return m_parentCollection->tdeaccel();
372  else
373  return 0L;
374 }
375 
376 // Only to be called from initPrivate()
377 bool TDEAction::initShortcut( const TDEShortcut& cut )
378 {
379  d->m_cut = cut;
380 
381  // Only insert action into TDEAccel if it has a valid name,
382  if( qstrcmp( name(), "unnamed" ) &&
383  m_parentCollection &&
384  m_parentCollection->isAutoConnectShortcuts() &&
385  m_parentCollection->tdeaccel() )
386  {
387  insertTDEAccel( m_parentCollection->tdeaccel() );
388  return true;
389  }
390  return false;
391  }
392 
393 // Only to be called from plug()
394 void TDEAction::plugShortcut()
395 {
396  TDEAccel* const tdeaccel = tdeaccelCurrent();
397 
398  //kdDebug(129) << "TDEAction::plugShortcut(): this = " << this << " tdeaccel() = " << (m_parentCollection ? m_parentCollection->tdeaccel() : 0) << endl;
399  if( tdeaccel && qstrcmp( name(), "unnamed" ) ) {
400  // Check if already plugged into current TDEAccel object
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();
404 
405  for( ; itr != itrEnd; ++itr) {
406  if( (*itr) == tdeaccel )
407  return;
408  }
409 
410  insertTDEAccel( tdeaccel );
411  }
412 }
413 
414 bool TDEAction::setShortcut( const TDEShortcut& cut )
415 {
416  bool bChanged = (d->m_cut != cut);
417  d->m_cut = cut;
418 
419  TDEAccel* const tdeaccel = tdeaccelCurrent();
420  bool bInsertRequired = true;
421  // Apply new shortcut to all existing TDEAccel objects
422 
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();
426 
427  for( ; itr != itrEnd; ++itr) {
428  // Check whether shortcut has already been plugged into
429  // the current tdeaccel object.
430  if( (*itr) == tdeaccel )
431  bInsertRequired = false;
432  if( bChanged )
433  updateTDEAccelShortcut( *itr );
434  }
435 
436  // Only insert action into TDEAccel if it has a valid name,
437  if( tdeaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) )
438  insertTDEAccel( tdeaccel );
439 
440  if( bChanged ) {
441 #ifndef KDE_NO_COMPAT // KDE 4: remove
442  if ( d->m_tdeaccel )
443  d->m_tdeaccel->setShortcut( name(), cut );
444 #endif // KDE 4: remove end
445  int len = containerCount();
446  for( int i = 0; i < len; ++i )
447  updateShortcut( i );
448  }
449  return true;
450 }
451 
452 bool TDEAction::updateTDEAccelShortcut( TDEAccel* tdeaccel )
453 {
454  // Check if action is permitted
455  if (kapp && !kapp->authorizeTDEAction(name()))
456  return false;
457 
458  bool b = true;
459 
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,
464  d->m_cut,
465  this, TQT_SLOT(slotActivated()),
466  isShortcutConfigurable(), isEnabled() );
467  }
468  }
469  else
470  b = tdeaccel->setShortcut( name(), d->m_cut );
471 
472  return b;
473 }
474 
475 void TDEAction::insertTDEAccel( TDEAccel* tdeaccel )
476 {
477  //kdDebug(129) << "TDEAction::insertTDEAccel( " << tdeaccel << " ): this = " << this << endl;
478  if ( !tdeaccel->actions().actionPtr( name() ) ) {
479  if( updateTDEAccelShortcut( tdeaccel ) ) {
480  d->m_tdeaccelList.append( tdeaccel );
481  connect( tdeaccel, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotDestroyed()) );
482  }
483  }
484  else
485  kdWarning(129) << "TDEAction::insertTDEAccel( tdeaccel = " << tdeaccel << " ): TDEAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis
486 }
487 
488 void TDEAction::removeTDEAccel( TDEAccel* tdeaccel )
489 {
490  //kdDebug(129) << "TDEAction::removeTDEAccel( " << i << " ): this = " << this << endl;
491  TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
492  TQValueList<TDEAccel*>::iterator itr = accelList.begin();
493  const TQValueList<TDEAccel*>::iterator itrEnd = accelList.end();
494 
495  for( ; itr != itrEnd; ++itr) {
496  if( (*itr) == tdeaccel ) {
497  tdeaccel->remove( name() );
498  accelList.remove( itr );
499  disconnect( tdeaccel, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotDestroyed()) );
500  break;
501  }
502  }
503 }
504 
505 #ifndef KDE_NO_COMPAT
506 // KDE 4: remove
507 void TDEAction::setAccel( int keyQt )
508 {
509  setShortcut( TDEShortcut(keyQt) );
510 }
511 #endif // KDE 4: remove end
512 
513 void TDEAction::updateShortcut( int i )
514 {
515  int id = itemId( i );
516 
517  TQWidget* w = container( i );
518  if ( ::tqqt_cast<TQPopupMenu *>( w ) ) {
519  TQPopupMenu* menu = static_cast<TQPopupMenu*>(w);
520  updateShortcut( menu, id );
521  }
522  else if ( ::tqqt_cast<TQMenuBar *>( w ) )
523  static_cast<TQMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id );
524 }
525 
526 void TDEAction::updateShortcut( TQPopupMenu* menu, int id )
527 {
528  //kdDebug(129) << "TDEAction::updateShortcut(): this = " << this << " d->m_tdeaccelList.count() = " << d->m_tdeaccelList.count() << endl;
529  // If the action has a TDEAccel object,
530  // show the string representation of its shortcut.
531  if ( d->m_tdeaccel || d->m_tdeaccelList.count() ) {
532  TQString s = menu->text( id );
533  int i = s.find( '\t' );
534  if ( i >= 0 )
535  s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() );
536  else
537  s += "\t" + d->m_cut.seq(0).toString();
538 
539  menu->changeItem( id, s );
540  }
541  // Otherwise insert the shortcut itself into the popup menu.
542  else {
543  // This is a fall-hack in case the TDEAction is missing a proper parent collection.
544  // It should be removed eventually. --ellis
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;
547  }
548 }
549 
550 const TDEShortcut& TDEAction::shortcut() const
551 {
552  return d->m_cut;
553 }
554 
555 const TDEShortcut& TDEAction::shortcutDefault() const
556 {
557  return d->m_cutDefault;
558 }
559 
560 TQString TDEAction::shortcutText() const
561 {
562  return d->m_cut.toStringInternal();
563 }
564 
565 void TDEAction::setShortcutText( const TQString& s )
566 {
567  setShortcut( TDEShortcut(s) );
568 }
569 
570 #ifndef KDE_NO_COMPAT // Remove in KDE 4
571 int TDEAction::accel() const
572 {
573  return d->m_cut.keyCodeQt();
574 }
575 #endif
576 
577 void TDEAction::setGroup( const TQString& grp )
578 {
579  d->m_group = grp;
580 
581  int len = containerCount();
582  for( int i = 0; i < len; ++i )
583  updateGroup( i );
584 }
585 
586 void TDEAction::updateGroup( int )
587 {
588  // DO SOMETHING
589 }
590 
591 TQString TDEAction::group() const
592 {
593  return d->m_group;
594 }
595 
596 bool TDEAction::isEnabled() const
597 {
598  return d->isEnabled();
599 }
600 
601 bool TDEAction::isShortcutConfigurable() const
602 {
603  return d->m_configurable;
604 }
605 
606 void TDEAction::setToolTip( const TQString& tt )
607 {
608  d->setToolTip( tt );
609 
610  int len = containerCount();
611  for( int i = 0; i < len; ++i )
612  updateToolTip( i );
613 }
614 
615 void TDEAction::updateToolTip( int i )
616 {
617  TQWidget *w = container( i );
618 
619  if ( ::tqqt_cast<TDEToolBar *>( w ) )
620  TQToolTip::add( static_cast<TDEToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
621 }
622 
623 TQString TDEAction::toolTip() const
624 {
625  return d->toolTip();
626 }
627 
628 int TDEAction::plug( TQWidget *w, int index )
629 {
630  //kdDebug(129) << "TDEAction::plug( " << w << ", " << index << " )" << endl;
631  if (!w ) {
632  kdWarning(129) << "TDEAction::plug called with 0 argument\n";
633  return -1;
634  }
635 
636  // Ellis: print warning if there is a shortcut, but no TDEAccel available (often due to no widget available in the actioncollection)
637  // David: Well, it doesn't matter much, things still work (e.g. Undo in koffice) via TQAccel.
638  // We should probably re-enable the warning for things that only TDEAccel can do, though - e.g. WIN key (mapped to Meta).
639 #if 0 //ndef NDEBUG
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; // ellis
643  }
644 #endif
645 
646  // Check if action is permitted
647  if (kapp && !kapp->authorizeTDEAction(name()))
648  return -1;
649 
650  plugShortcut();
651 
652  if ( ::tqqt_cast<TQPopupMenu *>( w ) )
653  {
654  TQPopupMenu* menu = static_cast<TQPopupMenu*>( w );
655  int id;
656  // Don't insert shortcut into menu if it's already in a TDEAccel object.
657  int keyQt = (d->m_tdeaccelList.count() || d->m_tdeaccel) ? 0 : d->m_cut.keyCodeQt();
658 
659  if ( d->hasIcon() )
660  {
661  TDEInstance *instance;
662  if ( m_parentCollection )
663  instance = m_parentCollection->instance();
664  else
665  instance = TDEGlobal::instance();
666  id = menu->insertItem( d->iconSet( TDEIcon::Small, 0, instance ), d->text(), this,//dsweet
667  TQT_SLOT( slotPopupActivated() ), keyQt,
668  -1, index );
669  }
670  else
671  id = menu->insertItem( d->text(), this,
672  TQT_SLOT( slotPopupActivated() ),
673  keyQt, -1, index );
674 
675  // If the shortcut is already in a TDEAccel object, then
676  // we need to set the menu item's shortcut text.
677  if ( d->m_tdeaccelList.count() || d->m_tdeaccel )
678  updateShortcut( menu, id );
679 
680  // call setItemEnabled only if the item really should be disabled,
681  // because that method is slow and the item is per default enabled
682  if ( !d->isEnabled() )
683  menu->setItemEnabled( id, false );
684 
685  if ( !d->whatsThis().isEmpty() )
686  menu->TQMenuData::setWhatsThis( id, whatsThisWithIcon() );
687 
688  addContainer( menu, id );
689  connect( menu, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( slotDestroyed() ) );
690 
691  if ( m_parentCollection )
692  m_parentCollection->connectHighlight( menu, this );
693 
694  return d->m_containers.count() - 1;
695  }
696  else if ( ::tqqt_cast<TDEToolBar *>( w ) )
697  {
698  TDEToolBar *bar = static_cast<TDEToolBar *>( w );
699 
700  int id_ = getToolButtonID();
701  TDEInstance *instance;
702  if ( m_parentCollection )
703  instance = m_parentCollection->instance();
704  else
705  instance = TDEGlobal::instance();
706 
707  if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using TQIconSet directly
708  {
709  bar->insertButton( iconSet().pixmap(), id_, TQT_SIGNAL( buttonClicked(int, TQt::ButtonState) ), this,
710  TQT_SLOT( slotButtonClicked(int, TQt::ButtonState) ),
711  d->isEnabled(), d->plainText(), index );
712  }
713  else
714  {
715  TQString icon = d->iconName();
716  if ( icon.isEmpty() )
717  icon = "unknown";
718  bar->insertButton( icon, id_, TQT_SIGNAL( buttonClicked(int, TQt::ButtonState) ), this,
719  TQT_SLOT( slotButtonClicked(int, TQt::ButtonState) ),
720  d->isEnabled(), d->plainText(), index, instance );
721  }
722 
723  TDEToolBarButton* ktb = bar->getButton(id_);
724  ktb->setName( TQCString("toolbutton_")+name() );
725 
726  if ( !d->whatsThis().isEmpty() )
727  TQWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() );
728 
729  if ( !d->toolTip().isEmpty() )
730  TQToolTip::add( bar->getButton(id_), d->toolTip() );
731 
732  addContainer( bar, id_ );
733 
734  connect( bar, TQT_SIGNAL( destroyed() ), this, TQT_SLOT( slotDestroyed() ) );
735 
736  if ( m_parentCollection )
737  m_parentCollection->connectHighlight( bar, this );
738 
739  return containerCount() - 1;
740  }
741 
742  return -1;
743 }
744 
745 void TDEAction::unplug( TQWidget *w )
746 {
747  int i = findContainer( w );
748  if ( i == -1 )
749  return;
750  int id = itemId( i );
751 
752  if ( ::tqqt_cast<TQPopupMenu *>( w ) )
753  {
754  TQPopupMenu *menu = static_cast<TQPopupMenu *>( w );
755  menu->removeItem( id );
756  }
757  else if ( ::tqqt_cast<TDEToolBar *>( w ) )
758  {
759  TDEToolBar *bar = static_cast<TDEToolBar *>( w );
760  bar->removeItemDelayed( id );
761  }
762  else if ( ::tqqt_cast<TQMenuBar *>( w ) )
763  {
764  TQMenuBar *bar = static_cast<TQMenuBar *>( w );
765  bar->removeItem( id );
766  }
767 
768  removeContainer( i );
769  if ( m_parentCollection )
770  m_parentCollection->disconnectHighlight( w, this );
771 }
772 
773 void TDEAction::plugAccel(TDEAccel *kacc, bool configurable)
774 {
775 #if 0 //ndef NDEBUG
776  kdWarning(129) << "TDEAction::plugAccel(): call to deprecated action." << endl;
777  kdDebug(129) << kdBacktrace() << endl;
778  //kdDebug(129) << "TDEAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl;
779 #endif
780  if ( d->m_tdeaccel )
781  unplugAccel();
782 
783  // If the parent collection's accel ptr isn't set yet
784  //if ( m_parentCollection && !m_parentCollection->accel() )
785  // m_parentCollection->setAccel( kacc );
786 
787  // We can only plug this action into the given TDEAccel object
788  // if it does not already contain an action with the same name.
789  if ( !kacc->actions().actionPtr(name()) )
790  {
791  d->m_tdeaccel = kacc;
792  d->m_tdeaccel->insert(name(), d->plainText(), TQString::null,
793  TDEShortcut(d->m_cut),
794  this, TQT_SLOT(slotActivated()),
795  configurable, isEnabled());
796  connect(d->m_tdeaccel, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotDestroyed()));
797  //connect(d->m_tdeaccel, TQT_SIGNAL(keycodeChanged()), this, TQT_SLOT(slotKeycodeChanged()));
798  }
799  else
800  {
801 #if 0 //ndef NDEBUG
802  kdWarning(129) << "TDEAction::plugAccel( kacc = " << kacc << " ): TDEAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis
803 #endif
804  }
805 }
806 
807 void TDEAction::unplugAccel()
808 {
809  //kdDebug(129) << "TDEAction::unplugAccel() " << this << " " << name() << endl;
810  if ( d->m_tdeaccel )
811  {
812  d->m_tdeaccel->remove(name());
813  d->m_tdeaccel = 0;
814  }
815 }
816 
817 void TDEAction::plugMainWindowAccel( TQWidget *w )
818 {
819  // Note: topLevelWidget() stops too early, we can't use it.
820  TQWidget * tl = w;
821  TQWidget * n;
822  while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store
823  tl = n;
824 
825  TDEMainWindow * mw = tqt_dynamic_cast<TDEMainWindow *>(tl); // try to see if it's a tdemainwindow
826  if (mw)
827  plugAccel( mw->accel() );
828  else
829  kdDebug(129) << "TDEAction::plugMainWindowAccel: Toplevel widget isn't a TDEMainWindow, can't plug accel. " << tl << endl;
830 }
831 
832 void TDEAction::setEnabled(bool enable)
833 {
834  //kdDebug(129) << "TDEAction::setEnabled( " << enable << " ): this = " << this << " d->m_tdeaccelList.count() = " << d->m_tdeaccelList.count() << endl;
835  if ( enable == d->isEnabled() )
836  return;
837 
838 #ifndef KDE_NO_COMPAT
839  // KDE 4: remove
840  if (d->m_tdeaccel)
841  d->m_tdeaccel->setEnabled(name(), enable);
842 #endif // KDE 4: remove end
843 
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();
847 
848  const char * const namePtr = name();
849 
850  for ( ; itr != itrEnd; ++itr )
851  (*itr)->setEnabled( namePtr, enable );
852 
853  d->setEnabled( enable );
854 
855  int len = containerCount();
856  for( int i = 0; i < len; ++i )
857  updateEnabled( i );
858 
859  emit enabled( d->isEnabled() );
860 }
861 
862 void TDEAction::updateEnabled( int i )
863 {
864  TQWidget *w = container( i );
865 
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<TDEToolBar *>( w ) )
871  static_cast<TDEToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
872 }
873 
874 void TDEAction::setShortcutConfigurable( bool b )
875 {
876  d->m_configurable = b;
877 }
878 
879 void TDEAction::setText( const TQString& text )
880 {
881 #ifndef KDE_NO_COMPAT
882  // KDE 4: remove
883  if (d->m_tdeaccel) {
884  TDEAccelAction* pAction = d->m_tdeaccel->actions().actionPtr(name());
885  if (pAction)
886  pAction->setLabel( text );
887  }
888 #endif // KDE 4: remove end
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();
892 
893  const char * const namePtr = name();
894 
895  for( ; itr != itrEnd; ++itr ) {
896  TDEAccelAction* const pAction = (*itr)->actions().actionPtr(namePtr);
897  if (pAction)
898  pAction->setLabel( text );
899  }
900 
901  d->setText( text );
902 
903  int len = containerCount();
904  for( int i = 0; i < len; ++i )
905  updateText( i );
906 }
907 
908 void TDEAction::updateText( int i )
909 {
910  TQWidget *w = container( i );
911 
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 );
917  }
918  else if ( ::tqqt_cast<TQMenuBar *>( w ) )
919  static_cast<TQMenuBar*>(w)->changeItem( itemId( i ), d->text() );
920  else if ( ::tqqt_cast<TDEToolBar *>( w ) )
921  {
922  TQWidget *button = static_cast<TDEToolBar *>(w)->getWidget( itemId( i ) );
923  if ( ::tqqt_cast<TDEToolBarButton *>( button ) )
924  static_cast<TDEToolBarButton *>(button)->setText( d->plainText() );
925  }
926 }
927 
928 TQString TDEAction::text() const
929 {
930  return d->text();
931 }
932 
933 TQString TDEAction::plainText() const
934 {
935  return d->plainText( );
936 }
937 
938 void TDEAction::setIcon( const TQString &icon )
939 {
940  d->setIconName( icon );
941 
942  // now handle any toolbars
943  int len = containerCount();
944  for ( int i = 0; i < len; ++i )
945  updateIcon( i );
946 }
947 
948 void TDEAction::updateIcon( int id )
949 {
950  TQWidget* w = container( id );
951 
952  if ( ::tqqt_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_ );
957  }
958  else if ( ::tqqt_cast<TQMenuBar *>( w ) )
959  static_cast<TQMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( TDEIcon::Small ), d->text() );
960  else if ( ::tqqt_cast<TDEToolBar *>( w ) )
961  static_cast<TDEToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() );
962 }
963 
964 TQString TDEAction::icon() const
965 {
966  return d->iconName( );
967 }
968 
969 void TDEAction::setIconSet( const TQIconSet &iconset )
970 {
971  d->setIconSet( iconset );
972 
973  int len = containerCount();
974  for( int i = 0; i < len; ++i )
975  updateIconSet( i );
976 }
977 
978 
979 void TDEAction::updateIconSet( int id )
980 {
981  TQWidget *w = container( id );
982 
983  if ( ::tqqt_cast<TQPopupMenu *>( w ) )
984  {
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_ );
989  }
990  else if ( ::tqqt_cast<TQMenuBar *>( w ) )
991  static_cast<TQMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() );
992  else if ( ::tqqt_cast<TDEToolBar *>( w ) )
993  {
994  if ( icon().isEmpty() && d->hasIcon() ) // only if there is no named icon ( scales better )
995  static_cast<TDEToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() );
996  else
997  static_cast<TDEToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( TDEIcon::Small ) );
998  }
999 }
1000 
1001 TQIconSet TDEAction::iconSet( TDEIcon::Group group, int size ) const
1002 {
1003  return d->iconSet( group, size );
1004 }
1005 
1006 bool TDEAction::hasIcon() const
1007 {
1008  return d->hasIcon();
1009 }
1010 
1011 void TDEAction::setWhatsThis( const TQString& text )
1012 {
1013  d->setWhatsThis( text );
1014 
1015  int len = containerCount();
1016  for( int i = 0; i < len; ++i )
1017  updateWhatsThis( i );
1018 }
1019 
1020 void TDEAction::updateWhatsThis( int i )
1021 {
1022  TQPopupMenu* pm = popupMenu( i );
1023  if ( pm )
1024  {
1025  pm->TQMenuData::setWhatsThis( itemId( i ), d->whatsThis() );
1026  return;
1027  }
1028 
1029  TDEToolBar *tb = toolBar( i );
1030  if ( tb )
1031  {
1032  TQWidget *w = tb->getButton( itemId( i ) );
1033  TQWhatsThis::remove( w );
1034  TQWhatsThis::add( w, d->whatsThis() );
1035  return;
1036  }
1037 }
1038 
1039 TQString TDEAction::whatsThis() const
1040 {
1041  return d->whatsThis();
1042 }
1043 
1044 TQString TDEAction::whatsThisWithIcon() const
1045 {
1046  TQString text = whatsThis();
1047  if (!d->iconName().isEmpty())
1048  return TQString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text);
1049  return text;
1050 }
1051 
1052 TQWidget* TDEAction::container( int index ) const
1053 {
1054  assert( index < containerCount() );
1055  return d->m_containers[ index ].m_container;
1056 }
1057 
1058 TDEToolBar* TDEAction::toolBar( int index ) const
1059 {
1060  return tqt_dynamic_cast<TDEToolBar *>( d->m_containers[ index ].m_container );
1061 }
1062 
1063 TQPopupMenu* TDEAction::popupMenu( int index ) const
1064 {
1065  return tqt_dynamic_cast<TQPopupMenu *>( d->m_containers[ index ].m_container );
1066 }
1067 
1068 TQWidget* TDEAction::representative( int index ) const
1069 {
1070  return d->m_containers[ index ].m_representative;
1071 }
1072 
1073 int TDEAction::itemId( int index ) const
1074 {
1075  return d->m_containers[ index ].m_id;
1076 }
1077 
1078 int TDEAction::containerCount() const
1079 {
1080  return d->m_containers.count();
1081 }
1082 
1083 uint TDEAction::tdeaccelCount() const
1084 {
1085  return d->m_tdeaccelList.count();
1086 }
1087 
1088 void TDEAction::addContainer( TQWidget* c, int id )
1089 {
1090  TDEActionPrivate::Container p;
1091  p.m_container = c;
1092  p.m_id = id;
1093  d->m_containers.append( p );
1094 }
1095 
1096 void TDEAction::addContainer( TQWidget* c, TQWidget* w )
1097 {
1098  TDEActionPrivate::Container p;
1099  p.m_container = c;
1100  p.m_representative = w;
1101  d->m_containers.append( p );
1102 }
1103 
1104 void TDEAction::activate()
1105 {
1106  emit activated( TDEAction::EmulatedActivation, Qt::NoButton );
1107  slotActivated();
1108 }
1109 
1110 void TDEAction::slotActivated()
1111 {
1112  const TQObject *senderObj = TQT_TQOBJECT_CONST(sender());
1113  if ( senderObj )
1114  {
1115  if ( ::tqqt_cast<TDEAccelPrivate *>( senderObj ) )
1116  emit activated( TDEAction::AccelActivation, Qt::NoButton );
1117  }
1118  emit activated();
1119 }
1120 
1121 // This catches signals emitted by TDEActions inserted into QPopupMenu
1122 // We do crude things inside it, because we need to know which
1123 // TQPopupMenu emitted the signal. We need to be sure that it is
1124 // only called by QPopupMenus, we plugged us in.
1125 void TDEAction::slotPopupActivated()
1126 {
1127  if( ::tqqt_cast<TQSignal *>(sender()))
1128  {
1129  int id = tqt_dynamic_cast<const TQSignal *>(sender())->value().toInt();
1130  int pos = findContainer(id);
1131  if(pos != -1)
1132  {
1133  TQPopupMenu* qpm = tqt_dynamic_cast<TQPopupMenu *>( container(pos) );
1134  if(qpm)
1135  {
1136  TDEPopupMenu* kpm = tqt_dynamic_cast<TDEPopupMenu *>( qpm );
1137  TQt::ButtonState state;
1138  if ( kpm ) // TDEPopupMenu? Nice, it stores the state.
1139  state = kpm->state();
1140  else { // just a QPopupMenu? We'll ask for the state now then (small race condition?)
1141  kdDebug(129) << "TDEAction::slotPopupActivated not a TDEPopupMenu -> using keyboardMouseState()" << endl;
1142  state = TDEApplication::keyboardMouseState();
1143  }
1144  emit activated( TDEAction::PopupMenuActivation, state );
1145  slotActivated();
1146  return;
1147  }
1148  }
1149  }
1150 
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, Qt::NoButton );
1153  slotActivated();
1154 }
1155 
1156 void TDEAction::slotButtonClicked( int, TQt::ButtonState state )
1157 {
1158  kdDebug(129) << "slotButtonClicked() state=" << state << endl;
1159  emit activated( TDEAction::ToolBarActivation, state );
1160 
1161  // RightButton isn't really an activation
1162  if ( ( state & Qt::LeftButton ) || ( state & Qt::MidButton ) )
1163  slotActivated();
1164 }
1165 
1166 
1167 void TDEAction::slotDestroyed()
1168 {
1169  kdDebug(129) << "TDEAction::slotDestroyed(): this = " << this << ", name = \"" << name() << "\", sender = " << sender() << endl;
1170  const TQObject* const o = TQT_TQOBJECT_CONST(sender());
1171 
1172 #ifndef KDE_NO_COMPAT // KDE 4: remove
1173  if ( o == d->m_tdeaccel )
1174  {
1175  d->m_tdeaccel = 0;
1176  return;
1177  }
1178 #endif // KDE 4: remove end
1179  TQValueList<TDEAccel*> & accelList = d->m_tdeaccelList;
1180  TQValueList<TDEAccel*>::iterator itr = accelList.begin();
1181  const TQValueList<TDEAccel*>::iterator itrEnd = accelList.end();
1182 
1183  for( ; itr != itrEnd; ++itr)
1184  {
1185  if ( o == *itr )
1186  {
1187  disconnect( *itr, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotDestroyed()) );
1188  accelList.remove(itr);
1189  return;
1190  }
1191  }
1192 
1193  int i;
1194  do
1195  {
1196  i = findContainer( TQT_TQWIDGET_CONST( static_cast<const QObject*>(o) ) );
1197  if ( i != -1 )
1198  removeContainer( i );
1199  } while ( i != -1 );
1200 }
1201 
1202 int TDEAction::findContainer( const TQWidget* widget ) const
1203 {
1204  int pos = 0;
1205 
1206  const TQValueList<TDEActionPrivate::Container> & containers = d->m_containers;
1207 
1208  TQValueList<TDEActionPrivate::Container>::ConstIterator it = containers.constBegin();
1209  const TQValueList<TDEActionPrivate::Container>::ConstIterator itEnd = containers.constEnd();
1210 
1211  while( it != itEnd )
1212  {
1213  if ( (*it).m_representative == widget || (*it).m_container == widget )
1214  return pos;
1215  ++it;
1216  ++pos;
1217  }
1218 
1219  return -1;
1220 }
1221 
1222 int TDEAction::findContainer( const int id ) const
1223 {
1224  int pos = 0;
1225 
1226  const TQValueList<TDEActionPrivate::Container> & containers = d->m_containers;
1227 
1228  TQValueList<TDEActionPrivate::Container>::ConstIterator it = containers.constBegin();
1229  const TQValueList<TDEActionPrivate::Container>::ConstIterator itEnd = containers.constEnd();
1230 
1231  while( it != itEnd )
1232  {
1233  if ( (*it).m_id == id )
1234  return pos;
1235  ++it;
1236  ++pos;
1237  }
1238 
1239  return -1;
1240 }
1241 
1242 void TDEAction::removeContainer( int index )
1243 {
1244  int i = 0;
1245 
1246  TQValueList<TDEActionPrivate::Container> & containers = d->m_containers;
1247 
1248  TQValueList<TDEActionPrivate::Container>::Iterator it = containers.begin();
1249  const TQValueList<TDEActionPrivate::Container>::Iterator itEnd = containers.end();
1250 
1251  while( it != itEnd )
1252  {
1253  if ( i == index )
1254  {
1255  containers.remove( it );
1256  return;
1257  }
1258  ++it;
1259  ++i;
1260  }
1261 }
1262 
1263 // FIXME: Remove this (ellis)
1264 void TDEAction::slotKeycodeChanged()
1265 {
1266  kdDebug(129) << "TDEAction::slotKeycodeChanged()" << endl; // -- ellis
1267  TDEAccelAction* pAction = d->m_tdeaccel->actions().actionPtr(name());
1268  if( pAction )
1269  setShortcut(pAction->shortcut());
1270 }
1271 
1272 TDEActionCollection *TDEAction::parentCollection() const
1273 {
1274  return m_parentCollection;
1275 }
1276 
1277 void TDEAction::unplugAll()
1278 {
1279  while ( containerCount() != 0 )
1280  unplug( container( 0 ) );
1281 }
1282 
1283 const KGuiItem& TDEAction::guiItem() const
1284 {
1285  return *d;
1286 }
1287 
1288 void TDEAction::virtual_hook( int, void* )
1289 { /*BASE::virtual_hook( id, data );*/ }
1290 
1291 #include "tdeaction.moc"
kdBacktrace
TQString kdBacktrace(int levels=-1)
TDEActionCollection::insert
void insert(TDEAction *action)
Add an action to the collection.
Definition: tdeactioncollection.cpp:365
TDEToolBar::removeItemDelayed
void removeItemDelayed(int id)
Remove item id.
Definition: tdetoolbar.cpp:696
TDEAction::slotButtonClicked
void slotButtonClicked(int, TQt::ButtonState state)
Definition: tdeaction.cpp:1156
TDEAction::getToolButtonID
static int getToolButtonID()
How it works.
Definition: tdeaction.cpp:76
TDEAction::setWhatsThis
virtual void setWhatsThis(const TQString &text)
Sets the What's this text for the action.
Definition: tdeaction.cpp:1011
KGuiItem::hasIcon
bool hasIcon() const
returns whether an icon is defined, doesn't tell if it really exists
Definition: kguiitem.cpp:192
TDEActionCollection::builderTDEAccel
TDEAccel * builderTDEAccel() const
Definition: tdeactioncollection.cpp:371
TDEAccel::setShortcut
bool setShortcut(const TQString &sAction, const TDEShortcut &shortcut)
TDEToolBar::insertButton
int insertButton(const TQString &icon, int id, bool enabled=true, const TQString &text=TQString::null, int index=-1, TDEInstance *_instance=TDEGlobal::instance())
Insert a button (a TDEToolBarButton) with a pixmap.
Definition: tdetoolbar.cpp:259
TDEToolBar::setText
void setText(const TQString &txt)
Assign a (translated) text to this toolbar.
Definition: tdetoolbar.cpp:1134
TDEAction::tdeaccelCount
uint tdeaccelCount() const
Definition: tdeaction.cpp:1083
TDEAction::setAccel
void setAccel(int key) KDE_DEPRECATED
Definition: tdeaction.cpp:507
TDEToolBarButton
A toolbar button.
Definition: tdetoolbarbutton.h:44
TDEAction::activated
void activated()
Emitted when this action is activated.
TDEAction::plugAccel
virtual void plugAccel(TDEAccel *accel, bool configurable=true) KDE_DEPRECATED
Definition: tdeaction.cpp:773
TDEAction::accel
int accel() const KDE_DEPRECATED
Definition: tdeaction.cpp:571
TDEShortcut::isNull
bool isNull() const
kdDebug
kdbgstream kdDebug(int area=0)
TDEActionCollection::connectHighlight
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...
Definition: tdeactioncollection.cpp:493
TDEActionCollection
A managed set of TDEAction objects.
Definition: tdeactioncollection.h:78
TDEAccel::insert
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)
TDEAction::slotPopupActivated
void slotPopupActivated()
Definition: tdeaction.cpp:1125
TDEAccel
TDEAction::isPlugged
virtual bool isPlugged() const
returns whether the action is plugged into any container widget or not.
Definition: tdeaction.cpp:273
TDEMainWindow
KDE top level main window
Definition: tdemainwindow.h:98
TDEToolBar
Floatable toolbar with auto resize.
Definition: tdetoolbar.h:104
TDEToolBar::getButton
TDEToolBarButton * getButton(int id)
Returns a pointer to TDEToolBarButton.
Definition: tdetoolbar.cpp:631
KGuiItem
An abstract class for GUI data such as ToolTip and Icon.
Definition: kguiitem.h:38
TDEGlobal::instance
static TDEInstance * instance()
TDEActionCollection::take
TDEAction * take(TDEAction *action)
Removes an action from the collection.
Definition: tdeactioncollection.cpp:367
TDEAction::setToolTip
virtual void setToolTip(const TQString &)
Sets the tooltip text for the action.
Definition: tdeaction.cpp:606
kdWarning
kdbgstream kdWarning(int area=0)
TDEAction::setShortcut
virtual bool setShortcut(const TDEShortcut &)
Sets the keyboard shortcut associated with this action.
Definition: tdeaction.cpp:414
TDEAction::TDEAction
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 TQT_SLOT to call when this action ...
Definition: tdeaction.cpp:123
TDEAction::setText
virtual void setText(const TQString &text)
Sets the text associated with this action.
Definition: tdeaction.cpp:879
TDEAction::text
virtual TQString text() const
Get the text associated with this action.
Definition: tdeaction.cpp:928
TDEIcon::Small
TDEMainWindow::accel
TDEAccel * accel()
Definition: tdemainwindow.cpp:1190
TDEAction::guiItem
const KGuiItem & guiItem() const
Return the underlying KGuiItem.
Definition: tdeaction.cpp:1283
TDEAction::setShortcutConfigurable
virtual void setShortcutConfigurable(bool)
Indicate whether the user may configure the action's shortcut.
Definition: tdeaction.cpp:874
TDEAction::activate
virtual void activate()
Emulate user's interaction programmatically, by activating the action.
Definition: tdeaction.cpp:1104
TDEAction::unplug
virtual void unplug(TQWidget *w)
"Unplug" or remove this action from a given widget.
Definition: tdeaction.cpp:745
TDEAction::setEnabled
virtual void setEnabled(bool enable)
Enables or disables this action.
Definition: tdeaction.cpp:832
TDEActionCollection::instance
TDEInstance * instance() const
The instance with which this class is associated.
Definition: tdeactioncollection.cpp:468
TDEAction::toolTip
virtual TQString toolTip() const
Get the tooltip text for the action.
Definition: tdeaction.cpp:623
TDEAction::iconSet
TQIconSet iconSet() const
Remove in KDE4.
Definition: tdeaction.h:476
TDEShortcut
TDEIcon::Group
Group
TDEActionCollection::tdeaccel
TDEAccel * tdeaccel()
Returns the TDEAccel object of the most recently set widget.
Definition: tdeactioncollection.cpp:282
TDEAction::shortcut
virtual const TDEShortcut & shortcut() const
Get the keyboard shortcut associated with this action.
Definition: tdeaction.cpp:550
TDEAccel::remove
bool remove(const TQString &sAction)
TDEAction::shortcutDefault
virtual const TDEShortcut & shortcutDefault() const
Get the default shortcut for this action.
Definition: tdeaction.cpp:555
TDEActionCollection::disconnectHighlight
void disconnectHighlight(TQWidget *container, TDEAction *action)
Disconnect highlight notifications for a particular pair of contianer and action. ...
Definition: tdeactioncollection.cpp:526
TDEAction::setIconSet
virtual void setIconSet(const TQIconSet &iconSet)
Sets the TQIconSet from which the icons used to display this action will be chosen.
Definition: tdeaction.cpp:969
TDEPopupMenu
A menu with title items.
Definition: tdepopupmenu.h:123
TDEAction::isEnabled
virtual bool isEnabled() const
Returns true if this action is enabled.
Definition: tdeaction.cpp:596
TDEPopupMenu::state
TQt::ButtonState state() const
Return the state of the mouse button and keyboard modifiers when the last menuitem was activated...
Definition: tdepopupmenu.cpp:285
TDEActionCollection::isAutoConnectShortcuts
bool isAutoConnectShortcuts()
This indicates whether new actions which are created in this collection have their keyboard shortcuts...
Definition: tdeactioncollection.cpp:172
TDEAction::unplugAccel
virtual void unplugAccel() KDE_DEPRECATED
Definition: tdeaction.cpp:807
endl
kndbgstream & endl(kndbgstream &s)
TDEAction::~TDEAction
virtual ~TDEAction()
Standard destructor.
Definition: tdeaction.cpp:222
TDEAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeaction.cpp:628
TDEStdAccel::name
TQString name(StdAccel id)
TDEInstance
TDEAction::isShortcutConfigurable
virtual bool isShortcutConfigurable() const
Returns true if this action's shortcut is configurable.
Definition: tdeaction.cpp:601
TDEAction::whatsThis
virtual TQString whatsThis() const
Get the What's this text for the action.
Definition: tdeaction.cpp:1039

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.