summaryrefslogtreecommitdiffstats
path: root/tdeui/kkeydialog.cpp
blob: ceab2a0ad683a9499f1b68f68cb3d61c8bcbdd06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
/* This file is part of the KDE libraries
    Copyright (C) 1998 Mark Donohoe <donohoe@kde.org>
    Copyright (C) 1997 Nicolas Hadacek <hadacek@kde.org>
    Copyright (C) 1998 Matthias Ettrich <ettrich@kde.org>
    Copyright (C) 2001 Ellis Whitehead <ellis@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#include "kkeydialog.h"
#include "kkeybutton.h"

#include <string.h>

#include <tqbuttongroup.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqdrawutil.h>
#include <tqpainter.h>
#include <tqradiobutton.h>
#include <tqregexp.h>
#include <tqtoolbutton.h>
#include <tqwhatsthis.h>

#include <kaccel.h>
#include <kaction.h>
#include <kaccelaction.h>
#include <kactionshortcutlist.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kglobalaccel.h>
#include <kiconloader.h>
#include <klistviewsearchline.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kshortcut.h>
#include <kshortcutlist.h>
#include <kxmlguifactory.h>
#include <kaboutdata.h>
#include <kstaticdeleter.h>

#ifdef Q_WS_X11
#define XK_XKB_KEYS
#define XK_MISCELLANY
#include <X11/Xlib.h>	// For x11Event()
#include <X11/keysymdef.h> // For XK_...
#include <tqwhatsthis.h>

#ifdef KeyPress
const int XFocusOut = FocusOut;
const int XFocusIn = FocusIn;
const int XKeyPress = KeyPress;
const int XKeyRelease = KeyRelease;
#undef KeyRelease
#undef KeyPress
#undef FocusOut
#undef FocusIn
#endif // KEYPRESS
#endif // Q_WX_X11

//---------------------------------------------------------------------
// KKeyChooserItem
//---------------------------------------------------------------------

class KKeyChooserItem : public KListViewItem
{
 public:
	KKeyChooserItem( KListView* parent, TQListViewItem* after, KShortcutList* pList, uint iAction );
	KKeyChooserItem( TQListViewItem* parent, TQListViewItem* after, KShortcutList* pList, uint iAction );

	TQString actionName() const;
	const KShortcut& shortcut() const;
	bool isConfigurable() const
		{ return m_pList->isConfigurable( m_iAction ); }
	const KShortcut& shortcutDefault() const
		{ return m_pList->shortcutDefault( m_iAction ); }
        TQString whatsThis() const
        { return m_pList->whatsThis( m_iAction ); }

	void setShortcut( const KShortcut& cut );
	void commitChanges();

	virtual TQString text( int iCol ) const;
	virtual int compare( TQListViewItem*, int iCol, bool bAscending ) const;

 protected:
	KShortcutList* m_pList;
	uint m_iAction;
	bool m_bModified;
	KShortcut m_cut;
};

// WhatsThis on KKeyChooserItems
class KKeyChooserWhatsThis : public TQWhatsThis
{
public:
    KKeyChooserWhatsThis( TQListView* listview )
        : TQWhatsThis( listview->viewport() ), m_listView( listview ) {}

protected:
    virtual TQString text( const TQPoint& p );

private:
    TQListView* m_listView;
};

//---------------------------------------------------------------------
// KKeyChooserPrivate
//---------------------------------------------------------------------

class KKeyChooserPrivate
{
 public:
	TQValueList<KShortcutList*> rgpLists;
	TQValueList<KShortcutList*> rgpListsAllocated;

	KListView *pList;
	TQLabel *lInfo;
	KKeyButton *pbtnShortcut;
	TQGroupBox *fCArea;
	TQButtonGroup *kbGroup;

	TQMap<TQString, KShortcut> mapGlobals;

	// If this is set, then shortcuts require a modifier:
	//  so 'A' would not be valid, whereas 'Ctrl+A' would be.
	// Note, however, that this only applies to printable characters.
	//  'F1', 'Insert', etc., could still be used.
	bool bAllowLetterShortcuts;
	// When set, pressing the 'Default' button will select the aDefaultKeycode4,
	//  otherwise aDefaultKeycode.
	bool bPreferFourModifierKeys;
};

//---------------------------------------------------------------------
// KKeyChooser
//---------------------------------------------------------------------

KKeyChooser::KKeyChooser( TQWidget* parent, ActionType type, bool bAllowLetterShortcuts )
: TQWidget( parent )
{
	initGUI( type, bAllowLetterShortcuts );
}

KKeyChooser::KKeyChooser( KActionCollection* coll, TQWidget* parent, bool bAllowLetterShortcuts )
: TQWidget( parent )
{
	initGUI( Application, bAllowLetterShortcuts );
	insert( coll );
}

KKeyChooser::KKeyChooser( KAccel* pAccel, TQWidget* parent, bool bAllowLetterShortcuts )
: TQWidget( parent )
{
	initGUI( Application, bAllowLetterShortcuts );
	insert( pAccel );
}

KKeyChooser::KKeyChooser( KGlobalAccel* pAccel, TQWidget* parent )
: TQWidget( parent )
{
	initGUI( ApplicationGlobal, false );
	insert( pAccel );
}

KKeyChooser::KKeyChooser( KShortcutList* pList, TQWidget* parent, ActionType type, bool bAllowLetterShortcuts )
: TQWidget( parent )
{
	initGUI( type, bAllowLetterShortcuts );
	insert( pList );
}

KKeyChooser::KKeyChooser( KAccel* actions, TQWidget* parent,
			bool bCheckAgainstStdKeys,
			bool bAllowLetterShortcuts,
			bool bAllowWinKey )
: TQWidget( parent )
{
	ActionType type;
	if( bAllowWinKey )
		type = (bCheckAgainstStdKeys) ? ApplicationGlobal : Global;
	else
		type = Application;

	initGUI( type, bAllowLetterShortcuts );
	insert( actions );
}

KKeyChooser::KKeyChooser( KGlobalAccel* actions, TQWidget* parent,
			bool bCheckAgainstStdKeys,
			bool bAllowLetterShortcuts,
			bool /*bAllowWinKey*/ )
