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

List:       kde-commits
Subject:    KDE/kdelibs/kdeui
From:       Andreas Hartmetz <ahartmetz () gmail ! com>
Date:       2008-01-04 0:03:09
Message-ID: 1199404989.139809.21893.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 757034 by ahartmetz:

As discussed on k-c-d, only use the text() of an action as a fallback identifier in \
the context of global shortcuts when the more robust objectName() is empty.

 M  +11 -1     actions/kaction.h  
 M  +16 -8     shortcuts/kglobalaccel.cpp  


--- trunk/KDE/kdelibs/kdeui/actions/kaction.h #757033:757034
@@ -341,7 +341,7 @@
      * Unlike regular shortcuts, the application's window does not need focus
      * for them to be activated.
      *
-     * When an action, identified by main component name and text(), is assigned
+     * When an action is assigned
      * a global shortcut for the first time on a KDE installation the assignment \
                will
      * be saved. The shortcut will then be restored every time the action's 
      * globalShortcutAllowed flag becomes true.
@@ -353,6 +353,16 @@
      * setGlobalShortcut(KShortcut(), KAction::ActiveShortcut | \
                KAction::DefaultShortcut,
      *                   KAction::NoAutoloading)
      * \endcode
+     * Note that actions will be recognized by their objectName() internally.
+     * In case of an empty objectName() text() will be used as a fallback.
+     * This fallback should be avoided if possible because it breaks
+     * when the application language is changed.
+     * Inserting an action into a KActionCollection with
+     * QAction *KActionCollection::addAction(const QString &name, QAction *action) \
or +     * KAction *KActionCollection::addAction(const QString &name, KAction \
*action) +     * will set the objectName() to @p name so you don't have to explicitly \
set an +     * objectName after you have already done that.
+
      * \param shortcut global shortcut(s) to assign
      * \param type the type of shortcut to be set, whether the active shortcut, the \
                default shortcut,
      *             or both (the default).
--- trunk/KDE/kdelibs/kdeui/shortcuts/kglobalaccel.cpp #757033:757034
@@ -144,11 +144,15 @@
     if (oldEnabled == newEnabled)
         return;
 
-    if (action->text().isEmpty())
-        return;
+    QString actionName(action->objectName());
+    if (actionName.isEmpty()) {
+        if (action->text().isEmpty()) {
+            return;
+        }
+        actionName = action->text();    //### breaks badly on change of language
+    }
     QStringList actionId(mainComponentName);
-    actionId.append(action->text());
-    //TODO: what about i18ned names?
+    actionId.append(actionName);
 
     if (!oldEnabled && newEnabled) {
         uint setterFlags = KdedGlobalAccel::SetPresent;
@@ -180,11 +184,15 @@
     if (!action)
         return;
 
-    if (action->text().isEmpty())
-        return;
+    QString actionName(action->objectName());
+    if (actionName.isEmpty()) {
+        if (action->text().isEmpty()) {
+            return;
+        }
+        actionName = action->text();    //### breaks badly on change of language
+    }
     QStringList actionId(mainComponentName);
-    actionId.append(action->text());
-    //TODO: what about i18ned names?
+    actionId.append(actionName);
 
     uint setterFlags = 0;
     if (flags & KAction::NoAutoloading)


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

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