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

tdeui

  • tdeui
kkeydialog.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 1998 Mark Donohoe <donohoe@kde.org>
3 Copyright (C) 1997 Nicolas Hadacek <hadacek@kde.org>
4 Copyright (C) 1998 Matthias Ettrich <ettrich@kde.org>
5 Copyright (C) 2001 Ellis Whitehead <ellis@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22
23#include "kkeydialog.h"
24#include "kkeybutton.h"
25
26#include <string.h>
27
28#include <tqbuttongroup.h>
29#include <tqlabel.h>
30#include <tqlayout.h>
31#include <tqdrawutil.h>
32#include <tqpainter.h>
33#include <tqradiobutton.h>
34#include <tqregexp.h>
35#include <tqtoolbutton.h>
36#include <tqwhatsthis.h>
37
38#include <tdeaccel.h>
39#include <tdeaction.h>
40#include <tdeaccelaction.h>
41#include <tdeactionshortcutlist.h>
42#include <tdeapplication.h>
43#include <tdeconfig.h>
44#include <kdebug.h>
45#include <tdeglobal.h>
46#include <tdeglobalaccel.h>
47#include <kiconloader.h>
48#include <tdelistviewsearchline.h>
49#include <tdelocale.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>
56
57#ifdef TQ_WS_X11
58#define XK_XKB_KEYS
59#define XK_MISCELLANY
60#include <X11/Xlib.h> // For x11Event()
61#include <X11/keysymdef.h> // For XK_...
62#include <tqwhatsthis.h>
63
64#ifdef KeyPress
65const int XFocusOut = FocusOut;
66const int XFocusIn = FocusIn;
67const int XKeyPress = KeyPress;
68const int XKeyRelease = KeyRelease;
69#undef KeyRelease
70#undef KeyPress
71#undef FocusOut
72#undef FocusIn
73#endif // KEYPRESS
74#endif // Q_WX_X11
75
76//---------------------------------------------------------------------
77// KKeyChooserItem
78//---------------------------------------------------------------------
79
80class KKeyChooserItem : public TDEListViewItem
81{
82 public:
83 KKeyChooserItem( TDEListView* parent, TQListViewItem* after, TDEShortcutList* pList, uint iAction );
84 KKeyChooserItem( TQListViewItem* parent, TQListViewItem* after, TDEShortcutList* pList, uint iAction );
85
86 TQString actionName() const;
87 const TDEShortcut& shortcut() const;
88 bool isConfigurable() const
89 { return m_pList->isConfigurable( m_iAction ); }
90 const TDEShortcut& shortcutDefault() const
91 { return m_pList->shortcutDefault( m_iAction ); }
92 TQString whatsThis() const
93 { return m_pList->whatsThis( m_iAction ); }
94
95 void setShortcut( const TDEShortcut& cut );
96 void commitChanges();
97
98 virtual TQString text( int iCol ) const;
99 virtual int compare( TQListViewItem*, int iCol, bool bAscending ) const;
100
101 protected:
102 TDEShortcutList* m_pList;
103 uint m_iAction;
104 bool m_bModified;
105 TDEShortcut m_cut;
106};
107
108// WhatsThis on KKeyChooserItems
109class KKeyChooserWhatsThis : public TQWhatsThis
110{
111public:
112 KKeyChooserWhatsThis( TQListView* listview )
113 : TQWhatsThis( listview->viewport() ), m_listView( listview ) {}
114
115protected:
116 virtual TQString text( const TQPoint& p );
117
118private:
119 TQListView* m_listView;
120};
121
122//---------------------------------------------------------------------
123// KKeyChooserPrivate
124//---------------------------------------------------------------------
125
126class KKeyChooserPrivate
127{
128 public:
129 TQValueList<TDEShortcutList*> rgpLists;
130 TQValueList<TDEShortcutList*> rgpListsAllocated;
131
132 TDEListView *pList;
133 TQLabel *lInfo;
134 KKeyButton *pbtnShortcut;
135 TQGroupBox *fCArea;
136 TQButtonGroup *kbGroup;
137
138 TQMap<TQString, TDEShortcut> mapGlobals;
139
140 // If this is set, then shortcuts require a modifier:
141 // so 'A' would not be valid, whereas 'Ctrl+A' would be.
142 // Note, however, that this only applies to printable characters.
143 // 'F1', 'Insert', etc., could still be used.
144 bool bAllowLetterShortcuts;
145 // When set, pressing the 'Default' button will select the aDefaultKeycode4,
146 // otherwise aDefaultKeycode.
147 bool bPreferFourModifierKeys;
148};
149
150//---------------------------------------------------------------------
151// KKeyChooser
152//---------------------------------------------------------------------
153
154KKeyChooser::KKeyChooser( TQWidget* parent, ActionType type, bool bAllowLetterShortcuts )
155: TQWidget( parent )
156{
157 initGUI( type, bAllowLetterShortcuts );
158}
159
160KKeyChooser::KKeyChooser( TDEActionCollection* coll, TQWidget* parent, bool bAllowLetterShortcuts )
161: TQWidget( parent )
162{
163 initGUI( Application, bAllowLetterShortcuts );
164 insert( coll );
165}
166
167KKeyChooser::KKeyChooser( TDEAccel* pAccel, TQWidget* parent, bool bAllowLetterShortcuts )
168: TQWidget( parent )
169{
170 initGUI( Application, bAllowLetterShortcuts );
171 insert( pAccel );
172}
173
174KKeyChooser::KKeyChooser( TDEGlobalAccel* pAccel, TQWidget* parent )
175: TQWidget( parent )
176{
177 initGUI( ApplicationGlobal, false );
178 insert( pAccel );
179}
180
181KKeyChooser::KKeyChooser( TDEShortcutList* pList, TQWidget* parent, ActionType type, bool bAllowLetterShortcuts )
182: TQWidget( parent )
183{
184 initGUI( type, bAllowLetterShortcuts );
185 insert( pList );
186}
187
188KKeyChooser::KKeyChooser( TDEAccel* actions, TQWidget* parent,
189 bool bCheckAgainstStdKeys,
190 bool bAllowLetterShortcuts,
191 bool bAllowWinKey )
192: TQWidget( parent )
193{
194 ActionType type;
195 if( bAllowWinKey )
196 type = (bCheckAgainstStdKeys) ? ApplicationGlobal : Global;
197 else
198 type = Application;
199
200 initGUI( type, bAllowLetterShortcuts );
201 insert( actions );
202}
203
204KKeyChooser::KKeyChooser( TDEGlobalAccel* actions, TQWidget* parent,
205 bool bCheckAgainstStdKeys,
206 bool bAllowLetterShortcuts,
207 bool /*bAllowWinKey*/ )
208: TQWidget( parent )
209{
210 ActionType type = (bCheckAgainstStdKeys) ? ApplicationGlobal : Global;
211
212 initGUI( type, bAllowLetterShortcuts );
213 insert( actions );
214}
215
216// list of all existing KKeyChooser's
217// Used when checking global shortcut for a possible conflict
218// (just checking against kdeglobals isn't enough, the shortcuts
219// might have changed in KKeyChooser and not being saved yet).
220// Also used when reassigning a shortcut from one chooser to another.
221static TQValueList< KKeyChooser* >* allChoosers = NULL;
222static KStaticDeleter< TQValueList< KKeyChooser* > > allChoosersDeleter;
223
224KKeyChooser::~KKeyChooser()
225{
226 allChoosers->remove( this );
227 // Delete allocated TDEShortcutLists
228 for( uint i = 0; i < d->rgpListsAllocated.count(); i++ )
229 delete d->rgpListsAllocated[i];
230 delete d;
231}
232
233bool KKeyChooser::insert( TDEActionCollection *pColl)
234{
235 return insert(pColl, TQString::null);
236}
237
238bool KKeyChooser::insert( TDEActionCollection* pColl, const TQString &title )
239{
240 TQString str = title;
241 if ( title.isEmpty() && pColl->instance()
242 && pColl->instance()->aboutData() )
243 str = pColl->instance()->aboutData()->programName();
244
245 TDEShortcutList* pList = new TDEActionShortcutList( pColl );
246 d->rgpListsAllocated.append( pList );
247 d->rgpLists.append( pList );
248 buildListView(d->rgpLists.count() - 1, str);
249 return true;
250}
251
252bool KKeyChooser::insert( TDEAccel* pAccel )
253{
254 TDEShortcutList* pList = new TDEAccelShortcutList( pAccel );
255 d->rgpListsAllocated.append( pList );
256 return insert( pList );
257}
258
259bool KKeyChooser::insert( TDEGlobalAccel* pAccel )
260{
261 TDEShortcutList* pList = new TDEAccelShortcutList( pAccel );
262 d->rgpListsAllocated.append( pList );
263 return insert( pList );
264}
265
266bool KKeyChooser::insert( TDEShortcutList* pList )
267{
268 d->rgpLists.append( pList );
269 buildListView( d->rgpLists.count() - 1, TQString::null );
270 return true;
271}
272
273void KKeyChooser::commitChanges()
274{
275 kdDebug(125) << "KKeyChooser::commitChanges()" << endl;
276
277 TQListViewItemIterator it( d->pList );
278 for( ; it.current(); ++it ) {
279 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(it.current());
280 if( pItem )
281 pItem->commitChanges();
282 }
283}
284
285void KKeyChooser::save()
286{
287 commitChanges();
288 for( uint i = 0; i < d->rgpLists.count(); i++ )
289 d->rgpLists[i]->save();
290}
291
292void KKeyChooser::initGUI( ActionType type, bool bAllowLetterShortcuts )
293{
294 d = new KKeyChooserPrivate();
295
296 m_type = type;
297 d->bAllowLetterShortcuts = bAllowLetterShortcuts;
298
299 d->bPreferFourModifierKeys = TDEGlobalAccel::useFourModifierKeys();
300
301 //
302 // TOP LAYOUT MANAGER
303 //
304 // The following layout is used for the dialog
305 // LIST LABELS LAYOUT
306 // SPLIT LIST BOX WIDGET
307 // CHOOSE KEY GROUP BOX WIDGET
308 // BUTTONS LAYOUT
309 // Items are added to topLayout as they are created.
310 //
311
312 TQBoxLayout *topLayout = new TQVBoxLayout( this, 0, KDialog::spacingHint() );
313
314 //
315 // ADD SEARCHLINE
316 //
317 TQHBoxLayout* searchLayout = new TQHBoxLayout(0, 0, KDialog::spacingHint());
318 topLayout->addLayout(searchLayout, 10);
319
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);
326 TDEListViewSearchLine* listViewSearch = new TDEListViewSearchLine(this);
327 searchLayout->addWidget(listViewSearch);
328 slbl->setBuddy(listViewSearch);
329 connect(clearSearch, TQ_SIGNAL(pressed()), listViewSearch, TQ_SLOT(clear()));
330
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.");
333
334 TQWhatsThis::add(slbl, wtstr);
335 TQWhatsThis::add(listViewSearch, wtstr);
336
337 //
338 // CREATE SPLIT LIST BOX
339 //
340 // fill up the split list box with the action/key pairs.
341 //
342 TQGridLayout *stackLayout = new TQGridLayout(2, 2, 2);
343 topLayout->addLayout( stackLayout, 10 );
344 stackLayout->setRowStretch( 1, 10 ); // Only list will stretch
345
346 d->pList = new TDEListView( this );
347 listViewSearch->setListView(d->pList); // Plug into search line
348 TQValueList<int> columns;
349 columns.append(0);
350 listViewSearch->setSearchColumns(columns);
351
352 stackLayout->addMultiCellWidget( d->pList, 1, 1, 0, 1 );
353
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.");
358
359 TQWhatsThis::add( d->pList, wtstr );
360 new KKeyChooserWhatsThis( d->pList );
361
362 d->pList->setAllColumnsShowFocus( true );
363 d->pList->addColumn(i18n("Action"));
364 d->pList->addColumn(i18n("Shortcut"));
365 d->pList->addColumn(i18n("Alternate"));
366
367 connect( d->pList, TQ_SIGNAL(currentChanged(TQListViewItem*)),
368 TQ_SLOT(slotListItemSelected(TQListViewItem*)) );
369
370 // handle double clicking an item
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()));
374 //
375 // CREATE CHOOSE KEY GROUP
376 //
377 d->fCArea = new TQGroupBox( this );
378 topLayout->addWidget( d->fCArea, 1 );
379
380 d->fCArea->setTitle( i18n("Shortcut for Selected Action") );
381 d->fCArea->setFrameStyle( TQFrame::GroupBoxPanel | TQFrame::Plain );
382
383 //
384 // CHOOSE KEY GROUP LAYOUT MANAGER
385 //
386 TQGridLayout *grid = new TQGridLayout( d->fCArea, 3, 4, KDialog::spacingHint() );
387 grid->addRowSpacing( 0, fontMetrics().lineSpacing() );
388
389 d->kbGroup = new TQButtonGroup( d->fCArea );
390 d->kbGroup->hide();
391 d->kbGroup->setExclusive( true );
392
393 m_prbNone = new TQRadioButton( i18n("no key", "&None"), d->fCArea );
394 d->kbGroup->insert( m_prbNone, NoKey );
395 m_prbNone->setEnabled( false );
396 //grid->addMultiCellWidget( rb, 1, 1, 1, 2 );
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()) );
400
401 m_prbDef = new TQRadioButton( i18n("default key", "De&fault"), d->fCArea );
402 d->kbGroup->insert( m_prbDef, DefaultKey );
403 m_prbDef->setEnabled( false );
404 //grid->addMultiCellWidget( rb, 2, 2, 1, 2 );
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()) );
408
409 m_prbCustom = new TQRadioButton( i18n("C&ustom"), d->fCArea );
410 d->kbGroup->insert( m_prbCustom, CustomKey );
411 m_prbCustom->setEnabled( false );
412 //grid->addMultiCellWidget( rb, 3, 3, 1, 2 );
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()) );
417
418 //connect( d->kbGroup, TQ_SIGNAL( clicked( int ) ), TQ_SLOT( keyMode( int ) ) );
419
420 TQBoxLayout *pushLayout = new TQHBoxLayout( KDialog::spacingHint() );
421 grid->addLayout( pushLayout, 1, 3 );
422
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 );
427
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 );
432
433 //
434 // Add widgets to the geometry manager
435 //
436 pushLayout->addSpacing( KDialog::spacingHint()*2 );
437 pushLayout->addWidget( d->pbtnShortcut );
438 pushLayout->addStretch( 10 );
439
440 d->lInfo = new TQLabel(d->fCArea);
441 //resize(0,0);
442 //d->lInfo->setAlignment( AlignCenter );
443 //d->lInfo->setEnabled( false );
444 //d->lInfo->hide();
445 grid->addMultiCellWidget( d->lInfo, 2, 2, 0, 3 );
446
447 //d->globalDict = new TQDict<int> ( 100, false );
448 //d->globalDict->setAutoDelete( true );
449 readGlobalKeys();
450 //d->stdDict = new TQDict<int> ( 100, false );
451 //d->stdDict->setAutoDelete( true );
452 //if (type == Application || type == ApplicationGlobal)
453 // readStdKeys();
454 connect( tdeApp, TQ_SIGNAL( settingsChanged( int )), TQ_SLOT( slotSettingsChanged( int )));
455 if( allChoosers == NULL )
456 allChoosers = allChoosersDeleter.setObject( allChoosers, new TQValueList< KKeyChooser* > );
457 allChoosers->append( this );
458}
459
460// Add all shortcuts to the list
461void KKeyChooser::buildListView( uint iList, const TQString &title )
462{
463 TDEShortcutList* pList = d->rgpLists[iList];
464 TDEActionShortcutList *pAList = dynamic_cast<TDEActionShortcutList*>(pList);
465
466 if( m_type == Global || m_type == ApplicationGlobal )
467 d->pList->setSorting( -1 );
468 TDEListViewItem *pProgramItem, *pGroupItem = 0, *pParentItem, *pItem;
469
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);
478 kdDebug(125) << "Key: " << sName << endl;
479 if( sName.startsWith( "Program:" ) ) {
480 pItem = new TDEListViewItem( d->pList, pProgramItem, pList->label(iAction) );
481 pItem->setSelectable( false );
482 pItem->setExpandable( true );
483 pItem->setOpen( true );
484 if( !pProgramItem->firstChild() )
485 delete pProgramItem;
486 pProgramItem = pParentItem = pItem;
487 } else if( sName.startsWith( "Group:" ) ) {
488 pItem = new TDEListViewItem( pProgramItem, pParentItem, pList->label(iAction) );
489 pItem->setSelectable( false );
490 pItem->setExpandable( true );
491 pItem->setOpen( true );
492 if( pGroupItem && !pGroupItem->firstChild() )
493 delete pGroupItem;
494 pGroupItem = pParentItem = pItem;
495 } else if( !sName.isEmpty() && sName != "unnamed" && pList->isConfigurable(iAction) ) {
496 pItem = new KKeyChooserItem( pParentItem, pItem, pList, iAction );
497 if(pAList)
498 pItem->setPixmap(0,pAList->action(iAction)->iconSet().pixmap(TQIconSet::Small,TQIconSet::Normal));
499 }
500 }
501 if( !pProgramItem->firstChild() )
502 delete pProgramItem;
503 if( pGroupItem && !pGroupItem->firstChild() )
504 delete pGroupItem;
505}
506
507
508void KKeyChooser::updateButtons()
509{
510 // Hack: Do this incase we still have changeKey() running.
511 // Better would be to capture the mouse pointer so that we can't click
512 // around while we're supposed to be entering a key.
513 // Better yet would be a modal dialog for changeKey()!
514 releaseKeyboard();
515 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );
516
517 if ( !pItem ) {
518 // if nothing is selected -> disable radio boxes
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 );
524 } else {
525 bool bConfigurable = pItem->isConfigurable();
526 bool bQtShortcut = (m_type == Application || m_type == Standard);
527 const TDEShortcut& cutDef = pItem->shortcutDefault();
528
529 // Set key strings
530 TQString keyStrCfg = pItem->shortcut().toString();
531 TQString keyStrDef = cutDef.toString();
532
533 d->pbtnShortcut->setShortcut( pItem->shortcut(), bQtShortcut );
534 //item->setText( 1, keyStrCfg );
535 pItem->repaint();
536 d->lInfo->setText( i18n("Default key:") + TQString(" %1").arg(keyStrDef.isEmpty() ? i18n("None") : keyStrDef) );
537
538 // Select the appropriate radio button.
539 int index = (pItem->shortcut().isNull()) ? NoKey
540 : (pItem->shortcut() == cutDef) ? DefaultKey
541 : CustomKey;
542 m_prbNone->setChecked( index == NoKey );
543 m_prbDef->setChecked( index == DefaultKey );
544 m_prbCustom->setChecked( index == CustomKey );
545
546 // Enable buttons if this key is configurable.
547 // The 'Default Key' button must also have a default key.
548 m_prbNone->setEnabled( bConfigurable );
549 m_prbDef->setEnabled( bConfigurable && cutDef.count() != 0 );
550 m_prbCustom->setEnabled( bConfigurable );
551 d->pbtnShortcut->setEnabled( bConfigurable );
552 }
553}
554
555void KKeyChooser::slotNoKey()
556{
557 // return if no key is selected
558 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );
559 if( pItem ) {
560 //kdDebug(125) << "no Key" << d->pList->currentItem()->text(0) << endl;
561 pItem->setShortcut( TDEShortcut() );
562 updateButtons();
563 emit keyChange();
564 }
565}
566
567void KKeyChooser::slotDefaultKey()
568{
569 // return if no key is selected
570 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );
571 if( pItem ) // don't set it directly, check for conflicts
572 setShortcut( pItem->shortcutDefault() );
573}
574
575void KKeyChooser::slotCustomKey()
576{
577 d->pbtnShortcut->captureShortcut();
578}
579
580void KKeyChooser::readGlobalKeys()
581{
582 d->mapGlobals.clear();
583 if( m_type == Global )
584 return; // they will be checked normally, because we're configuring them
585 readGlobalKeys( d->mapGlobals );
586}
587
588void KKeyChooser::readGlobalKeys( TQMap< TQString, TDEShortcut >& map )
589{
590 TQMap<TQString, TQString> mapEntry = TDEGlobal::config()->entryMap( "Global Shortcuts" );
591 TQMap<TQString, TQString>::Iterator it( mapEntry.begin() );
592 for( uint i = 0; it != mapEntry.end(); ++it, i++ )
593 map[it.key()] = TDEShortcut(*it);
594}
595
596void KKeyChooser::slotSettingsChanged( int category )
597{
598 if( category == TDEApplication::SETTINGS_SHORTCUTS )
599 readGlobalKeys(); // reread
600}
601
602void KKeyChooser::fontChange( const TQFont & )
603{
604 d->fCArea->setMinimumHeight( 4*d->pbtnShortcut->sizeHint().height() );
605
606 int widget_width = 0;
607
608 setMinimumWidth( 20+5*(widget_width+10) );
609}
610
611// KDE4 IMHO this shouldn't be here at all - it cannot check whether the default
612// shortcut don't conflict with some already changed ones (e.g. global shortcuts).
613// Also, I personally find reseting all shortcuts to default (i.e. hardcoded in the app)
614// ones after pressing the 'Default' button rather a misfeature.
615void KKeyChooser::allDefault()
616{
617 kdDebug(125) << "KKeyChooser::allDefault()" << endl;
618
619 TQListViewItemIterator it( d->pList );
620 for( ; it.current(); ++it ) {
621 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(it.current());
622 if( pItem )
623 pItem->setShortcut( pItem->shortcutDefault() );
624 }
625
626 updateButtons();
627 emit keyChange();
628}
629
630void KKeyChooser::slotListItemSelected( TQListViewItem* )
631{
632 updateButtons();
633}
634
635void KKeyChooser::slotListItemDoubleClicked ( TQListViewItem *, const TQPoint & , int )
636{ // KDE4 dump this
637 captureCurrentItem();
638}
639
640void KKeyChooser::captureCurrentItem()
641{
642 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>( d->pList->currentItem() );
643 if( pItem != NULL && pItem->isConfigurable())
644 d->pbtnShortcut->captureShortcut ( );
645}
646
647void KKeyChooser::setPreferFourModifierKeys( bool bPreferFourModifierKeys )
648{
649 d->bPreferFourModifierKeys = bPreferFourModifierKeys;
650}
651
652void KKeyChooser::capturedShortcut( const TDEShortcut& cut )
653{
654 if( cut.isNull() )
655 slotNoKey();
656 else
657 setShortcut( cut );
658}
659
660// FIXME: give this functionality again -- I don't think it's ever used, though. -- ellis
661// TODO: Check lxr.kde.org to see if it's used anywhere
662void KKeyChooser::listSync()
663{
664/* kdDebug(125) << "KKeyChooser::listSync()" << endl;
665
666 if( d->pColl ) {
667 // TODO: This is very inefficient. Come up with something better.
668 TDEAccelActions aa;
669 d->pColl->createKeyMap( aa );
670 d->actionsNew.updateShortcuts( aa );
671 } else if( d->pActionsOrig ) {
672 d->actionsNew.updateShortcuts( *d->pActionsOrig );
673 update();
674 updateButtons();
675 }*/
676}
677
678void KKeyChooser::syncToConfig( const TQString& sConfigGroup, TDEConfigBase* pConfig, bool bClearUnset )
679{
680 kdDebug(125) << "KKeyChooser::syncToConfig( \"" << sConfigGroup << "\", " << pConfig << " ) start" << endl;
681 if( !pConfig )
682 pConfig = TDEGlobal::config();
683 TDEConfigGroupSaver cgs( pConfig, sConfigGroup );
684
685 TQListViewItemIterator it( d->pList );
686 for( ; it.current(); ++it ) {
687 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(it.current());
688 if( pItem ) {
689 TQString sEntry = pConfig->readEntry( pItem->actionName() );
690 if( !sEntry.isNull() || bClearUnset ) {
691 if( sEntry == "none" )
692 sEntry = TQString::null;
693 pItem->setShortcut( sEntry );
694 }
695 kdDebug(125) << pItem->actionName() << " = " << pItem->shortcut().toStringInternal() << endl;
696 }
697 }
698 updateButtons();
699 kdDebug(125) << "KKeyChooser::syncToConfig() done" << endl;
700}
701
702void KKeyChooser::setShortcut( const TDEShortcut& cut )
703{
704 kdDebug(125) << "KKeyChooser::setShortcut( " << cut.toString() << " )" << endl;
705 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(d->pList->currentItem());
706 if( !pItem )
707 return;
708
709 for( uint i = 0; i < cut.count(); i++ ) {
710 const KKeySequence& seq = cut.seq(i);
711 const KKey& key = seq.key(0);
712
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()));
718 KMessageBox::sorry( this, s, i18n("Invalid Shortcut Key") );
719 return;
720 }
721 }
722
723 // If key isn't already in use,
724 if( !isKeyPresent( cut ) ) {
725 // Set new key code
726 pItem->setShortcut( cut );
727 // Update display
728 updateButtons();
729 emit keyChange();
730 }
731}
732
733// Returns iSeq index if cut2 has a sequence of equal or higher priority to a sequence in cut.
734// else -1
735static int keyConflict( const TDEShortcut& cut, const TDEShortcut& cut2 )
736{
737 for( uint iSeq = 0; iSeq < cut.count(); iSeq++ ) {
738 for( uint iSeq2 = 0; iSeq2 < cut2.count(); iSeq2++ ) {
739 if( cut.seq(iSeq) == cut2.seq(iSeq2) )
740 return iSeq;
741 }
742 }
743 return -1;
744}
745
746// Removes the sequences in cut2 from cut1
747static void removeFromShortcut( TDEShortcut & cut1, const TDEShortcut &cut2)
748{
749 for( uint iSeq2 = 0; iSeq2 < cut2.count(); iSeq2++ )
750 cut1.remove(cut2.seq(iSeq2));
751}
752
753bool KKeyChooser::isKeyPresent( const TDEShortcut& cut, bool bWarnUser )
754{
755 KKeyChooserItem* pItem = dynamic_cast<KKeyChooserItem*>(d->pList->currentItem());
756
757 if (!pItem) {
758 return false;
759 }
760
761 bool has_global_chooser = false;
762 bool has_standard_chooser = false;
763 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
764 it != allChoosers->end();
765 ++it ) {
766 has_global_chooser |= ((*it)->m_type == Global);
767 has_standard_chooser |= ((*it)->m_type == Standard);
768 }
769
770 // If editing global shortcuts, check them for conflicts with the stdaccels.
771 if( m_type == ApplicationGlobal || m_type == Global ) {
772 if( !has_standard_chooser ) {
773 if( checkStandardShortcutsConflict( cut, bWarnUser, this ))
774 return true;
775 }
776 }
777
778 // only check the global keys if one of the keychoosers isn't global
779 if( !has_global_chooser ) {
780 if( checkGlobalShortcutsConflict( cut, bWarnUser, this, d->mapGlobals,
781 m_type == Global ? pItem->actionName() : TQString::null ))
782 return true;
783 }
784
785 if( isKeyPresentLocally( cut, pItem, bWarnUser ))
786 return true;
787
788 // check also other KKeyChooser's
789 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
790 it != allChoosers->end();
791 ++it ) {
792 if( (*it) != this && (*it)->isKeyPresentLocally( cut, NULL, bWarnUser ))
793 return true;
794 }
795 return false;
796}
797
798// KDE4 remove
799bool KKeyChooser::isKeyPresentLocally( const TDEShortcut& cut, KKeyChooserItem* ignoreItem, const TQString& warnText )
800{
801 return isKeyPresentLocally( cut, ignoreItem, !warnText.isNull());
802}
803
804bool KKeyChooser::isKeyPresentLocally( const TDEShortcut& cut, KKeyChooserItem* ignoreItem, bool bWarnUser )
805{
806 if ( cut.toString().isEmpty())
807 return false;
808 // Search for shortcut conflicts with other actions in the
809 // lists we're configuring.
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() );
814 if( iSeq > -1 ) {
815 if( bWarnUser ) {
816 if( !promptForReassign( cut.seq(iSeq), pItem2->text(0), Application, this ))
817 return true;
818 // else remove the shortcut from it
819 TDEShortcut cut2 = pItem2->shortcut();
820 removeFromShortcut(cut2, cut);
821 pItem2->setShortcut(cut2);
822 updateButtons();
823 emit keyChange();
824 }
825 }
826 }
827 }
828 return false;
829}
830
831bool KKeyChooser::checkStandardShortcutsConflict( const TDEShortcut& cut, bool bWarnUser, TQWidget* parent )
832{
833 // For each key sequence in the shortcut,
834 for( uint i = 0; i < cut.count(); i++ ) {
835 const KKeySequence& seq = cut.seq(i);
836 TDEStdAccel::StdAccel id = TDEStdAccel::findStdAccel( seq );
837 if( id != TDEStdAccel::AccelNone
838 && keyConflict( cut, TDEStdAccel::shortcut( id ) ) > -1 ) {
839 if( bWarnUser ) {
840 if( !promptForReassign( seq, TDEStdAccel::label(id), Standard, parent ))
841 return true;
842 removeStandardShortcut( TDEStdAccel::label(id), dynamic_cast< KKeyChooser* > ( parent ), TDEStdAccel::shortcut( id ), cut);
843 }
844 }
845 }
846 return false;
847}
848
849bool KKeyChooser::checkGlobalShortcutsConflict( const TDEShortcut& cut, bool bWarnUser, TQWidget* parent )
850{
851 TQMap< TQString, TDEShortcut > map;
852 readGlobalKeys( map );
853 return checkGlobalShortcutsConflict( cut, bWarnUser, parent, map, TQString::null );
854}
855
856bool KKeyChooser::checkGlobalShortcutsConflict( const TDEShortcut& cut, bool bWarnUser, TQWidget* parent,
857 const TQMap< TQString, TDEShortcut >& map, const TQString& ignoreAction )
858{
859 TQMap<TQString, TDEShortcut>::ConstIterator it;
860 for( it = map.begin(); it != map.end(); ++it ) {
861 int iSeq = keyConflict( cut, (*it) );
862 if( iSeq > -1 ) {
863 if( ignoreAction.isEmpty() || it.key() != ignoreAction ) {
864 if( bWarnUser ) {
865 if( !promptForReassign( cut.seq(iSeq), it.key(), Global, parent ))
866 return true;
867 removeGlobalShortcut( it.key(), dynamic_cast< KKeyChooser* >( parent ), (*it), cut);
868 }
869 }
870 }
871 }
872 return false;
873}
874
875void KKeyChooser::removeStandardShortcut( const TQString& name, KKeyChooser* chooser, const TDEShortcut &origCut, const TDEShortcut &cut )
876{
877 bool was_in_choosers = false;
878 if( allChoosers != NULL ) {
879 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
880 it != allChoosers->end();
881 ++it ) {
882 if( (*it) != chooser && (*it)->m_type == Standard ) {
883 was_in_choosers |= ( (*it)->removeShortcut( name, cut ));
884 }
885 }
886 }
887 if( !was_in_choosers ) { // not edited, needs to be changed in config file
888 TDEStdAccel::ShortcutList std_list;
889 TDEShortcut newCut = origCut;
890 removeFromShortcut(newCut, cut);
891 int index = std_list.index( name );
892 if ( index >= 0 ) {
893 std_list.setShortcut( index, newCut );
894 std_list.save();
895 }
896 }
897}
898
899void KKeyChooser::removeGlobalShortcut( const TQString& name, KKeyChooser* chooser, const TDEShortcut &origCut, const TDEShortcut &cut )
900{
901 bool was_in_choosers = false;
902 if( allChoosers != NULL ) {
903 for( TQValueList< KKeyChooser* >::ConstIterator it = allChoosers->begin();
904 it != allChoosers->end();
905 ++it ) {
906 if( (*it) != chooser && (*it)->m_type == Global ) {
907 was_in_choosers |= ( (*it)->removeShortcut( name, cut ));
908 }
909 }
910 }
911 if( !was_in_choosers ) { // not edited, needs to be changed in config file
912 TDEAccelActions actions;
913 TDEShortcut newCut = origCut;
914 removeFromShortcut(newCut, cut);
915 actions.insert( name, "", "", newCut, newCut);
916 actions.writeActions( "Global Shortcuts", 0, true, true );
917 }
918}
919
920bool KKeyChooser::removeShortcut( const TQString& name, const TDEShortcut &cut )
921{
922 for( TQListViewItemIterator it( d->pList ); it.current(); ++it ) {
923 KKeyChooserItem* pItem2 = dynamic_cast<KKeyChooserItem*>(it.current());
924 if( pItem2 && pItem2->actionName() == name ) {
925 // remove the shortcut from it
926 TDEShortcut cut2 = pItem2->shortcut();
927 removeFromShortcut(cut2, cut);
928 pItem2->setShortcut(cut2);
929 updateButtons();
930 emit keyChange();
931 return true;
932 }
933 }
934 return false;
935}
936
937// KDE4 remove this
938void KKeyChooser::_warning( const KKeySequence& cut, TQString sAction, TQString sTitle )
939{
940 sAction = sAction.stripWhiteSpace();
941
942 TQString s =
943 i18n("The '%1' key combination has already been allocated "
944 "to the \"%2\" action.\n"
945 "Please choose a unique key combination.").
946 arg(cut.toString()).arg(sAction);
947
948 KMessageBox::sorry( this, s, sTitle );
949}
950
951bool KKeyChooser::promptForReassign( const KKeySequence& cut, const TQString& sAction, ActionType type, TQWidget* parent )
952{
953 if(cut.isNull())
954 return true;
955 TQString sTitle;
956 TQString s;
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?");
962 }
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?");
968 }
969 else {
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?");
974 }
975 s = s.arg(cut.toString()).arg(sAction.stripWhiteSpace());
976
977 return KMessageBox::warningContinueCancel( parent, s, sTitle, i18n("Reassign") ) == KMessageBox::Continue;
978}
979
980//---------------------------------------------------
981KKeyChooserItem::KKeyChooserItem( TDEListView* parent, TQListViewItem* after, TDEShortcutList* pList, uint iAction )
982: TDEListViewItem( parent, after )
983{
984 m_pList = pList;
985 m_iAction = iAction;
986 m_bModified = false;
987 m_cut = m_pList->shortcut(m_iAction);
988}
989
990KKeyChooserItem::KKeyChooserItem( TQListViewItem* parent, TQListViewItem* after, TDEShortcutList* pList, uint iAction )
991: TDEListViewItem( parent, after )
992{
993 m_pList = pList;
994 m_iAction = iAction;
995 m_bModified = false;
996 m_cut = m_pList->shortcut(m_iAction);
997}
998
999TQString KKeyChooserItem::actionName() const
1000{
1001 return m_pList->name(m_iAction);
1002}
1003
1004const TDEShortcut& KKeyChooserItem::shortcut() const
1005{
1006 return m_cut;
1007}
1008
1009void KKeyChooserItem::setShortcut( const TDEShortcut& cut )
1010{
1011 m_cut = cut;
1012 m_bModified = (m_cut != m_pList->shortcut(m_iAction));
1013 listView()->repaintItem( this );
1014}
1015
1016void KKeyChooserItem::commitChanges()
1017{
1018 if( m_bModified )
1019 m_pList->setShortcut( m_iAction, m_cut );
1020}
1021
1022TQString KKeyChooserItem::text( int iCol ) const
1023{
1024 if( iCol == 0 ) {
1025 // Quick HACK to get rid of '&'s.
1026 TQString s = m_pList->label(m_iAction);
1027 TQString s2;
1028 for( uint i = 0; i < s.length(); i++ )
1029 if( s[i] != '&' || ( i+1<s.length() && s[i+1] == '&' ) )
1030 s2 += s[i];
1031 return s2;
1032 }
1033 else if( iCol <= (int) m_cut.count() )
1034 return m_cut.seq(iCol-1).toString();
1035 else
1036 return TQString::null;
1037}
1038
1039int KKeyChooserItem::compare( TQListViewItem* item, int iCol, bool bAscending ) const
1040{
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 );
1049
1050 // Check if the last word is one or more digits
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;
1055 }
1056 }
1057
1058 return TQListViewItem::compare( item, iCol, bAscending );
1059}
1060
1062
1063TQString KKeyChooserWhatsThis::text( const TQPoint& p ) {
1064 if ( !m_listView )
1065 return TQString::null;
1066
1067 const TQListViewItem* item = m_listView->itemAt( p );
1068 const KKeyChooserItem* pItem = dynamic_cast<const KKeyChooserItem*>(item);
1069 if ( !pItem )
1070 return TQWhatsThis::textFor( m_listView );
1071
1072 const TQString itemWhatsThis = pItem->whatsThis();
1073 if ( itemWhatsThis.isEmpty() )
1074 return TQWhatsThis::textFor( m_listView );
1075
1076 return itemWhatsThis;
1077}
1078
1079/************************************************************************/
1080/* KKeyDialog */
1081/* */
1082/* Originally by Nicolas Hadacek <hadacek@via.ecp.fr> */
1083/* */
1084/* Substantially revised by Mark Donohoe <donohoe@kde.org> */
1085/* */
1086/* And by Espen Sand <espen@kde.org> 1999-10-19 */
1087/* (by using KDialogBase there is almost no code left ;) */
1088/* */
1089/************************************************************************/
1090KKeyDialog::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 )
1092{
1093 m_pKeyChooser = new KKeyChooser( this, type, bAllowLetterShortcuts );
1094 setMainWidget( m_pKeyChooser );
1095 connect( this, TQ_SIGNAL(defaultClicked()), m_pKeyChooser, TQ_SLOT(allDefault()) );
1096
1097 TDEConfigGroup group( TDEGlobal::config(), "KKeyDialog Settings" );
1098 TQSize sz = size();
1099 resize( group.readSizeEntry( "Dialog Size", &sz ) );
1100}
1101
1102KKeyDialog::KKeyDialog( bool bAllowLetterShortcuts, TQWidget *parent, const char* name )
1103: KDialogBase( parent, name ? name : "kkeydialog", true, i18n("Configure Shortcuts"), Default|Ok|Cancel, Ok )
1104{
1105 m_pKeyChooser = new KKeyChooser( this, KKeyChooser::Application, bAllowLetterShortcuts );
1106 setMainWidget( m_pKeyChooser );
1107 connect( this, TQ_SIGNAL(defaultClicked()), m_pKeyChooser, TQ_SLOT(allDefault()) );
1108
1109 TDEConfigGroup group( TDEGlobal::config(), "KKeyDialog Settings" );
1110 TQSize sz = size();
1111 resize( group.readSizeEntry( "Dialog Size", &sz ) );
1112}
1113
1114KKeyDialog::~KKeyDialog()
1115{
1116 TDEConfigGroup group( TDEGlobal::config(), "KKeyDialog Settings" );
1117 group.writeEntry( "Dialog Size", size(), true, true );
1118}
1119
1120bool KKeyDialog::insert( TDEActionCollection* pColl )
1121{
1122 return m_pKeyChooser->insert( pColl );
1123}
1124
1125bool KKeyDialog::insert(TDEActionCollection *pColl, const TQString &title)
1126{
1127 return m_pKeyChooser->insert(pColl, title);
1128}
1129
1130bool KKeyDialog::configure( bool bSaveSettings )
1131{
1132 int retcode = exec();
1133 if( retcode == Accepted ) {
1134 if( bSaveSettings )
1135 m_pKeyChooser->save();
1136 else
1137 commitChanges();
1138 }
1139 return retcode;
1140}
1141
1142void KKeyDialog::commitChanges()
1143{
1144 m_pKeyChooser->commitChanges();
1145}
1146
1147int KKeyDialog::configure( TDEActionCollection* coll, TQWidget* parent, bool bSaveSettings )
1148{
1149 return configure( coll, true, parent, bSaveSettings);
1150}
1151
1152int KKeyDialog::configure( TDEAccel* keys, TQWidget* parent, bool bSaveSettings )
1153{
1154 return configure( keys, true, parent, bSaveSettings);
1155}
1156
1157int KKeyDialog::configure( TDEGlobalAccel* keys, TQWidget* parent, bool bSaveSettings )
1158{
1159 return configure( keys, true, parent, bSaveSettings);
1160}
1161
1162int KKeyDialog::configure( TDEAccel* keys, bool bAllowLetterShortcuts, TQWidget *parent, bool bSaveSettings )
1163{
1164 KKeyDialog dlg( bAllowLetterShortcuts, parent );
1165 dlg.m_pKeyChooser->insert( keys );
1166 bool b = dlg.configure( bSaveSettings );
1167 if( b && bSaveSettings )
1168 keys->updateConnections();
1169 return b;
1170}
1171
1172int KKeyDialog::configure( TDEGlobalAccel* keys, bool bAllowLetterShortcuts, TQWidget *parent, bool bSaveSettings )
1173{
1174 KKeyDialog dlg( KKeyChooser::ApplicationGlobal, bAllowLetterShortcuts, parent );
1175 dlg.m_pKeyChooser->insert( keys );
1176 bool b = dlg.configure( bSaveSettings );
1177 if( b && bSaveSettings )
1178 keys->updateConnections();
1179 return b;
1180}
1181
1182int KKeyDialog::configure( TDEActionCollection* coll, bool bAllowLetterShortcuts, TQWidget *parent, bool bSaveSettings )
1183{
1184 kdDebug(125) << "KKeyDialog::configureKeys( TDEActionCollection*, " << bSaveSettings << " )" << endl;
1185 KKeyDialog dlg( bAllowLetterShortcuts, parent );
1186 dlg.m_pKeyChooser->insert( coll );
1187 return dlg.configure( bSaveSettings );
1188}
1189
1190/*int KKeyDialog::configure( TDEActionPtrList* coll, const TQString& file, TQWidget *parent, bool bSaveSettings )
1191{
1192 kdDebug(125) << "KKeyDialog::configureKeys( TDEActionCollection*, " << file << ", " << bSaveSettings << " )" << endl;
1193 TDEAccelActions actions;
1194 coll->createKeyMap( actions );
1195
1196 int retcode = configure( actions, file, parent, bSaveSettings );
1197 if( retcode == Accepted )
1198 coll->setKeyMap( actions );
1199
1200 return retcode;
1201}*/
1202
1203void KKeyChooser::virtual_hook( int, void* )
1204{ /*BASE::virtual_hook( id, data );*/ }
1205
1206void KKeyDialog::virtual_hook( int id, void* data )
1207{ KDialogBase::virtual_hook( id, data ); }
1208
1209#include "kkeydialog.moc"
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:192
KDialogBase::setMainWidget
void setMainWidget(TQWidget *widget)
Sets the main user definable widget.
Definition: kdialogbase.cpp:1431
KDialogBase::defaultClicked
void defaultClicked()
The Default button was pressed.
KDialog::spacingHint
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Definition: kdialog.cpp:110
KKeyButton
A push button that looks like a keyboard key.
Definition: kkeybutton.h:41
KKeyChooser
Widget for configuration of TDEAccel and TDEGlobalAccel.
Definition: kkeydialog.h:59
KKeyChooser::allDefault
void allDefault()
Set all keys to their default values (bindings).
Definition: kkeydialog.cpp:615
KKeyChooser::KKeyChooser
KKeyChooser(TQWidget *parent, ActionType type=Application, bool bAllowLetterShortcuts=true)
Constructor.
Definition: kkeydialog.cpp:154
KKeyChooser::listSync
void listSync()
Rebuild list entries based on underlying map.
Definition: kkeydialog.cpp:662
KKeyChooser::checkGlobalShortcutsConflict
static bool checkGlobalShortcutsConflict(const TDEShortcut &cut, bool warnUser, TQWidget *parent)
Checks whether the given shortcut conflicts with global keyboard shortcuts.
Definition: kkeydialog.cpp:849
KKeyChooser::save
void save()
This commits and then saves the actions to disk.
Definition: kkeydialog.cpp:285
KKeyChooser::buildListView
void buildListView(uint iList, const TQString &title=TQString::null)
Definition: kkeydialog.cpp:461
KKeyChooser::commitChanges
void commitChanges()
This function writes any shortcut changes back to the original action set(s).
Definition: kkeydialog.cpp:273
KKeyChooser::insert
bool insert(TDEActionCollection *)
Insert an action collection, i.e.
Definition: kkeydialog.cpp:233
KKeyChooser::checkStandardShortcutsConflict
static bool checkStandardShortcutsConflict(const TDEShortcut &cut, bool warnUser, TQWidget *parent)
Checks whether the given shortcut conflicts with standard keyboard shortcuts.
Definition: kkeydialog.cpp:831
KKeyChooser::setPreferFourModifierKeys
void setPreferFourModifierKeys(bool preferFourModifierKeys)
Specifies whether to use the 3 or 4 modifier key scheme.
Definition: kkeydialog.cpp:647
KKeyChooser::keyChange
void keyChange()
Emitted when an action's shortcut has been changed.
KKeyDialog
Dialog for configuration of TDEActionCollection, TDEAccel, and TDEGlobalAccel.
Definition: kkeydialog.h:275
KKeyDialog::KKeyDialog
KKeyDialog(bool bAllowLetterShortcuts=true, TQWidget *parent=0, const char *name=0)
Constructs a KKeyDialog called name as a child of parent.
Definition: kkeydialog.cpp:1102
KKeyDialog::commitChanges
void commitChanges()
Commit key setting changes so that changed settings actually become active.
Definition: kkeydialog.cpp:1142
KKeyDialog::~KKeyDialog
virtual ~KKeyDialog()
Destructor.
Definition: kkeydialog.cpp:1114
KKeyDialog::configure
bool configure(bool bSaveSettings=true)
Run the dialog and call commitChanges() if bSaveSettings is true.
Definition: kkeydialog.cpp:1130
KKeyDialog::insert
bool insert(TDEActionCollection *)
Insert an action collection, i.e.
Definition: kkeydialog.cpp:1120
KKeySequence
KKeySequence::toString
TQString toString() const
KKeySequence::key
const KKey & key(uint i) const
KKey
KMessageBox::sorry
static void sorry(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
Display an "Sorry" dialog.
Definition: tdemessagebox.cpp:825
KMessageBox::warningContinueCancel
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.
Definition: tdemessagebox.cpp:585
KStaticDeleter
TDEAboutData::programName
TQString programName() const
TDEAccelShortcutList
TDEAccel
TDEAccel::updateConnections
bool updateConnections()
TDEActionCollection
A managed set of TDEAction objects.
Definition: tdeactioncollection.h:79
TDEActionCollection::instance
TDEInstance * instance() const
The instance with which this class is associated.
Definition: tdeactioncollection.cpp:468
TDEConfigBase
TDEConfigBase::readEntry
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
TDEConfigBase::readSizeEntry
TQSize readSizeEntry(const TQString &pKey, const TQSize *pDefault=0L) const
TDEConfigBase::writeEntry
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
TDEConfigGroupSaver
TDEConfigGroup
TDEConfig::entryMap
virtual TQMap< TQString, TQString > entryMap(const TQString &pGroup) const
TDEGlobalAccel
TDEGlobalAccel::updateConnections
bool updateConnections()
TDEGlobal::config
static TDEConfig * config()
TDEInstance::aboutData
const TDEAboutData * aboutData() const
TDEListViewItem
A listview item with support for alternate background colors.
Definition: tdelistview.h:1119
TDEListViewSearchLine
This class makes it easy to add a search line for filtering the items in a listview based on a simple...
Definition: tdelistviewsearchline.h:48
TDEListViewSearchLine::setSearchColumns
void setSearchColumns(const TQValueList< int > &columns)
Sets the list of columns to be searched.
Definition: tdelistviewsearchline.cpp:173
TDEListViewSearchLine::setListView
void setListView(TDEListView *lv)
Sets the TDEListView that is filtered by this search line.
Definition: tdelistviewsearchline.cpp:178
TDEListView
This Widget extends the functionality of TQListView to honor the system wide settings for Single Clic...
Definition: tdelistview.h:85
TDEShortcutList
TDEShortcutList::index
virtual int index(const TQString &sName) const
TDEShortcutList::count
virtual uint count() const=0
TDEShortcutList::shortcut
virtual const TDEShortcut & shortcut(uint index) const=0
TDEShortcutList::name
virtual TQString name(uint index) const=0
TDEShortcutList::label
virtual TQString label(uint index) const=0
TDEShortcutList::isConfigurable
virtual bool isConfigurable(uint index) const=0
TDEShortcut
TDEShortcut::remove
void remove(const KKeySequence &keySeq)
TDEShortcut::count
uint count() const
TDEShortcut::toString
TQString toString() const
TDEShortcut::seq
const KKeySequence & seq(uint i) const
TDEShortcut::isNull
bool isNull() const
TDEStdAccel::ShortcutList
TDEStdAccel::ShortcutList::save
virtual bool save() const
TDEStdAccel::ShortcutList::setShortcut
virtual bool setShortcut(uint index, const TDEShortcut &shortcut)
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
TDEStdAccel::StdAccel
StdAccel
TDEStdAccel::key
int key(StdAccel id)
TDEStdAccel::name
TQString name(StdAccel id)
TDEStdAccel::cut
const TDEShortcut & cut()
TDEStdAccel::shortcutDefault
TDEShortcut shortcutDefault(StdAccel id)
TDEStdAccel::findStdAccel
StdAccel findStdAccel(const KKeySequence &keySeq)
TDEStdAccel::whatsThis
TQString whatsThis(StdAccel id)
TDEStdAccel::label
TQString label(StdAccel id)
TDEStdAccel::shortcut
const TDEShortcut & shortcut(StdAccel id)
tdelocale.h

tdeui

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

tdeui

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