: TQWidget( parent )
{
	ActionType type = (bCheckAgainstStdKeys) ? ApplicationGlobal : Global;

	initGUI( type, bAllowLetterShortcuts );
	insert( actions );
}

// list of all existing KKeyChooser's
// Used when checking global shortcut for a possible conflict
// (just checking against kdeglobals isn't enough, the shortcuts
// might have changed in KKeyChooser and not being saved yet).
// Also used when reassigning a shortcut from one chooser to another.
static TQValueList< KKeyChooser* >* allChoosers = NULL;
static KStaticDeleter< TQValueList< KKeyChooser* > > allChoosersDeleter;

KKeyChooser::~KKeyChooser()
{
        allChoosers->remove( this );
	// Delete allocated KShortcutLists
	for( uint i = 0; i < d->rgpListsAllocated.count(); i++ )
		delete d->rgpListsAllocated[i];
	delete d;
}

bool KKeyChooser::insert( KActionCollection *pColl)
{
    return insert(pColl, TQString::null);
}

bool KKeyChooser::insert( KActionCollection* pColl, const TQString &title )
{
    TQString str = title;
    if ( title.isEmpty() && pColl->instance()
        && pColl->instance()->aboutData() )
        str = pColl->instance()->aboutData()->programName();

	KShortcutList* pList = new KActionShortcutList( pColl );
	d->rgpListsAllocated.append( pList );
	d->rgpLists.append( pList );
	buildListView(d->rgpLists.count() - 1, str);
	return true;
}

bool KKeyChooser::insert( KAccel* pAccel )
{
	KShortcutList* pList = new KAccelShortcutList( pAccel );
	d->rgpListsAllocated.append( pList );
	return insert( pList );
}

bool KKeyChooser::insert( KGlobalAccel* pAccel )
{
	KShortcutList* pList = new KAccelShortcutList( pAccel );
	d->rgpListsAllocated.append( pList );
	return insert( pList );
}

bool KKeyChooser::insert( KShortcutList* pList )
{
	d->rgpLists.append( pList );
	buildListView( d->rgpLists.count() - 1, TQString::null );
	return true;
}

void KKeyChooser::commitChanges()
{
	kdDebug(125) << "KKeyChooser::commitChanges()" << endl;

	TQListViewItemIterator it( d->pList );
	for( ; it.current(); ++it ) {
		KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(it.current());
		if( pItem )
			pItem->commitChanges();
	}
}

void KKeyChooser::save()
{
	commitChanges();
	for( uint i = 0; i < d->rgpLists.count(); i++ )
		d->rgpLists[i]->save();
}

