Author: sh-sh-sh Date: Fri Jul 11 16:35:26 2008 New Revision: 49006 URL: http://svn.opensuse.org/viewcvs/yast?rev=49006&view=rev Log: Fixed bnc #367023: Keyboard shortcuts for non-ASCII languages Modified: trunk/libyui/package/yast2-libyui.changes trunk/libyui/src/YShortcut.cc trunk/libyui/src/YShortcut.h trunk/libyui/src/YShortcutManager.cc Modified: trunk/libyui/package/yast2-libyui.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/package/yast2-libyui.changes?rev=49006&r1=49005&r2=49006&view=diff ============================================================================== --- trunk/libyui/package/yast2-libyui.changes (original) +++ trunk/libyui/package/yast2-libyui.changes Fri Jul 11 16:35:26 2008 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Fri Jul 11 16:29:47 CEST 2008 - sh@suse.de + +- Fixed bnc #367023: Keyboard shortcuts for non-ASCII languages + +------------------------------------------------------------------- Tue Jul 8 18:57:10 CEST 2008 - sh@suse.de - Enable keyboard shortcuts for YDumbTab widgets (fate #304890) Modified: trunk/libyui/src/YShortcut.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YShortcut.cc?rev=49006&r1=49005&r2=49006&view=diff ============================================================================== --- trunk/libyui/src/YShortcut.cc (original) +++ trunk/libyui/src/YShortcut.cc Fri Jul 11 16:35:26 2008 @@ -212,6 +212,21 @@ } +bool +YShortcut::hasValidShortcutChar() +{ + string clean = cleanShortcutString(); + + for ( string::size_type pos=0; pos < clean.length(); pos++ ) + { + if ( YShortcut::isValid( clean[ pos ] ) ) + return true; + } + + return false; +} + + string YShortcut::getShortcutString() { Modified: trunk/libyui/src/YShortcut.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YShortcut.h?rev=49006&r1=49005&r2=49006&view=diff ============================================================================== --- trunk/libyui/src/YShortcut.h (original) +++ trunk/libyui/src/YShortcut.h Fri Jul 11 16:35:26 2008 @@ -135,6 +135,12 @@ * string, i.e. how many different shortcuts that widget could get. **/ int distinctShortcutChars(); + + /** + * Return true if this shortcut contains any character that would be valid + * as a shortcut character. + **/ + bool hasValidShortcutChar(); /** * Static function: Returns the character used for marking keyboard @@ -196,8 +202,8 @@ string _cleanShortcutString; bool _cleanShortcutStringCached; - int _preferred; // int to enable initializing with invalid char ( -1 ) - int _shortcut; // int to enable initializing with invalid char ( -1 ) + int _preferred; // int to enable initializing with invalid char (-1) + int _shortcut; // int to enable initializing with invalid char (-1) bool _conflict; bool _isButton; Modified: trunk/libyui/src/YShortcutManager.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YShortcutManager.cc?rev=49006&r1=49005&r2=49006&view=diff ============================================================================== --- trunk/libyui/src/YShortcutManager.cc (original) +++ trunk/libyui/src/YShortcutManager.cc Fri Jul 11 16:35:26 2008 @@ -25,6 +25,12 @@ #include "YDumbTab.h" +// Threshold of widgets with valid shortcut characters below which no shortcut +// check is performed at all. This might regularly occur for languages that +// primarily use non-ASCII characters (Russian, Greek, Chinese, Japanese, +// Korean). +#define MIN_VALID_PERCENT 50 + // Return the number of elements of an array of any type #define DIM( ARRAY ) ( (int) ( sizeof( ARRAY)/( sizeof( ARRAY[0] ) ) ) ) @@ -52,6 +58,29 @@ clearShortcutList(); findShortcutWidgets( _dialog->childrenBegin(), _dialog->childrenEnd() ); + int validCount = 0; + + for ( unsigned i=0; i < _shortcutList.size(); i++ ) + { + if ( _shortcutList[i]->hasValidShortcutChar() ) + ++validCount; + } + + int validPercent = _shortcutList.size() > 0 ? + ( 100 * validCount ) / _shortcutList.size() : 0; + + if ( validPercent < MIN_VALID_PERCENT ) + { + // No check at all if there are not enough widgets with valid shortcut + // characters ([A-Za-z0-9]). This might regularly occur for languages + // that primarily use non-ASCII characters (Russian, Greek, Chinese, + // Japanese, Korean). + + yuiMilestone() << "Not enough widgets with valid shorctcut characters - no check" << endl; + yuiDebug() << "Found " << validCount << " widgets with valid shortcut characters" << endl; + return; + } + // Initialize wanted character counters for ( int i=0; i < DIM( _wanted ); i++ ) -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org