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

List:       kde-commits
Subject:    KDE/kdelibs/kdeui/xmlgui
From:       Michael Jansen <kde () michael-jansen ! biz>
Date:       2008-09-28 20:49:09
Message-ID: 1222634949.878834.29031.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 865753 by mjansen:

Fix for using QAction::setShortcut on an KAction on application
initialization.

Shortcuts setup over an QAction Pointer only have an active shortcut. That
broke after the shortcut scheme support came around.

CCMAIL:faure@kde.org
CCMAIL:apaku@gmx.de

 M  +22 -1     kxmlguifactory.cpp  


--- trunk/KDE/kdelibs/kdeui/xmlgui/kxmlguifactory.cpp #865752:865753
@@ -331,10 +331,31 @@
 
 void KXMLGUIFactoryPrivate::saveDefaultActionProperties(KXMLGUIClient *client)
 {
+    // This method is called once during application initialization. At this
+    // point no user configured shortcut were loaded. Therefore we expect all
+    // shortcuts we encounter to have empty custom shortcuts.
     foreach (QAction *action, client->actionCollection()->actions())
     {
         if (KAction* kaction = qobject_cast<KAction*>(action))
-            kaction->setProperty("DefaultShortcut", \
kaction->shortcut(KAction::DefaultShortcut)); +        {
+            // Check if the default shortcut is set
+            KShortcut defaultShortcut = kaction->shortcut(KAction::DefaultShortcut);
+            KShortcut activeShortcut  = kaction->shortcut(KAction::ActiveShortcut);
+
+            // Check if we have an empty default shortcut and an non empty
+            // custom shortcut. This should only happen if a developer called
+            // QAction::setShortcut on an KAction. Print out a warning and
+            // correct the mistake
+            if ((!activeShortcut.isEmpty()) && defaultShortcut.isEmpty())
+            {
+                kError() << "Shortcut for KAction " << kaction->objectName() << \
kaction->text() << "set with QShortcut::setShortcut()! See KAction documentation."; + \
kaction->setProperty("DefaultShortcut", activeShortcut); +            }
+            else
+            {
+                kaction->setProperty("DefaultShortcut", defaultShortcut);
+            }
+        }
     }
 }
 


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

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