[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-30 22:03:48
Message-ID: 1222812228.076595.7721.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 866452 by mjansen:

Fix the QAction::setShortcut hack and shortcut schemes after some input by
David. The method addClient is called every time a kxmlguiclient is
activated. Ensure saveDefaultActionProperties only works on each action
once.

I couldn't use configureAction because it's only called for action with
non default settings which means none in the most cases.

 M  +16 -6     kxmlguifactory.cpp  


--- trunk/KDE/kdelibs/kdeui/xmlgui/kxmlguifactory.cpp #866451:866452
@@ -331,11 +331,14 @@
 
 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.
+    // This method is called every time the user activated a new
+    // kxmlguiclient. We only want to execute the following code only once in
+    // the lifetime of an action.
     foreach (QAction *action, client->actionCollection()->actions())
     {
+        // Skip actions we have seen already.
+        if (action->property("_k_DefaultShortcut").isValid()) continue;
+
         if (KAction* kaction = qobject_cast<KAction*>(action))
         {
             // Check if the default shortcut is set
@@ -349,13 +352,20 @@
             if ((!activeShortcut.isEmpty()) && defaultShortcut.isEmpty())
             {
                 kError() << "Shortcut for KAction " << kaction->objectName() << \
                kaction->text() << "set with QShortcut::setShortcut()! See KAction \
                documentation.";
-                kaction->setProperty("DefaultShortcut", activeShortcut);
+                kaction->setProperty("_k_DefaultShortcut", activeShortcut);
             }
             else
             {
-                kaction->setProperty("DefaultShortcut", defaultShortcut);
+                kaction->setProperty("_k_DefaultShortcut", defaultShortcut);
             }
         }
+        else
+        {
+            // A QAction used with KXMLGUI? Set our property and ignore it.
+            kError() << "Attempt to use QAction" << action->objectName() << "with \
KXMLGUIFactory!"; +            action->setProperty("_k_DefaultShortcut", \
KShortcut()); +        }
+
     }
 }
 
@@ -674,7 +684,7 @@
         {
             if (KAction *kaction = qobject_cast<KAction*>(action))
             {
-                QVariant savedDefaultShortcut = \
kaction->property("DefaultShortcut"); +                QVariant savedDefaultShortcut \
= kaction->property("_k_DefaultShortcut");  if (savedDefaultShortcut.isValid())
                 {
                     KShortcut shortcut = savedDefaultShortcut.value<KShortcut>();


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

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