void KKeyChooser::initGUI( ActionType type, bool bAllowLetterShortcuts )
{
  d = new KKeyChooserPrivate();

  m_type = type;
  d->bAllowLetterShortcuts = bAllowLetterShortcuts;

  d->bPreferFourModifierKeys = KGlobalAccel::useFourModifierKeys();

  //
  // TOP LAYOUT MANAGER
  //
  // The following layout is used for the dialog
  //            LIST LABELS LAYOUT
  //            SPLIT LIST BOX WIDGET
  //            CHOOSE KEY GROUP BOX WIDGET
  //            BUTTONS LAYOUT
  // Items are added to topLayout as they are created.
  //

  TQBoxLayout *topLayout = new TQVBoxLayout( this, 0, KDialog::spacingHint() );

  //
  // ADD SEARCHLINE
  //
  TQHBoxLayout* searchLayout = new TQHBoxLayout(0, 0, KDialog::spacingHint());
  topLayout->addLayout(searchLayout, 10);

  TQToolButton *clearSearch = new TQToolButton(this);
  clearSearch->setTextLabel(i18n("Clear Search"), true);
  clearSearch->setIconSet(SmallIconSet(TQApplication::reverseLayout() ? "clear_left" : "locationbar_erase"));
  searchLayout->addWidget(clearSearch);
  TQLabel* slbl = new TQLabel(i18n("&Search:"), this);
  searchLayout->addWidget(slbl);
  KListViewSearchLine* listViewSearch = new KListViewSearchLine(this);
  searchLayout->addWidget(listViewSearch);
  slbl->setBuddy(listViewSearch);
  connect(clearSearch, TQT_SIGNAL(pressed()), listViewSearch, TQT_SLOT(clear()));

  TQString wtstr = i18n("Search interactively for shortcut names (e.g. Copy) "
                       "or combination of keys (e.g. Ctrl+C) by typing them here.");

  TQWhatsThis::add(slbl, wtstr);
  TQWhatsThis::add(listViewSearch, wtstr);

  //
  // CREATE SPLIT LIST BOX
  //
  // fill up the split list box with the action/key pairs.
  //
  TQGridLayout *stackLayout = new TQGridLayout(2, 2, 2);
  topLayout->addLayout( TQT_TQLAYOUT(stackLayout), 10 );
  stackLayout->setRowStretch( 1, 10 ); // Only list will stretch

  d->pList = new KListView( this );
  listViewSearch->setListView(d->pList); // Plug into search line
  TQValueList<int> columns;
  columns.append(0);
  listViewSearch->setSearchColumns(columns);

  stackLayout->addMultiCellWidget( d->pList, 1, 1, 0, 1 );

  wtstr = i18n("Here you can see a list of key bindings, "
                       "i.e. associations between actions (e.g. 'Copy') "
                       "shown in the left column and keys or combination "
                       "of keys (e.g. Ctrl+V) shown in the right column.");

  TQWhatsThis::add( d->pList, wtstr );
  new KKeyChooserWhatsThis( d->pList );

  d->pList->setAllColumnsShowFocus( true );
  d->pList->addColumn(i18n("Action"));
  d->pList->addColumn(i18n("Shortcut"));
  d->pList->addColumn(i18n("Alternate"));

  connect( d->pList, TQT_SIGNAL(currentChanged(TQListViewItem*)),
           TQT_SLOT(slotListItemSelected(TQListViewItem*)) );

  // handle double clicking an item
  connect ( d->pList, TQT_SIGNAL ( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ),
                       TQT_SLOT ( captureCurrentItem()) );
  connect ( d->pList, TQT_SIGNAL ( spacePressed( TQListViewItem* )), TQT_SLOT( captureCurrentItem()));
  //
  // CREATE CHOOSE KEY GROUP
  //
  d->fCArea = new TQGroupBox( this );
  topLayout->addWidget( d->fCArea, 1 );

  d->fCArea->setTitle( i18n("Shortcut for Selected Action") );
  d->fCArea->setFrameStyle( TQFrame::GroupBoxPanel | TQFrame::Plain );

  //
  // CHOOSE KEY GROUP LAYOUT MANAGER
  //
  TQGridLayout *grid = new TQGridLayout( d->fCArea, 3, 4, KDialog::spacingHint() );
  grid->addRowSpacing( 0, fontMetrics().lineSpacing() );

  d->kbGroup = new TQButtonGroup( d->fCArea );
  d->kbGroup->hide();
  d->kbGroup->setExclusive( true );

  m_prbNone = new TQRadioButton( i18n("no key", "&None"), d->fCArea );
  d->kbGroup->insert( m_prbNone, NoKey );
  m_prbNone->setEnabled( false );
  //grid->addMultiCellWidget( rb, 1, 1, 1, 2 );
  grid->addWidget( m_prbNone, 1, 0 );
  TQWhatsThis::add( m_prbNone, i18n("The selected action will not be associated with any key.") );
  connect( m_prbNone, TQT_SIGNAL(clicked()), TQT_SLOT(slotNoKey()) );

  m_prbDef = new TQRadioButton( i18n("default key", "De&fault"), d->fCArea );
  d->kbGroup->insert( m_prbDef, DefaultKey );
  m_prbDef->setEnabled( false );
  //grid->addMultiCellWidget( rb, 2, 2, 1, 2 );
  grid->addWidget( m_prbDef, 1, 1 );
  TQWhatsThis::add( m_prbDef, i18n("This will bind the default key to the selected action. Usually a reasonable choice.") );
  connect( m_prbDef, TQT_SIGNAL(clicked()), TQT_SLOT(slotDefaultKey()) );

  m_prbCustom = new TQRadioButton( i18n("C&ustom"), d->fCArea );
  d->kbGroup->insert( m_prbCustom, CustomKey );
  m_prbCustom->setEnabled( false );
  //grid->addMultiCellWidget( rb, 3, 3, 1, 2 );
  grid->addWidget( m_prbCustom, 1, 2 );
  TQWhatsThis::add( m_prbCustom, i18n("If this option is selected you can create a customized key binding for the"
    " selected action using the buttons below.") );
  connect( m_prbCustom, TQT_SIGNAL(clicked()), TQT_SLOT(slotCustomKey()) );

  //connect( d->kbGroup, TQT_SIGNAL( clicked( int ) ), TQT_SLOT( keyMode( int ) ) );

  TQBoxLayout *pushLayout = new TQHBoxLayout( KDialog::spacingHint() );
  grid->addLayout( pushLayout, 1, 3 );

  d->pbtnShortcut = new KKeyButton(d->fCArea, "key");
  d->pbtnShortcut->setEnabled( false );
  connect( d->pbtnShortcut, TQT_SIGNAL(capturedShortcut(const KShortcut&)), TQT_SLOT(capturedShortcut(const KShortcut&)) );
  grid->addRowSpacing( 1, d->pbtnShortcut->sizeHint().height() + 5 );

  wtstr = i18n("Use this button to choose a new shortcut key. Once you click it, "
  		"you can press the key-combination which you would like to be assigned "
		"to the currently selected action.");
  TQWhatsThis::add( d->pbtnShortcut, wtstr );

  //
  // Add widgets to the geometry manager
  //
  pushLayout->addSpacing( KDialog::spacingHint()*2 );
  pushLayout->addWidget( d->pbtnShortcut );
  pushLayout->addStretch( 10 );

  d->lInfo = new TQLabel(d->fCArea);
  //resize(0,0);
  //d->lInfo->tqsetAlignment( AlignCenter );
  //d->lInfo->setEnabled( false );
  //d->lInfo->hide();
  grid->addMultiCellWidget( d->lInfo, 2, 2, 0, 3 );

  //d->globalDict = new TQDict<int> ( 100, false );
  //d->globalDict->setAutoDelete( true );
  readGlobalKeys();
  //d->stdDict = new TQDict<int> ( 100, false );
  //d->stdDict->setAutoDelete( true );
  //if (type == Application || type == ApplicationGlobal)
  //  readStdKeys();
  connect( kapp, TQT_SIGNAL( settingsChanged( int )), TQT_SLOT( slotSettingsChanged( int )));
  if( allChoosers == NULL )
        allChoosers = allChoosersDeleter.setObject( allChoosers, new TQValueList< KKeyChooser* > );
  allChoosers->append( this );
}

