26 #define YUILogComponent "ui-shortcuts"
29 #include "YShortcutManager.h"
38 #define MIN_VALID_PERCENT 50
41 #define DIM( ARRAY ) ( (int) ( sizeof( ARRAY)/( sizeof( ARRAY[0] ) ) ) )
62 yuiDebug() <<
"Checking keyboard shortcuts" << std::endl;
78 if ( validPercent < MIN_VALID_PERCENT )
85 yuiWarning() <<
"Not enough widgets with valid shortcut characters - no check" << std::endl;
86 yuiDebug() <<
"Found " << validCount <<
" widgets with valid shortcut characters" << std::endl;
92 for (
int i=0; i < DIM(
_wanted ); i++ )
96 for (
int i=0; i < DIM(
_wanted ); i++ )
119 yuiDebug() <<
"Shortcut conflict: '" << shortcut->
preferred()
120 <<
"' used for " << shortcut->
widget()
133 yuiDebug() <<
"No valid shortcut for " << shortcut->
widget() << std::endl;
155 yuiDebug() <<
"No shortcut conflicts" << std::endl;
163 yuiDebug() <<
"Resolving shortcut conflicts" << std::endl;
167 yuiError() <<
"Call checkShortcuts() first!" << std::endl;
174 YShortcutList conflictList;
181 if ( ( *it )->conflict() )
183 conflictList.push_back( *it );
191 while ( ! conflictList.empty() )
206 YShortcut * shortcut = conflictList[ prioIndex ];
211 yuiWarning() <<
"Couldn't resolve shortcut conflict for " << shortcut->
widget() << std::endl;
217 conflictList.erase( conflictList.begin() + prioIndex );
222 yuiDebug() <<
_conflictCount <<
" shortcut conflict(s) left" << std::endl;
236 ||
_used[ (
int) candidate ] )
241 for ( std::string::size_type pos = 0; pos < str.length(); pos++ )
263 if ( candidate != shortcut->
preferred() )
267 yuiDebug() <<
"Automatically assigning shortcut '" << candidate
268 <<
"' to " << shortcut->
widgetClass() <<
"(`opt(`autoShortcut ), \""
274 yuiDebug() <<
"Reassigning shortcut '" << candidate
275 <<
"' to " << shortcut->
widget()
282 yuiDebug() <<
"Keeping preferred shortcut '" << candidate
283 <<
"' for " << shortcut->
widget()
287 _used[ (int) candidate ] =
true;
292 yuiWarning() <<
"Couldn't resolve shortcut conflict for "
294 <<
" - assigning no shortcut"
309 int shortestIndex = -1;
310 int shortestLen = -1;
312 for (
unsigned i=1; i < conflictList.size(); i++ )
314 if ( conflictList[i]->isWizardButton() )
316 if ( shortestLen < 0 ||
317 conflictList[i]->distinctShortcutChars() < shortestLen )
320 shortestLen = conflictList[i]->distinctShortcutChars();
326 return shortestIndex;
334 unsigned shortestIndex = 0;
335 int shortestLen = conflictList[ shortestIndex ]->distinctShortcutChars();
337 for (
unsigned i=1; i < conflictList.size(); i++ )
339 int currentLen = conflictList[i]->distinctShortcutChars();
341 if ( currentLen < shortestLen )
346 shortestLen = currentLen;
348 else if ( currentLen == shortestLen )
350 if ( conflictList[i]->isButton() &&
351 ! conflictList[ shortestIndex ]->isButton() )
356 shortestLen = currentLen;
361 return shortestIndex;
380 YWidgetListConstIterator end )
382 for ( YWidgetListConstIterator it = begin; it != end; ++it )
390 for ( YItemConstIterator it = dumbTab->
itemsBegin();