23 #include "kkeydialog.h"
24 #include "kkeybutton.h"
28 #include <tqbuttongroup.h>
31 #include <tqdrawutil.h>
32 #include <tqpainter.h>
33 #include <tqradiobutton.h>
35 #include <tqtoolbutton.h>
36 #include <tqwhatsthis.h>
39 #include <tdeaction.h>
40 #include <tdeaccelaction.h>
41 #include <tdeactionshortcutlist.h>
42 #include <tdeapplication.h>
43 #include <tdeconfig.h>
45 #include <tdeglobal.h>
46 #include <kglobalaccel.h>
47 #include <kiconloader.h>
48 #include <tdelistviewsearchline.h>
50 #include <tdemessagebox.h>
51 #include <tdeshortcut.h>
52 #include <tdeshortcutlist.h>
53 #include <kxmlguifactory.h>
54 #include <tdeaboutdata.h>
55 #include <kstaticdeleter.h>
61 #include <X11/keysymdef.h>
62 #include <tqwhatsthis.h>
65 const int XFocusOut = FocusOut;
66 const int XFocusIn = FocusIn;
67 const int XKeyPress = KeyPress;
68 const int XKeyRelease = KeyRelease;
84 KKeyChooserItem( TQListViewItem* parent, TQListViewItem* after,
TDEShortcutList* pList, uint iAction );
86 TQString actionName()
const;
88 bool isConfigurable()
const
89 {
return m_pList->isConfigurable( m_iAction ); }
91 {
return m_pList->shortcutDefault( m_iAction ); }
93 {
return m_pList->whatsThis( m_iAction ); }
98 virtual TQString text(
int iCol )
const;
99 virtual int compare( TQListViewItem*,
int iCol,
bool bAscending )
const;
109 class KKeyChooserWhatsThis :
public TQWhatsThis
112 KKeyChooserWhatsThis( TQListView* listview )
113 : TQWhatsThis( listview->viewport() ), m_listView( listview ) {}
116 virtual TQString text(
const TQPoint& p );
119 TQListView* m_listView;
126 class KKeyChooserPrivate
129 TQValueList<TDEShortcutList*> rgpLists;
130 TQValueList<TDEShortcutList*> rgpListsAllocated;
136 TQButtonGroup *kbGroup;
138 TQMap<TQString, TDEShortcut> mapGlobals;
144 bool bAllowLetterShortcuts;
147 bool bPreferFourModifierKeys;
157 initGUI( type, bAllowLetterShortcuts );
163 initGUI( Application, bAllowLetterShortcuts );
170 initGUI( Application, bAllowLetterShortcuts );
177 initGUI( ApplicationGlobal,
false );
184 initGUI( type, bAllowLetterShortcuts );
189 bool bCheckAgainstStdKeys,
190 bool bAllowLetterShortcuts,
196 type = (bCheckAgainstStdKeys) ? ApplicationGlobal : Global;
200 initGUI( type, bAllowLetterShortcuts );
205 bool bCheckAgainstStdKeys,
206 bool bAllowLetterShortcuts,
210 ActionType type = (bCheckAgainstStdKeys) ? ApplicationGlobal : Global;
212 initGUI( type, bAllowLetterShortcuts );
221 static TQValueList< KKeyChooser* >* allChoosers = NULL;
224 KKeyChooser::~KKeyChooser()
226 allChoosers->remove(
this );
228 for( uint i = 0; i < d->rgpListsAllocated.count(); i++ )
229 delete d->rgpListsAllocated[i];
235 return insert(pColl, TQString::null);
240 TQString str = title;
241 if ( title.isEmpty() && pColl->
instance()
246 d->rgpListsAllocated.append( pList );
247 d->rgpLists.append( pList );
255 d->rgpListsAllocated.append( pList );
262 d->rgpListsAllocated.append( pList );
268 d->rgpLists.append( pList );
275 kdDebug(125) <<
"KKeyChooser::commitChanges()" <<
endl;
277 TQListViewItemIterator it( d->pList );
278 for( ; it.current(); ++it ) {
279 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>(it.current());
281 pItem->commitChanges();
288 for( uint i = 0; i < d->rgpLists.count(); i++ )
289 d->rgpLists[i]->save();
292 void KKeyChooser::initGUI( ActionType type,
bool bAllowLetterShortcuts )
294 d =
new KKeyChooserPrivate();
297 d->bAllowLetterShortcuts = bAllowLetterShortcuts;
299 d->bPreferFourModifierKeys = TDEGlobalAccel::useFourModifierKeys();
318 topLayout->addLayout(searchLayout, 10);
320 TQToolButton *clearSearch =
new TQToolButton(
this);
321 clearSearch->setTextLabel(i18n(
"Clear Search"),
true);
322 clearSearch->setIconSet(SmallIconSet(TQApplication::reverseLayout() ?
"clear_left" :
"locationbar_erase"));
323 searchLayout->addWidget(clearSearch);
324 TQLabel* slbl =
new TQLabel(i18n(
"&Search:"),
this);
325 searchLayout->addWidget(slbl);
327 searchLayout->addWidget(listViewSearch);
328 slbl->setBuddy(listViewSearch);
329 connect(clearSearch, TQ_SIGNAL(pressed()), listViewSearch, TQ_SLOT(clear()));
331 TQString wtstr = i18n(
"Search interactively for shortcut names (e.g. Copy) "
332 "or combination of keys (e.g. Ctrl+C) by typing them here.");
334 TQWhatsThis::add(slbl, wtstr);
335 TQWhatsThis::add(listViewSearch, wtstr);
342 TQGridLayout *stackLayout =
new TQGridLayout(2, 2, 2);
343 topLayout->addLayout( stackLayout, 10 );
344 stackLayout->setRowStretch( 1, 10 );
348 TQValueList<int> columns;
352 stackLayout->addMultiCellWidget( d->pList, 1, 1, 0, 1 );
354 wtstr = i18n(
"Here you can see a list of key bindings, "
355 "i.e. associations between actions (e.g. 'Copy') "
356 "shown in the left column and keys or combination "
357 "of keys (e.g. Ctrl+V) shown in the right column.");
359 TQWhatsThis::add( d->pList, wtstr );
360 new KKeyChooserWhatsThis( d->pList );
362 d->pList->setAllColumnsShowFocus(
true );
363 d->pList->addColumn(i18n(
"Action"));
364 d->pList->addColumn(i18n(
"Shortcut"));
365 d->pList->addColumn(i18n(
"Alternate"));
367 connect( d->pList, TQ_SIGNAL(currentChanged(TQListViewItem*)),
368 TQ_SLOT(slotListItemSelected(TQListViewItem*)) );
371 connect ( d->pList, TQ_SIGNAL ( doubleClicked ( TQListViewItem *,
const TQPoint &,
int ) ),
372 TQ_SLOT ( captureCurrentItem()) );
373 connect ( d->pList, TQ_SIGNAL ( spacePressed( TQListViewItem* )), TQ_SLOT( captureCurrentItem()));
377 d->fCArea =
new TQGroupBox(
this );
378 topLayout->addWidget( d->fCArea, 1 );
380 d->fCArea->setTitle( i18n(
"Shortcut for Selected Action") );
381 d->fCArea->setFrameStyle( TQFrame::GroupBoxPanel | TQFrame::Plain );
387 grid->addRowSpacing( 0, fontMetrics().lineSpacing() );
389 d->kbGroup =
new TQButtonGroup( d->fCArea );
391 d->kbGroup->setExclusive(
true );
393 m_prbNone =
new TQRadioButton( i18n(
"no key",
"&None"), d->fCArea );
394 d->kbGroup->insert( m_prbNone, NoKey );
395 m_prbNone->setEnabled(
false );
397 grid->addWidget( m_prbNone, 1, 0 );
398 TQWhatsThis::add( m_prbNone, i18n(
"The selected action will not be associated with any key.") );
399 connect( m_prbNone, TQ_SIGNAL(clicked()), TQ_SLOT(slotNoKey()) );
401 m_prbDef =
new TQRadioButton( i18n(
"default key",
"De&fault"), d->fCArea );
402 d->kbGroup->insert( m_prbDef, DefaultKey );
403 m_prbDef->setEnabled(
false );
405 grid->addWidget( m_prbDef, 1, 1 );
406 TQWhatsThis::add( m_prbDef, i18n(
"This will bind the default key to the selected action. Usually a reasonable choice.") );
407 connect( m_prbDef, TQ_SIGNAL(clicked()), TQ_SLOT(slotDefaultKey()) );
409 m_prbCustom =
new TQRadioButton( i18n(
"C&ustom"), d->fCArea );
410 d->kbGroup->insert( m_prbCustom, CustomKey );
411 m_prbCustom->setEnabled(
false );
413 grid->addWidget( m_prbCustom, 1, 2 );
414 TQWhatsThis::add( m_prbCustom, i18n(
"If this option is selected you can create a customized key binding for the"
415 " selected action using the buttons below.") );
416 connect( m_prbCustom, TQ_SIGNAL(clicked()), TQ_SLOT(slotCustomKey()) );
421 grid->addLayout( pushLayout, 1, 3 );
423 d->pbtnShortcut =
new KKeyButton(d->fCArea,
"key");
424 d->pbtnShortcut->setEnabled(
false );
425 connect( d->pbtnShortcut, TQ_SIGNAL(capturedShortcut(
const TDEShortcut&)), TQ_SLOT(capturedShortcut(
const TDEShortcut&)) );
426 grid->addRowSpacing( 1, d->pbtnShortcut->sizeHint().height() + 5 );
428 wtstr = i18n(
"Use this button to choose a new shortcut key. Once you click it, "
429 "you can press the key-combination which you would like to be assigned "
430 "to the currently selected action.");
431 TQWhatsThis::add( d->pbtnShortcut, wtstr );
437 pushLayout->addWidget( d->pbtnShortcut );
438 pushLayout->addStretch( 10 );
440 d->lInfo =
new TQLabel(d->fCArea);
445 grid->addMultiCellWidget( d->lInfo, 2, 2, 0, 3 );
454 connect( kapp, TQ_SIGNAL( settingsChanged(
int )), TQ_SLOT( slotSettingsChanged(
int )));
455 if( allChoosers == NULL )
456 allChoosers = allChoosersDeleter.setObject( allChoosers,
new TQValueList< KKeyChooser* > );
457 allChoosers->append(
this );
464 TDEActionShortcutList *pAList =
dynamic_cast<TDEActionShortcutList*
>(pList);
466 if( m_type == Global || m_type == ApplicationGlobal )
467 d->pList->setSorting( -1 );
470 TQString str = (title.isEmpty() ? i18n(
"Shortcuts") : title);
471 pParentItem = pProgramItem = pItem =
new TDEListViewItem( d->pList, str );
472 pParentItem->setExpandable(
true );
473 pParentItem->setOpen(
true );
474 pParentItem->setSelectable(
false );
475 uint nSize = pList->
count();
476 for( uint iAction = 0; iAction < nSize; iAction++ ) {
477 TQString sName = pList->
name(iAction);
479 if( sName.startsWith(
"Program:" ) ) {
481 pItem->setSelectable(
false );
482 pItem->setExpandable(
true );
483 pItem->setOpen(
true );
484 if( !pProgramItem->firstChild() )
486 pProgramItem = pParentItem = pItem;
487 }
else if( sName.startsWith(
"Group:" ) ) {
489 pItem->setSelectable(
false );
490 pItem->setExpandable(
true );
491 pItem->setOpen(
true );
492 if( pGroupItem && !pGroupItem->firstChild() )
494 pGroupItem = pParentItem = pItem;
495 }
else if( !sName.isEmpty() && sName !=
"unnamed" && pList->
isConfigurable(iAction) ) {
496 pItem =
new KKeyChooserItem( pParentItem, pItem, pList, iAction );
498 pItem->setPixmap(0,pAList->action(iAction)->iconSet().pixmap(TQIconSet::Small,TQIconSet::Normal));
501 if( !pProgramItem->firstChild() )
503 if( pGroupItem && !pGroupItem->firstChild() )
508 void KKeyChooser::updateButtons()
515 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>( d->pList->currentItem() );
519 m_prbNone->setEnabled(
false );
520 m_prbDef->setEnabled(
false );
521 m_prbCustom->setEnabled(
false );
522 d->pbtnShortcut->setEnabled(
false );
523 d->pbtnShortcut->setShortcut(
TDEShortcut(), false );
525 bool bConfigurable = pItem->isConfigurable();
526 bool bQtShortcut = (m_type == Application || m_type == Standard);
527 const TDEShortcut& cutDef = pItem->shortcutDefault();
530 TQString keyStrCfg = pItem->shortcut().
toString();
531 TQString keyStrDef = cutDef.
toString();
533 d->pbtnShortcut->setShortcut( pItem->shortcut(), bQtShortcut );
536 d->lInfo->setText( i18n(
"Default key:") + TQString(
" %1").arg(keyStrDef.isEmpty() ? i18n(
"None") : keyStrDef) );
539 int index = (pItem->shortcut().isNull()) ? NoKey
540 : (pItem->shortcut() == cutDef) ? DefaultKey
542 m_prbNone->setChecked( index == NoKey );
543 m_prbDef->setChecked( index == DefaultKey );
544 m_prbCustom->setChecked( index == CustomKey );
548 m_prbNone->setEnabled( bConfigurable );
549 m_prbDef->setEnabled( bConfigurable && cutDef.
count() != 0 );
550 m_prbCustom->setEnabled( bConfigurable );
551 d->pbtnShortcut->setEnabled( bConfigurable );
555 void KKeyChooser::slotNoKey()
558 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>( d->pList->currentItem() );
567 void KKeyChooser::slotDefaultKey()
570 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>( d->pList->currentItem() );
572 setShortcut( pItem->shortcutDefault() );
575 void KKeyChooser::slotCustomKey()
577 d->pbtnShortcut->captureShortcut();
580 void KKeyChooser::readGlobalKeys()
582 d->mapGlobals.clear();
583 if( m_type == Global )
585 readGlobalKeys( d->mapGlobals );
588 void KKeyChooser::readGlobalKeys( TQMap< TQString, TDEShortcut >& map )
591 TQMap<TQString, TQString>::Iterator it( mapEntry.begin() );
592 for( uint i = 0; it != mapEntry.end(); ++it, i++ )
596 void KKeyChooser::slotSettingsChanged(
int category )
598 if( category == TDEApplication::SETTINGS_SHORTCUTS )
602 void KKeyChooser::fontChange(
const TQFont & )
604 d->fCArea->setMinimumHeight( 4*d->pbtnShortcut->sizeHint().height() );
606 int widget_width = 0;
608 setMinimumWidth( 20+5*(widget_width+10) );
617 kdDebug(125) <<
"KKeyChooser::allDefault()" <<
endl;
619 TQListViewItemIterator it( d->pList );
620 for( ; it.current(); ++it ) {
621 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>(it.current());
623 pItem->setShortcut( pItem->shortcutDefault() );
630 void KKeyChooser::slotListItemSelected( TQListViewItem* )
635 void KKeyChooser::slotListItemDoubleClicked ( TQListViewItem *,
const TQPoint & ,
int )
637 captureCurrentItem();
640 void KKeyChooser::captureCurrentItem()
642 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>( d->pList->currentItem() );
643 if( pItem != NULL && pItem->isConfigurable())
644 d->pbtnShortcut->captureShortcut ( );
649 d->bPreferFourModifierKeys = bPreferFourModifierKeys;
652 void KKeyChooser::capturedShortcut(
const TDEShortcut& cut )
678 void KKeyChooser::syncToConfig(
const TQString& sConfigGroup,
TDEConfigBase* pConfig,
bool bClearUnset )
680 kdDebug(125) <<
"KKeyChooser::syncToConfig( \"" << sConfigGroup <<
"\", " << pConfig <<
" ) start" <<
endl;
685 TQListViewItemIterator it( d->pList );
686 for( ; it.current(); ++it ) {
687 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>(it.current());
689 TQString sEntry = pConfig->
readEntry( pItem->actionName() );
690 if( !sEntry.isNull() || bClearUnset ) {
691 if( sEntry ==
"none" )
692 sEntry = TQString::null;
693 pItem->setShortcut( sEntry );
695 kdDebug(125) << pItem->actionName() <<
" = " << pItem->shortcut().toStringInternal() <<
endl;
699 kdDebug(125) <<
"KKeyChooser::syncToConfig() done" <<
endl;
702 void KKeyChooser::setShortcut(
const TDEShortcut& cut )
705 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>(d->pList->currentItem());
709 for( uint i = 0; i <
cut.
count(); i++ ) {
713 if( !d->bAllowLetterShortcuts &&
key.modFlags() == 0
714 &&
key.sym() < 0x3000 && TQChar(
key.sym()).isLetterOrNumber() ) {
715 TQString s = i18n(
"In order to use the '%1' key as a shortcut, "
716 "it must be combined with the "
717 "Win, Alt, Ctrl, and/or Shift keys." ).arg(TQChar(
key.sym()));
724 if( !isKeyPresent( cut ) ) {
726 pItem->setShortcut( cut );
737 for( uint iSeq = 0; iSeq <
cut.
count(); iSeq++ ) {
738 for( uint iSeq2 = 0; iSeq2 < cut2.
count(); iSeq2++ ) {
749 for( uint iSeq2 = 0; iSeq2 < cut2.
count(); iSeq2++ )
753 bool KKeyChooser::isKeyPresent(
const TDEShortcut& cut,
bool bWarnUser )
755 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>(d->pList->currentItem());
761 bool has_global_chooser =
false;
762 bool has_standard_chooser =
false;
763 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
764 it != allChoosers->end();
766 has_global_chooser |= ((*it)->m_type == Global);
767 has_standard_chooser |= ((*it)->m_type == Standard);
771 if( m_type == ApplicationGlobal || m_type == Global ) {
772 if( !has_standard_chooser ) {
779 if( !has_global_chooser ) {
781 m_type == Global ? pItem->actionName() : TQString::null ))
785 if( isKeyPresentLocally( cut, pItem, bWarnUser ))
789 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
790 it != allChoosers->end();
792 if( (*it) !=
this && (*it)->isKeyPresentLocally( cut, NULL, bWarnUser ))
799 bool KKeyChooser::isKeyPresentLocally(
const TDEShortcut& cut, KKeyChooserItem* ignoreItem,
const TQString& warnText )
801 return isKeyPresentLocally( cut, ignoreItem, !warnText.isNull());
804 bool KKeyChooser::isKeyPresentLocally(
const TDEShortcut& cut, KKeyChooserItem* ignoreItem,
bool bWarnUser )
810 for( TQListViewItemIterator it( d->pList ); it.current(); ++it ) {
811 KKeyChooserItem* pItem2 =
dynamic_cast<KKeyChooserItem*
>(it.current());
812 if( pItem2 && pItem2 != ignoreItem ) {
813 int iSeq = keyConflict( cut, pItem2->shortcut() );
816 if( !promptForReassign(
cut.
seq(iSeq), pItem2->text(0), Application,
this ))
820 removeFromShortcut(cut2, cut);
821 pItem2->setShortcut(cut2);
834 for( uint i = 0; i < cut.
count(); i++ ) {
837 if(
id != TDEStdAccel::AccelNone
851 TQMap< TQString, TDEShortcut > map;
852 readGlobalKeys( map );
857 const TQMap< TQString, TDEShortcut >& map,
const TQString& ignoreAction )
859 TQMap<TQString, TDEShortcut>::ConstIterator it;
860 for( it = map.begin(); it != map.end(); ++it ) {
861 int iSeq = keyConflict( cut, (*it) );
863 if( ignoreAction.isEmpty() || it.key() != ignoreAction ) {
865 if( !promptForReassign( cut.
seq(iSeq), it.
key(), Global, parent ))
867 removeGlobalShortcut( it.key(),
dynamic_cast< KKeyChooser*
>( parent ), (*it), cut);
877 bool was_in_choosers =
false;
878 if( allChoosers != NULL ) {
879 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
880 it != allChoosers->end();
882 if( (*it) != chooser && (*it)->m_type == Standard ) {
883 was_in_choosers |= ( (*it)->removeShortcut( name, cut ));
887 if( !was_in_choosers ) {
890 removeFromShortcut(newCut, cut);
891 int index = std_list.
index( name );
901 bool was_in_choosers =
false;
902 if( allChoosers != NULL ) {
903 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
904 it != allChoosers->end();
906 if( (*it) != chooser && (*it)->m_type == Global ) {
907 was_in_choosers |= ( (*it)->removeShortcut( name, cut ));
911 if( !was_in_choosers ) {
912 TDEAccelActions actions;
914 removeFromShortcut(newCut, cut);
915 actions.insert( name,
"",
"", newCut, newCut);
916 actions.writeActions(
"Global Shortcuts", 0,
true,
true );
920 bool KKeyChooser::removeShortcut(
const TQString& name,
const TDEShortcut &cut )
922 for( TQListViewItemIterator it( d->pList ); it.current(); ++it ) {
923 KKeyChooserItem* pItem2 =
dynamic_cast<KKeyChooserItem*
>(it.current());
924 if( pItem2 && pItem2->actionName() ==
name ) {
927 removeFromShortcut(cut2, cut);
928 pItem2->setShortcut(cut2);
938 void KKeyChooser::_warning(
const KKeySequence& cut, TQString sAction, TQString sTitle )
940 sAction = sAction.stripWhiteSpace();
943 i18n(
"The '%1' key combination has already been allocated "
944 "to the \"%2\" action.\n"
945 "Please choose a unique key combination.").
951 bool KKeyChooser::promptForReassign(
const KKeySequence& cut,
const TQString& sAction, ActionType type, TQWidget* parent )
957 if( type == Standard ) {
958 sTitle = i18n(
"Conflict with Standard Application Shortcut");
959 s = i18n(
"The '%1' key combination has already been allocated "
960 "to the standard action \"%2\".\n"
961 "Do you want to reassign it from that action to the current one?");
963 else if( type == Global ) {
964 sTitle = i18n(
"Conflict with Global Shortcut");
965 s = i18n(
"The '%1' key combination has already been allocated "
966 "to the global action \"%2\".\n"
967 "Do you want to reassign it from that action to the current one?");
970 sTitle = i18n(
"Key Conflict");
971 s = i18n(
"The '%1' key combination has already been allocated "
972 "to the \"%2\" action.\n"
973 "Do you want to reassign it from that action to the current one?");
975 s = s.arg(
cut.
toString()).arg(sAction.stripWhiteSpace());
987 m_cut = m_pList->
shortcut(m_iAction);
990 KKeyChooserItem::KKeyChooserItem( TQListViewItem* parent, TQListViewItem* after,
TDEShortcutList* pList, uint iAction )
996 m_cut = m_pList->
shortcut(m_iAction);
999 TQString KKeyChooserItem::actionName()
const
1001 return m_pList->name(m_iAction);
1004 const TDEShortcut& KKeyChooserItem::shortcut()
const
1009 void KKeyChooserItem::setShortcut(
const TDEShortcut& cut )
1012 m_bModified = (m_cut != m_pList->shortcut(m_iAction));
1013 listView()->repaintItem(
this );
1016 void KKeyChooserItem::commitChanges()
1019 m_pList->setShortcut( m_iAction, m_cut );
1022 TQString KKeyChooserItem::text(
int iCol )
const
1026 TQString s = m_pList->label(m_iAction);
1028 for( uint i = 0; i < s.length(); i++ )
1029 if( s[i] !=
'&' || ( i+1<s.length() && s[i+1] ==
'&' ) )
1033 else if( iCol <= (
int) m_cut.count() )
1036 return TQString::null;
1039 int KKeyChooserItem::compare( TQListViewItem* item,
int iCol,
bool bAscending )
const
1041 KKeyChooserItem* pItem =
dynamic_cast<KKeyChooserItem*
>( item );
1042 if( iCol == 0 && pItem ) {
1043 TQString psName1 = m_pList->name(m_iAction);
1044 TQString psName2 = pItem->m_pList->name(pItem->m_iAction);
1045 TQRegExp rxNumber1(
" (\\d+)$" );
1046 TQRegExp rxNumber2(
" (\\d+)$" );
1047 int iNumber1 = rxNumber1.search( psName1 );
1048 int iNumber2 = rxNumber2.search( psName2 );
1051 if( iNumber1 >= 0 && iNumber1 == iNumber2 && psName1.startsWith( psName2.left( iNumber1+1 ) ) ) {
1052 int n1 = rxNumber1.cap(1).toInt();
1053 int n2 = rxNumber2.cap(1).toInt();
1054 return (n1 < n2) ? -1 : (n1 > n2) ? 1 : 0;
1058 return TQListViewItem::compare( item, iCol, bAscending );
1063 TQString KKeyChooserWhatsThis::text(
const TQPoint& p ) {
1065 return TQString::null;
1067 const TQListViewItem* item = m_listView->itemAt( p );
1068 const KKeyChooserItem* pItem =
dynamic_cast<const KKeyChooserItem*
>(item);
1070 return TQWhatsThis::textFor( m_listView );
1072 const TQString itemWhatsThis = pItem->whatsThis();
1073 if ( itemWhatsThis.isEmpty() )
1074 return TQWhatsThis::textFor( m_listView );
1076 return itemWhatsThis;
1090 KKeyDialog::KKeyDialog( KKeyChooser::ActionType type,
bool bAllowLetterShortcuts, TQWidget *parent,
const char* name )
1091 :
KDialogBase( parent,
name ?
name :
"kkeydialog", true, i18n(
"Configure Shortcuts"), Default|Ok|Cancel, Ok )
1093 m_pKeyChooser =
new KKeyChooser(
this, type, bAllowLetterShortcuts );
1094 setMainWidget( m_pKeyChooser );
1095 connect(
this, TQ_SIGNAL(defaultClicked()), m_pKeyChooser, TQ_SLOT(
allDefault()) );
1099 resize( group.readSizeEntry(
"Dialog Size", &sz ) );
1103 :
KDialogBase( parent, name ? name :
"kkeydialog", true, i18n(
"Configure Shortcuts"), Default|Ok|Cancel, Ok )
1105 m_pKeyChooser =
new KKeyChooser(
this, KKeyChooser::Application, bAllowLetterShortcuts );
1107 connect(
this, TQ_SIGNAL(
defaultClicked()), m_pKeyChooser, TQ_SLOT(allDefault()) );
1117 group.
writeEntry(
"Dialog Size", size(),
true,
true );
1122 return m_pKeyChooser->
insert( pColl );
1127 return m_pKeyChooser->
insert(pColl, title);
1132 int retcode = exec();
1133 if( retcode == Accepted ) {
1135 m_pKeyChooser->
save();
1149 return configure( coll,
true, parent, bSaveSettings);
1154 return configure( keys,
true, parent, bSaveSettings);
1159 return configure( keys,
true, parent, bSaveSettings);
1164 KKeyDialog dlg( bAllowLetterShortcuts, parent );
1165 dlg.m_pKeyChooser->
insert( keys );
1166 bool b = dlg.
configure( bSaveSettings );
1167 if( b && bSaveSettings )
1174 KKeyDialog dlg( KKeyChooser::ApplicationGlobal, bAllowLetterShortcuts, parent );
1175 dlg.m_pKeyChooser->
insert( keys );
1176 bool b = dlg.
configure( bSaveSettings );
1177 if( b && bSaveSettings )
1184 kdDebug(125) <<
"KKeyDialog::configureKeys( TDEActionCollection*, " << bSaveSettings <<
" )" <<
endl;
1185 KKeyDialog dlg( bAllowLetterShortcuts, parent );
1186 dlg.m_pKeyChooser->
insert( coll );
1203 void KKeyChooser::virtual_hook(
int,
void* )
1206 void KKeyDialog::virtual_hook(
int id,
void* data )
1207 { KDialogBase::virtual_hook(
id, data ); }
1209 #include "kkeydialog.moc"
A dialog base class with standard buttons and predefined layouts.
void setMainWidget(TQWidget *widget)
Sets the main user definable widget.
void defaultClicked()
The Default button was pressed.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Widget for configuration of TDEAccel and TDEGlobalAccel.
void allDefault()
Set all keys to their default values (bindings).
KKeyChooser(TQWidget *parent, ActionType type=Application, bool bAllowLetterShortcuts=true)
Constructor.
void listSync()
Rebuild list entries based on underlying map.
static bool checkGlobalShortcutsConflict(const TDEShortcut &cut, bool warnUser, TQWidget *parent)
Checks whether the given shortcut conflicts with global keyboard shortcuts.
void save()
This commits and then saves the actions to disk.
void buildListView(uint iList, const TQString &title=TQString::null)
void commitChanges()
This function writes any shortcut changes back to the original action set(s).
bool insert(TDEActionCollection *)
Insert an action collection, i.e.
static bool checkStandardShortcutsConflict(const TDEShortcut &cut, bool warnUser, TQWidget *parent)
Checks whether the given shortcut conflicts with standard keyboard shortcuts.
void setPreferFourModifierKeys(bool preferFourModifierKeys)
Specifies whether to use the 3 or 4 modifier key scheme.
void keyChange()
Emitted when an action's shortcut has been changed.
Dialog for configuration of TDEActionCollection, TDEAccel, and TDEGlobalAccel.
KKeyDialog(bool bAllowLetterShortcuts=true, TQWidget *parent=0, const char *name=0)
Constructs a KKeyDialog called name as a child of parent.
void commitChanges()
Commit key setting changes so that changed settings actually become active.
virtual ~KKeyDialog()
Destructor.
bool configure(bool bSaveSettings=true)
Run the dialog and call commitChanges() if bSaveSettings is true.
bool insert(TDEActionCollection *)
Insert an action collection, i.e.
TQString toString() const
const KKey & key(uint i) const
static void sorry(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
Display an "Sorry" dialog.
static int warningContinueCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
Display a "warning" dialog.
TQString programName() const
A managed set of TDEAction objects.
TDEInstance * instance() const
The instance with which this class is associated.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
virtual TQMap< TQString, TQString > entryMap(const TQString &pGroup) const
static TDEConfig * config()
const TDEAboutData * aboutData() const
A listview item with support for alternate background colors.
This class makes it easy to add a search line for filtering the items in a listview based on a simple...
void setSearchColumns(const TQValueList< int > &columns)
Sets the list of columns to be searched.
void setListView(TDEListView *lv)
Sets the TDEListView that is filtered by this search line.
This Widget extends the functionality of TQListView to honor the system wide settings for Single Clic...
virtual int index(const TQString &sName) const
virtual uint count() const=0
virtual const TDEShortcut & shortcut(uint index) const=0
virtual TQString name(uint index) const=0
virtual TQString label(uint index) const=0
virtual bool isConfigurable(uint index) const=0
void remove(const KKeySequence &keySeq)
TQString toString() const
const KKeySequence & seq(uint i) const
virtual bool save() const
virtual bool setShortcut(uint index, const TDEShortcut &shortcut)
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
TQString name(StdAccel id)
const TDEShortcut & cut()
TDEShortcut shortcutDefault(StdAccel id)
StdAccel findStdAccel(const KKeySequence &keySeq)
TQString whatsThis(StdAccel id)
TQString label(StdAccel id)
const TDEShortcut & shortcut(StdAccel id)