// Add all shortcuts to the list
void KKeyChooser::buildListView( uint iList, const TQString &title )
{
	KShortcutList* pList = d->rgpLists[iList];
	KActionShortcutList *pAList = dynamic_cast<KActionShortcutList*>(pList);

        if( m_type == Global || m_type == ApplicationGlobal )
	    d->pList->setSorting( -1 );
	KListViewItem *pProgramItem, *pGroupItem = 0, *pParentItem, *pItem;

	TQString str = (title.isEmpty() ? i18n("Shortcuts") : title);
	pParentItem = pProgramItem = pItem = new KListViewItem( d->pList, str );
	pParentItem->setExpandable( true );
	pParentItem->setOpen( true );
	pParentItem->setSelectable( false );
	uint nSize = pList->count();
	for( uint iAction = 0; iAction < nSize; iAction++ ) {
		TQString sName = pList->name(iAction);
		kdDebug(125) << "Key: " << sName << endl;
		if( sName.startsWith( "Program:" ) ) {
			pItem = new KListViewItem( d->pList, pProgramItem, pList->label(iAction) );
			pItem->setSelectable( false );
			pItem->setExpandable( true );
			pItem->setOpen( true );
			if( !pProgramItem->firstChild() )
				delete pProgramItem;
			pProgramItem = pParentItem = pItem;
		} else if( sName.startsWith( "Group:" ) ) {
			pItem = new KListViewItem( pProgramItem, pParentItem, pList->label(iAction) );
			pItem->setSelectable( false );
			pItem->setExpandable( true );
			pItem->setOpen( true );
			if( pGroupItem && !pGroupItem->firstChild() )
				delete pGroupItem;
			pGroupItem = pParentItem = pItem;
		} else if( !sName.isEmpty() && sName != "unnamed"  && pList->isConfigurable(iAction) ) {
			pItem = new KKeyChooserItem( pParentItem, pItem, pList, iAction );
			if(pAList)
				pItem->setPixmap(0,pAList->action(iAction)->iconSet().pixmap(TQIconSet::Small,TQIconSet::Normal));
		}
	}
	if( !pProgramItem->firstChild() )
		delete pProgramItem;
	if( pGroupItem && !pGroupItem->firstChild() )
		delete pGroupItem;
}


void KKeyChooser::updateButtons()
{
	// Hack: Do this incase we still have changeKey() running.
	//  Better would be to capture the mouse pointer so that we can't click
	//   around while we're supposed to be entering a key.
	//  Better yet would be a modal dialog for changeKey()!
	releaseKeyboard();
	KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );

	if ( !pItem ) {
		// if nothing is selected -> disable radio boxes
		m_prbNone->setEnabled( false );
		m_prbDef->setEnabled( false );
		m_prbCustom->setEnabled( false );
		d->pbtnShortcut->setEnabled( false );
		d->pbtnShortcut->setShortcut( KShortcut(), false );
	} else {
		bool bConfigurable = pItem->isConfigurable();
		bool bQtShortcut = (m_type == Application || m_type == Standard);
		const KShortcut& cutDef = pItem->shortcutDefault();

		// Set key strings
		TQString keyStrCfg = pItem->shortcut().toString();
		TQString keyStrDef = cutDef.toString();

		d->pbtnShortcut->setShortcut( pItem->shortcut(), bQtShortcut );
		//item->setText( 1, keyStrCfg );
		pItem->tqrepaint();
		d->lInfo->setText( i18n("Default key:") + TQString(" %1").arg(keyStrDef.isEmpty() ? i18n("None") : keyStrDef) );

		// Select the appropriate radio button.
		int index = (pItem->shortcut().isNull()) ? NoKey
				: (pItem->shortcut() == cutDef) ? DefaultKey
				: CustomKey;
		m_prbNone->setChecked( index == NoKey );
		m_prbDef->setChecked( index == DefaultKey );
		m_prbCustom->setChecked( index == CustomKey );

		// Enable buttons if this key is configurable.
		// The 'Default Key' button must also have a default key.
		m_prbNone->setEnabled( bConfigurable );
		m_prbDef->setEnabled( bConfigurable && cutDef.count() != 0 );
		m_prbCustom->setEnabled( bConfigurable );
		d->pbtnShortcut->setEnabled( bConfigurable );
	}
}

void KKeyChooser::slotNoKey()
{
	// return if no key is selected
	KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );
	if( pItem ) {
		//kdDebug(125) << "no Key" << d->pList->currentItem()->text(0) << endl;
		pItem->setShortcut( KShortcut() );
		updateButtons();
		emit keyChange();
	}
}

void KKeyChooser::slotDefaultKey()
{
	// return if no key is selected
	KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );
	if( pItem ) // don't set it directly, check for conflicts
		setShortcut( pItem->shortcutDefault() );
}

void KKeyChooser::slotCustomKey()
{
	d->pbtnShortcut->captureShortcut();
}

void KKeyChooser::readGlobalKeys()
{
        d->mapGlobals.clear();
        if( m_type == Global )
            return; // they will be checked normally, because we're configuring them
        readGlobalKeys( d->mapGlobals );
}

void KKeyChooser::readGlobalKeys( TQMap< TQString, KShortcut >& map )
{
	TQMap<TQString, TQString> mapEntry = KGlobal::config()->entryMap( "Global Shortcuts" );
	TQMap<TQString, TQString>::Iterator it( mapEntry.begin() );
	for( uint i = 0; it != mapEntry.end(); ++it, i++ )
		map[it.key()] = KShortcut(*it);
}

