[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Shortcut troubles
From:       Stefan =?iso-8859-1?q?Asserh=E4ll?= <stefan.asserhall () telia ! com>
Date:       2002-09-22 19:13:42
[Download RAW message or body]

Hi,

I did a hack in Qt to display warnings for shortcut clashes in menus, 
to detect and fix them in the Swedish translation. The hack is strictly 
for debugging, and outputs a warning when a clash is found using 
qWarning. To get the warnings, a program must be run, to create
the menus, and each RMB menu in the program must be clicked.
Patch to qmenudata.cpp attached. I also sent an e-mail to 
kde-i18n-doc with this info.

With these warnings in place I found two bugs (patches attached):
1. Upper and lower case are not handled by kdelibs/kdeui/kaccellgen.h.
2. Klipper shows '&' as '_' under the next character. (I'm not sure 
    that my patch solves the entire problem).

There are also some clashes in the original English strings. Here 
are a few examples:
  noatun: shortcut clash: '&Pause', '&Play'
  noatun: shortcut clash: 'E&qualizer...', '&Quit'
  kbabel: shortcut clash: 'Inser&t Tag', 'Cu&t'
  kbabel: shortcut clash: 'Inser&t Argument', 'Cu&t'
  kbabel: shortcut clash: 'Inser&t Argument', 'Inser&t Tag'
  kbabel: shortcut clash: 'Inser&t Tag', 'Cu&t'
  kbabel: shortcut clash: 'F&ind Selected Text', '&Insert Next Tag'
  kbabel: shortcut clash: 'Con&figure Dictionary', '&Find Text'
  catalogmanager: shortcut clash: 'Next Te&mplate Only', 'Next &Marked'
  catalogmanager: shortcut clash: '&Open Template', '&Open'
  konqueror: shortcut clash: '&Find File...', '&Forward'
  konqueror: shortcut clash: '&Properties', '&Paste'
  konqueror: shortcut clash: '&Properties', 'O&pen With...'
  konqueror: shortcut clash: 'A&dd to Bookmarks', '&Delete'
  konqueror: shortcut clash: 'O&pen With...', '&Paste'
  konqueror: shortcut clash: 'Open in &Background Tab', '&Back'
  konqueror: shortcut clash: 'Open in &New Tab', 'Create &New'
  kate: shortcut clash: '&Linux', '&Large'
  kate: shortcut clash: '&Close Terminal Emulator', '&Copy'
  kmail: shortcut clash: '&Move to Trash', '&Move To'
  kmail: shortcut clash: 'Save &As...', 'Reply to &All...'
  kmail: shortcut clash: '&Create Filter', '&Copy To'

Should these clashes be considered bugs, or can they just be ignored?
They are quite tricky to fix in some cases, e.g. for Konqueror, since the
menu items are reused in various RMB menus.

/ Stefan Asserhäll

["kaccelgen.diff" (text/x-diff)]

Index: kaccelgen.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kaccelgen.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 kaccelgen.h
--- kaccelgen.h	5 Mar 2002 23:13:27 -0000	1.2
+++ kaccelgen.h	22 Sep 2002 09:13:30 -0000
@@ -203,7 +203,9 @@ generate(Iter begin, Iter end, QStringLi
             }
 
             if( found ) {
-                used_accels.insert(item[j],true);
+                // Both upper and lower case marked as used
+                used_accels.insert(item[j].upper(),true);
+                used_accels.insert(item[j].lower(),true);
                 item.insert(j,QChar('&'));
             }
         }

["klipper.diff" (text/x-diff)]

Index: toplevel.cpp
===================================================================
RCS file: /home/kde/kdebase/klipper/toplevel.cpp,v
retrieving revision 1.111
diff -u -3 -p -r1.111 toplevel.cpp
--- toplevel.cpp	22 Sep 2002 08:58:56 -0000	1.111
+++ toplevel.cpp	22 Sep 2002 16:24:00 -0000
@@ -417,7 +417,7 @@ void KlipperWidget::slotConfigure()
         bUseGUIRegExpEditor = dlg->useGUIRegExpEditor();
         dlg->commitShortcuts();
         // the keys need to be written to kdeglobals, not kickerrc --ellis, 22/9/02
-        globalKeys->writeSettings(0, true);
+        globalKeys->writeSettings(0);
         globalKeys->updateConnections();
         toggleURLGrabAction->setShortcut(globalKeys->shortcut("Enable/Disable \
Clipboard Actions"));  
@@ -579,7 +579,8 @@ void KlipperWidget::applyClipChanges( co
     removeFromHistory( clipData );
     trimClipHistory(maxClipItems - 1);
 
-    m_selectedItem = \
m_popup->insertItem(KStringHandler::csqueeze(clipData.simplifyWhiteSpace(), 45), -2, \
1); // -2 means unique id, 1 means first location +    QString item = \
clipData.simplifyWhiteSpace().replace( QRegExp( "&" ), "&&" ); +    m_selectedItem = \
m_popup->insertItem(KStringHandler::csqueeze(item, 45), -2, 1); // -2 means unique \
id, 1 means first location  m_clipDict.insert(m_selectedItem, clipData);
     if ( bClipEmpty )
         m_popup->setItemEnabled( m_selectedItem, false );


["qmenudata.diff" (text/x-diff)]

Index: widgets/qmenudata.cpp
===================================================================
RCS file: /home/kde/qt-copy/src/widgets/qmenudata.cpp,v
retrieving revision 1.44
diff -u -3 -p -r1.44 qmenudata.cpp
--- widgets/qmenudata.cpp	6 Sep 2002 12:32:09 -0000	1.44
+++ widgets/qmenudata.cpp	22 Sep 2002 18:54:03 -0000
@@ -284,6 +284,37 @@ int QMenuData::insertAny( const QString 
     }
 
     mitems->insert( index, mi );
+
+    // Here is a hack to check for shortcut clashes
+    if ( mi->text_data ) {
+	int i = mi->text_data.find( '&' );
+	if ( i >= 0 ) {
+	    QMenuItemListIt it_check( *mitems );
+	    QMenuItem *mi_check;
+	    while ( (mi_check=it_check.current()) ) {
+		QString text_check = mi_check->text_data;
+		if ( mi_check != mi && !text_check.isEmpty() ) {
+		    int i_check = text_check.find( '&' );
+		    if ( i_check >= 0 ) {
+			QChar ch = mi->text_data[i+1];
+			QChar ch_check = text_check[i_check+1];
+			if ( !ch.isNull() && ch != '&'
+			     && !ch_check.isNull() && ch_check != '&' ) {
+			    ch = ch.upper();
+			    ch_check = ch_check.upper();
+			    if ( ch == ch_check )
+				qWarning("%s: shortcut clash: '%s', '%s'",
+					 qApp->argv()[0],
+					 mi->text_data.latin1(),
+					 text_check.latin1() );
+			}
+		    }
+		}
+		++it_check;
+	    }
+	}
+    }
+
     menuContentsChanged();			// menu data changed
     return mi->ident;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic