27 #include "tdeactionclasses.h"
31 #include <fontconfig/fontconfig.h>
34 #include <tqclipboard.h>
35 #include <tqfontdatabase.h>
36 #include <tqobjectlist.h>
37 #include <tqwhatsthis.h>
42 #include <dcopclient.h>
45 #include <tdeapplication.h>
46 #include <tdeconfig.h>
48 #include <tdefontcombo.h>
49 #include <tdefontdialog.h>
51 #include <tdemainwindow.h>
52 #include <tdemenubar.h>
53 #include <tdepopupmenu.h>
54 #include <tdetoolbar.h>
55 #include <tdetoolbarbutton.h>
57 #include <kstandarddirs.h>
58 #include <kstringhandler.h>
60 class TDEToggleAction::TDEToggleActionPrivate
63 TDEToggleActionPrivate()
70 TQString m_exclusiveGroup;
79 d =
new TDEToggleActionPrivate;
83 const TQObject* receiver,
const char* slot,
84 TQObject* parent,
const char* name )
85 :
TDEAction( text, cut, receiver, slot, parent, name )
87 d =
new TDEToggleActionPrivate;
92 TQObject* parent,
const char* name )
93 :
TDEAction( text, pix, cut, parent, name )
95 d =
new TDEToggleActionPrivate;
100 TQObject* parent,
const char* name )
101 :
TDEAction( text, pix, cut, parent, name )
103 d =
new TDEToggleActionPrivate;
108 const TQObject* receiver,
109 const char* slot, TQObject* parent,
111 :
TDEAction( text, pix, cut, receiver, slot, parent, name )
113 d =
new TDEToggleActionPrivate;
118 const TQObject* receiver,
119 const char* slot, TQObject* parent,
121 :
TDEAction( text, pix, cut, receiver, slot, parent, name )
123 d =
new TDEToggleActionPrivate;
129 d =
new TDEToggleActionPrivate;
134 delete d->m_checkedGuiItem;
140 if ( !::tqqt_cast<TQPopupMenu *>( widget ) && !::tqqt_cast<TDEToolBar *>( widget ) )
142 kdWarning() <<
"Can not plug TDEToggleAction in " << widget->className() <<
endl;
145 if (kapp && !kapp->authorizeTDEAction(name()))
152 if ( ::tqqt_cast<TDEToolBar *>( widget ) ) {
155 bar->
setToggle( itemId( _index ),
true );
160 updateChecked( _index );
167 if ( c == d->m_checked )
173 int len = containerCount();
175 for(
int i = 0; i < len; ++i )
179 const TQObjectList list = parent()->childrenListObject();
180 if ( !list.isEmpty() ) {
181 TQObjectListIt it( list );
182 for( ; it.current(); ++it ) {
183 if ( ::tqqt_cast<TDEToggleAction *>( it.current() ) && it.current() !=
this &&
188 emit a->toggled(
false );
196 void TDEToggleAction::updateChecked(
int id )
198 TQWidget *w = container(
id );
200 if ( ::tqqt_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 );
207 if ( d->m_checkedGuiItem->hasIcon() )
208 pm->changeItem( itemId_, gui->iconSet(
TDEIcon::Small ), gui->text() );
210 pm->changeItem( itemId_, gui->text() );
214 if ( d->m_checkedGuiItem->text() ==
guiItem().text() )
215 pm->setItemChecked( itemId_, d->m_checked );
217 if ( !d->m_checkedGuiItem->whatsThis().isEmpty() )
218 pm->TQMenuData::setWhatsThis( itemId_, gui->whatsThis() );
219 updateShortcut( pm, itemId_ );
222 else if ( ::tqqt_cast<TQMenuBar *>( w ) )
223 static_cast<TQMenuBar*
>(w)->setItemChecked( itemId(
id ), d->m_checked );
224 else if ( ::tqqt_cast<TDEToolBar *>( w ) )
226 TQWidget* r =
static_cast<TDEToolBar*
>( w )->getButton( itemId(
id ) );
227 if ( r && ::tqqt_cast<TDEToolBarButton *>( r ) ) {
228 static_cast<TDEToolBar*
>( w )->setButton( itemId(
id ), d->m_checked );
229 if ( d->m_checkedGuiItem && d->m_checkedGuiItem->hasIcon() ) {
237 void TDEToggleAction::slotActivated()
240 TDEAction::slotActivated();
251 d->m_exclusiveGroup = name;
256 return d->m_exclusiveGroup;
261 delete d->m_checkedGuiItem;
262 d->m_checkedGuiItem =
new KGuiItem( checkedItem );
267 if ( d->m_checkedGuiItem && d->m_checked )
268 return d->m_checkedGuiItem->toolTip();
274 TQObject* parent,
const char* name )
280 const TQObject* receiver,
const char* slot,
281 TQObject* parent,
const char* name )
288 TQObject* parent,
const char* name )
295 TQObject* parent,
const char* name )
302 const TQObject* receiver,
const char* slot,
303 TQObject* parent,
const char* name )
310 const TQObject* receiver,
const char* slot,
311 TQObject* parent,
const char* name )
321 void TDERadioAction::slotActivated()
325 const TQObject *senderObj = TQT_TQOBJECT_CONST(sender());
327 if ( !senderObj || !::tqqt_cast<const TDEToolBarButton *>( senderObj ) )
335 TDEToggleAction::slotActivated();
338 class TDESelectAction::TDESelectActionPrivate
341 TDESelectActionPrivate()
344 m_menuAccelsEnabled =
true;
348 m_maxComboViewCount = -1;
351 bool m_menuAccelsEnabled;
356 int m_maxComboViewCount;
358 TQString makeMenuText(
const TQString &_text )
360 if ( m_menuAccelsEnabled )
362 TQString
text = _text;
364 while ( i < text.length() ) {
365 if ( text[ i ] ==
'&' ) {
366 text.insert( i,
'&' );
377 TQObject* parent,
const char* name )
380 d =
new TDESelectActionPrivate;
384 const TQObject* receiver,
const char* slot,
385 TQObject* parent,
const char* name )
386 :
TDEAction( text, cut, receiver, slot, parent, name )
388 d =
new TDESelectActionPrivate;
393 TQObject* parent,
const char* name )
394 :
TDEAction( text, pix, cut, parent, name )
396 d =
new TDESelectActionPrivate;
401 TQObject* parent,
const char* name )
402 :
TDEAction( text, pix, cut, parent, name )
404 d =
new TDESelectActionPrivate;
409 const TQObject* receiver,
410 const char* slot, TQObject* parent,
412 :
TDEAction( text, pix, cut, receiver, slot, parent, name )
414 d =
new TDESelectActionPrivate;
419 const TQObject* receiver,
420 const char* slot, TQObject* parent,
422 :
TDEAction( text, pix, cut, receiver, slot, parent, name )
424 d =
new TDESelectActionPrivate;
430 d =
new TDESelectActionPrivate;
442 if (
id >= (
int)d->m_list.count() ) {
443 Q_ASSERT(
id < (
int)d->m_list.count());
449 if ( d->m_current >= 0 )
450 d->m_menu->setItemChecked( d->m_current,
false );
452 d->m_menu->setItemChecked(
id,
true );
457 int len = containerCount();
459 for(
int i = 0; i < len; ++i )
460 updateCurrentItem( i );
472 d->m_comboWidth=width;
474 int len = containerCount();
476 for(
int i = 0; i < len; ++i )
477 updateComboWidth( i );
483 d->m_maxComboViewCount = n;
491 d->m_menu =
new TDEPopupMenu(0L,
"TDESelectAction::popupMenu()");
493 if ( d->m_current >= 0 )
494 d->m_menu->setItemChecked( d->m_current,
true );
500 void TDESelectAction::setupMenu()
const
506 TQStringList::ConstIterator it = d->m_list.begin();
507 for( uint
id = 0; it != d->m_list.end(); ++it, ++id ) {
509 if ( !text.isEmpty() )
510 d->m_menu->insertItem( d->makeMenuText( text ),
this, TQT_SLOT( slotActivated(
int ) ), 0, id );
512 d->m_menu->insertSeparator();
518 if ( index < 0 || index >= (
int)d->m_list.count() )
520 kdWarning() <<
"TDESelectAction::changeItem Index out of scope" <<
endl;
524 d->m_list[ index ] =
text;
527 d->m_menu->changeItem( index, d->makeMenuText( text ) );
529 int len = containerCount();
530 for(
int i = 0; i < len; ++i )
539 TQWidget* w = container(
id );
540 if ( ::tqqt_cast<TDEToolBar *>( w ) )
542 TQWidget* r = (
static_cast<TDEToolBar*
>( w ))->getWidget( itemId(
id ) );
543 if ( ::tqqt_cast<TQComboBox *>( r ) )
545 TQComboBox *b =
static_cast<TQComboBox*
>( r );
546 b->changeItem(text, index );
558 int len = containerCount();
559 for(
int i = 0; i < len; ++i )
574 return TQString::null;
584 void TDESelectAction::updateCurrentItem(
int id )
586 if ( d->m_current < 0 )
589 TQWidget* w = container(
id );
590 if ( ::tqqt_cast<TDEToolBar *>( w ) ) {
591 TQWidget* r =
static_cast<TDEToolBar*
>( w )->getWidget( itemId(
id ) );
592 if ( ::tqqt_cast<TQComboBox *>( r ) ) {
593 TQComboBox *b =
static_cast<TQComboBox*
>( r );
594 b->setCurrentItem( d->m_current );
601 return d->m_comboWidth;
604 void TDESelectAction::updateComboWidth(
int id )
606 TQWidget* w = container(
id );
607 if ( ::tqqt_cast<TDEToolBar *>( w ) ) {
608 TQWidget* r =
static_cast<TDEToolBar*
>( w )->getWidget( itemId(
id ) );
609 if ( ::tqqt_cast<TQComboBox *>( r ) ) {
610 TQComboBox *cb =
static_cast<TQComboBox*
>( r );
611 cb->setMinimumWidth( d->m_comboWidth );
612 cb->setMaximumWidth( d->m_comboWidth );
617 void TDESelectAction::updateItems(
int id )
619 kdDebug(129) <<
"TDEAction::updateItems( " <<
id <<
", lst )" <<
endl;
620 TQWidget* w = container(
id );
621 if ( ::tqqt_cast<TDEToolBar *>( w ) ) {
622 TQWidget* r =
static_cast<TDEToolBar*
>( w )->getWidget( itemId(
id ) );
623 if ( ::tqqt_cast<TQComboBox *>( r ) ) {
624 TQComboBox *cb =
static_cast<TQComboBox*
>( r );
627 TQStringList::ConstIterator it = lst.begin();
628 for( ; it != lst.end(); ++it )
629 cb->insertItem( *it );
641 if (kapp && !kapp->authorizeTDEAction(name()))
643 kdDebug(129) <<
"TDESelectAction::plug( " << widget <<
", " << index <<
" )" <<
endl;
644 if ( ::tqqt_cast<TQPopupMenu *>( widget) )
649 TQPopupMenu* menu =
static_cast<TQPopupMenu*
>( widget );
652 id = menu->insertItem(
iconSet(),
text(), d->m_menu, -1, index );
654 id = menu->insertItem(
text(), d->m_menu, -1, index );
657 menu->setItemEnabled(
id,
false );
660 if ( !wth.isEmpty() )
661 menu->TQMenuData::setWhatsThis(
id, wth );
663 addContainer( menu,
id );
664 connect( menu, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
666 return containerCount() - 1;
668 else if ( ::tqqt_cast<TDEToolBar *>( widget ) )
673 TQT_SIGNAL(
activated(
const TQString & ) ),
this,
674 TQT_SLOT( slotActivated(
const TQString & ) ),
isEnabled(),
677 TQComboBox *cb = bar->
getCombo( id_ );
680 if (!
isEditable()) cb->setFocusPolicy(TQ_NoFocus);
681 cb->setMinimumWidth( cb->sizeHint().width() );
682 if ( d->m_comboWidth > 0 )
684 cb->setMinimumWidth( d->m_comboWidth );
685 cb->setMaximumWidth( d->m_comboWidth );
687 cb->setInsertionPolicy( TQComboBox::NoInsertion );
689 if ( d->m_maxComboViewCount != -1 ) cb->setSizeLimit( d->m_maxComboViewCount );
692 addContainer( bar, id_ );
694 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
696 updateCurrentItem( containerCount() - 1 );
698 return containerCount() - 1;
700 else if ( ::tqqt_cast<TQMenuBar *>( widget ) )
705 TQMenuBar* menu =
static_cast<TQMenuBar*
>( widget );
706 int id = menu->insertItem(
text(), d->m_menu, -1, index );
709 menu->setItemEnabled(
id,
false );
712 if ( !wth.isEmpty() )
713 menu->TQMenuData::setWhatsThis(
id, wth );
715 addContainer( menu,
id );
716 connect( menu, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
718 return containerCount() - 1;
721 kdWarning() <<
"Can not plug TDEAction in " << widget->className() <<
endl;
727 if( d->m_menuAccelsEnabled ) {
729 TQStringList::ConstIterator it = d->m_list.begin();
730 for( ; it != d->m_list.end(); ++it )
733 int i = item.find(
'&' );
735 item = item.remove( i, 1 );
749 int len = containerCount();
750 for(
int i = 0; i < len; ++i )
754 void TDESelectAction::updateClear(
int id )
756 TQWidget* w = container(
id );
757 if ( ::tqqt_cast<TDEToolBar *>( w ) ) {
758 TQWidget* r =
static_cast<TDEToolBar*
>( w )->getWidget( itemId(
id ) );
759 if ( ::tqqt_cast<TQComboBox *>( r ) ) {
760 TQComboBox *b =
static_cast<TQComboBox*
>( r );
766 void TDESelectAction::slotActivated(
int id )
768 if ( d->m_current ==
id )
774 TQTimer::singleShot( 0,
this, TQT_SLOT( slotActivated() ) );
777 void TDESelectAction::slotActivated(
const TQString &text )
781 TQStringList lst = d->m_list;
782 if(!lst.contains(text))
789 int i = d->m_list.findIndex( text );
796 TQTimer::singleShot( 0,
this, TQT_SLOT( slotActivated() ) );
799 void TDESelectAction::slotActivated()
801 TDEAction::slotActivated();
829 d->m_menuAccelsEnabled = b;
834 return d->m_menuAccelsEnabled;
837 class TDEListAction::TDEListActionPrivate
840 TDEListActionPrivate()
848 TQObject* parent,
const char* name )
851 d =
new TDEListActionPrivate;
855 const TQObject* receiver,
const char* slot,
856 TQObject* parent,
const char* name )
859 d =
new TDEListActionPrivate;
861 connect(
this, TQT_SIGNAL(
activated(
int ) ), receiver, slot );
866 TQObject* parent,
const char* name )
869 d =
new TDEListActionPrivate;
874 TQObject* parent,
const char* name )
877 d =
new TDEListActionPrivate;
882 const char* slot, TQObject* parent,
886 d =
new TDEListActionPrivate;
888 connect(
this, TQT_SIGNAL(
activated(
int ) ), receiver, slot );
893 const char* slot, TQObject* parent,
897 d =
new TDEListActionPrivate;
899 connect(
this, TQT_SIGNAL(
activated(
int ) ), receiver, slot );
905 d =
new TDEListActionPrivate;
916 d->m_current = index;
933 class TDERecentFilesAction::TDERecentFilesActionPrivate
936 TDERecentFilesActionPrivate()
943 TQMap<TQString, TQString> m_shortNames;
944 TQMap<TQString, KURL> m_urls;
949 TQObject* parent,
const char* name,
953 d =
new TDERecentFilesActionPrivate;
961 const TQObject* receiver,
963 TQObject* parent,
const char* name,
967 d =
new TDERecentFilesActionPrivate;
978 const TQIconSet& pix,
980 TQObject* parent,
const char* name,
984 d =
new TDERecentFilesActionPrivate;
993 TQObject* parent,
const char* name,
997 d =
new TDERecentFilesActionPrivate;
1004 const TQIconSet& pix,
1006 const TQObject* receiver,
1008 TQObject* parent,
const char* name,
1012 d =
new TDERecentFilesActionPrivate;
1023 const TQString& pix,
1025 const TQObject* receiver,
1027 TQObject* parent,
const char* name,
1031 d =
new TDERecentFilesActionPrivate;
1045 d =
new TDERecentFilesActionPrivate;
1051 void TDERecentFilesAction::init()
1055 connect(d->m_popup, TQT_SIGNAL(aboutToShow()),
this, TQT_SLOT(menuAboutToShow()));
1056 connect(d->m_popup, TQT_SIGNAL(
activated(
int)),
this, TQT_SLOT(menuItemActivated(
int)));
1057 connect(
this, TQT_SIGNAL(
activated(
const TQString& ) ),
1058 this, TQT_SLOT( itemSelected(
const TQString& ) ) );
1071 return d->m_maxItems;
1077 uint oldCount = lst.count();
1086 TQString lastItem = lst.last();
1087 d->m_shortNames.erase( lastItem );
1088 d->m_urls.erase( lastItem );
1089 lst.remove( lastItem );
1093 if( lst.count() != oldCount )
1110 const TQStringList::Iterator end = lst.end();
1111 for ( TQStringList::Iterator it = lst.begin(); it != end; ++it )
1113 TQString title = (*it);
1114 if ( title.endsWith( file +
"]" ) )
1117 d->m_urls.erase( title );
1118 d->m_shortNames.erase( title );
1123 if( lst.count() == d->m_maxItems )
1126 const TQString lastItem = lst.last();
1127 d->m_shortNames.erase( lastItem );
1128 d->m_urls.erase( lastItem );
1129 lst.remove( lastItem );
1133 const TQString title = name +
" [" + file +
"]";
1134 d->m_shortNames.insert( title, name );
1135 d->m_urls.insert( title, url );
1136 lst.prepend( title );
1146 TQStringList::Iterator end = lst.end();
1147 for ( TQStringList::Iterator it = lst.begin(); it != end; ++it )
1149 if ( (*it).endsWith( file +
"]" ))
1151 d->m_shortNames.erase( (*it) );
1152 d->m_urls.erase( (*it) );
1163 d->m_shortNames.clear();
1178 oldGroup = config->
group();
1180 if (groupname.isEmpty())
1181 groupname =
"RecentFiles";
1185 for(
unsigned int i = 1 ; i <= d->m_maxItems ; i++ )
1187 key = TQString(
"File%1" ).arg( i );
1195 nameKey = TQString(
"Name%1" ).arg( i );
1197 title = nameValue +
" [" + value +
"]";
1198 if (!value.isNull())
1200 lst.append( title );
1201 d->m_shortNames.insert( title, nameValue );
1202 d->m_urls.insert( title, url );
1219 oldGroup = config->
group();
1221 if (groupname.isEmpty())
1222 groupname =
"RecentFiles";
1227 for(
unsigned int i = 1 ; i <= lst.count() ; i++ )
1230 key = TQString(
"File%1" ).arg( i );
1231 value = d->m_urls[ lst[ i - 1 ] ].pathOrURL();
1233 key = TQString(
"Name%1" ).arg( i );
1234 value = d->m_shortNames[ lst[ i - 1 ] ];
1241 void TDERecentFilesAction::itemSelected(
const TQString& text )
1249 void TDERecentFilesAction::menuItemActivated(
int id )
1251 TQString text = d->m_popup->text(
id);
1258 void TDERecentFilesAction::menuAboutToShow()
1263 for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it )
1265 menu->insertItem(*it);
1271 if (kapp && !kapp->authorizeTDEAction(name()))
1275 if ( ::tqqt_cast<TDEToolBar *>( widget ) )
1282 if ( m_parentCollection )
1283 instance = m_parentCollection->
instance();
1287 bar->
insertButton( icon(), id_, TQT_SIGNAL( clicked() ),
this,
1288 TQT_SLOT( slotClicked() ),
isEnabled(), plainText(),
1291 addContainer( bar, id_ );
1293 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
1298 TQWhatsThis::add( bar->
getButton( id_ ), whatsThisWithIcon() );
1300 return containerCount() - 1;
1306 void TDERecentFilesAction::slotClicked()
1308 TDEAction::slotActivated();
1311 void TDERecentFilesAction::slotActivated(
const TQString& text)
1313 TDEListAction::slotActivated(text);
1317 void TDERecentFilesAction::slotActivated(
int id)
1319 TDEListAction::slotActivated(
id);
1323 void TDERecentFilesAction::slotActivated()
1333 TQStringList result;
1335 for(
unsigned int i = 1 ; i <= lst.count() ; i++ )
1350 class TDEFontAction::TDEFontActionPrivate
1353 TDEFontActionPrivate()
1356 TQStringList m_fonts;
1359 TDEFontAction::TDEFontAction(
const TQString& text,
1364 d =
new TDEFontActionPrivate;
1370 TDEFontAction::TDEFontAction(
const TQString& text,
const TDEShortcut& cut,
1371 const TQObject* receiver,
const char* slot,
1372 TQObject* parent,
const char* name )
1375 d =
new TDEFontActionPrivate;
1381 TDEFontAction::TDEFontAction(
const TQString& text,
const TQIconSet& pix,
1383 TQObject* parent,
const char* name )
1386 d =
new TDEFontActionPrivate;
1392 TDEFontAction::TDEFontAction(
const TQString& text,
const TQString& pix,
1394 TQObject* parent,
const char* name )
1397 d =
new TDEFontActionPrivate;
1403 TDEFontAction::TDEFontAction(
const TQString& text,
const TQIconSet& pix,
1405 const TQObject* receiver,
const char* slot,
1406 TQObject* parent,
const char* name )
1409 d =
new TDEFontActionPrivate;
1415 TDEFontAction::TDEFontAction(
const TQString& text,
const TQString& pix,
1417 const TQObject* receiver,
const char* slot,
1418 TQObject* parent,
const char* name )
1421 d =
new TDEFontActionPrivate;
1427 TDEFontAction::TDEFontAction( uint fontListCriteria,
const TQString& text,
1432 d =
new TDEFontActionPrivate;
1438 TDEFontAction::TDEFontAction( uint fontListCriteria,
const TQString& text,
const TQString& pix,
1440 TQObject* parent,
const char* name )
1443 d =
new TDEFontActionPrivate;
1449 TDEFontAction::TDEFontAction( TQObject* parent,
const char* name )
1452 d =
new TDEFontActionPrivate;
1458 TDEFontAction::~TDEFontAction()
1467 void TDEFontAction::setFont(
const TQString &family )
1469 TQString lowerName = family.lower();
1471 for ( TQStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1473 if ((*it).lower() == lowerName)
1479 i = lowerName.find(
" [");
1482 lowerName = lowerName.left(i);
1484 for ( TQStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1486 if ((*it).lower() == lowerName)
1496 for ( TQStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1498 if ((*it).lower().startsWith(lowerName))
1507 FcPattern *pattern = NULL;
1508 FcConfig *config = NULL;
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());
1519 if ( !realFamily.isEmpty() && realFamily != family )
1520 setFont( realFamily );
1522 kdDebug(129) <<
"Font not found " << family.lower() <<
endl;
1525 int TDEFontAction::plug( TQWidget *w,
int index )
1527 if (kapp && !kapp->authorizeTDEAction(
name()))
1529 if ( ::tqqt_cast<TDEToolBar *>( w ) )
1534 connect( cb, TQT_SIGNAL( activated(
const TQString & ) ),
1535 TQT_SLOT( slotActivated(
const TQString & ) ) );
1536 cb->setEnabled( isEnabled() );
1538 cb->setMinimumWidth( cb->sizeHint().width() );
1540 addContainer( bar, id_ );
1542 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
1544 updateCurrentItem( containerCount() - 1 );
1546 return containerCount() - 1;
1551 class TDEFontSizeAction::TDEFontSizeActionPrivate
1554 TDEFontSizeActionPrivate()
1559 TDEFontSizeAction::TDEFontSizeAction(
const TQString& text,
1561 TQObject* parent,
const char* name )
1567 TDEFontSizeAction::TDEFontSizeAction(
const TQString& text,
1569 const TQObject* receiver,
const char* slot,
1570 TQObject* parent,
const char* name )
1576 TDEFontSizeAction::TDEFontSizeAction(
const TQString& text,
const TQIconSet& pix,
1578 TQObject* parent,
const char* name )
1584 TDEFontSizeAction::TDEFontSizeAction(
const TQString& text,
const TQString& pix,
1586 TQObject* parent,
const char* name )
1592 TDEFontSizeAction::TDEFontSizeAction(
const TQString& text,
const TQIconSet& pix,
1594 const TQObject* receiver,
1595 const char* slot, TQObject* parent,
1602 TDEFontSizeAction::TDEFontSizeAction(
const TQString& text,
const TQString& pix,
1604 const TQObject* receiver,
1605 const char* slot, TQObject* parent,
1612 TDEFontSizeAction::TDEFontSizeAction( TQObject* parent,
const char* name )
1618 TDEFontSizeAction::~TDEFontSizeAction()
1624 void TDEFontSizeAction::init()
1626 d =
new TDEFontSizeActionPrivate;
1628 setEditable(
true );
1629 TQFontDatabase fontDB;
1630 TQValueList<int> sizes = fontDB.standardSizes();
1632 for ( TQValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it )
1633 lst.append( TQString::number( *it ) );
1638 void TDEFontSizeAction::setFontSize(
int size )
1640 if ( size == fontSize() ) {
1641 setCurrentItem( items().findIndex( TQString::number( size ) ) );
1646 kdWarning() <<
"TDEFontSizeAction: Size " << size <<
" is out of range" <<
endl;
1650 int index = items().findIndex( TQString::number( size ) );
1651 if ( index == -1 ) {
1653 TQValueList<int> lst;
1655 TQStringList itemsList = items();
1656 for (TQStringList::Iterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
1657 lst.append( (*it).toInt() );
1663 TQStringList strLst;
1664 for (TQValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it)
1665 strLst.append( TQString::number(*it) );
1668 index = lst.findIndex( size );
1669 setCurrentItem( index );
1672 setCurrentItem( index );
1681 int TDEFontSizeAction::fontSize()
const
1683 return currentText().toInt();
1686 void TDEFontSizeAction::slotActivated(
int index )
1688 TDESelectAction::slotActivated( index );
1690 emit fontSizeChanged( items()[ index ].toInt() );
1693 void TDEFontSizeAction::slotActivated(
const TQString& size )
1695 setFontSize( size.toInt() );
1696 TDESelectAction::slotActivated( size );
1697 emit fontSizeChanged( size.toInt() );
1700 class TDEActionMenu::TDEActionMenuPrivate
1703 TDEActionMenuPrivate()
1705 m_popup =
new TDEPopupMenu(0L,
"TDEActionMenu::TDEActionMenuPrivate");
1707 m_stickyMenu =
true;
1709 ~TDEActionMenuPrivate()
1711 delete m_popup; m_popup = 0;
1718 TDEActionMenu::TDEActionMenu( TQObject* parent,
const char* name )
1721 d =
new TDEActionMenuPrivate;
1725 TDEActionMenu::TDEActionMenu(
const TQString& text, TQObject* parent,
1729 d =
new TDEActionMenuPrivate;
1733 TDEActionMenu::TDEActionMenu(
const TQString& text,
const TQIconSet& icon,
1734 TQObject* parent,
const char* name )
1735 :
TDEAction( text, icon, 0, parent, name )
1737 d =
new TDEActionMenuPrivate;
1741 TDEActionMenu::TDEActionMenu(
const TQString& text,
const TQString& icon,
1742 TQObject* parent,
const char* name )
1743 :
TDEAction( text, icon, 0, parent, name )
1745 d =
new TDEActionMenuPrivate;
1749 TDEActionMenu::~TDEActionMenu()
1752 kdDebug(129) <<
"TDEActionMenu::~TDEActionMenu()" <<
endl;
1756 void TDEActionMenu::popup(
const TQPoint& global )
1758 popupMenu()->popup( global );
1766 void TDEActionMenu::insert(
TDEAction* cmd,
int index )
1769 cmd->
plug( d->m_popup, index );
1772 void TDEActionMenu::remove(
TDEAction* cmd )
1775 cmd->
unplug( d->m_popup );
1779 return d->m_delayed;
1783 d->m_delayed = _delayed;
1787 return d->m_stickyMenu;
1791 d->m_stickyMenu = sticky;
1796 if (kapp && !kapp->authorizeTDEAction(name()))
1798 kdDebug(129) <<
"TDEActionMenu::plug( " << widget <<
", " << index <<
" )" <<
endl;
1799 if ( ::tqqt_cast<TQPopupMenu *>( widget ) )
1801 TQPopupMenu* menu =
static_cast<TQPopupMenu*
>( widget );
1804 id = menu->insertItem(
iconSet(),
text(), d->m_popup, -1, index );
1806 id = menu->insertItem(
text(), d->m_popup, -1, index );
1809 menu->setItemEnabled(
id,
false );
1811 addContainer( menu,
id );
1812 connect( menu, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
1814 if ( m_parentCollection )
1817 return containerCount() - 1;
1819 else if ( ::tqqt_cast<TDEToolBar *>( widget ) )
1825 if ( icon().isEmpty() && !
iconSet().isNull() )
1827 TQT_SLOT( slotActivated() ),
isEnabled(), plainText(),
1833 if ( m_parentCollection )
1834 instance = m_parentCollection->
instance();
1838 bar->
insertButton( icon(), id_, TQT_SIGNAL( clicked() ),
this,
1839 TQT_SLOT( slotActivated() ),
isEnabled(), plainText(),
1843 addContainer( bar, id_ );
1848 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
1856 if ( m_parentCollection )
1859 return containerCount() - 1;
1861 else if ( ::tqqt_cast<TQMenuBar *>( widget ) )
1863 TQMenuBar *bar =
static_cast<TQMenuBar *
>( widget );
1867 id = bar->insertItem(
text(), popupMenu(), -1, index );
1872 addContainer( bar,
id );
1873 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
1875 return containerCount() - 1;
1884 const TQString& icon,
1886 TQObject* parent,
const char* name )
1887 :
TDEAction( text, icon, cut, parent, name )
1891 m_stickyMenu =
true;
1895 const TQString& icon,
1897 const TQObject* receiver,
1898 const char* slot, TQObject* parent,
1900 :
TDEAction( text, icon, cut, receiver, slot, parent, name )
1904 m_stickyMenu =
true;
1909 const TQObject* receiver,
1912 :
TDEAction( item, cut, receiver, slot, parent, name )
1916 m_stickyMenu =
true;
1919 TDEToolBarPopupAction::~TDEToolBarPopupAction()
1933 return m_stickyMenu;
1937 m_stickyMenu = sticky;
1942 if (kapp && !kapp->authorizeTDEAction(name()))
1946 if ( ::tqqt_cast<TDEToolBar *>( widget ) )
1952 if ( icon().isEmpty() && !
iconSet().isNull() ) {
1953 bar->
insertButton(
iconSet().pixmap(), id_, TQT_SIGNAL( buttonClicked(
int, TQt::ButtonState) ),
this,
1959 if ( m_parentCollection )
1960 instance = m_parentCollection->
instance();
1964 bar->
insertButton( icon(), id_, TQT_SIGNAL( buttonClicked(
int, TQt::ButtonState) ),
this,
1970 addContainer( bar, id_ );
1972 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
1981 TQWhatsThis::add( bar->
getButton( id_ ), whatsThisWithIcon() );
1983 return containerCount() - 1;
2003 , m_toolBarName( toolBarName )
2011 , m_toolBarName( 0 ), m_toolBar( toolBar )
2015 TDEToggleToolBarAction::~TDEToggleToolBarAction()
2021 if (kapp && !kapp->authorizeTDEAction(name()))
2028 while ( !tl->isDialog() && ( n = tl->parentWidget() ) )
2034 m_toolBar = mw->
toolBar( m_toolBarName );
2038 setChecked( m_toolBar->isVisible() );
2039 connect( m_toolBar, TQT_SIGNAL(visibilityChanged(
bool)),
this, TQT_SLOT(setChecked(
bool)) );
2041 connect( m_toolBar, TQT_SIGNAL(visibilityChanged(
bool)),
this, TQT_SIGNAL(toggled(
bool)) );
2049 void TDEToggleToolBarAction::setChecked(
bool c )
2051 if( m_toolBar && c != m_toolBar->isVisible() ) {
2057 TQMainWindow* mw = m_toolBar->mainWindow();
2058 if ( mw && ::tqqt_cast<TDEMainWindow *>( mw ) )
2067 const TQObject* receiver,
const char* slot,
2068 TQObject* parent, TQWidget* window,
2070 :
TDEToggleAction( TQString::null, cut, receiver, slot, parent, name ),
2076 TDEToggleFullScreenAction::~TDEToggleFullScreenAction()
2083 window->removeEventFilter(
this );
2086 window->installEventFilter(
this );
2089 void TDEToggleFullScreenAction::setChecked(
bool c )
2093 setText(i18n(
"Exit F&ull Screen Mode"));
2094 setIcon(
"view-restore");
2098 setText(i18n(
"F&ull Screen Mode"));
2099 setIcon(
"view-fullscreen");
2106 if( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(window) )
2107 if( e->type() == TQEvent::WindowStateChange )
2109 if( window->isFullScreen() !=
isChecked())
2119 const TQObject* receiver,
const char* slot,
2121 :
TDEAction( text, cut, receiver, slot, parent, name )
2122 , m_widget( widget )
2123 , m_autoSized( false )
2125 connect(
this, TQT_SIGNAL(enabled(
bool)), widget, TQT_SLOT(
setEnabled(
bool)) );
2128 KWidgetAction::~KWidgetAction()
2132 void KWidgetAction::setAutoSized(
bool autoSized )
2134 if( m_autoSized == autoSized )
2137 m_autoSized = autoSized;
2143 int i = findContainer( toolBar );
2146 int id = itemId( i );
2153 if (kapp && !kapp->authorizeTDEAction(name()))
2156 if ( !::tqqt_cast<TDEToolBar *>( w ) ) {
2157 kdError() <<
"KWidgetAction::plug: KWidgetAction must be plugged into TDEToolBar." <<
endl;
2161 kdError() <<
"KWidgetAction::plug: Widget was deleted or null!" <<
endl;
2169 m_widget->reparent( toolBar, TQPoint() );
2173 TQWhatsThis::add( m_widget,
whatsThis() );
2174 addContainer( toolBar,
id );
2176 connect( toolBar, TQT_SIGNAL( toolbarDestroyed() ),
this, TQT_SLOT( slotToolbarDestroyed() ) );
2177 connect( toolBar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
2179 return containerCount() - 1;
2190 disconnect( toolBar, TQT_SIGNAL( toolbarDestroyed() ),
this, TQT_SLOT( slotToolbarDestroyed() ) );
2191 m_widget->reparent( 0L, TQPoint(),
false );
2196 void KWidgetAction::slotToolbarDestroyed()
2204 m_widget->reparent( 0L, TQPoint(),
false );
2209 TDEActionSeparator::TDEActionSeparator( TQObject *parent,
const char *name )
2214 TDEActionSeparator::~TDEActionSeparator()
2218 int TDEActionSeparator::plug( TQWidget *widget,
int index )
2220 if ( ::tqqt_cast<TQPopupMenu *>( widget) )
2222 TQPopupMenu* menu =
static_cast<TQPopupMenu*
>( widget );
2224 int id = menu->insertSeparator( index );
2226 addContainer( menu,
id );
2227 connect( menu, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
2229 return containerCount() - 1;
2231 else if ( ::tqqt_cast<TQMenuBar *>( widget ) )
2233 TQMenuBar *menuBar =
static_cast<TQMenuBar *
>( widget );
2235 int id = menuBar->insertSeparator( index );
2237 addContainer( menuBar,
id );
2239 connect( menuBar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
2241 return containerCount() - 1;
2243 else if ( ::tqqt_cast<TDEToolBar *>( widget ) )
2249 addContainer( toolBar,
id );
2251 connect( toolBar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
2253 return containerCount() - 1;
2260 const TQString& icon,
2262 const TQObject* receiver,
2263 const char* slot, TQObject* parent,
2265 :
TDEAction( text, icon, cut, receiver, slot, parent, name )
2268 connect(m_popup, TQT_SIGNAL(aboutToShow()),
this, TQT_SLOT(menuAboutToShow()));
2269 connect(m_popup, TQT_SIGNAL(
activated(
int)),
this, TQT_SLOT(menuItemActivated(
int)));
2270 m_popup->setCheckable(
true);
2274 TDEPasteTextAction::~TDEPasteTextAction()
2286 if (kapp && !kapp->authorizeTDEAction(name()))
2288 if ( ::tqqt_cast<TDEToolBar *>( widget ) )
2295 if ( m_parentCollection )
2296 instance = m_parentCollection->
instance();
2300 bar->
insertButton( icon(), id_, TQT_SIGNAL( clicked() ),
this,
2301 TQT_SLOT( slotActivated() ),
isEnabled(), plainText(),
2304 addContainer( bar, id_ );
2306 connect( bar, TQT_SIGNAL( destroyed() ),
this, TQT_SLOT( slotDestroyed() ) );
2311 TQWhatsThis::add( bar->
getButton( id_ ), whatsThisWithIcon() );
2313 return containerCount() - 1;
2319 void TDEPasteTextAction::menuAboutToShow()
2325 DCOPRef klipper(
"klipper",
"klipper");
2326 DCOPReply reply = klipper.call(
"getClipboardHistoryMenu");
2330 TQString clipboardText = tqApp->clipboard()->text(TQClipboard::Clipboard);
2332 list << clipboardText;
2334 for ( TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it )
2337 text.replace(
"&",
"&&");
2338 int id = m_popup->insertItem(text);
2339 if (!found && *it == clipboardText)
2341 m_popup->setItemChecked(
id,
true);
2347 void TDEPasteTextAction::menuItemActivated(
int id)
2351 DCOPRef klipper(
"klipper",
"klipper");
2352 DCOPReply reply = klipper.call(
"getClipboardHistoryItem(int)", m_popup->indexOf(
id));
2355 TQString clipboardText = reply;
2356 reply = klipper.call(
"setClipboardContents(TQString)", clipboardText);
2358 kdDebug(129) <<
"Clipboard: " << TQString(tqApp->clipboard()->text(TQClipboard::Clipboard)) << endl;
2360 TQTimer::singleShot(20,
this, TQT_SLOT(slotActivated()));
2363 void TDEPasteTextAction::slotActivated()
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())));
2371 TDEAction::slotActivated();
2373 TDEAction::slotActivated();
2377 void TDEToggleAction::virtual_hook(
int id,
void* data )
2378 { TDEAction::virtual_hook(
id, data ); }
2380 void TDERadioAction::virtual_hook(
int id,
void* data )
2381 { TDEToggleAction::virtual_hook(
id, data ); }
2383 void TDESelectAction::virtual_hook(
int id,
void* data )
2384 { TDEAction::virtual_hook(
id, data ); }
2386 void TDEListAction::virtual_hook(
int id,
void* data )
2387 { TDESelectAction::virtual_hook(
id, data ); }
2389 void TDERecentFilesAction::virtual_hook(
int id,
void* data )
2390 { TDEListAction::virtual_hook(
id, data ); }
2392 void TDEFontAction::virtual_hook(
int id,
void* data )
2393 { TDESelectAction::virtual_hook(
id, data ); }
2395 void TDEFontSizeAction::virtual_hook(
int id,
void* data )
2396 { TDESelectAction::virtual_hook(
id, data ); }
2398 void TDEActionMenu::virtual_hook(
int id,
void* data )
2399 { TDEAction::virtual_hook(
id, data ); }
2401 void TDEToolBarPopupAction::virtual_hook(
int id,
void* data )
2402 { TDEAction::virtual_hook(
id, data ); }
2404 void TDEToggleToolBarAction::virtual_hook(
int id,
void* data )
2405 { TDEToggleAction::virtual_hook(
id, data ); }
2407 void TDEToggleFullScreenAction::virtual_hook(
int id,
void* data )
2408 { TDEToggleAction::virtual_hook(
id, data ); }
2410 void KWidgetAction::virtual_hook(
int id,
void* data )
2411 { TDEAction::virtual_hook(
id, data ); }
2413 void TDEActionSeparator::virtual_hook(
int id,
void* data )
2414 { TDEAction::virtual_hook(
id, data ); }
2416 void TDEPasteTextAction::virtual_hook(
int id,
void* data )
2417 { TDEAction::virtual_hook(
id, data ); }
2419 #include "tdeactionclasses.moc"