void KKeyChooser::slotSettingsChanged( int category )
{
    if( category == KApplication::SETTINGS_SHORTCUTS )
        readGlobalKeys(); // reread
}

void KKeyChooser::fontChange( const TQFont & )
{
        d->fCArea->setMinimumHeight( 4*d->pbtnShortcut->sizeHint().height() );

        int widget_width = 0;

        setMinimumWidth( 20+5*(widget_width+10) );
}

// KDE4 IMHO this shouldn't be here at all - it cannot check whether the default
// shortcut don't conflict with some already changed ones (e.g. global shortcuts).
// Also, I personally find reseting all shortcuts to default (i.e. hardcoded in the app)
// ones after pressing the 'Default' button rather a misfeature.
void KKeyChooser::allDefault()
{
	kdDebug(125) << "KKeyChooser::allDefault()" << endl;

	TQListViewItemIterator it( d->pList );
	for( ; it.current(); ++it ) {
		KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(it.current());
		if( pItem )
			pItem->setShortcut( pItem->shortcutDefault() );
	}

	updateButtons();
	emit keyChange();
}

void KKeyChooser::slotListItemSelected( TQListViewItem* )
{
	updateButtons();
}

void KKeyChooser::slotListItemDoubleClicked ( TQListViewItem *, const TQPoint & , int )
{ // KDE4 dump this
  captureCurrentItem();
}

void KKeyChooser::captureCurrentItem()
{
  KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );
  if( pItem != NULL && pItem->isConfigurable())
      d->pbtnShortcut->captureShortcut ( );
}

void KKeyChooser::setPreferFourModifierKeys( bool bPreferFourModifierKeys )
{
	d->bPreferFourModifierKeys = bPreferFourModifierKeys;
}

void KKeyChooser::capturedShortcut( const KShortcut& cut )
{
	if( cut.isNull() )
		slotNoKey();
	else
		setShortcut( cut );
}

// FIXME: give this functionality again -- I don't think it's ever used, though. -- ellis
// TODO: Check lxr.kde.org to see if it's used anywhere
void KKeyChooser::listSync()
{
/*	kdDebug(125) << "KKeyChooser::listSync()" << endl;

	if( d->pColl ) {
		// TODO: This is very inefficient.  Come up with something better.
		KAccelActions aa;
		d->pColl->createKeyMap( aa );
		d->actionsNew.updateShortcuts( aa );
	} else if( d->pActionsOrig ) {
		d->actionsNew.updateShortcuts( *d->pActionsOrig );
		update();
		updateButtons();
	}*/
}

void KKeyChooser::syncToConfig( const TQString& sConfigGroup, KConfigBase* pConfig, bool bClearUnset )
{
	kdDebug(125) << "KKeyChooser::syncToConfig( \"" << sConfigGroup << "\", " << pConfig << " ) start" << endl;
	if( !pConfig )
		pConfig = KGlobal::config();
	KConfigGroupSaver cgs( pConfig, sConfigGroup );

	TQListViewItemIterator it( d->pList );
	for( ; it.current(); ++it ) {
		KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(it.current());
		if( pItem ) {
			TQString sEntry = pConfig->readEntry( pItem->actionName() );
			if( !sEntry.isNull() || bClearUnset ) {
				if( sEntry == "none" )
					sEntry = TQString::null;
				pItem->setShortcut( sEntry );
			}
			kdDebug(125) << pItem->actionName() << " = " << pItem->shortcut().toStringInternal() << endl;
		}
	}
	updateButtons();
	kdDebug(125) << "KKeyChooser::syncToConfig() done" << endl;
}

void KKeyChooser::setShortcut( const KShortcut& cut )
{
	kdDebug(125) << "KKeyChooser::setShortcut( " << cut.toString() << " )" << endl;
	KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(d->pList->currentItem());
	if( !pItem )
		return;

	for( uint i = 0; i < cut.count(); i++ ) {
		const KKeySequence& seq = cut.seq(i);
		const KKey& key = seq.key(0);

		if( !d->bAllowLetterShortcuts && key.modFlags() == 0
		    && key.sym() < 0x3000 && TQChar(key.sym()).isLetterOrNumber() ) {
			TQString s = i18n( 	"In order to use the '%1' key as a shortcut, "
						"it must be combined with the "
						"Win, Alt, Ctrl, and/or Shift keys." ).arg(TQChar(key.sym()));
			KMessageBox::sorry( this, s, i18n("Invalid Shortcut Key") );
			return;
		}
	}

	// If key isn't already in use,
	if( !isKeyPresent( cut ) ) {
		// Set new key code
		pItem->setShortcut( cut );
		// Update display
		updateButtons();
		emit keyChange();
	}
}

// Returns iSeq index if cut2 has a sequence of equal or higher priority to a sequence in cut.
// else -1
static int keyConflict( const KShortcut& cut, const KShortcut& cut2 )
{
	for( uint iSeq = 0; iSeq < cut.count(); iSeq++ ) {
		for( uint iSeq2 = 0; iSeq2 < cut2.count(); iSeq2++ ) {
			if( cut.seq(iSeq) == cut2.seq(iSeq2) )
				return iSeq;
		}
	}
	return -1;
}

// Removes the sequences in cut2 from cut1
static void removeFromShortcut(  KShortcut & cut1, const KShortcut &cut2)
{
	for( uint iSeq2 = 0; iSeq2 < cut2.count(); iSeq2++ )
		cut1.remove(cut2.seq(iSeq2));
}

