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

tdeui

  • tdeui
tdeactionclasses.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  (C) 2003 Andras Mantia <amantia@kde.org>
11 
12  This library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU Library General Public
14  License version 2 as published by the Free Software Foundation.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Library General Public License for more details.
20 
21  You should have received a copy of the GNU Library General Public License
22  along with this library; see the file COPYING.LIB. If not, write to
23  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  Boston, MA 02110-1301, USA.
25 */
26 
27 #include "tdeactionclasses.h"
28 
29 #include <assert.h>
30 #include <ft2build.h>
31 #include <fontconfig/fontconfig.h>
32 
33 #include <tqcursor.h>
34 #include <tqclipboard.h>
35 #include <tqfontdatabase.h>
36 #include <tqobjectlist.h>
37 #include <tqwhatsthis.h>
38 #include <tqtimer.h>
39 #include <tqfile.h>
40 #include <tqregexp.h>
41 
42 #include <dcopclient.h>
43 #include <dcopref.h>
44 #include <tdeaccel.h>
45 #include <tdeapplication.h>
46 #include <tdeconfig.h>
47 #include <kdebug.h>
48 #include <tdefontcombo.h>
49 #include <tdefontdialog.h>
50 #include <tdelocale.h>
51 #include <tdemainwindow.h>
52 #include <tdemenubar.h>
53 #include <tdepopupmenu.h>
54 #include <tdetoolbar.h>
55 #include <tdetoolbarbutton.h>
56 #include <kurl.h>
57 #include <kstandarddirs.h>
58 #include <kstringhandler.h>
59 
60 class TDEToggleAction::TDEToggleActionPrivate
61 {
62 public:
63  TDEToggleActionPrivate()
64  {
65  m_checked = false;
66  m_checkedGuiItem = 0;
67  }
68 
69  bool m_checked;
70  TQString m_exclusiveGroup;
71  KGuiItem* m_checkedGuiItem;
72 };
73 
74 TDEToggleAction::TDEToggleAction( const TQString& text, const TDEShortcut& cut,
75  TQObject* parent,
76  const char* name )
77  : TDEAction( text, cut, parent, name )
78 {
79  d = new TDEToggleActionPrivate;
80 }
81 
82 TDEToggleAction::TDEToggleAction( const TQString& text, const TDEShortcut& cut,
83  const TQObject* receiver, const char* slot,
84  TQObject* parent, const char* name )
85  : TDEAction( text, cut, receiver, slot, parent, name )
86 {
87  d = new TDEToggleActionPrivate;
88 }
89 
90 TDEToggleAction::TDEToggleAction( const TQString& text, const TQIconSet& pix,
91  const TDEShortcut& cut,
92  TQObject* parent, const char* name )
93  : TDEAction( text, pix, cut, parent, name )
94 {
95  d = new TDEToggleActionPrivate;
96 }
97 
98 TDEToggleAction::TDEToggleAction( const TQString& text, const TQString& pix,
99  const TDEShortcut& cut,
100  TQObject* parent, const char* name )
101  : TDEAction( text, pix, cut, parent, name )
102 {
103  d = new TDEToggleActionPrivate;
104 }
105 
106 TDEToggleAction::TDEToggleAction( const TQString& text, const TQIconSet& pix,
107  const TDEShortcut& cut,
108  const TQObject* receiver,
109  const char* slot, TQObject* parent,
110  const char* name )
111  : TDEAction( text, pix, cut, receiver, slot, parent, name )
112 {
113  d = new TDEToggleActionPrivate;
114 }
115 
116 TDEToggleAction::TDEToggleAction( const TQString& text, const TQString& pix,
117  const TDEShortcut& cut,
118  const TQObject* receiver,
119  const char* slot, TQObject* parent,
120  const char* name )
121  : TDEAction( text, pix, cut, receiver, slot, parent, name )
122 {
123  d = new TDEToggleActionPrivate;
124 }
125 
126 TDEToggleAction::TDEToggleAction( TQObject* parent, const char* name )
127  : TDEAction( parent, name )
128 {
129  d = new TDEToggleActionPrivate;
130 }
131 
132 TDEToggleAction::~TDEToggleAction()
133 {
134  delete d->m_checkedGuiItem;
135  delete d;
136 }
137 
138 int TDEToggleAction::plug( TQWidget* widget, int index )
139 {
140  if ( !::tqt_cast<TQPopupMenu *>( widget ) && !::tqt_cast<TDEToolBar *>( widget ) )
141  {
142  kdWarning() << "Can not plug TDEToggleAction in " << widget->className() << endl;
143  return -1;
144  }
145  if (kapp && !kapp->authorizeTDEAction(name()))
146  return -1;
147 
148  int _index = TDEAction::plug( widget, index );
149  if ( _index == -1 )
150  return _index;
151 
152  if ( ::tqt_cast<TDEToolBar *>( widget ) ) {
153  TDEToolBar *bar = static_cast<TDEToolBar *>( widget );
154 
155  bar->setToggle( itemId( _index ), true );
156  bar->setButton( itemId( _index ), isChecked() );
157  }
158 
159  if ( d->m_checked )
160  updateChecked( _index );
161 
162  return _index;
163 }
164 
165 void TDEToggleAction::setChecked( bool c )
166 {
167  if ( c == d->m_checked )
168  return;
169  //kdDebug(129) << "TDEToggleAction::setChecked(" << c << ") " << this << " " << name() << endl;
170 
171  d->m_checked = c;
172 
173  int len = containerCount();
174 
175  for( int i = 0; i < len; ++i )
176  updateChecked( i );
177 
178  if ( c && parent() && !exclusiveGroup().isEmpty() ) {
179  const TQObjectList list = parent()->childrenListObject();
180  if ( !list.isEmpty() ) {
181  TQObjectListIt it( list );
182  for( ; it.current(); ++it ) {
183  if ( ::tqt_cast<TDEToggleAction *>( it.current() ) && it.current() != this &&
184  static_cast<TDEToggleAction*>(it.current())->exclusiveGroup() == exclusiveGroup() ) {
185  TDEToggleAction *a = static_cast<TDEToggleAction*>(it.current());
186  if( a->isChecked() ) {
187  a->setChecked( false );
188  emit a->toggled( false );
189  }
190  }
191  }
192  }
193  }
194 }
195 
196 void TDEToggleAction::updateChecked( int id )
197 {
198  TQWidget *w = container( id );
199 
200  if ( ::tqt_cast<TQPopupMenu *>( w ) ) {
201  TQPopupMenu* pm = static_cast<TQPopupMenu*>(w);
202  int itemId_ = itemId( id );
203  if ( !d->m_checkedGuiItem )
204  pm->setItemChecked( itemId_, d->m_checked );
205  else {
206  const KGuiItem* gui = d->m_checked ? d->m_checkedGuiItem : &guiItem();
207  if ( d->m_checkedGuiItem->hasIcon() )
208  pm->changeItem( itemId_, gui->iconSet( TDEIcon::Small ), gui->text() );
209  else
210  pm->changeItem( itemId_, gui->text() );
211 
212  // If the text doesn't change, then set the icon to be "pressed", otherwise
213  // there is too little difference between checked and unchecked.
214  if ( d->m_checkedGuiItem->text() == guiItem().text() )
215  pm->setItemChecked( itemId_, d->m_checked );
216 
217  if ( !d->m_checkedGuiItem->whatsThis().isEmpty() ) // if empty, we keep the initial one
218  pm->TQMenuData::setWhatsThis( itemId_, gui->whatsThis() );
219  updateShortcut( pm, itemId_ );
220  }
221  }
222  else if ( ::tqt_cast<TQMenuBar *>( w ) ) // not handled in plug...
223  static_cast<TQMenuBar*>(w)->setItemChecked( itemId( id ), d->m_checked );
224  else if ( ::tqt_cast<TDEToolBar *>( w ) )
225  {
226  TQWidget* r = static_cast<TDEToolBar*>( w )->getButton( itemId( id ) );
227  if ( r && ::tqt_cast<TDEToolBarButton *>( r ) ) {
228  static_cast<TDEToolBar*>( w )->setButton( itemId( id ), d->m_checked );
229  if ( d->m_checkedGuiItem && d->m_checkedGuiItem->hasIcon() ) {
230  const KGuiItem* gui = d->m_checked ? d->m_checkedGuiItem : &guiItem();
231  static_cast<TDEToolBar*>( w )->setButtonIconSet( itemId( id ), gui->iconSet( TDEIcon::Toolbar ) );
232  }
233  }
234  }
235 }
236 
237 void TDEToggleAction::slotActivated()
238 {
239  setChecked( !isChecked() );
240  TDEAction::slotActivated();
241  emit toggled( isChecked() );
242 }
243 
244 bool TDEToggleAction::isChecked() const
245 {
246  return d->m_checked;
247 }
248 
249 void TDEToggleAction::setExclusiveGroup( const TQString& name )
250 {
251  d->m_exclusiveGroup = name;
252 }
253 
254 TQString TDEToggleAction::exclusiveGroup() const
255 {
256  return d->m_exclusiveGroup;
257 }
258 
259 void TDEToggleAction::setCheckedState( const KGuiItem& checkedItem )
260 {
261  delete d->m_checkedGuiItem;
262  d->m_checkedGuiItem = new KGuiItem( checkedItem );
263 }
264 
265 TQString TDEToggleAction::toolTip() const
266 {
267  if ( d->m_checkedGuiItem && d->m_checked )
268  return d->m_checkedGuiItem->toolTip();
269  else
270  return TDEAction::toolTip();
271 }
272 
273 TDERadioAction::TDERadioAction( const TQString& text, const TDEShortcut& cut,
274  TQObject* parent, const char* name )
275 : TDEToggleAction( text, cut, parent, name )
276 {
277 }
278 
279 TDERadioAction::TDERadioAction( const TQString& text, const TDEShortcut& cut,
280  const TQObject* receiver, const char* slot,
281  TQObject* parent, const char* name )
282 : TDEToggleAction( text, cut, receiver, slot, parent, name )
283 {
284 }
285 
286 TDERadioAction::TDERadioAction( const TQString& text, const TQIconSet& pix,
287  const TDEShortcut& cut,
288  TQObject* parent, const char* name )
289 : TDEToggleAction( text, pix, cut, parent, name )
290 {
291 }
292 
293 TDERadioAction::TDERadioAction( const TQString& text, const TQString& pix,
294  const TDEShortcut& cut,
295  TQObject* parent, const char* name )
296 : TDEToggleAction( text, pix, cut, parent, name )
297 {
298 }
299 
300 TDERadioAction::TDERadioAction( const TQString& text, const TQIconSet& pix,
301  const TDEShortcut& cut,
302  const TQObject* receiver, const char* slot,
303  TQObject* parent, const char* name )
304 : TDEToggleAction( text, pix, cut, receiver, slot, parent, name )
305 {
306 }
307 
308 TDERadioAction::TDERadioAction( const TQString& text, const TQString& pix,
309  const TDEShortcut& cut,
310  const TQObject* receiver, const char* slot,
311  TQObject* parent, const char* name )
312 : TDEToggleAction( text, pix, cut, receiver, slot, parent, name )
313 {
314 }
315 
316 TDERadioAction::TDERadioAction( TQObject* parent, const char* name )
317 : TDEToggleAction( parent, name )
318 {
319 }
320 
321 void TDERadioAction::slotActivated()
322 {
323  if ( isChecked() )
324  {
325  const TQObject *senderObj = sender();
326 
327  if ( !senderObj || !::tqt_cast<const TDEToolBarButton *>( senderObj ) )
328  return;
329 
330  const_cast<TDEToolBarButton *>( static_cast<const TDEToolBarButton *>( senderObj ) )->on( true );
331 
332  return;
333  }
334 
335  TDEToggleAction::slotActivated();
336 }
337 
338 class TDESelectAction::TDESelectActionPrivate
339 {
340 public:
341  TDESelectActionPrivate()
342  {
343  m_edit = false;
344  m_menuAccelsEnabled = true;
345  m_menu = 0;
346  m_current = -1;
347  m_comboWidth = -1;
348  m_maxComboViewCount = -1;
349  }
350  bool m_edit;
351  bool m_menuAccelsEnabled;
352  TQPopupMenu *m_menu;
353  int m_current;
354  int m_comboWidth;
355  TQStringList m_list;
356  int m_maxComboViewCount;
357 
358  TQString makeMenuText( const TQString &_text )
359  {
360  if ( m_menuAccelsEnabled )
361  return _text;
362  TQString text = _text;
363  uint i = 0;
364  while ( i < text.length() ) {
365  if ( text[ i ] == '&' ) {
366  text.insert( i, '&' );
367  i += 2;
368  }
369  else
370  ++i;
371  }
372  return text;
373  }
374 };
375 
376 TDESelectAction::TDESelectAction( const TQString& text, const TDEShortcut& cut,
377  TQObject* parent, const char* name )
378  : TDEAction( text, cut, parent, name )
379 {
380  d = new TDESelectActionPrivate;
381 }
382 
383 TDESelectAction::TDESelectAction( const TQString& text, const TDEShortcut& cut,
384  const TQObject* receiver, const char* slot,
385  TQObject* parent, const char* name )
386  : TDEAction( text, cut, receiver, slot, parent, name )
387 {
388  d = new TDESelectActionPrivate;
389 }
390 
391 TDESelectAction::TDESelectAction( const TQString& text, const TQIconSet& pix,
392  const TDEShortcut& cut,
393  TQObject* parent, const char* name )
394  : TDEAction( text, pix, cut, parent, name )
395 {
396  d = new TDESelectActionPrivate;
397 }
398 
399 TDESelectAction::TDESelectAction( const TQString& text, const TQString& pix,
400  const TDEShortcut& cut,
401  TQObject* parent, const char* name )
402  : TDEAction( text, pix, cut, parent, name )
403 {
404  d = new TDESelectActionPrivate;
405 }
406 
407 TDESelectAction::TDESelectAction( const TQString& text, const TQIconSet& pix,
408  const TDEShortcut& cut,
409  const TQObject* receiver,
410  const char* slot, TQObject* parent,
411  const char* name )
412  : TDEAction( text, pix, cut, receiver, slot, parent, name )
413 {
414  d = new TDESelectActionPrivate;
415 }
416 
417 TDESelectAction::TDESelectAction( const TQString& text, const TQString& pix,
418  const TDEShortcut& cut,
419  const TQObject* receiver,
420  const char* slot, TQObject* parent,
421  const char* name )
422  : TDEAction( text, pix, cut, receiver, slot, parent, name )
423 {
424  d = new TDESelectActionPrivate;
425 }
426 
427 TDESelectAction::TDESelectAction( TQObject* parent, const char* name )
428  : TDEAction( parent, name )
429 {
430  d = new TDESelectActionPrivate;
431 }
432 
433 TDESelectAction::~TDESelectAction()
434 {
435  assert(d);
436  delete d->m_menu;
437  delete d; d = 0;
438 }
439 
440 void TDESelectAction::setCurrentItem( int id )
441 {
442  if ( id >= (int)d->m_list.count() ) {
443  Q_ASSERT(id < (int)d->m_list.count());
444  return;
445  }
446 
447  if ( d->m_menu )
448  {
449  if ( d->m_current >= 0 )
450  d->m_menu->setItemChecked( d->m_current, false );
451  if ( id >= 0 )
452  d->m_menu->setItemChecked( id, true );
453  }
454 
455  d->m_current = id;
456 
457  int len = containerCount();
458 
459  for( int i = 0; i < len; ++i )
460  updateCurrentItem( i );
461 
462  // emit TDEAction::activated();
463  // emit activated( currentItem() );
464  // emit activated( currentText() );
465 }
466 
467 void TDESelectAction::setComboWidth( int width )
468 {
469  if ( width < 0 )
470  return;
471 
472  d->m_comboWidth=width;
473 
474  int len = containerCount();
475 
476  for( int i = 0; i < len; ++i )
477  updateComboWidth( i );
478 
479 }
480 
481 void TDESelectAction::setMaxComboViewCount( int n )
482 {
483  d->m_maxComboViewCount = n;
484 }
485 
486 TQPopupMenu* TDESelectAction::popupMenu() const
487 {
488  kdDebug(129) << "TDEAction::popupMenu()" << endl; // remove -- ellis
489  if ( !d->m_menu )
490  {
491  d->m_menu = new TDEPopupMenu(0L, "TDESelectAction::popupMenu()");
492  setupMenu();
493  if ( d->m_current >= 0 )
494  d->m_menu->setItemChecked( d->m_current, true );
495  }
496 
497  return d->m_menu;
498 }
499 
500 void TDESelectAction::setupMenu() const
501 {
502  if ( !d->m_menu )
503  return;
504  d->m_menu->clear();
505 
506  TQStringList::ConstIterator it = d->m_list.begin();
507  for( uint id = 0; it != d->m_list.end(); ++it, ++id ) {
508  TQString text = *it;
509  if ( !text.isEmpty() )
510  d->m_menu->insertItem( d->makeMenuText( text ), this, TQ_SLOT( slotActivated( int ) ), 0, id );
511  else
512  d->m_menu->insertSeparator();
513  }
514 }
515 
516 void TDESelectAction::changeItem( int index, const TQString& text )
517 {
518  if ( index < 0 || index >= (int)d->m_list.count() )
519  {
520  kdWarning() << "TDESelectAction::changeItem Index out of scope" << endl;
521  return;
522  }
523 
524  d->m_list[ index ] = text;
525 
526  if ( d->m_menu )
527  d->m_menu->changeItem( index, d->makeMenuText( text ) );
528 
529  int len = containerCount();
530  for( int i = 0; i < len; ++i )
531  changeItem( i, index, text );
532 }
533 
534 void TDESelectAction::changeItem( int id, int index, const TQString& text)
535 {
536  if ( index < 0 )
537  return;
538 
539  TQWidget* w = container( id );
540  if ( ::tqt_cast<TDEToolBar *>( w ) )
541  {
542  TQWidget* r = (static_cast<TDEToolBar*>( w ))->getWidget( itemId( id ) );
543  if ( ::tqt_cast<TQComboBox *>( r ) )
544  {
545  TQComboBox *b = static_cast<TQComboBox*>( r );
546  b->changeItem(text, index );
547  }
548  }
549 }
550 
551 void TDESelectAction::setItems( const TQStringList &lst )
552 {
553  d->m_list = lst;
554  d->m_current = -1;
555 
556  setupMenu();
557 
558  int len = containerCount();
559  for( int i = 0; i < len; ++i )
560  updateItems( i );
561 
562  // Disable if empty and not editable
563  setEnabled ( lst.count() > 0 || d->m_edit );
564 }
565 
566 TQStringList TDESelectAction::items() const
567 {
568  return d->m_list;
569 }
570 
571 TQString TDESelectAction::currentText() const
572 {
573  if ( currentItem() < 0 )
574  return TQString::null;
575 
576  return d->m_list[ currentItem() ];
577 }
578 
579 int TDESelectAction::currentItem() const
580 {
581  return d->m_current;
582 }
583 
584 void TDESelectAction::updateCurrentItem( int id )
585 {
586  if ( d->m_current < 0 )
587  return;
588 
589  TQWidget* w = container( id );
590  if ( ::tqt_cast<TDEToolBar *>( w ) ) {
591  TQWidget* r = static_cast<TDEToolBar*>( w )->getWidget( itemId( id ) );
592  if ( ::tqt_cast<TQComboBox *>( r ) ) {
593  TQComboBox *b = static_cast<TQComboBox*>( r );
594  b->setCurrentItem( d->m_current );
595  }
596  }
597 }
598 
599 int TDESelectAction::comboWidth() const
600 {
601  return d->m_comboWidth;
602 }
603 
604 void TDESelectAction::updateComboWidth( int id )
605 {
606  TQWidget* w = container( id );
607  if ( ::tqt_cast<TDEToolBar *>( w ) ) {
608  TQWidget* r = static_cast<TDEToolBar*>( w )->getWidget( itemId( id ) );
609  if ( ::tqt_cast<TQComboBox *>( r ) ) {
610  TQComboBox *cb = static_cast<TQComboBox*>( r );
611  cb->setMinimumWidth( d->m_comboWidth );
612  cb->setMaximumWidth( d->m_comboWidth );
613  }
614  }
615 }
616 
617 void TDESelectAction::updateItems( int id )
618 {
619  kdDebug(129) << "TDEAction::updateItems( " << id << ", lst )" << endl; // remove -- ellis
620  TQWidget* w = container( id );
621  if ( ::tqt_cast<TDEToolBar *>( w ) ) {
622  TQWidget* r = static_cast<TDEToolBar*>( w )->getWidget( itemId( id ) );
623  if ( ::tqt_cast<TQComboBox *>( r ) ) {
624  TQComboBox *cb = static_cast<TQComboBox*>( r );
625  cb->clear();
626  TQStringList lst = comboItems();
627  TQStringList::ConstIterator it = lst.begin();
628  for( ; it != lst.end(); ++it )
629  cb->insertItem( *it );
630  // qt caches and never recalculates the sizeHint()
631  // qcombobox.cpp recommends calling setFont to invalidate the sizeHint
632  // setFont sets own_font = True, so we're a bit mean and calll
633  // unsetFont which calls setFont and then overwrites the own_font
634  cb->unsetFont();
635  }
636  }
637 }
638 
639 int TDESelectAction::plug( TQWidget *widget, int index )
640 {
641  if (kapp && !kapp->authorizeTDEAction(name()))
642  return -1;
643  kdDebug(129) << "TDESelectAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis
644  if ( ::tqt_cast<TQPopupMenu *>( widget) )
645  {
646  // Create the PopupMenu and store it in m_menu
647  (void)popupMenu();
648 
649  TQPopupMenu* menu = static_cast<TQPopupMenu*>( widget );
650  int id;
651  if ( hasIcon() )
652  id = menu->insertItem( iconSet(), text(), d->m_menu, -1, index );
653  else
654  id = menu->insertItem( text(), d->m_menu, -1, index );
655 
656  if ( !isEnabled() )
657  menu->setItemEnabled( id, false );
658 
659  TQString wth = whatsThis();
660  if ( !wth.isEmpty() )
661  menu->TQMenuData::setWhatsThis( id, wth );
662 
663  addContainer( menu, id );
664  connect( menu, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
665 
666  return containerCount() - 1;
667  }
668  else if ( ::tqt_cast<TDEToolBar *>( widget ) )
669  {
670  TDEToolBar* bar = static_cast<TDEToolBar*>( widget );
671  int id_ = TDEAction::getToolButtonID();
672  bar->insertCombo( comboItems(), id_, isEditable(),
673  TQ_SIGNAL( activated( const TQString & ) ), this,
674  TQ_SLOT( slotActivated( const TQString & ) ), isEnabled(),
675  toolTip(), -1, index );
676 
677  TQComboBox *cb = bar->getCombo( id_ );
678  if ( cb )
679  {
680  if (!isEditable()) cb->setFocusPolicy(TQWidget::NoFocus);
681  cb->setMinimumWidth( cb->sizeHint().width() );
682  if ( d->m_comboWidth > 0 )
683  {
684  cb->setMinimumWidth( d->m_comboWidth );
685  cb->setMaximumWidth( d->m_comboWidth );
686  }
687  cb->setInsertionPolicy( TQComboBox::NoInsertion );
688  TQWhatsThis::add( cb, whatsThis() );
689  if ( d->m_maxComboViewCount != -1 ) cb->setSizeLimit( d->m_maxComboViewCount );
690  }
691 
692  addContainer( bar, id_ );
693 
694  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
695 
696  updateCurrentItem( containerCount() - 1 );
697 
698  return containerCount() - 1;
699  }
700  else if ( ::tqt_cast<TQMenuBar *>( widget ) )
701  {
702  // Create the PopupMenu and store it in m_menu
703  (void)popupMenu();
704 
705  TQMenuBar* menu = static_cast<TQMenuBar*>( widget );
706  int id = menu->insertItem( text(), d->m_menu, -1, index );
707 
708  if ( !isEnabled() )
709  menu->setItemEnabled( id, false );
710 
711  TQString wth = whatsThis();
712  if ( !wth.isEmpty() )
713  menu->TQMenuData::setWhatsThis( id, wth );
714 
715  addContainer( menu, id );
716  connect( menu, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
717 
718  return containerCount() - 1;
719  }
720 
721  kdWarning() << "Can not plug TDEAction in " << widget->className() << endl;
722  return -1;
723 }
724 
725 TQStringList TDESelectAction::comboItems() const
726 {
727  if( d->m_menuAccelsEnabled ) {
728  TQStringList lst;
729  TQStringList::ConstIterator it = d->m_list.begin();
730  for( ; it != d->m_list.end(); ++it )
731  {
732  TQString item = *it;
733  int i = item.find( '&' );
734  if ( i > -1 )
735  item = item.remove( i, 1 );
736  lst.append( item );
737  }
738  return lst;
739  }
740  else
741  return d->m_list;
742 }
743 
744 void TDESelectAction::clear()
745 {
746  if ( d->m_menu )
747  d->m_menu->clear();
748 
749  int len = containerCount();
750  for( int i = 0; i < len; ++i )
751  updateClear( i );
752 }
753 
754 void TDESelectAction::updateClear( int id )
755 {
756  TQWidget* w = container( id );
757  if ( ::tqt_cast<TDEToolBar *>( w ) ) {
758  TQWidget* r = static_cast<TDEToolBar*>( w )->getWidget( itemId( id ) );
759  if ( ::tqt_cast<TQComboBox *>( r ) ) {
760  TQComboBox *b = static_cast<TQComboBox*>( r );
761  b->clear();
762  }
763  }
764 }
765 
766 void TDESelectAction::slotActivated( int id )
767 {
768  if ( d->m_current == id )
769  return;
770 
771  setCurrentItem( id );
772  // Delay this. Especially useful when the slot connected to activated() will re-create
773  // the menu, e.g. in the recent files action. This prevents a crash.
774  TQTimer::singleShot( 0, this, TQ_SLOT( slotActivated() ) );
775 }
776 
777 void TDESelectAction::slotActivated( const TQString &text )
778 {
779  if ( isEditable() )
780  {
781  TQStringList lst = d->m_list;
782  if(!lst.contains(text))
783  {
784  lst.append( text );
785  setItems( lst );
786  }
787  }
788 
789  int i = d->m_list.findIndex( text );
790  if ( i > -1 )
791  setCurrentItem( i );
792  else
793  setCurrentItem( comboItems().findIndex( text ) );
794  // Delay this. Especially useful when the slot connected to activated() will re-create
795  // the menu, e.g. in the recent files action. This prevents a crash.
796  TQTimer::singleShot( 0, this, TQ_SLOT( slotActivated() ) );
797 }
798 
799 void TDESelectAction::slotActivated()
800 {
801  TDEAction::slotActivated();
802  kdDebug(129) << "TDESelectAction::slotActivated currentItem=" << currentItem() << " currentText=" << currentText() << endl;
803  emit activated( currentItem() );
804  emit activated( currentText() );
805 }
806 
807 void TDESelectAction::setEditable( bool edit )
808 {
809  d->m_edit = edit;
810 }
811 
812 bool TDESelectAction::isEditable() const
813 {
814  return d->m_edit;
815 }
816 
817 void TDESelectAction::setRemoveAmpersandsInCombo( bool b )
818 {
819  setMenuAccelsEnabled( b );
820 }
821 
822 bool TDESelectAction::removeAmpersandsInCombo() const
823 {
824  return menuAccelsEnabled( );
825 }
826 
827 void TDESelectAction::setMenuAccelsEnabled( bool b )
828 {
829  d->m_menuAccelsEnabled = b;
830 }
831 
832 bool TDESelectAction::menuAccelsEnabled() const
833 {
834  return d->m_menuAccelsEnabled;
835 }
836 
837 class TDEListAction::TDEListActionPrivate
838 {
839 public:
840  TDEListActionPrivate()
841  {
842  m_current = 0;
843  }
844  int m_current;
845 };
846 
847 TDEListAction::TDEListAction( const TQString& text, const TDEShortcut& cut,
848  TQObject* parent, const char* name )
849  : TDESelectAction( text, cut, parent, name )
850 {
851  d = new TDEListActionPrivate;
852 }
853 
854 TDEListAction::TDEListAction( const TQString& text, const TDEShortcut& cut,
855  const TQObject* receiver, const char* slot,
856  TQObject* parent, const char* name )
857  : TDESelectAction( text, cut, parent, name )
858 {
859  d = new TDEListActionPrivate;
860  if ( receiver )
861  connect( this, TQ_SIGNAL( activated( int ) ), receiver, slot );
862 }
863 
864 TDEListAction::TDEListAction( const TQString& text, const TQIconSet& pix,
865  const TDEShortcut& cut,
866  TQObject* parent, const char* name )
867  : TDESelectAction( text, pix, cut, parent, name )
868 {
869  d = new TDEListActionPrivate;
870 }
871 
872 TDEListAction::TDEListAction( const TQString& text, const TQString& pix,
873  const TDEShortcut& cut,
874  TQObject* parent, const char* name )
875  : TDESelectAction( text, pix, cut, parent, name )
876 {
877  d = new TDEListActionPrivate;
878 }
879 
880 TDEListAction::TDEListAction( const TQString& text, const TQIconSet& pix,
881  const TDEShortcut& cut, const TQObject* receiver,
882  const char* slot, TQObject* parent,
883  const char* name )
884  : TDESelectAction( text, pix, cut, parent, name )
885 {
886  d = new TDEListActionPrivate;
887  if ( receiver )
888  connect( this, TQ_SIGNAL( activated( int ) ), receiver, slot );
889 }
890 
891 TDEListAction::TDEListAction( const TQString& text, const TQString& pix,
892  const TDEShortcut& cut, const TQObject* receiver,
893  const char* slot, TQObject* parent,
894  const char* name )
895  : TDESelectAction( text, pix, cut, parent, name )
896 {
897  d = new TDEListActionPrivate;
898  if ( receiver )
899  connect( this, TQ_SIGNAL( activated( int ) ), receiver, slot );
900 }
901 
902 TDEListAction::TDEListAction( TQObject* parent, const char* name )
903  : TDESelectAction( parent, name )
904 {
905  d = new TDEListActionPrivate;
906 }
907 
908 TDEListAction::~TDEListAction()
909 {
910  delete d; d = 0;
911 }
912 
913 void TDEListAction::setCurrentItem( int index )
914 {
915  TDESelectAction::setCurrentItem( index );
916  d->m_current = index;
917 
918  // emit TDEAction::activated();
919  // emit activated( currentItem() );
920  // emit activated( currentText() );
921 }
922 
923 TQString TDEListAction::currentText() const
924 {
925  return TDESelectAction::currentText();
926 }
927 
928 int TDEListAction::currentItem() const
929 {
930  return d->m_current;
931 }
932 
933 class TDERecentFilesAction::TDERecentFilesActionPrivate
934 {
935 public:
936  TDERecentFilesActionPrivate()
937  {
938  m_maxItems = 0;
939  m_popup = 0;
940  }
941  uint m_maxItems;
942  TDEPopupMenu *m_popup;
943  TQMap<TQString, TQString> m_shortNames;
944  TQMap<TQString, KURL> m_urls;
945 };
946 
947 TDERecentFilesAction::TDERecentFilesAction( const TQString& text,
948  const TDEShortcut& cut,
949  TQObject* parent, const char* name,
950  uint maxItems )
951  : TDEListAction( text, cut, parent, name)
952 {
953  d = new TDERecentFilesActionPrivate;
954  d->m_maxItems = maxItems;
955 
956  init();
957 }
958 
959 TDERecentFilesAction::TDERecentFilesAction( const TQString& text,
960  const TDEShortcut& cut,
961  const TQObject* receiver,
962  const char* slot,
963  TQObject* parent, const char* name,
964  uint maxItems )
965  : TDEListAction( text, cut, parent, name)
966 {
967  d = new TDERecentFilesActionPrivate;
968  d->m_maxItems = maxItems;
969 
970  init();
971 
972  if ( receiver )
973  connect( this, TQ_SIGNAL(urlSelected(const KURL&)),
974  receiver, slot );
975 }
976 
977 TDERecentFilesAction::TDERecentFilesAction( const TQString& text,
978  const TQIconSet& pix,
979  const TDEShortcut& cut,
980  TQObject* parent, const char* name,
981  uint maxItems )
982  : TDEListAction( text, pix, cut, parent, name)
983 {
984  d = new TDERecentFilesActionPrivate;
985  d->m_maxItems = maxItems;
986 
987  init();
988 }
989 
990 TDERecentFilesAction::TDERecentFilesAction( const TQString& text,
991  const TQString& pix,
992  const TDEShortcut& cut,
993  TQObject* parent, const char* name,
994  uint maxItems )
995  : TDEListAction( text, pix, cut, parent, name)
996 {
997  d = new TDERecentFilesActionPrivate;
998  d->m_maxItems = maxItems;
999 
1000  init();
1001 }
1002 
1003 TDERecentFilesAction::TDERecentFilesAction( const TQString& text,
1004  const TQIconSet& pix,
1005  const TDEShortcut& cut,
1006  const TQObject* receiver,
1007  const char* slot,
1008  TQObject* parent, const char* name,
1009  uint maxItems )
1010  : TDEListAction( text, pix, cut, parent, name)
1011 {
1012  d = new TDERecentFilesActionPrivate;
1013  d->m_maxItems = maxItems;
1014 
1015  init();
1016 
1017  if ( receiver )
1018  connect( this, TQ_SIGNAL(urlSelected(const KURL&)),
1019  receiver, slot );
1020 }
1021 
1022 TDERecentFilesAction::TDERecentFilesAction( const TQString& text,
1023  const TQString& pix,
1024  const TDEShortcut& cut,
1025  const TQObject* receiver,
1026  const char* slot,
1027  TQObject* parent, const char* name,
1028  uint maxItems )
1029  : TDEListAction( text, pix, cut, parent, name)
1030 {
1031  d = new TDERecentFilesActionPrivate;
1032  d->m_maxItems = maxItems;
1033 
1034  init();
1035 
1036  if ( receiver )
1037  connect( this, TQ_SIGNAL(urlSelected(const KURL&)),
1038  receiver, slot );
1039 }
1040 
1041 TDERecentFilesAction::TDERecentFilesAction( TQObject* parent, const char* name,
1042  uint maxItems )
1043  : TDEListAction( parent, name )
1044 {
1045  d = new TDERecentFilesActionPrivate;
1046  d->m_maxItems = maxItems;
1047 
1048  init();
1049 }
1050 
1051 void TDERecentFilesAction::init()
1052 {
1053  TDERecentFilesAction *that = const_cast<TDERecentFilesAction*>(this);
1054  that->d->m_popup = new TDEPopupMenu;
1055  connect(d->m_popup, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(menuAboutToShow()));
1056  connect(d->m_popup, TQ_SIGNAL(activated(int)), this, TQ_SLOT(menuItemActivated(int)));
1057  connect( this, TQ_SIGNAL( activated( const TQString& ) ),
1058  this, TQ_SLOT( itemSelected( const TQString& ) ) );
1059 
1060  setMenuAccelsEnabled( false );
1061 }
1062 
1063 TDERecentFilesAction::~TDERecentFilesAction()
1064 {
1065  delete d->m_popup;
1066  delete d; d = 0;
1067 }
1068 
1069 uint TDERecentFilesAction::maxItems() const
1070 {
1071  return d->m_maxItems;
1072 }
1073 
1074 void TDERecentFilesAction::setMaxItems( uint maxItems )
1075 {
1076  TQStringList lst = TDESelectAction::items();
1077  uint oldCount = lst.count();
1078 
1079  // set new maxItems
1080  d->m_maxItems = maxItems;
1081 
1082  // remove all items that are too much
1083  while( lst.count() > maxItems )
1084  {
1085  // remove last item
1086  TQString lastItem = lst.last();
1087  d->m_shortNames.erase( lastItem );
1088  d->m_urls.erase( lastItem );
1089  lst.remove( lastItem );
1090  }
1091 
1092  // set new list if changed
1093  if( lst.count() != oldCount )
1094  setItems( lst );
1095 }
1096 
1097 void TDERecentFilesAction::addURL( const KURL& url )
1098 {
1099  addURL( url, url.fileName() );
1100 }
1101 
1102 void TDERecentFilesAction::addURL( const KURL& url, const TQString& name )
1103 {
1104  if ( url.isLocalFile() && !TDEGlobal::dirs()->relativeLocation("tmp", url.path()).startsWith("/"))
1105  return;
1106  const TQString file = url.pathOrURL();
1107  TQStringList lst = TDESelectAction::items();
1108 
1109  // remove file if already in list
1110  const TQStringList::Iterator end = lst.end();
1111  for ( TQStringList::Iterator it = lst.begin(); it != end; ++it )
1112  {
1113  TQString title = (*it);
1114  if ( title.endsWith( file + "]" ) )
1115  {
1116  lst.remove( it );
1117  d->m_urls.erase( title );
1118  d->m_shortNames.erase( title );
1119  break;
1120  }
1121  }
1122  // remove last item if already maxitems in list
1123  if( lst.count() == d->m_maxItems )
1124  {
1125  // remove last item
1126  const TQString lastItem = lst.last();
1127  d->m_shortNames.erase( lastItem );
1128  d->m_urls.erase( lastItem );
1129  lst.remove( lastItem );
1130  }
1131 
1132  // add file to list
1133  const TQString title = name + " [" + file + "]";
1134  d->m_shortNames.insert( title, name );
1135  d->m_urls.insert( title, url );
1136  lst.prepend( title );
1137  setItems( lst );
1138 }
1139 
1140 void TDERecentFilesAction::removeURL( const KURL& url )
1141 {
1142  TQStringList lst = TDESelectAction::items();
1143  TQString file = url.pathOrURL();
1144 
1145  // remove url
1146  TQStringList::Iterator end = lst.end();
1147  for ( TQStringList::Iterator it = lst.begin(); it != end; ++it )
1148  {
1149  if ( (*it).endsWith( file + "]" ))
1150  {
1151  d->m_shortNames.erase( (*it) );
1152  d->m_urls.erase( (*it) );
1153  lst.remove( it );
1154  setItems( lst );
1155  break;
1156  }
1157  }
1158 }
1159 
1160 void TDERecentFilesAction::clearURLList()
1161 {
1162  clear();
1163  d->m_shortNames.clear();
1164  d->m_urls.clear();
1165 }
1166 
1167 void TDERecentFilesAction::loadEntries( TDEConfig* config, TQString groupname)
1168 {
1169  TQString key;
1170  TQString value;
1171  TQString nameKey;
1172  TQString nameValue;
1173  TQString title;
1174  TQString oldGroup;
1175  TQStringList lst;
1176  KURL url;
1177 
1178  oldGroup = config->group();
1179 
1180  if (groupname.isEmpty())
1181  groupname = "RecentFiles";
1182  config->setGroup( groupname );
1183 
1184  // read file list
1185  for( unsigned int i = 1 ; i <= d->m_maxItems ; i++ )
1186  {
1187  key = TQString( "File%1" ).arg( i );
1188  value = config->readPathEntry( key );
1189  url = KURL::fromPathOrURL( value );
1190 
1191  // Don't restore if file doesn't exist anymore
1192  if (url.isLocalFile() && !TQFile::exists(url.path()))
1193  continue;
1194 
1195  nameKey = TQString( "Name%1" ).arg( i );
1196  nameValue = config->readPathEntry( nameKey, url.fileName() );
1197  title = nameValue + " [" + value + "]";
1198  if (!value.isNull())
1199  {
1200  lst.append( title );
1201  d->m_shortNames.insert( title, nameValue );
1202  d->m_urls.insert( title, url );
1203  }
1204  }
1205 
1206  // set file
1207  setItems( lst );
1208 
1209  config->setGroup( oldGroup );
1210 }
1211 
1212 void TDERecentFilesAction::saveEntries( TDEConfig* config, TQString groupname )
1213 {
1214  TQString key;
1215  TQString value;
1216  TQString oldGroup;
1217  TQStringList lst = TDESelectAction::items();
1218 
1219  oldGroup = config->group();
1220 
1221  if (groupname.isEmpty())
1222  groupname = "RecentFiles";
1223  config->deleteGroup( groupname, true );
1224  config->setGroup( groupname );
1225 
1226  // write file list
1227  for( unsigned int i = 1 ; i <= lst.count() ; i++ )
1228  {
1229  //kdDebug(129) << "Entry for " << lst[i-1] << d->m_urls[ lst[ i - 1 ] ] << endl;
1230  key = TQString( "File%1" ).arg( i );
1231  value = d->m_urls[ lst[ i - 1 ] ].pathOrURL();
1232  config->writePathEntry( key, value );
1233  key = TQString( "Name%1" ).arg( i );
1234  value = d->m_shortNames[ lst[ i - 1 ] ];
1235  config->writePathEntry( key, value );
1236  }
1237 
1238  config->setGroup( oldGroup );
1239 }
1240 
1241 void TDERecentFilesAction::itemSelected( const TQString& text )
1242 {
1243  //return a copy of the URL since the slot where it is connected might call
1244  //addURL or removeURL where the d->m_urls.erase( title ) could destroy the
1245  //d->m_urls[ text ] and the emitted URL will be invalid in the rest of the slot
1246  emit urlSelected( KURL(d->m_urls[ text ]) );
1247 }
1248 
1249 void TDERecentFilesAction::menuItemActivated( int id )
1250 {
1251  TQString text = d->m_popup->text(id);
1252  //return a copy of the URL since the slot where it is connected might call
1253  //addURL or removeURL where the d->m_urls.erase( title ) could destroy the
1254  //d->m_urls[ text ] and the emitted URL will be invalid in the rest of the slot
1255  emit urlSelected( KURL(d->m_urls[ text ]) );
1256 }
1257 
1258 void TDERecentFilesAction::menuAboutToShow()
1259 {
1260  TDEPopupMenu *menu = d->m_popup;
1261  menu->clear();
1262  TQStringList list = TDESelectAction::items();
1263  for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it )
1264  {
1265  menu->insertItem(*it);
1266  }
1267 }
1268 
1269 int TDERecentFilesAction::plug( TQWidget *widget, int index )
1270 {
1271  if (kapp && !kapp->authorizeTDEAction(name()))
1272  return -1;
1273  // This is very related to TDEActionMenu::plug.
1274  // In fact this class could be an interesting base class for TDEActionMenu
1275  if ( ::tqt_cast<TDEToolBar *>( widget ) )
1276  {
1277  TDEToolBar *bar = (TDEToolBar *)widget;
1278 
1279  int id_ = TDEAction::getToolButtonID();
1280 
1281  TDEInstance * instance;
1282  if ( m_parentCollection )
1283  instance = m_parentCollection->instance();
1284  else
1285  instance = TDEGlobal::instance();
1286 
1287  bar->insertButton( icon(), id_, TQ_SIGNAL( clicked() ), this,
1288  TQ_SLOT( slotClicked() ), isEnabled(), plainText(),
1289  index, instance );
1290 
1291  addContainer( bar, id_ );
1292 
1293  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
1294 
1295  bar->setDelayedPopup( id_, d->m_popup, true);
1296 
1297  if ( !whatsThis().isEmpty() )
1298  TQWhatsThis::add( bar->getButton( id_ ), whatsThisWithIcon() );
1299 
1300  return containerCount() - 1;
1301  }
1302 
1303  return TDEListAction::plug( widget, index );
1304 }
1305 
1306 void TDERecentFilesAction::slotClicked()
1307 {
1308  TDEAction::slotActivated();
1309 }
1310 
1311 void TDERecentFilesAction::slotActivated(const TQString& text)
1312 {
1313  TDEListAction::slotActivated(text);
1314 }
1315 
1316 
1317 void TDERecentFilesAction::slotActivated(int id)
1318 {
1319  TDEListAction::slotActivated(id);
1320 }
1321 
1322 
1323 void TDERecentFilesAction::slotActivated()
1324 {
1325  emit activated( currentItem() );
1326  emit activated( currentText() );
1327 }
1328 
1329 //KDE4: rename to urls() and return a KURL::List
1330 TQStringList TDERecentFilesAction::items() const
1331 {
1332  TQStringList lst = TDESelectAction::items();
1333  TQStringList result;
1334 
1335  for( unsigned int i = 1 ; i <= lst.count() ; i++ )
1336  {
1337  result += d->m_urls[ lst[ i - 1 ] ].prettyURL(0, KURL::StripFileProtocol);
1338  }
1339 
1340  return result;
1341 }
1342 
1343 //KDE4: remove
1344 TQStringList TDERecentFilesAction::completeItems() const
1345 {
1346  return TDESelectAction::items();
1347 }
1348 
1349 
1350 class TDEFontAction::TDEFontActionPrivate
1351 {
1352 public:
1353  TDEFontActionPrivate()
1354  {
1355  }
1356  TQStringList m_fonts;
1357 };
1358 
1359 TDEFontAction::TDEFontAction( const TQString& text,
1360  const TDEShortcut& cut, TQObject* parent,
1361  const char* name )
1362  : TDESelectAction( text, cut, parent, name )
1363 {
1364  d = new TDEFontActionPrivate;
1365  TDEFontChooser::getFontList( d->m_fonts, 0 );
1366  TDESelectAction::setItems( d->m_fonts );
1367  setEditable( true );
1368 }
1369 
1370 TDEFontAction::TDEFontAction( const TQString& text, const TDEShortcut& cut,
1371  const TQObject* receiver, const char* slot,
1372  TQObject* parent, const char* name )
1373  : TDESelectAction( text, cut, receiver, slot, parent, name )
1374 {
1375  d = new TDEFontActionPrivate;
1376  TDEFontChooser::getFontList( d->m_fonts, 0 );
1377  TDESelectAction::setItems( d->m_fonts );
1378  setEditable( true );
1379 }
1380 
1381 TDEFontAction::TDEFontAction( const TQString& text, const TQIconSet& pix,
1382  const TDEShortcut& cut,
1383  TQObject* parent, const char* name )
1384  : TDESelectAction( text, pix, cut, parent, name )
1385 {
1386  d = new TDEFontActionPrivate;
1387  TDEFontChooser::getFontList( d->m_fonts, 0 );
1388  TDESelectAction::setItems( d->m_fonts );
1389  setEditable( true );
1390 }
1391 
1392 TDEFontAction::TDEFontAction( const TQString& text, const TQString& pix,
1393  const TDEShortcut& cut,
1394  TQObject* parent, const char* name )
1395  : TDESelectAction( text, pix, cut, parent, name )
1396 {
1397  d = new TDEFontActionPrivate;
1398  TDEFontChooser::getFontList( d->m_fonts, 0 );
1399  TDESelectAction::setItems( d->m_fonts );
1400  setEditable( true );
1401 }
1402 
1403 TDEFontAction::TDEFontAction( const TQString& text, const TQIconSet& pix,
1404  const TDEShortcut& cut,
1405  const TQObject* receiver, const char* slot,
1406  TQObject* parent, const char* name )
1407  : TDESelectAction( text, pix, cut, receiver, slot, parent, name )
1408 {
1409  d = new TDEFontActionPrivate;
1410  TDEFontChooser::getFontList( d->m_fonts, 0 );
1411  TDESelectAction::setItems( d->m_fonts );
1412  setEditable( true );
1413 }
1414 
1415 TDEFontAction::TDEFontAction( const TQString& text, const TQString& pix,
1416  const TDEShortcut& cut,
1417  const TQObject* receiver, const char* slot,
1418  TQObject* parent, const char* name )
1419  : TDESelectAction( text, pix, cut, receiver, slot, parent, name )
1420 {
1421  d = new TDEFontActionPrivate;
1422  TDEFontChooser::getFontList( d->m_fonts, 0 );
1423  TDESelectAction::setItems( d->m_fonts );
1424  setEditable( true );
1425 }
1426 
1427 TDEFontAction::TDEFontAction( uint fontListCriteria, const TQString& text,
1428  const TDEShortcut& cut, TQObject* parent,
1429  const char* name )
1430  : TDESelectAction( text, cut, parent, name )
1431 {
1432  d = new TDEFontActionPrivate;
1433  TDEFontChooser::getFontList( d->m_fonts, fontListCriteria );
1434  TDESelectAction::setItems( d->m_fonts );
1435  setEditable( true );
1436 }
1437 
1438 TDEFontAction::TDEFontAction( uint fontListCriteria, const TQString& text, const TQString& pix,
1439  const TDEShortcut& cut,
1440  TQObject* parent, const char* name )
1441  : TDESelectAction( text, pix, cut, parent, name )
1442 {
1443  d = new TDEFontActionPrivate;
1444  TDEFontChooser::getFontList( d->m_fonts, fontListCriteria );
1445  TDESelectAction::setItems( d->m_fonts );
1446  setEditable( true );
1447 }
1448 
1449 TDEFontAction::TDEFontAction( TQObject* parent, const char* name )
1450  : TDESelectAction( parent, name )
1451 {
1452  d = new TDEFontActionPrivate;
1453  TDEFontChooser::getFontList( d->m_fonts, 0 );
1454  TDESelectAction::setItems( d->m_fonts );
1455  setEditable( true );
1456 }
1457 
1458 TDEFontAction::~TDEFontAction()
1459 {
1460  delete d;
1461  d = 0;
1462 }
1463 
1464 /*
1465  * Maintenance note: Keep in sync with TDEFontCombo::setCurrentFont()
1466  */
1467 void TDEFontAction::setFont( const TQString &family )
1468 {
1469  TQString lowerName = family.lower();
1470  int i = 0;
1471  for ( TQStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1472  {
1473  if ((*it).lower() == lowerName)
1474  {
1475  setCurrentItem(i);
1476  return;
1477  }
1478  }
1479  i = lowerName.find(" [");
1480  if (i>-1)
1481  {
1482  lowerName = lowerName.left(i);
1483  i = 0;
1484  for ( TQStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1485  {
1486  if ((*it).lower() == lowerName)
1487  {
1488  setCurrentItem(i);
1489  return;
1490  }
1491  }
1492  }
1493 
1494  lowerName += " [";
1495  i = 0;
1496  for ( TQStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1497  {
1498  if ((*it).lower().startsWith(lowerName))
1499  {
1500  setCurrentItem(i);
1501  return;
1502  }
1503  }
1504 
1505  // nothing matched yet, try a fontconfig reverse lookup and
1506  // check again to solve an alias
1507  FcPattern *pattern = NULL;
1508  FcConfig *config = NULL;
1509  FcResult result;
1510  TQString realFamily;
1511  TQRegExp regExp("[-:]");
1512  pattern = FcNameParse( (unsigned char*) family.ascii() );
1513  FcDefaultSubstitute(pattern);
1514  FcConfigSubstitute (config, pattern, FcMatchPattern);
1515  pattern = FcFontMatch(NULL, pattern, &result);
1516  realFamily = (char*)FcNameUnparse(pattern);
1517  realFamily.remove(realFamily.find(regExp), realFamily.length());
1518 
1519  if ( !realFamily.isEmpty() && realFamily != family )
1520  setFont( realFamily );
1521  else
1522  kdDebug(129) << "Font not found " << family.lower() << endl;
1523 }
1524 
1525 int TDEFontAction::plug( TQWidget *w, int index )
1526 {
1527  if (kapp && !kapp->authorizeTDEAction(name()))
1528  return -1;
1529  if ( ::tqt_cast<TDEToolBar *>( w ) )
1530  {
1531  TDEToolBar* bar = static_cast<TDEToolBar*>( w );
1532  int id_ = TDEAction::getToolButtonID();
1533  TDEFontCombo *cb = new TDEFontCombo( items(), bar );
1534  connect( cb, TQ_SIGNAL( activated( const TQString & ) ),
1535  TQ_SLOT( slotActivated( const TQString & ) ) );
1536  cb->setEnabled( isEnabled() );
1537  bar->insertWidget( id_, comboWidth(), cb, index );
1538  cb->setMinimumWidth( cb->sizeHint().width() );
1539 
1540  addContainer( bar, id_ );
1541 
1542  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
1543 
1544  updateCurrentItem( containerCount() - 1 );
1545 
1546  return containerCount() - 1;
1547  }
1548  else return TDESelectAction::plug( w, index );
1549 }
1550 
1551 class TDEFontSizeAction::TDEFontSizeActionPrivate
1552 {
1553 public:
1554  TDEFontSizeActionPrivate()
1555  {
1556  }
1557 };
1558 
1559 TDEFontSizeAction::TDEFontSizeAction( const TQString& text,
1560  const TDEShortcut& cut,
1561  TQObject* parent, const char* name )
1562  : TDESelectAction( text, cut, parent, name )
1563 {
1564  init();
1565 }
1566 
1567 TDEFontSizeAction::TDEFontSizeAction( const TQString& text,
1568  const TDEShortcut& cut,
1569  const TQObject* receiver, const char* slot,
1570  TQObject* parent, const char* name )
1571  : TDESelectAction( text, cut, receiver, slot, parent, name )
1572 {
1573  init();
1574 }
1575 
1576 TDEFontSizeAction::TDEFontSizeAction( const TQString& text, const TQIconSet& pix,
1577  const TDEShortcut& cut,
1578  TQObject* parent, const char* name )
1579  : TDESelectAction( text, pix, cut, parent, name )
1580 {
1581  init();
1582 }
1583 
1584 TDEFontSizeAction::TDEFontSizeAction( const TQString& text, const TQString& pix,
1585  const TDEShortcut& cut,
1586  TQObject* parent, const char* name )
1587  : TDESelectAction( text, pix, cut, parent, name )
1588 {
1589  init();
1590 }
1591 
1592 TDEFontSizeAction::TDEFontSizeAction( const TQString& text, const TQIconSet& pix,
1593  const TDEShortcut& cut,
1594  const TQObject* receiver,
1595  const char* slot, TQObject* parent,
1596  const char* name )
1597  : TDESelectAction( text, pix, cut, receiver, slot, parent, name )
1598 {
1599  init();
1600 }
1601 
1602 TDEFontSizeAction::TDEFontSizeAction( const TQString& text, const TQString& pix,
1603  const TDEShortcut& cut,
1604  const TQObject* receiver,
1605  const char* slot, TQObject* parent,
1606  const char* name )
1607  : TDESelectAction( text, pix, cut, receiver, slot, parent, name )
1608 {
1609  init();
1610 }
1611 
1612 TDEFontSizeAction::TDEFontSizeAction( TQObject* parent, const char* name )
1613  : TDESelectAction( parent, name )
1614 {
1615  init();
1616 }
1617 
1618 TDEFontSizeAction::~TDEFontSizeAction()
1619 {
1620  delete d;
1621  d = 0;
1622 }
1623 
1624 void TDEFontSizeAction::init()
1625 {
1626  d = new TDEFontSizeActionPrivate;
1627 
1628  setEditable( true );
1629  TQFontDatabase fontDB;
1630  TQValueList<int> sizes = fontDB.standardSizes();
1631  TQStringList lst;
1632  for ( TQValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it )
1633  lst.append( TQString::number( *it ) );
1634 
1635  setItems( lst );
1636 }
1637 
1638 void TDEFontSizeAction::setFontSize( int size )
1639 {
1640  if ( size == fontSize() ) {
1641  setCurrentItem( items().findIndex( TQString::number( size ) ) );
1642  return;
1643  }
1644 
1645  if ( size < 1 ) {
1646  kdWarning() << "TDEFontSizeAction: Size " << size << " is out of range" << endl;
1647  return;
1648  }
1649 
1650  int index = items().findIndex( TQString::number( size ) );
1651  if ( index == -1 ) {
1652  // Insert at the correct position in the list (to keep sorting)
1653  TQValueList<int> lst;
1654  // Convert to list of ints
1655  TQStringList itemsList = items();
1656  for (TQStringList::Iterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
1657  lst.append( (*it).toInt() );
1658  // New size
1659  lst.append( size );
1660  // Sort the list
1661  qHeapSort( lst );
1662  // Convert back to string list
1663  TQStringList strLst;
1664  for (TQValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it)
1665  strLst.append( TQString::number(*it) );
1666  TDESelectAction::setItems( strLst );
1667  // Find new current item
1668  index = lst.findIndex( size );
1669  setCurrentItem( index );
1670  }
1671  else
1672  setCurrentItem( index );
1673 
1674 
1675  //emit TDEAction::activated();
1676  //emit activated( index );
1677  //emit activated( TQString::number( size ) );
1678  //emit fontSizeChanged( size );
1679 }
1680 
1681 int TDEFontSizeAction::fontSize() const
1682 {
1683  return currentText().toInt();
1684 }
1685 
1686 void TDEFontSizeAction::slotActivated( int index )
1687 {
1688  TDESelectAction::slotActivated( index );
1689 
1690  emit fontSizeChanged( items()[ index ].toInt() );
1691 }
1692 
1693 void TDEFontSizeAction::slotActivated( const TQString& size )
1694 {
1695  setFontSize( size.toInt() ); // insert sorted first
1696  TDESelectAction::slotActivated( size );
1697  emit fontSizeChanged( size.toInt() );
1698 }
1699 
1700 class TDEActionMenu::TDEActionMenuPrivate
1701 {
1702 public:
1703  TDEActionMenuPrivate()
1704  {
1705  m_popup = new TDEPopupMenu(0L,"TDEActionMenu::TDEActionMenuPrivate");
1706  m_delayed = true;
1707  m_stickyMenu = true;
1708  }
1709  ~TDEActionMenuPrivate()
1710  {
1711  delete m_popup; m_popup = 0;
1712  }
1713  TDEPopupMenu *m_popup;
1714  bool m_delayed;
1715  bool m_stickyMenu;
1716 };
1717 
1718 TDEActionMenu::TDEActionMenu( TQObject* parent, const char* name )
1719  : TDEAction( parent, name )
1720 {
1721  d = new TDEActionMenuPrivate;
1722  setShortcutConfigurable( false );
1723 }
1724 
1725 TDEActionMenu::TDEActionMenu( const TQString& text, TQObject* parent,
1726  const char* name )
1727  : TDEAction( text, 0, parent, name )
1728 {
1729  d = new TDEActionMenuPrivate;
1730  setShortcutConfigurable( false );
1731 }
1732 
1733 TDEActionMenu::TDEActionMenu( const TQString& text, const TQIconSet& icon,
1734  TQObject* parent, const char* name )
1735  : TDEAction( text, icon, 0, parent, name )
1736 {
1737  d = new TDEActionMenuPrivate;
1738  setShortcutConfigurable( false );
1739 }
1740 
1741 TDEActionMenu::TDEActionMenu( const TQString& text, const TQString& icon,
1742  TQObject* parent, const char* name )
1743  : TDEAction( text, icon, 0, parent, name )
1744 {
1745  d = new TDEActionMenuPrivate;
1746  setShortcutConfigurable( false );
1747 }
1748 
1749 TDEActionMenu::~TDEActionMenu()
1750 {
1751  unplugAll();
1752  kdDebug(129) << "TDEActionMenu::~TDEActionMenu()" << endl; // ellis
1753  delete d; d = 0;
1754 }
1755 
1756 void TDEActionMenu::popup( const TQPoint& global )
1757 {
1758  popupMenu()->popup( global );
1759 }
1760 
1761 TDEPopupMenu* TDEActionMenu::popupMenu() const
1762 {
1763  return d->m_popup;
1764 }
1765 
1766 void TDEActionMenu::insert( TDEAction* cmd, int index )
1767 {
1768  if ( cmd )
1769  cmd->plug( d->m_popup, index );
1770 }
1771 
1772 void TDEActionMenu::remove( TDEAction* cmd )
1773 {
1774  if ( cmd )
1775  cmd->unplug( d->m_popup );
1776 }
1777 
1778 bool TDEActionMenu::delayed() const {
1779  return d->m_delayed;
1780 }
1781 
1782 void TDEActionMenu::setDelayed(bool _delayed) {
1783  d->m_delayed = _delayed;
1784 }
1785 
1786 bool TDEActionMenu::stickyMenu() const {
1787  return d->m_stickyMenu;
1788 }
1789 
1790 void TDEActionMenu::setStickyMenu(bool sticky) {
1791  d->m_stickyMenu = sticky;
1792 }
1793 
1794 int TDEActionMenu::plug( TQWidget* widget, int index )
1795 {
1796  if (kapp && !kapp->authorizeTDEAction(name()))
1797  return -1;
1798  kdDebug(129) << "TDEActionMenu::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis
1799  if ( ::tqt_cast<TQPopupMenu *>( widget ) )
1800  {
1801  TQPopupMenu* menu = static_cast<TQPopupMenu*>( widget );
1802  int id;
1803  if ( hasIcon() )
1804  id = menu->insertItem( iconSet(), text(), d->m_popup, -1, index );
1805  else
1806  id = menu->insertItem( text(), d->m_popup, -1, index );
1807 
1808  if ( !isEnabled() )
1809  menu->setItemEnabled( id, false );
1810 
1811  addContainer( menu, id );
1812  connect( menu, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
1813 
1814  if ( m_parentCollection )
1815  m_parentCollection->connectHighlight( menu, this );
1816 
1817  return containerCount() - 1;
1818  }
1819  else if ( ::tqt_cast<TDEToolBar *>( widget ) )
1820  {
1821  TDEToolBar *bar = static_cast<TDEToolBar *>( widget );
1822 
1823  int id_ = TDEAction::getToolButtonID();
1824 
1825  if ( icon().isEmpty() && !iconSet().isNull() )
1826  bar->insertButton( iconSet().pixmap(), id_, TQ_SIGNAL( clicked() ), this,
1827  TQ_SLOT( slotActivated() ), isEnabled(), plainText(),
1828  index );
1829  else
1830  {
1831  TDEInstance *instance;
1832 
1833  if ( m_parentCollection )
1834  instance = m_parentCollection->instance();
1835  else
1836  instance = TDEGlobal::instance();
1837 
1838  bar->insertButton( icon(), id_, TQ_SIGNAL( clicked() ), this,
1839  TQ_SLOT( slotActivated() ), isEnabled(), plainText(),
1840  index, instance );
1841  }
1842 
1843  addContainer( bar, id_ );
1844 
1845  if (!whatsThis().isEmpty())
1846  TQWhatsThis::add( bar->getButton(id_), whatsThis() );
1847 
1848  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
1849 
1850  if (delayed()) {
1851  bar->setDelayedPopup( id_, popupMenu(), stickyMenu() );
1852  } else {
1853  bar->getButton(id_)->setPopup(popupMenu(), stickyMenu() );
1854  }
1855 
1856  if ( m_parentCollection )
1857  m_parentCollection->connectHighlight( bar, this );
1858 
1859  return containerCount() - 1;
1860  }
1861  else if ( ::tqt_cast<TQMenuBar *>( widget ) )
1862  {
1863  TQMenuBar *bar = static_cast<TQMenuBar *>( widget );
1864 
1865  int id;
1866 
1867  id = bar->insertItem( text(), popupMenu(), -1, index );
1868 
1869  if ( !isEnabled() )
1870  bar->setItemEnabled( id, false );
1871 
1872  addContainer( bar, id );
1873  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
1874 
1875  return containerCount() - 1;
1876  }
1877 
1878  return -1;
1879 }
1880 
1882 
1883 TDEToolBarPopupAction::TDEToolBarPopupAction( const TQString& text,
1884  const TQString& icon,
1885  const TDEShortcut& cut,
1886  TQObject* parent, const char* name )
1887  : TDEAction( text, icon, cut, parent, name )
1888 {
1889  m_popup = 0;
1890  m_delayed = true;
1891  m_stickyMenu = true;
1892 }
1893 
1894 TDEToolBarPopupAction::TDEToolBarPopupAction( const TQString& text,
1895  const TQString& icon,
1896  const TDEShortcut& cut,
1897  const TQObject* receiver,
1898  const char* slot, TQObject* parent,
1899  const char* name )
1900  : TDEAction( text, icon, cut, receiver, slot, parent, name )
1901 {
1902  m_popup = 0;
1903  m_delayed = true;
1904  m_stickyMenu = true;
1905 }
1906 
1907 TDEToolBarPopupAction::TDEToolBarPopupAction( const KGuiItem& item,
1908  const TDEShortcut& cut,
1909  const TQObject* receiver,
1910  const char* slot, TDEActionCollection* parent,
1911  const char* name )
1912  : TDEAction( item, cut, receiver, slot, parent, name )
1913 {
1914  m_popup = 0;
1915  m_delayed = true;
1916  m_stickyMenu = true;
1917 }
1918 
1919 TDEToolBarPopupAction::~TDEToolBarPopupAction()
1920 {
1921  delete m_popup;
1922 }
1923 
1924 bool TDEToolBarPopupAction::delayed() const {
1925  return m_delayed;
1926 }
1927 
1928 void TDEToolBarPopupAction::setDelayed(bool delayed) {
1929  m_delayed = delayed;
1930 }
1931 
1932 bool TDEToolBarPopupAction::stickyMenu() const {
1933  return m_stickyMenu;
1934 }
1935 
1936 void TDEToolBarPopupAction::setStickyMenu(bool sticky) {
1937  m_stickyMenu = sticky;
1938 }
1939 
1940 int TDEToolBarPopupAction::plug( TQWidget *widget, int index )
1941 {
1942  if (kapp && !kapp->authorizeTDEAction(name()))
1943  return -1;
1944  // This is very related to TDEActionMenu::plug.
1945  // In fact this class could be an interesting base class for TDEActionMenu
1946  if ( ::tqt_cast<TDEToolBar *>( widget ) )
1947  {
1948  TDEToolBar *bar = (TDEToolBar *)widget;
1949 
1950  int id_ = TDEAction::getToolButtonID();
1951 
1952  if ( icon().isEmpty() && !iconSet().isNull() ) {
1953  bar->insertButton( iconSet().pixmap(), id_, TQ_SIGNAL( buttonClicked(int, TQt::ButtonState) ), this,
1954  TQ_SLOT( slotButtonClicked(int, TQt::ButtonState) ),
1955  isEnabled(), plainText(),
1956  index );
1957  } else {
1958  TDEInstance * instance;
1959  if ( m_parentCollection )
1960  instance = m_parentCollection->instance();
1961  else
1962  instance = TDEGlobal::instance();
1963 
1964  bar->insertButton( icon(), id_, TQ_SIGNAL( buttonClicked(int, TQt::ButtonState) ), this,
1965  TQ_SLOT( slotButtonClicked(int, TQt::ButtonState) ),
1966  isEnabled(), plainText(),
1967  index, instance );
1968  }
1969 
1970  addContainer( bar, id_ );
1971 
1972  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
1973 
1974  if (delayed()) {
1975  bar->setDelayedPopup( id_, popupMenu(), stickyMenu() );
1976  } else {
1977  bar->getButton(id_)->setPopup(popupMenu(), stickyMenu());
1978  }
1979 
1980  if ( !whatsThis().isEmpty() )
1981  TQWhatsThis::add( bar->getButton( id_ ), whatsThisWithIcon() );
1982 
1983  return containerCount() - 1;
1984  }
1985 
1986  return TDEAction::plug( widget, index );
1987 }
1988 
1989 TDEPopupMenu *TDEToolBarPopupAction::popupMenu() const
1990 {
1991  if ( !m_popup ) {
1992  TDEToolBarPopupAction *that = const_cast<TDEToolBarPopupAction*>(this);
1993  that->m_popup = new TDEPopupMenu;
1994  }
1995  return m_popup;
1996 }
1997 
1999 
2000 TDEToggleToolBarAction::TDEToggleToolBarAction( const char* toolBarName,
2001  const TQString& text, TDEActionCollection* parent, const char* name )
2002  : TDEToggleAction( text, TDEShortcut(), parent, name )
2003  , m_toolBarName( toolBarName )
2004  , m_toolBar( 0L )
2005 {
2006 }
2007 
2008 TDEToggleToolBarAction::TDEToggleToolBarAction( TDEToolBar *toolBar, const TQString &text,
2009  TDEActionCollection *parent, const char *name )
2010  : TDEToggleAction( text, TDEShortcut(), parent, name )
2011  , m_toolBarName( 0 ), m_toolBar( toolBar )
2012 {
2013 }
2014 
2015 TDEToggleToolBarAction::~TDEToggleToolBarAction()
2016 {
2017 }
2018 
2019 int TDEToggleToolBarAction::plug( TQWidget* w, int index )
2020 {
2021  if (kapp && !kapp->authorizeTDEAction(name()))
2022  return -1;
2023 
2024  if ( !m_toolBar ) {
2025  // Note: topLevelWidget() stops too early, we can't use it.
2026  TQWidget * tl = w;
2027  TQWidget * n;
2028  while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store
2029  tl = n;
2030 
2031  TDEMainWindow * mw = dynamic_cast<TDEMainWindow *>(tl); // try to see if it's a tdemainwindow
2032 
2033  if ( mw )
2034  m_toolBar = mw->toolBar( m_toolBarName );
2035  }
2036 
2037  if( m_toolBar ) {
2038  setChecked( m_toolBar->isVisible() );
2039  connect( m_toolBar, TQ_SIGNAL(visibilityChanged(bool)), this, TQ_SLOT(setChecked(bool)) );
2040  // Also emit toggled when the toolbar's visibility changes (see comment in header)
2041  connect( m_toolBar, TQ_SIGNAL(visibilityChanged(bool)), this, TQ_SIGNAL(toggled(bool)) );
2042  } else {
2043  setEnabled( false );
2044  }
2045 
2046  return TDEToggleAction::plug( w, index );
2047 }
2048 
2049 void TDEToggleToolBarAction::setChecked( bool c )
2050 {
2051  if( m_toolBar && c != m_toolBar->isVisible() ) {
2052  if( c ) {
2053  m_toolBar->show();
2054  } else {
2055  m_toolBar->hide();
2056  }
2057  TQMainWindow* mw = m_toolBar->mainWindow();
2058  if ( mw && ::tqt_cast<TDEMainWindow *>( mw ) )
2059  static_cast<TDEMainWindow *>( mw )->setSettingsDirty();
2060  }
2061  TDEToggleAction::setChecked( c );
2062 }
2063 
2065 
2066 TDEToggleFullScreenAction::TDEToggleFullScreenAction( const TDEShortcut &cut,
2067  const TQObject* receiver, const char* slot,
2068  TQObject* parent, TQWidget* window,
2069  const char* name )
2070  : TDEToggleAction( TQString::null, cut, receiver, slot, parent, name ),
2071  window( NULL )
2072 {
2073  setWindow( window );
2074 }
2075 
2076 TDEToggleFullScreenAction::~TDEToggleFullScreenAction()
2077 {
2078 }
2079 
2080 void TDEToggleFullScreenAction::setWindow( TQWidget* w )
2081 {
2082  if( window )
2083  window->removeEventFilter( this );
2084  window = w;
2085  if( window )
2086  window->installEventFilter( this );
2087 }
2088 
2089 void TDEToggleFullScreenAction::setChecked( bool c )
2090 {
2091  if (c)
2092  {
2093  setText(i18n("Exit F&ull Screen Mode"));
2094  setIcon("view-restore");
2095  }
2096  else
2097  {
2098  setText(i18n("F&ull Screen Mode"));
2099  setIcon("view-fullscreen");
2100  }
2101  TDEToggleAction::setChecked( c );
2102 }
2103 
2104 bool TDEToggleFullScreenAction::eventFilter( TQObject* o, TQEvent* e )
2105 {
2106  if( o == window )
2107  if( e->type() == TQEvent::WindowStateChange )
2108  {
2109  if( window->isFullScreen() != isChecked())
2110  slotActivated(); // setChecked( window->isFullScreen()) wouldn't emit signals
2111  }
2112  return false;
2113 }
2114 
2116 
2117 KWidgetAction::KWidgetAction( TQWidget* widget,
2118  const TQString& text, const TDEShortcut& cut,
2119  const TQObject* receiver, const char* slot,
2120  TDEActionCollection* parent, const char* name )
2121  : TDEAction( text, cut, receiver, slot, parent, name )
2122  , m_widget( widget )
2123  , m_autoSized( false )
2124 {
2125  connect( this, TQ_SIGNAL(enabled(bool)), widget, TQ_SLOT(setEnabled(bool)) );
2126 }
2127 
2128 KWidgetAction::~KWidgetAction()
2129 {
2130 }
2131 
2132 void KWidgetAction::setAutoSized( bool autoSized )
2133 {
2134  if( m_autoSized == autoSized )
2135  return;
2136 
2137  m_autoSized = autoSized;
2138 
2139  if( !m_widget || !isPlugged() )
2140  return;
2141 
2142  TDEToolBar* toolBar = (TDEToolBar*)m_widget->parent();
2143  int i = findContainer( toolBar );
2144  if ( i == -1 )
2145  return;
2146  int id = itemId( i );
2147 
2148  toolBar->setItemAutoSized( id, m_autoSized );
2149 }
2150 
2151 int KWidgetAction::plug( TQWidget* w, int index )
2152 {
2153  if (kapp && !kapp->authorizeTDEAction(name()))
2154  return -1;
2155 
2156  if ( !::tqt_cast<TDEToolBar *>( w ) ) {
2157  kdError() << "KWidgetAction::plug: KWidgetAction must be plugged into TDEToolBar." << endl;
2158  return -1;
2159  }
2160  if ( !m_widget ) {
2161  kdError() << "KWidgetAction::plug: Widget was deleted or null!" << endl;
2162  return -1;
2163  }
2164 
2165  TDEToolBar* toolBar = static_cast<TDEToolBar*>( w );
2166 
2167  int id = TDEAction::getToolButtonID();
2168 
2169  m_widget->reparent( toolBar, TQPoint() );
2170  toolBar->insertWidget( id, 0, m_widget, index );
2171  toolBar->setItemAutoSized( id, m_autoSized );
2172 
2173  TQWhatsThis::add( m_widget, whatsThis() );
2174  addContainer( toolBar, id );
2175 
2176  connect( toolBar, TQ_SIGNAL( toolbarDestroyed() ), this, TQ_SLOT( slotToolbarDestroyed() ) );
2177  connect( toolBar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
2178 
2179  return containerCount() - 1;
2180 }
2181 
2182 void KWidgetAction::unplug( TQWidget *w )
2183 {
2184  if( !m_widget || !isPlugged() )
2185  return;
2186 
2187  TDEToolBar* toolBar = (TDEToolBar*)m_widget->parent();
2188  if ( toolBar == w )
2189  {
2190  disconnect( toolBar, TQ_SIGNAL( toolbarDestroyed() ), this, TQ_SLOT( slotToolbarDestroyed() ) );
2191  m_widget->reparent( 0L, TQPoint(), false /*showIt*/ );
2192  }
2193  TDEAction::unplug( w );
2194 }
2195 
2196 void KWidgetAction::slotToolbarDestroyed()
2197 {
2198  //Q_ASSERT( m_widget ); // When exiting the app the widget could be destroyed before the toolbar.
2199  Q_ASSERT( isPlugged() );
2200  if( !m_widget || !isPlugged() )
2201  return;
2202 
2203  // Don't let a toolbar being destroyed, delete my widget.
2204  m_widget->reparent( 0L, TQPoint(), false /*showIt*/ );
2205 }
2206 
2208 
2209 TDEActionSeparator::TDEActionSeparator( TQObject *parent, const char *name )
2210  : TDEAction( parent, name )
2211 {
2212 }
2213 
2214 TDEActionSeparator::~TDEActionSeparator()
2215 {
2216 }
2217 
2218 int TDEActionSeparator::plug( TQWidget *widget, int index )
2219 {
2220  if ( ::tqt_cast<TQPopupMenu *>( widget) )
2221  {
2222  TQPopupMenu* menu = static_cast<TQPopupMenu*>( widget );
2223 
2224  int id = menu->insertSeparator( index );
2225 
2226  addContainer( menu, id );
2227  connect( menu, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
2228 
2229  return containerCount() - 1;
2230  }
2231  else if ( ::tqt_cast<TQMenuBar *>( widget ) )
2232  {
2233  TQMenuBar *menuBar = static_cast<TQMenuBar *>( widget );
2234 
2235  int id = menuBar->insertSeparator( index );
2236 
2237  addContainer( menuBar, id );
2238 
2239  connect( menuBar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
2240 
2241  return containerCount() - 1;
2242  }
2243  else if ( ::tqt_cast<TDEToolBar *>( widget ) )
2244  {
2245  TDEToolBar *toolBar = static_cast<TDEToolBar *>( widget );
2246 
2247  int id = toolBar->insertSeparator( index );
2248 
2249  addContainer( toolBar, id );
2250 
2251  connect( toolBar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
2252 
2253  return containerCount() - 1;
2254  }
2255 
2256  return -1;
2257 }
2258 
2259 TDEPasteTextAction::TDEPasteTextAction( const TQString& text,
2260  const TQString& icon,
2261  const TDEShortcut& cut,
2262  const TQObject* receiver,
2263  const char* slot, TQObject* parent,
2264  const char* name)
2265  : TDEAction( text, icon, cut, receiver, slot, parent, name )
2266 {
2267  m_popup = new TDEPopupMenu;
2268  connect(m_popup, TQ_SIGNAL(aboutToShow()), this, TQ_SLOT(menuAboutToShow()));
2269  connect(m_popup, TQ_SIGNAL(activated(int)), this, TQ_SLOT(menuItemActivated(int)));
2270  m_popup->setCheckable(true);
2271  m_mixedMode = true;
2272 }
2273 
2274 TDEPasteTextAction::~TDEPasteTextAction()
2275 {
2276  delete m_popup;
2277 }
2278 
2279 void TDEPasteTextAction::setMixedMode(bool mode)
2280 {
2281  m_mixedMode = mode;
2282 }
2283 
2284 int TDEPasteTextAction::plug( TQWidget *widget, int index )
2285 {
2286  if (kapp && !kapp->authorizeTDEAction(name()))
2287  return -1;
2288  if ( ::tqt_cast<TDEToolBar *>( widget ) )
2289  {
2290  TDEToolBar *bar = (TDEToolBar *)widget;
2291 
2292  int id_ = TDEAction::getToolButtonID();
2293 
2294  TDEInstance * instance;
2295  if ( m_parentCollection )
2296  instance = m_parentCollection->instance();
2297  else
2298  instance = TDEGlobal::instance();
2299 
2300  bar->insertButton( icon(), id_, TQ_SIGNAL( clicked() ), this,
2301  TQ_SLOT( slotActivated() ), isEnabled(), plainText(),
2302  index, instance );
2303 
2304  addContainer( bar, id_ );
2305 
2306  connect( bar, TQ_SIGNAL( destroyed() ), this, TQ_SLOT( slotDestroyed() ) );
2307 
2308  bar->setDelayedPopup( id_, m_popup, true );
2309 
2310  if ( !whatsThis().isEmpty() )
2311  TQWhatsThis::add( bar->getButton( id_ ), whatsThisWithIcon() );
2312 
2313  return containerCount() - 1;
2314  }
2315 
2316  return TDEAction::plug( widget, index );
2317 }
2318 
2319 void TDEPasteTextAction::menuAboutToShow()
2320 {
2321  m_popup->clear();
2322  TQStringList list;
2323  DCOPClient *client = kapp->dcopClient();
2324  if (client->isAttached() && client->isApplicationRegistered("klipper")) {
2325  DCOPRef klipper("klipper","klipper");
2326  DCOPReply reply = klipper.call("getClipboardHistoryMenu");
2327  if (reply.isValid())
2328  list = reply;
2329  }
2330  TQString clipboardText = tqApp->clipboard()->text(TQClipboard::Clipboard);
2331  if (list.isEmpty())
2332  list << clipboardText;
2333  bool found = false;
2334  for ( TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it )
2335  {
2336  TQString text = KStringHandler::cEmSqueeze((*it).simplifyWhiteSpace(), m_popup->fontMetrics(), 20);
2337  text.replace("&", "&&");
2338  int id = m_popup->insertItem(text);
2339  if (!found && *it == clipboardText)
2340  {
2341  m_popup->setItemChecked(id, true);
2342  found = true;
2343  }
2344  }
2345 }
2346 
2347 void TDEPasteTextAction::menuItemActivated( int id)
2348 {
2349  DCOPClient *client = kapp->dcopClient();
2350  if (client->isAttached() && client->isApplicationRegistered("klipper")) {
2351  DCOPRef klipper("klipper","klipper");
2352  DCOPReply reply = klipper.call("getClipboardHistoryItem(int)", m_popup->indexOf(id));
2353  if (!reply.isValid())
2354  return;
2355  TQString clipboardText = reply;
2356  reply = klipper.call("setClipboardContents(TQString)", clipboardText);
2357  if (reply.isValid())
2358  kdDebug(129) << "Clipboard: " << TQString(tqApp->clipboard()->text(TQClipboard::Clipboard)) << endl;
2359  }
2360  TQTimer::singleShot(20, this, TQ_SLOT(slotActivated()));
2361 }
2362 
2363 void TDEPasteTextAction::slotActivated()
2364 {
2365  if (!m_mixedMode) {
2366  TQWidget *w = tqApp->widgetAt(TQCursor::pos(), true);
2367  TQMimeSource *data = TQApplication::clipboard()->data();
2368  if (!data->provides("text/plain") && w) {
2369  m_popup->popup(w->mapToGlobal(TQPoint(0, w->height())));
2370  } else
2371  TDEAction::slotActivated();
2372  } else
2373  TDEAction::slotActivated();
2374 }
2375 
2376 
2377 void TDEToggleAction::virtual_hook( int id, void* data )
2378 { TDEAction::virtual_hook( id, data ); }
2379 
2380 void TDERadioAction::virtual_hook( int id, void* data )
2381 { TDEToggleAction::virtual_hook( id, data ); }
2382 
2383 void TDESelectAction::virtual_hook( int id, void* data )
2384 { TDEAction::virtual_hook( id, data ); }
2385 
2386 void TDEListAction::virtual_hook( int id, void* data )
2387 { TDESelectAction::virtual_hook( id, data ); }
2388 
2389 void TDERecentFilesAction::virtual_hook( int id, void* data )
2390 { TDEListAction::virtual_hook( id, data ); }
2391 
2392 void TDEFontAction::virtual_hook( int id, void* data )
2393 { TDESelectAction::virtual_hook( id, data ); }
2394 
2395 void TDEFontSizeAction::virtual_hook( int id, void* data )
2396 { TDESelectAction::virtual_hook( id, data ); }
2397 
2398 void TDEActionMenu::virtual_hook( int id, void* data )
2399 { TDEAction::virtual_hook( id, data ); }
2400 
2401 void TDEToolBarPopupAction::virtual_hook( int id, void* data )
2402 { TDEAction::virtual_hook( id, data ); }
2403 
2404 void TDEToggleToolBarAction::virtual_hook( int id, void* data )
2405 { TDEToggleAction::virtual_hook( id, data ); }
2406 
2407 void TDEToggleFullScreenAction::virtual_hook( int id, void* data )
2408 { TDEToggleAction::virtual_hook( id, data ); }
2409 
2410 void KWidgetAction::virtual_hook( int id, void* data )
2411 { TDEAction::virtual_hook( id, data ); }
2412 
2413 void TDEActionSeparator::virtual_hook( int id, void* data )
2414 { TDEAction::virtual_hook( id, data ); }
2415 
2416 void TDEPasteTextAction::virtual_hook( int id, void* data )
2417 { TDEAction::virtual_hook( id, data ); }
2418 
2419 #include "tdeactionclasses.moc"
DCOPClient
DCOPClient::isApplicationRegistered
bool isApplicationRegistered(const TQCString &remApp)
DCOPClient::isAttached
bool isAttached() const
DCOPRef
DCOPReply
DCOPReply::isValid
bool isValid() const
KGuiItem
An abstract class for GUI data such as ToolTip and Icon.
Definition: kguiitem.h:39
KStringHandler::cEmSqueeze
static TQString cEmSqueeze(const TQString &name, const TQFontMetrics &fontMetrics, uint maxlen=30)
KURL
KURL::path
TQString path() const
KURL::StripFileProtocol
StripFileProtocol
KURL::fileName
TQString fileName(bool _ignore_trailing_slash_in_path=true) const
KURL::isLocalFile
bool isLocalFile() const
KURL::pathOrURL
TQString pathOrURL() const
KURL::fromPathOrURL
static KURL fromPathOrURL(const TQString &text)
KWidgetAction::unplug
virtual void unplug(TQWidget *w)
Unplug the action.
Definition: tdeactionclasses.cpp:2182
KWidgetAction::plug
virtual int plug(TQWidget *widget, int index=-1)
Plug the action.
Definition: tdeactionclasses.cpp:2151
KWidgetAction::widget
TQWidget * widget()
Returns the widget associated with this action.
Definition: tdeactionclasses.h:1328
KWidgetAction::KWidgetAction
KWidgetAction(TQWidget *widget, const TQString &text, const TDEShortcut &cut, const TQObject *receiver, const char *slot, TDEActionCollection *parent, const char *name)
Create an action that will embed widget into a toolbar when plugged.
Definition: tdeactionclasses.cpp:2117
TDEActionCollection
A managed set of TDEAction objects.
Definition: tdeactioncollection.h:79
TDEActionCollection::instance
TDEInstance * instance() const
The instance with which this class is associated.
Definition: tdeactioncollection.cpp:468
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
TDEActionMenu::setDelayed
void setDelayed(bool _delayed)
If set to true, this action will create a delayed popup menu when plugged in a TDEToolbar.
Definition: tdeactionclasses.cpp:1782
TDEActionMenu::setStickyMenu
void setStickyMenu(bool sticky)
If set to true, this action will create a sticky popup menu when plugged in a TDEToolbar.
Definition: tdeactionclasses.cpp:1790
TDEActionMenu::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeactionclasses.cpp:1794
TDEActionMenu::stickyMenu
bool stickyMenu() const
Returns true if this action creates a sticky popup menu.
Definition: tdeactionclasses.cpp:1786
TDEActionMenu::delayed
bool delayed() const
Returns true if this action creates a delayed popup menu when plugged in a TDEToolbar.
Definition: tdeactionclasses.cpp:1778
TDEAction
Class to encapsulate user-driven action or event.
Definition: tdeaction.h:203
TDEAction::iconSet
TQIconSet iconSet() const
Remove in KDE4.
Definition: tdeaction.h:476
TDEAction::setShortcutConfigurable
virtual void setShortcutConfigurable(bool)
Indicate whether the user may configure the action's shortcut.
Definition: tdeaction.cpp:874
TDEAction::isPlugged
virtual bool isPlugged() const
returns whether the action is plugged into any container widget or not.
Definition: tdeaction.cpp:273
TDEAction::slotButtonClicked
void slotButtonClicked(int, TQt::ButtonState state)
Definition: tdeaction.cpp:1156
TDEAction::setEnabled
virtual void setEnabled(bool enable)
Enables or disables this action.
Definition: tdeaction.cpp:832
TDEAction::unplug
virtual void unplug(TQWidget *w)
"Unplug" or remove this action from a given widget.
Definition: tdeaction.cpp:745
TDEAction::isEnabled
virtual bool isEnabled() const
Returns true if this action is enabled.
Definition: tdeaction.cpp:596
TDEAction::toolTip
virtual TQString toolTip() const
Get the tooltip text for the action.
Definition: tdeaction.cpp:623
TDEAction::text
virtual TQString text() const
Get the text associated with this action.
Definition: tdeaction.cpp:928
TDEAction::setText
virtual void setText(const TQString &text)
Sets the text associated with this action.
Definition: tdeaction.cpp:879
TDEAction::whatsThis
virtual TQString whatsThis() const
Get the What's this text for the action.
Definition: tdeaction.cpp:1039
TDEAction::activated
void activated()
Emitted when this action is activated.
TDEAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeaction.cpp:628
TDEAction::guiItem
const KGuiItem & guiItem() const
Return the underlying KGuiItem.
Definition: tdeaction.cpp:1283
TDEAction::getToolButtonID
static int getToolButtonID()
How it works.
Definition: tdeaction.cpp:76
TDEConfigBase::deleteGroup
bool deleteGroup(const TQString &group, bool bDeep=true, bool bGlobal=false)
TDEConfigBase::writePathEntry
void writePathEntry(const TQString &pKey, const TQString &path, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
TDEConfigBase::group
TQString group() const
TDEConfigBase::readPathEntry
TQString readPathEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
TDEConfigBase::setGroup
void setGroup(const TQString &group)
TDEConfig
TDEFontChooser::getFontList
static void getFontList(TQStringList &list, uint fontListCriteria)
Creates a list of font strings.
Definition: tdefontdialog.cpp:674
TDEFontCombo
A combobox that lists the available fonts.
Definition: tdefontcombo.h:36
TDEGlobal::dirs
static TDEStandardDirs * dirs()
TDEGlobal::instance
static TDEInstance * instance()
TDEIcon::Toolbar
Toolbar
TDEIcon::Small
Small
TDEInstance
TDEListAction
Remove this class in KDE-4.0. It doesn't add anything to TDESelectAction.
Definition: tdeactionclasses.h:585
TDEListAction::currentItem
virtual int currentItem() const
Returns the index of the current item.
Definition: tdeactionclasses.cpp:928
TDEListAction::~TDEListAction
virtual ~TDEListAction()
Destructor.
Definition: tdeactionclasses.cpp:908
TDEListAction::setCurrentItem
virtual void setCurrentItem(int index)
Sets the currently checked item.
Definition: tdeactionclasses.cpp:913
TDEListAction::currentText
virtual TQString currentText() const
Returns the text of the currently selected item.
Definition: tdeactionclasses.cpp:923
TDEListAction::TDEListAction
TDEListAction(const TQString &text, const TDEShortcut &cut=TDEShortcut(), TQObject *parent=0, const char *name=0)
Constructs a list action with text and potential keyboard accelerator but nothing else.
Definition: tdeactionclasses.cpp:847
TDEMainWindow
KDE top level main window
Definition: tdemainwindow.h:99
TDEMainWindow::toolBar
TDEToolBar * toolBar(const char *name=0)
Returns a pointer to the toolbar with the specified name.
Definition: tdemainwindow.cpp:1160
TDEPasteTextAction::setMixedMode
void setMixedMode(bool mode)
Controls the behavior of the clipboard history menu popup.
Definition: tdeactionclasses.cpp:2279
TDEPasteTextAction::TDEPasteTextAction
TDEPasteTextAction(const TQString &text, const TQString &icon, const TDEShortcut &cut, const TQObject *receiver, const char *slot, TQObject *parent=0, const char *name=0)
Create a TDEPasteTextAction, with a text, an icon, an accelerator, a slot connected to the action,...
Definition: tdeactionclasses.cpp:2259
TDEPasteTextAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeactionclasses.cpp:2284
TDEPopupMenu
A menu with title items.
Definition: tdepopupmenu.h:123
TDERadioAction::TDERadioAction
TDERadioAction(const TQString &text, const TDEShortcut &cut=TDEShortcut(), TQObject *parent=0, const char *name=0)
Constructs a radio action with text and potential keyboard accelerator but nothing else.
Definition: tdeactionclasses.cpp:273
TDERecentFilesAction
Recent files action.
Definition: tdeactionclasses.h:701
TDERecentFilesAction::~TDERecentFilesAction
virtual ~TDERecentFilesAction()
Destructor.
Definition: tdeactionclasses.cpp:1063
TDERecentFilesAction::TDERecentFilesAction
TDERecentFilesAction(const TQString &text, const TDEShortcut &cut, TQObject *parent, const char *name=0, uint maxItems=10)
Definition: tdeactionclasses.cpp:947
TDERecentFilesAction::loadEntries
void loadEntries(TDEConfig *config, TQString groupname=TQString::null)
Loads the recent files entries from a given TDEConfig object.
Definition: tdeactionclasses.cpp:1167
TDERecentFilesAction::setMaxItems
void setMaxItems(uint maxItems)
Sets the maximum of items in the recent files list.
Definition: tdeactionclasses.cpp:1074
TDERecentFilesAction::clearURLList
void clearURLList()
Removes all entries from the recent files list.
Definition: tdeactionclasses.cpp:1160
TDERecentFilesAction::completeItems
TQStringList completeItems() const
Definition: tdeactionclasses.cpp:1344
TDERecentFilesAction::maxItems
uint maxItems() const
Returns the maximum of items in the recent files list.
Definition: tdeactionclasses.cpp:1069
TDERecentFilesAction::removeURL
void removeURL(const KURL &url)
Remove an URL from the recent files list.
Definition: tdeactionclasses.cpp:1140
TDERecentFilesAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeactionclasses.cpp:1269
TDERecentFilesAction::addURL
void addURL(const KURL &url)
Add URL to recent files list.
Definition: tdeactionclasses.cpp:1097
TDERecentFilesAction::items
virtual TQStringList items() const
Definition: tdeactionclasses.cpp:1330
TDERecentFilesAction::urlSelected
void urlSelected(const KURL &url)
This signal gets emited when the user selects an URL.
TDERecentFilesAction::saveEntries
void saveEntries(TDEConfig *config, TQString groupname=TQString::null)
Saves the current recent files entries to a given TDEConfig object.
Definition: tdeactionclasses.cpp:1212
TDESelectAction
Action for selecting one of several items.
Definition: tdeactionclasses.h:332
TDESelectAction::setMenuAccelsEnabled
void setMenuAccelsEnabled(bool b)
Sets whether any occurrence of the ampersand character ( & ) in items should be interpreted as keyboa...
Definition: tdeactionclasses.cpp:827
TDESelectAction::currentText
virtual TQString currentText() const
Returns the text of the currently selected item.
Definition: tdeactionclasses.cpp:571
TDESelectAction::setEditable
virtual void setEditable(bool)
When this action is plugged into a toolbar, it creates a combobox.
Definition: tdeactionclasses.cpp:807
TDESelectAction::popupMenu
TQPopupMenu * popupMenu() const
Returns a pointer to the popup menu used by this action.
Definition: tdeactionclasses.cpp:486
TDESelectAction::removeAmpersandsInCombo
bool removeAmpersandsInCombo() const
Definition: tdeactionclasses.cpp:822
TDESelectAction::~TDESelectAction
virtual ~TDESelectAction()
Destructor.
Definition: tdeactionclasses.cpp:433
TDESelectAction::menuAccelsEnabled
bool menuAccelsEnabled() const
Definition: tdeactionclasses.cpp:832
TDESelectAction::setCurrentItem
virtual void setCurrentItem(int index)
Sets the currently checked item.
Definition: tdeactionclasses.cpp:440
TDESelectAction::comboWidth
virtual int comboWidth() const
When this action is plugged into a toolbar, it creates a combobox.
Definition: tdeactionclasses.cpp:599
TDESelectAction::items
virtual TQStringList items() const
Definition: tdeactionclasses.cpp:566
TDESelectAction::setItems
virtual void setItems(const TQStringList &lst)
Sets the items to be displayed in this action You need to call this.
Definition: tdeactionclasses.cpp:551
TDESelectAction::setMaxComboViewCount
void setMaxComboViewCount(int n)
Sets the maximum items that are visible at once if the action is a combobox, that is the number of it...
Definition: tdeactionclasses.cpp:481
TDESelectAction::TDESelectAction
TDESelectAction(const TQString &text, const TDEShortcut &cut=TDEShortcut(), TQObject *parent=0, const char *name=0)
Constructs a select action with text and potential keyboard accelerator but nothing else.
Definition: tdeactionclasses.cpp:376
TDESelectAction::isEditable
virtual bool isEditable() const
When this action is plugged into a toolbar, it creates a combobox.
Definition: tdeactionclasses.cpp:812
TDESelectAction::setRemoveAmpersandsInCombo
void setRemoveAmpersandsInCombo(bool b) TDE_DEPRECATED
Definition: tdeactionclasses.cpp:817
TDESelectAction::changeItem
virtual void changeItem(int index, const TQString &text)
Changes the text of item.
Definition: tdeactionclasses.cpp:516
TDESelectAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeactionclasses.cpp:639
TDESelectAction::clear
virtual void clear()
Clears up all the items in this action.
Definition: tdeactionclasses.cpp:744
TDESelectAction::currentItem
virtual int currentItem() const
Returns the index of the current item.
Definition: tdeactionclasses.cpp:579
TDESelectAction::setComboWidth
virtual void setComboWidth(int width)
When this action is plugged into a toolbar, it creates a combobox.
Definition: tdeactionclasses.cpp:467
TDESelectAction::comboItems
TQStringList comboItems() const
Depending on the menuAccelsEnabled property this method will return the actions items in a way for in...
Definition: tdeactionclasses.cpp:725
TDEShortcut
TDEShortcut::remove
void remove(const KKeySequence &keySeq)
TDEStandardDirs::relativeLocation
TQString relativeLocation(const char *type, const TQString &absPath)
TDEToggleAction
Checkbox like action.
Definition: tdeactionclasses.h:69
TDEToggleAction::isChecked
bool isChecked() const
Returns the actual state of the action.
Definition: tdeactionclasses.cpp:244
TDEToggleAction::setCheckedState
void setCheckedState(const KGuiItem &checkedItem)
Defines the text (and icon, tooltip, whatsthis) that should be displayed instead of the normal text,...
Definition: tdeactionclasses.cpp:259
TDEToggleAction::toolTip
virtual TQString toolTip() const
Reimplemented for internal reasons.
Definition: tdeactionclasses.cpp:265
TDEToggleAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeactionclasses.cpp:138
TDEToggleAction::~TDEToggleAction
virtual ~TDEToggleAction()
Destructor.
Definition: tdeactionclasses.cpp:132
TDEToggleAction::TDEToggleAction
TDEToggleAction(const TQString &text, const TDEShortcut &cut=TDEShortcut(), TQObject *parent=0, const char *name=0)
Constructs a toggle action with text and potential keyboard accelerator but nothing else.
Definition: tdeactionclasses.cpp:74
TDEToggleAction::exclusiveGroup
TQString exclusiveGroup() const
Definition: tdeactionclasses.cpp:254
TDEToggleAction::setChecked
virtual void setChecked(bool)
Sets the state of the action.
Definition: tdeactionclasses.cpp:165
TDEToggleAction::setExclusiveGroup
virtual void setExclusiveGroup(const TQString &name)
Defines which "exclusive group" this action is part of.
Definition: tdeactionclasses.cpp:249
TDEToggleFullScreenAction::eventFilter
virtual bool eventFilter(TQObject *o, TQEvent *e)
Definition: tdeactionclasses.cpp:2104
TDEToggleFullScreenAction::setWindow
void setWindow(TQWidget *window)
Sets the window that will be related to this action.
Definition: tdeactionclasses.cpp:2080
TDEToggleFullScreenAction::TDEToggleFullScreenAction
TDEToggleFullScreenAction(const TDEShortcut &cut, const TQObject *receiver, const char *slot, TQObject *parent, TQWidget *window, const char *name)
Create a TDEToggleFullScreenAction.
Definition: tdeactionclasses.cpp:2066
TDEToggleToolBarAction::TDEToggleToolBarAction
TDEToggleToolBarAction(const char *toolBarName, const TQString &text, TDEActionCollection *parent, const char *name)
Create a TDEToggleToolbarAction that manages the toolbar named toolBarName.
Definition: tdeactionclasses.cpp:2000
TDEToggleToolBarAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeactionclasses.cpp:2019
TDEToolBarButton
A toolbar button.
Definition: tdetoolbarbutton.h:45
TDEToolBarButton::setPopup
void setPopup(TQPopupMenu *p, bool unused=false)
Give this button a popup menu.
Definition: tdetoolbarbutton.cpp:365
TDEToolBarButton::on
void on(bool flag=true)
Turn this button on or off.
Definition: tdetoolbarbutton.cpp:715
TDEToolBarPopupAction
This action is a normal action everywhere, except in a toolbar where it also has a popupmenu (optionn...
Definition: tdeactionclasses.h:1095
TDEToolBarPopupAction::stickyMenu
bool stickyMenu() const
Returns true if this action creates a sticky popup menu.
Definition: tdeactionclasses.cpp:1932
TDEToolBarPopupAction::setStickyMenu
void setStickyMenu(bool sticky)
If set to true, this action will create a sticky popup menu when plugged in a TDEToolbar.
Definition: tdeactionclasses.cpp:1936
TDEToolBarPopupAction::plug
virtual int plug(TQWidget *widget, int index=-1)
"Plug" or insert this action into a given widget.
Definition: tdeactionclasses.cpp:1940
TDEToolBarPopupAction::TDEToolBarPopupAction
TDEToolBarPopupAction(const TQString &text, const TQString &icon, const TDEShortcut &cut=TDEShortcut(), TQObject *parent=0, const char *name=0)
Create a TDEToolBarPopupAction, with a text, an icon, an optional accelerator, parent and name.
Definition: tdeactionclasses.cpp:1883
TDEToolBarPopupAction::delayed
bool delayed() const
Returns true if this action creates a delayed popup menu when plugged in a TDEToolbar.
Definition: tdeactionclasses.cpp:1924
TDEToolBarPopupAction::popupMenu
TDEPopupMenu * popupMenu() const
The popup menu that is shown when clicking (some time) on the toolbar button.
Definition: tdeactionclasses.cpp:1989
TDEToolBarPopupAction::setDelayed
void setDelayed(bool delayed)
If set to true, this action will create a delayed popup menu when plugged in a TDEToolbar.
Definition: tdeactionclasses.cpp:1928
TDEToolBar
Floatable toolbar with auto resize.
Definition: tdetoolbar.h:105
TDEToolBar::setItemAutoSized
void setItemAutoSized(int id, bool yes=true)
Set item autosized.
Definition: tdetoolbar.cpp:659
TDEToolBar::insertCombo
int insertCombo(const TQStringList &list, int id, bool writable, const char *signal, const TQObject *receiver, const char *slot, bool enabled=true, const TQString &tooltiptext=TQString::null, int size=70, int index=-1, TQComboBox::Policy policy=TQComboBox::AtBottom)
Inserts a KComboBox with list.
Definition: tdetoolbar.cpp:352
TDEToolBar::setButton
void setButton(int id, bool flag)
Sets a toggle button state.
Definition: tdetoolbar.cpp:529
TDEToolBar::setDelayedPopup
void setDelayedPopup(int id, TQPopupMenu *_popup, bool toggle=false)
Sets a delayed popup for a button.
Definition: tdetoolbar.cpp:497
TDEToolBar::getCombo
KComboBox * getCombo(int id)
Returns a pointer to the combobox with id.
Definition: tdetoolbar.cpp:613
TDEToolBar::insertWidget
int insertWidget(int id, int width, TQWidget *_widget, int index=-1)
Inserts a user-defined widget.
Definition: tdetoolbar.cpp:411
TDEToolBar::clear
void clear()
Remove all items.
Definition: tdetoolbar.cpp:667
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::setToggle
void setToggle(int id, bool flag=true)
Turns button into a toggle button if flag is true.
Definition: tdetoolbar.cpp:513
TDEToolBar::getButton
TDEToolBarButton * getButton(int id)
Returns a pointer to TDEToolBarButton.
Definition: tdetoolbar.cpp:631
TDEToolBar::insertSeparator
int insertSeparator(int index=-1, int id=-1)
Inserts a separator into the toolbar with the given id.
Definition: tdetoolbar.cpp:396
TDEToolBar::setItemEnabled
void setItemEnabled(int id, bool enabled)
Enables/disables item.
Definition: tdetoolbar.cpp:466
endl
kndbgstream & endl(kndbgstream &s)
kdWarning
kdbgstream kdWarning(int area=0)
kdError
kdbgstream kdError(int area=0)
kdDebug
kdbgstream kdDebug(int area=0)
TDEStdAccel::name
TQString name(StdAccel id)
TDEStdAccel::cut
const TDEShortcut & cut()
tdelocale.h

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
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.1
This website is maintained by Timothy Pearson.