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

tdecore

  • tdecore
tdeaccelbase.cpp
1 /*
2  Copyright (C) 1997-2000 Nicolas Hadacek <hadacek@kde.org>
3  Copyright (C) 1998 Mark Donohoe <donohoe@kde.org>
4  Copyright (C) 1998 Matthias Ettrich <ettrich@kde.org>
5  Copyright (c) 2001,2002 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 "tdeaccelbase.h"
24 
25 #include <tqkeycode.h>
26 #include <tqlabel.h>
27 #include <tqpopupmenu.h>
28 
29 #include <tdeconfig.h>
30 #include "kckey.h"
31 #include <kdebug.h>
32 #include <tdeglobal.h>
33 #include <kkeynative.h>
34 #include "kkeyserver.h"
35 #include <tdelocale.h>
36 #include "tdeshortcutmenu.h"
37 
38 //---------------------------------------------------------------------
39 // class TDEAccelBase::ActionInfo
40 //---------------------------------------------------------------------
41 
42 //---------------------------------------------------------------------
43 // class TDEAccelBase
44 //---------------------------------------------------------------------
45 
46 TDEAccelBase::TDEAccelBase( int fInitCode )
47 : m_rgActions( this )
48 {
49  kdDebug(125) << "TDEAccelBase(): this = " << this << endl;
50  m_bNativeKeys = fInitCode & NATIVE_KEYS;
51  m_bEnabled = true;
52  m_sConfigGroup = "Shortcuts";
53  m_bConfigIsGlobal = false;
54  m_bAutoUpdate = false;
55  mtemp_pActionRemoving = 0;
56 }
57 
58 TDEAccelBase::~TDEAccelBase()
59 {
60  kdDebug(125) << "~TDEAccelBase(): this = " << this << endl;
61 }
62 
63 uint TDEAccelBase::actionCount() const { return m_rgActions.count(); }
64 TDEAccelActions& TDEAccelBase::actions() { return m_rgActions; }
65 bool TDEAccelBase::isEnabled() const { return m_bEnabled; }
66 // see TDEGlobalAccel::blockShortcuts() stuff - it's to temporarily block
67 // all global shortcuts, so that the key grabs are released, but from the app's
68 // point of view the TDEGlobalAccel is still enabled, so TDEGlobalAccel needs
69 // to disable key grabbing even if enabled
70 bool TDEAccelBase::isEnabledInternal() const { return isEnabled(); }
71 
72 TDEAccelAction* TDEAccelBase::actionPtr( const TQString& sAction )
73  { return m_rgActions.actionPtr( sAction ); }
74 
75 const TDEAccelAction* TDEAccelBase::actionPtr( const TQString& sAction ) const
76  { return m_rgActions.actionPtr( sAction ); }
77 
78 TDEAccelAction* TDEAccelBase::actionPtr( const KKeyServer::Key& key )
79 {
80  if( !m_mapKeyToAction.contains( key ) )
81  return 0;
82  // Note: If more than one action is connected to a single key, nil will be returned.
83  return m_mapKeyToAction[key].pAction;
84 }
85 
86 TDEAccelAction* TDEAccelBase::actionPtr( const KKey& key )
87 {
88  KKeyServer::Key k2;
89  k2.init( key, !m_bNativeKeys );
90  return actionPtr( k2 );
91 }
92 
93 void TDEAccelBase::setConfigGroup( const TQString& sConfigGroup )
94  { m_sConfigGroup = sConfigGroup; }
95 
96 void TDEAccelBase::setConfigGlobal( bool global )
97  { m_bConfigIsGlobal = global; }
98 
99 bool TDEAccelBase::setActionEnabled( const TQString& sAction, bool bEnable )
100 {
101  TDEAccelAction* pAction = actionPtr( sAction );
102  if( pAction ) {
103  if( pAction->m_bEnabled != bEnable ) {
104  kdDebug(125) << "TDEAccelBase::setActionEnabled( " << sAction << ", " << bEnable << " )" << endl;
105  pAction->m_bEnabled = bEnable;
106  if( m_bAutoUpdate ) {
107  // FIXME: the action may already have it's connections inserted!
108  if( bEnable )
109  insertConnection( pAction );
110  else if( pAction->isConnected() )
111  removeConnection( pAction );
112  }
113  }
114  return true;
115  }
116  return false;
117 }
118 
119 bool TDEAccelBase::setAutoUpdate( bool bAuto )
120 {
121  kdDebug(125) << "TDEAccelBase::setAutoUpdate( " << bAuto << " ): m_bAutoUpdate on entrance = " << m_bAutoUpdate << endl;
122  bool b = m_bAutoUpdate;
123  if( !m_bAutoUpdate && bAuto )
124  updateConnections();
125  m_bAutoUpdate = bAuto;
126  return b;
127 }
128 
129 TDEAccelAction* TDEAccelBase::insert( const TQString& sAction, const TQString& sDesc, const TQString& sHelp,
130  const TDEShortcut& rgCutDefaults3, const TDEShortcut& rgCutDefaults4,
131  const TQObject* pObjSlot, const char* psMethodSlot,
132  bool bConfigurable, bool bEnabled )
133 {
134  kdDebug(125) << "TDEAccelBase::insert() begin" << endl;
135  kdDebug(125) << "\t" << sAction << ": " << rgCutDefaults3.toString() << ": " << rgCutDefaults4.toString() << endl;
136  TDEAccelAction* pAction = m_rgActions.insert(
137  sAction, sDesc, sHelp,
138  rgCutDefaults3, rgCutDefaults4,
139  pObjSlot, psMethodSlot,
140  bConfigurable, bEnabled );
141 
142  if( pAction && m_bAutoUpdate )
143  insertConnection( pAction );
144 
145  //kdDebug(125) << "TDEAccelBase::insert() end" << endl;
146  return pAction;
147 }
148 
149 TDEAccelAction* TDEAccelBase::insert( const TQString& sName, const TQString& sDesc )
150  { return m_rgActions.insert( sName, sDesc ); }
151 
152 bool TDEAccelBase::remove( const TQString& sAction )
153 {
154  return m_rgActions.remove( sAction );
155 }
156 
157 void TDEAccelBase::slotRemoveAction( TDEAccelAction* pAction )
158 {
159  removeConnection( pAction );
160 }
161 
162 bool TDEAccelBase::setActionSlot( const TQString& sAction, const TQObject* pObjSlot, const char* psMethodSlot )
163 {
164  kdDebug(125) << "TDEAccelBase::setActionSlot( " << sAction << ", " << pObjSlot << ", " << psMethodSlot << " )\n";
165  TDEAccelAction* pAction = m_rgActions.actionPtr( sAction );
166  if( pAction ) {
167  // If there was a previous connection, remove it.
168  if( m_bAutoUpdate && pAction->isConnected() ) {
169  kdDebug(125) << "\tm_pObjSlot = " << pAction->m_pObjSlot << " m_psMethodSlot = " << pAction->m_psMethodSlot << endl;
170  removeConnection( pAction );
171  }
172 
173  pAction->m_pObjSlot = pObjSlot;
174  pAction->m_psMethodSlot = psMethodSlot;
175 
176  // If we're setting a connection,
177  if( m_bAutoUpdate && pObjSlot && psMethodSlot )
178  insertConnection( pAction );
179 
180  return true;
181  } else
182  return false;
183 }
184 
185 /*
186 TDEAccelBase
187  Run Command=Meta+Enter;Alt+F2
188  TDEAccelAction = "Run Command"
189  1) TDEAccelKeySeries = "Meta+Enter"
190  1a) Meta+Enter
191  1b) Meta+Keypad_Enter
192  2) TDEAccelKeySeries = "Alt+F2"
193  1a) Alt+F2
194 
195  Konqueror=Meta+I,I
196  TDEAccelAction = "Konqueror"
197  1) TDEAccelKeySeries = "Meta+I,I"
198  1a) Meta+I
199  2a) I
200 
201  Something=Meta+Asterisk,X
202  TDEAccelAction = "Something"
203  1) TDEAccelKeySeries = "Meta+Asterisk,X"
204  1a) Meta+Shift+8
205  1b) Meta+Keypad_8
206  2a) X
207 
208 read in a config entry
209  split by ';'
210  find key sequences to disconnect
211  find new key sequences to connect
212 check for conflicts with implicit keys
213  disconnect conflicting implicit keys
214 connect new key sequences
215 */
216 /*
217 {
218  For {
219  for( TDEAccelAction::iterator itAction = m_rgActions.begin(); itAction != m_rgActions.end(); ++itAction ) {
220  TDEAccelAction& action = *itAction;
221  for( TDEAccelSeries::iterator itSeries = action.m_rgSeries.begin(); itSeries != action.m_rgSeries.end(); ++itSeries ) {
222  TDEAccelSeries& series = *itSeries;
223  if(
224  }
225  }
226  }
227  Sort by: iVariation, iSequence, iSeries, iAction
228 
229  1) TDEAccelAction = "Run Command"
230  1) TDEAccelKeySeries = "Meta+Enter"
231  1a) Meta+Enter
232  1b) Meta+Keypad_Enter
233  2) TDEAccelKeySeries = "Alt+F2"
234  1a) Alt+F2
235 
236  2) TDEAccelAction = "Enter Calculation"
237  1) TDEAccelKeySeries = "Meta+Keypad_Enter"
238  1a) Meta+Keypad_Enter
239 
240  List =
241  Meta+Enter -> 1, 1, 1a
242  Meta+Keypad_Enter -> 2, 1, 1a
243  Alt+F2 -> 1, 2, 1a
244  [Meta+Keypad_Enter] -> [1, 1, 1b]
245 
246 }
247 */
248 
249 #ifdef Q_WS_X11
250 struct TDEAccelBase::X
251 {
252  uint iAction, iSeq, iVari;
253  KKeyServer::Key key;
254 
255  X() {}
256  X( uint _iAction, uint _iSeq, uint _iVari, const KKeyServer::Key& _key )
257  { iAction = _iAction; iSeq = _iSeq; iVari = _iVari; key = _key; }
258 
259  int compare( const X& x )
260  {
261  int n = key.compare( x.key );
262  if( n != 0 ) return n;
263  if( iVari != x.iVari ) return iVari - x.iVari;
264  if( iSeq != x.iSeq ) return iSeq - x.iSeq;
265  return 0;
266  }
267 
268  bool operator <( const X& x ) { return compare( x ) < 0; }
269  bool operator >( const X& x ) { return compare( x ) > 0; }
270  bool operator <=( const X& x ) { return compare( x ) <= 0; }
271 };
272 #endif //Q_WS_X11
273 
274 /*
275 #1 Ctrl+A
276 #2 Ctrl+A
277 #3 Ctrl+B
278  ------
279  Ctrl+A => Null
280  Ctrl+B => #3
281 
282 #1 Ctrl+A
283 #1 Ctrl+B;Ctrl+A
284  ------
285  Ctrl+A => #1
286  Ctrl+B => #2
287 
288 #1 Ctrl+A
289 #1 Ctrl+B,C
290 #1 Ctrl+B,D
291  ------
292  Ctrl+A => #1
293  Ctrl+B => Null
294 
295 #1 Ctrl+A
296 #2 Ctrl+Plus(Ctrl+KP_Add)
297  ------
298  Ctrl+A => #1
299  Ctrl+Plus => #2
300  Ctrl+KP_Add => #2
301 
302 #1 Ctrl+Plus(Ctrl+KP_Add)
303 #2 Ctrl+KP_Add
304  ------
305  Ctrl+Plus => #1
306  Ctrl+KP_Add => #2
307 
308 #1 Ctrl+Plus(Ctrl+KP_Add)
309 #2 Ctrl+A;Ctrl+KP_Add
310  ------
311  Ctrl+A => #2
312  Ctrl+Plus => #1
313  Ctrl+KP_Add => #2
314 */
315 
316 bool TDEAccelBase::updateConnections()
317 {
318 #ifdef Q_WS_X11
319  kdDebug(125) << "TDEAccelBase::updateConnections() this = " << this << endl;
320  // Retrieve the list of keys to be connected, sorted by priority.
321  // (key, variation, seq)
322  TQValueVector<X> rgKeys;
323  createKeyList( rgKeys );
324  m_rgActionsNonUnique.clear();
325 
326  KKeyToActionMap mapKeyToAction;
327  for( uint i = 0; i < rgKeys.size(); i++ ) {
328  X& x = rgKeys[i];
329  KKeyServer::Key& key = x.key;
330  ActionInfo info;
331  bool bNonUnique = false;
332 
333  info.pAction = m_rgActions.actionPtr( x.iAction );
334  info.iSeq = x.iSeq;
335  info.iVariation = x.iVari;
336 
337  // If this is a multi-key shortcut,
338  if( info.pAction->shortcut().seq(info.iSeq).count() > 1 )
339  bNonUnique = true;
340  // If this key is requested by more than one action,
341  else if( i < rgKeys.size() - 1 && key == rgKeys[i+1].key ) {
342  // If multiple actions requesting this key
343  // have the same priority as the first one,
344  if( info.iVariation == rgKeys[i+1].iVari && info.iSeq == rgKeys[i+1].iSeq )
345  bNonUnique = true;
346 
347  kdDebug(125) << "key conflict = " << key.key().toStringInternal()
348  << " action1 = " << info.pAction->name()
349  << " action2 = " << m_rgActions.actionPtr( rgKeys[i+1].iAction )->name()
350  << " non-unique = " << bNonUnique << endl;
351 
352  // Skip over the other records with this same key.
353  while( i < rgKeys.size() - 1 && key == rgKeys[i+1].key )
354  i++;
355  }
356 
357  if( bNonUnique ) {
358  // Remove connection to single action if there is one
359  if( m_mapKeyToAction.contains( key ) ) {
360  TDEAccelAction* pAction = m_mapKeyToAction[key].pAction;
361  if( pAction ) {
362  m_mapKeyToAction.remove( key );
363  disconnectKey( *pAction, key );
364  pAction->decConnections();
365  m_rgActionsNonUnique.append( pAction );
366  }
367  }
368  // Indicate that no single action is associated with this key.
369  m_rgActionsNonUnique.append( info.pAction );
370  info.pAction = 0;
371  }
372 
373  kdDebug(125) << "mapKeyToAction[" << key.key().toStringInternal() << "] = " << info.pAction << endl;
374  mapKeyToAction[key] = info;
375  }
376 
377  // Disconnect keys which no longer have bindings:
378  for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it ) {
379  const KKeyServer::Key& key = it.key();
380  TDEAccelAction* pAction = (*it).pAction;
381  // If this key is longer used or it points to a different action now,
382  if( !mapKeyToAction.contains( key ) || mapKeyToAction[key].pAction != pAction ) {
383  if( pAction ) {
384  disconnectKey( *pAction, key );
385  pAction->decConnections();
386  } else
387  disconnectKey( key );
388  }
389  }
390 
391  // Connect any unconnected keys:
392  // In other words, connect any keys which are present in the
393  // new action map, but which are _not_ present in the old one.
394  for( KKeyToActionMap::iterator it = mapKeyToAction.begin(); it != mapKeyToAction.end(); ++it ) {
395  const KKeyServer::Key& key = it.key();
396  TDEAccelAction* pAction = (*it).pAction;
397  if( !m_mapKeyToAction.contains( key ) || m_mapKeyToAction[key].pAction != pAction ) {
398  // TODO: Decide what to do if connect fails.
399  // Probably should remove this item from map.
400  if( pAction ) {
401  if( connectKey( *pAction, key ) )
402  pAction->incConnections();
403  } else
404  connectKey( key );
405  }
406  }
407 
408  // Store new map.
409  m_mapKeyToAction = mapKeyToAction;
410 
411 #ifndef NDEBUG
412  for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it ) {
413  kdDebug(125) << "Key: " << it.key().key().toStringInternal() << " => '"
414  << (((*it).pAction) ? (*it).pAction->name() : TQString::null) << "'" << endl;
415  }
416 #endif
417 #endif //Q_WS_X11
418  return true;
419 }
420 
421 #ifdef Q_WS_X11
422 // Construct a list of keys to be connected, sorted highest priority first.
423 void TDEAccelBase::createKeyList( TQValueVector<struct X>& rgKeys )
424 {
425  kdDebug(125) << "TDEAccelBase::createKeyList()" << endl;
426  if( !isEnabledInternal()) {
427  return;
428  }
429 
430  // create the list
431  // For each action
432  for( uint iAction = 0; iAction < m_rgActions.count(); iAction++ ) {
433  TDEAccelAction* pAction = m_rgActions.actionPtr( iAction );
434  if( pAction && pAction->m_pObjSlot && pAction->m_psMethodSlot && pAction != mtemp_pActionRemoving ) {
435  // For each key sequence associated with action
436  for( uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++ ) {
437  const KKeySequence& seq = pAction->shortcut().seq(iSeq);
438  if( seq.count() > 0 ) {
439  KKeyServer::Variations vars;
440  vars.init( seq.key(0), !m_bNativeKeys );
441  for( uint iVari = 0; iVari < vars.count(); iVari++ ) {
442  if( vars.key(iVari).code() && vars.key(iVari).sym() ) {
443  rgKeys.push_back( X( iAction, iSeq, iVari, vars.key( iVari ) ) );
444  }
445  kdDebug(125) << "\t" << pAction->name() << ": " << vars.key(iVari).key().toStringInternal() << " [action specified: " << pAction->toStringInternal() << "]" << endl;
446  }
447  }
448  //else {
449  // kdDebug(125) << "\t*" << pAction->name() << ":" << endl;
450  // }
451  }
452  }
453  }
454 
455  // sort by priority: iVariation[of first key], iSequence, iAction
456  qHeapSort( rgKeys.begin(), rgKeys.end() );
457 }
458 #endif //Q_WS_X11
459 
460 bool TDEAccelBase::insertConnection( TDEAccelAction* pAction )
461 {
462  if( !pAction->m_pObjSlot || !pAction->m_psMethodSlot )
463  return true;
464 
465  kdDebug(125) << "TDEAccelBase::insertConnection( " << pAction << "=\"" << pAction->m_sName << "\"; shortcut = " << pAction->shortcut().toStringInternal() << " ) this = " << this << endl;
466 
467  // For each sequence associated with the given action:
468  for( uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++ ) {
469  // Get the first key of the sequence.
470  KKeyServer::Variations vars;
471  vars.init( pAction->shortcut().seq(iSeq).key(0), !m_bNativeKeys );
472  for( uint iVari = 0; iVari < vars.count(); iVari++ ) {
473  const KKeyServer::Key& key = vars.key( iVari );
474 
475  //if( !key.isNull() ) {
476  if( key.sym() ) {
477  if( !m_mapKeyToAction.contains( key ) ) {
478  // If this is a single-key shortcut,
479  if( pAction->shortcut().seq(iSeq).count() == 1 ) {
480  m_mapKeyToAction[key] = ActionInfo( pAction, iSeq, iVari );
481  if( connectKey( *pAction, key ) )
482  pAction->incConnections();
483  }
484  // Else this is a multi-key shortcut,
485  else {
486  m_mapKeyToAction[key] = ActionInfo( 0, 0, 0 );
487  // Insert into non-unique list if it's not already there.
488  if( m_rgActionsNonUnique.findIndex( pAction ) == -1 )
489  m_rgActionsNonUnique.append( pAction );
490  if( connectKey( key ) )
491  pAction->incConnections();
492  }
493  } else {
494  // There is a key conflict. A full update
495  // check is necessary.
496  // TODO: make this more efficient where possible.
497  if( m_mapKeyToAction[key].pAction != pAction
498  && m_mapKeyToAction[key].pAction != 0 ) {
499  kdDebug(125) << "Key conflict with action = " << m_mapKeyToAction[key].pAction->name()
500  << " key = " << key.key().toStringInternal() << " : call updateConnections()" << endl;
501  return updateConnections();
502  }
503  }
504  }
505  }
506  }
507 
508  //kdDebug(125) << "\tActions = " << m_rgActions.size() << endl;
509  //for( TDEAccelActions::const_iterator it = m_rgActions.begin(); it != m_rgActions.end(); ++it ) {
510  // kdDebug(125) << "\t" << &(*it) << " '" << (*it).m_sName << "'" << endl;
511  //}
512 
513  //kdDebug(125) << "\tKeys = " << m_mapKeyToAction.size() << endl;
514  //for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it ) {
515  // //kdDebug(125) << "\tKey: " << it.key().toString() << " => '" << (*it)->m_sName << "'" << endl;
516  // kdDebug(125) << "\tKey: " << it.key().toString() << " => '" << *it << "'" << endl;
517  // kdDebug(125) << "\t\t'" << (*it)->m_sName << "'" << endl;
518  //}
519 
520  return true;
521 }
522 
523 bool TDEAccelBase::removeConnection( TDEAccelAction* pAction )
524 {
525  kdDebug(125) << "TDEAccelBase::removeConnection( " << pAction << " = \"" << pAction->m_sName << "\"; shortcut = " << pAction->m_cut.toStringInternal() << " ): this = " << this << endl;
526 
527  //for( KKeyToActionMap::iterator it = m_mapKeyToAction.begin(); it != m_mapKeyToAction.end(); ++it )
528  // kdDebug(125) << "\tKey: " << it.key().toString() << " => '" << (*it)->m_sName << "'" << " " << *it << endl;
529 
530  if( m_rgActionsNonUnique.findIndex( pAction ) >= 0 ) {
531  mtemp_pActionRemoving = pAction;
532  bool b = updateConnections();
533  mtemp_pActionRemoving = 0;
534  return b;
535  }
536 
537  KKeyToActionMap::iterator it = m_mapKeyToAction.begin();
538  while( it != m_mapKeyToAction.end() ) {
539  KKeyServer::Key key = it.key();
540  ActionInfo* pInfo = &(*it);
541 
542  // If the given action is connected to this key,
543  if( pAction == pInfo->pAction ) {
544  disconnectKey( *pAction, key );
545  pAction->decConnections();
546 
547  KKeyToActionMap::iterator itRemove = it++;
548  m_mapKeyToAction.remove( itRemove );
549  } else
550  ++it;
551  }
552  return true;
553 }
554 
555 bool TDEAccelBase::setShortcut( const TQString& sAction, const TDEShortcut& cut )
556 {
557  TDEAccelAction* pAction = actionPtr( sAction );
558  if( pAction ) {
559  if( m_bAutoUpdate )
560  removeConnection( pAction );
561 
562  pAction->setShortcut( cut );
563 
564  if( m_bAutoUpdate && !pAction->shortcut().isNull() )
565  insertConnection( pAction );
566  return true;
567  } else
568  return false;
569 }
570 
571 void TDEAccelBase::readSettings( TDEConfigBase* pConfig )
572 {
573  m_rgActions.readActions( m_sConfigGroup, pConfig );
574  if( m_bAutoUpdate )
575  updateConnections();
576 }
577 
578 void TDEAccelBase::writeSettings( TDEConfigBase* pConfig ) const
579 {
580  m_rgActions.writeActions( m_sConfigGroup, pConfig, m_bConfigIsGlobal, m_bConfigIsGlobal );
581 }
582 
583 TQPopupMenu* TDEAccelBase::createPopupMenu( TQWidget* pParent, const KKeySequence& seq )
584 {
585  TDEShortcutMenu* pMenu = new TDEShortcutMenu( pParent, &actions(), seq );
586 
587  bool bActionInserted = false;
588  bool bInsertSeparator = false;
589  for( uint i = 0; i < actionCount(); i++ ) {
590  const TDEAccelAction* pAction = actions().actionPtr( i );
591 
592  if( !pAction->isEnabled() )
593  continue;
594 
595  // If an action has already been inserted into the menu
596  // and we have a label instead of an action here,
597  // then indicate that we should insert a separator before the next menu entry.
598  if( bActionInserted && !pAction->isConfigurable() && pAction->name().contains( ':' ) )
599  bInsertSeparator = true;
600 
601  for( uint iSeq = 0; iSeq < pAction->shortcut().count(); iSeq++ ) {
602  const KKeySequence& seqAction = pAction->shortcut().seq(iSeq);
603  if( seqAction.startsWith( seq ) ) {
604  if( bInsertSeparator ) {
605  pMenu->insertSeparator();
606  bInsertSeparator = false;
607  }
608 
609  pMenu->insertAction( i, seqAction );
610 
611  //kdDebug(125) << "sLabel = " << sLabel << ", seq = " << (TQString)seqMenu.qt() << ", i = " << i << endl;
612  //kdDebug(125) << "pMenu->accel(" << i << ") = " << (TQString)pMenu->accel(i) << endl;
613  bActionInserted = true;
614  break;
615  }
616  }
617  }
618  pMenu->updateShortcuts();
619  return pMenu;
620 }
KKeyServer::Key::key
KKey key() const
Converts this Key to a KKey.
TDEGlobal::kdDebug
kdbgstream kdDebug(int area=0)
Definition: kdebug.cpp:369
KKeyServer::Variations
TODO: please document this class.
Definition: kkeyserver_x11.h:244
KKeySequence
A KKeySequence object holds a sequence of up to 4 keys.
Definition: tdeshortcut.h:288
TDEConfigBase
KDE Configuration Management abstract base class.
Definition: tdeconfigbase.h:70
KKeySequence::startsWith
bool startsWith(const KKeySequence &keySeq) const
Returns true if this key sequence begins with the given sequence.
Definition: tdeshortcut.cpp:321
tdelocale.h
KKeyServer::Key::sym
uint sym() const
Returns the symbol of the key.
Definition: kkeyserver_x11.h:186
KKeySequence::key
const KKey & key(uint i) const
Return the i'th key of this sequence, or a null key if there are less then i keys.
Definition: tdeshortcut.cpp:294
TDEShortcut::toString
TQString toString() const
Returns a description of the shortcut as semicolon-separated ket sequences, as returned by KKeySequen...
Definition: tdeshortcut.cpp:635
KKeyServer::Key::init
bool init(const KKey &key, bool bQt)
Initializes the key with a KKey.
KKey
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
Definition: tdeshortcut.h:40
TDEShortcut
The TDEShortcut class is used to represent a keyboard shortcut to an action.
Definition: tdeshortcut.h:543
KKey::toStringInternal
TQString toStringInternal() const
Returns an untranslated text representation of the key in the form "modifier+key", suitable e.g.
Definition: tdeshortcut.cpp:179
X
Definition: fixx11h.h:31
KKeyServer::Key
Represents a key press.
Definition: kkeyserver_x11.h:137
endl
kndbgstream & endl(kndbgstream &s)
Does nothing.
Definition: kdebug.h:583
KKeyServer::Key::compare
int compare(const Key &key) const
Compares this key with the given Key object.
KKeyServer::Key::code
uint code() const
Returns the code of the key.
Definition: kkeyserver_x11.h:174
TDEGlobal::endl
kdbgstream & endl(kdbgstream &s)
Definition: kdebug.h:430
KKeySequence::count
uint count() const
Returns the number of key strokes of this sequence.
Definition: tdeshortcut.cpp:289

tdecore

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

tdecore

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