bool KKeyChooser::isKeyPresent( const KShortcut& cut, bool bWarnUser )
{
	KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(d->pList->currentItem());

	if (!pItem) {
		return false;
	}

        bool has_global_chooser = false;
        bool has_standard_chooser = false;
        for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
             it != allChoosers->end();
             ++it ) {
            has_global_chooser |= ((*it)->m_type == Global);
            has_standard_chooser |= ((*it)->m_type == Standard);
        }

	// If editing global shortcuts, check them for conflicts with the stdaccels.
	if( m_type == ApplicationGlobal || m_type == Global ) {
            if( !has_standard_chooser ) {
                if( checkStandardShortcutsConflict( cut, bWarnUser, this ))
                    return true;
            }
	}

        // only check the global keys if one of the keychoosers isn't global
        if( !has_global_chooser ) {
            if( checkGlobalShortcutsConflict( cut, bWarnUser, this, d->mapGlobals,
                m_type == Global ? pItem->actionName() : TQString::null ))
                return true;
        }

        if( isKeyPresentLocally( cut, pItem, bWarnUser ))
            return true;

        // check also other KKeyChooser's
        for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
             it != allChoosers->end();
             ++it ) {
            if( (*it) != this && (*it)->isKeyPresentLocally( cut, NULL, bWarnUser ))
                    return true;
            }
	return false;
}

// KDE4 remove
bool KKeyChooser::isKeyPresentLocally( const KShortcut& cut, KKeyChooserItem* ignoreItem, const TQString& warnText )
{
    return isKeyPresentLocally( cut, ignoreItem, !warnText.isNull());
}

bool KKeyChooser::isKeyPresentLocally( const KShortcut& cut, KKeyChooserItem* ignoreItem, bool bWarnUser )
{
    if ( cut.toString().isEmpty())
        return false;
	// Search for shortcut conflicts with other actions in the
	//  lists we're configuring.
	for( TQListViewItemIterator it( d->pList ); it.current(); ++it ) {
		KKeyChooserItem* pItem2 = dynamic_cast<KKeyChooserItem*>(it.current());
		if( pItem2 && pItem2 != ignoreItem ) {
			int iSeq = keyConflict( cut, pItem2->shortcut() );
			if( iSeq > -1 ) {
				if( bWarnUser ) {
                                        if( !promptForReassign( cut.seq(iSeq), pItem2->text(0), Application, this ))
				                return true;
                                        // else remove the shortcut from it
                                        KShortcut cut2 = pItem2->shortcut();
                                        removeFromShortcut(cut2, cut);
                                        pItem2->setShortcut(cut2);
                                        updateButtons();
		                        emit keyChange();
                                }
			}
		}
	}
        return false;
}

bool KKeyChooser::checkStandardShortcutsConflict( const KShortcut& cut, bool bWarnUser, TQWidget* parent )
{
    // For each key sequence in the shortcut,
    for( uint i = 0; i < cut.count(); i++ ) {
	const KKeySequence& seq = cut.seq(i);
	KStdAccel::StdAccel id = KStdAccel::findStdAccel( seq );
	if( id != KStdAccel::AccelNone
	    && keyConflict( cut, KStdAccel::shortcut( id ) ) > -1 ) {
		if( bWarnUser ) {
			if( !promptForReassign( seq, KStdAccel::label(id), Standard, parent ))
                                return true;
                        removeStandardShortcut( KStdAccel::label(id), dynamic_cast< KKeyChooser* > ( parent ), KStdAccel::shortcut( id ), cut);
                }
	}
    }
    return false;
}

bool KKeyChooser::checkGlobalShortcutsConflict( const KShortcut& cut, bool bWarnUser, TQWidget* parent )
{
    TQMap< TQString, KShortcut > map;
    readGlobalKeys( map );
    return checkGlobalShortcutsConflict( cut, bWarnUser, parent, map, TQString::null );
}

bool KKeyChooser::checkGlobalShortcutsConflict( const KShortcut& cut, bool bWarnUser, TQWidget* parent,
    const TQMap< TQString, KShortcut >& map, const TQString& ignoreAction )
{
    TQMap<TQString, KShortcut>::ConstIterator it;
    for( it = map.begin(); it != map.end(); ++it ) {
	    int iSeq = keyConflict( cut, (*it) );
	    if( iSeq > -1 ) {
	    	if( ignoreAction.isEmpty() || it.key() != ignoreAction ) {
                    if( bWarnUser ) {
			if( !promptForReassign( cut.seq(iSeq), it.key(), Global, parent ))
                                    return true;
                            removeGlobalShortcut( it.key(), dynamic_cast< KKeyChooser* >( parent ), (*it), cut);
                    }
		}
	}
    }
    return false;
}

void KKeyChooser::removeStandardShortcut( const TQString& name, KKeyChooser* chooser, const KShortcut &origCut, const KShortcut &cut )
{
    bool was_in_choosers = false;
    if( allChoosers != NULL ) {
        for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
             it != allChoosers->end();
             ++it ) {
            if( (*it) != chooser && (*it)->m_type == Standard ) {
                was_in_choosers |= ( (*it)->removeShortcut( name, cut ));
            }
        }
    }
    if( !was_in_choosers ) { // not edited, needs to be changed in config file
        KStdAccel::ShortcutList std_list;
        KShortcut newCut = origCut;
        removeFromShortcut(newCut, cut);
        int index = std_list.index( name );
        if ( index >= 0 ) {
            std_list.setShortcut( index, newCut );
            std_list.save();
        }
    }
}

void KKeyChooser::removeGlobalShortcut( const TQString& name, KKeyChooser* chooser, const KShortcut &origCut, const KShortcut &cut )
{
    bool was_in_choosers = false;
    if( allChoosers != NULL ) {
        for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
             it != allChoosers->end();
             ++it ) {
            if( (*it) != chooser && (*it)->m_type == Global ) {
                was_in_choosers |= ( (*it)->removeShortcut( name, cut ));
            }
        }
    }
    if( !was_in_choosers ) { // not edited, needs to be changed in config file
        KAccelActions actions;
        KShortcut newCut = origCut;
        removeFromShortcut(newCut, cut);
        actions.insert( name, "", "", newCut, newCut);
	actions.writeActions( "Global Shortcuts", 0, true, true );
    }
}

bool KKeyChooser::removeShortcut( const TQString& name, const KShortcut &cut )
{
	for( TQListViewItemIterator it( d->pList ); it.current(); ++it ) {
		KKeyChooserItem* pItem2 = dynamic_cast<KKeyChooserItem*>(it.current());
                    if( pItem2 && pItem2->actionName() == name ) {
                        // remove the shortcut from it
                        KShortcut cut2 = pItem2->shortcut();
                        removeFromShortcut(cut2, cut);
                        pItem2->setShortcut(cut2);
                        updateButtons();
		        emit keyChange();
                        return true;
                    }
        }
        return false;
}

// KDE4 remove this
void KKeyChooser::_warning( const KKeySequence& cut, TQString sAction, TQString sTitle )
{
	sAction = sAction.stripWhiteSpace();

	TQString s =
		i18n("The '%1' key combination has already been allocated "
		"to the \"%2\" action.\n"
		"Please choose a unique key combination.").
		arg(cut.toString()).arg(sAction);

	KMessageBox::sorry( this, s, sTitle );
}

bool KKeyChooser::promptForReassign( const KKeySequence& cut, const TQString& sAction, ActionType type, TQWidget* parent )
{
        if(cut.isNull())
            return true;
        TQString sTitle;
        TQString s;
        if( type == Standard ) {
                sTitle = i18n("Conflict with Standard Application Shortcut");
		s = i18n("The '%1' key combination has already been allocated "
		"to the standard action \"%2\".\n"
		"Do you want to reassign it from that action to the current one?");
        }
        else if( type == Global ) {
                sTitle = i18n("Conflict with Global Shortcut");
		s = i18n("The '%1' key combination has already been allocated "
		"to the global action \"%2\".\n"
		"Do you want to reassign it from that action to the current one?");
        }
        else {
                sTitle = i18n("Key Conflict");
		s = i18n("The '%1' key combination has already been allocated "
		"to the \"%2\" action.\n"
		"Do you want to reassign it from that action to the current one?");
        }
	s = s.arg(cut.toString()).arg(sAction.stripWhiteSpace());

	return KMessageBox::warningContinueCancel( parent, s, sTitle, i18n("Reassign") ) == KMessageBox::Continue;
}

//---------------------------------------------------
KKeyChooserItem::KKeyChooserItem( KListView* parent, TQListViewItem* after, KShortcutList* pList, uint iAction )
:	KListViewItem( parent, after )
{
	m_pList = pList;
	m_iAction = iAction;
	m_bModified = false;
	m_cut = m_pList->shortcut(m_iAction);
}

KKeyChooserItem::KKeyChooserItem( TQListViewItem* parent, TQListViewItem* after, KShortcutList* pList, uint iAction )
:	KListViewItem( parent, after )
{
	m_pList = pList;
	m_iAction = iAction;
	m_bModified = false;
	m_cut = m_pList->shortcut(m_iAction);
}

TQString KKeyChooserItem::actionName() const
{
	return m_pList->name(m_iAction);
}

const KShortcut& KKeyChooserItem::shortcut() const
{
	return m_cut;
}

void KKeyChooserItem::setShortcut( const KShortcut& cut )
{
	m_cut = cut;
	m_bModified = (m_cut != m_pList->shortcut(m_iAction));
	listView()->repaintItem( this );
}

void KKeyChooserItem::commitChanges()
{
	if( m_bModified )
		m_pList->setShortcut( m_iAction, m_cut );
}

TQString KKeyChooserItem::text( int iCol ) const
{
	if( iCol == 0 ) {
		// Quick HACK to get rid of '&'s.
		TQString s = m_pList->label(m_iAction);
		TQString s2;
		for( uint i = 0; i < s.length(); i++ )
			if( s[i] != '&' || ( i+1<s.length() && s[i+1] == '&' ) )
				s2 += s[i];
		return s2;
	}
	else if( iCol <= (int) m_cut.count() )
		return m_cut.seq(iCol-1).toString();
	else
		return TQString::null;
}

int KKeyChooserItem::compare( TQListViewItem* item, int iCol, bool bAscending ) const
{
	KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( item );
	if( iCol == 0 && pItem ) {
		TQString psName1 = m_pList->name(m_iAction);
		TQString psName2 = pItem->m_pList->name(pItem->m_iAction);
		TQRegExp rxNumber1( " (\\d+)$" );
		TQRegExp rxNumber2( " (\\d+)$" );
		int iNumber1 = rxNumber1.search( psName1 );
		int iNumber2 = rxNumber2.search( psName2 );

		// Check if the last word is one or more digits
		if( iNumber1 >= 0 && iNumber1 == iNumber2 && psName1.startsWith( psName2.left( iNumber1+1 ) ) ) {
			int n1 = rxNumber1.cap(1).toInt();
			int n2 = rxNumber2.cap(1).toInt();
			return (n1 < n2) ? -1 : (n1 > n2) ? 1 : 0;
		}
	}

	return TQListViewItem::compare( item, iCol, bAscending );
}

////

TQString KKeyChooserWhatsThis::text( const TQPoint& p ) {
    if ( !m_listView )
        return TQString::null;

    const TQListViewItem* item = m_listView->itemAt( p );
    const KKeyChooserItem* pItem = dynamic_cast<const KKeyChooserItem*>(item);
    if ( !pItem )
        return TQWhatsThis::textFor( m_listView );

    const TQString itemWhatsThis = pItem->whatsThis();
    if ( itemWhatsThis.isEmpty() )
        return TQWhatsThis::textFor( m_listView );

    return itemWhatsThis;
}

/************************************************************************/
/* KKeyDialog                                                           */
/*                                                                      */
/* Originally by Nicolas Hadacek <hadacek@via.ecp.fr>                   */
/*                                                                      */
/* Substantially revised by Mark Donohoe <donohoe@kde.org>              */
/*                                                                      */
/* And by Espen Sand <espen@kde.org> 1999-10-19                         */
/* (by using KDialogBase there is almost no code left ;)                */
/*                                                                      */
/************************************************************************/
KKeyDialog::KKeyDialog( KKeyChooser::ActionType type, bool bAllowLetterShortcuts, TQWidget *parent, const char* name )
: KDialogBase( parent, name ? name : "kkeydialog", true, i18n("Configure Shortcuts"), Default|Ok|Cancel, Ok )
{
	m_pKeyChooser = new KKeyChooser( this, type, bAllowLetterShortcuts );
	setMainWidget( m_pKeyChooser );
	connect( this, TQT_SIGNAL(defaultClicked()), m_pKeyChooser, TQT_SLOT(allDefault()) );

	KConfigGroup group( KGlobal::config(), "KKeyDialog Settings" );
	TQSize sz = size();
	resize( group.readSizeEntry( "Dialog Size", &sz ) );
}

KKeyDialog::KKeyDialog( bool bAllowLetterShortcuts, TQWidget *parent, const char* name )
: KDialogBase( parent, name ? name : "kkeydialog", true, i18n("Configure Shortcuts"), Default|Ok|Cancel, Ok )
{
	m_pKeyChooser = new KKeyChooser( this, KKeyChooser::Application, bAllowLetterShortcuts );
	setMainWidget( m_pKeyChooser );
	connect( this, TQT_SIGNAL(defaultClicked()), m_pKeyChooser, TQT_SLOT(allDefault()) );

	KConfigGroup group( KGlobal::config(), "KKeyDialog Settings" );
	TQSize sz = size();
	resize( group.readSizeEntry( "Dialog Size", &sz ) );
}

KKeyDialog::~KKeyDialog()
{
	KConfigGroup group( KGlobal::config(), "KKeyDialog Settings" );
	group.writeEntry( "Dialog Size", size(), true, true );
}

bool KKeyDialog::insert( KActionCollection* pColl )
{
	return m_pKeyChooser->insert( pColl );
}

bool KKeyDialog::insert(KActionCollection *pColl, const TQString &title)
{
    return m_pKeyChooser->insert(pColl, title);
}

bool KKeyDialog::configure( bool bSaveSettings )
{
	int retcode = exec();
	if( retcode == Accepted ) {
		if( bSaveSettings )
			m_pKeyChooser->save();
		else
			commitChanges();
	}
	return retcode;
}

void KKeyDialog::commitChanges()
{
	m_pKeyChooser->commitChanges();
}

int KKeyDialog::configure( KActionCollection* coll, TQWidget* parent, bool bSaveSettings )
{
	return configure( coll, true, parent, bSaveSettings);
}

int KKeyDialog::configure( KAccel* keys, TQWidget* parent, bool bSaveSettings )
{
	return configure( keys, true, parent, bSaveSettings);
}

int KKeyDialog::configure( KGlobalAccel* keys, TQWidget* parent, bool bSaveSettings )
{
	return configure( keys, true, parent, bSaveSettings);
}

int KKeyDialog::configure( KAccel* keys, bool bAllowLetterShortcuts, TQWidget *parent, bool bSaveSettings )
{
	KKeyDialog dlg( bAllowLetterShortcuts, parent );
	dlg.m_pKeyChooser->insert( keys );
	bool b = dlg.configure( bSaveSettings );
	if( b && bSaveSettings )
		keys->updateConnections();
	return b;
}

int KKeyDialog::configure( KGlobalAccel* keys, bool bAllowLetterShortcuts, TQWidget *parent, bool bSaveSettings )
{
	KKeyDialog dlg( KKeyChooser::ApplicationGlobal, bAllowLetterShortcuts, parent );
	dlg.m_pKeyChooser->insert( keys );
	bool b = dlg.configure( bSaveSettings );
	if( b && bSaveSettings )
		keys->updateConnections();
	return b;
}

int KKeyDialog::configure( KActionCollection* coll, bool bAllowLetterShortcuts, TQWidget *parent, bool bSaveSettings )
{
	kdDebug(125) << "KKeyDialog::configureKeys( KActionCollection*, " << bSaveSettings << " )" << endl;
	KKeyDialog dlg( bAllowLetterShortcuts, parent );
	dlg.m_pKeyChooser->insert( coll );
	return dlg.configure( bSaveSettings );
}

/*int KKeyDialog::configure( KActionPtrList* coll, const TQString& file, TQWidget *parent, bool bSaveSettings )
{
	kdDebug(125) << "KKeyDialog::configureKeys( KActionCollection*, " << file << ", " << bSaveSettings << " )" << endl;
	KAccelActions actions;
	coll->createKeyMap( actions );

	int retcode = configure( actions, file, parent, bSaveSettings );
	if( retcode == Accepted )
		coll->setKeyMap( actions );

	return retcode;
}*/

void KKeyChooser::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }

void KKeyDialog::virtual_hook( int id, void* data )
{ KDialogBase::virtual_hook( id, data ); }

#include "kkeydialog.moc"